@streamlayer/sdk-web 0.32.3 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +15 -20
- package/lib/es/index.js +2798 -3426
- package/lib/index.d.ts +1 -1
- package/package.json +14 -15
package/lib/cjs/index.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});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(de.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 a of s)this.attempt=0,this.onData(a)}catch(i){i instanceof te.ConnectError&&i.code!=te.Code.Canceled&&this.onStreamError(i)}})(),this.updateState(de.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(de.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(de.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(de.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 te.ConnectError&&e.code!==te.Code.Canceled){this.updateState(de.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}const wi=oi.pino({level:"trace",enabled:!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ct=(t,e)=>wi.child({name:t},e),bi=new Set([te.Code.Unknown,te.Code.Internal,te.Code.DeadlineExceeded,te.Code.ResourceExhausted,te.Code.FailedPrecondition,te.Code.Unavailable,te.Code.DataLoss]),Dr=ct("grpc:retry"),vi=t=>async e=>{const r=e.contextValues.get(sr.retryAttempts),i=300,s=e.contextValues.get(sr.retryDelay);if(e.stream||r===0)return t(e);Dr.trace({url:e.url,attempts:r,maxDelay:s},"retry options");for(let a=0;;a++)try{return await t(e)}catch(l){Dr.trace({attempt:a,error:l},"retry attempt");const d=te.ConnectError.from(l);if(a>=r||!(d instanceof te.ConnectError)||!bi.has(d.code))throw l;const h=Math.min(s,Math.pow(2,a)*i),m=Math.round(h*(1+Math.random())/2);await new Promise(c=>setTimeout(c,m))}},sr={retryAttempts:te.createContextKey(5,{description:"Number of attempts to retry"}),retryDelay:te.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},Si=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=ii.nanoid();return localStorage.setItem("sl-device-id",e),e};class Ai{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(Ce({"sl-device-id":Si()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.callbackClients=new Map,this.subscriptions=new Map;const[r,i,s]=Rr.nanoquery();this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:s},this.transport=Pr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=Pr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,i)=>{const s=this.subscriptions.get(r);if(s)return s;const a=new mi(this.$headers,e,r,i);return this.subscriptions.set(r,a),a};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[s,a]of this.subscriptions)a.disconnect(),this.subscriptions.delete(s);this.clients.clear(),this.callbackClients.clear(),this.subscriptions.clear();const[e,r,i]=Rr.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=te.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=te.createPromiseClient(e,this.streamTransport);return this.clients.set(r,i),i};createPromiseClient=(e,{params:r=[],method:i})=>{const s=this.getClient(e),a=e.methods[i].name,l=[e.typeName,a.charAt(0).toLowerCase()+a.slice(1),...Array.isArray(r)?r:[r]],d=[e.typeName,a.charAt(0).toLowerCase()+a.slice(1)];return{client:s,createRequestOptions:m=>{const c=te.createContextValues();for(const w in m){const E=sr[w];c.set(E,m[w])}return c},queryKey:l,queryKeyStr:d.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 a in s)i.header.set(a,s[a]);return r(i)};this.interceptors.push(e),this.interceptors.push(gi()),this.interceptors.push(vi)}}const Ei=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(si.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,a,l)=>{if(!l||typeof l!="string")return"";try{return(await r.retrieveEventId({id:l})).data?.id||""}catch{return""}}})},Ii=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(mt.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,a,l)=>l?(await r.getStream({id:l})).data?.attributes:void 0})},Ti=(t,e)=>{const{queryKey:r,client:i}=e.createPromiseClient(mr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>i.me({})})},Oi=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(mr.Users,{method:"bypassAuth"}),i=r({retryAttempts:0});return async({userKey:s,schema:a,init:l,inviterKey:d})=>{const h=await e.bypassAuth({userKey:s,schema:a,init:l},{contextValues:i});return h.meta&&(h.meta.inviterKey=d),h}},_i=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(mt.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.get({})).data?.attributes})},Fi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(mt.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}})},Ci=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(mt.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},ki=(t,e,r)=>{t.transport=new Ai(e.host),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),r()};class Rt{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 Ie;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(Ie||(Ie={}));class Ze extends Rt{constructor(){super("user")}setSchema=e=>{this.write(Ie.SCHEMA,e)};getSchema=()=>this.read(Ie.SCHEMA);setToken=e=>{this.write(Ie.TOKEN,e)};getToken=()=>this.read(Ie.TOKEN);setExternalToken=e=>{this.write(Ie.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(Ie.EXTERNAL_TOKEN);removeToken=()=>{this.remove(Ie.TOKEN)}}var Oe;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(Oe||(Oe={}));const xi=t=>{const e=new Ze,r=new se(ie(e.getExternalToken()),"userKey"),i=new se(ie(e.getToken()),"userToken"),s=new he(Ti(i.getStore(),t),"user",({data:l,error:d,loading:h},m)=>{if(!d)return l?.data?.id?l.data.id:h===!1?void 0:m}),a=new he(_i(i.getStore(),t),"userSettings");return{userKey:r,userToken:i,user:s,userSettings:a}},Li=t=>{const e=new se(ie(void 0),"providerStreamId"),r=new he(Ei(e.getStore(),t),"slStreamId",s=>s?.data),i=new he(Ii(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(s=>{(s===""||s===void 0)&&i.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:i}},Bi=t=>{const e=new se(ie(void 0),"enabled"),r=new se(ie(Oe.DISABLED),"status"),i=new he(Fi(e.getStore(),t),"organizationSettings",d=>d?.data?.id),s=new he(Ci(i.getAtomStore(),t),"organizationAdvertising"),a=xi(t),l=Li(t);return{enabled:e,status:r,providerStreamId:l.providerStreamId,slStreamId:l.slStreamId,streamSettings:l.streamSettings,user:a.user,userKey:a.userKey,userToken:a.userToken,userSettings:a.userSettings,organizationSettings:i,organizationAdvertising:s}};class Pi extends Pt{stores;constructor(e){const r=Bi(e),i=hi(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 Ri extends Rt{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Nr="sldl",Dt="sldl_uid",mn="sldl_eid",wn="sldl_e_eid",Di=new Set([Dt,mn,wn]),$r=t=>{const e={},r={};for(const[i,s]of t)Di.has(i)?e[i]=s:r[i]=s;return{result:e,remain:r}},Ni=({hash:t,search:e})=>{if(t&&t.includes(Nr)){const r=new URLSearchParams(t.substr(1));return{hash:$r(r)}}if(e&&e.includes(Nr)){const r=new URLSearchParams(e);return{search:$r(r)}}return null},Ur=ct("deep_link"),we={debug:(...t)=>{Ur.debug(...t),console.log(...t)},trace:(...t)=>{Ur.trace(...t),console.log(...t)}},$i=(t,e)=>{const{hash:r,search:i}=window.location;if(we.debug({hash:r,search:i},"get deep link data from"),r||i){const s=Ni({hash:r,search:i});if(we.debug(s,"parse deep link result"),s){const{hash:a,search:l}=s,{result:d,remain:h}=a||l;if(Object.keys(d).length!==0){t.setValue("data",d);const m=Object.keys(h).length!==0;if(a){let c="";m&&(c=`#${new URLSearchParams(h).toString()}`,we.debug({updatedHash:c},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+c)}if(l){let c="";m&&(c=`?${new URLSearchParams(h).toString()}`,we.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(d)}}}t.setValue("parsed",!0)},Ui=(t,e,r)=>{const i=new Ri,s=i.get("sl-deep-link-store");let a={};if(s)try{a=JSON.parse(s)}catch(d){we.debug(d)}t.deepLink={$store:new nt(Ce(a),"deep-link-context"),getDeepLinkData:()=>{const{data:d,used:h}=t.deepLink.$store.getValues();return{data:d,used:h}},deepLinkUsed:d=>{we.debug(`logged in with inviterId: ${d}`),t.deepLink.$store.setValue("used",!0)},onDeepLinkHandlers:new Set},t.sdk.getInviter=()=>{const{data:d,used:h}=t.deepLink.getDeepLinkData();return h?d?.[Dt]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),i.del("sl-deep-link-store")},t.deepLink.$store.subscribe(d=>i.set("sl-deep-link-store",JSON.stringify(d))),t.sdk.addDeepLinkHandler=d=>{we.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(d)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=d=>{we.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(d)};const l=d=>{t.deepLink.$store.setValue("handled",!0),we.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const h of t.deepLink.onDeepLinkHandlers)try{we.trace("called handler"),h(d)}catch(m){console.error(m)}};$i(t.deepLink.$store,l),r()},ji=ct("bypass");class Vi extends di{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,i){super(),this.$coreStore=e,this.deepLink=i,this.transport=r,this.bypassLogin=Oi(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(),a=i?"":s?.[Dt];ji.debug({inviterKey:a},"login with inviterKey");const l=await this.bypassLogin({schema:e,userKey:r,inviterKey:a,init:!1}),d=l.meta?.jwt,h=l.data?.id;if(!d||!h)throw new Error("internal: token missing");return l.meta?.inviterKey&&this.deepLink.deepLinkUsed(l.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate(l),this.saveUser(d,h),d};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 a=s.id;this.saveUser(r,a)}});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 pt=new Ze,Mi=(t,e,r)=>{t.auth=new Vi(t.store,t.transport,t.deepLink),t.stores.status.listen(i=>{i===Oe.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(i,s)=>{if(!(pt.getSchema()===i&&pt.getExternalToken()===s&&t.transport.getHeader("authorization")))try{await t.auth.login(i,s),pt.setSchema(i),pt.setExternalToken(s)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),pt.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},qi=(t,e,r)=>{t.store=new Pi(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()},jr=ct("video_player"),vt={debug:(...t)=>{jr.debug(...t),console.log(...t)},trace:(...t)=>{jr.trace(...t),console.log(...t)}},Qi=(t,e,r)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=i=>{vt.trace("adding video player controller"),t.videoPlayer.controllers.add(i)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=i=>{vt.trace("removing video player controller"),t.videoPlayer.controllers.delete(i)},t.sdk.controlVideoPlayer=i=>{vt.trace("controlling video player");for(const s of t.videoPlayer.controllers){vt.trace("calling video player controller");try{s(i)}catch(a){console.error(a)}}},r()},Gi=(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(Oe.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(Oe.READY),{enabled:!!s}):(t.stores.status.setValue(Oe.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(Oe.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(Oe.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()},zi=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(fn.Leaderboard,{method:"summary",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(a,l,d,h)=>(await i.summary({eventId:d,userId:h})).data?.attributes})},Ki=t=>{const{client:e}=t.createPromiseClient(fn.Leaderboard,{method:"list"});return r=>e.list(r)},Wi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(mr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,a,l)=>l?(await r.getFriends({})).data:[]})},Hi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(xe.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,a,l)=>(await r.get({eventId:l})).data?.attributes})},Ji=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(xe.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,a,l)=>l?(await r.syncQuestion({filter:{eventId:l}})).data?.attributes:void 0})},Yi=(t,e)=>{const{client:r}=e.createStreamClient(xe.Feed),i=ke.atom({eventId:t.get()||"",feedId:""});return t.subscribe((a="")=>{i.set({eventId:a,feedId:""})}),e.addSubscription(r.subscription,i,{name:"feedSubscription"})},Xi=(t,e)=>{const{client:r}=e.createStreamClient(xe.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},bn=async(t,e)=>{const{client:r}=e.createPromiseClient(xe.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},Zi=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(xe.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(a,l,d,h)=>d?(await i.list({eventId:d,filter:{types:h===Qe.ALLOWED?[]:[ne.QuestionType.FACTOID,ne.QuestionType.PROMOTION,ne.QuestionType.TWEET],statuses:[ne.QuestionStatus.ACTIVE,ne.QuestionStatus.RESOLVED]}})).data:[]})};var vn={},Nt={};Nt.byteLength=ro;Nt.toByteArray=io;Nt.fromByteArray=ao;var be=[],ae=[],eo=typeof Uint8Array<"u"?Uint8Array:Array,qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var He=0,to=qt.length;He<to;++He)be[He]=qt[He],ae[qt.charCodeAt(He)]=He;ae[45]=62;ae[95]=63;function Sn(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 ro(t){var e=Sn(t),r=e[0],i=e[1];return(r+i)*3/4-i}function no(t,e,r){return(e+r)*3/4-r}function io(t){var e,r=Sn(t),i=r[0],s=r[1],a=new eo(no(t,i,s)),l=0,d=s>0?i-4:i,h;for(h=0;h<d;h+=4)e=ae[t.charCodeAt(h)]<<18|ae[t.charCodeAt(h+1)]<<12|ae[t.charCodeAt(h+2)]<<6|ae[t.charCodeAt(h+3)],a[l++]=e>>16&255,a[l++]=e>>8&255,a[l++]=e&255;return s===2&&(e=ae[t.charCodeAt(h)]<<2|ae[t.charCodeAt(h+1)]>>4,a[l++]=e&255),s===1&&(e=ae[t.charCodeAt(h)]<<10|ae[t.charCodeAt(h+1)]<<4|ae[t.charCodeAt(h+2)]>>2,a[l++]=e>>8&255,a[l++]=e&255),a}function oo(t){return be[t>>18&63]+be[t>>12&63]+be[t>>6&63]+be[t&63]}function so(t,e,r){for(var i,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),s.push(oo(i));return s.join("")}function ao(t){for(var e,r=t.length,i=r%3,s=[],a=16383,l=0,d=r-i;l<d;l+=a)s.push(so(t,l,l+a>d?d:l+a));return i===1?(e=t[r-1],s.push(be[e>>2]+be[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],s.push(be[e>>10]+be[e>>4&63]+be[e<<2&63]+"=")),s.join("")}var wr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */wr.read=function(t,e,r,i,s){var a,l,d=s*8-i-1,h=(1<<d)-1,m=h>>1,c=-7,w=r?s-1:0,E=r?-1:1,T=t[e+w];for(w+=E,a=T&(1<<-c)-1,T>>=-c,c+=d;c>0;a=a*256+t[e+w],w+=E,c-=8);for(l=a&(1<<-c)-1,a>>=-c,c+=i;c>0;l=l*256+t[e+w],w+=E,c-=8);if(a===0)a=1-m;else{if(a===h)return l?NaN:(T?-1:1)*(1/0);l=l+Math.pow(2,i),a=a-m}return(T?-1:1)*l*Math.pow(2,a-i)};wr.write=function(t,e,r,i,s,a){var l,d,h,m=a*8-s-1,c=(1<<m)-1,w=c>>1,E=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=i?0:a-1,F=i?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(d=isNaN(e)?1:0,l=c):(l=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-l))<1&&(l--,h*=2),l+w>=1?e+=E/h:e+=E*Math.pow(2,1-w),e*h>=2&&(l++,h/=2),l+w>=c?(d=0,l=c):l+w>=1?(d=(e*h-1)*Math.pow(2,s),l=l+w):(d=e*Math.pow(2,w-1)*Math.pow(2,s),l=0));s>=8;t[r+T]=d&255,T+=F,d/=256,s-=8);for(l=l<<s|d,m+=s;m>0;t[r+T]=l&255,T+=F,l/=256,m-=8);t[r+T-F]|=k*128};/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/(function(t){const e=Nt,r=wr,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=C,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:a,ArrayBuffer:l,SharedArrayBuffer:d}=globalThis;c.TYPED_ARRAY_SUPPORT=h(),!c.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 h(){try{const u=new a(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,a.prototype),Object.setPrototypeOf(u,n),u.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function m(u){if(u>s)throw new RangeError('The value "'+u+'" is invalid for option "size"');const n=new a(u);return Object.setPrototypeOf(n,c.prototype),n}function c(u,n,o){if(typeof u=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(u)}return w(u,n,o)}c.poolSize=8192;function w(u,n,o){if(typeof u=="string")return k(u,n);if(l.isView(u))return I(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(ye(u,l)||u&&ye(u.buffer,l)||typeof d<"u"&&(ye(u,d)||u&&ye(u.buffer,d)))return _(u,n,o);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const f=u.valueOf&&u.valueOf();if(f!=null&&f!==u)return c.from(f,n,o);const p=j(u);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return c.from(u[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 u)}c.from=function(u,n,o){return w(u,n,o)},Object.setPrototypeOf(c.prototype,a.prototype),Object.setPrototypeOf(c,a);function E(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function T(u,n,o){return E(u),u<=0?m(u):n!==void 0?typeof o=="string"?m(u).fill(n,o):m(u).fill(n):m(u)}c.alloc=function(u,n,o){return T(u,n,o)};function F(u){return E(u),m(u<0?0:B(u)|0)}c.allocUnsafe=function(u){return F(u)},c.allocUnsafeSlow=function(u){return F(u)};function k(u,n){if((typeof n!="string"||n==="")&&(n="utf8"),!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const o=x(u,n)|0;let f=m(o);const p=f.write(u,n);return p!==o&&(f=f.slice(0,p)),f}function D(u){const n=u.length<0?0:B(u.length)|0,o=m(n);for(let f=0;f<n;f+=1)o[f]=u[f]&255;return o}function I(u){if(ye(u,a)){const n=new a(u);return _(n.buffer,n.byteOffset,n.byteLength)}return D(u)}function _(u,n,o){if(n<0||u.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');let f;return n===void 0&&o===void 0?f=new a(u):o===void 0?f=new a(u,n):f=new a(u,n,o),Object.setPrototypeOf(f,c.prototype),f}function j(u){if(c.isBuffer(u)){const n=B(u.length)|0,o=m(n);return o.length===0||u.copy(o,0,0,n),o}if(u.length!==void 0)return typeof u.length!="number"||Mt(u.length)?m(0):D(u);if(u.type==="Buffer"&&Array.isArray(u.data))return D(u.data)}function B(u){if(u>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return u|0}function C(u){return+u!=u&&(u=0),c.alloc(+u)}c.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==c.prototype},c.compare=function(n,o){if(ye(n,a)&&(n=c.from(n,n.offset,n.byteLength)),ye(o,a)&&(o=c.from(o,o.offset,o.byteLength)),!c.isBuffer(n)||!c.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,p=o.length;for(let y=0,b=Math.min(f,p);y<b;++y)if(n[y]!==o[y]){f=n[y],p=o[y];break}return f<p?-1:p<f?1:0},c.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}},c.concat=function(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return c.alloc(0);let f;if(o===void 0)for(o=0,f=0;f<n.length;++f)o+=n[f].length;const p=c.allocUnsafe(o);let y=0;for(f=0;f<n.length;++f){let b=n[f];if(ye(b,a))y+b.length>p.length?(c.isBuffer(b)||(b=c.from(b)),b.copy(p,y)):a.prototype.set.call(p,b,y);else if(c.isBuffer(b))b.copy(p,y);else throw new TypeError('"list" argument must be an Array of Buffers');y+=b.length}return p};function x(u,n){if(c.isBuffer(u))return u.length;if(l.isView(u)||ye(u,l))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);const o=u.length,f=arguments.length>2&&arguments[2]===!0;if(!f&&o===0)return 0;let p=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return ht(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Br(u).length;default:if(p)return f?-1:ht(u).length;n=(""+n).toLowerCase(),p=!0}}c.byteLength=x;function L(u,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(u||(u="utf8");;)switch(u){case"hex":return g(this,n,o);case"utf8":case"utf-8":return Ke(this,n,o);case"ascii":return Pe(this,n,o);case"latin1":case"binary":return We(this,n,o);case"base64":return Be(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: "+u);u=(u+"").toLowerCase(),f=!0}}c.prototype._isBuffer=!0;function q(u,n,o){const f=u[n];u[n]=u[o],u[o]=f}c.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},c.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},c.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},c.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Ke(this,0,n):L.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(n){if(!c.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:c.compare(this,n)===0},c.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&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(n,o,f,p,y){if(ye(n,a)&&(n=c.from(n,n.offset,n.byteLength)),!c.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),p===void 0&&(p=0),y===void 0&&(y=this.length),o<0||f>n.length||p<0||y>this.length)throw new RangeError("out of range index");if(p>=y&&o>=f)return 0;if(p>=y)return-1;if(o>=f)return 1;if(o>>>=0,f>>>=0,p>>>=0,y>>>=0,this===n)return 0;let b=y-p,N=f-o;const W=Math.min(b,N),K=this.slice(p,y),H=n.slice(o,f);for(let z=0;z<W;++z)if(K[z]!==H[z]){b=K[z],N=H[z];break}return b<N?-1:N<b?1:0};function oe(u,n,o,f,p){if(u.length===0)return-1;if(typeof o=="string"?(f=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Mt(o)&&(o=p?0:u.length-1),o<0&&(o=u.length+o),o>=u.length){if(p)return-1;o=u.length-1}else if(o<0)if(p)o=0;else return-1;if(typeof n=="string"&&(n=c.from(n,f)),c.isBuffer(n))return n.length===0?-1:ve(u,n,o,f,p);if(typeof n=="number")return n=n&255,typeof a.prototype.indexOf=="function"?p?a.prototype.indexOf.call(u,n,o):a.prototype.lastIndexOf.call(u,n,o):ve(u,[n],o,f,p);throw new TypeError("val must be string, number or Buffer")}function ve(u,n,o,f,p){let y=1,b=u.length,N=n.length;if(f!==void 0&&(f=String(f).toLowerCase(),f==="ucs2"||f==="ucs-2"||f==="utf16le"||f==="utf-16le")){if(u.length<2||n.length<2)return-1;y=2,b/=2,N/=2,o/=2}function W(H,z){return y===1?H[z]:H.readUInt16BE(z*y)}let K;if(p){let H=-1;for(K=o;K<b;K++)if(W(u,K)===W(n,H===-1?0:K-H)){if(H===-1&&(H=K),K-H+1===N)return H*y}else H!==-1&&(K-=K-H),H=-1}else for(o+N>b&&(o=b-N),K=o;K>=0;K--){let H=!0;for(let z=0;z<N;z++)if(W(u,K+z)!==W(n,z)){H=!1;break}if(H)return K}return-1}c.prototype.includes=function(n,o,f){return this.indexOf(n,o,f)!==-1},c.prototype.indexOf=function(n,o,f){return oe(this,n,o,f,!0)},c.prototype.lastIndexOf=function(n,o,f){return oe(this,n,o,f,!1)};function Se(u,n,o,f){o=Number(o)||0;const p=u.length-o;f?(f=Number(f),f>p&&(f=p)):f=p;const y=n.length;f>y/2&&(f=y/2);let b;for(b=0;b<f;++b){const N=parseInt(n.substr(b*2,2),16);if(Mt(N))return b;u[o+b]=N}return b}function ce(u,n,o,f){return bt(ht(n,u.length-o),u,o,f)}function dt(u,n,o,f){return bt(Lr(n),u,o,f)}function pe(u,n,o,f){return bt(Br(n),u,o,f)}function Ne(u,n,o,f){return bt(ti(n,u.length-o),u,o,f)}c.prototype.write=function(n,o,f,p){if(o===void 0)p="utf8",f=this.length,o=0;else if(f===void 0&&typeof o=="string")p=o,f=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(f)?(f=f>>>0,p===void 0&&(p="utf8")):(p=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");p||(p="utf8");let b=!1;for(;;)switch(p){case"hex":return Se(this,n,o,f);case"utf8":case"utf-8":return ce(this,n,o,f);case"ascii":case"latin1":case"binary":return dt(this,n,o,f);case"base64":return pe(this,n,o,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ne(this,n,o,f);default:if(b)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),b=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Be(u,n,o){return n===0&&o===u.length?e.fromByteArray(u):e.fromByteArray(u.slice(n,o))}function Ke(u,n,o){o=Math.min(u.length,o);const f=[];let p=n;for(;p<o;){const y=u[p];let b=null,N=y>239?4:y>223?3:y>191?2:1;if(p+N<=o){let W,K,H,z;switch(N){case 1:y<128&&(b=y);break;case 2:W=u[p+1],(W&192)===128&&(z=(y&31)<<6|W&63,z>127&&(b=z));break;case 3:W=u[p+1],K=u[p+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=u[p+1],K=u[p+2],H=u[p+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,N=1):b>65535&&(b-=65536,f.push(b>>>10&1023|55296),b=56320|b&1023),f.push(b),p+=N}return le(f)}const Ae=4096;function le(u){const n=u.length;if(n<=Ae)return String.fromCharCode.apply(String,u);let o="",f=0;for(;f<n;)o+=String.fromCharCode.apply(String,u.slice(f,f+=Ae));return o}function Pe(u,n,o){let f="";o=Math.min(u.length,o);for(let p=n;p<o;++p)f+=String.fromCharCode(u[p]&127);return f}function We(u,n,o){let f="";o=Math.min(u.length,o);for(let p=n;p<o;++p)f+=String.fromCharCode(u[p]);return f}function g(u,n,o){const f=u.length;(!n||n<0)&&(n=0),(!o||o<0||o>f)&&(o=f);let p="";for(let y=n;y<o;++y)p+=ri[u[y]];return p}function v(u,n,o){const f=u.slice(n,o);let p="";for(let y=0;y<f.length-1;y+=2)p+=String.fromCharCode(f[y]+f[y+1]*256);return p}c.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 p=this.subarray(n,o);return Object.setPrototypeOf(p,c.prototype),p};function S(u,n,o){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+n>o)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let p=this[n],y=1,b=0;for(;++b<o&&(y*=256);)p+=this[n+b]*y;return p},c.prototype.readUintBE=c.prototype.readUIntBE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let p=this[n+--o],y=1;for(;o>0&&(y*=256);)p+=this[n+--o]*y;return p},c.prototype.readUint8=c.prototype.readUInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]|this[n+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]<<8|this[n+1]},c.prototype.readUint32LE=c.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},c.prototype.readUint32BE=c.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])},c.prototype.readBigUInt64LE=De(function(n){n=n>>>0,Ee(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&je(n,this.length-8);const p=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(p)+(BigInt(y)<<BigInt(32))}),c.prototype.readBigUInt64BE=De(function(n){n=n>>>0,Ee(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&je(n,this.length-8);const p=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(p)<<BigInt(32))+BigInt(y)}),c.prototype.readIntLE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let p=this[n],y=1,b=0;for(;++b<o&&(y*=256);)p+=this[n+b]*y;return y*=128,p>=y&&(p-=Math.pow(2,8*o)),p},c.prototype.readIntBE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let p=o,y=1,b=this[n+--p];for(;p>0&&(y*=256);)b+=this[n+--p]*y;return y*=128,b>=y&&(b-=Math.pow(2,8*o)),b},c.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]},c.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},c.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},c.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},c.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]},c.prototype.readBigInt64LE=De(function(n){n=n>>>0,Ee(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&je(n,this.length-8);const p=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(f<<24);return(BigInt(p)<<BigInt(32))+BigInt(o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),c.prototype.readBigInt64BE=De(function(n){n=n>>>0,Ee(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&je(n,this.length-8);const p=(o<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(p)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+f)}),c.prototype.readFloatLE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!0,23,4)},c.prototype.readFloatBE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!1,23,4)},c.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!0,52,8)},c.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!1,52,8)};function O(u,n,o,f,p,y){if(!c.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>p||n<y)throw new RangeError('"value" argument is out of bounds');if(o+f>u.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(n,o,f,p){if(n=+n,o=o>>>0,f=f>>>0,!p){const N=Math.pow(2,8*f)-1;O(this,n,o,f,N,0)}let y=1,b=0;for(this[o]=n&255;++b<f&&(y*=256);)this[o+b]=n/y&255;return o+f},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(n,o,f,p){if(n=+n,o=o>>>0,f=f>>>0,!p){const N=Math.pow(2,8*f)-1;O(this,n,o,f,N,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},c.prototype.writeUint8=c.prototype.writeUInt8=function(n,o,f){return n=+n,o=o>>>0,f||O(this,n,o,1,255,0),this[o]=n&255,o+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(n,o,f){return n=+n,o=o>>>0,f||O(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(n,o,f){return n=+n,o=o>>>0,f||O(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(n,o,f){return n=+n,o=o>>>0,f||O(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},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(n,o,f){return n=+n,o=o>>>0,f||O(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 V(u,n,o,f,p){Ue(n,f,p,u,o,7);let y=Number(n&BigInt(4294967295));u[o++]=y,y=y>>8,u[o++]=y,y=y>>8,u[o++]=y,y=y>>8,u[o++]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return u[o++]=b,b=b>>8,u[o++]=b,b=b>>8,u[o++]=b,b=b>>8,u[o++]=b,o}function M(u,n,o,f,p){Ue(n,f,p,u,o,7);let y=Number(n&BigInt(4294967295));u[o+7]=y,y=y>>8,u[o+6]=y,y=y>>8,u[o+5]=y,y=y>>8,u[o+4]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return u[o+3]=b,b=b>>8,u[o+2]=b,b=b>>8,u[o+1]=b,b=b>>8,u[o]=b,o+8}c.prototype.writeBigUInt64LE=De(function(n,o=0){return V(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=De(function(n,o=0){return M(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(n,o,f,p){if(n=+n,o=o>>>0,!p){const W=Math.pow(2,8*f-1);O(this,n,o,f,W-1,-W)}let y=0,b=1,N=0;for(this[o]=n&255;++y<f&&(b*=256);)n<0&&N===0&&this[o+y-1]!==0&&(N=1),this[o+y]=(n/b>>0)-N&255;return o+f},c.prototype.writeIntBE=function(n,o,f,p){if(n=+n,o=o>>>0,!p){const W=Math.pow(2,8*f-1);O(this,n,o,f,W-1,-W)}let y=f-1,b=1,N=0;for(this[o+y]=n&255;--y>=0&&(b*=256);)n<0&&N===0&&this[o+y+1]!==0&&(N=1),this[o+y]=(n/b>>0)-N&255;return o+f},c.prototype.writeInt8=function(n,o,f){return n=+n,o=o>>>0,f||O(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},c.prototype.writeInt16LE=function(n,o,f){return n=+n,o=o>>>0,f||O(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},c.prototype.writeInt16BE=function(n,o,f){return n=+n,o=o>>>0,f||O(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},c.prototype.writeInt32LE=function(n,o,f){return n=+n,o=o>>>0,f||O(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},c.prototype.writeInt32BE=function(n,o,f){return n=+n,o=o>>>0,f||O(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},c.prototype.writeBigInt64LE=De(function(n,o=0){return V(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=De(function(n,o=0){return M(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function R(u,n,o,f,p,y){if(o+f>u.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function $(u,n,o,f,p){return n=+n,o=o>>>0,p||R(u,n,o,4),r.write(u,n,o,f,23,4),o+4}c.prototype.writeFloatLE=function(n,o,f){return $(this,n,o,!0,f)},c.prototype.writeFloatBE=function(n,o,f){return $(this,n,o,!1,f)};function Q(u,n,o,f,p){return n=+n,o=o>>>0,p||R(u,n,o,8),r.write(u,n,o,f,52,8),o+8}c.prototype.writeDoubleLE=function(n,o,f){return Q(this,n,o,!0,f)},c.prototype.writeDoubleBE=function(n,o,f){return Q(this,n,o,!1,f)},c.prototype.copy=function(n,o,f,p){if(!c.isBuffer(n))throw new TypeError("argument should be a Buffer");if(f||(f=0),!p&&p!==0&&(p=this.length),o>=n.length&&(o=n.length),o||(o=0),p>0&&p<f&&(p=f),p===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(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),n.length-o<p-f&&(p=n.length-o+f);const y=p-f;return this===n&&typeof a.prototype.copyWithin=="function"?this.copyWithin(o,f,p):a.prototype.set.call(n,this.subarray(f,p),o),y},c.prototype.fill=function(n,o,f,p){if(typeof n=="string"){if(typeof o=="string"?(p=o,o=0,f=this.length):typeof f=="string"&&(p=f,f=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!c.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(n.length===1){const b=n.charCodeAt(0);(p==="utf8"&&b<128||p==="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=c.isBuffer(n)?n:c.from(n,p),N=b.length;if(N===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(y=0;y<f-o;++y)this[y+o]=b[y%N]}return this};const J={};function fe(u,n,o){J[u]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${u}]`,this.stack,delete this.name}get code(){return u}set code(p){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:p,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}fe("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),fe("ERR_INVALID_ARG_TYPE",function(u,n){return`The "${u}" argument must be of type number. Received type ${typeof n}`},TypeError),fe("ERR_OUT_OF_RANGE",function(u,n,o){let f=`The value of "${u}" is out of range.`,p=o;return Number.isInteger(o)&&Math.abs(o)>2**32?p=$e(String(o)):typeof o=="bigint"&&(p=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(p=$e(p)),p+="n"),f+=` It must be ${n}. Received ${p}`,f},RangeError);function $e(u){let n="",o=u.length;const f=u[0]==="-"?1:0;for(;o>=f+4;o-=3)n=`_${u.slice(o-3,o)}${n}`;return`${u.slice(0,o)}${n}`}function Re(u,n,o){Ee(n,"offset"),(u[n]===void 0||u[n+o]===void 0)&&je(n,u.length-(o+1))}function Ue(u,n,o,f,p,y){if(u>o||u<n){const b=typeof n=="bigint"?"n":"";let N;throw y>3?n===0||n===BigInt(0)?N=`>= 0${b} and < 2${b} ** ${(y+1)*8}${b}`:N=`>= -(2${b} ** ${(y+1)*8-1}${b}) and < 2 ** ${(y+1)*8-1}${b}`:N=`>= ${n}${b} and <= ${o}${b}`,new J.ERR_OUT_OF_RANGE("value",N,u)}Re(f,p,y)}function Ee(u,n){if(typeof u!="number")throw new J.ERR_INVALID_ARG_TYPE(n,"number",u)}function je(u,n,o){throw Math.floor(u)!==u?(Ee(u,o),new J.ERR_OUT_OF_RANGE(o||"offset","an integer",u)):n<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(o||"offset",`>= ${o?1:0} and <= ${n}`,u)}const Vt=/[^+/0-9A-Za-z-_]/g;function A(u){if(u=u.split("=")[0],u=u.trim().replace(Vt,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function ht(u,n){n=n||1/0;let o;const f=u.length;let p=null;const y=[];for(let b=0;b<f;++b){if(o=u.charCodeAt(b),o>55295&&o<57344){if(!p){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}p=o;continue}if(o<56320){(n-=3)>-1&&y.push(239,191,189),p=o;continue}o=(p-55296<<10|o-56320)+65536}else p&&(n-=3)>-1&&y.push(239,191,189);if(p=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 Lr(u){const n=[];for(let o=0;o<u.length;++o)n.push(u.charCodeAt(o)&255);return n}function ti(u,n){let o,f,p;const y=[];for(let b=0;b<u.length&&!((n-=2)<0);++b)o=u.charCodeAt(b),f=o>>8,p=o%256,y.push(p),y.push(f);return y}function Br(u){return e.toByteArray(A(u))}function bt(u,n,o,f){let p;for(p=0;p<f&&!(p+o>=n.length||p>=u.length);++p)n[p+o]=u[p];return p}function ye(u,n){return u instanceof n||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===n.name}function Mt(u){return u!==u}const ri=function(){const u="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const f=o*16;for(let p=0;p<16;++p)n[f+p]=u[o]+u[p]}return n}();function De(u){return typeof BigInt>"u"?ni:u}function ni(){throw new Error("BigInt not supported")}})(vn);const Vr=vn.Buffer;var An=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var br={exports:{}};const co=Object.getPrototypeOf({});function vr(t){function e(I){return I!=="constructor"&&I!=="prototype"&&I!=="__proto__"}function r(I){let _=0;const j=I.length,B=new Array(j);for(_=0;_<j;++_)B[_]=T(I[_]);return B}function i(I){const _={};if(h&&Object.getPrototypeOf(I)!==co)return h(I);const j=d(I);let B,C,x;for(B=0,C=j.length;B<C;++B)e(x=j[B])&&(_[x]=T(I[x]));return _}function s(I,_){const j=I.length,B=_.length;let C=0;const x=new Array(j+B);for(C=0;C<j;++C)x[C]=T(I[C]);for(C=0;C<B;++C)x[C+j]=T(_[C]);return x}const a=Object.prototype.propertyIsEnumerable;function l(I){const _=Object.keys(I),j=Object.getOwnPropertySymbols(I);for(let B=0,C=j.length;B<C;++B)a.call(I,j[B])&&_.push(j[B]);return _}const d=t&&t.symbols?l:Object.keys,h=typeof t?.cloneProtoObject=="function"?t.cloneProtoObject:void 0;function m(I){return typeof I=="object"&&I!==null&&!(I instanceof RegExp)&&!(I instanceof Date)}function c(I){return typeof I!="object"||I===null}const w=typeof Vr<"u"?I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date||I instanceof Vr:I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date,E=t&&typeof t.mergeArray=="function"?t.mergeArray({clone:T,deepmerge:k,getKeys:d,isMergeableObject:m}):s;function T(I){return m(I)?Array.isArray(I)?r(I):i(I):I}function F(I,_){const j={},B=d(I),C=d(_);let x,L,q;for(x=0,L=B.length;x<L;++x)e(q=B[x])&&C.indexOf(q)===-1&&(j[q]=T(I[q]));for(x=0,L=C.length;x<L;++x)e(q=C[x])&&(q in I&&(B.indexOf(q)!==-1&&(j[q]=k(I[q],_[q])),!0)||(j[q]=T(_[q])));return j}function k(I,_){const j=Array.isArray(_),B=Array.isArray(I);return c(_)?_:w(I)?T(_):j&&B?E(I,_):j!==B?T(_):F(I,_)}function D(){switch(arguments.length){case 0:return{};case 1:return T(arguments[0]);case 2:return k(arguments[0],arguments[1])}let I;for(let _=0,j=arguments.length;_<j;++_)I=k(I,arguments[_]);return I}return t&&t.all?D:k}br.exports=vr;br.exports.default=vr;var lo=br.exports.deepmerge=vr;const fo=t=>(e,r)=>{let i=0;const s=e.length,a=r.length,l=Math.max(s,a),d=new Array(l);for(i=0;i<l;++i)i<a?d[i]=t.deepmerge(e[i],r[i]):d[i]=t.clone(e[i]);return d},ho=lo({mergeArray:fo}),po=(t,e,r)=>{const i=ie(void 0);ke.onMount(i,()=>{const l=e.subscribe(h=>{if(h){if(h.question){i.set(h.question);return}const m=r.get().data?.find(c=>c.id===h.questionId);m?i.set(m):console.error("Feed list is not loaded yet. Issue with the opened question.")}else i.set(void 0)}),d=r.subscribe(h=>{const m=e.get();if(h.data&&m){const c=r.get().data?.find(w=>w.id===m.questionId);c?i.set(c):console.error("Feed list is not loaded yet. Issue with the opened question.")}});return()=>{l(),d()}});const s=Ce({data:void 0,loading:void 0,error:void 0});return i.subscribe(async l=>{if(l&&l.type==="question"){s.setKey("loading",!0);const d=await bn(l.id,t);s.set({data:d,loading:!1});return}s.set({data:void 0,loading:!1})}),{$store:i,$extendedStore:s,updateExtendedQuestion:l=>{const d=s.get().data;if(d&&l?.answers)for(const h of l.answers)h.youVoted!==!0&&delete h.youVoted;s.set({data:ho(d,l)})}}};var Qe;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Qe||(Qe={}));class yo{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;constructor(e){this.log=ct("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new se(ie(void 0),"moderationId").getStore(),this.interactiveAllowed=new se(ie(Qe.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new se(ie(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new he(Hi(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new he(Zi(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=new he(Ji(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=po(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.questionSubscription=Xi(r.questionId,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=Yi(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{const i=this.activeQuestionId.getStore();i&&(this.activeQuestionId,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()||"",a=e.entity||"",l=e.prefix||"";return[s,r,i,l,a].join(":")};disconnect=()=>{this.feedSubscription?.disconnect()};openQuestion=(e,r)=>{this.openedQuestionId.set({questionId:e,question:r}),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 go{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ct("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new se(ie(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[l]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(l),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,a=new Map(this.notifications.getValue());a.set(r.id,r),this.notifications.setValue(a);const l=setTimeout(()=>{this.logger.debug({notificationId:s,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(s)},r.autoHideDuration||5e3);this.timeouts.set(s,l),this.logger.debug({notificationId:s,queue:[...a.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 a=new Map(this.notifications.getValue());a.delete(e),this.notifications.setValue(a);const l=this.timeouts.get(e);l!==void 0&&(clearTimeout(l),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 Ft;(function(t){t.OPENED="opened"})(Ft||(Ft={}));class mo extends Rt{constructor(){super("notification")}setOpened=e=>{this.write(Ft.OPENED,e,"true")};isOpened=e=>this.read(Ft.OPENED,e);clearNotification=()=>{this.clear()}}var qe;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(qe||(qe={}));class wo{queue;storage;constructor(e={}){this.storage=new mo,this.queue=new go({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 bo=(t,e,r)=>{t.notifications=new wo,t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),r()},vo=(t,e)=>{const{client:r,createRequestOptions:i}=t.createPromiseClient(xe.Feed,{method:"submitAnswer"}),s=i({retryAttempts:0});return r.submitAnswer({data:e},{contextValues:s})},So=(t,e)=>{const{client:r,createRequestOptions:i}=t.createPromiseClient(xe.Feed,{method:"submitInplay"}),s=i({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:s})},Ao=(t,e)=>{const{client:r,createRequestOptions:i}=t.createPromiseClient(xe.Feed,{method:"skipQuestion"}),s=i({retryAttempts:0});return r.skipQuestion({data:{id:e}},{contextValues:s})};var et;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(et||(et={}));class En extends Rt{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 Mr={pageSize:10},Eo=(t,e,r,i,s)=>{let a=0;const l=ie({pageSize:s?.pageSize||Mr.pageSize,page:0}),d=Ce({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),h=Ki(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),d.setKey("loading",!0),d.setKey("data",[]);const k={eventId:E,usersIds:T,pagination:{page:0,pageSize:s?.pageSize||Mr.pageSize}},D=await h(k);d.set({data:D.data.map(I=>I.attributes),hasMore:!0,key:Date.now(),loading:!1}),D.meta&&(a=Math.round(D.meta.count/D.meta.pageSize)),l.set(k.pagination)}},c=()=>{m()},w=E=>{const T=l.get(),F=E||T.page+1;F<=a&&l.set({...T,page:F})};return ke.onMount(d,()=>{const E=e.listen(m),T=i.listen(m),F=l.listen(async k=>{const D=e.get();if(k.page>0&&D)if(k.page<a){d.setKey("loading",!0);const _=await h({eventId:D,pagination:k}),j=d.get().data||[];d.set({data:[...j,..._.data.map(B=>B.attributes)],key:d.get().key,loading:!1,hasMore:!0})}else d.setKey("hasMore",!1)});return()=>{E(),T(),F()}}),{$store:d,fetchMore:w,invalidate:c}},Io=(t,e)=>{const{client:r,queryKey:i}=t.createPromiseClient(mt.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(i,{fetcher:async(s,a,l,d)=>l?(await r.generateDeepLink({data:{gamification:!0,externalEventId:d,eventId:l}})).data?.attributes:{}})},To=(t,{web:e,mobile:r})=>{const{client:i}=t.createPromiseClient(ai.LinksClient,{method:"generate"});return i.generate({web:e,mobile:r})},qr=(t,e)=>{const r=new URLSearchParams(t);for(const[i,s]of Object.entries(e))r.append(i,s);return r.toString()},Oo=(t,e,r,i)=>{const s=Ce({});return ke.onMount(s,()=>Io(t,[e,r]).subscribe(async({data:d,error:h,loading:m})=>{const c=h?"https://masters.com":d?.url,w=i.get()||"",E=e.get()||"",T=r.get()||"",F={[Dt]:w,[mn]:E,[wn]:T};if(!m&&c){s.setKey("loading",!0);let k=window.location.search,D=window.location.hash;k&&D||D?k=`?${qr(k,F)}`:D=`#${qr("",F)}`;const I=window.location.origin+window.location.pathname+k+D,_=await To(t,{web:I,mobile:c});s.set({data:_.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 _o=(t,e,r,i)=>{const{inplayGame:s}=t.featureSettings.get(),a=e.getCurrentSessionId({prefix:"onboarding"});s&&r.add({type:qe.ONBOARDING,id:a,action:t.openFeature,persistent:!0,autoHideDuration:1e6,data:{questionType:ne.QuestionType.UNSET,onboarding:{...s,instantOpen:!i.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},St=(t,e,r,i,s,a)=>{try{const l=e.userId.get();if(!l)return;if(s.getOnboardingStatus({userId:l,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===ee.Completed){t.set(ee.Completed);for(const E of a)E();return}const h=e.moderation.getStore().value?.data,m=r.featureSettings.get().inplayGame;if(h===void 0||m===void 0)return;const c=h?.options?.onboardingEnabled,w=m?.titleCard?.optIn;c?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(l){console.error(l)}},Fo=(t,e,r,i)=>{let s=!1;const a=new En,l=ie(ee.Unset);l.subscribe(m=>{m!==ee.Unset&&((m===ee.Optional||m===ee.Required)&&s===!1&&(_o(t,e,i,a),s=!0),m===ee.Completed&&e.activeQuestionId.invalidate(),a.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const d=[];return St(l,e,t,i,a,d),l.get()!==ee.Completed&&(d.push(e.userId.listen(m=>{m&&St(l,e,t,i,a,d)})),d.push(e.moderation.listen(m=>{m.data&&St(l,e,t,i,a,d)})),d.push(t.featureSettings.listen(m=>{m&&St(l,e,t,i,a,d)}))),{$store:l,submitInplay:async()=>{const m=e.slStreamId.get();if(m){await So(r,m),l.set(ee.Completed),a.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:m},ee.Completed);const c=e.getCurrentSessionId({prefix:"onboarding"});i.close(c)}}}},Co=new Set([ne.QuestionType.POLL,ne.QuestionType.PREDICTION,ne.QuestionType.TRIVIA]);class ko extends gn{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 yo(i),this.storage=new En,this.userSummary=new he(zi(this.background.slStreamId,this.background.userId,i.transport),"gamification:userSummary"),this.feedList=this.background.feedList,this.friends=new he(Wi(this.background.userId,i.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=ie(void 0),this.leaderboardId=new se(ie(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=Fo(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(_e.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=Oo(this.transport,this.background.slStreamId,i.stores.providerStreamId.getStore(),this.background.userId),this.leaderboardList=Eo(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,a=!r||s||i!==!0;this.background.interactiveAllowed.set(a?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,s=r.data?.attributes?.feedItem;if(!i)return;const{status:a,type:l,id:d}=i;if(a===ne.QuestionStatus.RESOLVED&&l===ne.QuestionType.PREDICTION){const h=this.background.getCurrentSessionId({prefix:`notification-id:${d}`}),m=await bn(d,e),c=m?.answers.find(({correct:E})=>E),w=m?.answers.find(({youVoted:E})=>E);if(!w||!m)return;this.notifications.add({type:qe.QUESTION_RESOLVED,action:()=>this.openQuestion(m.id,s),close:()=>this.closeQuestion(d),autoHideDuration:c?.youVoted?15e3:12e3,id:h,data:{questionType:ne.QuestionType.PREDICTION,question:{title:c?.youVoted?`Congratulations! You answered correctly! You won ${c.points} pts!`:`Better luck next time! Correct: ${c?.text}!`,votedAnswer:{title:w?.text,points:w?.points},correctAnswerTitle:c?.text,correct:c?.youVoted,predictionResult:a===ne.QuestionStatus.RESOLVED,questionTitle:m?.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 vo(this.transport,{questionId:e,answerId:r}),this.feedList.invalidate(),this.userSummary.invalidate()};skipQuestion=async e=>{await Ao(this.transport,e),this.feedList.invalidate(),this.userSummary.invalidate()};openQuestion=(e,r)=>(this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e})),this.background.openQuestion(e,r));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!==ne.SilenceSetting.ON&&e.data.question.status===ne.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Co.has(e.data.question.type))this.isInteractiveAllowed&&this.notifications.add({type:qe.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),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===ne.QuestionType.FACTOID){const i=e.data.question.options?.options.value,s={heading:e.data.question.notification.title,body:e.data.question.notification.body,imageMode:i.imageMode,image:i?.image,video:{id:i?.video?.id||"",url:i?.video?.url||"",thumbnailUrl:i?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:qe.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),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===ne.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,tweetId:e.data.question.id};this.notifications.add({type:qe.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),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 xo={[_e.SdkOverlayType.GAMES]:!0};class Lo extends gn{constructor(e,r){super(e,r)}}const Bo=(t,e,r)=>t.type===_e.SdkOverlayType.GAMES?new ko(t,e,r):new Lo(t,e),Po=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new se(ie(new Set),"features-list"),t.activeFeature=new se(ie(_e.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();if(t.activeFeature.setValue(_e.SdkOverlayType.UNSET),i&&s){t.features.delete(s);const a=t.sdk.featuresList.getValue();a&&a.delete(s),t.sdk.featuresList.setValue(a)}},t.initFeature=(i,s=Te.ORGANIZATION)=>{if(i.type in xo&&!t.features.has(i.type)){const a=Bo(i,s,t);t.features.set(i.type,a);let l=t.sdk.featuresList.getValue();l?l.add(i.type):l=new Set([i.type]),t.sdk.featuresList.setValue(new Set(l))}},t.updateFeature=(i,s)=>{t.features.get(i.type)?.update(i,s)},t.destroyFeature=i=>{t.features.delete(i.type);const s=t.sdk.featuresList.getValue();s&&s.delete(i.type),t.sdk.featuresList.setValue(new Set(s))},t.reinitializeFeatures=async()=>{const i=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const s of i?.overlays||[])t.initFeature(s,Te.ORGANIZATION)},t.stores.providerStreamId.listen(i=>{i||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const i=(a,l)=>{if(l?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&a===Te.ORGANIZATION))for(const d of l.overlays)d.sdkEnable===!0&&(t.features.has(d.type)?t.updateFeature(d,a):t.initFeature(d,a))},s={organizationSettings:a=>{if(a.data)try{i(Te.ORGANIZATION,a.data)}catch(l){console.log(l)}},streamSettings:a=>{if(a.data)try{i(Te.STREAM,a.data)}catch(l){console.log(l)}}};t.store.subscribe(s)},r()};var Sr={exports:{}},Ar={exports:{}};function Ro(t){var e=new t,r=e;function i(){var a=e;return a.next?e=a.next:(e=new t,r=e),a.next=null,a}function s(a){r.next=a,r=a}return{get:i,release:s}}var Do=Ro,No=Do;function In(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=No($o),s=null,a=null,l=0,d=null,h={push:k,drain:ue,saturated:ue,pause:c,paused:!1,concurrency:r,running:m,resume:T,idle:F,length:w,getQueue:E,unshift:D,empty:ue,kill:_,killAndDrain:j,error:B};return h;function m(){return l}function c(){h.paused=!0}function w(){for(var C=s,x=0;C;)C=C.next,x++;return x}function E(){for(var C=s,x=[];C;)x.push(C.value),C=C.next;return x}function T(){if(h.paused){h.paused=!1;for(var C=0;C<h.concurrency;C++)l++,I()}}function F(){return l===0&&h.length()===0}function k(C,x){var L=i.get();L.context=t,L.release=I,L.value=C,L.callback=x||ue,L.errorHandler=d,l===h.concurrency||h.paused?a?(a.next=L,a=L):(s=L,a=L,h.saturated()):(l++,e.call(t,L.value,L.worked))}function D(C,x){var L=i.get();L.context=t,L.release=I,L.value=C,L.callback=x||ue,L.errorHandler=d,l===h.concurrency||h.paused?s?(L.next=s,s=L):(s=L,a=L,h.saturated()):(l++,e.call(t,L.value,L.worked))}function I(C){C&&i.release(C);var x=s;x?h.paused?l--:(a===s&&(a=null),s=x.next,x.next=null,e.call(t,x.value,x.worked),a===null&&h.empty()):--l===0&&h.drain()}function _(){s=null,a=null,h.drain=ue}function j(){s=null,a=null,h.drain(),h.drain=ue}function B(C){d=C}}function ue(){}function $o(){this.value=null,this.callback=ue,this.next=null,this.release=ue,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,i){var s=t.callback,a=t.errorHandler,l=t.value;t.value=null,t.callback=ue,t.errorHandler&&a(r,l),s.call(t.context,r,i),t.release(t)}}function Uo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function i(c,w){e.call(this,c).then(function(E){w(null,E)},w)}var s=In(t,i,r),a=s.push,l=s.unshift;return s.push=d,s.unshift=h,s.drained=m,s;function d(c){var w=new Promise(function(E,T){a(c,function(F,k){if(F){T(F);return}E(k)})});return w.catch(ue),w}function h(c){var w=new Promise(function(E,T){l(c,function(F,k){if(F){T(F);return}E(k)})});return w.catch(ue),w}function m(){if(s.idle())return new Promise(function(E){E()});var c=s.drain,w=new Promise(function(E){s.drain=function(){c(),E()}});return w}}Ar.exports=In;Ar.exports.promise=Uo;var Tn=Ar.exports,Er={exports:{}},ot=typeof Reflect=="object"?Reflect:null,Qr=ot&&typeof ot.apply=="function"?ot.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Et;ot&&typeof ot.ownKeys=="function"?Et=ot.ownKeys:Object.getOwnPropertySymbols?Et=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Et=function(e){return Object.getOwnPropertyNames(e)};function jo(t){console&&console.warn&&console.warn(t)}var On=Number.isNaN||function(e){return e!==e};function G(){G.init.call(this)}Er.exports=G;Er.exports.once=Qo;G.EventEmitter=G;G.prototype._events=void 0;G.prototype._eventsCount=0;G.prototype._maxListeners=void 0;var Gr=10;function $t(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 Gr},set:function(t){if(typeof t!="number"||t<0||On(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Gr=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||On(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 _n(t){return t._maxListeners===void 0?G.defaultMaxListeners:t._maxListeners}G.prototype.getMaxListeners=function(){return _n(this)};G.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var s=e==="error",a=this._events;if(a!==void 0)s=s&&a.error===void 0;else if(!s)return!1;if(s){var l;if(r.length>0&&(l=r[0]),l instanceof Error)throw l;var d=new Error("Unhandled error."+(l?" ("+l.message+")":""));throw d.context=l,d}var h=a[e];if(h===void 0)return!1;if(typeof h=="function")Qr(h,this,r);else for(var m=h.length,c=Ln(h,m),i=0;i<m;++i)Qr(c[i],this,r);return!0};function Fn(t,e,r,i){var s,a,l;if($t(r),a=t._events,a===void 0?(a=t._events=Object.create(null),t._eventsCount=0):(a.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),l=a[e]),l===void 0)l=a[e]=r,++t._eventsCount;else if(typeof l=="function"?l=a[e]=i?[r,l]:[l,r]:i?l.unshift(r):l.push(r),s=_n(t),s>0&&l.length>s&&!l.warned){l.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=t,d.type=e,d.count=l.length,jo(d)}return t}G.prototype.addListener=function(e,r){return Fn(this,e,r,!1)};G.prototype.on=G.prototype.addListener;G.prototype.prependListener=function(e,r){return Fn(this,e,r,!0)};function Vo(){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 Cn(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=Vo.bind(i);return s.listener=r,i.wrapFn=s,s}G.prototype.once=function(e,r){return $t(r),this.on(e,Cn(this,e,r)),this};G.prototype.prependOnceListener=function(e,r){return $t(r),this.prependListener(e,Cn(this,e,r)),this};G.prototype.removeListener=function(e,r){var i,s,a,l,d;if($t(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(a=-1,l=i.length-1;l>=0;l--)if(i[l]===r||i[l].listener===r){d=i[l].listener,a=l;break}if(a<0)return this;a===0?i.shift():Mo(i,a),i.length===1&&(s[e]=i[0]),s.removeListener!==void 0&&this.emit("removeListener",e,d||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 a=Object.keys(i),l;for(s=0;s<a.length;++s)l=a[s],l!=="removeListener"&&this.removeAllListeners(l);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 kn(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?qo(s):Ln(s,s.length)}G.prototype.listeners=function(e){return kn(this,e,!0)};G.prototype.rawListeners=function(e){return kn(this,e,!1)};G.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):xn.call(t,e)};G.prototype.listenerCount=xn;function xn(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?Et(this._events):[]};function Ln(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Mo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function qo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Qo(t,e){return new Promise(function(r,i){function s(l){t.removeListener(e,a),i(l)}function a(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}Bn(t,e,a,{once:!0}),e!=="error"&&Go(t,s,{once:!0})})}function Go(t,e,r){typeof t.on=="function"&&Bn(t,"error",e,r)}function Bn(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(a){i.once&&t.removeEventListener(e,s),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Pn=Er.exports,Ut={},Rn={},Dn=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 a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var l=Object.getOwnPropertyDescriptor(e,r);if(l.value!==s||l.enumerable!==!0)return!1}return!0},zo=Dn,Ir=function(){return zo()&&!!Symbol.toStringTag},zr=typeof Symbol<"u"&&Symbol,Ko=Dn,Wo=function(){return typeof zr!="function"||typeof Symbol!="function"||typeof zr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Ko()},Kr={foo:{}},Ho=Object,Jo=function(){return{__proto__:Kr}.foo===Kr.foo&&!({__proto__:null}instanceof Ho)},Yo="Function.prototype.bind called on incompatible ",Xo=Object.prototype.toString,Zo=Math.max,es="[object Function]",Wr=function(e,r){for(var i=[],s=0;s<e.length;s+=1)i[s]=e[s];for(var a=0;a<r.length;a+=1)i[a+e.length]=r[a];return i},ts=function(e,r){for(var i=[],s=r||0,a=0;s<e.length;s+=1,a+=1)i[a]=e[s];return i},rs=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r},ns=function(e){var r=this;if(typeof r!="function"||Xo.apply(r)!==es)throw new TypeError(Yo+r);for(var i=ts(arguments,1),s,a=function(){if(this instanceof s){var c=r.apply(this,Wr(i,arguments));return Object(c)===c?c:this}return r.apply(e,Wr(i,arguments))},l=Zo(0,r.length-i.length),d=[],h=0;h<l;h++)d[h]="$"+h;if(s=Function("binder","return function ("+rs(d,",")+"){ return binder.apply(this,arguments); }")(a),r.prototype){var m=function(){};m.prototype=r.prototype,s.prototype=new m,m.prototype=null}return s},is=ns,Tr=Function.prototype.bind||is,os=Function.prototype.call,ss=Object.prototype.hasOwnProperty,as=Tr,us=as.call(os,ss),U,at=SyntaxError,Nn=Function,st=TypeError,Qt=function(t){try{return Nn('"use strict"; return ('+t+").constructor;")()}catch{}},Ge=Object.getOwnPropertyDescriptor;if(Ge)try{Ge({},"")}catch{Ge=null}var Gt=function(){throw new st},cs=Ge?function(){try{return arguments.callee,Gt}catch{try{return Ge(arguments,"callee").get}catch{return Gt}}}():Gt,Je=Wo(),ls=Jo(),X=Object.getPrototypeOf||(ls?function(t){return t.__proto__}:null),Xe={},fs=typeof Uint8Array>"u"||!X?U:X(Uint8Array),ze={"%AggregateError%":typeof AggregateError>"u"?U:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?U:ArrayBuffer,"%ArrayIteratorPrototype%":Je&&X?X([][Symbol.iterator]()):U,"%AsyncFromSyncIteratorPrototype%":U,"%AsyncFunction%":Xe,"%AsyncGenerator%":Xe,"%AsyncGeneratorFunction%":Xe,"%AsyncIteratorPrototype%":Xe,"%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%":Nn,"%GeneratorFunction%":Xe,"%Int8Array%":typeof Int8Array>"u"?U:Int8Array,"%Int16Array%":typeof Int16Array>"u"?U:Int16Array,"%Int32Array%":typeof Int32Array>"u"?U:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Je&&X?X(X([][Symbol.iterator]())):U,"%JSON%":typeof JSON=="object"?JSON:U,"%Map%":typeof Map>"u"?U:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Je||!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"||!Je||!X?U:X(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?U:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Je&&X?X(""[Symbol.iterator]()):U,"%Symbol%":Je?Symbol:U,"%SyntaxError%":at,"%ThrowTypeError%":cs,"%TypedArray%":fs,"%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 ds=X(X(t));ze["%Error.prototype%"]=ds}var hs=function t(e){var r;if(e==="%AsyncFunction%")r=Qt("async function () {}");else if(e==="%GeneratorFunction%")r=Qt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Qt("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 ze[e]=r,r},Hr={"%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"]},wt=Tr,Ct=us,ps=wt.call(Function.call,Array.prototype.concat),ys=wt.call(Function.apply,Array.prototype.splice),Jr=wt.call(Function.call,String.prototype.replace),kt=wt.call(Function.call,String.prototype.slice),gs=wt.call(Function.call,RegExp.prototype.exec),ms=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ws=/\\(\\)?/g,bs=function(e){var r=kt(e,0,1),i=kt(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 Jr(e,ms,function(a,l,d,h){s[s.length]=d?Jr(h,ws,"$1"):l||a}),s},vs=function(e,r){var i=e,s;if(Ct(Hr,i)&&(s=Hr[i],i="%"+s[0]+"%"),Ct(ze,i)){var a=ze[i];if(a===Xe&&(a=hs(i)),typeof a>"u"&&!r)throw new st("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:a}}throw new at("intrinsic "+e+" does not exist!")},lt=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(gs(/^%?[^%]*%?$/,e)===null)throw new at("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=bs(e),s=i.length>0?i[0]:"",a=vs("%"+s+"%",r),l=a.name,d=a.value,h=!1,m=a.alias;m&&(s=m[0],ys(i,ps([0,1],m)));for(var c=1,w=!0;c<i.length;c+=1){var E=i[c],T=kt(E,0,1),F=kt(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)&&(h=!0),s+="."+E,l="%"+s+"%",Ct(ze,l))d=ze[l];else if(d!=null){if(!(E in d)){if(!r)throw new st("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ge&&c+1>=i.length){var k=Ge(d,E);w=!!k,w&&"get"in k&&!("originalValue"in k.get)?d=k.get:d=d[E]}else w=Ct(d,E),d=d[E];w&&!h&&(ze[l]=d)}}return d},$n={exports:{}},Ss=lt,ar=Ss("%Object.defineProperty%",!0),ur=function(){if(ar)try{return ar({},"a",{value:1}),!0}catch{return!1}return!1};ur.hasArrayLengthDefineBug=function(){if(!ur())return null;try{return ar([],"length",{value:1}).length!==1}catch{return!0}};var Un=ur,As=lt,It=As("%Object.getOwnPropertyDescriptor%",!0);if(It)try{It([],"length")}catch{It=null}var Or=It,Es=Un(),_r=lt,yt=Es&&_r("%Object.defineProperty%",!0);if(yt)try{yt({},"a",{value:1})}catch{yt=!1}var Is=_r("%SyntaxError%"),Ye=_r("%TypeError%"),Yr=Or,Ts=function(e,r,i){if(!e||typeof e!="object"&&typeof e!="function")throw new Ye("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Ye("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ye("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ye("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ye("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ye("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,a=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,d=arguments.length>6?arguments[6]:!1,h=!!Yr&&Yr(e,r);if(yt)yt(e,r,{configurable:l===null&&h?h.configurable:!l,enumerable:s===null&&h?h.enumerable:!s,value:i,writable:a===null&&h?h.writable:!a});else if(d||!s&&!a&&!l)e[r]=i;else throw new Is("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},jn=lt,Xr=Ts,Os=Un(),Zr=Or,en=jn("%TypeError%"),_s=jn("%Math.floor%"),Fs=function(e,r){if(typeof e!="function")throw new en("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||_s(r)!==r)throw new en("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,a=!0;if("length"in e&&Zr){var l=Zr(e,"length");l&&!l.configurable&&(s=!1),l&&!l.writable&&(a=!1)}return(s||a||!i)&&(Os?Xr(e,"length",r,!0,!0):Xr(e,"length",r)),e};(function(t){var e=Tr,r=lt,i=Fs,s=r("%TypeError%"),a=r("%Function.prototype.apply%"),l=r("%Function.prototype.call%"),d=r("%Reflect.apply%",!0)||e.call(l,a),h=r("%Object.defineProperty%",!0),m=r("%Math.max%");if(h)try{h({},"a",{value:1})}catch{h=null}t.exports=function(E){if(typeof E!="function")throw new s("a function is required");var T=d(e,l,arguments);return i(T,1+m(0,E.length-(arguments.length-1)),!0)};var c=function(){return d(e,a,arguments)};h?h(t.exports,"apply",{value:c}):t.exports.apply=c})($n);var Vn=$n.exports,Mn=lt,qn=Vn,Cs=qn(Mn("String.prototype.indexOf")),Qn=function(e,r){var i=Mn(e,!!r);return typeof i=="function"&&Cs(e,".prototype.")>-1?qn(i):i},ks=Ir(),xs=Qn,cr=xs("Object.prototype.toString"),jt=function(e){return ks&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:cr(e)==="[object Arguments]"},Gn=function(e){return jt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&cr(e)!=="[object Array]"&&cr(e.callee)==="[object Function]"},Ls=function(){return jt(arguments)}();jt.isLegacyArguments=Gn;var Bs=Ls?jt:Gn,Ps=Object.prototype.toString,Rs=Function.prototype.toString,Ds=/^\s*(?:function)?\*/,zn=Ir(),zt=Object.getPrototypeOf,Ns=function(){if(!zn)return!1;try{return Function("return function*() {}")()}catch{}},Kt,$s=function(e){if(typeof e!="function")return!1;if(Ds.test(Rs.call(e)))return!0;if(!zn){var r=Ps.call(e);return r==="[object GeneratorFunction]"}if(!zt)return!1;if(typeof Kt>"u"){var i=Ns();Kt=i?zt(i):!1}return zt(e)===Kt},Kn=Function.prototype.toString,tt=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,lr,Tt;if(typeof tt=="function"&&typeof Object.defineProperty=="function")try{lr=Object.defineProperty({},"length",{get:function(){throw Tt}}),Tt={},tt(function(){throw 42},null,lr)}catch(t){t!==Tt&&(tt=null)}else tt=null;var Us=/^\s*class\b/,fr=function(e){try{var r=Kn.call(e);return Us.test(r)}catch{return!1}},Wt=function(e){try{return fr(e)?!1:(Kn.call(e),!0)}catch{return!1}},Ot=Object.prototype.toString,js="[object Object]",Vs="[object Function]",Ms="[object GeneratorFunction]",qs="[object HTMLAllCollection]",Qs="[object HTML document.all class]",Gs="[object HTMLCollection]",zs=typeof Symbol=="function"&&!!Symbol.toStringTag,Ks=!(0 in[,]),dr=function(){return!1};if(typeof document=="object"){var Ws=document.all;Ot.call(Ws)===Ot.call(document.all)&&(dr=function(e){if((Ks||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=Ot.call(e);return(r===qs||r===Qs||r===Gs||r===js)&&e("")==null}catch{}return!1})}var Hs=tt?function(e){if(dr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{tt(e,null,lr)}catch(r){if(r!==Tt)return!1}return!fr(e)&&Wt(e)}:function(e){if(dr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(zs)return Wt(e);if(fr(e))return!1;var r=Ot.call(e);return r!==Vs&&r!==Ms&&!/^\[object HTML/.test(r)?!1:Wt(e)},Js=Hs,Ys=Object.prototype.toString,Wn=Object.prototype.hasOwnProperty,Xs=function(e,r,i){for(var s=0,a=e.length;s<a;s++)Wn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},Zs=function(e,r,i){for(var s=0,a=e.length;s<a;s++)i==null?r(e.charAt(s),s,e):r.call(i,e.charAt(s),s,e)},ea=function(e,r,i){for(var s in e)Wn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},ta=function(e,r,i){if(!Js(r))throw new TypeError("iterator must be a function");var s;arguments.length>=3&&(s=i),Ys.call(e)==="[object Array]"?Xs(e,r,s):typeof e=="string"?Zs(e,r,s):ea(e,r,s)},ra=ta,Ht=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],na=typeof globalThis>"u"?An:globalThis,ia=function(){for(var e=[],r=0;r<Ht.length;r++)typeof na[Ht[r]]=="function"&&(e[e.length]=Ht[r]);return e},xt=ra,oa=ia,tn=Vn,Fr=Qn,_t=Or,sa=Fr("Object.prototype.toString"),Hn=Ir(),rn=typeof globalThis>"u"?An:globalThis,hr=oa(),Cr=Fr("String.prototype.slice"),Jt=Object.getPrototypeOf,aa=Fr("Array.prototype.indexOf",!0)||function(e,r){for(var i=0;i<e.length;i+=1)if(e[i]===r)return i;return-1},Lt={__proto__:null};Hn&&_t&&Jt?xt(hr,function(t){var e=new rn[t];if(Symbol.toStringTag in e){var r=Jt(e),i=_t(r,Symbol.toStringTag);if(!i){var s=Jt(r);i=_t(s,Symbol.toStringTag)}Lt["$"+t]=tn(i.get)}}):xt(hr,function(t){var e=new rn[t],r=e.slice||e.set;r&&(Lt["$"+t]=tn(r))});var ua=function(e){var r=!1;return xt(Lt,function(i,s){if(!r)try{"$"+i(e)===s&&(r=Cr(s,1))}catch{}}),r},ca=function(e){var r=!1;return xt(Lt,function(i,s){if(!r)try{i(e),r=Cr(s,1)}catch{}}),r},Jn=function(e){if(!e||typeof e!="object")return!1;if(!Hn){var r=Cr(sa(e),8,-1);return aa(hr,r)>-1?r:r!=="Object"?!1:ca(e)}return _t?ua(e):null},la=Jn,fa=function(e){return!!la(e)};(function(t){var e=Bs,r=$s,i=Jn,s=fa;function a(A){return A.call.bind(A)}var l=typeof BigInt<"u",d=typeof Symbol<"u",h=a(Object.prototype.toString),m=a(Number.prototype.valueOf),c=a(String.prototype.valueOf),w=a(Boolean.prototype.valueOf);if(l)var E=a(BigInt.prototype.valueOf);if(d)var T=a(Symbol.prototype.valueOf);function F(A,ht){if(typeof A!="object")return!1;try{return ht(A),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function k(A){return typeof Promise<"u"&&A instanceof Promise||A!==null&&typeof A=="object"&&typeof A.then=="function"&&typeof A.catch=="function"}t.isPromise=k;function D(A){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(A):s(A)||v(A)}t.isArrayBufferView=D;function I(A){return i(A)==="Uint8Array"}t.isUint8Array=I;function _(A){return i(A)==="Uint8ClampedArray"}t.isUint8ClampedArray=_;function j(A){return i(A)==="Uint16Array"}t.isUint16Array=j;function B(A){return i(A)==="Uint32Array"}t.isUint32Array=B;function C(A){return i(A)==="Int8Array"}t.isInt8Array=C;function x(A){return i(A)==="Int16Array"}t.isInt16Array=x;function L(A){return i(A)==="Int32Array"}t.isInt32Array=L;function q(A){return i(A)==="Float32Array"}t.isFloat32Array=q;function oe(A){return i(A)==="Float64Array"}t.isFloat64Array=oe;function ve(A){return i(A)==="BigInt64Array"}t.isBigInt64Array=ve;function Se(A){return i(A)==="BigUint64Array"}t.isBigUint64Array=Se;function ce(A){return h(A)==="[object Map]"}ce.working=typeof Map<"u"&&ce(new Map);function dt(A){return typeof Map>"u"?!1:ce.working?ce(A):A instanceof Map}t.isMap=dt;function pe(A){return h(A)==="[object Set]"}pe.working=typeof Set<"u"&&pe(new Set);function Ne(A){return typeof Set>"u"?!1:pe.working?pe(A):A instanceof Set}t.isSet=Ne;function Be(A){return h(A)==="[object WeakMap]"}Be.working=typeof WeakMap<"u"&&Be(new WeakMap);function Ke(A){return typeof WeakMap>"u"?!1:Be.working?Be(A):A instanceof WeakMap}t.isWeakMap=Ke;function Ae(A){return h(A)==="[object WeakSet]"}Ae.working=typeof WeakSet<"u"&&Ae(new WeakSet);function le(A){return Ae(A)}t.isWeakSet=le;function Pe(A){return h(A)==="[object ArrayBuffer]"}Pe.working=typeof ArrayBuffer<"u"&&Pe(new ArrayBuffer);function We(A){return typeof ArrayBuffer>"u"?!1:Pe.working?Pe(A):A instanceof ArrayBuffer}t.isArrayBuffer=We;function g(A){return h(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 O(A){return h(A)==="[object SharedArrayBuffer]"}function V(A){return typeof S>"u"?!1:(typeof O.working>"u"&&(O.working=O(new S)),O.working?O(A):A instanceof S)}t.isSharedArrayBuffer=V;function M(A){return h(A)==="[object AsyncFunction]"}t.isAsyncFunction=M;function R(A){return h(A)==="[object Map Iterator]"}t.isMapIterator=R;function $(A){return h(A)==="[object Set Iterator]"}t.isSetIterator=$;function Q(A){return h(A)==="[object Generator]"}t.isGeneratorObject=Q;function J(A){return h(A)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=J;function fe(A){return F(A,m)}t.isNumberObject=fe;function $e(A){return F(A,c)}t.isStringObject=$e;function Re(A){return F(A,w)}t.isBooleanObject=Re;function Ue(A){return l&&F(A,E)}t.isBigIntObject=Ue;function Ee(A){return d&&F(A,T)}t.isSymbolObject=Ee;function je(A){return fe(A)||$e(A)||Re(A)||Ue(A)||Ee(A)}t.isBoxedPrimitive=je;function Vt(A){return typeof Uint8Array<"u"&&(We(A)||V(A))}t.isAnyArrayBuffer=Vt,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(A){Object.defineProperty(t,A,{enumerable:!1,value:function(){throw new Error(A+" is not supported in userland")}})})})(Rn);var da=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},pr={exports:{}};typeof Object.create=="function"?pr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:pr.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 ha=pr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(v){for(var S=Object.keys(v),O={},V=0;V<S.length;V++)O[S[V]]=Object.getOwnPropertyDescriptor(v,S[V]);return O},r=/%[sdj%]/g;t.format=function(g){if(!C(g)){for(var v=[],S=0;S<arguments.length;S++)v.push(l(arguments[S]));return v.join(" ")}for(var S=1,O=arguments,V=O.length,M=String(g).replace(r,function($){if($==="%%")return"%";if(S>=V)return $;switch($){case"%s":return String(O[S++]);case"%d":return Number(O[S++]);case"%j":try{return JSON.stringify(O[S++])}catch{return"[Circular]"}default:return $}}),R=O[S];S<V;R=O[++S])_(R)||!oe(R)?M+=" "+R:M+=" "+l(R);return M},t.deprecate=function(g,v){if(typeof P<"u"&&P.noDeprecation===!0)return g;if(typeof P>"u")return function(){return t.deprecate(g,v).apply(this,arguments)};var S=!1;function O(){if(!S){if(P.throwDeprecation)throw new Error(v);P.traceDeprecation?console.trace(v):console.error(v),S=!0}return g.apply(this,arguments)}return O};var i={},s=/^$/;if(P.env.NODE_DEBUG){var a=P.env.NODE_DEBUG;a=a.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+a+"$","i")}t.debuglog=function(g){if(g=g.toUpperCase(),!i[g])if(s.test(g)){var v=P.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 l(g,v){var S={seen:[],stylize:h};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),L(S.showHidden)&&(S.showHidden=!1),L(S.depth)&&(S.depth=2),L(S.colors)&&(S.colors=!1),L(S.customInspect)&&(S.customInspect=!0),S.colors&&(S.stylize=d),c(S,g,S.depth)}t.inspect=l,l.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]},l.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function d(g,v){var S=l.styles[v];return S?"\x1B["+l.colors[S][0]+"m"+g+"\x1B["+l.colors[S][1]+"m":g}function h(g,v){return g}function m(g){var v={};return g.forEach(function(S,O){v[S]=!0}),v}function c(g,v,S){if(g.customInspect&&v&&ce(v.inspect)&&v.inspect!==t.inspect&&!(v.constructor&&v.constructor.prototype===v)){var O=v.inspect(S,g);return C(O)||(O=c(g,O,S)),O}var V=w(g,v);if(V)return V;var M=Object.keys(v),R=m(M);if(g.showHidden&&(M=Object.getOwnPropertyNames(v)),Se(v)&&(M.indexOf("message")>=0||M.indexOf("description")>=0))return E(v);if(M.length===0){if(ce(v)){var $=v.name?": "+v.name:"";return g.stylize("[Function"+$+"]","special")}if(q(v))return g.stylize(RegExp.prototype.toString.call(v),"regexp");if(ve(v))return g.stylize(Date.prototype.toString.call(v),"date");if(Se(v))return E(v)}var Q="",J=!1,fe=["{","}"];if(D(v)&&(J=!0,fe=["[","]"]),ce(v)){var $e=v.name?": "+v.name:"";Q=" [Function"+$e+"]"}if(q(v)&&(Q=" "+RegExp.prototype.toString.call(v)),ve(v)&&(Q=" "+Date.prototype.toUTCString.call(v)),Se(v)&&(Q=" "+E(v)),M.length===0&&(!J||v.length==0))return fe[0]+Q+fe[1];if(S<0)return q(v)?g.stylize(RegExp.prototype.toString.call(v),"regexp"):g.stylize("[Object]","special");g.seen.push(v);var Re;return J?Re=T(g,v,S,R,M):Re=M.map(function(Ue){return F(g,v,S,R,Ue,J)}),g.seen.pop(),k(Re,Q,fe)}function w(g,v){if(L(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(B(v))return g.stylize(""+v,"number");if(I(v))return g.stylize(""+v,"boolean");if(_(v))return g.stylize("null","null")}function E(g){return"["+Error.prototype.toString.call(g)+"]"}function T(g,v,S,O,V){for(var M=[],R=0,$=v.length;R<$;++R)Ae(v,String(R))?M.push(F(g,v,S,O,String(R),!0)):M.push("");return V.forEach(function(Q){Q.match(/^\d+$/)||M.push(F(g,v,S,O,Q,!0))}),M}function F(g,v,S,O,V,M){var R,$,Q;if(Q=Object.getOwnPropertyDescriptor(v,V)||{value:v[V]},Q.get?Q.set?$=g.stylize("[Getter/Setter]","special"):$=g.stylize("[Getter]","special"):Q.set&&($=g.stylize("[Setter]","special")),Ae(O,V)||(R="["+V+"]"),$||(g.seen.indexOf(Q.value)<0?(_(S)?$=c(g,Q.value,null):$=c(g,Q.value,S-1),$.indexOf(`
|
|
8
|
-
`)
|
|
9
|
-
`).
|
|
10
|
-
`).
|
|
11
|
-
|
|
12
|
-
`)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`)+" "+g.join(`,
|
|
16
|
-
`)+" "+S[1]:S[0]+v+" "+g.join(", ")+" "+S[1]}t.types=Rn;function D(g){return Array.isArray(g)}t.isArray=D;function I(g){return typeof g=="boolean"}t.isBoolean=I;function _(g){return g===null}t.isNull=_;function j(g){return g==null}t.isNullOrUndefined=j;function B(g){return typeof g=="number"}t.isNumber=B;function C(g){return typeof g=="string"}t.isString=C;function x(g){return typeof g=="symbol"}t.isSymbol=x;function L(g){return g===void 0}t.isUndefined=L;function q(g){return oe(g)&&pe(g)==="[object RegExp]"}t.isRegExp=q,t.types.isRegExp=q;function oe(g){return typeof g=="object"&&g!==null}t.isObject=oe;function ve(g){return oe(g)&&pe(g)==="[object Date]"}t.isDate=ve,t.types.isDate=ve;function Se(g){return oe(g)&&(pe(g)==="[object Error]"||g instanceof Error)}t.isError=Se,t.types.isNativeError=Se;function ce(g){return typeof g=="function"}t.isFunction=ce;function dt(g){return g===null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||typeof g=="symbol"||typeof g>"u"}t.isPrimitive=dt,t.isBuffer=da;function pe(g){return Object.prototype.toString.call(g)}function Ne(g){return g<10?"0"+g.toString(10):g.toString(10)}var Be=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ke(){var g=new Date,v=[Ne(g.getHours()),Ne(g.getMinutes()),Ne(g.getSeconds())].join(":");return[g.getDate(),Be[g.getMonth()],v].join(" ")}t.log=function(){console.log("%s - %s",Ke(),t.format.apply(t,arguments))},t.inherits=ha,t._extend=function(g,v){if(!v||!oe(v))return g;for(var S=Object.keys(v),O=S.length;O--;)g[S[O]]=v[S[O]];return g};function Ae(g,v){return Object.prototype.hasOwnProperty.call(g,v)}var le=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(le&&v[le]){var S=v[le];if(typeof S!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(S,le,{value:S,enumerable:!1,writable:!1,configurable:!0}),S}function S(){for(var O,V,M=new Promise(function(Q,J){O=Q,V=J}),R=[],$=0;$<arguments.length;$++)R.push(arguments[$]);R.push(function(Q,J){Q?V(Q):O(J)});try{v.apply(this,R)}catch(Q){V(Q)}return M}return Object.setPrototypeOf(S,Object.getPrototypeOf(v)),le&&Object.defineProperty(S,le,{value:S,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(S,e(v))},t.promisify.custom=le;function Pe(g,v){if(!g){var S=new Error("Promise was rejected with a falsy value");S.reason=g,g=S}return v(g)}function We(g){if(typeof g!="function")throw new TypeError('The "original" argument must be of type Function');function v(){for(var S=[],O=0;O<arguments.length;O++)S.push(arguments[O]);var V=S.pop();if(typeof V!="function")throw new TypeError("The last argument must be of type Function");var M=this,R=function(){return V.apply(M,arguments)};g.apply(this,S).then(function($){P.nextTick(R.bind(null,null,$))},function($){P.nextTick(Pe.bind(null,$,R))})}return Object.setPrototypeOf(v,Object.getPrototypeOf(g)),Object.defineProperties(v,e(g)),v}t.callbackify=We})(Ut);const{inherits:pa,format:Yt}=Ut;function Ve(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,a,l){if(!new.target)return new i(s,a,l);Error.captureStackTrace(this,i),this.code=t,this.message=e,this.name="AvvioError",s&&a&&l?this.message=Yt(e,s,a,l):s&&a?this.message=Yt(e,s,a):s?this.message=Yt(e,s):this.message=e}return i.prototype[Symbol.toStringTag]="Error",i.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},pa(i,r),i}var Yn={createError:Ve,AVV_ERR_EXPOSE_ALREADY_DEFINED:Ve("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:Ve("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:Ve("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:Ve("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:Ve("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:Ve("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},ya=function t(e,r,i){r===void 0&&(r=""),i||(i={});var s=function(h){var m={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return i.unicode===!1?m[h]:h};typeof e=="string"&&(e={label:e});var a=e.nodes||[],l=(e.label||"").split(`
|
|
17
|
-
`),d=`
|
|
18
|
-
`+r+(a.length?s("│"):" ")+" ";return r+l.join(d)+`
|
|
19
|
-
`+a.map(function(h,m){var c=m===a.length-1,w=h.nodes&&h.nodes.length,E=r+(c?" ":s("│"))+" ";return r+s(c?"└":"├")+s("─")+s(w?"┬":"─")+" "+t(h,E,i).slice(r.length+2)}).join("")};const ga=ya,nn=Symbol("avvio.TimeTree.untrackNode"),Xt=Symbol("avvio.TimeTree.trackNode"),on=Symbol("avvio.TimeTree.getParent"),sn=Symbol("avvio.TimeTree.getNode"),an=Symbol("avvio.TimeTree.addNode");let ma=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Xt](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])}[nn](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)}[on](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[sn](e){return this.tableId.get(e)}[an](e,r,i){if(e===null)return this.root={id:"root",label:r,start:i,nodes:[]},this[Xt](this.root),this.root.id;const a=this[on](e),l=`${r}-${Math.random()}`,d={id:l,parent:e,start:i,label:r,nodes:[]};return a.nodes.push(d),this[Xt](d),l}start(e,r,i=Date.now()){return this[an](e,r,i)}stop(e,r=Date.now()){const i=this[sn](e);i&&(i.stop=r,i.diff=i.stop-i.start||0,this[nn](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 ga(r)}};var wa=ma,kr={exports:{}},yr={exports:{}},Zt,un;function ba(){if(un)return Zt;un=1;var t=1e3,e=t*60,r=e*60,i=r*24,s=i*7,a=i*365.25;Zt=function(c,w){w=w||{};var E=typeof c;if(E==="string"&&c.length>0)return l(c);if(E==="number"&&isFinite(c))return w.long?h(c):d(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function l(c){if(c=String(c),!(c.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(c);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*a;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 d(c){var w=Math.abs(c);return w>=i?Math.round(c/i)+"d":w>=r?Math.round(c/r)+"h":w>=e?Math.round(c/e)+"m":w>=t?Math.round(c/t)+"s":c+"ms"}function h(c){var w=Math.abs(c);return w>=i?m(c,w,i,"day"):w>=r?m(c,w,r,"hour"):w>=e?m(c,w,e,"minute"):w>=t?m(c,w,t,"second"):c+" ms"}function m(c,w,E,T){var F=w>=E*1.5;return Math.round(c/E)+" "+T+(F?"s":"")}return Zt}function va(t){r.debug=r,r.default=r,r.coerce=h,r.disable=a,r.enable=s,r.enabled=l,r.humanize=ba(),r.destroy=m,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let w=0;for(let E=0;E<c.length;E++)w=(w<<5)-w+c.charCodeAt(E),w|=0;return r.colors[Math.abs(w)%r.colors.length]}r.selectColor=e;function r(c){let w,E=null,T,F;function k(...D){if(!k.enabled)return;const I=k,_=Number(new Date),j=_-(w||_);I.diff=j,I.prev=w,I.curr=_,w=_,D[0]=r.coerce(D[0]),typeof D[0]!="string"&&D.unshift("%O");let B=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(x,L)=>{if(x==="%%")return"%";B++;const q=r.formatters[L];if(typeof q=="function"){const oe=D[B];x=q.call(I,oe),D.splice(B,1),B--}return x}),r.formatArgs.call(I,D),(I.log||r.log).apply(I,D)}return k.namespace=c,k.useColors=r.useColors(),k.color=r.selectColor(c),k.extend=i,k.destroy=r.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(T!==r.namespaces&&(T=r.namespaces,F=r.enabled(c)),F),set:D=>{E=D}}),typeof r.init=="function"&&r.init(k),k}function i(c,w){const E=r(this.namespace+(typeof w>"u"?":":w)+c);return E.log=this.log,E}function s(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let w;const E=(typeof c=="string"?c:"").split(/[\s,]+/),T=E.length;for(w=0;w<T;w++)E[w]&&(c=E[w].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function a(){const c=[...r.names.map(d),...r.skips.map(d).map(w=>"-"+w)].join(",");return r.enable(""),c}function l(c){if(c[c.length-1]==="*")return!0;let w,E;for(w=0,E=r.skips.length;w<E;w++)if(r.skips[w].test(c))return!1;for(w=0,E=r.names.length;w<E;w++)if(r.names[w].test(c))return!0;return!1}function d(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function h(c){return c instanceof Error?c.stack||c.message:c}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 Sa=va;(function(t,e){e.formatArgs=i,e.save=s,e.load=a,e.useColors=r,e.storage=l(),e.destroy=(()=>{let h=!1;return()=>{h||(h=!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(h){if(h[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+h[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;h.splice(1,0,m,"color: inherit");let c=0,w=0;h[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(c++,E==="%c"&&(w=c))}),h.splice(w,0,m)}e.log=console.debug||console.log||(()=>{});function s(h){try{h?e.storage.setItem("debug",h):e.storage.removeItem("debug")}catch{}}function a(){let h;try{h=e.storage.getItem("debug")}catch{}return!h&&typeof P<"u"&&"env"in P&&(h=P.env.DEBUG),h}function l(){try{return localStorage}catch{}}t.exports=Sa(e);const{formatters:d}=t.exports;d.j=function(h){try{return JSON.stringify(h)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}})(yr,yr.exports);var Xn=yr.exports;const Aa=Tn,Ea=Pn.EventEmitter,Ia=Ut.inherits,Z=Xn("avvio"),{AVV_ERR_READY_TIMEOUT:Ta}=Yn,er=Symbol.for("plugin-meta");function Oa(t,e){return t[er]&&t[er].name?t[er].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 _a(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function ft(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=Oa(e,r),this.isAfter=i,this.q=Aa(t,Fa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}Ia(ft,Ea);ft.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),P.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(h){return Z("override errored",s),e(h)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,Z("exec",s);let a;const l=h=>{if(i){Z("loading complete",s);return}this._error=h,Z(h?"exec errored":"exec completed",s),i=!0,a&&clearTimeout(a),e(h)};this.timeout>0&&(Z("setting up timeout",s,this.timeout),a=setTimeout(function(){Z("timed out",s),a=null;const h=new Ta(s);h.fn=r,l(h)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const d=r(this.server,this.opts,l);d&&typeof d.then=="function"&&(Z("exec: resolving promise",s),d.then(()=>P.nextTick(l),h=>P.nextTick(l,h)))};ft.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,P.nextTick(i,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=_a(),e=this._promise.promise,this.server?t():this.on("start",t)),e};ft.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)};ft.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=Ca,queueMicrotask(i)}};queueMicrotask(i),this.q.resume()};function Fa(t,e){const r=this;P.nextTick(xr.bind(r),t,e)}function xr(t,e){if(typeof t.func.then=="function"){t.func.then(i=>{typeof i.default=="function"&&(i=i.default),t.func=i,xr.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 Ca(){}kr.exports=ft;kr.exports.loadPlugin=xr;var ka=kr.exports;const cn=Tn,xa=Pn.EventEmitter,La=Ut.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:tr,AVV_ERR_CALLBACK_NOT_FN:gt,AVV_ERR_PLUGIN_NOT_VALID:Ba,AVV_ERR_ROOT_PLG_BOOTED:Pa,AVV_ERR_READY_TIMEOUT:Ra}=Yn,Da=wa,gr=ka,ut=Xn("avvio"),Bt=Symbol("kAvvio"),rr=Symbol("kThenifyDoNotWrap");function Na(t,e,r){const i=e.expose||{},s=i.use||"use",a=i.after||"after",l=i.ready||"ready",d=i.onClose||"onClose",h=i.close||"close";if(t[s])throw new tr(s);if(t[a])throw new tr(a);if(t[l])throw new tr(l);t[s]=function(m,c){return r.use(m,c),this},Object.defineProperty(t,"then",{get:Zn.bind(r)}),t[Bt]=!0,t[a]=function(m){return typeof m!="function"?r._loadRegistered():(r.after(nr(m,this)),this)},t[l]=function(m){if(m&&typeof m!="function")throw new gt(l,typeof m);return r.ready(m?nr(m,this):void 0)},t[d]=function(m){if(typeof m!="function")throw new gt(d,typeof m);return r.onClose(Ma(m,this)),this},t[h]=function(m){if(m&&typeof m!="function")throw new gt(h,typeof m);return m?(r.close(nr(m,this)),this):r.close()}}function re(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 re)){const i=new re(t,e,r);return t&&Na(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 Da,this._readyQ=cn(this,ei,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=ln},this._closeQ=cn(this,Va,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=ln},this._doStart=null,this._root=new gr(this,$a.bind(this),e,!1,0),this._root.once("start",(i,s,a)=>{const l=this.pluginTree.start(null,s,a);this._root.once("loaded",(d,h,m)=>{this.pluginTree.stop(l,m)})}),gr.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 $a(t,e,r){this._doStart=r,e.autostart&&this.start()}La(re,xa);re.prototype.start=function(){return this.started=!0,P.nextTick(this._doStart),this};re.prototype.override=function(t,e,r){return t};function Ua(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new Ba(typeof t);return t}re.prototype[Bt]=!0;re.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};re.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&P.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(re.prototype,"then",{get:Zn});re.prototype._addPlugin=function(t,e,r){if(t=Ua(t),e=e||{},this.booted)throw new Pa;const i=this._current[0],s=new gr(this,t,e,r);if(s.once("start",(a,l,d)=>{const h=this.pluginTree.start(i.name,l,d);s.once("loaded",(m,c,w)=>{this.pluginTree.stop(h,w)})}),i.loaded)throw new Error(s.name,i.name);return i.enqueue(s,a=>{a&&(this._error=a)}),s};re.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,i,s){ei.call(this,t,s)}return this};re.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};re.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new gt("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),P.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};re.prototype.ready=function(t){if(t){if(typeof t!="function")throw new gt("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(a,l,d){a?r(a):e(i),P.nextTick(d)}})};re.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};re.prototype.toJSON=function(){return this.pluginTree.toJSON()};function ln(){}function Zn(){if(this.booted){ut("thenify returning null because we are already booted");return}if(this[rr]){this[rr]=!1;return}return ut("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[rr]=!0,t(this._server)),e)}function ei(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[Bt]&&typeof s.then=="function"?s.then(()=>P.nextTick(e),a=>P.nextTick(e,a)):P.nextTick(e);else if(t.length===1)s=t(i),s&&!s[Bt]&&typeof s.then=="function"?s.then(()=>P.nextTick(e),a=>P.nextTick(e,a)):P.nextTick(e);else if(this._timeout===0){const a=l=>{this._error=l,e(this._error)};t.length===2?t(i,a):t(i,r,a)}else ja.call(this,t,i,r,e)}function ja(t,e,r,i){const s=t.name;ut("setting up ready timeout",s,this._timeout);let a=setTimeout(()=>{ut("timed out",s),a=null;const d=new Ra(s);d.fn=t,this._error=d,i(d)},this._timeout);t.length===2?t(e,l.bind(this)):t(e,r,l.bind(this));function l(d){a&&(clearTimeout(a),this._error=d,i(this._error))}}function Va(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(()=>P.nextTick(e),a=>P.nextTick(e,a))):P.nextTick(e)}else t.length===2?t(i?r:this._error,e):i?t(r,e):t(this._error,r,e)}function Ma(t,e){return r.bind(e);function r(i,s){let a;t.length===0?(a=t(),a&&a.then?a.then(function(){P.nextTick(s)},s):P.nextTick(s)):t.length===1?(a=t(this),a&&a.then?a.then(function(){P.nextTick(s)},s):P.nextTick(s)):t(this,s)}}function nr(t,e){return r.bind(e);function r(i,s){let a;t?t.length===0?(a=t(),a&&a.then?a.then(function(){P.nextTick(s,i)},s):P.nextTick(s,i)):t.length===1?(a=t(i),a&&a.then?a.then(function(){P.nextTick(s)},s):P.nextTick(s)):t.length===2?t(i,s):t(i,this,s):P.nextTick(s)}}Sr.exports=re;Sr.exports.express=function(t){return re(t,{expose:{use:"load"}})};var qa=Sr.exports;const Qa=uo(qa);(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(),a=Math.max(0,16-(s-e)),l=window.setTimeout(function(){i(s+a)},a);return e=s+a,l},window.cancelAnimationFrame=clearTimeout}})();function Ga(t,e=!0,r=!0,i){console.log("start sdk");const s=e?"https://grpc-sdk.streamlayer.io:443":"https://grpc-sdk.next.streamlayer.io:443",a=Qa(Object.create({}),{autostart:!1});return a.use(Gi),a.use(Ui,{onDeepLinkHandled:i?.onDeepLinkHandled}),a.use(Qi,{videoPlayerController:i?.videoPlayerController}),a.use(ki,{sdkKey:t,host:s,version:i?.version}),a.use(qi),a.use(Mi),a.use(Po),a.use(bo),r&&a.after(async(l,d,h)=>{if(l)throw l;await d.sdk.initializeApp(),h()}),a.onClose(()=>{console.log("close")}),a}exports.StreamLayer=Ga;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jn=require("pino"),_=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),nt=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),R=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),it=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),ie=require("nanostores"),Ut=require("nanoid"),q=require("@connectrpc/connect"),yr=require("@connectrpc/connect-web"),gr=require("@nanostores/query"),qn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Xe=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),rr=require("@streamlayer/sl-eslib/users/users_connect"),me=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),Gr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const Mn=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect"),v=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),zr=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),mr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),Y=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function Un(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hr={exports:{}},j=Hr.exports={},te,re;function xt(){throw new Error("setTimeout has not been defined")}function Bt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?te=setTimeout:te=xt}catch{te=xt}try{typeof clearTimeout=="function"?re=clearTimeout:re=Bt}catch{re=Bt}})();function Wr(t){if(te===setTimeout)return setTimeout(t,0);if((te===xt||!te)&&setTimeout)return te=setTimeout,setTimeout(t,0);try{return te(t,0)}catch{try{return te.call(null,t,0)}catch{return te.call(this,t,0)}}}function xn(t){if(re===clearTimeout)return clearTimeout(t);if((re===Bt||!re)&&clearTimeout)return re=clearTimeout,clearTimeout(t);try{return re(t)}catch{try{return re.call(null,t)}catch{return re.call(this,t)}}}var de=[],je=!1,Ae,at=-1;function Bn(){!je||!Ae||(je=!1,Ae.length?de=Ae.concat(de):at=-1,de.length&&Jr())}function Jr(){if(!je){var t=Wr(Bn);je=!0;for(var e=de.length;e;){for(Ae=de,de=[];++at<e;)Ae&&Ae[at].run();at=-1,e=de.length}Ae=null,je=!1,xn(t)}}j.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];de.push(new Yr(t,e)),de.length===1&&!je&&Wr(Jr)};function Yr(t,e){this.fun=t,this.array=e}Yr.prototype.run=function(){this.fun.apply(null,this.array)};j.title="browser";j.browser=!0;j.env={};j.argv=[];j.version="";j.versions={};function he(){}j.on=he;j.addListener=he;j.once=he;j.off=he;j.removeListener=he;j.removeAllListeners=he;j.emit=he;j.prependListener=he;j.prependOnceListener=he;j.listeners=function(t){return[]};j.binding=function(t){throw new Error("process.binding is not supported")};j.cwd=function(){return"/"};j.chdir=function(t){throw new Error("process.chdir is not supported")};j.umask=function(){return 0};var Qn=Hr.exports;const w=Un(Qn),Kn=jn.pino({level:"trace",enabled:!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ve=(t,e)=>Kn.child({name:t},e);class Gn extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const zn=ve("event-bus");class Hn{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,r)=>{const n=new Gn(this.name,{...r,type:e});zn.debug(n,"Emitting event"),window.dispatchEvent(n)};listen(e){return window.addEventListener(this.name,e),this.listeners.add(e),()=>{this.off(e)}}off(e){window.removeEventListener(this.name,e),this.listeners.delete(e)}destroy=()=>{this.listeners.forEach(e=>{window.removeEventListener(this.name,e),this.listeners.delete(e)}),this.listeners.clear()}}class Wn{}window.slStore=Object.create(null);class bt{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const Jn=t=>{const e=Object.keys(t);return ie.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((n,i)=>[n,r[i]])))};class Te 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 fe=t=>ie.map(t);var ue;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(ue||(ue={}));const Yn={[R.SdkOverlayType.BETTING]:"betting",[R.SdkOverlayType.GAMES]:"games",[R.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[R.SdkOverlayType.TWITTER]:"twitter"};var ze;(function(t){t.Ready="ready",t.Suspended="suspended"})(ze||(ze={}));class Xr{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=Yn[r.type],this.status=ie.atom(ze.Suspended),this.config=new Te(fe(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Te(fe(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Te(fe({}),`feature:settings:${this.settingsKey}`),this.source=n}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(ze.Ready)};disable=()=>{this.status.set(ze.Suspended)};setFeatureConfig=({settings:e,...r})=>{let n;for(n in r)this.config.setValue(n,r[n]);if(e?.overlaySettings?.case!==void 0&&e?.overlaySettings.case===this.settingsKey){const i=e.overlaySettings.value;if(i!==void 0){let o;for(o in i)i[o]!==0&&i[o]!==""&&this.settings.setValue(o,i[o])}}};update=(e,r)=>{this.source===ue.STREAM&&r===ue.ORGANIZATION||(this.setFeatureConfig(e),this.source=r)};fireEvent(e){for(const r of this.listeners.values())try{r.onEvent(e)}catch(n){console.error(n)}}}class H 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 K=t=>ie.atom(t);class X extends bt{atomStore;constructor(e,r,n){super(e,`api:${r}`),this.atomStore=ie.atom(),n&&e.subscribe(i=>{const o=this.atomStore.get(),s=n(i,o);o!==s&&this.atomStore.set(s)})}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()}const pe=new Hn;async function*Xn(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now();const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}const Zn=()=>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 n=await t(e);if(r.received_at=Date.now(),r.response.header=Object.fromEntries(n.header.entries()),r.response.trailer=Object.fromEntries(n.trailer.entries()),e.stream){r.request.message=e.message;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(i),{...n,message:Xn(r,n.message)}}else{r.request.message=e.message,r.response.message=n.message,r.latency=r.received_at-r.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};window.postMessage(i)}return n}catch(n){r.received_at=Date.now(),r.request.message=e.message,r.response.trailer={"grpc-status":n.code,"grpc-message":n.rawMessage},r.response.message=n.rawMessage,r.latency=r.received_at-r.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};throw window.postMessage(i),n}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));var J;(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"})(J||(J={}));class ei{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:J.Init,ts:new Date,log:[]};this.state=new Te(fe(o),`subscription:${i.name}:state`),this.options={...i,reconnectDelay:i.reconnectDelay??1e3,reconnectMaxDelay:i.reconnectMaxDelay??3e4,reconnectMaxAttempts:i.reconnectMaxAttempts??10,withStore:i.withStore??!1},this.headers=e,this.listeners=new Map,this.params=n,this.method=r,i.withStore&&(this.store=new H(K(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===J.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(J.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,n=`${this.options.name} ${new Date().toISOString()}: ${e}`;r.push(n),this.state.setValue("log",r),window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
|
|
2
|
+
`+n)};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(J.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 n={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,n);for await(const o of i)this.attempt=0,this.onData(o)}catch(n){n instanceof q.ConnectError&&n.code!=q.Code.Canceled&&this.onStreamError(n)}})(),this.updateState(J.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(J.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(J.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(J.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 q.ConnectError&&e.code!==q.Code.Canceled){this.updateState(J.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}const ti=new Set([q.Code.Unknown,q.Code.Internal,q.Code.DeadlineExceeded,q.Code.ResourceExhausted,q.Code.FailedPrecondition,q.Code.Unavailable,q.Code.DataLoss]),vr=ve("grpc:retry"),ri=t=>async e=>{const r=e.contextValues.get(Qt.retryAttempts),n=300,i=e.contextValues.get(Qt.retryDelay);if(e.stream||r===0)return t(e);vr.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){vr.trace({attempt:o,error:s},"retry attempt");const a=q.ConnectError.from(s);if(o>=r||!(a instanceof q.ConnectError)||!ti.has(a.code))throw s;const u=Math.min(i,Math.pow(2,o)*n),d=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,d))}},Qt={retryAttempts:q.createContextKey(5,{description:"Number of attempts to retry"}),retryDelay:q.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},ni=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=Ut.nanoid();return localStorage.setItem("sl-device-id",e),e},ii=()=>navigator.userAgentData?.platform||navigator.platform;class br{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;interceptors=[];clients;streamClients;subscriptions;constructor(e){this.host=e,this.$headers=new Te(fe({"sl-device-id":ni(),"sl-device-os":ii()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map;const[r,n,i]=gr.nanoquery({dedupeTime:1e3*60*5,refetchInterval:1e3*60*5});this.nanoquery={createFetcherStore:r,createMutatorStore:n,utils:i},this.transport=yr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=yr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,n)=>{const i=this.subscriptions.get(r);if(i)return i;const o=new ei(this.$headers,e,r,n);return this.subscriptions.set(r,o),o};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[i,o]of this.subscriptions)o.disconnect(),this.subscriptions.delete(i);this.clients.clear(),this.streamClients.clear(),this.subscriptions.clear();const[e,r,n]=gr.nanoquery();this.nanoquery={createFetcherStore:e,createMutatorStore:r,utils:n}};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 n=q.createPromiseClient(e,this.transport);return this.clients.set(r,n),n};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const n=q.createPromiseClient(e,this.streamTransport);return this.clients.set(r,n),n};createPromiseClient=(e,{params:r=[],method:n})=>{const i=this.getClient(e),o=e.methods[n].name,s=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1),...Array.isArray(r)?r:[r]],a=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1)];return{client:i,createRequestOptions:d=>{const c=q.createContextValues();for(const f in d){const y=Qt[f];c.set(y,d[f])}return c},queryKey:s,queryKeyStr:a.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=>n=>{const i=this.$headers.getValues();for(const o in i)n.header.set(o,i[o]);return r(n)};this.interceptors.push(e),this.interceptors.push(Zn()),this.interceptors.push(ri)}}const oi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(qn.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s||typeof s!="string")return"";try{return(await r.retrieveEventId({id:s})).data?.id||""}catch{return""}}})},si=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getStream({id:s})).data?.attributes:void 0})},ai=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(rr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>n.me({})})},ui=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(rr.Users,{method:"bypassAuth"}),n=r({retryAttempts:0});return async({userKey:i,schema:o,init:s,inviterKey:a})=>{const u=await e.bypassAuth({userKey:i,schema:o,init:s},{contextValues:n});return u.meta&&(u.meta.inviterKey=a),u}},ci=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.get({})).data?.attributes})},li=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{const i=await r.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},di=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},fi=(t,e,r)=>{t.transport=new br(e.host),t.analyticsTransport=new br(e.analyticsHost),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),t.transport.$headers.subscribe(n=>{t.analyticsTransport.$headers.getStore().set(n)}),t.sdk.onMount(()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),r()};class St{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 Re extends St{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 ce;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(ce||(ce={}));const pi=t=>{const e=new Re,r=new H(K(e.getExternalToken()),"userKey"),n=new H(K(e.getToken()),"userToken"),i=new X(ai(n.getStore(),t),"user",({data:s,error:a,loading:u},d)=>{if(!a)return s?.data?.id?s.data.id:u===!1?void 0:d}),o=new X(ci(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},hi=t=>{const e=new H(K(void 0),"providerStreamId"),r=new X(oi(e.getStore(),t),"slStreamId",i=>i?.data),n=new X(si(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(i=>{(i===""||i===void 0)&&n.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:n}},yi=t=>{const e=new H(K(void 0),"enabled"),r=new H(K(ce.DISABLED),"status"),n=new X(li(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new X(di(n.getAtomStore(),t),"organizationAdvertising"),o=pi(t),s=hi(t);return{enabled:e,status:r,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:n,organizationAdvertising:i}};class gi extends bt{stores;constructor(e){const r=yi(e),n=Jn(r);super(n,"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 n=e[r];r in e&&n!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}const mi=(t,e,r)=>{t.store=new gi(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(([n,i])=>[n,i.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},vi=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(Gr.Leaderboard,{method:"summary",params:[t,e]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>(await n.summary({eventId:a,userId:u})).data?.attributes})},bi=t=>{const{client:e}=t.createPromiseClient(Gr.Leaderboard,{method:"list"});return r=>e.list(r)},Si=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(rr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getFriends({})).data:[]})},wi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:0,dedupeTime:1e3*60*60})},Ai=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.syncQuestion({filter:{eventId:s}})).data?.attributes:void 0,dedupeTime:1e3*60*10,refetchInterval:0})},Ti=(t,e)=>{const{client:r}=e.createStreamClient(me.Feed),n=ie.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{n.set({eventId:o,feedId:""})}),e.addSubscription(r.subscription,n,{name:"feedSubscription"})},Ei=(t,e)=>{const{client:r}=e.createStreamClient(me.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},Kt=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"questionByUser",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.questionByUser({questionId:s})).data?.attributes?.question,dedupeTime:1e3*60*5})},Ii=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(me.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>a?(await n.list({eventId:a,filter:{types:u===Ee.ALLOWED?[]:[_.QuestionType.FACTOID,_.QuestionType.PROMOTION,_.QuestionType.TWEET],statuses:[_.QuestionStatus.ACTIVE,_.QuestionStatus.RESOLVED]}})).data:[],dedupeTime:0,refetchInterval:0})},Oi=(t,e,r)=>{const n=ie.batched([e,r],()=>{const a=e.get();if(!a)return;const u=r.get().data?.find(c=>c.id===a?.questionId),d=a?.question?.openedFrom;return u?(u.openedFrom=d,u):a.question}),i=ie.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=Kt(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,f)=>{if(!c||!f)return c||f||[];const y=[];for(let m=0;m<c.length;m++)y.push({...c[m],...f[m],correct:c[m].correct,youVoted:c[m].youVoted,pointsEarned:c[m].pointsEarned});return y};o.mutate({...a,answers:d(u?.answers,a?.answers)})}}};var Ee;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ee||(Ee={}));class Ci{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;transport;constructor(e){this.transport=e.transport,this.log=ve("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new H(K(void 0),"moderationId").getStore(),this.interactiveAllowed=new H(K(Ee.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new H(K(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new X(wi(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new X(Ii(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=new X(Ai(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=Oi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.questionSubscription=Ei(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",n=>{this.openedQuestion.updateExtendedQuestion(n.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=Ti(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{const n=this.activeQuestionId.getStore();n&&n.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()||"",n=e.userId||this.userId.get()||"",i=e.organizationId||this.organizationId.get()||"",o=e.entity||"",s=e.prefix||"";return[i,r,n,s,o].join(":")};disconnect=()=>{this.feedSubscription?.disconnect(),this.questionSubscription!==void 0&&(this.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0)};openQuestion=(e,r)=>{this.openedQuestionId.set({questionId:e,question:r}),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 _i{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ve("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new H(K(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,n=e.action;if(this.store.set(e.id,{...e,close:(...i)=>{r&&r(...i),this.closeNotification(e.id)},action:(...i)=>{n&&n(...i),this.closeNotification(e.id)}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[i]=this.activeQueue;if(this.store.get(i)?.persistent!==!0)this.closeNotification(i);else{const[s]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(s),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 n=setTimeout(()=>{const i=e,o=new Map(this.notifications.getValue());o.set(r.id,r),this.notifications.setValue(o);const s=setTimeout(()=>{this.logger.debug({notificationId:i,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(i)},r.autoHideDuration||5e3);this.timeouts.set(i,s),this.logger.debug({notificationId:i,queue:[...o.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,n),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=e=>{const r=new Map(this.notifications.getValue()),n=r.get(e);if(n){n.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notifications.setValue(r);const i=setTimeout(()=>{const o=new Map(this.notifications.getValue());o.delete(e),this.notifications.setValue(o);const s=this.timeouts.get(e);s!==void 0&&(clearTimeout(s),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,i)}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),n}}var pt;(function(t){t.OPENED="opened"})(pt||(pt={}));class ki extends St{constructor(){super("notification")}setOpened=e=>{this.write(pt.OPENED,e,"true")};isOpened=e=>this.read(pt.OPENED,e);clearNotification=()=>{this.clear()}}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));class Li{queue;storage;constructor(e={}){this.storage=new ki,this.queue=new _i({concurrency:1,animationDelay:1600,...e})}add=e=>{if(!this.storage.isOpened(e.id)){if(e.data&&e.emitEvent){const n=e.action;e.action=(...i)=>{n&&n(...i),pe.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,r=!0)=>{this.queue.closeNotification(e),r&&this.markAsViewed(e)};getActiveNotification=()=>{const e=this.queue.notificationsList.get();if(!e?.size)return null;for(const n of e.values())if(n.type===ge.ONBOARDING)return n;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const Pi=(t,e,r)=>{t.notifications=new Li(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),r()};var Ye;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Ye||(Ye={}));const Fi=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(me.Feed,{method:"submitAnswer"}),i=n({retryAttempts:0});try{return await r.submitAnswer({data:e},{contextValues:i})}catch(o){throw q.ConnectError.from(o)?.code===q.Code.AlreadyExists?new Error(Ye.ALREADY_VOTED):new Error(Ye.UNKNOWN)}},Ni=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(me.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})};var Ve;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(Ve||(Ve={}));class Zr extends St{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write(Ve.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read(Ve.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{const i=this.generateKey([Ve.ONBOARDING_IO,n,e,r]);window.sessionStorage.setItem(i,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{const i=this.generateKey([Ve.ONBOARDING_IO,n,e,r]);return window.sessionStorage.getItem(i)}}const Sr={pageSize:10},Di=(t,e,r,n,i)=>{let o=0;const s=K({pageSize:i?.pageSize||Sr.pageSize,page:0}),a=fe({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=bi(t),d=async()=>{const y=e.get(),m=n.getStore().get().data?.map(b=>b.slId)||[];if(y&&m?.length){const b=r.get();b&&m.push(b),a.setKey("loading",!0),a.setKey("data",[]);const A={eventId:y,usersIds:m,pagination:{page:0,pageSize:i?.pageSize||Sr.pageSize}},T=await u(A);a.set({data:T.data.map(N=>N.attributes),hasMore:!0,key:Date.now(),loading:!1}),T.meta&&(o=Math.round(T.meta.count/T.meta.pageSize)),s.set(A.pagination)}},c=()=>{d()},f=y=>{const m=s.get(),b=y||m.page+1;b<=o&&s.set({...m,page:b})};return ie.onMount(a,()=>{const y=e.listen(d),m=n.listen(d),b=s.listen(async A=>{const T=e.get();if(A.page>0&&T)if(A.page<o){a.setKey("loading",!0);const $=await u({eventId:T,pagination:A}),M=a.get().data||[];a.set({data:[...M,...$.data.map(z=>z.attributes)],key:a.get().key,loading:!1,hasMore:!0})}else a.setKey("hasMore",!1)});return()=>{y(),m(),b()}}),{$store:a,fetchMore:f,invalidate:c}};class Ri extends St{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const wr="sldl",wt="sldl_uid",en="sldl_eid",tn="sldl_e_eid",Vi=new Set([wt,en,tn]),Ar=t=>{const e={},r={};for(const[n,i]of t)Vi.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},$i=({hash:t,search:e})=>{if(t&&t.includes(wr)){const r=new URLSearchParams(t.substr(1));return{hash:Ar(r)}}if(e&&e.includes(wr)){const r=new URLSearchParams(e);return{search:Ar(r)}}return null},Tr=ve("deep_link"),ne={debug:(...t)=>{Tr.debug(...t),console.log(...t)},trace:(...t)=>{Tr.trace(...t),console.log(...t)}},ji=(t,e)=>{const{hash:r,search:n}=window.location;if(ne.debug({hash:r,search:n},"get deep link data from"),r||n){const i=$i({hash:r,search:n});if(ne.debug(i,"parse deep link result"),i){const{hash:o,search:s}=i,{result:a,remain:u}=o||s;if(Object.keys(a).length!==0){t.setValue("data",a);const d=Object.keys(u).length!==0;if(o){let c="";d&&(c=`#${new URLSearchParams(u).toString()}`,ne.debug({updatedHash:c},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+c)}if(s){let c="";d&&(c=`?${new URLSearchParams(u).toString()}`,ne.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},qi=(t,e,r)=>{const n=new Ri,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ne.debug(a)}t.deepLink={$store:new Te(fe(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ne.debug(`logged in with inviterId: ${a}`),t.deepLink.$store.setValue("used",!0)},onDeepLinkHandlers:new Set},t.sdk.getInviter=()=>{const{data:a,used:u}=t.deepLink.getDeepLinkData();return u?a?.[wt]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),n.del("sl-deep-link-store")},t.deepLink.$store.subscribe(a=>n.set("sl-deep-link-store",JSON.stringify(a))),t.sdk.addDeepLinkHandler=a=>{ne.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ne.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ne.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ne.trace("called handler"),u(a)}catch(d){console.error(d)}};ji(t.deepLink.$store,s),r()},Mi=ve("bypass");class Ui extends Wn{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=ui(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:n,data:i}=this.deepLink.getDeepLinkData(),o=n?"":i?.[wt];Mi.debug({inviterKey:o},"login with inviterKey");const s=await this.bypassLogin({schema:e,userKey:r,inviterKey:o,init:!1}),a=s.meta?.jwt,u=s.data?.id;if(!a||!u)throw new Error("internal: token missing");return s.meta?.inviterKey&&this.deepLink.deepLinkUsed(s.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate(s),this.saveUser(a,u),a};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Re().clear()};softLogout=()=>{const e=new Re;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Re,r=e.getToken(),n=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(n),r)return this.saveUser(r,""),this.me().then(i=>{if(i?.id){const o=i.id;this.saveUser(r,o)}});if(n&&!r){const i=e.getSchema();i&&n&&this.login(i,n).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Re().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(n){throw n.code&&(n.code===7||n.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),n}})}}const Ge=new Re,xi=(t,e,r)=>{t.auth=new Ui(t.store,t.transport,t.deepLink),t.stores.status.listen(n=>{n===ce.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(n,i)=>{if(!(Ge.getSchema()===n&&Ge.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(n,i),Ge.setSchema(n),Ge.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),Ge.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},Er=ve("video_player"),ot={debug:(...t)=>{Er.debug(...t),console.log(...t)},trace:(...t)=>{Er.trace(...t),console.log(...t)}},Bi=(t,e,r)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=n=>{ot.trace("adding video player controller"),t.videoPlayer.controllers.add(n)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=n=>{ot.trace("removing video player controller"),t.videoPlayer.controllers.delete(n)},t.sdk.controlVideoPlayer=n=>{ot.trace("controlling video player");for(const i of t.videoPlayer.controllers){ot.trace("calling video player controller");try{i(n)}catch(o){console.error(o)}}},r()},Qi=(t,e,r)=>{const n=new Set,i=new Set;t.sdk=Object.create(null),t.sdk.onMount=o=>{n.add(o)},t.ready=()=>{t.stores.enabled.subscribe(o=>{o==="on"?n.forEach(s=>i.add(s())):i.forEach(s=>s())})},t.sdk.initializeApp=async o=>{if(t.contextConfig=o,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(ce.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(ce.READY),{enabled:!!s}):(t.stores.status.setValue(ce.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(ce.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(ce.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=o=>{t.stores.providerStreamId.setValue(o)},r()},Ki=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Xe.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s,a)=>s?(await r.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes:{},dedupeTime:1e3*60*60*24,refetchInterval:0})},Gi=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(Mn.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Ir=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},zi=(t,e,r,n)=>{const i=fe({});return ie.onMount(i,()=>Ki(t,[e,r]).subscribe(async({data:a,error:u,loading:d})=>{const c=u?"https://masters.com":a?.url,f=n.get()||"",y=e.get()||"",m=r.get()||"",b={[wt]:f,[en]:y,[tn]:m};if(!d&&c){i.setKey("loading",!0);let A=window.location.search,T=window.location.hash;A&&T||T?A=`?${Ir(A,b)}`:T=`#${Ir("",b)}`;const N=window.location.origin+window.location.pathname+A+T,$=await Gi(t,{web:N,mobile:c});i.set({data:$.data?.link,loading:!1})}else i.setKey("loading",!0)})),{$store:i,fetch}};var B;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(B||(B={}));const Hi=(t,e,r,n)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&r.add({type:ge.ONBOARDING,id:o,action:t.openFeature,persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:_.QuestionType.UNSET,onboarding:{...i,instantOpen:!n.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},st=(t,e,r,n,i,o)=>{try{const s=e.userId.get();if(!s)return;if(i.getOnboardingStatus({userId:s,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===B.Completed){t.set(B.Completed);for(const y of o)y();return}const u=e.moderation.getStore().value?.data,d=r.featureSettings.get().inplayGame;if(u===void 0||d===void 0)return;const c=u?.options?.onboardingEnabled,f=d?.titleCard?.optIn;c?f?t.set(B.Required):t.set(B.Optional):(f?t.set(B.Unavailable):t.set(B.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(s){console.error(s)}},Wi=(t,e,r,n)=>{let i=!1;const o=new Zr,s=K(B.Unset);s.subscribe(d=>{d!==B.Unset&&((d===B.Optional||d===B.Required)&&i===!1&&(Hi(t,e,n,o),i=!0),d===B.Completed&&e.activeQuestionId.invalidate(),o.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const a=[];return st(s,e,t,n,o,a),s.get()!==B.Completed&&(a.push(e.userId.listen(d=>{d&&st(s,e,t,n,o,a)})),a.push(e.moderation.listen(d=>{d.data&&st(s,e,t,n,o,a)})),a.push(t.featureSettings.listen(d=>{d&&st(s,e,t,n,o,a)}))),{$store:s,submitInplay:async()=>{const d=e.slStreamId.get();if(d){await Ni(r,d),s.set(B.Completed),o.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:d},B.Completed),pe.emit("poll",{action:"onboardingPassed",payload:{}});const c=e.getCurrentSessionId({prefix:"onboarding"});n.close(c)}}}},Ji=new Set([_.QuestionType.POLL,_.QuestionType.PREDICTION,_.QuestionType.TRIVIA]);class Yi extends Xr{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;notifications;transport;background;storage;submitAnswerTimeout;constructor(e,r,n){super(e,r),this.background=new Ci(n),this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=new Zr,this.userSummary=new X(vi(this.background.slStreamId,this.background.userId,n.transport),"gamification:userSummary"),this.feedList=this.background.feedList,this.friends=new X(Si(this.background.userId,n.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=K(void 0),this.leaderboardId=new H(K(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=Wi(this,this.background,n.transport,n.notifications),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=()=>n.sdk.closeFeature(!0),this.openFeature=()=>n.sdk.openFeature(R.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=zi(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.leaderboardList=Di(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.connect(),this.userSummary.listen(i=>{this.leaderboardList.$store.lc!==0&&i?.data?.summary&&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()===Ee.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,n=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===B.Completed,o=!r||i||n!==!0;this.background.interactiveAllowed.set(o?Ee.ALLOWED:Ee.DISALLOWED)};connect=()=>{this.background.feedSubscription.addListener("feed-subscription-prediction-close",async e=>{if(!this.isInteractiveAllowed)return;const r=e.data?.attributes?.question,n=e.data?.attributes?.feedItem;if(!r||!n?.attributes)return;const{status:i,type:o,id:s,answers:a}=r;if(i===_.QuestionStatus.RESOLVED&&o===_.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(M=>M.id===s),f=d[c];let y=f?.attributes?.attributes?.value?.answerId;const m=Kt(s,this.transport),b=m.subscribe(()=>{});await m.get().promise;const A=m.get().data;b(),window.requestAnimationFrame(()=>{m.invalidate()}),y||(y=A?.answers.find(({youVoted:M})=>M)?.id);const T=a.find(({correct:M})=>M),N=y?a.find(({id:M})=>M===y):void 0,$=!!N?.correct;if(f&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=y,d[c].attributes.attributes.value.openForVoting=!1,y&&(d[c].attributes.attributes.value.status=$?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!N||!T)return;this.openedQuestionId.get()?.questionId!==r.id&&this.notifications.add({type:ge.QUESTION_RESOLVED,action:()=>this.openQuestion(r.id,n),close:()=>this.closeQuestion(s),autoHideDuration:$?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:_.QuestionType.PREDICTION,question:{title:$?`Congratulations! You answered correctly! You won ${T.points} pts!`:`Better luck next time! Correct: ${T?.text}!`,votedAnswer:{title:N?.text,points:N?.points},correctAnswerTitle:T?.text,correct:!!$,predictionResult:i===_.QuestionStatus.RESOLVED,questionTitle:r?.subject}}}),this.userSummary.invalidate()}}),this.background.feedSubscription.addListener("feed-subscription-questions-list",e=>{const r=[...this.feedList.getStore().value?.data||[]],n=e.data?.attributes?.feedItem,i=r.findIndex(o=>o.id===n?.id);if(n){if(i!==-1)if(n.attributes?.attributes.case==="question"&&r[i].attributes?.attributes.case==="question"){const o=r[i];o.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting}}}})}else r[i]=n;i===-1&&(r.unshift(n),pe.emit("poll",{action:"received",payload:{questionId:n.id,questionType:n.attributes?.type}})),this.feedList.getStore().mutate(r)}})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{const n=Kt(e,this.transport),i=()=>{const o=this.feedList.getValues().data;if(!o)return;const s=o.findIndex(d=>d.id===e),a=o[s],u=a?.attributes?.attributes.case==="question"&&a.attributes.attributes.value;if(u){pe.emit("poll",{action:"voted",payload:{questionId:e,questionType:u.questionType}});const d=n.subscribe(()=>{}),c=n.get().data;if(d(),c){const f=c.answers.find(b=>b.correct===!0),y=c.answers.findIndex(b=>b.id===r),m=c.answers[y];o[s].attributes.attributes.value.answerId=r,o[s].attributes.attributes.value.openForVoting=!1,o[s].attributes.attributes.value.text=m?.text||"",f&&(o[s].attributes.attributes.value.status=f.id===r?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...o]),c.answers[y].correct=f?.id===r,c.answers[y].youVoted=!0,f?.id===r&&(c.answers[y].pointsEarned=c.status===_.QuestionStatus.RESOLVED?0:f.points),n.mutate({...c})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Fi(this.transport,{questionId:e,answerId:r}),i()}catch(o){if(o.message===Ye.ALREADY_VOTED){this.userSummary.invalidate();const s=n.subscribe(()=>{});n.invalidate(),s()}throw o}};openQuestion=(e,r)=>{this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}));let n=r?.attributes?.type;return n||(n=(this.feedList.getStore().value?.data||[]).find(o=>o.id===e)?.attributes?.type),pe.emit("poll",{action:"opened",payload:{questionId:e,questionType:n,questionOpenedFrom:r?.openedFrom}}),this.background.openQuestion(e,r)};closeQuestion=e=>this.background.closeQuestion(e);openUser=e=>{const r=this.leaderboardList.$store.get().data?.find(n=>n.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!==B.Unset&&e.data.question?.id!==void 0&&e.data.question.notification!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==_.SilenceSetting.ON&&e.data.question.status===_.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Ji.has(e.data.question.type))this.isInteractiveAllowed&&this.notifications.add({type:ge.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),emitEvent:!0,data:{questionId:e.data.question.id,questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===_.QuestionType.FACTOID){const n=e.data.question.options?.options.value,i={heading:e.data.question.notification.title,body:e.data.question.notification.body,imageMode:n.imageMode,image:n?.image,video:{id:n?.video?.id||"",url:n?.video?.url||"",thumbnailUrl:n?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:ge.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,insight:i}})}else if(e.data.question.type===_.QuestionType.TWEET){const n=e.data.question.options?.options.value,i={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:n?.tweetMeta?.account||"",accountVerified:!!n?.tweetMeta?.accountVerified,tweet:n?.tweetMeta?.tweet,tweetId:e.data.question.id};this.notifications.add({type:ge.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,tweet:i}})}}}}const Xi={[R.SdkOverlayType.GAMES]:!0};class Zi extends Xr{constructor(e,r){super(e,r)}}const eo=(t,e,r)=>t.type===R.SdkOverlayType.GAMES?new Yi(t,e,r):new Zi(t,e),to=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new H(K(new Set),"features-list"),t.activeFeature=new H(K(R.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=n=>t.features.get(n),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=n=>{t.activeFeature.setValue(n)},t.sdk.closeFeature=(n=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(R.SdkOverlayType.UNSET),n&&i){t.features.delete(i);const o=t.sdk.featuresList.getValue();o&&o.delete(i),t.sdk.featuresList.setValue(o)}},t.initFeature=(n,i=ue.ORGANIZATION)=>{if(n.type in Xi&&!t.features.has(n.type)){const o=eo(n,i,t);t.features.set(n.type,o);let s=t.sdk.featuresList.getValue();s?s.add(n.type):s=new Set([n.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(n,i)=>{t.features.get(n.type)?.update(n,i)},t.destroyFeature=n=>{t.features.delete(n.type);const i=t.sdk.featuresList.getValue();i&&i.delete(n.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const n=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of n?.overlays||[])t.initFeature(i,ue.ORGANIZATION)},t.stores.providerStreamId.listen(n=>{n||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const n=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===ue.ORGANIZATION))for(const a of s.overlays)a.sdkEnable===!0&&(t.features.has(a.type)?t.updateFeature(a,o):t.initFeature(a,o))},i={organizationSettings:o=>{if(o.data)try{n(ue.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{n(ue.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},r()};class ro{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="invitation")switch(n.slEventBus.action){case"sent":this.sent(n.slEventBus.payload);break}};return pe.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_ACCEPTED},category:it.InvitationCategory.GAMES,from:it.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_SENT},category:it.InvitationCategory.GAMES,from:e||it.InvitationFrom.UNSET})}}class no{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="interactions")switch(n.slEventBus.action){case"tap":this.tap();break;case"scroll":this.scroll();break}};return pe.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:mr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:mr.InteractionActionType.SCROLL})}}const He={[_.QuestionType.UNSET]:v.TopicType.UNSET,[_.QuestionType.FACTOID]:v.TopicType.POLLS_INSIGHT,[_.QuestionType.POLL]:v.TopicType.POLLS_POLL,[_.QuestionType.PREDICTION]:v.TopicType.POLLS_PREDICTION,[_.QuestionType.PROMOTION]:v.TopicType.POLLS_PROMOTION,[_.QuestionType.TRIVIA]:v.TopicType.POLLS_TRIVIA,[_.QuestionType.TWEET]:v.TopicType.POLLS_TWITTER};_.QuestionType.UNSET+"",Y.NotificationKind.UNSET,_.QuestionType.FACTOID+"",Y.NotificationKind.POLLS,_.QuestionType.POLL+"",Y.NotificationKind.POLLS,_.QuestionType.PREDICTION+"",Y.NotificationKind.POLLS,_.QuestionType.PROMOTION+"",Y.NotificationKind.POLLS,_.QuestionType.TRIVIA+"",Y.NotificationKind.POLLS,_.QuestionType.TWEET+"",Y.NotificationKind.POLLS;const io={[R.SdkOverlayType.UNSET]:v.Category.UNSET,[R.SdkOverlayType.INPLAY]:v.Category.INPLAY,[R.SdkOverlayType.MESSAGING]:v.Category.MESSAGING,[R.SdkOverlayType.STATISTICS]:v.Category.STATS,[R.SdkOverlayType.BETTING]:v.Category.BETTING,[R.SdkOverlayType.TWITTER]:v.Category.TWITTER,[R.SdkOverlayType.MERCHANDISE]:v.Category.MERCHANDISE,[R.SdkOverlayType.CONTESTS]:v.Category.CONTESTS,[R.SdkOverlayType.VOICE_CHAT]:v.Category.CALLING,[R.SdkOverlayType.TICKETS]:v.Category.TICKETS,[R.SdkOverlayType.WHOIS_WATCHING]:v.Category.WHOISWATCHING,[R.SdkOverlayType.PROFILE]:v.Category.PROFILE,[R.SdkOverlayType.GAMES]:v.Category.POLLS,[R.SdkOverlayType.GOLF_STATISTICS]:v.Category.STATS,[R.SdkOverlayType.HIGHLIGHTS]:v.Category.HIGHLIGHTS,[R.SdkOverlayType.PUBLIC_CHAT]:v.Category.PUBLIC_CHAT};class oo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="notification")switch(n.slEventBus.action){case"rendered":this.received(n.slEventBus.payload);break;case"opened":this.opened(n.slEventBus.payload);break}};return pe.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},notificationKind:Y.NotificationKind.POLLS,notificationType:Y.NotificationType.IN_APP})};opened=({questionId:e,questionType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},notificationKind:Y.NotificationKind.POLLS,notificationType:Y.NotificationType.IN_APP})}}class so{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="poll")switch(n.slEventBus.action){case"voted":this.voted(n.slEventBus.payload);break;case"navigated":this.navigated();break;case"onboardingPassed":this.onboardingPassed();break;case"received":this.received(n.slEventBus.payload);break;case"opened":this.opened(n.slEventBus.payload);break}};return pe.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:n==="list"?v.PollOpenedFrom.PICK_HISTORY:v.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_VOTE,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.GAMES_JOINED},pollOpenedFrom:v.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_NAVIGATED},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const ao=({transport:t,$commonStore:e})=>{let r;const n=K(!1),i=5e3,{client:o,queryKey:s}=t.createPromiseClient(zr.AnalyticsService,{method:"send",params:[n]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const y=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...y,kind:v.Kind.SESSION_HEARTBEAT}}}})}catch(m){le.error(m,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{le.debug("mounted heartbeat"),r=a.subscribe(()=>{})},d=()=>{le.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{le.debug("disabled heartbeat"),n.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{le.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},le=ve("analytics");class uo{commonStore;notifications;polls;invitation;interactions;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Te(fe({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=ao({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new oo(this),this.polls=new so(this),this.invitation=new ro(this),this.interactions=new no(this);const{client:r}=e.analyticsTransport.createPromiseClient(zr.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",Ut.nanoid()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,le.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,le.debug("analytics disconnected")};write=(e,r)=>{r&&this.analyticsClient.unary({message:{case:e,value:r}}).then(()=>{le.trace("send analytics success",e,r)}).catch(n=>{le.error(n,"send analytics failed")})};writeCommon=(e,r)=>{this.commonStore.setValue(e,r)};onConnect=e=>{this.listeners.add(e),this.connected&&this.listenersCancels.add(e())};connectToSDK=e=>{this.onConnect(()=>e.stores.slStreamId.getAtomStore().subscribe(r=>{this.writeCommon("eventId",r)})),this.onConnect(()=>e.sdk.getActiveFeature().subscribe(r=>{r&&this.writeCommon("category",io[r]),r!==R.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",Ut.nanoid()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?v.ScreenOrientation.PORTRAIT:v.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const co=(t,e,r)=>{t.analytics=new uo(t),t.sdk.onMount(()=>(t.analytics.connect(),()=>{t.analytics.disconnect()})),r()};var rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nr={exports:{}},ir={exports:{}};function fo(t){var e=new t,r=e;function n(){var o=e;return o.next?e=o.next:(e=new t,r=e),o.next=null,o}function i(o){r.next=o,r=o}return{get:n,release:i}}var po=fo,ho=po;function nn(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 n=ho(yo),i=null,o=null,s=0,a=null,u={push:A,drain:W,saturated:W,pause:c,paused:!1,concurrency:r,running:d,resume:m,idle:b,length:f,getQueue:y,unshift:T,empty:W,kill:$,killAndDrain:M,error:z};return u;function d(){return s}function c(){u.paused=!0}function f(){for(var P=i,V=0;P;)P=P.next,V++;return V}function y(){for(var P=i,V=[];P;)V.push(P.value),P=P.next;return V}function m(){if(u.paused){u.paused=!1;for(var P=0;P<u.concurrency;P++)s++,N()}}function b(){return s===0&&u.length()===0}function A(P,V){var O=n.get();O.context=t,O.release=N,O.value=P,O.callback=V||W,O.errorHandler=a,s===u.concurrency||u.paused?o?(o.next=O,o=O):(i=O,o=O,u.saturated()):(s++,e.call(t,O.value,O.worked))}function T(P,V){var O=n.get();O.context=t,O.release=N,O.value=P,O.callback=V||W,O.errorHandler=a,s===u.concurrency||u.paused?i?(O.next=i,i=O):(i=O,o=O,u.saturated()):(s++,e.call(t,O.value,O.worked))}function N(P){P&&n.release(P);var V=i;V?u.paused?s--:(o===i&&(o=null),i=V.next,V.next=null,e.call(t,V.value,V.worked),o===null&&u.empty()):--s===0&&u.drain()}function $(){i=null,o=null,u.drain=W}function M(){i=null,o=null,u.drain(),u.drain=W}function z(P){a=P}}function W(){}function yo(){this.value=null,this.callback=W,this.next=null,this.release=W,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,n){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=W,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function go(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(c,f){e.call(this,c).then(function(y){f(null,y)},f)}var i=nn(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var f=new Promise(function(y,m){o(c,function(b,A){if(b){m(b);return}y(A)})});return f.catch(W),f}function u(c){var f=new Promise(function(y,m){s(c,function(b,A){if(b){m(b);return}y(A)})});return f.catch(W),f}function d(){if(i.idle())return new Promise(function(y){y()});var c=i.drain,f=new Promise(function(y){i.drain=function(){c(),y()}});return f}}ir.exports=nn;ir.exports.promise=go;var on=ir.exports,or={exports:{}},qe=typeof Reflect=="object"?Reflect:null,Or=qe&&typeof qe.apply=="function"?qe.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ut;qe&&typeof qe.ownKeys=="function"?ut=qe.ownKeys:Object.getOwnPropertySymbols?ut=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ut=function(e){return Object.getOwnPropertyNames(e)};function mo(t){console&&console.warn&&console.warn(t)}var sn=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}or.exports=F;or.exports.once=wo;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var Cr=10;function At(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(F,"defaultMaxListeners",{enumerable:!0,get:function(){return Cr},set:function(t){if(typeof t!="number"||t<0||sn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Cr=t}});F.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};F.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||sn(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 an(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return an(this)};F.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Or(u,this,r);else for(var d=u.length,c=fn(u,d),n=0;n<d;++n)Or(c[n],this,r);return!0};function un(t,e,r,n){var i,o,s;if(At(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=an(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,mo(a)}return t}F.prototype.addListener=function(e,r){return un(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return un(this,e,r,!0)};function vo(){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 cn(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=vo.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return At(r),this.on(e,cn(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return At(r),this.prependListener(e,cn(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(At(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():bo(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};F.prototype.off=F.prototype.removeListener;F.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function ln(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?So(i):fn(i,i.length)}F.prototype.listeners=function(e){return ln(this,e,!0)};F.prototype.rawListeners=function(e){return ln(this,e,!1)};F.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):dn.call(t,e)};F.prototype.listenerCount=dn;function dn(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}F.prototype.eventNames=function(){return this._eventsCount>0?ut(this._events):[]};function fn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function bo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function So(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function wo(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}pn(t,e,o,{once:!0}),e!=="error"&&Ao(t,i,{once:!0})})}function Ao(t,e,r){typeof t.on=="function"&&pn(t,"error",e,r)}function pn(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var hn=or.exports,Tt={},yn={},gn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;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 o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0},To=gn,sr=function(){return To()&&!!Symbol.toStringTag},_r=typeof Symbol<"u"&&Symbol,Eo=gn,Io=function(){return typeof _r!="function"||typeof Symbol!="function"||typeof _r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Eo()},kr={foo:{}},Oo=Object,Co=function(){return{__proto__:kr}.foo===kr.foo&&!({__proto__:null}instanceof Oo)},_o="Function.prototype.bind called on incompatible ",ko=Object.prototype.toString,Lo=Math.max,Po="[object Function]",Lr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var o=0;o<r.length;o+=1)n[o+e.length]=r[o];return n},Fo=function(e,r){for(var n=[],i=r||0,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},No=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},Do=function(e){var r=this;if(typeof r!="function"||ko.apply(r)!==Po)throw new TypeError(_o+r);for(var n=Fo(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,Lr(n,arguments));return Object(c)===c?c:this}return r.apply(e,Lr(n,arguments))},s=Lo(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+No(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var d=function(){};d.prototype=r.prototype,i.prototype=new d,d.prototype=null}return i},Ro=Do,ar=Function.prototype.bind||Ro,Vo=Function.prototype.call,$o=Object.prototype.hasOwnProperty,jo=ar,qo=jo.call(Vo,$o),I,Ue=SyntaxError,mn=Function,Me=TypeError,Ct=function(t){try{return mn('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var _t=function(){throw new Me},Mo=Ie?function(){try{return arguments.callee,_t}catch{try{return Ie(arguments,"callee").get}catch{return _t}}}():_t,Fe=Io(),Uo=Co(),U=Object.getPrototypeOf||(Uo?function(t){return t.__proto__}:null),De={},xo=typeof Uint8Array>"u"||!U?I:U(Uint8Array),Oe={"%AggregateError%":typeof AggregateError>"u"?I:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?I:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&U?U([][Symbol.iterator]()):I,"%AsyncFromSyncIteratorPrototype%":I,"%AsyncFunction%":De,"%AsyncGenerator%":De,"%AsyncGeneratorFunction%":De,"%AsyncIteratorPrototype%":De,"%Atomics%":typeof Atomics>"u"?I:Atomics,"%BigInt%":typeof BigInt>"u"?I:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?I:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?I:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?I:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?I:Float32Array,"%Float64Array%":typeof Float64Array>"u"?I:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?I:FinalizationRegistry,"%Function%":mn,"%GeneratorFunction%":De,"%Int8Array%":typeof Int8Array>"u"?I:Int8Array,"%Int16Array%":typeof Int16Array>"u"?I:Int16Array,"%Int32Array%":typeof Int32Array>"u"?I:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&U?U(U([][Symbol.iterator]())):I,"%JSON%":typeof JSON=="object"?JSON:I,"%Map%":typeof Map>"u"?I:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!U?I:U(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?I:Promise,"%Proxy%":typeof Proxy>"u"?I:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?I:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?I:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!U?I:U(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?I:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&U?U(""[Symbol.iterator]()):I,"%Symbol%":Fe?Symbol:I,"%SyntaxError%":Ue,"%ThrowTypeError%":Mo,"%TypedArray%":xo,"%TypeError%":Me,"%Uint8Array%":typeof Uint8Array>"u"?I:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?I:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?I:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?I:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?I:WeakMap,"%WeakRef%":typeof WeakRef>"u"?I:WeakRef,"%WeakSet%":typeof WeakSet>"u"?I:WeakSet};if(U)try{null.error}catch(t){var Bo=U(U(t));Oe["%Error.prototype%"]=Bo}var Qo=function t(e){var r;if(e==="%AsyncFunction%")r=Ct("async function () {}");else if(e==="%GeneratorFunction%")r=Ct("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Ct("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&U&&(r=U(i.prototype))}return Oe[e]=r,r},Pr={"%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"]},Ze=ar,ht=qo,Ko=Ze.call(Function.call,Array.prototype.concat),Go=Ze.call(Function.apply,Array.prototype.splice),Fr=Ze.call(Function.call,String.prototype.replace),yt=Ze.call(Function.call,String.prototype.slice),zo=Ze.call(Function.call,RegExp.prototype.exec),Ho=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Wo=/\\(\\)?/g,Jo=function(e){var r=yt(e,0,1),n=yt(e,-1);if(r==="%"&&n!=="%")throw new Ue("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Ue("invalid intrinsic syntax, expected opening `%`");var i=[];return Fr(e,Ho,function(o,s,a,u){i[i.length]=a?Fr(u,Wo,"$1"):s||o}),i},Yo=function(e,r){var n=e,i;if(ht(Pr,n)&&(i=Pr[n],n="%"+i[0]+"%"),ht(Oe,n)){var o=Oe[n];if(o===De&&(o=Qo(n)),typeof o>"u"&&!r)throw new Me("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new Ue("intrinsic "+e+" does not exist!")},Be=function(e,r){if(typeof e!="string"||e.length===0)throw new Me("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Me('"allowMissing" argument must be a boolean');if(zo(/^%?[^%]*%?$/,e)===null)throw new Ue("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Jo(e),i=n.length>0?n[0]:"",o=Yo("%"+i+"%",r),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],Go(n,Ko([0,1],d)));for(var c=1,f=!0;c<n.length;c+=1){var y=n[c],m=yt(y,0,1),b=yt(y,-1);if((m==='"'||m==="'"||m==="`"||b==='"'||b==="'"||b==="`")&&m!==b)throw new Ue("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(u=!0),i+="."+y,s="%"+i+"%",ht(Oe,s))a=Oe[s];else if(a!=null){if(!(y in a)){if(!r)throw new Me("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=n.length){var A=Ie(a,y);f=!!A,f&&"get"in A&&!("originalValue"in A.get)?a=A.get:a=a[y]}else f=ht(a,y),a=a[y];f&&!u&&(Oe[s]=a)}}return a},vn={exports:{}},Xo=Be,Gt=Xo("%Object.defineProperty%",!0),zt=function(){if(Gt)try{return Gt({},"a",{value:1}),!0}catch{return!1}return!1};zt.hasArrayLengthDefineBug=function(){if(!zt())return null;try{return Gt([],"length",{value:1}).length!==1}catch{return!0}};var bn=zt,Zo=Be,ct=Zo("%Object.getOwnPropertyDescriptor%",!0);if(ct)try{ct([],"length")}catch{ct=null}var ur=ct,es=bn(),cr=Be,We=es&&cr("%Object.defineProperty%",!0);if(We)try{We({},"a",{value:1})}catch{We=!1}var ts=cr("%SyntaxError%"),Ne=cr("%TypeError%"),Nr=ur,rs=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Ne("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Ne("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ne("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ne("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ne("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ne("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,u=!!Nr&&Nr(e,r);if(We)We(e,r,{configurable:s===null&&u?u.configurable:!s,enumerable:i===null&&u?u.enumerable:!i,value:n,writable:o===null&&u?u.writable:!o});else if(a||!i&&!o&&!s)e[r]=n;else throw new ts("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Sn=Be,Dr=rs,ns=bn(),Rr=ur,Vr=Sn("%TypeError%"),is=Sn("%Math.floor%"),os=function(e,r){if(typeof e!="function")throw new Vr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||is(r)!==r)throw new Vr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Rr){var s=Rr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(ns?Dr(e,"length",r,!0,!0):Dr(e,"length",r)),e};(function(t){var e=ar,r=Be,n=os,i=r("%TypeError%"),o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=r("%Object.defineProperty%",!0),d=r("%Math.max%");if(u)try{u({},"a",{value:1})}catch{u=null}t.exports=function(y){if(typeof y!="function")throw new i("a function is required");var m=a(e,s,arguments);return n(m,1+d(0,y.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(vn);var wn=vn.exports,An=Be,Tn=wn,ss=Tn(An("String.prototype.indexOf")),En=function(e,r){var n=An(e,!!r);return typeof n=="function"&&ss(e,".prototype.")>-1?Tn(n):n},as=sr(),us=En,Ht=us("Object.prototype.toString"),Et=function(e){return as&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:Ht(e)==="[object Arguments]"},In=function(e){return Et(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ht(e)!=="[object Array]"&&Ht(e.callee)==="[object Function]"},cs=function(){return Et(arguments)}();Et.isLegacyArguments=In;var ls=cs?Et:In,ds=Object.prototype.toString,fs=Function.prototype.toString,ps=/^\s*(?:function)?\*/,On=sr(),kt=Object.getPrototypeOf,hs=function(){if(!On)return!1;try{return Function("return function*() {}")()}catch{}},Lt,ys=function(e){if(typeof e!="function")return!1;if(ps.test(fs.call(e)))return!0;if(!On){var r=ds.call(e);return r==="[object GeneratorFunction]"}if(!kt)return!1;if(typeof Lt>"u"){var n=hs();Lt=n?kt(n):!1}return kt(e)===Lt},Cn=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Wt,lt;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{Wt=Object.defineProperty({},"length",{get:function(){throw lt}}),lt={},$e(function(){throw 42},null,Wt)}catch(t){t!==lt&&($e=null)}else $e=null;var gs=/^\s*class\b/,Jt=function(e){try{var r=Cn.call(e);return gs.test(r)}catch{return!1}},Pt=function(e){try{return Jt(e)?!1:(Cn.call(e),!0)}catch{return!1}},dt=Object.prototype.toString,ms="[object Object]",vs="[object Function]",bs="[object GeneratorFunction]",Ss="[object HTMLAllCollection]",ws="[object HTML document.all class]",As="[object HTMLCollection]",Ts=typeof Symbol=="function"&&!!Symbol.toStringTag,Es=!(0 in[,]),Yt=function(){return!1};if(typeof document=="object"){var Is=document.all;dt.call(Is)===dt.call(document.all)&&(Yt=function(e){if((Es||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=dt.call(e);return(r===Ss||r===ws||r===As||r===ms)&&e("")==null}catch{}return!1})}var Os=$e?function(e){if(Yt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,Wt)}catch(r){if(r!==lt)return!1}return!Jt(e)&&Pt(e)}:function(e){if(Yt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Ts)return Pt(e);if(Jt(e))return!1;var r=dt.call(e);return r!==vs&&r!==bs&&!/^\[object HTML/.test(r)?!1:Pt(e)},Cs=Os,_s=Object.prototype.toString,_n=Object.prototype.hasOwnProperty,ks=function(e,r,n){for(var i=0,o=e.length;i<o;i++)_n.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ls=function(e,r,n){for(var i=0,o=e.length;i<o;i++)n==null?r(e.charAt(i),i,e):r.call(n,e.charAt(i),i,e)},Ps=function(e,r,n){for(var i in e)_n.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Fs=function(e,r,n){if(!Cs(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),_s.call(e)==="[object Array]"?ks(e,r,i):typeof e=="string"?Ls(e,r,i):Ps(e,r,i)},Ns=Fs,Ft=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],Ds=typeof globalThis>"u"?rn:globalThis,Rs=function(){for(var e=[],r=0;r<Ft.length;r++)typeof Ds[Ft[r]]=="function"&&(e[e.length]=Ft[r]);return e},gt=Ns,Vs=Rs,$r=wn,lr=En,ft=ur,$s=lr("Object.prototype.toString"),kn=sr(),jr=typeof globalThis>"u"?rn:globalThis,Xt=Vs(),dr=lr("String.prototype.slice"),Nt=Object.getPrototypeOf,js=lr("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},mt={__proto__:null};kn&&ft&&Nt?gt(Xt,function(t){var e=new jr[t];if(Symbol.toStringTag in e){var r=Nt(e),n=ft(r,Symbol.toStringTag);if(!n){var i=Nt(r);n=ft(i,Symbol.toStringTag)}mt["$"+t]=$r(n.get)}}):gt(Xt,function(t){var e=new jr[t],r=e.slice||e.set;r&&(mt["$"+t]=$r(r))});var qs=function(e){var r=!1;return gt(mt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=dr(i,1))}catch{}}),r},Ms=function(e){var r=!1;return gt(mt,function(n,i){if(!r)try{n(e),r=dr(i,1)}catch{}}),r},Ln=function(e){if(!e||typeof e!="object")return!1;if(!kn){var r=dr($s(e),8,-1);return js(Xt,r)>-1?r:r!=="Object"?!1:Ms(e)}return ft?qs(e):null},Us=Ln,xs=function(e){return!!Us(e)};(function(t){var e=ls,r=ys,n=Ln,i=xs;function o(h){return h.call.bind(h)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),d=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),f=o(Boolean.prototype.valueOf);if(s)var y=o(BigInt.prototype.valueOf);if(a)var m=o(Symbol.prototype.valueOf);function b(h,$n){if(typeof h!="object")return!1;try{return $n(h),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=i;function A(h){return typeof Promise<"u"&&h instanceof Promise||h!==null&&typeof h=="object"&&typeof h.then=="function"&&typeof h.catch=="function"}t.isPromise=A;function T(h){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(h):i(h)||p(h)}t.isArrayBufferView=T;function N(h){return n(h)==="Uint8Array"}t.isUint8Array=N;function $(h){return n(h)==="Uint8ClampedArray"}t.isUint8ClampedArray=$;function M(h){return n(h)==="Uint16Array"}t.isUint16Array=M;function z(h){return n(h)==="Uint32Array"}t.isUint32Array=z;function P(h){return n(h)==="Int8Array"}t.isInt8Array=P;function V(h){return n(h)==="Int16Array"}t.isInt16Array=V;function O(h){return n(h)==="Int32Array"}t.isInt32Array=O;function Z(h){return n(h)==="Float32Array"}t.isFloat32Array=Z;function ee(h){return n(h)==="Float64Array"}t.isFloat64Array=ee;function Ce(h){return n(h)==="BigInt64Array"}t.isBigInt64Array=Ce;function be(h){return n(h)==="BigUint64Array"}t.isBigUint64Array=be;function oe(h){return u(h)==="[object Map]"}oe.working=typeof Map<"u"&&oe(new Map);function It(h){return typeof Map>"u"?!1:oe.working?oe(h):h instanceof Map}t.isMap=It;function ye(h){return u(h)==="[object Set]"}ye.working=typeof Set<"u"&&ye(new Set);function Ke(h){return typeof Set>"u"?!1:ye.working?ye(h):h instanceof Set}t.isSet=Ke;function _e(h){return u(h)==="[object WeakMap]"}_e.working=typeof WeakMap<"u"&&_e(new WeakMap);function Ot(h){return typeof WeakMap>"u"?!1:_e.working?_e(h):h instanceof WeakMap}t.isWeakMap=Ot;function ke(h){return u(h)==="[object WeakSet]"}ke.working=typeof WeakSet<"u"&&ke(new WeakSet);function se(h){return ke(h)}t.isWeakSet=se;function Le(h){return u(h)==="[object ArrayBuffer]"}Le.working=typeof ArrayBuffer<"u"&&Le(new ArrayBuffer);function et(h){return typeof ArrayBuffer>"u"?!1:Le.working?Le(h):h instanceof ArrayBuffer}t.isArrayBuffer=et;function l(h){return u(h)==="[object DataView]"}l.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&l(new DataView(new ArrayBuffer(1),0,1));function p(h){return typeof DataView>"u"?!1:l.working?l(h):h instanceof DataView}t.isDataView=p;var g=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function S(h){return u(h)==="[object SharedArrayBuffer]"}function k(h){return typeof g>"u"?!1:(typeof S.working>"u"&&(S.working=S(new g)),S.working?S(h):h instanceof g)}t.isSharedArrayBuffer=k;function L(h){return u(h)==="[object AsyncFunction]"}t.isAsyncFunction=L;function E(h){return u(h)==="[object Map Iterator]"}t.isMapIterator=E;function C(h){return u(h)==="[object Set Iterator]"}t.isSetIterator=C;function D(h){return u(h)==="[object Generator]"}t.isGeneratorObject=D;function G(h){return u(h)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=G;function Se(h){return b(h,d)}t.isNumberObject=Se;function tt(h){return b(h,c)}t.isStringObject=tt;function Pe(h){return b(h,f)}t.isBooleanObject=Pe;function rt(h){return s&&b(h,y)}t.isBigIntObject=rt;function hr(h){return a&&b(h,m)}t.isSymbolObject=hr;function Rn(h){return Se(h)||tt(h)||Pe(h)||rt(h)||hr(h)}t.isBoxedPrimitive=Rn;function Vn(h){return typeof Uint8Array<"u"&&(et(h)||k(h))}t.isAnyArrayBuffer=Vn,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(h){Object.defineProperty(t,h,{enumerable:!1,value:function(){throw new Error(h+" is not supported in userland")}})})})(yn);var Bs=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},Zt={exports:{}};typeof Object.create=="function"?Zt.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Zt.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}};var Qs=Zt.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(p){for(var g=Object.keys(p),S={},k=0;k<g.length;k++)S[g[k]]=Object.getOwnPropertyDescriptor(p,g[k]);return S},r=/%[sdj%]/g;t.format=function(l){if(!P(l)){for(var p=[],g=0;g<arguments.length;g++)p.push(s(arguments[g]));return p.join(" ")}for(var g=1,S=arguments,k=S.length,L=String(l).replace(r,function(C){if(C==="%%")return"%";if(g>=k)return C;switch(C){case"%s":return String(S[g++]);case"%d":return Number(S[g++]);case"%j":try{return JSON.stringify(S[g++])}catch{return"[Circular]"}default:return C}}),E=S[g];g<k;E=S[++g])$(E)||!ee(E)?L+=" "+E:L+=" "+s(E);return L},t.deprecate=function(l,p){if(typeof w<"u"&&w.noDeprecation===!0)return l;if(typeof w>"u")return function(){return t.deprecate(l,p).apply(this,arguments)};var g=!1;function S(){if(!g){if(w.throwDeprecation)throw new Error(p);w.traceDeprecation?console.trace(p):console.error(p),g=!0}return l.apply(this,arguments)}return S};var n={},i=/^$/;if(w.env.NODE_DEBUG){var o=w.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(l){if(l=l.toUpperCase(),!n[l])if(i.test(l)){var p=w.pid;n[l]=function(){var g=t.format.apply(t,arguments);console.error("%s %d: %s",l,p,g)}}else n[l]=function(){};return n[l]};function s(l,p){var g={seen:[],stylize:u};return arguments.length>=3&&(g.depth=arguments[2]),arguments.length>=4&&(g.colors=arguments[3]),N(p)?g.showHidden=p:p&&t._extend(g,p),O(g.showHidden)&&(g.showHidden=!1),O(g.depth)&&(g.depth=2),O(g.colors)&&(g.colors=!1),O(g.customInspect)&&(g.customInspect=!0),g.colors&&(g.stylize=a),c(g,l,g.depth)}t.inspect=s,s.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]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function a(l,p){var g=s.styles[p];return g?"\x1B["+s.colors[g][0]+"m"+l+"\x1B["+s.colors[g][1]+"m":l}function u(l,p){return l}function d(l){var p={};return l.forEach(function(g,S){p[g]=!0}),p}function c(l,p,g){if(l.customInspect&&p&&oe(p.inspect)&&p.inspect!==t.inspect&&!(p.constructor&&p.constructor.prototype===p)){var S=p.inspect(g,l);return P(S)||(S=c(l,S,g)),S}var k=f(l,p);if(k)return k;var L=Object.keys(p),E=d(L);if(l.showHidden&&(L=Object.getOwnPropertyNames(p)),be(p)&&(L.indexOf("message")>=0||L.indexOf("description")>=0))return y(p);if(L.length===0){if(oe(p)){var C=p.name?": "+p.name:"";return l.stylize("[Function"+C+"]","special")}if(Z(p))return l.stylize(RegExp.prototype.toString.call(p),"regexp");if(Ce(p))return l.stylize(Date.prototype.toString.call(p),"date");if(be(p))return y(p)}var D="",G=!1,Se=["{","}"];if(T(p)&&(G=!0,Se=["[","]"]),oe(p)){var tt=p.name?": "+p.name:"";D=" [Function"+tt+"]"}if(Z(p)&&(D=" "+RegExp.prototype.toString.call(p)),Ce(p)&&(D=" "+Date.prototype.toUTCString.call(p)),be(p)&&(D=" "+y(p)),L.length===0&&(!G||p.length==0))return Se[0]+D+Se[1];if(g<0)return Z(p)?l.stylize(RegExp.prototype.toString.call(p),"regexp"):l.stylize("[Object]","special");l.seen.push(p);var Pe;return G?Pe=m(l,p,g,E,L):Pe=L.map(function(rt){return b(l,p,g,E,rt,G)}),l.seen.pop(),A(Pe,D,Se)}function f(l,p){if(O(p))return l.stylize("undefined","undefined");if(P(p)){var g="'"+JSON.stringify(p).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l.stylize(g,"string")}if(z(p))return l.stylize(""+p,"number");if(N(p))return l.stylize(""+p,"boolean");if($(p))return l.stylize("null","null")}function y(l){return"["+Error.prototype.toString.call(l)+"]"}function m(l,p,g,S,k){for(var L=[],E=0,C=p.length;E<C;++E)ke(p,String(E))?L.push(b(l,p,g,S,String(E),!0)):L.push("");return k.forEach(function(D){D.match(/^\d+$/)||L.push(b(l,p,g,S,D,!0))}),L}function b(l,p,g,S,k,L){var E,C,D;if(D=Object.getOwnPropertyDescriptor(p,k)||{value:p[k]},D.get?D.set?C=l.stylize("[Getter/Setter]","special"):C=l.stylize("[Getter]","special"):D.set&&(C=l.stylize("[Setter]","special")),ke(S,k)||(E="["+k+"]"),C||(l.seen.indexOf(D.value)<0?($(g)?C=c(l,D.value,null):C=c(l,D.value,g-1),C.indexOf(`
|
|
3
|
+
`)>-1&&(L?C=C.split(`
|
|
4
|
+
`).map(function(G){return" "+G}).join(`
|
|
5
|
+
`).slice(2):C=`
|
|
6
|
+
`+C.split(`
|
|
7
|
+
`).map(function(G){return" "+G}).join(`
|
|
8
|
+
`))):C=l.stylize("[Circular]","special")),O(E)){if(L&&k.match(/^\d+$/))return C;E=JSON.stringify(""+k),E.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(E=E.slice(1,-1),E=l.stylize(E,"name")):(E=E.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),E=l.stylize(E,"string"))}return E+": "+C}function A(l,p,g){var S=l.reduce(function(k,L){return L.indexOf(`
|
|
9
|
+
`)>=0,k+L.replace(/\u001b\[\d\d?m/g,"").length+1},0);return S>60?g[0]+(p===""?"":p+`
|
|
10
|
+
`)+" "+l.join(`,
|
|
11
|
+
`)+" "+g[1]:g[0]+p+" "+l.join(", ")+" "+g[1]}t.types=yn;function T(l){return Array.isArray(l)}t.isArray=T;function N(l){return typeof l=="boolean"}t.isBoolean=N;function $(l){return l===null}t.isNull=$;function M(l){return l==null}t.isNullOrUndefined=M;function z(l){return typeof l=="number"}t.isNumber=z;function P(l){return typeof l=="string"}t.isString=P;function V(l){return typeof l=="symbol"}t.isSymbol=V;function O(l){return l===void 0}t.isUndefined=O;function Z(l){return ee(l)&&ye(l)==="[object RegExp]"}t.isRegExp=Z,t.types.isRegExp=Z;function ee(l){return typeof l=="object"&&l!==null}t.isObject=ee;function Ce(l){return ee(l)&&ye(l)==="[object Date]"}t.isDate=Ce,t.types.isDate=Ce;function be(l){return ee(l)&&(ye(l)==="[object Error]"||l instanceof Error)}t.isError=be,t.types.isNativeError=be;function oe(l){return typeof l=="function"}t.isFunction=oe;function It(l){return l===null||typeof l=="boolean"||typeof l=="number"||typeof l=="string"||typeof l=="symbol"||typeof l>"u"}t.isPrimitive=It,t.isBuffer=Bs;function ye(l){return Object.prototype.toString.call(l)}function Ke(l){return l<10?"0"+l.toString(10):l.toString(10)}var _e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ot(){var l=new Date,p=[Ke(l.getHours()),Ke(l.getMinutes()),Ke(l.getSeconds())].join(":");return[l.getDate(),_e[l.getMonth()],p].join(" ")}t.log=function(){console.log("%s - %s",Ot(),t.format.apply(t,arguments))},t.inherits=Qs,t._extend=function(l,p){if(!p||!ee(p))return l;for(var g=Object.keys(p),S=g.length;S--;)l[g[S]]=p[g[S]];return l};function ke(l,p){return Object.prototype.hasOwnProperty.call(l,p)}var se=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(p){if(typeof p!="function")throw new TypeError('The "original" argument must be of type Function');if(se&&p[se]){var g=p[se];if(typeof g!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(g,se,{value:g,enumerable:!1,writable:!1,configurable:!0}),g}function g(){for(var S,k,L=new Promise(function(D,G){S=D,k=G}),E=[],C=0;C<arguments.length;C++)E.push(arguments[C]);E.push(function(D,G){D?k(D):S(G)});try{p.apply(this,E)}catch(D){k(D)}return L}return Object.setPrototypeOf(g,Object.getPrototypeOf(p)),se&&Object.defineProperty(g,se,{value:g,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(g,e(p))},t.promisify.custom=se;function Le(l,p){if(!l){var g=new Error("Promise was rejected with a falsy value");g.reason=l,l=g}return p(l)}function et(l){if(typeof l!="function")throw new TypeError('The "original" argument must be of type Function');function p(){for(var g=[],S=0;S<arguments.length;S++)g.push(arguments[S]);var k=g.pop();if(typeof k!="function")throw new TypeError("The last argument must be of type Function");var L=this,E=function(){return k.apply(L,arguments)};l.apply(this,g).then(function(C){w.nextTick(E.bind(null,null,C))},function(C){w.nextTick(Le.bind(null,C,E))})}return Object.setPrototypeOf(p,Object.getPrototypeOf(l)),Object.defineProperties(p,e(l)),p}t.callbackify=et})(Tt);const{inherits:Ks,format:Dt}=Tt;function we(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 n(i,o,s){if(!new.target)return new n(i,o,s);Error.captureStackTrace(this,n),this.code=t,this.message=e,this.name="AvvioError",i&&o&&s?this.message=Dt(e,i,o,s):i&&o?this.message=Dt(e,i,o):i?this.message=Dt(e,i):this.message=e}return n.prototype[Symbol.toStringTag]="Error",n.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},Ks(n,r),n}var Pn={createError:we,AVV_ERR_EXPOSE_ALREADY_DEFINED:we("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:we("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:we("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:we("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:we("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:we("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},Gs=function t(e,r,n){r===void 0&&(r=""),n||(n={});var i=function(u){var d={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return n.unicode===!1?d[u]:u};typeof e=="string"&&(e={label:e});var o=e.nodes||[],s=(e.label||"").split(`
|
|
12
|
+
`),a=`
|
|
13
|
+
`+r+(o.length?i("│"):" ")+" ";return r+s.join(a)+`
|
|
14
|
+
`+o.map(function(u,d){var c=d===o.length-1,f=u.nodes&&u.nodes.length,y=r+(c?" ":i("│"))+" ";return r+i(c?"└":"├")+i("─")+i(f?"┬":"─")+" "+t(u,y,n).slice(r.length+2)}).join("")};const zs=Gs,qr=Symbol("avvio.TimeTree.untrackNode"),Rt=Symbol("avvio.TimeTree.trackNode"),Mr=Symbol("avvio.TimeTree.getParent"),Ur=Symbol("avvio.TimeTree.getNode"),xr=Symbol("avvio.TimeTree.addNode");let Hs=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Rt](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])}[qr](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)}[Mr](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[Ur](e){return this.tableId.get(e)}[xr](e,r,n){if(e===null)return this.root={id:"root",label:r,start:n,nodes:[]},this[Rt](this.root),this.root.id;const o=this[Mr](e),s=`${r}-${Math.random()}`,a={id:s,parent:e,start:n,label:r,nodes:[]};return o.nodes.push(a),this[Rt](a),s}start(e,r,n=Date.now()){return this[xr](e,r,n)}stop(e,r=Date.now()){const n=this[Ur](e);n&&(n.stop=r,n.diff=n.stop-n.start||0,this[qr](n))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const e=n=>(n.label=`${n.label} ${n.diff} ms`,n.nodes.length>0&&(n.nodes=n.nodes.map(i=>e(i))),n),r=e(this.toJSON());return zs(r)}};var Ws=Hs,fr={exports:{}},er={exports:{}},Vt,Br;function Js(){if(Br)return Vt;Br=1;var t=1e3,e=t*60,r=e*60,n=r*24,i=n*7,o=n*365.25;Vt=function(c,f){f=f||{};var y=typeof c;if(y==="string"&&c.length>0)return s(c);if(y==="number"&&isFinite(c))return f.long?u(c):a(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function s(c){if(c=String(c),!(c.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(f){var y=parseFloat(f[1]),m=(f[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return y*o;case"weeks":case"week":case"w":return y*i;case"days":case"day":case"d":return y*n;case"hours":case"hour":case"hrs":case"hr":case"h":return y*r;case"minutes":case"minute":case"mins":case"min":case"m":return y*e;case"seconds":case"second":case"secs":case"sec":case"s":return y*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return y;default:return}}}}function a(c){var f=Math.abs(c);return f>=n?Math.round(c/n)+"d":f>=r?Math.round(c/r)+"h":f>=e?Math.round(c/e)+"m":f>=t?Math.round(c/t)+"s":c+"ms"}function u(c){var f=Math.abs(c);return f>=n?d(c,f,n,"day"):f>=r?d(c,f,r,"hour"):f>=e?d(c,f,e,"minute"):f>=t?d(c,f,t,"second"):c+" ms"}function d(c,f,y,m){var b=f>=y*1.5;return Math.round(c/y)+" "+m+(b?"s":"")}return Vt}function Ys(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=i,r.enabled=s,r.humanize=Js(),r.destroy=d,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let f=0;for(let y=0;y<c.length;y++)f=(f<<5)-f+c.charCodeAt(y),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(c){let f,y=null,m,b;function A(...T){if(!A.enabled)return;const N=A,$=Number(new Date),M=$-(f||$);N.diff=M,N.prev=f,N.curr=$,f=$,T[0]=r.coerce(T[0]),typeof T[0]!="string"&&T.unshift("%O");let z=0;T[0]=T[0].replace(/%([a-zA-Z%])/g,(V,O)=>{if(V==="%%")return"%";z++;const Z=r.formatters[O];if(typeof Z=="function"){const ee=T[z];V=Z.call(N,ee),T.splice(z,1),z--}return V}),r.formatArgs.call(N,T),(N.log||r.log).apply(N,T)}return A.namespace=c,A.useColors=r.useColors(),A.color=r.selectColor(c),A.extend=n,A.destroy=r.destroy,Object.defineProperty(A,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(m!==r.namespaces&&(m=r.namespaces,b=r.enabled(c)),b),set:T=>{y=T}}),typeof r.init=="function"&&r.init(A),A}function n(c,f){const y=r(this.namespace+(typeof f>"u"?":":f)+c);return y.log=this.log,y}function i(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let f;const y=(typeof c=="string"?c:"").split(/[\s,]+/),m=y.length;for(f=0;f<m;f++)y[f]&&(c=y[f].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function o(){const c=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),c}function s(c){if(c[c.length-1]==="*")return!0;let f,y;for(f=0,y=r.skips.length;f<y;f++)if(r.skips[f].test(c))return!1;for(f=0,y=r.names.length;f<y;f++)if(r.names[f].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function u(c){return c instanceof Error?c.stack||c.message:c}function d(){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 Xs=Ys;(function(t,e){e.formatArgs=n,e.save=i,e.load=o,e.useColors=r,e.storage=s(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!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 n(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;u.splice(1,0,d,"color: inherit");let c=0,f=0;u[0].replace(/%[a-zA-Z%]/g,y=>{y!=="%%"&&(c++,y==="%c"&&(f=c))}),u.splice(f,0,d)}e.log=console.debug||console.log||(()=>{});function i(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch{}}function o(){let u;try{u=e.storage.getItem("debug")}catch{}return!u&&typeof w<"u"&&"env"in w&&(u=w.env.DEBUG),u}function s(){try{return localStorage}catch{}}t.exports=Xs(e);const{formatters:a}=t.exports;a.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(er,er.exports);var Fn=er.exports;const Zs=on,ea=hn.EventEmitter,ta=Tt.inherits,x=Fn("avvio"),{AVV_ERR_READY_TIMEOUT:ra}=Pn,$t=Symbol.for("plugin-meta");function na(t,e){return t[$t]&&t[$t].name?t[$t].name:typeof e<"u"&&typeof e!="function"&&e.name?e.name:t.name?t.name:t.toString().split(`
|
|
15
|
+
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function ia(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function Qe(t,e,r,n,i){this.started=!1,this.func=e,this.opts=r,this.onFinish=null,this.parent=t,this.timeout=i===void 0?t._timeout:i,this.name=na(e,r),this.isAfter=n,this.q=Zs(t,oa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}ta(Qe,ea);Qe.prototype.exec=function(t,e){const r=this.func;let n=!1;const i=this.name;if(this.parent._error&&!this.isAfter){x("skipping loading of plugin as parent errored and it is not an after",i),w.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(u){return x("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,x("exec",i);let o;const s=u=>{if(n){x("loading complete",i);return}this._error=u,x(u?"exec errored":"exec completed",i),n=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(x("setting up timeout",i,this.timeout),o=setTimeout(function(){x("timed out",i),o=null;const u=new ra(i);u.fn=r,s(u)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const a=r(this.server,this.opts,s);a&&typeof a.then=="function"&&(x("exec: resolving promise",i),a.then(()=>w.nextTick(s),u=>w.nextTick(s,u)))};Qe.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,n)=>{this._error=r,this.q.pause(),r?(x("rejecting promise",this.name,r),this._promise.reject(r)):(x("resolving promise",this.name),this._promise.resolve()),this._promise=null,w.nextTick(n,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=ia(),e=this._promise.promise,this.server?t():this.on("start",t)),e};Qe.prototype.enqueue=function(t,e){x("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};Qe.prototype.finish=function(t,e){x("finish",this.name,t);const r=()=>{this.loaded||(x("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 n=()=>{if(x("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{x("wrap"),queueMicrotask(n)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else r();else x("delayed",this.name),this.q.drain=()=>{x("drain",this.name),this.q.drain=sa,queueMicrotask(n)}};queueMicrotask(n),this.q.resume()};function oa(t,e){const r=this;w.nextTick(pr.bind(r),t,e)}function pr(t,e){if(typeof t.func.then=="function"){t.func.then(n=>{typeof n.default=="function"&&(n=n.default),t.func=n,pr.call(this,t,e)},e);return}const r=this._current[0];this._current.unshift(t),t.exec(r&&r.server||this._server,n=>{t.finish(n,i=>{this._current.shift(),e(i)})})}function sa(){}fr.exports=Qe;fr.exports.loadPlugin=pr;var aa=fr.exports;const Qr=on,ua=hn.EventEmitter,ca=Tt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:jt,AVV_ERR_CALLBACK_NOT_FN:Je,AVV_ERR_PLUGIN_NOT_VALID:la,AVV_ERR_ROOT_PLG_BOOTED:da,AVV_ERR_READY_TIMEOUT:fa}=Pn,pa=Ws,tr=aa,xe=Fn("avvio"),vt=Symbol("kAvvio"),qt=Symbol("kThenifyDoNotWrap");function ha(t,e,r){const n=e.expose||{},i=n.use||"use",o=n.after||"after",s=n.ready||"ready",a=n.onClose||"onClose",u=n.close||"close";if(t[i])throw new jt(i);if(t[o])throw new jt(o);if(t[s])throw new jt(s);t[i]=function(d,c){return r.use(d,c),this},Object.defineProperty(t,"then",{get:Nn.bind(r)}),t[vt]=!0,t[o]=function(d){return typeof d!="function"?r._loadRegistered():(r.after(Mt(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new Je(s,typeof d);return r.ready(d?Mt(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new Je(a,typeof d);return r.onClose(ba(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new Je(u,typeof d);return d?(r.close(Mt(d,this)),this):r.close()}}function Q(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 Q)){const n=new Q(t,e,r);return t&&ha(t,e,n),n}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 pa,this._readyQ=Qr(this,Dn,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=Kr},this._closeQ=Qr(this,va,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=Kr},this._doStart=null,this._root=new tr(this,ya.bind(this),e,!1,0),this._root.once("start",(n,i,o)=>{const s=this.pluginTree.start(null,i,o);this._root.once("loaded",(a,u,d)=>{this.pluginTree.stop(s,d)})}),tr.loadPlugin.call(this,this._root,n=>{xe("root plugin ready");try{this.emit("preReady"),this._root=null}catch(i){n=n||this._error||i}if(n){if(this._error=n,this._readyQ.length()===0)throw n}else this.booted=!0;this._readyQ.resume()})}function ya(t,e,r){this._doStart=r,e.autostart&&this.start()}ca(Q,ua);Q.prototype.start=function(){return this.started=!0,w.nextTick(this._doStart),this};Q.prototype.override=function(t,e,r){return t};function ga(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new la(typeof t);return t}Q.prototype[vt]=!0;Q.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};Q.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&w.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(Q.prototype,"then",{get:Nn});Q.prototype._addPlugin=function(t,e,r){if(t=ga(t),e=e||{},this.booted)throw new da;const n=this._current[0],i=new tr(this,t,e,r);if(i.once("start",(o,s,a)=>{const u=this.pluginTree.start(n.name,s,a);i.once("loaded",(d,c,f)=>{this.pluginTree.stop(u,f)})}),n.loaded)throw new Error(i.name,n.name);return n.enqueue(i,o=>{o&&(this._error=o)}),i};Q.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,n,i){Dn.call(this,t,i)}return this};Q.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};Q.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new Je("close",typeof t)}else e=new Promise(function(r,n){t=function(i){if(i)return n(i);r()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),w.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};Q.prototype.ready=function(t){if(t){if(typeof t!="function")throw new Je("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,r)=>{this._readyQ.push(i),this.start();const n=this._current[0].server;function i(o,s,a){o?r(o):e(n),w.nextTick(a)}})};Q.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};Q.prototype.toJSON=function(){return this.pluginTree.toJSON()};function Kr(){}function Nn(){if(this.booted){xe("thenify returning null because we are already booted");return}if(this[qt]){this[qt]=!1;return}return xe("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[qt]=!0,t(this._server)),e)}function Dn(t,e){const r=this._server,n=this._error;let i;if(this._error=null,t.length===0)this._error=n,i=t(),i&&!i[vt]&&typeof i.then=="function"?i.then(()=>w.nextTick(e),o=>w.nextTick(e,o)):w.nextTick(e);else if(t.length===1)i=t(n),i&&!i[vt]&&typeof i.then=="function"?i.then(()=>w.nextTick(e),o=>w.nextTick(e,o)):w.nextTick(e);else if(this._timeout===0){const o=s=>{this._error=s,e(this._error)};t.length===2?t(n,o):t(n,r,o)}else ma.call(this,t,n,r,e)}function ma(t,e,r,n){const i=t.name;xe("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{xe("timed out",i),o=null;const a=new fa(i);a.fn=t,this._error=a,n(a)},this._timeout);t.length===2?t(e,s.bind(this)):t(e,r,s.bind(this));function s(a){o&&(clearTimeout(o),this._error=a,n(this._error))}}function va(t,e){const r=this._server,n=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let i;n?i=t(r):i=t(this._error),i&&typeof i.then=="function"?(xe("resolving close/onClose promise"),i.then(()=>w.nextTick(e),o=>w.nextTick(e,o))):w.nextTick(e)}else t.length===2?t(n?r:this._error,e):n?t(r,e):t(this._error,r,e)}function ba(t,e){return r.bind(e);function r(n,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t(this,i)}}function Mt(t,e){return r.bind(e);function r(n,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){w.nextTick(i,n)},i):w.nextTick(i,n)):t.length===1?(o=t(n),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t.length===2?t(n,i):t(n,this,i):w.nextTick(i)}}nr.exports=Q;nr.exports.express=function(t){return Q(t,{expose:{use:"load"}})};var Sa=nr.exports;const wa=lo(Sa);(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(n){const i=r?window.performance.now():new Date().getTime(),o=Math.max(0,16-(i-e)),s=window.setTimeout(function(){n(i+o)},o);return e=i+o,s},window.cancelAnimationFrame=clearTimeout}})();function Aa(t,e=!0,r=!0,n){console.log("start sdk");const i=e?"https://grpc-sdk.streamlayer.io:443":"https://grpc-sdk.next.streamlayer.io:443",o=e?"https://grpc.streamlayer.io:443":"https://grpc.next.streamlayer.io:443",s=wa(Object.create({}),{autostart:!1});return s.use(Qi),s.use(qi,{onDeepLinkHandled:n?.onDeepLinkHandled}),s.use(Bi,{videoPlayerController:n?.videoPlayerController}),s.use(fi,{sdkKey:t,host:i,analyticsHost:o,version:n?.version}),s.use(mi),s.use(xi),s.use(to),s.use(Pi),s.use(co),s.after((a,u,d)=>{if(a)throw a;u.ready(),d()}),r&&s.after(async(a,u,d)=>{if(a)throw a;await u.sdk.initializeApp(),d()}),s.onClose(()=>{console.log("close")}),s}exports.StreamLayer=Aa;
|