@streamlayer/sdk-web 1.14.6 → 1.15.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 +6 -6
- package/lib/es/index.js +121 -94
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ci=require("pino"),m=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),z=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),B=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),st=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),Z=require("nanostores"),bt=require("uuid"),Q=require("@connectrpc/connect"),Nn=require("@connectrpc/connect-web"),Ln=require("@nanostores/query"),hr=require("@streamlayer/sl-eslib/sports/events/events_pb"),et=require("@streamlayer/sl-eslib/sdkSettings/client/client_pb"),yn=require("@streamlayer/sl-eslib/users/users_pb"),yr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb"),di=require("@streamlayer/sl-eslib/shortLinks/linksClient_pb"),h=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),mr=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_pb"),Fn=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),te=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function li(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var gr={exports:{}},j=gr.exports={},se,ae;function en(){throw new Error("setTimeout has not been defined")}function tn(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?se=setTimeout:se=en}catch{se=en}try{typeof clearTimeout=="function"?ae=clearTimeout:ae=tn}catch{ae=tn}})();function br(t){if(se===setTimeout)return setTimeout(t,0);if((se===en||!se)&&setTimeout)return se=setTimeout,setTimeout(t,0);try{return se(t,0)}catch{try{return se.call(null,t,0)}catch{return se.call(this,t,0)}}}function fi(t){if(ae===clearTimeout)return clearTimeout(t);if((ae===tn||!ae)&&clearTimeout)return ae=clearTimeout,clearTimeout(t);try{return ae(t)}catch{try{return ae.call(null,t)}catch{return ae.call(this,t)}}}var me=[],qe=!1,Ae,dt=-1;function pi(){!qe||!Ae||(qe=!1,Ae.length?me=Ae.concat(me):dt=-1,me.length&&vr())}function vr(){if(!qe){var t=br(pi);qe=!0;for(var e=me.length;e;){for(Ae=me,me=[];++dt<e;)Ae&&Ae[dt].run();dt=-1,e=me.length}Ae=null,qe=!1,fi(t)}}j.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];me.push(new Sr(t,e)),me.length===1&&!qe&&br(vr)};function Sr(t,e){this.fun=t,this.array=e}Sr.prototype.run=function(){this.fun.apply(null,this.array)};j.title="browser";j.browser=!0;j.env={};j.argv=[];j.version="";j.versions={};function be(){}j.on=be;j.addListener=be;j.once=be;j.off=be;j.removeListener=be;j.removeAllListeners=be;j.emit=be;j.prependListener=be;j.prependOnceListener=be;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 hi=gr.exports;const _=li(hi),yi=ci.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ce=(t,e)=>yi.child({name:t},e);class mi extends Event{slEventBus;constructor(e,n){super(e),this.slEventBus=n}}const gi=ce("event-bus");class bi{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,n)=>{const r=new mi(this.name,{...n,type:e});gi.debug(r,"Emitting event"),window.dispatchEvent(r)};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 vi{}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));window.slStore=Object.create(null);class _t{store;name;constructor(e,n){this.store=e,this.name=n}getStore(){return this.store}}const Si=t=>{const e=Object.keys(t);return Z.computed(e.map(n=>t[n].getStore()),(...n)=>Object.fromEntries(e.map((r,i)=>[r,n[i]])))};class Oe extends _t{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,n)=>this.getStore().setKey(e,n);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const Y=t=>Z.map(t);var pe;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(pe||(pe={}));const wi={[B.SdkOverlayType.BETTING]:"betting",[B.SdkOverlayType.GAMES]:"games",[B.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[B.SdkOverlayType.TWITTER]:"twitter"};var Je;(function(t){t.Ready="ready",t.Suspended="suspended"})(Je||(Je={}));const Ti=new Set(["equals","clone","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","getType"]);class wr{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...n},r){this.settingsKey=wi[n.type],this.status=Z.atom(Je.Suspended),this.config=new Oe(Y(n),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Oe(Y(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Oe(Y({}),`feature:settings:${this.settingsKey}`),this.source=r}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(Je.Ready)};disable=()=>{this.status.set(Je.Suspended)};setFeatureConfig=({settings:e,...n})=>{let r;for(r in n)this.config.setValue(r,n[r]);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)!Ti.has(o)&&i[o]&&this.settings.setValue(o,i[o])}}};update=(e,n)=>{this.source===pe.STREAM&&n===pe.ORGANIZATION||(this.setFeatureConfig(e),this.source=n)};fireEvent(e){for(const n of this.listeners.values())try{n.onEvent(e)}catch(r){console.error(r)}}}class X extends _t{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 x=t=>Z.atom(t);class ne extends _t{atomStore;constructor(e,n,r){super(e,`api:${n}`),this.atomStore=Z.atom(),r&&e.subscribe(i=>{const o=this.atomStore.get(),s=r(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 M=new bi;async function*Ei(t,e){for await(const n of e){t.response.message=n,t.received_at=Date.now(),t.id=Date.now();const r={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(r),yield n}}const Ai=()=>t=>async e=>{const n={id:Date.now(),name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries()),message:e.message},response:{}};window.postMessage({type:"__GRPC_DEVTOOLS_EXTENSION__",data:n});try{const r=await t(e);if(n.received_at=Date.now(),n.response.header=Object.fromEntries(r.header.entries()),n.response.trailer=Object.fromEntries(r.trailer.entries()),e.stream){const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...n,stream:!0}};return window.postMessage(i),{...r,message:Ei(n,r.message)}}else{n.response.message=r.message,n.latency=n.received_at-n.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};window.postMessage(i)}return r}catch(r){n.received_at=Date.now(),n.response.trailer={"grpc-status":r.code,"grpc-message":r.rawMessage},n.response.message=r.rawMessage,n.latency=n.received_at-n.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};throw window.postMessage(i),r}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function Tr(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")}class He{delimiter=":";prefix;storage;constructor(e="main",n=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=n}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 n=e.pop()||"",r=this.generateKey(e);try{this.storage.setItem(r,n)}catch(i){Tr(i)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(r,n))}};read=(...e)=>{const n=this.storage.getItem(this.generateKey(e));return n===null?void 0:n};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var ee;(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"})(ee||(ee={}));const Dn=ce("grpc:stream");class Oi{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,n,r,i){const o={status:ee.Init,ts:new Date,log:[]};this.state=new Oe(Y(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=r,this.method=n,i.withStore&&(this.store=new X(x(null),`subscription:${i.name}:store`)),"subscribe"in r&&typeof r.subscribe=="function"&&(this.paramsListener=r.subscribe(s=>{this.state.getValue("status")===ee.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(ee.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const n=this.state.getStore().get().log,r=`${this.options.name} ${new Date().toISOString()}: ${e}`;if(n.push(r),this.state.setValue("log",n),localStorage.getItem("SL_DEBUG")){e.startsWith("received data")?Dn.trace({name:this.options.name,attempt:this.attempt},"received data"):Dn.trace({name:this.options.name,attempt:this.attempt},e);try{window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
|
|
2
|
-
`+r)}catch(i){Tr(i)&&window.sessionStorage.removeItem("slstreamlogs"),window.sessionStorage.setItem("slstreamlogs",r)}}};addListener=(e,n)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),()=>{}):(this.listeners.set(e,n),this.addStateLog(`listener '${e}' added`),()=>this.removeListener(e));removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(ee.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 r={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,r);for await(const o of i)this.attempt=0,this.onData(o)}catch(r){r instanceof Q.ConnectError&&r.code!=Q.Code.Canceled&&this.onStreamError(r)}})(),this.updateState(ee.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(ee.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(ee.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),n=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(ee.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${n}ms`),this.connect(),this.reconnectTimeout=void 0},n)}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[,n]of this.listeners)n(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(n){this.addStateLog(`error process data => ${n}`)}};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(ee.Failed),this.state.setValue("error",e),e.code===Q.Code.Unknown&&e.cause==="missing trailer"&&(this.attempt=0),this.reconnect();return}this.disconnect()}}}const Ii=new Set([Q.Code.Unknown,Q.Code.Internal,Q.Code.DeadlineExceeded,Q.Code.ResourceExhausted,Q.Code.FailedPrecondition,Q.Code.Unavailable,Q.Code.DataLoss]),Rn=ce("grpc:retry"),_i=t=>async e=>{const n=e.contextValues.get(nn.retryAttempts),r=300,i=e.contextValues.get(nn.retryDelay);if(e.stream||n===0)return t(e);Rn.trace({url:e.url,attempts:n,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Rn.trace({attempt:o,error:s,url:e.url},"retry attempt");const a=Q.ConnectError.from(s);if(o>=n||!(a instanceof Q.ConnectError)||!Ii.has(a.code))throw s;const u=Math.min(i,Math.pow(2,o)*r),d=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,d))}},nn={retryAttempts:Q.createContextKey(10,{description:"Number of attempts to retry"}),retryDelay:Q.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},ki=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=bt.v4();return localStorage.setItem("sl-device-id",e),e},Pi=()=>navigator.userAgentData?.platform||navigator.platform,Ci=t=>t?"webOS":navigator.userAgentData&&navigator.userAgentData.mobile||"ontouchstart"in window||navigator.maxTouchPoints>0?"mobile-web":"desktop-web";class Vn{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;storeCache;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,n){this.host=e,this.opts=n,this.$headers=new Oe(Y({"sl-device-id":ki(),"sl-device-os":Pi(),"sl-platform":Ci(n?.webOS)}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map,this.storeCache=new Map;const[r,i,o]=Ln.nanoquery({dedupeTime:n?.dedupeTime,refetchInterval:n?.refetchInterval});this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:o},this.transport=Nn.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=Nn.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors})}addSubscription=(e,n,r)=>{const i=this.subscriptions.get(n);if(i)return i;const o=new Oi(this.$headers,e,n,r);return this.subscriptions.set(n,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,n,r]=Ln.nanoquery({dedupeTime:this.opts?.dedupeTime,refetchInterval:this.opts?.refetchInterval});this.nanoquery={createFetcherStore:e,createMutatorStore:n,utils:r}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(n=>n!==e)};getClient=e=>{const n=e.typeName;if(this.clients.has(n))return this.clients.get(n);const r=Q.createClient(e,this.transport);return this.clients.set(n,r),r};getStreamClient=e=>{const n=`stream-${e.typeName}`;if(this.clients.has(n))return this.clients.get(n);const r=Q.createClient(e,this.streamTransport);return this.clients.set(n,r),r};createPromiseClient=(e,{params:n=[],method:r})=>{const i=this.getClient(e),o=r.toString(),s=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1),...Array.isArray(n)?n:[n]],a=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1)];return{client:i,createRequestOptions:d=>{const c=Q.createContextValues();for(const l in d){const p=nn[l];c.set(p,d[l])}return c},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,n)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",n)};setHeader=(e,n)=>this.$headers.setValue(e,n);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=n=>r=>{const i=this.$headers.getValues();for(const o in i)r.header.set(o,i[o]);return n(r)};this.interceptors.push(e),this.interceptors.push(Ai()),this.opts?.retryable&&this.interceptors.push(_i)}}const Ni=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(hr.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s||typeof s!="string")return"";try{return(await n.retrieveEventId({id:s})).data?.id||""}catch{return""}}})},Li=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>s?(await n.getStream({id:s})).data?.attributes:void 0})},Fi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(hr.Events,{method:"summary",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>s?(await n.summary({id:s})).data?.attributes:void 0})},Di=(t,e)=>{const{queryKey:n,client:r}=e.createPromiseClient(yn.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{if(!e.getHeader("authorization"))return{data:void 0};const{data:o}=await r.me({});return{data:o}}})},Ri=t=>{const{client:e,createRequestOptions:n}=t.createPromiseClient(yn.Users,{method:"bypassAuth"}),r=n({retryAttempts:0});return({userKey:i,schema:o,init:s,inviterKey:a})=>e.bypassAuth({userKey:i,schema:o,init:s,inviterKey:a},{contextValues:r})},Vi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>(await n.get({})).data?.attributes})},Ui=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{const i=await n.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},Bi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>(await n.getOrganizationAdvertising({})).data?.attributes})},Mi=(t,e,n)=>{t.transport=new Vn(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0,webOS:e.webOS}),t.analyticsTransport=new Vn(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(r=>{t.analyticsTransport.$headers.getStore().set(r)}),t.sdk.onMount({name:"transport"},()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),n()};var fe;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(fe||(fe={}));class Be extends He{constructor(){super("user")}setSchema=e=>{this.write(fe.SCHEMA,e)};getSchema=()=>this.read(fe.SCHEMA);setToken=e=>{this.write(fe.TOKEN,e)};getToken=()=>this.read(fe.TOKEN);setExternalToken=e=>{this.write(fe.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(fe.EXTERNAL_TOKEN);removeToken=()=>{this.remove(fe.TOKEN)}}var he;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(he||(he={}));const $i=t=>{const e=new Be,n=new X(x(e.getExternalToken()),"userKey"),r=new X(x(e.getToken()),"userToken"),i=new ne(Di(r.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 ne(Vi(r.getStore(),t),"userSettings");return{userKey:n,userToken:r,user:i,userSettings:o}},qi=t=>{const e=new X(x(void 0),"providerStreamId"),n=new ne(Ni(e.getStore(),t),"slStreamId",o=>o?.data),r=new ne(Li(n.getAtomStore(),t),"streamSettings"),i=new ne(Fi(n.getAtomStore(),t),"streamSettings");return n.getAtomStore().listen(o=>{(o===""||o===void 0)&&(r.getStore().mutate(void 0),i.getStore().mutate(void 0))}),{providerStreamId:e,slStreamId:n,streamSettings:r,streamSummary:i}},Qi=t=>{const e=new X(x(void 0),"enabled"),n=new X(x(he.DISABLED),"status"),r=new ne(Ui(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new ne(Bi(r.getAtomStore(),t),"organizationAdvertising"),o=$i(t),s=qi(t);return{enabled:e,status:n,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,streamSummary:s.streamSummary,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:r,organizationAdvertising:i}};class ji extends _t{stores;constructor(e){const n=Qi(e),r=Si(n);super(r,"core"),this.stores=n}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let n;for(n in this.stores){const r=e[n];n in e&&r!==void 0&&this.stores[n].subscribe(e[n])}};unsubscribe=()=>this.getStore().off()}const xi=(t,e,n)=>{t.store=new ji(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(([r,i])=>[r,i.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.sdk.streamSummary=()=>t.stores.streamSummary.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},n()},Gi=t=>{const{client:e}=t.createPromiseClient(yr.Leaderboard,{method:"list"});return n=>e.list(n)},Er=t=>{const{client:e}=t.createPromiseClient(yr.Leaderboard,{method:"summary"});return n=>e.summary(n)},Ki=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(yn.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s)return[];try{return(await n.getFriends({})).data}catch{return[]}}})},Hi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(z.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>(await n.get({eventId:s})).data?.attributes,refetchInterval:1/0,dedupeTime:1e3*60*60})},zi=(t,e,n)=>{const{client:r,queryKey:i}=n.createPromiseClient(z.Feed,{method:"syncQuestion",params:[t,e?"true":""]});return n.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>{if(!a||u)return;const d=await r.syncQuestion({filter:{eventId:a}});if(d.data?.attributes?.question?.type!==m.QuestionType.PROMOTION)return d.data?.attributes},dedupeTime:1e3*60*10,refetchInterval:1/0})},Wi=async(t,e)=>{const{client:n}=e.createPromiseClient(z.Feed,{method:"item",params:[t]});return(await n.item({id:t})).data},Yi=(t,e)=>{const{client:n}=e.createStreamClient(z.Feed),r=Z.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{r.set({eventId:o,feedId:""})}),e.addSubscription(n.subscription,r,{name:"feedSubscription"})},Ji=(t,e)=>{const{client:n}=e.createStreamClient(z.Feed);return e.addSubscription(n.questionSubscription,{questionId:t},{name:"questionSubscription"})},Ar=async(t,e)=>{const{client:n}=e.createPromiseClient(z.Feed,{method:"questionByUser",params:[t]});return(await n.questionByUser({questionId:t})).data?.attributes?.question},lt=(t,e)=>{const{client:n,queryKey:r,queryKeyStr:i}=e.createPromiseClient(z.Feed,{method:"questionByUser",params:[t]});let o=i;if(typeof t!="object"?o+=t:o+="atom",e.storeCache.has(o))return e.storeCache.get(o);{const s=e.nanoquery.createFetcherStore(r,{fetcher:async(a,u,d)=>(await n.questionByUser({questionId:d})).data?.attributes?.question,dedupeTime:1/0,refetchInterval:1/0});return e.storeCache.set(o,s),s}},Or=async(t,e)=>{if(!t)return;const{client:n}=e.createPromiseClient(z.Feed,{method:"getQuestion",params:[t]}),r=await n.getQuestion({id:t});if(!r.data?.attributes)return;const{options:i,notification:o,...s}=r.data.attributes,a=i?.options.case==="promotion"?i?.options.value:void 0;return{id:s.id,question:s,promotion:a,notification:o}},Xi=(t,e,n,r,i,o,s)=>{const{client:a,queryKey:u}=s.createPromiseClient(z.Feed,{method:"list",params:[t,e,o?"true":""]});return s.nanoquery.createFetcherStore(u,{fetcher:async(d,c,l,p,v)=>{if(!l||v)return[];const E=await a.list({eventId:l,filter:{types:p===Se.ALLOWED?[]:[m.QuestionType.FACTOID,m.QuestionType.PROMOTION,m.QuestionType.TWEET],statuses:[m.QuestionStatus.ACTIVE,m.QuestionStatus.RESOLVED]}}),w={eventId:l,userId:n.get(),organizationId:r.get()};for(const A of E.data)i.isQuestionReceived(w,A.id)||(M.emit("poll",{action:"received",payload:{isAd:A.attributes?.adUnit==m.AdUnit.UNSET,questionId:A.id,questionType:A.attributes?.type}}),i.saveQuestionReceived(w,A.id));return E.data},dedupeTime:1/0,refetchInterval:1/0})},Zi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(z.Feed,{method:"list",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s)return;const u=(await n.list({eventId:s,filter:{types:[m.QuestionType.PROMOTION],statuses:[m.QuestionStatus.ACTIVE]},pagination:{page:0,pageSize:1}})).data?.[0];if(u.type==="promotion")return Or(u.id,e)},dedupeTime:1/0,refetchInterval:1/0})},eo=(t,e,n,r,i)=>{const{client:o,queryKey:s}=i.createPromiseClient(z.Feed,{method:"betPack",params:[t,e,n]});return i.nanoquery.createFetcherStore(s,{fetcher:async(a,u,d,c,l)=>{if(!d||!c||!l)return{timestamp:Date.now(),data:null};const p=await o.betPack({eventId:d,types:[m.QuestionType.PREDICTION],statuses:[m.QuestionStatus.ACTIVE,m.QuestionStatus.RESOLVED],limit:5,sort:{field:"activated_at",order:"asc"}});return!p.data||!p.data.length?{timestamp:Date.now(),data:null}:{timestamp:Date.now(),data:p.data?.reduce((v,E)=>{const w=E?.attributes?.question;if(!w?.id)return v;const A={eventId:d,userId:c,organizationId:l};return r.isQuestionReceived(A,w.id)||(M.emit("poll",{action:"received",payload:{isAd:w?.adUnit==m.AdUnit.UNSET,questionId:w.id,questionType:w.type}}),r.saveQuestionReceived(A,w.id)),w.answers=w.answers.sort((L,S)=>L.id>S.id?1:-1),{...v,[w.id]:w}},{})}},dedupeTime:1/0,refetchInterval:1/0})},to=(t,e,n)=>{const r=Z.batched([e,n],()=>{const a=e.get();if(!a)return;const u=n.get().data?.find(c=>c.id===a?.questionId),d=a?.question?.openedFrom;return u?(u.openedFrom=d,u):a.question}),i=Z.batched(r,a=>a&&a.type==="question"?a.id:void 0),o=lt(i,t);return{$store:r,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,l)=>{if(!c||!l)return(c||l||[]).sort((w,A)=>w.id>A.id?1:-1);const p=c.sort((w,A)=>w.id>A.id?1:-1),v=l.sort((w,A)=>w.id>A.id?1:-1),E=[];for(let w=0;w<p.length;w++)E.push({...p[w],...v[w],correct:p[w].correct,youVoted:p[w].youVoted,pointsEarned:p[w].pointsEarned});return E};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:d(u?.answers,a?.answers)})}}};var Me;(function(t){t.SHOWED="showed",t.EVENT="ev"})(Me||(Me={}));class no extends He{constructor(){super("advertisement")}setShowed=e=>{this.write(Me.SHOWED,e,"true")};isViewed=e=>this.read(Me.SHOWED,e);fireEvent=(e,n)=>{this.write(Me.EVENT,n,e,"true")};isEventFired=(e,n)=>this.read(Me.EVENT,n,e)==="true"}const ro=t=>{const e=t.data?.attributes?.question;if((t.data?.attributes?.feedItem?.type==="promotion"?t.data.attributes.feedItem:void 0)===void 0||!e)return;const{options:r,notification:i,...o}=e,s=r?.options.case==="promotion"?r.options.value:void 0;return{id:o.id,question:o,notification:i,promotion:s}},at=t=>t.startsWith("http://")||t.startsWith("https://")?new URL(t).toString():t,io=({gamOptions:t,gamBaseUrl:e})=>{const n=`${e}?`,r=[];for(const i in t){const o=i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1_").toLowerCase(),s=t[i];if(s)if(typeof s=="string")r.push(`${o}=${at(s)}`);else if(Array.isArray(s))r.push(`${o}=${s.map(at).join(",")}`);else{const a=Object.entries(s).map(([u,d])=>Array.isArray(d)?`${u}=${d.map(at).join(",")}`:typeof d=="string"?`${u}=${at(d)}`:`${u}=${d}`).join("&").replaceAll("=","%3D").replaceAll("&","%26").replaceAll(",","%2C");r.push(`${o}=${a}`)}}return n+r.join("&")},Fe=t=>(t?.promotion?.type===m.PromotionType.INGAME_IAB11_LBAR||t?.promotion?.type===m.PromotionType.INGAME_IAB21_LBAR)&&!!t.promotion.additionalBanner?.imageUrl,oo=(t,e,n)=>{let r=!1;const i=n.transport,o=ce("advertisement"),s=new no,a=(S,T)=>{s.fireEvent(S,T)},u=(S,T)=>s.isEventFired(S,T),d=Y({}),c=Zi(t,i),l=S=>{const T=d.get(),k=T.data?.question.id,O=T.data?.promotion?.type;if(!k)return;d.get()?.isOpened||(d.setKey("isOpened",!0),M.emit("advertisement",{action:"opened",payload:{id:k,type:O,hasBanner:Fe(T.data),openedFrom:S?.fromNotification?"notification":"auto"}})),S?.fromNotification&&(d.setKey("hasNotification",!1),M.emit("advertisement",{action:"notification-opened",payload:{id:k,type:O,hasBanner:Fe(T.data)}}))},p=()=>{const S=d.get(),T=S.data?.question.id,k=S.data?.promotion?.type,O=d.get()?.isOpened;T&&!O&&(o.debug({id:T},"markAsViewed: %o"),s.setShowed(T),d.setKey("isOpened",!0),M.emit("advertisement",{action:"viewed",payload:{id:T,type:k,hasBanner:Fe(S.data)}}))},v=(S,T)=>{T?d.set({loading:!1,error:void 0,data:T,hasNotification:T?.notification?.enabled===m.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>E(T.question.id),togglePause:k=>w(T.question.id,k),toggleMute:k=>A(T.question.id,k),isViewed:!!s.isViewed(T.question.id),fireEvent:k=>a(S,k),isEventFired:k=>u(S,k)}):(d.setKey("loading",!0),Or(S,i).then(k=>d.set({loading:!1,error:void 0,data:k,hasNotification:k?.notification?.enabled===m.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>E(k?.question.id),togglePause:O=>w(k?.question.id,O),toggleMute:O=>A(k?.question.id,O),isViewed:k&&!!s.isViewed(k.question.id),fireEvent:O=>a(S,O),isEventFired:O=>u(S,O)})).catch(k=>d.set({loading:!1,error:k,data:void 0,fireEvent:()=>{},isEventFired:()=>!1})))};d.subscribe((S,T)=>{if(!(S.data?.id===T?.data?.id&&S.isPaused!==T?.isPaused)){if(S.data?.promotion?.type===m.PromotionType.EXTERNAL_AD&&!S?.externalAd&&S.data.promotion.adCampaigns?.desktopWebSettings){const k=io(S.data.promotion.adCampaigns.desktopWebSettings);d.setKey("externalAd",{type:"gam",url:k})}S.data?.promotion&&!S.isOpened&&(M.emit("advertisement",{action:"received",payload:{id:S.data.question.id,type:S.data.promotion.type,hasNotification:!!S.hasNotification,hasBanner:Fe(S.data),isViewed:!!s.isViewed(S.data.question.id)},skipAnalytics:S.data.question.id===T?.data?.question.id}),S.data.question.id!==T?.data?.question.id&&!s.isViewed(S.data.question.id)&&M.emit("advertisement",{action:"notification-received",payload:{id:S.data.question.id,type:S.data.promotion.type,hasNotification:!0,hasBanner:Fe(S.data),isViewed:!1}})),!S?.data&&T?.data&&M.emit("advertisement",{action:"closed",payload:{id:T.data.question.id,type:T.data.promotion?.type,hasNotification:!!T.hasNotification,hasBanner:Fe(T.data),isViewed:!!s.isViewed(T.data.question.id)}})}});const E=S=>{(!S||d.get()?.data?.question.id===S)&&d.set({})},w=(S,T)=>{d.get()?.data?.question.id===S&&d.setKey("isPaused",T)},A=(S,T)=>{d.get()?.data?.question.id===S&&d.setKey("isMuted",T)};return{connect:()=>{r||(r=!0,c.subscribe((S,T)=>{S.data&&(!T?.data||S.data.id!==T.data.id)&&v(S.data.question.id,S.data)}),e.addListener("promotion",S=>{const T=ro(S);if(T){if(T.question.status===m.QuestionStatus.RESOLVED){E(T.question.id),o.debug({promotion:T},"resolved: %o");return}if(T.question.status===m.QuestionStatus.ACTIVE){o.debug({promotion:T},"active: %o"),v(T.question.id,T);return}o.debug({promotion:T},"skip: %o")}}))},hide:E,show:v,open:l,markAsViewed:p,$store:d}};var oe;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io",t.QUESTION_RECEIVED="q-received",t.QUESTION_OPENED="q-opened"})(oe||(oe={}));class so extends He{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,n)=>{this.write(...e,n)};readValue=e=>this.read(...e)}class ao extends He{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new so}saveQuestionReceived=({userId:e,eventId:n,organizationId:r},i)=>{this.write(oe.QUESTION_RECEIVED,r,e,n,i,"1")};isQuestionReceived=({userId:e,eventId:n,organizationId:r},i)=>!!this.read(oe.QUESTION_RECEIVED,r,e,n,i);saveQuestionOpened=({userId:e,eventId:n,organizationId:r},i)=>{this.write(oe.QUESTION_OPENED,r,e,n,i,"1")};isQuestionOpened=({userId:e,eventId:n,organizationId:r},i)=>!!this.read(oe.QUESTION_OPENED,r,e,n,i);saveOnboardingStatus=({userId:e,eventId:n,organizationId:r},i)=>{this.write(oe.ONBOARDING,r,e,n,i)};getOnboardingStatus=({userId:e,eventId:n,organizationId:r})=>this.read(oe.ONBOARDING,r,e,n);setOnboardingInstantOpen=({userId:e,eventId:n,organizationId:r})=>{this.sessionStorage.writeValue([oe.ONBOARDING_IO,r,e,n],"1")};getOnboardingInstantOpen=({userId:e,eventId:n,organizationId:r})=>this.sessionStorage.readValue([oe.ONBOARDING_IO,r,e,n])}var Se;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Se||(Se={}));class uo{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;betPack;moderationId;moderation;feedSubscription;questionSubscription;advertisement;storage;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=ce("gamification-background"),this.storage=new ao,this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new X(x(void 0),"moderationId").getStore(),this.interactiveAllowed=new X(x(Se.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new X(x(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new ne(Hi(this.slStreamId,e.transport),"gamification:moderation");const n=!!e.sdk.options.get().betPack;this.feedList=new ne(Xi(this.slStreamId,this.interactiveAllowed,this.userId,this.organizationId,this.storage,n,e.transport),"gamification:feedList"),this.betPack=new ne(eo(this.slStreamId,this.userId,this.organizationId,this.storage,e.transport),"gamification:betPack"),this.activeQuestionId=zi(this.slStreamId,n,e.transport),this.openedQuestion=to(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0),this.questionSubscription=Ji(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{const o=i.data?.attributes?.question;if(this.openedQuestion.updateExtendedQuestion(o),this.betPack&&o?.type===m.QuestionType.PREDICTION&&(o.status===m.QuestionStatus.ACTIVE||o.status===m.QuestionStatus.RESOLVED)){const s=this.betPack.getValues().data?.data||{},a=s?.[o.id];if(a){const u=[],d=a.answers.sort((l,p)=>l.id>p.id?1:-1),c=o.answers.sort((l,p)=>l.id>p.id?1:-1);for(let l=0;l<d.length;l++)u.push({...d[l],...c[l],correct:d[l].correct,youVoted:d[l].youVoted,pointsEarned:d[l].pointsEarned});this.betPack.getStore().mutate({timestamp:Date.now(),data:{...s,[o.id]:{...a,status:o.status,marketClosed:o.marketClosed,activatedAt:o.activatedAt,answerSetAt:o.answerSetAt,answers:u}}})}}}),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.cancels.add(this.feedSubscription.addListener("bet-pack-update",async r=>{const i=r.data?.attributes?.question;if(this.betPack&&i?.type===m.QuestionType.PREDICTION&&(i.status===m.QuestionStatus.ACTIVE||i.status===m.QuestionStatus.RESOLVED)){const o=this.betPack.getValues().data?.data||{},s=o?.[i.id];if(s)this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:{...s,status:i.status,marketClosed:i.marketClosed,activatedAt:i.activatedAt,answerSetAt:i.answerSetAt}}});else if(!s&&Object.keys(o).length<5){const a=await Ar(i.id,this.transport);this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:a}})}}})),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",r=>{const i=this.activeQuestionId.get().data?.question?.id,o=r.data?.attributes?.question;if(!(!o||o.type===m.QuestionType.PROMOTION)){if(o.status===m.QuestionStatus.RESOLVED){i===o.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(r.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((r,i)=>{r.data?.feedItem&&r.data?.feedItem?.id!==i?.data?.feedItem?.id&&e.onQuestionActivate({stage:"activate",id:r.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:r.data.feedItem.id})),hasNotification:!0,type:r.data.feedItem.type}),!r.data?.feedItem&&i?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:i.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:i.data.feedItem.id})),hasNotification:!0,type:i.data.feedItem.type})})),this.feedSubscription.connect(),this.cancels.add(this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})),e.sdk.onMount({name:"gamification-background"},()=>()=>{this.activeQuestionId.off();for(const r of this.cancels)r(),this.cancels.delete(r)}),n||(this.advertisement=oo(this.slStreamId,this.feedSubscription,e))}getCurrentSessionId=e=>{const n=e.eventId||this.slStreamId.get()||"",r=e.userId||this.userId.get()||"",i=e.organizationId||this.organizationId.get()||"",o=e.entity||"",s=e.prefix||"";return[i,n,r,s,o].join(":")};disconnect=()=>{this.feedSubscription?.disconnect(),this.questionSubscription!==void 0&&(this.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0)};openQuestion=(e,n)=>{this.openedQuestionId.set({questionId:e,question:n}),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 co{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ce("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=x(new Map)}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const n=e.close,r=e.action;if(this.store.set(e.id,{...e,close:(...i)=>{n&&n(...i),this.closeNotification(e.id)},action:(...i)=>{r&&r(...i),this.closeNotification(e.id,{animateHiding:!1})}}),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 n=this.store.get(e);if(!n){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}M.emit("notification",{action:"received",payload:{type:n.type,questionId:n.data.questionId,questionType:n.data.questionType}});const r=setTimeout(()=>{const i=e,o=new Map(this.notificationsList.get());o.set(n.id,n),this.notificationsList.set(o);const s=setTimeout(()=>{this.logger.debug({notificationId:i,delay:n.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(i)},n.autoHideDuration||5e3);this.timeouts.set(i,s),this.logger.debug({notificationId:i,queue:[...o.values()]},"notification displayed")},n.delay||0);this.timeouts.set(e,r),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=(e,{animateHiding:n=!0}={})=>{const r=new Map(this.notificationsList.get()),i=r.get(e);if(i){const o=!(this.waitingQueue.size>=this.options.concurrency)&&n;i.hiding=o,this.notificationsList.set(r);const s=()=>{const a=new Map(this.notificationsList.get());a.delete(e),this.notificationsList.set(a);const u=this.timeouts.get(e);u!==void 0&&(clearTimeout(u),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden"),i.hiding&&M.emit("notification",{action:"closed",payload:{type:i.type,questionId:i.data.questionId,questionType:i.data.questionType}})};if(o){const a=setTimeout(s,this.options.animationDelay||0);this.timeouts.set(e,a)}else s()}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),i};drain=()=>{this.store.clear(),this.timeouts.clear(),this.waitingQueue.clear(),this.activeQueue.clear(),this.notificationsList.off(),this.notificationsList.set(new Map)}}var vt;(function(t){t.OPENED="opened"})(vt||(vt={}));class lo extends He{constructor(){super("notification")}setOpened=e=>{this.write(vt.OPENED,e,"true")};isOpened=e=>this.read(vt.OPENED,e);clearNotification=()=>{this.clear()}}class fo{queue;storage;constructor(e={}){this.storage=new lo,this.queue=new co({concurrency:1,animationDelay:1600,...e})}isViewed=e=>this.storage.isOpened(e);add=e=>{if(!this.isViewed(e.id)){if(e.data&&e.emitEvent){const r=e.action;e.action=(...i)=>{r&&r(...i),M.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,{markAsViewed:n=!0,animateHiding:r}={})=>{this.queue.closeNotification(e,{animateHiding:r}),n&&this.markAsViewed(e)};update=(e,n)=>{const r=this.queue.notificationsList.get()?.get(e);n(r)};getActiveNotification=()=>{const e=this.queue.notificationsList.get();if(!e?.size)return null;for(const r of e.values())if(r.type===ge.ONBOARDING)return r;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const po=(t,e,n)=>{t.notifications=new fo(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),t.sdk.onMount({name:"notifications"},()=>()=>{t.notifications.queue.drain()}),n()};var xe;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(xe||(xe={}));const Un=async(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(z.Feed,{method:"submitAnswer"}),i=r({retryAttempts:0});try{return await n.submitAnswer({data:e},{contextValues:i})}catch(o){throw Q.ConnectError.from(o)?.code===Q.Code.AlreadyExists?new Error(xe.ALREADY_VOTED):new Error(xe.UNKNOWN)}},Ir=(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(z.Feed,{method:"submitInplay"}),i=r({retryAttempts:0});return n.submitInplay({data:{eventId:+e}},{contextValues:i})},ho={pageSize:10},yo=(t,e,n,r,i)=>{let o=0;const s=x({pageSize:ho.pageSize,page:0}),a=Y({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=Gi(t),d=async()=>{const p=e.get(),v=r?.getStore().get().data?.map(E=>E.slId)||[];if(p&&v?.length){const E=n.get();E&&v.push(E),a.setKey("loading",!0),a.setKey("data",[]);const A=await u({eventId:p,usersIds:v,leaderboardId:""});a.set({data:A.data.map((L,S)=>({...L.attributes,friendsRank:S+1})),hasMore:!1,key:Date.now(),loading:!1}),A.meta&&(o=Math.round(A.meta.count/A.meta.pageSize))}},c=()=>{d()},l=p=>{const v=s.get(),E=p||v.page+1;E<=o&&s.set({...v,page:E})};return Z.onMount(a,()=>{const p=e.listen(d),v=r?.listen(d);return()=>{p(),v?.()}}),{$store:a,fetchMore:l,invalidate:c}};class mo extends He{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Bn="sldl",kt="sldl_uid",_r="sldl_eid",kr="sldl_e_eid",go=new Set([kt,_r,kr]),Mn=t=>{const e={},n={};for(const[r,i]of t)go.has(r)?e[r]=i:n[r]=i;return{result:e,remain:n}},bo=({hash:t,search:e})=>{if(t&&t.includes(Bn)){const n=new URLSearchParams(t.substr(1));return{hash:Mn(n)}}if(e&&e.includes(Bn)){const n=new URLSearchParams(e);return{search:Mn(n)}}return null},$n=ce("deep_link"),ue={debug:(...t)=>{$n.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{$n.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},vo=(t,e)=>{const{hash:n,search:r}=window.location;if(ue.debug({hash:n,search:r},"get deep link data from"),n||r){const i=bo({hash:n,search:r});if(ue.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()}`,ue.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()}`,ue.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},So=(t,e,n)=>{const r=new mo,i=r.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ue.debug(a)}t.deepLink={$store:new Oe(Y(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ue.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?.[kt]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),r.del("sl-deep-link-store")},t.deepLink.$store.subscribe(a=>r.set("sl-deep-link-store",JSON.stringify(a))),t.sdk.addDeepLinkHandler=a=>{localStorage.getItem("SL_DEBUG")&&ue.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ue.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ue.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ue.trace("called handler"),u(a)}catch(d){console.error(d)}};vo(t.deepLink.$store,s),n()},wo=ce("bypass");class To extends vi{$coreStore;deepLink;transport;bypassLogin;constructor(e,n,r){super(),this.$coreStore=e,this.deepLink=r,this.transport=n,this.bypassLogin=Ri(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,n)=>{this.$coreStore.getValues().userKey.setValue(n);const{used:r,data:i}=this.deepLink.getDeepLinkData(),o=r?"":i?.[kt];wo.debug({inviterKey:o},"login with inviterKey");const s=await this.bypassLogin({schema:e,userKey:n,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({data:s.data}),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 Be().clear()};softLogout=()=>{const e=new Be;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=({skipLogin:e}={skipLogin:!1})=>{const n=new Be,r=n.getToken(),i=n.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),r)return this.saveUser(r,""),this.me().then(o=>{if(o?.id){const s=o.id;this.saveUser(r,s)}return o});if(i&&!r&&!e){const o=n.getSchema();o&&i&&this.login(o,i).catch(()=>{this.logout()})}};saveUser=(e,n)=>{this.transport.setAuth(e,n),this.$coreStore.getValues().userToken.setValue(e),new Be().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async n=>{try{return await e(n)}catch(r){throw r.code&&(r.code===7||r.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),r}})}}const Ye=new Be,Eo=(t,e,n)=>{t.auth=new To(t.store,t.transport,t.deepLink),t.stores.status.listen(r=>{r===he.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(r,i)=>{if(!(Ye.getSchema()===r&&Ye.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(r,i),Ye.setSchema(r),Ye.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),Ye.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),n()},qn=ce("video_player"),ut={debug:(...t)=>{qn.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{qn.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},Ao=(t,e,n)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=r=>{ut.trace("adding video player controller"),t.videoPlayer.controllers.add(r)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=r=>{ut.trace("removing video player controller"),t.videoPlayer.controllers.delete(r)},t.sdk.controlVideoPlayer=r=>{ut.trace("controlling video player");for(const i of t.videoPlayer.controllers){ut.trace("calling video player controller");try{i(r)}catch(o){console.error(o)}}},n()},Oo={[m.QuestionType.FACTOID]:"insight",[m.QuestionType.POLL]:"poll",[m.QuestionType.TRIVIA]:"trivia",[m.QuestionType.PREDICTION]:"prediction",[m.QuestionType.TWEET]:"tweet"},De=t=>t===m.PromotionType.INGAME_IAB11||t===m.PromotionType.INGAME_IAB21||t===m.PromotionType.NFL_SHOP_OVERLAY||t===m.PromotionType.SHOP_OVERLAY,Io=(t,e,n)=>{t.sdk.uiState=Y({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!0)},disableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),onboardingNotification:!1,appBanner:!1,appSidebar:!1,appNotification:!1,app:!1})},enableExposedPauseAd:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),exposedPauseAd:!0})},disableExposedPauseAd:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),exposedPauseAd:!1})}},e.onContentActivate&&(t.ui.onContentActivate=e.onContentActivate);const r=i=>{t.ui.onContentActivate&&t.ui.onContentActivate({...i,type:"advertisement"})};t.onQuestionActivate=({questionType:i,...o})=>{if(t.ui.enableAppNotification(),t.ui.onContentActivate){const s=o.type||i&&Oo[i]||"question";t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="app")switch(a.slEventBus.action){case"open":t.ui.enableApp();break;case"close":t.ui.disableApp();break}if(a.slEventBus?.type==="poll"){const u=a.slEventBus.action,{hasBanner:d}=a.slEventBus.payload;switch(u){case"onboardingOpen":t.sdk.uiState.set({app:!0});break;case"opened":t.sdk.uiState.set({...t.sdk.uiState.get(),appBanner:d,appSidebar:!0});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),appBanner:!1,appSidebar:!1});break}}if(a.slEventBus?.type==="notification"){const u=a.slEventBus.action;if(a.slEventBus.payload.type===ge.ONBOARDING)switch(u){case"received":t.ui.enableOnboardingNotification();break;case"closed":t.ui.disableOnboardingNotification();break}else switch(u){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:d,hasBanner:c,id:l,isViewed:p,type:v}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:v===m.PromotionType.EXTERNAL_AD,promotionBanner:c,promotionNotification:!1,promotionOverlay:De(v),promotionSidebar:!De(v)});break;case"received":if(t.sdk.closeFeature(),r({stage:"activate",id:l,hasNotification:d,hasBanner:c,isViewed:p}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:c,onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionOverlay:De(v),promotionSidebar:!De(v),promotionExternalAd:v===m.PromotionType.EXTERNAL_AD});break}d?t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionNotification:!0}):t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionBanner:c,promotionOverlay:De(v),promotionSidebar:!De(v),promotionExternalAd:v===m.PromotionType.EXTERNAL_AD});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),promotionNotification:!1,promotionBanner:!1,promotionOverlay:!1,promotionExternalAd:!1,promotionSidebar:!1}),r({stage:"deactivate",id:l,hasNotification:d,hasBanner:c,isViewed:p});break}}},o=M.listen(i),s=t.activeFeature.subscribe(a=>{a||t.ui.disableApp()});return()=>{o(),s()}}),n()},_o=(t,e,n)=>{const r={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=Y(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const d=o.get(s);d&&d(),i.delete(s),o.delete(s)}i.set(s,{cb:u,clear:a}),t?.stores?.enabled?.get()==="on"&&o.set(s,u())},t.ready=()=>{t.stores.enabled.subscribe(s=>{s==="on"&&r.onMountedFired===!1&&(i.forEach(({cb:a},u)=>o.set(u,a())),r.onMountedFired=!0),s!=="on"&&r.onMountedFired===!0&&(o.forEach(a=>a()),o.clear(),i.forEach(({clear:a},u)=>a&&i.delete(u)),r.onMountedFired=!1)})},t.sdk.initializeApp=async s=>{if(t.contextConfig=s,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(he.INITIALIZATION);try{const a=await t.stores.organizationSettings.getValue();return a?(t.stores.status.setValue(he.READY),{enabled:!!a}):(t.stores.status.setValue(he.FAILED),{err:"failed"})}catch(a){return t.stores.enabled.setValue(),t.stores.status.setValue(he.FAILED),{err:`${a}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(he.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=(s,a)=>{a?t.stores.slStreamId.getStore().set({loading:!1,data:s}):t.stores.providerStreamId.setValue(s)},n()},ko=(t,e)=>{const{client:n,queryKey:r}=t.createPromiseClient(et.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s,a)=>{if(!s)return{};try{return(await n.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes}catch{return}},dedupeTime:1e3*60*60*24,refetchInterval:1/0})},Po=(t,{web:e,mobile:n})=>{const{client:r}=t.createPromiseClient(di.LinksClient,{method:"generate"});return r.generate({web:e,mobile:n})},Qn=(t,e)=>{const n=new URLSearchParams(t);for(const[r,i]of Object.entries(e))n.append(r,i);return n.toString()},Co=(t,e,n,r)=>{const i=Y({});return Z.onMount(i,()=>ko(t,[e,n]).subscribe(async({data:a,loading:u})=>{const d=a===void 0&&u===!1?"https://streamlayer.io":a?.url,c=r.get()||"",l=e.get()||"",p=n.get()||"",v={[kt]:c,[_r]:l,[kr]:p};if(!u&&d){i.setKey("loading",!0);let E=window.location.search,w=window.location.hash;E&&w||w?E=`?${Qn(E,v)}`:w=`#${Qn("",v)}`;const A=window.location.origin+window.location.pathname+E+w;try{const L=await Po(t,{web:A,mobile:d});i.set({data:L.data?.link,loading:!1})}catch{i.set({loading:!1,error:"Failed to generate short link",data:void 0})}}else i.setKey("loading",!0)})),{$store:i,fetch}};var q;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(q||(q={}));const No=(t,e,n,r)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&n.add({type:ge.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:m.QuestionType.UNSET,onboarding:{...i,instantOpen:!r.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}),markIstantOpen:()=>{r.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}),n.update(o,s=>{s?.data?.onboarding&&(s.data.onboarding.instantOpen=!0)})}}}})},ct=(t,e,n,r,i,o,s,a)=>{try{const u=e.userId.get(),d=e.organizationId.get(),c=e.slStreamId.get();if(!u||!d||!c)return;const l=i.getOnboardingStatus({userId:u,organizationId:d,eventId:c});if(l===q.Completed||a?.skipOnboarding){t.set(q.Completed);for(const A of o)A();a?.skipOnboarding&&l!==q.Completed&&(i.saveOnboardingStatus({organizationId:d,userId:u,eventId:c},q.Completed),Ir(s,c));return}const p=e.moderation.getStore().value?.data,v=n.featureSettings.get().inplayGame;if(p===void 0||v===void 0)return;const E=p?.options?.onboardingEnabled,w=v?.titleCard?.optIn;E?w?t.set(q.Required):t.set(q.Optional):(w?t.set(q.Unavailable):t.set(q.Disabled),r.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(u){console.error(u)}},jn=(t,e,n,r,i)=>{let o=!!i?.skipOnboarding;const s=e.storage,a=x(q.Unset);a.subscribe(c=>{c!==q.Unset&&(c===q.Optional||c===q.Required?o===!1&&(No(t,e,r,s),o=!0):t.onboardingProcessed.set(!0),c===q.Completed&&e.activeQuestionId.invalidate(),s.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const u=[];return a.get()!==q.Completed&&(u.push(e.userId.listen(c=>{c&&ct(a,e,t,r,s,u,n,i)})),u.push(e.moderation.listen(c=>{c.data&&ct(a,e,t,r,s,u,n,i)})),u.push(t.featureSettings.listen(c=>{c&&ct(a,e,t,r,s,u,n,i)}))),ct(a,e,t,r,s,u,n,i),{$store:a,submitInplay:async()=>{const c=e.slStreamId.get();if(c){await Ir(n,c),a.set(q.Completed),s.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:c},q.Completed),M.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const l=e.getCurrentSessionId({prefix:"onboarding"});r.close(l)}}}},Lo=(t,e,n,r)=>{const i=Y(void 0),o=Er(r),s=async()=>{const u=t.get(),d=e.get(),c=n?n.getStore().get().data?.map(v=>v.slId):[];if(!c||!u||!d)return;const l={eventId:u,userId:d,leaderboardId:"",usersIds:[...c,d]},p=await o(l);i.set(p.data?.attributes)},a=()=>{s()};return Z.onMount(i,()=>{a();const u=t.listen(s),d=n?.listen(s),c=e.listen(s);return()=>{u(),d?.(),c()}}),{$store:i,invalidate:a}},Fo=async(t,e,n,r,i)=>{const o=Er(i),s=t.get(),a=e.get(),u=n?.getStore().get().data?.map(p=>p.slId)||[],d={eventId:s,userId:r,leaderboardId:"",usersIds:[...u,a]};return(await o(d)).data?.attributes?.summary},xn=new Set([m.QuestionType.POLL,m.QuestionType.PREDICTION,m.QuestionType.TRIVIA]);class Do extends wr{userSummary;feedList;betPack;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;onboardingProcessed;friendsTabEnabled;skipOnboarding;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,n,r){if(super(e,n),this.background=new uo(r),this.advertisement=this.background.advertisement,this.onQuestionActivate=r.onQuestionActivate,this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=this.background.storage,this.feedList=this.background.feedList,this.betPack=this.background.betPack,this.currentUserId=this.background.userId,this.onboardingProcessed=x(!r.sdk.withAuth),this.leaderboardId=new X(x(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.notifications=r.notifications,this.transport=r.transport,this.closeFeature=(i=!0)=>r.sdk.closeFeature(i),this.openFeature=()=>r.sdk.openFeature(B.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=Co(this.transport,this.background.slStreamId,r.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=Lo(this.background.slStreamId,this.background.userId,this.friends,this.transport),!r.sdk.options.get().hideFriends){this.friends=new ne(Ki(this.background.userId,r.transport),"gamification:friends"),this.openedUser=x(void 0);const i=this.leaderboardList=yo(this.transport,this.background.slStreamId,this.background.userId,this.friends);this.cancels.add(this.userSummary.$store.listen((o,s)=>{s?.summary&&o?.summary&&i.invalidate()}))}this.connect(),this.skipOnboarding=!!r.sdk.options.get().skipOnboarding,this.onboardingStatus=jn(this,this.background,r.transport,r.notifications,{skipOnboarding:r.sdk.options.get().skipOnboarding}),r.sdk.options.get().skipOnboarding||(this.onboardingStatus=jn(this,this.background,r.transport,r.notifications,{skipOnboarding:r.sdk.options.get().skipOnboarding})),this.cancels.add(this.onboardingStatus.$store.listen(this.checkInteractiveFlag)),this.cancels.add(this.background.moderation.getStore().listen(this.checkInteractiveFlag)),this.cancels.add(this.settings.subscribe(this.checkInteractiveFlag)),this.cancels.add(this.onboardingStatus.$store.listen((i,o)=>{(o===void 0||i!==q.Unset)&&this.background.activeQuestionId.invalidate()})),this.background.activeQuestionId.listen(this.showInApp),this.friendsTabEnabled=x(!1),this.cancels.add(r.sdk.options.subscribe(i=>{i.friendsTab==="disabled"?this.friendsTabEnabled.set(!1):i.friendsTab==="enabled"&&this.friendsTabEnabled.set(!0)})),this.cancels.add(this.settings.subscribe(i=>{r.sdk.options.get().friendsTab==="activatedGame"&&this.friendsTabEnabled.set(!!i.inplayGame?.titleCard?.optIn)})),r.sdk.onMount({name:"gamification",clear:!0},()=>()=>{for(const i of this.cancels)i(),this.cancels.delete(i)})}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Se.ALLOWED}checkInteractiveFlag=()=>{if(this.skipOnboarding)this.background.interactiveAllowed.set(Se.ALLOWED);else{const e=this.onboardingStatus.$store.get(),n=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,r=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===q.Completed,o=!n||i||r!==!0;this.background.interactiveAllowed.set(o?Se.ALLOWED:Se.DISALLOWED)}};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement&&this.advertisement.connect()}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-prediction-close",async e=>{if(!this.isInteractiveAllowed)return;const n=e.data?.attributes?.question,r=e.data?.attributes?.feedItem;if(!n||!r?.attributes)return;const{status:i,type:o,id:s,answers:a}=n;if(i===m.QuestionStatus.RESOLVED&&o===m.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(T=>T.id===s),l=d[c];let p=l?.attributes?.attributes?.value?.answerId;const v=lt(s,this.transport),E=v.subscribe(()=>{});await v.get().promise;let w=v.get().data;w||(w=await Ar(s,this.transport),v.mutate(w)),E(),window.requestAnimationFrame(()=>{v.invalidate()}),p||(p=w?.answers.find(({youVoted:T})=>T)?.id);const A=a.find(({correct:T})=>T),L=p?a.find(({id:T})=>T===p):void 0,S=!!L?.correct;if(l&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=p,d[c].attributes.attributes.value.openForVoting=!1,p&&(d[c].attributes.attributes.value.status=S?z.PickHistoryStatus.WON:z.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!L||!A)return;this.openedQuestionId.get()?.questionId!==n.id&&this.notifications.add({type:ge.QUESTION_RESOLVED,action:()=>this.openQuestion(n.id,r),close:()=>this.closeQuestion(s),autoHideDuration:S?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:m.QuestionType.PREDICTION,question:{title:S?`Congratulations! You answered correctly! You won ${A.points} pts!`:`Better luck next time! Correct: ${A?.text}!`,votedAnswer:{title:L?.text,points:L?.points},correctAnswerTitle:A?.text,correct:!!S,predictionResult:i===m.QuestionStatus.RESOLVED,questionTitle:n?.subject},inApp:{notification:n.notification,appearance:n.appearance,sponsorship:n.sponsorship,adUnit:n?.adUnit,sponsorLogo:n.promotion?.sponsor?.logo}}}),this.userSummary.invalidate()}})),Z.onStart(this.feedList.getStore(),()=>{this.cancels.add(this.feedList.subscribe(()=>{}))}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-questions-list",e=>{const n=[...this.feedList.getStore().value?.data||[]],r=e.data?.attributes?.feedItem,i=n.findIndex(o=>o.id===r?.id);if(r?.attributes&&r.attributes.attributes.case!=="promotion"&&!(r.attributes.status!==m.QuestionStatus.ACTIVE&&r.attributes.status!==m.QuestionStatus.RESOLVED)&&!(!this.isInteractiveAllowed&&xn.has(r.attributes.type)&&r?.attributes?.adUnit!==m.AdUnit.STANDART)){if(i!==-1)if(r.attributes.attributes.case==="question"&&n[i].attributes?.attributes.case==="question"){const o=n[i];o.attributes&&(n[i]={...n[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...r.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting===!1?!1:r.attributes.attributes.value.openForVoting}}}})}else{const o=n[i];o.attributes&&r.attributes&&(n[i]={...n[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...r.attributes.attributes.value}}}})}i===-1&&(n.unshift(r),M.emit("poll",{action:"received",payload:{isAd:r.attributes?.adUnit==m.AdUnit.UNSET,questionId:r.id,questionType:r.attributes?.type}})),this.feedList.getStore().mutate(n)}}))};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};betPackVote=async(e,n)=>{if(!this.betPack)return;try{await Un(this.transport,{questionId:e,answerId:n})}catch(o){if(o.message===xe.ALREADY_VOTED){const s=lt(e,this.transport),a=s.subscribe(()=>{});s.invalidate(),a()}throw o}const r={...this.betPack.getValues().data?.data},i=r?.[e];i&&(M.emit("poll",{action:"voted",payload:{questionId:e,isAd:i?.adUnit==m.AdUnit.UNSET,questionType:i.type}}),i.answers=i.answers.map(o=>o.id===n?{...o,youVoted:!0}:o),this.betPack.getStore().mutate({data:r,timestamp:Date.now()}))};submitAnswer=async(e,n)=>{const r=lt(e,this.transport),i=r.subscribe(()=>{}),o={...r.get().data||{}},s=()=>{const a=this.feedList.getValues().data;if(!a)return;const u=a.findIndex(l=>l.id===e),d=a[u],c=d?.attributes?.attributes.case==="question"&&d.attributes.attributes.value;if(c){M.emit("poll",{action:"voted",payload:{isAd:d.attributes?.adUnit==m.AdUnit.UNSET,questionId:e,questionType:c.questionType}});const l=r.get().data;if(i(),l){const p=l.answers.find(A=>A.correct===!0),v=l.answers.findIndex(A=>A.id===n),E=l.answers[v],w=l.answers.every(({percentageDecimal:A},L)=>A===o?.answers[L].percentageDecimal);a[u].attributes.attributes.value.answerId=n,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=E?.text||"",p&&(a[u].attributes.attributes.value.status=p.id===n?z.PickHistoryStatus.WON:z.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a]),l.answers[v].correct=p?.id===n,l.answers[v].youVoted=!0,w&&l.answers.forEach(A=>{A.percentageDecimal=0}),p?.id===n&&(l.answers[v].pointsEarned=l.status===m.QuestionStatus.RESOLVED?0:p.points),r.mutate({...l})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Un(this.transport,{questionId:e,answerId:n}),s()}catch(a){if(a.message===xe.ALREADY_VOTED){this.userSummary.invalidate();const u=r.subscribe(()=>{});r.invalidate(),u()}throw a}};openQuestion=(e,n)=>{if(console.log("openQuestion",e,n),!e)return()=>{};const r=n?.openedFrom==="bet-pack";this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let i=n?.attributes?.type,o=n?.attributes?.adUnit===m.AdUnit.STANDART&&!!n?.attributes?.adPromotion?.banner?.imageUrl;if(!i&&!r){const u=(this.feedList.getStore().value?.data||[]).find(d=>d.id===e)?.attributes;i=u?.type,o=u?.adUnit===m.AdUnit.STANDART&&!!u?.adPromotion?.banner?.imageUrl}const s={eventId:this.background.slStreamId.get()||"",userId:this.background.userId.get()||"",organizationId:this.background.organizationId.get()||""};return M.emit("poll",{action:"opened",payload:{questionId:e,questionType:i,isAd:n?.attributes?.adUnit==m.AdUnit.UNSET,questionOpenedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom,hasBanner:o}}),this.storage.isQuestionOpened(s,e)||(M.emit("poll",{action:"viewed",payload:{questionId:e,questionType:i,isAd:n?.attributes?.adUnit==m.AdUnit.UNSET,questionOpenedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom}}),this.storage.saveQuestionOpened(s,e)),r||this.openFeature(),this.background.openQuestion(e,n?{...n,openedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom}:void 0)};getFeedItem=e=>Wi(e,this.transport);isOpenedQuestion=e=>!!this.notifications.isViewed(e);closeQuestion=e=>(e&&(this.onQuestionActivate({stage:"deactivate",id:e,isViewed:!!this.notifications.isViewed(this.background.getCurrentSessionId({prefix:"notification",entity:e}))}),M.emit("poll",{action:"closed",payload:{questionId:e}})),this.background.closeQuestion(e));openUser=async e=>{if(!this.leaderboardList)return;const n=this.leaderboardList?.$store.get().data?.find(i=>i.userId===e);if(!n){this.openedUser?.set(n);return}if(n.summaryLoaded){this.openedUser?.set(n);return}const r={...n};try{const i=await Fo(this.background.slStreamId,this.background.userId,this.friends,e,this.transport);i?.inTop!==void 0&&(this.leaderboardList?.$store.setKey("data",this.leaderboardList.$store.get().data?.map(o=>(o.userId===e&&(o.inTop=i.inTop),o))),r.inTop=i.inTop)}catch(i){console.error(i)}this.openedUser.set(r)};closeUser=()=>{this.openedUser?.set(void 0)};openOnboarding=()=>{this.openFeature(),M.emit("poll",{action:"onboardingOpen",payload:{}})};showInApp=e=>{const n=this.onboardingStatus.$store.get(),r=e?.data?.question?.adUnit===m.AdUnit.STANDART;if(e&&e.data&&(r||n&&n!==q.Unset)&&e.data.question?.id!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==m.SilenceSetting.ON&&e.data.question.status===m.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(xn.has(e.data.question.type))(this.isInteractiveAllowed||r)&&e.data.question.notification!==void 0&&this.notifications.add({type:ge.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>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},inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship,adUnit:e.data.question?.adUnit,sponsorLogo:e.data.question.promotion?.sponsor?.logo}}});else if(e.data.question.type===m.QuestionType.FACTOID){const i=e.data.question.options?.options.value,o=e.data.question.notification?.useContentTexts===m.NotificationUseContentTexts.ENABLED?e.data.question.subject:e.data.question.notification?.title||"",s=e.data.question.notification?.useContentTexts===m.NotificationUseContentTexts.ENABLED?i.body:e.data.question.notification?.body,a={heading:o,body:s,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:ge.QUESTION,action:()=>this.openQuestion(e?.data?.question?.id,e?.data?.feedItem),close:()=>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:a,inApp:{useMediaFromContent:i?.useAsNotification===m.UseAsNotification.ENABLED,notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship,adUnit:e.data.question?.adUnit,sponsorLogo:e.data.question.promotion?.sponsor?.logo,isVideo:i?.mode===m.FactoidMediaMode.VIDEO}}})}else if(e.data.question.type===m.QuestionType.TWEET&&e.data.question.notification!==void 0){const i=e.data.question.options?.options.value,o={image:"",video:""};if(i.tweetMeta?.tweet?.meta?.extendedEntities?.media?.[0]){const a=i.tweetMeta.tweet.meta.extendedEntities.media;if(a){const u=a.find(({type:d})=>d==="photo")||a[0];o.image=u.mediaUrlHttps,u.type==="video"&&(o.video=u.url)}}const 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,tweetMedia:o};this.notifications.add({type:ge.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>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:s,inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}}}}const Ro={[B.SdkOverlayType.GAMES]:!0};class Vo extends wr{constructor(e,n){super(e,n)}}const Uo=(t,e,n)=>t.type===B.SdkOverlayType.GAMES?new Do(t,e,n):new Vo(t,e),Bo=(t,e,n)=>{t.features=new Map,t.sdk.featuresList=new X(x(new Set),"features-list"),t.activeFeature=new X(x(B.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=r=>t.features.get(r),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=r=>{t.sdk.initializeApp().then(()=>{t.activeFeature.setValue(r)})},t.sdk.closeFeature=(r=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(B.SdkOverlayType.UNSET),r&&i){t.features.delete(i);const o=t.sdk.featuresList.getValue();o&&o.delete(i),t.sdk.featuresList.setValue(o)}},t.initFeature=(r,i=pe.ORGANIZATION)=>{if(r.type in Ro&&!t.features.has(r.type)){const o=Uo(r,i,t);t.features.set(r.type,o);let s=t.sdk.featuresList.getValue();s?s.add(r.type):s=new Set([r.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(r,i)=>{t.features.get(r.type)?.update(r,i)},t.destroyFeature=r=>{t.features.delete(r.type);const i=t.sdk.featuresList.getValue();i&&i.delete(r.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const r=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of r?.overlays||[])t.initFeature(i,pe.ORGANIZATION)},t.stores.providerStreamId.listen(r=>{r||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const r=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===pe.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{r(pe.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{r(pe.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},n()};class Mo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="invitation")switch(r.slEventBus.action){case"sent":this.sent(r.slEventBus.payload);break}};return M.listen(n)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INVITATION_ACCEPTED},category:st.InvitationCategory.GAMES,from:st.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INVITATION_SENT},category:st.InvitationCategory.GAMES,from:e||st.InvitationFrom.UNSET})}}class $o{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="interactions")switch(r.slEventBus.action){case"tap":this.tap();break;case"scroll":this.scroll();break}};return M.listen(n)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INTERACTIONS},actionType:Fn.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INTERACTIONS},actionType:Fn.InteractionActionType.SCROLL})}}const qo={[m.PromotionType.UNSET]:h.TopicSubType.UNSET,[m.PromotionType.INGAME_IAB21]:h.TopicSubType.PROMOTION_INGAME_IAB21,[m.PromotionType.INGAME_IAB21_SIDEBAR]:h.TopicSubType.PROMOTION_INGAME_IAB21,[m.PromotionType.INGAME_IAB11_LBAR]:h.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[m.PromotionType.INGAME_IAB11]:h.TopicSubType.PROMOTION_INGAME_IAB11,[m.PromotionType.INGAME_IAB11_SIDEBAR]:h.TopicSubType.PROMOTION_INGAME_IAB11,[m.PromotionType.INGAME_IAB21_LBAR]:h.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[m.PromotionType.INGAME_IAB61]:h.TopicSubType.PROMOTION_INGAME_IAB61,[m.PromotionType.INGAME_IAB61_SIDEBAR]:h.TopicSubType.PROMOTION_INGAME_IAB61,[m.PromotionType.EXTERNAL_AD]:h.TopicSubType.PROMOTION_GAM,[m.PromotionType.VIDEO_SIDE_BY_SIDE]:h.TopicSubType.PROMOTION_VIDEO_SIDE_BY_SIDE,[m.PromotionType.PICTURE_IN_PICTURE]:h.TopicSubType.PROMOTION_PICTURE_IN_PICTURE,[m.PromotionType.LOWER_THIRD]:h.TopicSubType.PROMOTION_LOWER_THIRD,[m.PromotionType.SHOP_LBAR]:h.TopicSubType.PROMOTION_SHOP_LBAR,[m.PromotionType.SHOP_OVERLAY]:h.TopicSubType.PROMOTION_SHOP_OVERLAY,[m.PromotionType.SHOP_SIDEBAR]:h.TopicSubType.PROMOTION_SHOP_SIDEBAR,[m.PromotionType.NFL_SHOP_LBAR]:h.TopicSubType.PROMOTION_SHOP_LBAR,[m.PromotionType.NFL_SHOP_OVERLAY]:h.TopicSubType.PROMOTION_SHOP_OVERLAY,[m.PromotionType.NFL_SHOP_SIDEBAR]:h.TopicSubType.PROMOTION_SHOP_SIDEBAR,[m.PromotionType.STATS]:h.TopicSubType.UNSET,[m.PromotionType.STANDARD]:h.TopicSubType.UNSET,[m.PromotionType.SHOP]:h.TopicSubType.UNSET,[m.PromotionType.NFL_SHOP]:h.TopicSubType.UNSET},rn=t=>t?qo[t]:h.TopicSubType.UNSET,Qo={25:h.Kind.AD_VIDEO_Q25,50:h.Kind.AD_VIDEO_Q50,75:h.Kind.AD_VIDEO_Q75};class jo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(!r.slEventBus?.skipAnalytics&&r.slEventBus?.type==="advertisement"){const i=rn(r.slEventBus.payload.type);switch(r.slEventBus.action){case"videoPlay":this.videoPlay(r.slEventBus.payload,{topicSubType:i});break;case"videoEnd":this.videoEnd(r.slEventBus.payload,{topicSubType:i});break;case"videoRendered":this.videoRendered(r.slEventBus.payload,{topicSubType:i});break;case"buttonSelect":this.buttonSelect(r.slEventBus.payload,{topicSubType:i});break;case"bannerSelect":this.bannerSelect(r.slEventBus.payload,{topicSubType:i});break;case"bannerShown":this.bannerShown(r.slEventBus.payload,{topicSubType:i});break;case"received":this.received(r.slEventBus.payload,{topicSubType:i});break;case"opened":this.opened(r.slEventBus.payload,{topicSubType:i});break;case"viewed":this.viewed(r.slEventBus.payload,{topicSubType:i});break;case"videoMuted":case"videoUnmuted":this.videoMuted(r.slEventBus.payload,{topicSubType:i,muted:r.slEventBus.action==="videoMuted"});break;case"videoReplayed":this.videoReplayed(r.slEventBus.payload,{topicSubType:i});break;case"quartileCompleted":this.quartileCompleted(r.slEventBus.payload,{topicSubType:i});break}}};return M.listen(n)})}received=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_RECEIVED,topicId:e,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:n},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_OPENED,topicId:e,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:n==="notification"?h.PollOpenedFrom.IN_APP:h.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:n})=>{};videoMuted=({id:e},{topicSubType:n,muted:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:r?h.Kind.AD_VIDEO_MUTED:h.Kind.AD_VIDEO_UNMUTED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};quartileCompleted=({id:e,quartile:n},{topicSubType:r})=>{n&&this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:Qo[n],topicType:h.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoReplayed=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_REPLAYED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_PLAYED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoEnd=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_COMPLETE,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoRendered=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_RENDERED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_INTERACTION_BUTTON_NAVIGATED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_INTERACTION_BANNER_NAVIGATED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};bannerShown=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_BANNER_SHOWN,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})}}const Xe={[m.QuestionType.UNSET]:h.TopicType.UNSET,[m.QuestionType.FACTOID]:h.TopicType.POLLS_INSIGHT,[m.QuestionType.POLL]:h.TopicType.POLLS_POLL,[m.QuestionType.PREDICTION]:h.TopicType.POLLS_PREDICTION,[m.QuestionType.PROMOTION]:h.TopicType.POLLS_PROMOTION,[m.QuestionType.TRIVIA]:h.TopicType.POLLS_TRIVIA,[m.QuestionType.TWEET]:h.TopicType.POLLS_TWITTER};m.QuestionType.UNSET+"",te.NotificationKind.UNSET,m.QuestionType.FACTOID+"",te.NotificationKind.POLLS,m.QuestionType.POLL+"",te.NotificationKind.POLLS,m.QuestionType.PREDICTION+"",te.NotificationKind.POLLS,m.QuestionType.PROMOTION+"",te.NotificationKind.POLLS,m.QuestionType.TRIVIA+"",te.NotificationKind.POLLS,m.QuestionType.TWEET+"",te.NotificationKind.POLLS;const xo={[B.SdkOverlayType.UNSET]:h.Category.UNSET,[B.SdkOverlayType.INPLAY]:h.Category.INPLAY,[B.SdkOverlayType.MESSAGING]:h.Category.MESSAGING,[B.SdkOverlayType.STATISTICS]:h.Category.STATS,[B.SdkOverlayType.BETTING]:h.Category.BETTING,[B.SdkOverlayType.TWITTER]:h.Category.TWITTER,[B.SdkOverlayType.MERCHANDISE]:h.Category.MERCHANDISE,[B.SdkOverlayType.CONTESTS]:h.Category.CONTESTS,[B.SdkOverlayType.VOICE_CHAT]:h.Category.CALLING,[B.SdkOverlayType.TICKETS]:h.Category.TICKETS,[B.SdkOverlayType.WHOIS_WATCHING]:h.Category.WHOISWATCHING,[B.SdkOverlayType.PROFILE]:h.Category.PROFILE,[B.SdkOverlayType.GAMES]:h.Category.POLLS,[B.SdkOverlayType.GOLF_STATISTICS]:h.Category.STATS,[B.SdkOverlayType.HIGHLIGHTS]:h.Category.HIGHLIGHTS,[B.SdkOverlayType.PUBLIC_CHAT]:h.Category.PUBLIC_CHAT};class Go{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="notification")switch(r.slEventBus.action){case"rendered":this.received(r.slEventBus.payload);break;case"opened":this.opened(r.slEventBus.payload);break}if(r.slEventBus?.type==="advertisement")switch(r.slEventBus.action){case"notification-received":this.received({questionId:r.slEventBus.payload.id,questionType:m.QuestionType.PROMOTION,topicSubType:rn(r.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:r.slEventBus.payload.id,questionType:m.QuestionType.PROMOTION,topicSubType:rn(r.slEventBus.payload.type)});break}};return M.listen(n)})}received=({questionId:e,questionType:n,topicSubType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET,topicSubType:r},notificationKind:te.NotificationKind.POLLS,notificationType:te.NotificationType.IN_APP})};opened=({questionId:e,questionType:n,topicSubType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.NOTIFICATION_OPENED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET,topicSubType:r},notificationKind:te.NotificationKind.POLLS,notificationType:te.NotificationType.IN_APP})}}class Ko{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="poll")switch(r.slEventBus.action){case"voted":this.voted(r.slEventBus.payload);break;case"navigated":this.navigated();break;case"onboardingPassed":this.onboardingPassed();break;case"received":this.received(r.slEventBus.payload);break;case"viewed":this.viewed(r.slEventBus.payload);break}};return M.listen(n)})}received=({questionId:e,questionType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_RECEIVED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET},pollOpenedFrom:h.PollOpenedFrom.UNSET})};viewed=({questionId:e,questionType:n,questionOpenedFrom:r,isAd:i})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:i?h.Kind.POLLS_AD_OPENED:h.Kind.POLLS_OPENED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET},pollOpenedFrom:r==="list"?h.PollOpenedFrom.PICK_HISTORY:h.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:n,isAd:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:r?h.Kind.POLLS_AD_VOTE:h.Kind.POLLS_VOTE,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET},pollOpenedFrom:h.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.GAMES_JOINED},pollOpenedFrom:h.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_NAVIGATED},pollOpenedFrom:h.PollOpenedFrom.UNSET})}}const Ho=({transport:t,$commonStore:e})=>{let n;const r=x(!1),i=3e4,{client:o,queryKey:s}=t.createPromiseClient(mr.AnalyticsService,{method:"send",params:[r]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const p=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...p,kind:h.Kind.SESSION_HEARTBEAT}}}})}catch(v){ye.error(v,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{ye.debug("mounted heartbeat"),n=a.subscribe(()=>{})},d=()=>{ye.debug("enabled heartbeat"),r.set(!0),a.lc===0&&u()},c=()=>{ye.debug("disabled heartbeat"),r.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{ye.debug("unmounted heartbeat"),a.off(),n?.(),n=void 0,c()}}},ye=ce("analytics");class zo{commonStore;notifications;polls;invitation;interactions;advertisement;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Oe(Y({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=Ho({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new Go(this),this.polls=new Ko(this),this.invitation=new Mo(this),this.interactions=new $o(this),this.advertisement=new jo(this);const{client:n}=e.analyticsTransport.createPromiseClient(mr.AnalyticsService,{method:"send"});this.analyticsClient=n}connect=()=>{this.writeCommon("sessionId",bt.v4()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,ye.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,ye.debug("analytics disconnected")};write=(e,n)=>{n&&this.analyticsClient.unary({message:{case:e,value:n}}).then(()=>{ye.trace("send analytics success",e,n)}).catch(r=>{ye.error(r,"send analytics failed")})};writeCommon=(e,n)=>{this.commonStore.setValue(e,n)};onConnect=e=>{this.listeners.add(e),this.connected&&this.listenersCancels.add(e())};connectToSDK=e=>{this.onConnect(()=>e.stores.slStreamId.getAtomStore().subscribe(n=>{this.writeCommon("eventId",n)})),this.onConnect(()=>e.sdk.getActiveFeature().subscribe(n=>{n&&this.writeCommon("category",xo[n]),n!==B.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",bt.v4()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const n=window.matchMedia("(orientation: portrait)"),r=i=>{this.writeCommon("screenOrientation",i.matches?h.ScreenOrientation.PORTRAIT:h.ScreenOrientation.LANDSCAPE)};return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)}}),this.onConnect(()=>e.deepLink.$store.subscribe(n=>{n?.handled&&this.invitation.accepted()}))}}const Wo=(t,e,n)=>{t.analytics=new zo(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),t.sdk.writeOverlaySessionId=r=>{r===""?t.analytics.writeCommon("overlaySessionId",""):t.analytics.writeCommon("overlaySessionId",bt.v4())},()=>{t.analytics.disconnect()})),n()};var mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var gn={exports:{}},bn={exports:{}};function Jo(t){var e=new t,n=e;function r(){var o=e;return o.next?e=o.next:(e=new t,n=e),o.next=null,o}function i(o){n.next=o,n=o}return{get:r,release:i}}var Xo=Jo,Zo=Xo;function Pr(t,e,n){if(typeof t=="function"&&(n=e,e=t,t=null),!(n>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var r=Zo(es),i=null,o=null,s=0,a=null,u={push:w,drain:J,saturated:J,pause:c,paused:!1,get concurrency(){return n},set concurrency(O){if(!(O>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(n=O,!u.paused)for(;i&&s<n;)s++,L()},running:d,resume:v,idle:E,length:l,getQueue:p,unshift:A,empty:J,kill:S,killAndDrain:T,error:k};return u;function d(){return s}function c(){u.paused=!0}function l(){for(var O=i,$=0;O;)O=O.next,$++;return $}function p(){for(var O=i,$=[];O;)$.push(O.value),O=O.next;return $}function v(){if(u.paused){if(u.paused=!1,i===null){s++,L();return}for(;i&&s<n;)s++,L()}}function E(){return s===0&&u.length()===0}function w(O,$){var N=r.get();N.context=t,N.release=L,N.value=O,N.callback=$||J,N.errorHandler=a,s>=n||u.paused?o?(o.next=N,o=N):(i=N,o=N,u.saturated()):(s++,e.call(t,N.value,N.worked))}function A(O,$){var N=r.get();N.context=t,N.release=L,N.value=O,N.callback=$||J,N.errorHandler=a,s>=n||u.paused?i?(N.next=i,i=N):(i=N,o=N,u.saturated()):(s++,e.call(t,N.value,N.worked))}function L(O){O&&r.release(O);var $=i;$&&s<=n?u.paused?s--:(o===i&&(o=null),i=$.next,$.next=null,e.call(t,$.value,$.worked),o===null&&u.empty()):--s===0&&u.drain()}function S(){i=null,o=null,u.drain=J}function T(){i=null,o=null,u.drain(),u.drain=J}function k(O){a=O}}function J(){}function es(){this.value=null,this.callback=J,this.next=null,this.release=J,this.context=null,this.errorHandler=null;var t=this;this.worked=function(n,r){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=J,t.errorHandler&&o(n,s),i.call(t.context,n,r),t.release(t)}}function ts(t,e,n){typeof t=="function"&&(n=e,e=t,t=null);function r(c,l){e.call(this,c).then(function(p){l(null,p)},l)}var i=Pr(t,r,n),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var l=new Promise(function(p,v){o(c,function(E,w){if(E){v(E);return}p(w)})});return l.catch(J),l}function u(c){var l=new Promise(function(p,v){s(c,function(E,w){if(E){v(E);return}p(w)})});return l.catch(J),l}function d(){if(i.idle())return new Promise(function(p){p()});var c=i.drain,l=new Promise(function(p){i.drain=function(){c(),p()}});return l}}bn.exports=Pr;bn.exports.promise=ts;var Cr=bn.exports,vn={exports:{}},Qe=typeof Reflect=="object"?Reflect:null,Gn=Qe&&typeof Qe.apply=="function"?Qe.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},ft;Qe&&typeof Qe.ownKeys=="function"?ft=Qe.ownKeys:Object.getOwnPropertySymbols?ft=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ft=function(e){return Object.getOwnPropertyNames(e)};function ns(t){console&&console.warn&&console.warn(t)}var Nr=Number.isNaN||function(e){return e!==e};function V(){V.init.call(this)}vn.exports=V;vn.exports.once=ss;V.EventEmitter=V;V.prototype._events=void 0;V.prototype._eventsCount=0;V.prototype._maxListeners=void 0;var Kn=10;function Pt(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(V,"defaultMaxListeners",{enumerable:!0,get:function(){return Kn},set:function(t){if(typeof t!="number"||t<0||Nr(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Kn=t}});V.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};V.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Nr(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 Lr(t){return t._maxListeners===void 0?V.defaultMaxListeners:t._maxListeners}V.prototype.getMaxListeners=function(){return Lr(this)};V.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);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(n.length>0&&(s=n[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")Gn(u,this,n);else for(var d=u.length,c=Ur(u,d),r=0;r<d;++r)Gn(c[r],this,n);return!0};function Fr(t,e,n,r){var i,o,s;if(Pt(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]),s===void 0)s=o[e]=n,++t._eventsCount;else if(typeof s=="function"?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=Lr(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,ns(a)}return t}V.prototype.addListener=function(e,n){return Fr(this,e,n,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(e,n){return Fr(this,e,n,!0)};function rs(){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 Dr(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=rs.bind(r);return i.listener=n,r.wrapFn=i,i}V.prototype.once=function(e,n){return Pt(n),this.on(e,Dr(this,e,n)),this};V.prototype.prependOnceListener=function(e,n){return Pt(n),this.prependListener(e,Dr(this,e,n)),this};V.prototype.removeListener=function(e,n){var r,i,o,s,a;if(Pt(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){a=r[s].listener,o=s;break}if(o<0)return this;o===0?r.shift():is(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||n)}return this};V.prototype.off=V.prototype.removeListener;V.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),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(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function Rr(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?os(i):Ur(i,i.length)}V.prototype.listeners=function(e){return Rr(this,e,!0)};V.prototype.rawListeners=function(e){return Rr(this,e,!1)};V.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Vr.call(t,e)};V.prototype.listenerCount=Vr;function Vr(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}V.prototype.eventNames=function(){return this._eventsCount>0?ft(this._events):[]};function Ur(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function is(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function os(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function ss(t,e){return new Promise(function(n,r){function i(s){t.removeListener(e,o),r(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}Br(t,e,o,{once:!0}),e!=="error"&&as(t,i,{once:!0})})}function as(t,e,n){typeof t.on=="function"&&Br(t,"error",e,n)}function Br(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Mr=vn.exports,Ct={},$r={},qr=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[n]=i;for(n 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]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,n);if(s.value!==i||s.enumerable!==!0)return!1}return!0},us=qr,Nt=function(){return us()&&!!Symbol.toStringTag},cs=Error,ds=EvalError,ls=RangeError,fs=ReferenceError,Qr=SyntaxError,Lt=TypeError,ps=URIError,Hn=typeof Symbol<"u"&&Symbol,hs=qr,ys=function(){return typeof Hn!="function"||typeof Symbol!="function"||typeof Hn("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:hs()},Ut={__proto__:null,foo:{}},ms=Object,gs=function(){return{__proto__:Ut}.foo===Ut.foo&&!(Ut instanceof ms)},bs="Function.prototype.bind called on incompatible ",vs=Object.prototype.toString,Ss=Math.max,ws="[object Function]",zn=function(e,n){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var o=0;o<n.length;o+=1)r[o+e.length]=n[o];return r},Ts=function(e,n){for(var r=[],i=n,o=0;i<e.length;i+=1,o+=1)r[o]=e[i];return r},Es=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},As=function(e){var n=this;if(typeof n!="function"||vs.apply(n)!==ws)throw new TypeError(bs+n);for(var r=Ts(arguments,1),i,o=function(){if(this instanceof i){var c=n.apply(this,zn(r,arguments));return Object(c)===c?c:this}return n.apply(e,zn(r,arguments))},s=Ss(0,n.length-r.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+Es(a,",")+"){ return binder.apply(this,arguments); }")(o),n.prototype){var d=function(){};d.prototype=n.prototype,i.prototype=new d,d.prototype=null}return i},Os=As,Sn=Function.prototype.bind||Os,Is=Function.prototype.call,_s=Object.prototype.hasOwnProperty,ks=Sn,Ps=ks.call(Is,_s),C,Cs=cs,Ns=ds,Ls=ls,Fs=fs,Ge=Qr,je=Lt,Ds=ps,jr=Function,Bt=function(t){try{return jr('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var Mt=function(){throw new je},Rs=Ie?function(){try{return arguments.callee,Mt}catch{try{return Ie(arguments,"callee").get}catch{return Mt}}}():Mt,Re=ys(),Vs=gs(),G=Object.getPrototypeOf||(Vs?function(t){return t.__proto__}:null),Ue={},Us=typeof Uint8Array>"u"||!G?C:G(Uint8Array),_e={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?C:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?C:ArrayBuffer,"%ArrayIteratorPrototype%":Re&&G?G([][Symbol.iterator]()):C,"%AsyncFromSyncIteratorPrototype%":C,"%AsyncFunction%":Ue,"%AsyncGenerator%":Ue,"%AsyncGeneratorFunction%":Ue,"%AsyncIteratorPrototype%":Ue,"%Atomics%":typeof Atomics>"u"?C:Atomics,"%BigInt%":typeof BigInt>"u"?C:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?C:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?C:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?C:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Cs,"%eval%":eval,"%EvalError%":Ns,"%Float32Array%":typeof Float32Array>"u"?C:Float32Array,"%Float64Array%":typeof Float64Array>"u"?C:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?C:FinalizationRegistry,"%Function%":jr,"%GeneratorFunction%":Ue,"%Int8Array%":typeof Int8Array>"u"?C:Int8Array,"%Int16Array%":typeof Int16Array>"u"?C:Int16Array,"%Int32Array%":typeof Int32Array>"u"?C:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Re&&G?G(G([][Symbol.iterator]())):C,"%JSON%":typeof JSON=="object"?JSON:C,"%Map%":typeof Map>"u"?C:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Re||!G?C:G(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?C:Promise,"%Proxy%":typeof Proxy>"u"?C:Proxy,"%RangeError%":Ls,"%ReferenceError%":Fs,"%Reflect%":typeof Reflect>"u"?C:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?C:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Re||!G?C:G(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?C:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Re&&G?G(""[Symbol.iterator]()):C,"%Symbol%":Re?Symbol:C,"%SyntaxError%":Ge,"%ThrowTypeError%":Rs,"%TypedArray%":Us,"%TypeError%":je,"%Uint8Array%":typeof Uint8Array>"u"?C:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?C:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?C:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?C:Uint32Array,"%URIError%":Ds,"%WeakMap%":typeof WeakMap>"u"?C:WeakMap,"%WeakRef%":typeof WeakRef>"u"?C:WeakRef,"%WeakSet%":typeof WeakSet>"u"?C:WeakSet};if(G)try{null.error}catch(t){var Bs=G(G(t));_e["%Error.prototype%"]=Bs}var Ms=function t(e){var n;if(e==="%AsyncFunction%")n=Bt("async function () {}");else if(e==="%GeneratorFunction%")n=Bt("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=Bt("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&G&&(n=G(i.prototype))}return _e[e]=n,n},Wn={__proto__:null,"%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"]},tt=Sn,St=Ps,$s=tt.call(Function.call,Array.prototype.concat),qs=tt.call(Function.apply,Array.prototype.splice),Yn=tt.call(Function.call,String.prototype.replace),wt=tt.call(Function.call,String.prototype.slice),Qs=tt.call(Function.call,RegExp.prototype.exec),js=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,xs=/\\(\\)?/g,Gs=function(e){var n=wt(e,0,1),r=wt(e,-1);if(n==="%"&&r!=="%")throw new Ge("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Ge("invalid intrinsic syntax, expected opening `%`");var i=[];return Yn(e,js,function(o,s,a,u){i[i.length]=a?Yn(u,xs,"$1"):s||o}),i},Ks=function(e,n){var r=e,i;if(St(Wn,r)&&(i=Wn[r],r="%"+i[0]+"%"),St(_e,r)){var o=_e[r];if(o===Ue&&(o=Ms(r)),typeof o>"u"&&!n)throw new je("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:o}}throw new Ge("intrinsic "+e+" does not exist!")},nt=function(e,n){if(typeof e!="string"||e.length===0)throw new je("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new je('"allowMissing" argument must be a boolean');if(Qs(/^%?[^%]*%?$/,e)===null)throw new Ge("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Gs(e),i=r.length>0?r[0]:"",o=Ks("%"+i+"%",n),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],qs(r,$s([0,1],d)));for(var c=1,l=!0;c<r.length;c+=1){var p=r[c],v=wt(p,0,1),E=wt(p,-1);if((v==='"'||v==="'"||v==="`"||E==='"'||E==="'"||E==="`")&&v!==E)throw new Ge("property names with quotes must have matching quotes");if((p==="constructor"||!l)&&(u=!0),i+="."+p,s="%"+i+"%",St(_e,s))a=_e[s];else if(a!=null){if(!(p in a)){if(!n)throw new je("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=r.length){var w=Ie(a,p);l=!!w,l&&"get"in w&&!("originalValue"in w.get)?a=w.get:a=a[p]}else l=St(a,p),a=a[p];l&&!u&&(_e[s]=a)}}return a},xr={exports:{}},$t,Jn;function wn(){if(Jn)return $t;Jn=1;var t=nt,e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return $t=e,$t}var Hs=nt,pt=Hs("%Object.getOwnPropertyDescriptor%",!0);if(pt)try{pt([],"length")}catch{pt=null}var Ft=pt,Xn=wn(),zs=Qr,Ve=Lt,Zn=Ft,Ws=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new Ve("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new Ve("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ve("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ve("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ve("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ve("`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=!!Zn&&Zn(e,n);if(Xn)Xn(e,n,{configurable:s===null&&u?u.configurable:!s,enumerable:i===null&&u?u.enumerable:!i,value:r,writable:o===null&&u?u.writable:!o});else if(a||!i&&!o&&!s)e[n]=r;else throw new zs("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},on=wn(),Gr=function(){return!!on};Gr.hasArrayLengthDefineBug=function(){if(!on)return null;try{return on([],"length",{value:1}).length!==1}catch{return!0}};var Ys=Gr,Js=nt,er=Ws,Xs=Ys(),tr=Ft,nr=Lt,Zs=Js("%Math.floor%"),ea=function(e,n){if(typeof e!="function")throw new nr("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||Zs(n)!==n)throw new nr("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&tr){var s=tr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!r)&&(Xs?er(e,"length",n,!0,!0):er(e,"length",n)),e};(function(t){var e=Sn,n=nt,r=ea,i=Lt,o=n("%Function.prototype.apply%"),s=n("%Function.prototype.call%"),a=n("%Reflect.apply%",!0)||e.call(s,o),u=wn(),d=n("%Math.max%");t.exports=function(p){if(typeof p!="function")throw new i("a function is required");var v=a(e,s,arguments);return r(v,1+d(0,p.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(xr);var Tn=xr.exports,Kr=nt,Hr=Tn,ta=Hr(Kr("String.prototype.indexOf")),En=function(e,n){var r=Kr(e,!!n);return typeof r=="function"&&ta(e,".prototype.")>-1?Hr(r):r},na=Nt(),ra=En,sn=ra("Object.prototype.toString"),Dt=function(e){return na&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:sn(e)==="[object Arguments]"},zr=function(e){return Dt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&sn(e)!=="[object Array]"&&sn(e.callee)==="[object Function]"},ia=function(){return Dt(arguments)}();Dt.isLegacyArguments=zr;var oa=ia?Dt:zr,sa=Object.prototype.toString,aa=Function.prototype.toString,ua=/^\s*(?:function)?\*/,Wr=Nt(),qt=Object.getPrototypeOf,ca=function(){if(!Wr)return!1;try{return Function("return function*() {}")()}catch{}},Qt,da=function(e){if(typeof e!="function")return!1;if(ua.test(aa.call(e)))return!0;if(!Wr){var n=sa.call(e);return n==="[object GeneratorFunction]"}if(!qt)return!1;if(typeof Qt>"u"){var r=ca();Qt=r?qt(r):!1}return qt(e)===Qt},Yr=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,an,ht;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{an=Object.defineProperty({},"length",{get:function(){throw ht}}),ht={},$e(function(){throw 42},null,an)}catch(t){t!==ht&&($e=null)}else $e=null;var la=/^\s*class\b/,un=function(e){try{var n=Yr.call(e);return la.test(n)}catch{return!1}},jt=function(e){try{return un(e)?!1:(Yr.call(e),!0)}catch{return!1}},yt=Object.prototype.toString,fa="[object Object]",pa="[object Function]",ha="[object GeneratorFunction]",ya="[object HTMLAllCollection]",ma="[object HTML document.all class]",ga="[object HTMLCollection]",ba=typeof Symbol=="function"&&!!Symbol.toStringTag,va=!(0 in[,]),cn=function(){return!1};if(typeof document=="object"){var Sa=document.all;yt.call(Sa)===yt.call(document.all)&&(cn=function(e){if((va||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=yt.call(e);return(n===ya||n===ma||n===ga||n===fa)&&e("")==null}catch{}return!1})}var wa=$e?function(e){if(cn(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,an)}catch(n){if(n!==ht)return!1}return!un(e)&&jt(e)}:function(e){if(cn(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(ba)return jt(e);if(un(e))return!1;var n=yt.call(e);return n!==pa&&n!==ha&&!/^\[object HTML/.test(n)?!1:jt(e)},Ta=wa,Ea=Object.prototype.toString,Jr=Object.prototype.hasOwnProperty,Aa=function(e,n,r){for(var i=0,o=e.length;i<o;i++)Jr.call(e,i)&&(r==null?n(e[i],i,e):n.call(r,e[i],i,e))},Oa=function(e,n,r){for(var i=0,o=e.length;i<o;i++)r==null?n(e.charAt(i),i,e):n.call(r,e.charAt(i),i,e)},Ia=function(e,n,r){for(var i in e)Jr.call(e,i)&&(r==null?n(e[i],i,e):n.call(r,e[i],i,e))},_a=function(e,n,r){if(!Ta(n))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=r),Ea.call(e)==="[object Array]"?Aa(e,n,i):typeof e=="string"?Oa(e,n,i):Ia(e,n,i)},Xr=_a,ka=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],xt=ka,Pa=typeof globalThis>"u"?mn:globalThis,Zr=function(){for(var e=[],n=0;n<xt.length;n++)typeof Pa[xt[n]]=="function"&&(e[e.length]=xt[n]);return e},Tt=Xr,Ca=Zr,rr=Tn,An=En,mt=Ft,Na=An("Object.prototype.toString"),ei=Nt(),ir=typeof globalThis>"u"?mn:globalThis,dn=Ca(),On=An("String.prototype.slice"),Gt=Object.getPrototypeOf,La=An("Array.prototype.indexOf",!0)||function(e,n){for(var r=0;r<e.length;r+=1)if(e[r]===n)return r;return-1},Et={__proto__:null};ei&&mt&&Gt?Tt(dn,function(t){var e=new ir[t];if(Symbol.toStringTag in e){var n=Gt(e),r=mt(n,Symbol.toStringTag);if(!r){var i=Gt(n);r=mt(i,Symbol.toStringTag)}Et["$"+t]=rr(r.get)}}):Tt(dn,function(t){var e=new ir[t],n=e.slice||e.set;n&&(Et["$"+t]=rr(n))});var Fa=function(e){var n=!1;return Tt(Et,function(r,i){if(!n)try{"$"+r(e)===i&&(n=On(i,1))}catch{}}),n},Da=function(e){var n=!1;return Tt(Et,function(r,i){if(!n)try{r(e),n=On(i,1)}catch{}}),n},Ra=function(e){if(!e||typeof e!="object")return!1;if(!ei){var n=On(Na(e),8,-1);return La(dn,n)>-1?n:n!=="Object"?!1:Da(e)}return mt?Fa(e):null},At=Xr,Va=Zr,or=Tn,In=En,gt=Ft,Ua=In("Object.prototype.toString"),ti=Nt(),sr=typeof globalThis>"u"?mn:globalThis,ln=Va(),_n=In("String.prototype.slice"),Kt=Object.getPrototypeOf,Ba=In("Array.prototype.indexOf",!0)||function(e,n){for(var r=0;r<e.length;r+=1)if(e[r]===n)return r;return-1},Ot={__proto__:null};ti&>&&Kt?At(ln,function(t){var e=new sr[t];if(Symbol.toStringTag in e){var n=Kt(e),r=gt(n,Symbol.toStringTag);if(!r){var i=Kt(n);r=gt(i,Symbol.toStringTag)}Ot["$"+t]=or(r.get)}}):At(ln,function(t){var e=new sr[t],n=e.slice||e.set;n&&(Ot["$"+t]=or(n))});var Ma=function(e){var n=!1;return At(Ot,function(r,i){if(!n)try{"$"+r(e)===i&&(n=_n(i,1))}catch{}}),n},$a=function(e){var n=!1;return At(Ot,function(r,i){if(!n)try{r(e),n=_n(i,1)}catch{}}),n},qa=function(e){if(!e||typeof e!="object")return!1;if(!ti){var n=_n(Ua(e),8,-1);return Ba(ln,n)>-1?n:n!=="Object"?!1:$a(e)}return gt?Ma(e):null},Qa=qa,ja=function(e){return!!Qa(e)};(function(t){var e=oa,n=da,r=Ra,i=ja;function o(g){return g.call.bind(g)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),d=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),l=o(Boolean.prototype.valueOf);if(s)var p=o(BigInt.prototype.valueOf);if(a)var v=o(Symbol.prototype.valueOf);function E(g,ui){if(typeof g!="object")return!1;try{return ui(g),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=i;function w(g){return typeof Promise<"u"&&g instanceof Promise||g!==null&&typeof g=="object"&&typeof g.then=="function"&&typeof g.catch=="function"}t.isPromise=w;function A(g){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(g):i(g)||y(g)}t.isArrayBufferView=A;function L(g){return r(g)==="Uint8Array"}t.isUint8Array=L;function S(g){return r(g)==="Uint8ClampedArray"}t.isUint8ClampedArray=S;function T(g){return r(g)==="Uint16Array"}t.isUint16Array=T;function k(g){return r(g)==="Uint32Array"}t.isUint32Array=k;function O(g){return r(g)==="Int8Array"}t.isInt8Array=O;function $(g){return r(g)==="Int16Array"}t.isInt16Array=$;function N(g){return r(g)==="Int32Array"}t.isInt32Array=N;function re(g){return r(g)==="Float32Array"}t.isFloat32Array=re;function ie(g){return r(g)==="Float64Array"}t.isFloat64Array=ie;function ke(g){return r(g)==="BigInt64Array"}t.isBigInt64Array=ke;function we(g){return r(g)==="BigUint64Array"}t.isBigUint64Array=we;function de(g){return u(g)==="[object Map]"}de.working=typeof Map<"u"&&de(new Map);function Rt(g){return typeof Map>"u"?!1:de.working?de(g):g instanceof Map}t.isMap=Rt;function ve(g){return u(g)==="[object Set]"}ve.working=typeof Set<"u"&&ve(new Set);function We(g){return typeof Set>"u"?!1:ve.working?ve(g):g instanceof Set}t.isSet=We;function Pe(g){return u(g)==="[object WeakMap]"}Pe.working=typeof WeakMap<"u"&&Pe(new WeakMap);function Vt(g){return typeof WeakMap>"u"?!1:Pe.working?Pe(g):g instanceof WeakMap}t.isWeakMap=Vt;function Ce(g){return u(g)==="[object WeakSet]"}Ce.working=typeof WeakSet<"u"&&Ce(new WeakSet);function le(g){return Ce(g)}t.isWeakSet=le;function Ne(g){return u(g)==="[object ArrayBuffer]"}Ne.working=typeof ArrayBuffer<"u"&&Ne(new ArrayBuffer);function rt(g){return typeof ArrayBuffer>"u"?!1:Ne.working?Ne(g):g instanceof ArrayBuffer}t.isArrayBuffer=rt;function f(g){return u(g)==="[object DataView]"}f.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&f(new DataView(new ArrayBuffer(1),0,1));function y(g){return typeof DataView>"u"?!1:f.working?f(g):g instanceof DataView}t.isDataView=y;var b=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function I(g){return u(g)==="[object SharedArrayBuffer]"}function D(g){return typeof b>"u"?!1:(typeof I.working>"u"&&(I.working=I(new b)),I.working?I(g):g instanceof b)}t.isSharedArrayBuffer=D;function R(g){return u(g)==="[object AsyncFunction]"}t.isAsyncFunction=R;function P(g){return u(g)==="[object Map Iterator]"}t.isMapIterator=P;function F(g){return u(g)==="[object Set Iterator]"}t.isSetIterator=F;function U(g){return u(g)==="[object Generator]"}t.isGeneratorObject=U;function W(g){return u(g)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=W;function Te(g){return E(g,d)}t.isNumberObject=Te;function it(g){return E(g,c)}t.isStringObject=it;function Le(g){return E(g,l)}t.isBooleanObject=Le;function ot(g){return s&&E(g,p)}t.isBigIntObject=ot;function Cn(g){return a&&E(g,v)}t.isSymbolObject=Cn;function si(g){return Te(g)||it(g)||Le(g)||ot(g)||Cn(g)}t.isBoxedPrimitive=si;function ai(g){return typeof Uint8Array<"u"&&(rt(g)||D(g))}t.isAnyArrayBuffer=ai,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(g){Object.defineProperty(t,g,{enumerable:!1,value:function(){throw new Error(g+" is not supported in userland")}})})})($r);var xa=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},fn={exports:{}};typeof Object.create=="function"?fn.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:fn.exports=function(e,n){if(n){e.super_=n;var r=function(){};r.prototype=n.prototype,e.prototype=new r,e.prototype.constructor=e}};var Ga=fn.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(y){for(var b=Object.keys(y),I={},D=0;D<b.length;D++)I[b[D]]=Object.getOwnPropertyDescriptor(y,b[D]);return I},n=/%[sdj%]/g;t.format=function(f){if(!O(f)){for(var y=[],b=0;b<arguments.length;b++)y.push(s(arguments[b]));return y.join(" ")}for(var b=1,I=arguments,D=I.length,R=String(f).replace(n,function(F){if(F==="%%")return"%";if(b>=D)return F;switch(F){case"%s":return String(I[b++]);case"%d":return Number(I[b++]);case"%j":try{return JSON.stringify(I[b++])}catch{return"[Circular]"}default:return F}}),P=I[b];b<D;P=I[++b])S(P)||!ie(P)?R+=" "+P:R+=" "+s(P);return R},t.deprecate=function(f,y){if(typeof _<"u"&&_.noDeprecation===!0)return f;if(typeof _>"u")return function(){return t.deprecate(f,y).apply(this,arguments)};var b=!1;function I(){if(!b){if(_.throwDeprecation)throw new Error(y);_.traceDeprecation?console.trace(y):console.error(y),b=!0}return f.apply(this,arguments)}return I};var r={},i=/^$/;if(_.env.NODE_DEBUG){var o=_.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(f){if(f=f.toUpperCase(),!r[f])if(i.test(f)){var y=_.pid;r[f]=function(){var b=t.format.apply(t,arguments);console.error("%s %d: %s",f,y,b)}}else r[f]=function(){};return r[f]};function s(f,y){var b={seen:[],stylize:u};return arguments.length>=3&&(b.depth=arguments[2]),arguments.length>=4&&(b.colors=arguments[3]),L(y)?b.showHidden=y:y&&t._extend(b,y),N(b.showHidden)&&(b.showHidden=!1),N(b.depth)&&(b.depth=2),N(b.colors)&&(b.colors=!1),N(b.customInspect)&&(b.customInspect=!0),b.colors&&(b.stylize=a),c(b,f,b.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(f,y){var b=s.styles[y];return b?"\x1B["+s.colors[b][0]+"m"+f+"\x1B["+s.colors[b][1]+"m":f}function u(f,y){return f}function d(f){var y={};return f.forEach(function(b,I){y[b]=!0}),y}function c(f,y,b){if(f.customInspect&&y&&de(y.inspect)&&y.inspect!==t.inspect&&!(y.constructor&&y.constructor.prototype===y)){var I=y.inspect(b,f);return O(I)||(I=c(f,I,b)),I}var D=l(f,y);if(D)return D;var R=Object.keys(y),P=d(R);if(f.showHidden&&(R=Object.getOwnPropertyNames(y)),we(y)&&(R.indexOf("message")>=0||R.indexOf("description")>=0))return p(y);if(R.length===0){if(de(y)){var F=y.name?": "+y.name:"";return f.stylize("[Function"+F+"]","special")}if(re(y))return f.stylize(RegExp.prototype.toString.call(y),"regexp");if(ke(y))return f.stylize(Date.prototype.toString.call(y),"date");if(we(y))return p(y)}var U="",W=!1,Te=["{","}"];if(A(y)&&(W=!0,Te=["[","]"]),de(y)){var it=y.name?": "+y.name:"";U=" [Function"+it+"]"}if(re(y)&&(U=" "+RegExp.prototype.toString.call(y)),ke(y)&&(U=" "+Date.prototype.toUTCString.call(y)),we(y)&&(U=" "+p(y)),R.length===0&&(!W||y.length==0))return Te[0]+U+Te[1];if(b<0)return re(y)?f.stylize(RegExp.prototype.toString.call(y),"regexp"):f.stylize("[Object]","special");f.seen.push(y);var Le;return W?Le=v(f,y,b,P,R):Le=R.map(function(ot){return E(f,y,b,P,ot,W)}),f.seen.pop(),w(Le,U,Te)}function l(f,y){if(N(y))return f.stylize("undefined","undefined");if(O(y)){var b="'"+JSON.stringify(y).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return f.stylize(b,"string")}if(k(y))return f.stylize(""+y,"number");if(L(y))return f.stylize(""+y,"boolean");if(S(y))return f.stylize("null","null")}function p(f){return"["+Error.prototype.toString.call(f)+"]"}function v(f,y,b,I,D){for(var R=[],P=0,F=y.length;P<F;++P)Ce(y,String(P))?R.push(E(f,y,b,I,String(P),!0)):R.push("");return D.forEach(function(U){U.match(/^\d+$/)||R.push(E(f,y,b,I,U,!0))}),R}function E(f,y,b,I,D,R){var P,F,U;if(U=Object.getOwnPropertyDescriptor(y,D)||{value:y[D]},U.get?U.set?F=f.stylize("[Getter/Setter]","special"):F=f.stylize("[Getter]","special"):U.set&&(F=f.stylize("[Setter]","special")),Ce(I,D)||(P="["+D+"]"),F||(f.seen.indexOf(U.value)<0?(S(b)?F=c(f,U.value,null):F=c(f,U.value,b-1),F.indexOf(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ci=require("pino"),m=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),z=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),B=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),st=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),Z=require("nanostores"),bt=require("uuid"),Q=require("@connectrpc/connect"),Nn=require("@connectrpc/connect-web"),Ln=require("@nanostores/query"),hr=require("@streamlayer/sl-eslib/sports/events/events_pb"),et=require("@streamlayer/sl-eslib/sdkSettings/client/client_pb"),yn=require("@streamlayer/sl-eslib/users/users_pb"),yr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb"),di=require("@streamlayer/sl-eslib/shortLinks/linksClient_pb"),h=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),mr=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_pb"),Fn=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),te=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function li(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var gr={exports:{}},j=gr.exports={},se,ae;function en(){throw new Error("setTimeout has not been defined")}function tn(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?se=setTimeout:se=en}catch{se=en}try{typeof clearTimeout=="function"?ae=clearTimeout:ae=tn}catch{ae=tn}})();function br(t){if(se===setTimeout)return setTimeout(t,0);if((se===en||!se)&&setTimeout)return se=setTimeout,setTimeout(t,0);try{return se(t,0)}catch{try{return se.call(null,t,0)}catch{return se.call(this,t,0)}}}function fi(t){if(ae===clearTimeout)return clearTimeout(t);if((ae===tn||!ae)&&clearTimeout)return ae=clearTimeout,clearTimeout(t);try{return ae(t)}catch{try{return ae.call(null,t)}catch{return ae.call(this,t)}}}var me=[],qe=!1,Ae,dt=-1;function pi(){!qe||!Ae||(qe=!1,Ae.length?me=Ae.concat(me):dt=-1,me.length&&vr())}function vr(){if(!qe){var t=br(pi);qe=!0;for(var e=me.length;e;){for(Ae=me,me=[];++dt<e;)Ae&&Ae[dt].run();dt=-1,e=me.length}Ae=null,qe=!1,fi(t)}}j.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];me.push(new Sr(t,e)),me.length===1&&!qe&&br(vr)};function Sr(t,e){this.fun=t,this.array=e}Sr.prototype.run=function(){this.fun.apply(null,this.array)};j.title="browser";j.browser=!0;j.env={};j.argv=[];j.version="";j.versions={};function be(){}j.on=be;j.addListener=be;j.once=be;j.off=be;j.removeListener=be;j.removeAllListeners=be;j.emit=be;j.prependListener=be;j.prependOnceListener=be;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 hi=gr.exports;const _=li(hi),yi=ci.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ce=(t,e)=>yi.child({name:t},e);class mi extends Event{slEventBus;constructor(e,n){super(e),this.slEventBus=n}}const gi=ce("event-bus");class bi{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,n)=>{const r=new mi(this.name,{...n,type:e});gi.debug(r,"Emitting event"),window.dispatchEvent(r)};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 vi{}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));window.slStore=Object.create(null);class _t{store;name;constructor(e,n){this.store=e,this.name=n}getStore(){return this.store}}const Si=t=>{const e=Object.keys(t);return Z.computed(e.map(n=>t[n].getStore()),(...n)=>Object.fromEntries(e.map((r,i)=>[r,n[i]])))};class Oe extends _t{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,n)=>this.getStore().setKey(e,n);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const Y=t=>Z.map(t);var pe;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(pe||(pe={}));const wi={[B.SdkOverlayType.BETTING]:"betting",[B.SdkOverlayType.GAMES]:"games",[B.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[B.SdkOverlayType.TWITTER]:"twitter"};var Je;(function(t){t.Ready="ready",t.Suspended="suspended"})(Je||(Je={}));const Ti=new Set(["equals","clone","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","getType"]);class wr{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...n},r){this.settingsKey=wi[n.type],this.status=Z.atom(Je.Suspended),this.config=new Oe(Y(n),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Oe(Y(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Oe(Y({}),`feature:settings:${this.settingsKey}`),this.source=r}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(Je.Ready)};disable=()=>{this.status.set(Je.Suspended)};setFeatureConfig=({settings:e,...n})=>{let r;for(r in n)this.config.setValue(r,n[r]);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)!Ti.has(o)&&i[o]&&this.settings.setValue(o,i[o])}}};update=(e,n)=>{this.source===pe.STREAM&&n===pe.ORGANIZATION||(this.setFeatureConfig(e),this.source=n)};fireEvent(e){for(const n of this.listeners.values())try{n.onEvent(e)}catch(r){console.error(r)}}}class X extends _t{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 x=t=>Z.atom(t);class ne extends _t{atomStore;constructor(e,n,r){super(e,`api:${n}`),this.atomStore=Z.atom(),r&&e.subscribe(i=>{const o=this.atomStore.get(),s=r(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 M=new bi;async function*Ei(t,e){for await(const n of e){t.response.message=n,t.received_at=Date.now(),t.id=Date.now();const r={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(r),yield n}}const Ai=()=>t=>async e=>{const n={id:Date.now(),name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries()),message:e.message},response:{}};try{window.postMessage({type:"__GRPC_DEVTOOLS_EXTENSION__",data:n})}catch(r){console.log("devtools error",r)}try{const r=await t(e);if(n.received_at=Date.now(),n.response.header=Object.fromEntries(r.header.entries()),n.response.trailer=Object.fromEntries(r.trailer.entries()),e.stream){const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...n,stream:!0}};try{window.postMessage(i)}catch(o){console.log("devtools error",o)}return{...r,message:Ei(n,r.message)}}else{n.response.message=r.message,n.latency=n.received_at-n.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};try{window.postMessage(i)}catch(o){console.log("devtools error",o)}}return r}catch(r){n.received_at=Date.now(),n.response.trailer={"grpc-status":r.code,"grpc-message":r.rawMessage},n.response.message=r.rawMessage,n.latency=n.received_at-n.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};try{window.postMessage(i)}catch(o){console.log("devtools error",o)}throw r}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function Tr(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")}class He{delimiter=":";prefix;storage;constructor(e="main",n=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=n}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 n=e.pop()||"",r=this.generateKey(e);try{this.storage.setItem(r,n)}catch(i){Tr(i)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(r,n))}};read=(...e)=>{const n=this.storage.getItem(this.generateKey(e));return n===null?void 0:n};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var ee;(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"})(ee||(ee={}));const Dn=ce("grpc:stream");class Oi{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,n,r,i){const o={status:ee.Init,ts:new Date,log:[]};this.state=new Oe(Y(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=r,this.method=n,i.withStore&&(this.store=new X(x(null),`subscription:${i.name}:store`)),"subscribe"in r&&typeof r.subscribe=="function"&&(this.paramsListener=r.subscribe(s=>{this.state.getValue("status")===ee.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(ee.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const n=this.state.getStore().get().log,r=`${this.options.name} ${new Date().toISOString()}: ${e}`;if(n.push(r),this.state.setValue("log",n),localStorage.getItem("SL_DEBUG")){e.startsWith("received data")?Dn.trace({name:this.options.name,attempt:this.attempt},"received data"):Dn.trace({name:this.options.name,attempt:this.attempt},e);try{window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
|
|
2
|
+
`+r)}catch(i){Tr(i)&&window.sessionStorage.removeItem("slstreamlogs"),window.sessionStorage.setItem("slstreamlogs",r)}}};addListener=(e,n)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),()=>{}):(this.listeners.set(e,n),this.addStateLog(`listener '${e}' added`),()=>this.removeListener(e));removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(ee.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 r={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,r);for await(const o of i)this.attempt=0,this.onData(o)}catch(r){r instanceof Q.ConnectError&&r.code!=Q.Code.Canceled&&this.onStreamError(r)}})(),this.updateState(ee.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(ee.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(ee.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),n=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(ee.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${n}ms`),this.connect(),this.reconnectTimeout=void 0},n)}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[,n]of this.listeners)n(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(n){this.addStateLog(`error process data => ${n}`)}};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(ee.Failed),this.state.setValue("error",e),e.code===Q.Code.Unknown&&e.cause==="missing trailer"&&(this.attempt=0),this.reconnect();return}this.disconnect()}}}const Ii=new Set([Q.Code.Unknown,Q.Code.Internal,Q.Code.DeadlineExceeded,Q.Code.ResourceExhausted,Q.Code.FailedPrecondition,Q.Code.Unavailable,Q.Code.DataLoss]),Rn=ce("grpc:retry"),_i=t=>async e=>{const n=e.contextValues.get(nn.retryAttempts),r=300,i=e.contextValues.get(nn.retryDelay);if(e.stream||n===0)return t(e);Rn.trace({url:e.url,attempts:n,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Rn.trace({attempt:o,error:s,url:e.url},"retry attempt");const a=Q.ConnectError.from(s);if(o>=n||!(a instanceof Q.ConnectError)||!Ii.has(a.code))throw s;const u=Math.min(i,Math.pow(2,o)*r),d=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,d))}},nn={retryAttempts:Q.createContextKey(10,{description:"Number of attempts to retry"}),retryDelay:Q.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},Pi=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=bt.v4();return localStorage.setItem("sl-device-id",e),e},ki=()=>navigator.userAgentData?.platform||navigator.platform,Ci=t=>t?"webOS":navigator.userAgentData&&navigator.userAgentData.mobile||"ontouchstart"in window||navigator.maxTouchPoints>0?"mobile-web":"desktop-web";class Vn{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;storeCache;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,n){this.host=e,this.opts=n,this.$headers=new Oe(Y({"sl-device-id":Pi(),"sl-device-os":ki(),"sl-platform":Ci(n?.webOS)}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map,this.storeCache=new Map;const[r,i,o]=Ln.nanoquery({dedupeTime:n?.dedupeTime,refetchInterval:n?.refetchInterval});this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:o},this.transport=Nn.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=Nn.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors})}addSubscription=(e,n,r)=>{const i=this.subscriptions.get(n);if(i)return i;const o=new Oi(this.$headers,e,n,r);return this.subscriptions.set(n,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,n,r]=Ln.nanoquery({dedupeTime:this.opts?.dedupeTime,refetchInterval:this.opts?.refetchInterval});this.nanoquery={createFetcherStore:e,createMutatorStore:n,utils:r}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(n=>n!==e)};getClient=e=>{const n=e.typeName;if(this.clients.has(n))return this.clients.get(n);const r=Q.createClient(e,this.transport);return this.clients.set(n,r),r};getStreamClient=e=>{const n=`stream-${e.typeName}`;if(this.clients.has(n))return this.clients.get(n);const r=Q.createClient(e,this.streamTransport);return this.clients.set(n,r),r};createPromiseClient=(e,{params:n=[],method:r})=>{const i=this.getClient(e),o=r.toString(),s=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1),...Array.isArray(n)?n:[n]],a=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1)];return{client:i,createRequestOptions:d=>{const c=Q.createContextValues();for(const l in d){const p=nn[l];c.set(p,d[l])}return c},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,n)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",n)};setHeader=(e,n)=>this.$headers.setValue(e,n);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=n=>r=>{const i=this.$headers.getValues();for(const o in i)r.header.set(o,i[o]);return n(r)};this.interceptors.push(e),window.localStorage.getItem("SL_GRPC_DEVTOOLS")==="true"?this.interceptors.push(Ai()):console.warn("SL GRPC DevTools is disabled. To enable, set SL_GRPC_DEVTOOLS to true in localStorage."),this.opts?.retryable&&this.interceptors.push(_i)}}const Ni=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(hr.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s||typeof s!="string")return"";try{return(await n.retrieveEventId({id:s})).data?.id||""}catch{return""}}})},Li=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>s?(await n.getStream({id:s})).data?.attributes:void 0})},Fi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(hr.Events,{method:"summary",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>s?(await n.summary({id:s})).data?.attributes:void 0})},Di=(t,e)=>{const{queryKey:n,client:r}=e.createPromiseClient(yn.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{if(!e.getHeader("authorization"))return{data:void 0};const{data:o}=await r.me({});return{data:o}}})},Ri=t=>{const{client:e,createRequestOptions:n}=t.createPromiseClient(yn.Users,{method:"bypassAuth"}),r=n({retryAttempts:0});return({userKey:i,schema:o,init:s,inviterKey:a})=>e.bypassAuth({userKey:i,schema:o,init:s,inviterKey:a},{contextValues:r})},Vi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>(await n.get({})).data?.attributes})},Ui=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{const i=await n.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},Bi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(et.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>(await n.getOrganizationAdvertising({})).data?.attributes})},Mi=(t,e,n)=>{t.transport=new Vn(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0,webOS:e.webOS}),t.analyticsTransport=new Vn(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(r=>{t.analyticsTransport.$headers.getStore().set(r)}),t.sdk.onMount({name:"transport"},()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),n()};var fe;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(fe||(fe={}));class Be extends He{constructor(){super("user")}setSchema=e=>{this.write(fe.SCHEMA,e)};getSchema=()=>this.read(fe.SCHEMA);setToken=e=>{this.write(fe.TOKEN,e)};getToken=()=>this.read(fe.TOKEN);setExternalToken=e=>{this.write(fe.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(fe.EXTERNAL_TOKEN);removeToken=()=>{this.remove(fe.TOKEN)}}var he;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(he||(he={}));const $i=t=>{const e=new Be,n=new X(x(e.getExternalToken()),"userKey"),r=new X(x(e.getToken()),"userToken"),i=new ne(Di(r.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 ne(Vi(r.getStore(),t),"userSettings");return{userKey:n,userToken:r,user:i,userSettings:o}},qi=t=>{const e=new X(x(void 0),"providerStreamId"),n=new ne(Ni(e.getStore(),t),"slStreamId",o=>o?.data),r=new ne(Li(n.getAtomStore(),t),"streamSettings"),i=new ne(Fi(n.getAtomStore(),t),"streamSettings");return n.getAtomStore().listen(o=>{(o===""||o===void 0)&&(r.getStore().mutate(void 0),i.getStore().mutate(void 0))}),{providerStreamId:e,slStreamId:n,streamSettings:r,streamSummary:i}},Qi=t=>{const e=new X(x(void 0),"enabled"),n=new X(x(he.DISABLED),"status"),r=new ne(Ui(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new ne(Bi(r.getAtomStore(),t),"organizationAdvertising"),o=$i(t),s=qi(t);return{enabled:e,status:n,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,streamSummary:s.streamSummary,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:r,organizationAdvertising:i}};class ji extends _t{stores;constructor(e){const n=Qi(e),r=Si(n);super(r,"core"),this.stores=n}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let n;for(n in this.stores){const r=e[n];n in e&&r!==void 0&&this.stores[n].subscribe(e[n])}};unsubscribe=()=>this.getStore().off()}const xi=(t,e,n)=>{t.store=new ji(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(([r,i])=>[r,i.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.sdk.streamSummary=()=>t.stores.streamSummary.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},n()},Gi=t=>{const{client:e}=t.createPromiseClient(yr.Leaderboard,{method:"list"});return n=>e.list(n)},Er=t=>{const{client:e}=t.createPromiseClient(yr.Leaderboard,{method:"summary"});return n=>e.summary(n)},Ki=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(yn.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s)return[];try{return(await n.getFriends({})).data}catch{return[]}}})},Hi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(z.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>(await n.get({eventId:s})).data?.attributes,refetchInterval:1/0,dedupeTime:1e3*60*60})},zi=(t,e,n)=>{const{client:r,queryKey:i}=n.createPromiseClient(z.Feed,{method:"syncQuestion",params:[t,e?"true":""]});return n.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>{if(!a||u)return;const d=await r.syncQuestion({filter:{eventId:a}});if(d.data?.attributes?.question?.type!==m.QuestionType.PROMOTION)return d.data?.attributes},dedupeTime:1e3*60*10,refetchInterval:1/0})},Wi=async(t,e)=>{const{client:n}=e.createPromiseClient(z.Feed,{method:"item",params:[t]});return(await n.item({id:t})).data},Yi=(t,e)=>{const{client:n}=e.createStreamClient(z.Feed),r=Z.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{r.set({eventId:o,feedId:""})}),e.addSubscription(n.subscription,r,{name:"feedSubscription"})},Ji=(t,e)=>{const{client:n}=e.createStreamClient(z.Feed);return e.addSubscription(n.questionSubscription,{questionId:t},{name:"questionSubscription"})},Ar=async(t,e)=>{const{client:n}=e.createPromiseClient(z.Feed,{method:"questionByUser",params:[t]});return(await n.questionByUser({questionId:t})).data?.attributes?.question},lt=(t,e)=>{const{client:n,queryKey:r,queryKeyStr:i}=e.createPromiseClient(z.Feed,{method:"questionByUser",params:[t]});let o=i;if(typeof t!="object"?o+=t:o+="atom",e.storeCache.has(o))return e.storeCache.get(o);{const s=e.nanoquery.createFetcherStore(r,{fetcher:async(a,u,d)=>(await n.questionByUser({questionId:d})).data?.attributes?.question,dedupeTime:1/0,refetchInterval:1/0});return e.storeCache.set(o,s),s}},Or=async(t,e)=>{if(!t)return;const{client:n}=e.createPromiseClient(z.Feed,{method:"getQuestion",params:[t]}),r=await n.getQuestion({id:t});if(!r.data?.attributes)return;const{options:i,notification:o,...s}=r.data.attributes,a=i?.options.case==="promotion"?i?.options.value:void 0;return{id:s.id,question:s,promotion:a,notification:o}},Xi=(t,e,n,r,i,o,s)=>{const{client:a,queryKey:u}=s.createPromiseClient(z.Feed,{method:"list",params:[t,e,o?"true":""]});return s.nanoquery.createFetcherStore(u,{fetcher:async(d,c,l,p,v)=>{if(!l||v)return[];const E=await a.list({eventId:l,filter:{types:p===Se.ALLOWED?[]:[m.QuestionType.FACTOID,m.QuestionType.PROMOTION,m.QuestionType.TWEET],statuses:[m.QuestionStatus.ACTIVE,m.QuestionStatus.RESOLVED]}}),w={eventId:l,userId:n.get(),organizationId:r.get()};for(const A of E.data)i.isQuestionReceived(w,A.id)||(M.emit("poll",{action:"received",payload:{isAd:A.attributes?.adUnit==m.AdUnit.UNSET,questionId:A.id,questionType:A.attributes?.type}}),i.saveQuestionReceived(w,A.id));return E.data},dedupeTime:1/0,refetchInterval:1/0})},Zi=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(z.Feed,{method:"list",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s)return;const u=(await n.list({eventId:s,filter:{types:[m.QuestionType.PROMOTION],statuses:[m.QuestionStatus.ACTIVE]},pagination:{page:0,pageSize:1}})).data?.[0];if(u.type==="promotion")return Or(u.id,e)},dedupeTime:1/0,refetchInterval:1/0})},eo=(t,e,n,r,i)=>{const{client:o,queryKey:s}=i.createPromiseClient(z.Feed,{method:"betPack",params:[t,e,n]});return i.nanoquery.createFetcherStore(s,{fetcher:async(a,u,d,c,l)=>{if(!d||!c||!l)return{timestamp:Date.now(),data:null};const p=await o.betPack({eventId:d,types:[m.QuestionType.PREDICTION],statuses:[m.QuestionStatus.ACTIVE,m.QuestionStatus.RESOLVED],limit:5,sort:{field:"activated_at",order:"asc"}});return!p.data||!p.data.length?{timestamp:Date.now(),data:null}:{timestamp:Date.now(),data:p.data?.reduce((v,E)=>{const w=E?.attributes?.question;if(!w?.id)return v;const A={eventId:d,userId:c,organizationId:l};return r.isQuestionReceived(A,w.id)||(M.emit("poll",{action:"received",payload:{isAd:w?.adUnit==m.AdUnit.UNSET,questionId:w.id,questionType:w.type}}),r.saveQuestionReceived(A,w.id)),w.answers=w.answers.sort((L,S)=>L.id>S.id?1:-1),{...v,[w.id]:w}},{})}},dedupeTime:1/0,refetchInterval:1/0})},to=(t,e,n)=>{const r=Z.batched([e,n],()=>{const a=e.get();if(!a)return;const u=n.get().data?.find(c=>c.id===a?.questionId),d=a?.question?.openedFrom;return u?(u.openedFrom=d,u):a.question}),i=Z.batched(r,a=>a&&a.type==="question"?a.id:void 0),o=lt(i,t);return{$store:r,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,l)=>{if(!c||!l)return(c||l||[]).sort((w,A)=>w.id>A.id?1:-1);const p=c.sort((w,A)=>w.id>A.id?1:-1),v=l.sort((w,A)=>w.id>A.id?1:-1),E=[];for(let w=0;w<p.length;w++)E.push({...p[w],...v[w],correct:p[w].correct,youVoted:p[w].youVoted,pointsEarned:p[w].pointsEarned});return E};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:d(u?.answers,a?.answers)})}}};var Me;(function(t){t.SHOWED="showed",t.EVENT="ev"})(Me||(Me={}));class no extends He{constructor(){super("advertisement")}setShowed=e=>{this.write(Me.SHOWED,e,"true")};isViewed=e=>this.read(Me.SHOWED,e);fireEvent=(e,n)=>{this.write(Me.EVENT,n,e,"true")};isEventFired=(e,n)=>this.read(Me.EVENT,n,e)==="true"}const ro=t=>{const e=t.data?.attributes?.question;if((t.data?.attributes?.feedItem?.type==="promotion"?t.data.attributes.feedItem:void 0)===void 0||!e)return;const{options:r,notification:i,...o}=e,s=r?.options.case==="promotion"?r.options.value:void 0;return{id:o.id,question:o,notification:i,promotion:s}},at=t=>t.startsWith("http://")||t.startsWith("https://")?new URL(t).toString():t,io=({gamOptions:t,gamBaseUrl:e})=>{const n=`${e}?`,r=[];for(const i in t){const o=i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1_").toLowerCase(),s=t[i];if(s)if(typeof s=="string")r.push(`${o}=${at(s)}`);else if(Array.isArray(s))r.push(`${o}=${s.map(at).join(",")}`);else{const a=Object.entries(s).map(([u,d])=>Array.isArray(d)?`${u}=${d.map(at).join(",")}`:typeof d=="string"?`${u}=${at(d)}`:`${u}=${d}`).join("&").replaceAll("=","%3D").replaceAll("&","%26").replaceAll(",","%2C");r.push(`${o}=${a}`)}}return n+r.join("&")},Fe=t=>(t?.promotion?.type===m.PromotionType.INGAME_IAB11_LBAR||t?.promotion?.type===m.PromotionType.INGAME_IAB21_LBAR)&&!!t.promotion.additionalBanner?.imageUrl,oo=(t,e,n)=>{let r=!1;const i=n.transport,o=ce("advertisement"),s=new no,a=(S,T)=>{s.fireEvent(S,T)},u=(S,T)=>s.isEventFired(S,T),d=Y({}),c=Zi(t,i),l=S=>{const T=d.get(),P=T.data?.question.id,O=T.data?.promotion?.type;if(!P)return;d.get()?.isOpened||(d.setKey("isOpened",!0),M.emit("advertisement",{action:"opened",payload:{id:P,type:O,hasBanner:Fe(T.data),openedFrom:S?.fromNotification?"notification":"auto"}})),S?.fromNotification&&(d.setKey("hasNotification",!1),M.emit("advertisement",{action:"notification-opened",payload:{id:P,type:O,hasBanner:Fe(T.data)}}))},p=()=>{const S=d.get(),T=S.data?.question.id,P=S.data?.promotion?.type,O=d.get()?.isOpened;T&&!O&&(o.debug({id:T},"markAsViewed: %o"),s.setShowed(T),d.setKey("isOpened",!0),M.emit("advertisement",{action:"viewed",payload:{id:T,type:P,hasBanner:Fe(S.data)}}))},v=(S,T)=>{T?d.set({loading:!1,error:void 0,data:T,hasNotification:T?.notification?.enabled===m.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>E(T.question.id),togglePause:P=>w(T.question.id,P),toggleMute:P=>A(T.question.id,P),isViewed:!!s.isViewed(T.question.id),fireEvent:P=>a(S,P),isEventFired:P=>u(S,P)}):(d.setKey("loading",!0),Or(S,i).then(P=>d.set({loading:!1,error:void 0,data:P,hasNotification:P?.notification?.enabled===m.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>E(P?.question.id),togglePause:O=>w(P?.question.id,O),toggleMute:O=>A(P?.question.id,O),isViewed:P&&!!s.isViewed(P.question.id),fireEvent:O=>a(S,O),isEventFired:O=>u(S,O)})).catch(P=>d.set({loading:!1,error:P,data:void 0,fireEvent:()=>{},isEventFired:()=>!1})))};d.subscribe((S,T)=>{if(!(S.data?.id===T?.data?.id&&S.isPaused!==T?.isPaused)){if(S.data?.promotion?.type===m.PromotionType.EXTERNAL_AD&&!S?.externalAd&&S.data.promotion.adCampaigns?.desktopWebSettings){const P=io(S.data.promotion.adCampaigns.desktopWebSettings);d.setKey("externalAd",{type:"gam",url:P})}S.data?.promotion&&!S.isOpened&&(M.emit("advertisement",{action:"received",payload:{id:S.data.question.id,type:S.data.promotion.type,hasNotification:!!S.hasNotification,hasBanner:Fe(S.data),isViewed:!!s.isViewed(S.data.question.id)},skipAnalytics:S.data.question.id===T?.data?.question.id}),S.data.question.id!==T?.data?.question.id&&!s.isViewed(S.data.question.id)&&M.emit("advertisement",{action:"notification-received",payload:{id:S.data.question.id,type:S.data.promotion.type,hasNotification:!0,hasBanner:Fe(S.data),isViewed:!1}})),!S?.data&&T?.data&&M.emit("advertisement",{action:"closed",payload:{id:T.data.question.id,type:T.data.promotion?.type,hasNotification:!!T.hasNotification,hasBanner:Fe(T.data),isViewed:!!s.isViewed(T.data.question.id)}})}});const E=S=>{(!S||d.get()?.data?.question.id===S)&&d.set({})},w=(S,T)=>{d.get()?.data?.question.id===S&&d.setKey("isPaused",T)},A=(S,T)=>{d.get()?.data?.question.id===S&&d.setKey("isMuted",T)};return{connect:()=>{r||(r=!0,c.subscribe((S,T)=>{S.data&&(!T?.data||S.data.id!==T.data.id)&&v(S.data.question.id,S.data)}),e.addListener("promotion",S=>{const T=ro(S);if(T){if(T.question.status===m.QuestionStatus.RESOLVED){E(T.question.id),o.debug({promotion:T},"resolved: %o");return}if(T.question.status===m.QuestionStatus.ACTIVE){o.debug({promotion:T},"active: %o"),v(T.question.id,T);return}o.debug({promotion:T},"skip: %o")}}))},hide:E,show:v,open:l,markAsViewed:p,$store:d}};var oe;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io",t.QUESTION_RECEIVED="q-received",t.QUESTION_OPENED="q-opened"})(oe||(oe={}));class so extends He{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,n)=>{this.write(...e,n)};readValue=e=>this.read(...e)}class ao extends He{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new so}saveQuestionReceived=({userId:e,eventId:n,organizationId:r},i)=>{this.write(oe.QUESTION_RECEIVED,r,e,n,i,"1")};isQuestionReceived=({userId:e,eventId:n,organizationId:r},i)=>!!this.read(oe.QUESTION_RECEIVED,r,e,n,i);saveQuestionOpened=({userId:e,eventId:n,organizationId:r},i)=>{this.write(oe.QUESTION_OPENED,r,e,n,i,"1")};isQuestionOpened=({userId:e,eventId:n,organizationId:r},i)=>!!this.read(oe.QUESTION_OPENED,r,e,n,i);saveOnboardingStatus=({userId:e,eventId:n,organizationId:r},i)=>{this.write(oe.ONBOARDING,r,e,n,i)};getOnboardingStatus=({userId:e,eventId:n,organizationId:r})=>this.read(oe.ONBOARDING,r,e,n);setOnboardingInstantOpen=({userId:e,eventId:n,organizationId:r})=>{this.sessionStorage.writeValue([oe.ONBOARDING_IO,r,e,n],"1")};getOnboardingInstantOpen=({userId:e,eventId:n,organizationId:r})=>this.sessionStorage.readValue([oe.ONBOARDING_IO,r,e,n])}var Se;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Se||(Se={}));class uo{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;betPack;moderationId;moderation;feedSubscription;questionSubscription;advertisement;storage;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=ce("gamification-background"),this.storage=new ao,this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new X(x(void 0),"moderationId").getStore(),this.interactiveAllowed=new X(x(Se.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new X(x(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new ne(Hi(this.slStreamId,e.transport),"gamification:moderation");const n=!!e.sdk.options.get().betPack;this.feedList=new ne(Xi(this.slStreamId,this.interactiveAllowed,this.userId,this.organizationId,this.storage,n,e.transport),"gamification:feedList"),this.betPack=new ne(eo(this.slStreamId,this.userId,this.organizationId,this.storage,e.transport),"gamification:betPack"),this.activeQuestionId=zi(this.slStreamId,n,e.transport),this.openedQuestion=to(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0),this.questionSubscription=Ji(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{const o=i.data?.attributes?.question;if(this.openedQuestion.updateExtendedQuestion(o),this.betPack&&o?.type===m.QuestionType.PREDICTION&&(o.status===m.QuestionStatus.ACTIVE||o.status===m.QuestionStatus.RESOLVED)){const s=this.betPack.getValues().data?.data||{},a=s?.[o.id];if(a){const u=[],d=a.answers.sort((l,p)=>l.id>p.id?1:-1),c=o.answers.sort((l,p)=>l.id>p.id?1:-1);for(let l=0;l<d.length;l++)u.push({...d[l],...c[l],correct:d[l].correct,youVoted:d[l].youVoted,pointsEarned:d[l].pointsEarned});this.betPack.getStore().mutate({timestamp:Date.now(),data:{...s,[o.id]:{...a,status:o.status,marketClosed:o.marketClosed,activatedAt:o.activatedAt,answerSetAt:o.answerSetAt,answers:u}}})}}}),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.cancels.add(this.feedSubscription.addListener("bet-pack-update",async r=>{const i=r.data?.attributes?.question;if(this.betPack&&i?.type===m.QuestionType.PREDICTION&&(i.status===m.QuestionStatus.ACTIVE||i.status===m.QuestionStatus.RESOLVED)){const o=this.betPack.getValues().data?.data||{},s=o?.[i.id];if(s)this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:{...s,status:i.status,marketClosed:i.marketClosed,activatedAt:i.activatedAt,answerSetAt:i.answerSetAt}}});else if(!s&&Object.keys(o).length<5){const a=await Ar(i.id,this.transport);this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:a}})}}})),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",r=>{const i=this.activeQuestionId.get().data?.question?.id,o=r.data?.attributes?.question;if(!(!o||o.type===m.QuestionType.PROMOTION)){if(o.status===m.QuestionStatus.RESOLVED){i===o.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(r.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((r,i)=>{r.data?.feedItem&&r.data?.feedItem?.id!==i?.data?.feedItem?.id&&e.onQuestionActivate({stage:"activate",id:r.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:r.data.feedItem.id})),hasNotification:!0,type:r.data.feedItem.type}),!r.data?.feedItem&&i?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:i.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:i.data.feedItem.id})),hasNotification:!0,type:i.data.feedItem.type})})),this.feedSubscription.connect(),this.cancels.add(this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})),e.sdk.onMount({name:"gamification-background"},()=>()=>{this.activeQuestionId.off();for(const r of this.cancels)r(),this.cancels.delete(r)}),n||(this.advertisement=oo(this.slStreamId,this.feedSubscription,e))}getCurrentSessionId=e=>{const n=e.eventId||this.slStreamId.get()||"",r=e.userId||this.userId.get()||"",i=e.organizationId||this.organizationId.get()||"",o=e.entity||"",s=e.prefix||"";return[i,n,r,s,o].join(":")};disconnect=()=>{this.feedSubscription?.disconnect(),this.questionSubscription!==void 0&&(this.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0)};openQuestion=(e,n)=>{this.openedQuestionId.set({questionId:e,question:n}),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 co{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ce("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=x(new Map)}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const n=e.close,r=e.action;if(this.store.set(e.id,{...e,close:(...i)=>{n&&n(...i),this.closeNotification(e.id)},action:(...i)=>{r&&r(...i),this.closeNotification(e.id,{animateHiding:!1})}}),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 n=this.store.get(e);if(!n){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}M.emit("notification",{action:"received",payload:{type:n.type,questionId:n.data.questionId,questionType:n.data.questionType}});const r=setTimeout(()=>{const i=e,o=new Map(this.notificationsList.get());o.set(n.id,n),this.notificationsList.set(o);const s=setTimeout(()=>{this.logger.debug({notificationId:i,delay:n.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(i)},n.autoHideDuration||5e3);this.timeouts.set(i,s),this.logger.debug({notificationId:i,queue:[...o.values()]},"notification displayed")},n.delay||0);this.timeouts.set(e,r),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=(e,{animateHiding:n=!0}={})=>{const r=new Map(this.notificationsList.get()),i=r.get(e);if(i){const o=!(this.waitingQueue.size>=this.options.concurrency)&&n;i.hiding=o,this.notificationsList.set(r);const s=()=>{const a=new Map(this.notificationsList.get());a.delete(e),this.notificationsList.set(a);const u=this.timeouts.get(e);u!==void 0&&(clearTimeout(u),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden"),i.hiding&&M.emit("notification",{action:"closed",payload:{type:i.type,questionId:i.data.questionId,questionType:i.data.questionType}})};if(o){const a=setTimeout(s,this.options.animationDelay||0);this.timeouts.set(e,a)}else s()}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),i};drain=()=>{this.store.clear(),this.timeouts.clear(),this.waitingQueue.clear(),this.activeQueue.clear(),this.notificationsList.off(),this.notificationsList.set(new Map)}}var vt;(function(t){t.OPENED="opened"})(vt||(vt={}));class lo extends He{constructor(){super("notification")}setOpened=e=>{this.write(vt.OPENED,e,"true")};isOpened=e=>this.read(vt.OPENED,e);clearNotification=()=>{this.clear()}}class fo{queue;storage;constructor(e={}){this.storage=new lo,this.queue=new co({concurrency:1,animationDelay:1600,...e})}isViewed=e=>this.storage.isOpened(e);add=e=>{if(!this.isViewed(e.id)){if(e.data&&e.emitEvent){const r=e.action;e.action=(...i)=>{r&&r(...i),M.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,{markAsViewed:n=!0,animateHiding:r}={})=>{this.queue.closeNotification(e,{animateHiding:r}),n&&this.markAsViewed(e)};update=(e,n)=>{const r=this.queue.notificationsList.get()?.get(e);n(r)};getActiveNotification=()=>{const e=this.queue.notificationsList.get();if(!e?.size)return null;for(const r of e.values())if(r.type===ge.ONBOARDING)return r;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const po=(t,e,n)=>{t.notifications=new fo(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),t.sdk.onMount({name:"notifications"},()=>()=>{t.notifications.queue.drain()}),n()};var xe;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(xe||(xe={}));const Un=async(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(z.Feed,{method:"submitAnswer"}),i=r({retryAttempts:0});try{return await n.submitAnswer({data:e},{contextValues:i})}catch(o){throw Q.ConnectError.from(o)?.code===Q.Code.AlreadyExists?new Error(xe.ALREADY_VOTED):new Error(xe.UNKNOWN)}},Ir=(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(z.Feed,{method:"submitInplay"}),i=r({retryAttempts:0});return n.submitInplay({data:{eventId:+e}},{contextValues:i})},ho={pageSize:10},yo=(t,e,n,r,i)=>{let o=0;const s=x({pageSize:ho.pageSize,page:0}),a=Y({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=Gi(t),d=async()=>{const p=e.get(),v=r?.getStore().get().data?.map(E=>E.slId)||[];if(p&&v?.length){const E=n.get();E&&v.push(E),a.setKey("loading",!0),a.setKey("data",[]);const A=await u({eventId:p,usersIds:v,leaderboardId:""});a.set({data:A.data.map((L,S)=>({...L.attributes,friendsRank:S+1})),hasMore:!1,key:Date.now(),loading:!1}),A.meta&&(o=Math.round(A.meta.count/A.meta.pageSize))}},c=()=>{d()},l=p=>{const v=s.get(),E=p||v.page+1;E<=o&&s.set({...v,page:E})};return Z.onMount(a,()=>{const p=e.listen(d),v=r?.listen(d);return()=>{p(),v?.()}}),{$store:a,fetchMore:l,invalidate:c}};class mo extends He{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Bn="sldl",Pt="sldl_uid",_r="sldl_eid",Pr="sldl_e_eid",go=new Set([Pt,_r,Pr]),Mn=t=>{const e={},n={};for(const[r,i]of t)go.has(r)?e[r]=i:n[r]=i;return{result:e,remain:n}},bo=({hash:t,search:e})=>{if(t&&t.includes(Bn)){const n=new URLSearchParams(t.substr(1));return{hash:Mn(n)}}if(e&&e.includes(Bn)){const n=new URLSearchParams(e);return{search:Mn(n)}}return null},$n=ce("deep_link"),ue={debug:(...t)=>{$n.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{$n.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},vo=(t,e)=>{const{hash:n,search:r}=window.location;if(ue.debug({hash:n,search:r},"get deep link data from"),n||r){const i=bo({hash:n,search:r});if(ue.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()}`,ue.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()}`,ue.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},So=(t,e,n)=>{const r=new mo,i=r.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ue.debug(a)}t.deepLink={$store:new Oe(Y(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ue.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?.[Pt]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),r.del("sl-deep-link-store")},t.deepLink.$store.subscribe(a=>r.set("sl-deep-link-store",JSON.stringify(a))),t.sdk.addDeepLinkHandler=a=>{localStorage.getItem("SL_DEBUG")&&ue.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ue.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ue.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ue.trace("called handler"),u(a)}catch(d){console.error(d)}};vo(t.deepLink.$store,s),n()},wo=ce("bypass");class To extends vi{$coreStore;deepLink;transport;bypassLogin;constructor(e,n,r){super(),this.$coreStore=e,this.deepLink=r,this.transport=n,this.bypassLogin=Ri(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,n)=>{this.$coreStore.getValues().userKey.setValue(n);const{used:r,data:i}=this.deepLink.getDeepLinkData(),o=r?"":i?.[Pt];wo.debug({inviterKey:o},"login with inviterKey");const s=await this.bypassLogin({schema:e,userKey:n,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({data:s.data}),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 Be().clear()};softLogout=()=>{const e=new Be;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=({skipLogin:e}={skipLogin:!1})=>{const n=new Be,r=n.getToken(),i=n.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),r)return this.saveUser(r,""),this.me().then(o=>{if(o?.id){const s=o.id;this.saveUser(r,s)}return o});if(i&&!r&&!e){const o=n.getSchema();o&&i&&this.login(o,i).catch(()=>{this.logout()})}};saveUser=(e,n)=>{this.transport.setAuth(e,n),this.$coreStore.getValues().userToken.setValue(e),new Be().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async n=>{try{return await e(n)}catch(r){throw r.code&&(r.code===7||r.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),r}})}}const Ye=new Be,Eo=(t,e,n)=>{t.auth=new To(t.store,t.transport,t.deepLink),t.stores.status.listen(r=>{r===he.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(r,i)=>{if(!(Ye.getSchema()===r&&Ye.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(r,i),Ye.setSchema(r),Ye.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),Ye.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),n()},qn=ce("video_player"),ut={debug:(...t)=>{qn.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{qn.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},Ao=(t,e,n)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=r=>{ut.trace("adding video player controller"),t.videoPlayer.controllers.add(r)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=r=>{ut.trace("removing video player controller"),t.videoPlayer.controllers.delete(r)},t.sdk.controlVideoPlayer=r=>{ut.trace("controlling video player");for(const i of t.videoPlayer.controllers){ut.trace("calling video player controller");try{i(r)}catch(o){console.error(o)}}},n()},Oo={[m.QuestionType.FACTOID]:"insight",[m.QuestionType.POLL]:"poll",[m.QuestionType.TRIVIA]:"trivia",[m.QuestionType.PREDICTION]:"prediction",[m.QuestionType.TWEET]:"tweet"},De=t=>t===m.PromotionType.INGAME_IAB11||t===m.PromotionType.INGAME_IAB21||t===m.PromotionType.NFL_SHOP_OVERLAY||t===m.PromotionType.SHOP_OVERLAY,Io=(t,e,n)=>{t.sdk.uiState=Y({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!0)},disableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),onboardingNotification:!1,appBanner:!1,appSidebar:!1,appNotification:!1,app:!1})},enableExposedPauseAd:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),exposedPauseAd:!0})},disableExposedPauseAd:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),exposedPauseAd:!1})}},e.onContentActivate&&(t.ui.onContentActivate=e.onContentActivate);const r=i=>{t.ui.onContentActivate&&t.ui.onContentActivate({...i,type:"advertisement"})};t.onQuestionActivate=({questionType:i,...o})=>{if(t.ui.enableAppNotification(),t.ui.onContentActivate){const s=o.type||i&&Oo[i]||"question";t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="exposedPauseAd")switch(a.slEventBus.action){case"enabled":t.ui.enableExposedPauseAd();break;case"disabled":t.ui.disableExposedPauseAd();break}if(a.slEventBus?.type==="app")switch(a.slEventBus.action){case"open":t.ui.enableApp();break;case"close":t.ui.disableApp();break}if(a.slEventBus?.type==="poll"){const u=a.slEventBus.action,{hasBanner:d}=a.slEventBus.payload;switch(u){case"onboardingOpen":t.sdk.uiState.set({app:!0});break;case"opened":t.sdk.uiState.set({...t.sdk.uiState.get(),appBanner:d,appSidebar:!0});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),appBanner:!1,appSidebar:!1});break}}if(a.slEventBus?.type==="notification"){const u=a.slEventBus.action;if(a.slEventBus.payload.type===ge.ONBOARDING)switch(u){case"received":t.ui.enableOnboardingNotification();break;case"closed":t.ui.disableOnboardingNotification();break}else switch(u){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:d,hasBanner:c,id:l,isViewed:p,type:v}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:v===m.PromotionType.EXTERNAL_AD,promotionBanner:c,promotionNotification:!1,promotionOverlay:De(v),promotionSidebar:!De(v)});break;case"received":if(t.sdk.closeFeature(),r({stage:"activate",id:l,hasNotification:d,hasBanner:c,isViewed:p}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:c,onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionOverlay:De(v),promotionSidebar:!De(v),promotionExternalAd:v===m.PromotionType.EXTERNAL_AD});break}d?t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionNotification:!0}):t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionBanner:c,promotionOverlay:De(v),promotionSidebar:!De(v),promotionExternalAd:v===m.PromotionType.EXTERNAL_AD});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),promotionNotification:!1,promotionBanner:!1,promotionOverlay:!1,promotionExternalAd:!1,promotionSidebar:!1}),r({stage:"deactivate",id:l,hasNotification:d,hasBanner:c,isViewed:p});break}}},o=M.listen(i),s=t.activeFeature.subscribe(a=>{a||t.ui.disableApp()});return()=>{o(),s()}}),n()},_o=(t,e,n)=>{const r={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=Y(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const d=o.get(s);d&&d(),i.delete(s),o.delete(s)}i.set(s,{cb:u,clear:a}),t?.stores?.enabled?.get()==="on"&&o.set(s,u())},t.ready=()=>{t.stores.enabled.subscribe(s=>{s==="on"&&r.onMountedFired===!1&&(i.forEach(({cb:a},u)=>o.set(u,a())),r.onMountedFired=!0),s!=="on"&&r.onMountedFired===!0&&(o.forEach(a=>a()),o.clear(),i.forEach(({clear:a},u)=>a&&i.delete(u)),r.onMountedFired=!1)})},t.sdk.initializeApp=async s=>{if(t.contextConfig=s,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(he.INITIALIZATION);try{const a=await t.stores.organizationSettings.getValue();return a?(t.stores.status.setValue(he.READY),{enabled:!!a}):(t.stores.status.setValue(he.FAILED),{err:"failed"})}catch(a){return t.stores.enabled.setValue(),t.stores.status.setValue(he.FAILED),{err:`${a}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(he.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=(s,a)=>{a?t.stores.slStreamId.getStore().set({loading:!1,data:s}):t.stores.providerStreamId.setValue(s)},n()},Po=(t,e)=>{const{client:n,queryKey:r}=t.createPromiseClient(et.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s,a)=>{if(!s)return{};try{return(await n.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes}catch{return}},dedupeTime:1e3*60*60*24,refetchInterval:1/0})},ko=(t,{web:e,mobile:n})=>{const{client:r}=t.createPromiseClient(di.LinksClient,{method:"generate"});return r.generate({web:e,mobile:n})},Qn=(t,e)=>{const n=new URLSearchParams(t);for(const[r,i]of Object.entries(e))n.append(r,i);return n.toString()},Co=(t,e,n,r)=>{const i=Y({});return Z.onMount(i,()=>Po(t,[e,n]).subscribe(async({data:a,loading:u})=>{const d=a===void 0&&u===!1?"https://streamlayer.io":a?.url,c=r.get()||"",l=e.get()||"",p=n.get()||"",v={[Pt]:c,[_r]:l,[Pr]:p};if(!u&&d){i.setKey("loading",!0);let E=window.location.search,w=window.location.hash;E&&w||w?E=`?${Qn(E,v)}`:w=`#${Qn("",v)}`;const A=window.location.origin+window.location.pathname+E+w;try{const L=await ko(t,{web:A,mobile:d});i.set({data:L.data?.link,loading:!1})}catch{i.set({loading:!1,error:"Failed to generate short link",data:void 0})}}else i.setKey("loading",!0)})),{$store:i,fetch}};var q;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(q||(q={}));const No=(t,e,n,r)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&n.add({type:ge.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:m.QuestionType.UNSET,onboarding:{...i,instantOpen:!r.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}),markIstantOpen:()=>{r.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}),n.update(o,s=>{s?.data?.onboarding&&(s.data.onboarding.instantOpen=!0)})}}}})},ct=(t,e,n,r,i,o,s,a)=>{try{const u=e.userId.get(),d=e.organizationId.get(),c=e.slStreamId.get();if(!u||!d||!c)return;const l=i.getOnboardingStatus({userId:u,organizationId:d,eventId:c});if(l===q.Completed||a?.skipOnboarding){t.set(q.Completed);for(const A of o)A();a?.skipOnboarding&&l!==q.Completed&&(i.saveOnboardingStatus({organizationId:d,userId:u,eventId:c},q.Completed),Ir(s,c));return}const p=e.moderation.getStore().value?.data,v=n.featureSettings.get().inplayGame;if(p===void 0||v===void 0)return;const E=p?.options?.onboardingEnabled,w=v?.titleCard?.optIn;E?w?t.set(q.Required):t.set(q.Optional):(w?t.set(q.Unavailable):t.set(q.Disabled),r.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(u){console.error(u)}},jn=(t,e,n,r,i)=>{let o=!!i?.skipOnboarding;const s=e.storage,a=x(q.Unset);a.subscribe(c=>{c!==q.Unset&&(c===q.Optional||c===q.Required?o===!1&&(No(t,e,r,s),o=!0):t.onboardingProcessed.set(!0),c===q.Completed&&e.activeQuestionId.invalidate(),s.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const u=[];return a.get()!==q.Completed&&(u.push(e.userId.listen(c=>{c&&ct(a,e,t,r,s,u,n,i)})),u.push(e.moderation.listen(c=>{c.data&&ct(a,e,t,r,s,u,n,i)})),u.push(t.featureSettings.listen(c=>{c&&ct(a,e,t,r,s,u,n,i)}))),ct(a,e,t,r,s,u,n,i),{$store:a,submitInplay:async()=>{const c=e.slStreamId.get();if(c){await Ir(n,c),a.set(q.Completed),s.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:c},q.Completed),M.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const l=e.getCurrentSessionId({prefix:"onboarding"});r.close(l)}}}},Lo=(t,e,n,r)=>{const i=Y(void 0),o=Er(r),s=async()=>{const u=t.get(),d=e.get(),c=n?n.getStore().get().data?.map(v=>v.slId):[];if(!c||!u||!d)return;const l={eventId:u,userId:d,leaderboardId:"",usersIds:[...c,d]},p=await o(l);i.set(p.data?.attributes)},a=()=>{s()};return Z.onMount(i,()=>{a();const u=t.listen(s),d=n?.listen(s),c=e.listen(s);return()=>{u(),d?.(),c()}}),{$store:i,invalidate:a}},Fo=async(t,e,n,r,i)=>{const o=Er(i),s=t.get(),a=e.get(),u=n?.getStore().get().data?.map(p=>p.slId)||[],d={eventId:s,userId:r,leaderboardId:"",usersIds:[...u,a]};return(await o(d)).data?.attributes?.summary},xn=new Set([m.QuestionType.POLL,m.QuestionType.PREDICTION,m.QuestionType.TRIVIA]);class Do extends wr{userSummary;feedList;betPack;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;onboardingProcessed;friendsTabEnabled;skipOnboarding;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,n,r){if(super(e,n),this.background=new uo(r),this.advertisement=this.background.advertisement,this.onQuestionActivate=r.onQuestionActivate,this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=this.background.storage,this.feedList=this.background.feedList,this.betPack=this.background.betPack,this.currentUserId=this.background.userId,this.onboardingProcessed=x(!r.sdk.withAuth),this.leaderboardId=new X(x(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.notifications=r.notifications,this.transport=r.transport,this.closeFeature=(i=!0)=>r.sdk.closeFeature(i),this.openFeature=()=>r.sdk.openFeature(B.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=Co(this.transport,this.background.slStreamId,r.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=Lo(this.background.slStreamId,this.background.userId,this.friends,this.transport),!r.sdk.options.get().hideFriends){this.friends=new ne(Ki(this.background.userId,r.transport),"gamification:friends"),this.openedUser=x(void 0);const i=this.leaderboardList=yo(this.transport,this.background.slStreamId,this.background.userId,this.friends);this.cancels.add(this.userSummary.$store.listen((o,s)=>{s?.summary&&o?.summary&&i.invalidate()}))}this.connect(),this.skipOnboarding=!!r.sdk.options.get().skipOnboarding,this.onboardingStatus=jn(this,this.background,r.transport,r.notifications,{skipOnboarding:r.sdk.options.get().skipOnboarding}),r.sdk.options.get().skipOnboarding||(this.onboardingStatus=jn(this,this.background,r.transport,r.notifications,{skipOnboarding:r.sdk.options.get().skipOnboarding})),this.cancels.add(this.onboardingStatus.$store.listen(this.checkInteractiveFlag)),this.cancels.add(this.background.moderation.getStore().listen(this.checkInteractiveFlag)),this.cancels.add(this.settings.subscribe(this.checkInteractiveFlag)),this.cancels.add(this.onboardingStatus.$store.listen((i,o)=>{(o===void 0||i!==q.Unset)&&this.background.activeQuestionId.invalidate()})),this.background.activeQuestionId.listen(this.showInApp),this.friendsTabEnabled=x(!1),this.cancels.add(r.sdk.options.subscribe(i=>{i.friendsTab==="disabled"?this.friendsTabEnabled.set(!1):i.friendsTab==="enabled"&&this.friendsTabEnabled.set(!0)})),this.cancels.add(this.settings.subscribe(i=>{r.sdk.options.get().friendsTab==="activatedGame"&&this.friendsTabEnabled.set(!!i.inplayGame?.titleCard?.optIn)})),r.sdk.onMount({name:"gamification",clear:!0},()=>()=>{for(const i of this.cancels)i(),this.cancels.delete(i)})}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Se.ALLOWED}checkInteractiveFlag=()=>{if(this.skipOnboarding)this.background.interactiveAllowed.set(Se.ALLOWED);else{const e=this.onboardingStatus.$store.get(),n=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,r=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===q.Completed,o=!n||i||r!==!0;this.background.interactiveAllowed.set(o?Se.ALLOWED:Se.DISALLOWED)}};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement&&this.advertisement.connect()}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-prediction-close",async e=>{if(!this.isInteractiveAllowed)return;const n=e.data?.attributes?.question,r=e.data?.attributes?.feedItem;if(!n||!r?.attributes)return;const{status:i,type:o,id:s,answers:a}=n;if(i===m.QuestionStatus.RESOLVED&&o===m.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(T=>T.id===s),l=d[c];let p=l?.attributes?.attributes?.value?.answerId;const v=lt(s,this.transport),E=v.subscribe(()=>{});await v.get().promise;let w=v.get().data;w||(w=await Ar(s,this.transport),v.mutate(w)),E(),window.requestAnimationFrame(()=>{v.invalidate()}),p||(p=w?.answers.find(({youVoted:T})=>T)?.id);const A=a.find(({correct:T})=>T),L=p?a.find(({id:T})=>T===p):void 0,S=!!L?.correct;if(l&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=p,d[c].attributes.attributes.value.openForVoting=!1,p&&(d[c].attributes.attributes.value.status=S?z.PickHistoryStatus.WON:z.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!L||!A)return;this.openedQuestionId.get()?.questionId!==n.id&&this.notifications.add({type:ge.QUESTION_RESOLVED,action:()=>this.openQuestion(n.id,r),close:()=>this.closeQuestion(s),autoHideDuration:S?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:m.QuestionType.PREDICTION,question:{title:S?`Congratulations! You answered correctly! You won ${A.points} pts!`:`Better luck next time! Correct: ${A?.text}!`,votedAnswer:{title:L?.text,points:L?.points},correctAnswerTitle:A?.text,correct:!!S,predictionResult:i===m.QuestionStatus.RESOLVED,questionTitle:n?.subject},inApp:{notification:n.notification,appearance:n.appearance,sponsorship:n.sponsorship,adUnit:n?.adUnit,sponsorLogo:n.promotion?.sponsor?.logo}}}),this.userSummary.invalidate()}})),Z.onStart(this.feedList.getStore(),()=>{this.cancels.add(this.feedList.subscribe(()=>{}))}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-questions-list",e=>{const n=[...this.feedList.getStore().value?.data||[]],r=e.data?.attributes?.feedItem,i=n.findIndex(o=>o.id===r?.id);if(r?.attributes&&r.attributes.attributes.case!=="promotion"&&!(r.attributes.status!==m.QuestionStatus.ACTIVE&&r.attributes.status!==m.QuestionStatus.RESOLVED)&&!(!this.isInteractiveAllowed&&xn.has(r.attributes.type)&&r?.attributes?.adUnit!==m.AdUnit.STANDART)){if(i!==-1)if(r.attributes.attributes.case==="question"&&n[i].attributes?.attributes.case==="question"){const o=n[i];o.attributes&&(n[i]={...n[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...r.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting===!1?!1:r.attributes.attributes.value.openForVoting}}}})}else{const o=n[i];o.attributes&&r.attributes&&(n[i]={...n[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...r.attributes.attributes.value}}}})}i===-1&&(n.unshift(r),M.emit("poll",{action:"received",payload:{isAd:r.attributes?.adUnit==m.AdUnit.UNSET,questionId:r.id,questionType:r.attributes?.type}})),this.feedList.getStore().mutate(n)}}))};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};betPackVote=async(e,n)=>{if(!this.betPack)return;try{await Un(this.transport,{questionId:e,answerId:n})}catch(o){if(o.message===xe.ALREADY_VOTED){const s=lt(e,this.transport),a=s.subscribe(()=>{});s.invalidate(),a()}throw o}const r={...this.betPack.getValues().data?.data},i=r?.[e];i&&(M.emit("poll",{action:"voted",payload:{questionId:e,isAd:i?.adUnit==m.AdUnit.UNSET,questionType:i.type}}),i.answers=i.answers.map(o=>o.id===n?{...o,youVoted:!0}:o),this.betPack.getStore().mutate({data:r,timestamp:Date.now()}))};submitAnswer=async(e,n)=>{const r=lt(e,this.transport),i=r.subscribe(()=>{}),o={...r.get().data||{}},s=()=>{const a=this.feedList.getValues().data;if(!a)return;const u=a.findIndex(l=>l.id===e),d=a[u],c=d?.attributes?.attributes.case==="question"&&d.attributes.attributes.value;if(c){M.emit("poll",{action:"voted",payload:{isAd:d.attributes?.adUnit==m.AdUnit.UNSET,questionId:e,questionType:c.questionType}});const l=r.get().data;if(i(),l){const p=l.answers.find(A=>A.correct===!0),v=l.answers.findIndex(A=>A.id===n),E=l.answers[v],w=l.answers.every(({percentageDecimal:A},L)=>A===o?.answers[L].percentageDecimal);a[u].attributes.attributes.value.answerId=n,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=E?.text||"",p&&(a[u].attributes.attributes.value.status=p.id===n?z.PickHistoryStatus.WON:z.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a]),l.answers[v].correct=p?.id===n,l.answers[v].youVoted=!0,w&&l.answers.forEach(A=>{A.percentageDecimal=0}),p?.id===n&&(l.answers[v].pointsEarned=l.status===m.QuestionStatus.RESOLVED?0:p.points),r.mutate({...l})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Un(this.transport,{questionId:e,answerId:n}),s()}catch(a){if(a.message===xe.ALREADY_VOTED){this.userSummary.invalidate();const u=r.subscribe(()=>{});r.invalidate(),u()}throw a}};openQuestion=(e,n)=>{if(console.log("openQuestion",e,n),!e)return()=>{};const r=n?.openedFrom==="bet-pack";this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let i=n?.attributes?.type,o=n?.attributes?.adUnit===m.AdUnit.STANDART&&!!n?.attributes?.adPromotion?.banner?.imageUrl;if(!i&&!r){const u=(this.feedList.getStore().value?.data||[]).find(d=>d.id===e)?.attributes;i=u?.type,o=u?.adUnit===m.AdUnit.STANDART&&!!u?.adPromotion?.banner?.imageUrl}const s={eventId:this.background.slStreamId.get()||"",userId:this.background.userId.get()||"",organizationId:this.background.organizationId.get()||""};return M.emit("poll",{action:"opened",payload:{questionId:e,questionType:i,isAd:n?.attributes?.adUnit==m.AdUnit.UNSET,questionOpenedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom,hasBanner:o}}),this.storage.isQuestionOpened(s,e)||(M.emit("poll",{action:"viewed",payload:{questionId:e,questionType:i,isAd:n?.attributes?.adUnit==m.AdUnit.UNSET,questionOpenedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom}}),this.storage.saveQuestionOpened(s,e)),r||this.openFeature(),this.background.openQuestion(e,n?{...n,openedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom}:void 0)};getFeedItem=e=>Wi(e,this.transport);isOpenedQuestion=e=>!!this.notifications.isViewed(e);closeQuestion=e=>(e&&(this.onQuestionActivate({stage:"deactivate",id:e,isViewed:!!this.notifications.isViewed(this.background.getCurrentSessionId({prefix:"notification",entity:e}))}),M.emit("poll",{action:"closed",payload:{questionId:e}})),this.background.closeQuestion(e));openUser=async e=>{if(!this.leaderboardList)return;const n=this.leaderboardList?.$store.get().data?.find(i=>i.userId===e);if(!n){this.openedUser?.set(n);return}if(n.summaryLoaded){this.openedUser?.set(n);return}const r={...n};try{const i=await Fo(this.background.slStreamId,this.background.userId,this.friends,e,this.transport);i?.inTop!==void 0&&(this.leaderboardList?.$store.setKey("data",this.leaderboardList.$store.get().data?.map(o=>(o.userId===e&&(o.inTop=i.inTop),o))),r.inTop=i.inTop)}catch(i){console.error(i)}this.openedUser.set(r)};closeUser=()=>{this.openedUser?.set(void 0)};openOnboarding=()=>{this.openFeature(),M.emit("poll",{action:"onboardingOpen",payload:{}})};showInApp=e=>{const n=this.onboardingStatus.$store.get(),r=e?.data?.question?.adUnit===m.AdUnit.STANDART;if(e&&e.data&&(r||n&&n!==q.Unset)&&e.data.question?.id!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==m.SilenceSetting.ON&&e.data.question.status===m.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(xn.has(e.data.question.type))(this.isInteractiveAllowed||r)&&e.data.question.notification!==void 0&&this.notifications.add({type:ge.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>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},inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship,adUnit:e.data.question?.adUnit,sponsorLogo:e.data.question.promotion?.sponsor?.logo}}});else if(e.data.question.type===m.QuestionType.FACTOID){const i=e.data.question.options?.options.value,o=e.data.question.notification?.useContentTexts===m.NotificationUseContentTexts.ENABLED?e.data.question.subject:e.data.question.notification?.title||"",s=e.data.question.notification?.useContentTexts===m.NotificationUseContentTexts.ENABLED?i.body:e.data.question.notification?.body,a={heading:o,body:s,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:ge.QUESTION,action:()=>this.openQuestion(e?.data?.question?.id,e?.data?.feedItem),close:()=>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:a,inApp:{useMediaFromContent:i?.useAsNotification===m.UseAsNotification.ENABLED,notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship,adUnit:e.data.question?.adUnit,sponsorLogo:e.data.question.promotion?.sponsor?.logo,isVideo:i?.mode===m.FactoidMediaMode.VIDEO}}})}else if(e.data.question.type===m.QuestionType.TWEET&&e.data.question.notification!==void 0){const i=e.data.question.options?.options.value,o={image:"",video:""};if(i.tweetMeta?.tweet?.meta?.extendedEntities?.media?.[0]){const a=i.tweetMeta.tweet.meta.extendedEntities.media;if(a){const u=a.find(({type:d})=>d==="photo")||a[0];o.image=u.mediaUrlHttps,u.type==="video"&&(o.video=u.url)}}const 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,tweetMedia:o};this.notifications.add({type:ge.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>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:s,inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}}}}const Ro={[B.SdkOverlayType.GAMES]:!0};class Vo extends wr{constructor(e,n){super(e,n)}}const Uo=(t,e,n)=>t.type===B.SdkOverlayType.GAMES?new Do(t,e,n):new Vo(t,e),Bo=(t,e,n)=>{t.features=new Map,t.sdk.featuresList=new X(x(new Set),"features-list"),t.activeFeature=new X(x(B.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=r=>t.features.get(r),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=r=>{t.sdk.initializeApp().then(()=>{t.activeFeature.setValue(r)})},t.sdk.closeFeature=(r=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(B.SdkOverlayType.UNSET),r&&i){t.features.delete(i);const o=t.sdk.featuresList.getValue();o&&o.delete(i),t.sdk.featuresList.setValue(o)}},t.initFeature=(r,i=pe.ORGANIZATION)=>{if(r.type in Ro&&!t.features.has(r.type)){const o=Uo(r,i,t);t.features.set(r.type,o);let s=t.sdk.featuresList.getValue();s?s.add(r.type):s=new Set([r.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(r,i)=>{t.features.get(r.type)?.update(r,i)},t.destroyFeature=r=>{t.features.delete(r.type);const i=t.sdk.featuresList.getValue();i&&i.delete(r.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const r=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of r?.overlays||[])t.initFeature(i,pe.ORGANIZATION)},t.stores.providerStreamId.listen(r=>{r||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const r=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===pe.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{r(pe.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{r(pe.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},n()};class Mo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="invitation")switch(r.slEventBus.action){case"sent":this.sent(r.slEventBus.payload);break}};return M.listen(n)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INVITATION_ACCEPTED},category:st.InvitationCategory.GAMES,from:st.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INVITATION_SENT},category:st.InvitationCategory.GAMES,from:e||st.InvitationFrom.UNSET})}}class $o{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="interactions")switch(r.slEventBus.action){case"tap":this.tap();break;case"scroll":this.scroll();break}};return M.listen(n)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INTERACTIONS},actionType:Fn.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.INTERACTIONS},actionType:Fn.InteractionActionType.SCROLL})}}const qo={[m.PromotionType.UNSET]:h.TopicSubType.UNSET,[m.PromotionType.INGAME_IAB21]:h.TopicSubType.PROMOTION_INGAME_IAB21,[m.PromotionType.INGAME_IAB21_SIDEBAR]:h.TopicSubType.PROMOTION_INGAME_IAB21,[m.PromotionType.INGAME_IAB11_LBAR]:h.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[m.PromotionType.INGAME_IAB11]:h.TopicSubType.PROMOTION_INGAME_IAB11,[m.PromotionType.INGAME_IAB11_SIDEBAR]:h.TopicSubType.PROMOTION_INGAME_IAB11,[m.PromotionType.INGAME_IAB21_LBAR]:h.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[m.PromotionType.INGAME_IAB61]:h.TopicSubType.PROMOTION_INGAME_IAB61,[m.PromotionType.INGAME_IAB61_SIDEBAR]:h.TopicSubType.PROMOTION_INGAME_IAB61,[m.PromotionType.EXTERNAL_AD]:h.TopicSubType.PROMOTION_GAM,[m.PromotionType.VIDEO_SIDE_BY_SIDE]:h.TopicSubType.PROMOTION_VIDEO_SIDE_BY_SIDE,[m.PromotionType.PICTURE_IN_PICTURE]:h.TopicSubType.PROMOTION_PICTURE_IN_PICTURE,[m.PromotionType.LOWER_THIRD]:h.TopicSubType.PROMOTION_LOWER_THIRD,[m.PromotionType.SHOP_LBAR]:h.TopicSubType.PROMOTION_SHOP_LBAR,[m.PromotionType.SHOP_OVERLAY]:h.TopicSubType.PROMOTION_SHOP_OVERLAY,[m.PromotionType.SHOP_SIDEBAR]:h.TopicSubType.PROMOTION_SHOP_SIDEBAR,[m.PromotionType.NFL_SHOP_LBAR]:h.TopicSubType.PROMOTION_SHOP_LBAR,[m.PromotionType.NFL_SHOP_OVERLAY]:h.TopicSubType.PROMOTION_SHOP_OVERLAY,[m.PromotionType.NFL_SHOP_SIDEBAR]:h.TopicSubType.PROMOTION_SHOP_SIDEBAR,[m.PromotionType.STATS]:h.TopicSubType.UNSET,[m.PromotionType.STANDARD]:h.TopicSubType.UNSET,[m.PromotionType.SHOP]:h.TopicSubType.UNSET,[m.PromotionType.NFL_SHOP]:h.TopicSubType.UNSET},rn=t=>t?qo[t]:h.TopicSubType.UNSET,Qo={25:h.Kind.AD_VIDEO_Q25,50:h.Kind.AD_VIDEO_Q50,75:h.Kind.AD_VIDEO_Q75};class jo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(!r.slEventBus?.skipAnalytics&&r.slEventBus?.type==="advertisement"){const i=rn(r.slEventBus.payload.type);switch(r.slEventBus.action){case"videoPlay":this.videoPlay(r.slEventBus.payload,{topicSubType:i});break;case"videoEnd":this.videoEnd(r.slEventBus.payload,{topicSubType:i});break;case"videoRendered":this.videoRendered(r.slEventBus.payload,{topicSubType:i});break;case"buttonSelect":this.buttonSelect(r.slEventBus.payload,{topicSubType:i});break;case"bannerSelect":this.bannerSelect(r.slEventBus.payload,{topicSubType:i});break;case"bannerShown":this.bannerShown(r.slEventBus.payload,{topicSubType:i});break;case"received":this.received(r.slEventBus.payload,{topicSubType:i});break;case"opened":this.opened(r.slEventBus.payload,{topicSubType:i});break;case"viewed":this.viewed(r.slEventBus.payload,{topicSubType:i});break;case"videoMuted":case"videoUnmuted":this.videoMuted(r.slEventBus.payload,{topicSubType:i,muted:r.slEventBus.action==="videoMuted"});break;case"videoReplayed":this.videoReplayed(r.slEventBus.payload,{topicSubType:i});break;case"quartileCompleted":this.quartileCompleted(r.slEventBus.payload,{topicSubType:i});break}}};return M.listen(n)})}received=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_RECEIVED,topicId:e,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:n},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_OPENED,topicId:e,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:n==="notification"?h.PollOpenedFrom.IN_APP:h.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:n})=>{};videoMuted=({id:e},{topicSubType:n,muted:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:r?h.Kind.AD_VIDEO_MUTED:h.Kind.AD_VIDEO_UNMUTED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};quartileCompleted=({id:e,quartile:n},{topicSubType:r})=>{n&&this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:Qo[n],topicType:h.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoReplayed=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_REPLAYED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_PLAYED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoEnd=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_COMPLETE,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};videoRendered=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_VIDEO_RENDERED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_INTERACTION_BUTTON_NAVIGATED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_INTERACTION_BANNER_NAVIGATED,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})};bannerShown=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:h.Kind.AD_BANNER_SHOWN,topicType:h.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:h.PollOpenedFrom.UNSET})}}const Xe={[m.QuestionType.UNSET]:h.TopicType.UNSET,[m.QuestionType.FACTOID]:h.TopicType.POLLS_INSIGHT,[m.QuestionType.POLL]:h.TopicType.POLLS_POLL,[m.QuestionType.PREDICTION]:h.TopicType.POLLS_PREDICTION,[m.QuestionType.PROMOTION]:h.TopicType.POLLS_PROMOTION,[m.QuestionType.TRIVIA]:h.TopicType.POLLS_TRIVIA,[m.QuestionType.TWEET]:h.TopicType.POLLS_TWITTER};m.QuestionType.UNSET+"",te.NotificationKind.UNSET,m.QuestionType.FACTOID+"",te.NotificationKind.POLLS,m.QuestionType.POLL+"",te.NotificationKind.POLLS,m.QuestionType.PREDICTION+"",te.NotificationKind.POLLS,m.QuestionType.PROMOTION+"",te.NotificationKind.POLLS,m.QuestionType.TRIVIA+"",te.NotificationKind.POLLS,m.QuestionType.TWEET+"",te.NotificationKind.POLLS;const xo={[B.SdkOverlayType.UNSET]:h.Category.UNSET,[B.SdkOverlayType.INPLAY]:h.Category.INPLAY,[B.SdkOverlayType.MESSAGING]:h.Category.MESSAGING,[B.SdkOverlayType.STATISTICS]:h.Category.STATS,[B.SdkOverlayType.BETTING]:h.Category.BETTING,[B.SdkOverlayType.TWITTER]:h.Category.TWITTER,[B.SdkOverlayType.MERCHANDISE]:h.Category.MERCHANDISE,[B.SdkOverlayType.CONTESTS]:h.Category.CONTESTS,[B.SdkOverlayType.VOICE_CHAT]:h.Category.CALLING,[B.SdkOverlayType.TICKETS]:h.Category.TICKETS,[B.SdkOverlayType.WHOIS_WATCHING]:h.Category.WHOISWATCHING,[B.SdkOverlayType.PROFILE]:h.Category.PROFILE,[B.SdkOverlayType.GAMES]:h.Category.POLLS,[B.SdkOverlayType.GOLF_STATISTICS]:h.Category.STATS,[B.SdkOverlayType.HIGHLIGHTS]:h.Category.HIGHLIGHTS,[B.SdkOverlayType.PUBLIC_CHAT]:h.Category.PUBLIC_CHAT};class Go{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="notification")switch(r.slEventBus.action){case"rendered":this.received(r.slEventBus.payload);break;case"opened":this.opened(r.slEventBus.payload);break}if(r.slEventBus?.type==="advertisement")switch(r.slEventBus.action){case"notification-received":this.received({questionId:r.slEventBus.payload.id,questionType:m.QuestionType.PROMOTION,topicSubType:rn(r.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:r.slEventBus.payload.id,questionType:m.QuestionType.PROMOTION,topicSubType:rn(r.slEventBus.payload.type)});break}};return M.listen(n)})}received=({questionId:e,questionType:n,topicSubType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET,topicSubType:r},notificationKind:te.NotificationKind.POLLS,notificationType:te.NotificationType.IN_APP})};opened=({questionId:e,questionType:n,topicSubType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.NOTIFICATION_OPENED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET,topicSubType:r},notificationKind:te.NotificationKind.POLLS,notificationType:te.NotificationType.IN_APP})}}class Ko{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="poll")switch(r.slEventBus.action){case"voted":this.voted(r.slEventBus.payload);break;case"navigated":this.navigated();break;case"onboardingPassed":this.onboardingPassed();break;case"received":this.received(r.slEventBus.payload);break;case"viewed":this.viewed(r.slEventBus.payload);break}};return M.listen(n)})}received=({questionId:e,questionType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_RECEIVED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET},pollOpenedFrom:h.PollOpenedFrom.UNSET})};viewed=({questionId:e,questionType:n,questionOpenedFrom:r,isAd:i})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:i?h.Kind.POLLS_AD_OPENED:h.Kind.POLLS_OPENED,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET},pollOpenedFrom:r==="list"?h.PollOpenedFrom.PICK_HISTORY:h.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:n,isAd:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:r?h.Kind.POLLS_AD_VOTE:h.Kind.POLLS_VOTE,topicId:e,topicType:n?Xe[n]:h.TopicType.UNSET},pollOpenedFrom:h.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.GAMES_JOINED},pollOpenedFrom:h.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:h.Kind.POLLS_NAVIGATED},pollOpenedFrom:h.PollOpenedFrom.UNSET})}}const Ho=({transport:t,$commonStore:e})=>{let n;const r=x(!1),i=3e4,{client:o,queryKey:s}=t.createPromiseClient(mr.AnalyticsService,{method:"send",params:[r]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const p=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...p,kind:h.Kind.SESSION_HEARTBEAT}}}})}catch(v){ye.error(v,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{ye.debug("mounted heartbeat"),n=a.subscribe(()=>{})},d=()=>{ye.debug("enabled heartbeat"),r.set(!0),a.lc===0&&u()},c=()=>{ye.debug("disabled heartbeat"),r.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{ye.debug("unmounted heartbeat"),a.off(),n?.(),n=void 0,c()}}},ye=ce("analytics");class zo{commonStore;notifications;polls;invitation;interactions;advertisement;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Oe(Y({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=Ho({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new Go(this),this.polls=new Ko(this),this.invitation=new Mo(this),this.interactions=new $o(this),this.advertisement=new jo(this);const{client:n}=e.analyticsTransport.createPromiseClient(mr.AnalyticsService,{method:"send"});this.analyticsClient=n}connect=()=>{this.writeCommon("sessionId",bt.v4()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,ye.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,ye.debug("analytics disconnected")};write=(e,n)=>{n&&this.analyticsClient.unary({message:{case:e,value:n}}).then(()=>{ye.trace("send analytics success",e,n)}).catch(r=>{ye.error(r,"send analytics failed")})};writeCommon=(e,n)=>{this.commonStore.setValue(e,n)};onConnect=e=>{this.listeners.add(e),this.connected&&this.listenersCancels.add(e())};connectToSDK=e=>{this.onConnect(()=>e.stores.slStreamId.getAtomStore().subscribe(n=>{this.writeCommon("eventId",n)})),this.onConnect(()=>e.sdk.getActiveFeature().subscribe(n=>{n&&this.writeCommon("category",xo[n]),n!==B.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",bt.v4()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const n=window.matchMedia("(orientation: portrait)"),r=i=>{this.writeCommon("screenOrientation",i.matches?h.ScreenOrientation.PORTRAIT:h.ScreenOrientation.LANDSCAPE)};return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)}}),this.onConnect(()=>e.deepLink.$store.subscribe(n=>{n?.handled&&this.invitation.accepted()}))}}const Wo=(t,e,n)=>{t.analytics=new zo(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),t.sdk.writeOverlaySessionId=r=>{r===""?t.analytics.writeCommon("overlaySessionId",""):t.analytics.writeCommon("overlaySessionId",bt.v4())},()=>{t.analytics.disconnect()})),n()};var mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var gn={exports:{}},bn={exports:{}};function Jo(t){var e=new t,n=e;function r(){var o=e;return o.next?e=o.next:(e=new t,n=e),o.next=null,o}function i(o){n.next=o,n=o}return{get:r,release:i}}var Xo=Jo,Zo=Xo;function kr(t,e,n){if(typeof t=="function"&&(n=e,e=t,t=null),!(n>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var r=Zo(es),i=null,o=null,s=0,a=null,u={push:w,drain:J,saturated:J,pause:c,paused:!1,get concurrency(){return n},set concurrency(O){if(!(O>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(n=O,!u.paused)for(;i&&s<n;)s++,L()},running:d,resume:v,idle:E,length:l,getQueue:p,unshift:A,empty:J,kill:S,killAndDrain:T,error:P};return u;function d(){return s}function c(){u.paused=!0}function l(){for(var O=i,$=0;O;)O=O.next,$++;return $}function p(){for(var O=i,$=[];O;)$.push(O.value),O=O.next;return $}function v(){if(u.paused){if(u.paused=!1,i===null){s++,L();return}for(;i&&s<n;)s++,L()}}function E(){return s===0&&u.length()===0}function w(O,$){var N=r.get();N.context=t,N.release=L,N.value=O,N.callback=$||J,N.errorHandler=a,s>=n||u.paused?o?(o.next=N,o=N):(i=N,o=N,u.saturated()):(s++,e.call(t,N.value,N.worked))}function A(O,$){var N=r.get();N.context=t,N.release=L,N.value=O,N.callback=$||J,N.errorHandler=a,s>=n||u.paused?i?(N.next=i,i=N):(i=N,o=N,u.saturated()):(s++,e.call(t,N.value,N.worked))}function L(O){O&&r.release(O);var $=i;$&&s<=n?u.paused?s--:(o===i&&(o=null),i=$.next,$.next=null,e.call(t,$.value,$.worked),o===null&&u.empty()):--s===0&&u.drain()}function S(){i=null,o=null,u.drain=J}function T(){i=null,o=null,u.drain(),u.drain=J}function P(O){a=O}}function J(){}function es(){this.value=null,this.callback=J,this.next=null,this.release=J,this.context=null,this.errorHandler=null;var t=this;this.worked=function(n,r){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=J,t.errorHandler&&o(n,s),i.call(t.context,n,r),t.release(t)}}function ts(t,e,n){typeof t=="function"&&(n=e,e=t,t=null);function r(c,l){e.call(this,c).then(function(p){l(null,p)},l)}var i=kr(t,r,n),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var l=new Promise(function(p,v){o(c,function(E,w){if(E){v(E);return}p(w)})});return l.catch(J),l}function u(c){var l=new Promise(function(p,v){s(c,function(E,w){if(E){v(E);return}p(w)})});return l.catch(J),l}function d(){if(i.idle())return new Promise(function(p){p()});var c=i.drain,l=new Promise(function(p){i.drain=function(){c(),p()}});return l}}bn.exports=kr;bn.exports.promise=ts;var Cr=bn.exports,vn={exports:{}},Qe=typeof Reflect=="object"?Reflect:null,Gn=Qe&&typeof Qe.apply=="function"?Qe.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},ft;Qe&&typeof Qe.ownKeys=="function"?ft=Qe.ownKeys:Object.getOwnPropertySymbols?ft=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ft=function(e){return Object.getOwnPropertyNames(e)};function ns(t){console&&console.warn&&console.warn(t)}var Nr=Number.isNaN||function(e){return e!==e};function V(){V.init.call(this)}vn.exports=V;vn.exports.once=ss;V.EventEmitter=V;V.prototype._events=void 0;V.prototype._eventsCount=0;V.prototype._maxListeners=void 0;var Kn=10;function kt(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(V,"defaultMaxListeners",{enumerable:!0,get:function(){return Kn},set:function(t){if(typeof t!="number"||t<0||Nr(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Kn=t}});V.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};V.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Nr(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 Lr(t){return t._maxListeners===void 0?V.defaultMaxListeners:t._maxListeners}V.prototype.getMaxListeners=function(){return Lr(this)};V.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);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(n.length>0&&(s=n[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")Gn(u,this,n);else for(var d=u.length,c=Ur(u,d),r=0;r<d;++r)Gn(c[r],this,n);return!0};function Fr(t,e,n,r){var i,o,s;if(kt(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]),s===void 0)s=o[e]=n,++t._eventsCount;else if(typeof s=="function"?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=Lr(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,ns(a)}return t}V.prototype.addListener=function(e,n){return Fr(this,e,n,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(e,n){return Fr(this,e,n,!0)};function rs(){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 Dr(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=rs.bind(r);return i.listener=n,r.wrapFn=i,i}V.prototype.once=function(e,n){return kt(n),this.on(e,Dr(this,e,n)),this};V.prototype.prependOnceListener=function(e,n){return kt(n),this.prependListener(e,Dr(this,e,n)),this};V.prototype.removeListener=function(e,n){var r,i,o,s,a;if(kt(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){a=r[s].listener,o=s;break}if(o<0)return this;o===0?r.shift():is(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||n)}return this};V.prototype.off=V.prototype.removeListener;V.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),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(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function Rr(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?os(i):Ur(i,i.length)}V.prototype.listeners=function(e){return Rr(this,e,!0)};V.prototype.rawListeners=function(e){return Rr(this,e,!1)};V.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Vr.call(t,e)};V.prototype.listenerCount=Vr;function Vr(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}V.prototype.eventNames=function(){return this._eventsCount>0?ft(this._events):[]};function Ur(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function is(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function os(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function ss(t,e){return new Promise(function(n,r){function i(s){t.removeListener(e,o),r(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}Br(t,e,o,{once:!0}),e!=="error"&&as(t,i,{once:!0})})}function as(t,e,n){typeof t.on=="function"&&Br(t,"error",e,n)}function Br(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Mr=vn.exports,Ct={},$r={},qr=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[n]=i;for(n 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]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,n);if(s.value!==i||s.enumerable!==!0)return!1}return!0},us=qr,Nt=function(){return us()&&!!Symbol.toStringTag},cs=Error,ds=EvalError,ls=RangeError,fs=ReferenceError,Qr=SyntaxError,Lt=TypeError,ps=URIError,Hn=typeof Symbol<"u"&&Symbol,hs=qr,ys=function(){return typeof Hn!="function"||typeof Symbol!="function"||typeof Hn("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:hs()},Ut={__proto__:null,foo:{}},ms=Object,gs=function(){return{__proto__:Ut}.foo===Ut.foo&&!(Ut instanceof ms)},bs="Function.prototype.bind called on incompatible ",vs=Object.prototype.toString,Ss=Math.max,ws="[object Function]",zn=function(e,n){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var o=0;o<n.length;o+=1)r[o+e.length]=n[o];return r},Ts=function(e,n){for(var r=[],i=n,o=0;i<e.length;i+=1,o+=1)r[o]=e[i];return r},Es=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},As=function(e){var n=this;if(typeof n!="function"||vs.apply(n)!==ws)throw new TypeError(bs+n);for(var r=Ts(arguments,1),i,o=function(){if(this instanceof i){var c=n.apply(this,zn(r,arguments));return Object(c)===c?c:this}return n.apply(e,zn(r,arguments))},s=Ss(0,n.length-r.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+Es(a,",")+"){ return binder.apply(this,arguments); }")(o),n.prototype){var d=function(){};d.prototype=n.prototype,i.prototype=new d,d.prototype=null}return i},Os=As,Sn=Function.prototype.bind||Os,Is=Function.prototype.call,_s=Object.prototype.hasOwnProperty,Ps=Sn,ks=Ps.call(Is,_s),C,Cs=cs,Ns=ds,Ls=ls,Fs=fs,Ge=Qr,je=Lt,Ds=ps,jr=Function,Bt=function(t){try{return jr('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var Mt=function(){throw new je},Rs=Ie?function(){try{return arguments.callee,Mt}catch{try{return Ie(arguments,"callee").get}catch{return Mt}}}():Mt,Re=ys(),Vs=gs(),G=Object.getPrototypeOf||(Vs?function(t){return t.__proto__}:null),Ue={},Us=typeof Uint8Array>"u"||!G?C:G(Uint8Array),_e={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?C:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?C:ArrayBuffer,"%ArrayIteratorPrototype%":Re&&G?G([][Symbol.iterator]()):C,"%AsyncFromSyncIteratorPrototype%":C,"%AsyncFunction%":Ue,"%AsyncGenerator%":Ue,"%AsyncGeneratorFunction%":Ue,"%AsyncIteratorPrototype%":Ue,"%Atomics%":typeof Atomics>"u"?C:Atomics,"%BigInt%":typeof BigInt>"u"?C:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?C:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?C:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?C:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Cs,"%eval%":eval,"%EvalError%":Ns,"%Float32Array%":typeof Float32Array>"u"?C:Float32Array,"%Float64Array%":typeof Float64Array>"u"?C:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?C:FinalizationRegistry,"%Function%":jr,"%GeneratorFunction%":Ue,"%Int8Array%":typeof Int8Array>"u"?C:Int8Array,"%Int16Array%":typeof Int16Array>"u"?C:Int16Array,"%Int32Array%":typeof Int32Array>"u"?C:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Re&&G?G(G([][Symbol.iterator]())):C,"%JSON%":typeof JSON=="object"?JSON:C,"%Map%":typeof Map>"u"?C:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Re||!G?C:G(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?C:Promise,"%Proxy%":typeof Proxy>"u"?C:Proxy,"%RangeError%":Ls,"%ReferenceError%":Fs,"%Reflect%":typeof Reflect>"u"?C:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?C:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Re||!G?C:G(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?C:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Re&&G?G(""[Symbol.iterator]()):C,"%Symbol%":Re?Symbol:C,"%SyntaxError%":Ge,"%ThrowTypeError%":Rs,"%TypedArray%":Us,"%TypeError%":je,"%Uint8Array%":typeof Uint8Array>"u"?C:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?C:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?C:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?C:Uint32Array,"%URIError%":Ds,"%WeakMap%":typeof WeakMap>"u"?C:WeakMap,"%WeakRef%":typeof WeakRef>"u"?C:WeakRef,"%WeakSet%":typeof WeakSet>"u"?C:WeakSet};if(G)try{null.error}catch(t){var Bs=G(G(t));_e["%Error.prototype%"]=Bs}var Ms=function t(e){var n;if(e==="%AsyncFunction%")n=Bt("async function () {}");else if(e==="%GeneratorFunction%")n=Bt("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=Bt("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&G&&(n=G(i.prototype))}return _e[e]=n,n},Wn={__proto__:null,"%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"]},tt=Sn,St=ks,$s=tt.call(Function.call,Array.prototype.concat),qs=tt.call(Function.apply,Array.prototype.splice),Yn=tt.call(Function.call,String.prototype.replace),wt=tt.call(Function.call,String.prototype.slice),Qs=tt.call(Function.call,RegExp.prototype.exec),js=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,xs=/\\(\\)?/g,Gs=function(e){var n=wt(e,0,1),r=wt(e,-1);if(n==="%"&&r!=="%")throw new Ge("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Ge("invalid intrinsic syntax, expected opening `%`");var i=[];return Yn(e,js,function(o,s,a,u){i[i.length]=a?Yn(u,xs,"$1"):s||o}),i},Ks=function(e,n){var r=e,i;if(St(Wn,r)&&(i=Wn[r],r="%"+i[0]+"%"),St(_e,r)){var o=_e[r];if(o===Ue&&(o=Ms(r)),typeof o>"u"&&!n)throw new je("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:o}}throw new Ge("intrinsic "+e+" does not exist!")},nt=function(e,n){if(typeof e!="string"||e.length===0)throw new je("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new je('"allowMissing" argument must be a boolean');if(Qs(/^%?[^%]*%?$/,e)===null)throw new Ge("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Gs(e),i=r.length>0?r[0]:"",o=Ks("%"+i+"%",n),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],qs(r,$s([0,1],d)));for(var c=1,l=!0;c<r.length;c+=1){var p=r[c],v=wt(p,0,1),E=wt(p,-1);if((v==='"'||v==="'"||v==="`"||E==='"'||E==="'"||E==="`")&&v!==E)throw new Ge("property names with quotes must have matching quotes");if((p==="constructor"||!l)&&(u=!0),i+="."+p,s="%"+i+"%",St(_e,s))a=_e[s];else if(a!=null){if(!(p in a)){if(!n)throw new je("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=r.length){var w=Ie(a,p);l=!!w,l&&"get"in w&&!("originalValue"in w.get)?a=w.get:a=a[p]}else l=St(a,p),a=a[p];l&&!u&&(_e[s]=a)}}return a},xr={exports:{}},$t,Jn;function wn(){if(Jn)return $t;Jn=1;var t=nt,e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return $t=e,$t}var Hs=nt,pt=Hs("%Object.getOwnPropertyDescriptor%",!0);if(pt)try{pt([],"length")}catch{pt=null}var Ft=pt,Xn=wn(),zs=Qr,Ve=Lt,Zn=Ft,Ws=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new Ve("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new Ve("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ve("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ve("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ve("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ve("`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=!!Zn&&Zn(e,n);if(Xn)Xn(e,n,{configurable:s===null&&u?u.configurable:!s,enumerable:i===null&&u?u.enumerable:!i,value:r,writable:o===null&&u?u.writable:!o});else if(a||!i&&!o&&!s)e[n]=r;else throw new zs("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},on=wn(),Gr=function(){return!!on};Gr.hasArrayLengthDefineBug=function(){if(!on)return null;try{return on([],"length",{value:1}).length!==1}catch{return!0}};var Ys=Gr,Js=nt,er=Ws,Xs=Ys(),tr=Ft,nr=Lt,Zs=Js("%Math.floor%"),ea=function(e,n){if(typeof e!="function")throw new nr("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||Zs(n)!==n)throw new nr("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&tr){var s=tr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!r)&&(Xs?er(e,"length",n,!0,!0):er(e,"length",n)),e};(function(t){var e=Sn,n=nt,r=ea,i=Lt,o=n("%Function.prototype.apply%"),s=n("%Function.prototype.call%"),a=n("%Reflect.apply%",!0)||e.call(s,o),u=wn(),d=n("%Math.max%");t.exports=function(p){if(typeof p!="function")throw new i("a function is required");var v=a(e,s,arguments);return r(v,1+d(0,p.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(xr);var Tn=xr.exports,Kr=nt,Hr=Tn,ta=Hr(Kr("String.prototype.indexOf")),En=function(e,n){var r=Kr(e,!!n);return typeof r=="function"&&ta(e,".prototype.")>-1?Hr(r):r},na=Nt(),ra=En,sn=ra("Object.prototype.toString"),Dt=function(e){return na&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:sn(e)==="[object Arguments]"},zr=function(e){return Dt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&sn(e)!=="[object Array]"&&sn(e.callee)==="[object Function]"},ia=function(){return Dt(arguments)}();Dt.isLegacyArguments=zr;var oa=ia?Dt:zr,sa=Object.prototype.toString,aa=Function.prototype.toString,ua=/^\s*(?:function)?\*/,Wr=Nt(),qt=Object.getPrototypeOf,ca=function(){if(!Wr)return!1;try{return Function("return function*() {}")()}catch{}},Qt,da=function(e){if(typeof e!="function")return!1;if(ua.test(aa.call(e)))return!0;if(!Wr){var n=sa.call(e);return n==="[object GeneratorFunction]"}if(!qt)return!1;if(typeof Qt>"u"){var r=ca();Qt=r?qt(r):!1}return qt(e)===Qt},Yr=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,an,ht;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{an=Object.defineProperty({},"length",{get:function(){throw ht}}),ht={},$e(function(){throw 42},null,an)}catch(t){t!==ht&&($e=null)}else $e=null;var la=/^\s*class\b/,un=function(e){try{var n=Yr.call(e);return la.test(n)}catch{return!1}},jt=function(e){try{return un(e)?!1:(Yr.call(e),!0)}catch{return!1}},yt=Object.prototype.toString,fa="[object Object]",pa="[object Function]",ha="[object GeneratorFunction]",ya="[object HTMLAllCollection]",ma="[object HTML document.all class]",ga="[object HTMLCollection]",ba=typeof Symbol=="function"&&!!Symbol.toStringTag,va=!(0 in[,]),cn=function(){return!1};if(typeof document=="object"){var Sa=document.all;yt.call(Sa)===yt.call(document.all)&&(cn=function(e){if((va||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=yt.call(e);return(n===ya||n===ma||n===ga||n===fa)&&e("")==null}catch{}return!1})}var wa=$e?function(e){if(cn(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,an)}catch(n){if(n!==ht)return!1}return!un(e)&&jt(e)}:function(e){if(cn(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(ba)return jt(e);if(un(e))return!1;var n=yt.call(e);return n!==pa&&n!==ha&&!/^\[object HTML/.test(n)?!1:jt(e)},Ta=wa,Ea=Object.prototype.toString,Jr=Object.prototype.hasOwnProperty,Aa=function(e,n,r){for(var i=0,o=e.length;i<o;i++)Jr.call(e,i)&&(r==null?n(e[i],i,e):n.call(r,e[i],i,e))},Oa=function(e,n,r){for(var i=0,o=e.length;i<o;i++)r==null?n(e.charAt(i),i,e):n.call(r,e.charAt(i),i,e)},Ia=function(e,n,r){for(var i in e)Jr.call(e,i)&&(r==null?n(e[i],i,e):n.call(r,e[i],i,e))},_a=function(e,n,r){if(!Ta(n))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=r),Ea.call(e)==="[object Array]"?Aa(e,n,i):typeof e=="string"?Oa(e,n,i):Ia(e,n,i)},Xr=_a,Pa=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],xt=Pa,ka=typeof globalThis>"u"?mn:globalThis,Zr=function(){for(var e=[],n=0;n<xt.length;n++)typeof ka[xt[n]]=="function"&&(e[e.length]=xt[n]);return e},Tt=Xr,Ca=Zr,rr=Tn,An=En,mt=Ft,Na=An("Object.prototype.toString"),ei=Nt(),ir=typeof globalThis>"u"?mn:globalThis,dn=Ca(),On=An("String.prototype.slice"),Gt=Object.getPrototypeOf,La=An("Array.prototype.indexOf",!0)||function(e,n){for(var r=0;r<e.length;r+=1)if(e[r]===n)return r;return-1},Et={__proto__:null};ei&&mt&&Gt?Tt(dn,function(t){var e=new ir[t];if(Symbol.toStringTag in e){var n=Gt(e),r=mt(n,Symbol.toStringTag);if(!r){var i=Gt(n);r=mt(i,Symbol.toStringTag)}Et["$"+t]=rr(r.get)}}):Tt(dn,function(t){var e=new ir[t],n=e.slice||e.set;n&&(Et["$"+t]=rr(n))});var Fa=function(e){var n=!1;return Tt(Et,function(r,i){if(!n)try{"$"+r(e)===i&&(n=On(i,1))}catch{}}),n},Da=function(e){var n=!1;return Tt(Et,function(r,i){if(!n)try{r(e),n=On(i,1)}catch{}}),n},Ra=function(e){if(!e||typeof e!="object")return!1;if(!ei){var n=On(Na(e),8,-1);return La(dn,n)>-1?n:n!=="Object"?!1:Da(e)}return mt?Fa(e):null},At=Xr,Va=Zr,or=Tn,In=En,gt=Ft,Ua=In("Object.prototype.toString"),ti=Nt(),sr=typeof globalThis>"u"?mn:globalThis,ln=Va(),_n=In("String.prototype.slice"),Kt=Object.getPrototypeOf,Ba=In("Array.prototype.indexOf",!0)||function(e,n){for(var r=0;r<e.length;r+=1)if(e[r]===n)return r;return-1},Ot={__proto__:null};ti&>&&Kt?At(ln,function(t){var e=new sr[t];if(Symbol.toStringTag in e){var n=Kt(e),r=gt(n,Symbol.toStringTag);if(!r){var i=Kt(n);r=gt(i,Symbol.toStringTag)}Ot["$"+t]=or(r.get)}}):At(ln,function(t){var e=new sr[t],n=e.slice||e.set;n&&(Ot["$"+t]=or(n))});var Ma=function(e){var n=!1;return At(Ot,function(r,i){if(!n)try{"$"+r(e)===i&&(n=_n(i,1))}catch{}}),n},$a=function(e){var n=!1;return At(Ot,function(r,i){if(!n)try{r(e),n=_n(i,1)}catch{}}),n},qa=function(e){if(!e||typeof e!="object")return!1;if(!ti){var n=_n(Ua(e),8,-1);return Ba(ln,n)>-1?n:n!=="Object"?!1:$a(e)}return gt?Ma(e):null},Qa=qa,ja=function(e){return!!Qa(e)};(function(t){var e=oa,n=da,r=Ra,i=ja;function o(g){return g.call.bind(g)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),d=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),l=o(Boolean.prototype.valueOf);if(s)var p=o(BigInt.prototype.valueOf);if(a)var v=o(Symbol.prototype.valueOf);function E(g,ui){if(typeof g!="object")return!1;try{return ui(g),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=i;function w(g){return typeof Promise<"u"&&g instanceof Promise||g!==null&&typeof g=="object"&&typeof g.then=="function"&&typeof g.catch=="function"}t.isPromise=w;function A(g){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(g):i(g)||y(g)}t.isArrayBufferView=A;function L(g){return r(g)==="Uint8Array"}t.isUint8Array=L;function S(g){return r(g)==="Uint8ClampedArray"}t.isUint8ClampedArray=S;function T(g){return r(g)==="Uint16Array"}t.isUint16Array=T;function P(g){return r(g)==="Uint32Array"}t.isUint32Array=P;function O(g){return r(g)==="Int8Array"}t.isInt8Array=O;function $(g){return r(g)==="Int16Array"}t.isInt16Array=$;function N(g){return r(g)==="Int32Array"}t.isInt32Array=N;function re(g){return r(g)==="Float32Array"}t.isFloat32Array=re;function ie(g){return r(g)==="Float64Array"}t.isFloat64Array=ie;function Pe(g){return r(g)==="BigInt64Array"}t.isBigInt64Array=Pe;function we(g){return r(g)==="BigUint64Array"}t.isBigUint64Array=we;function de(g){return u(g)==="[object Map]"}de.working=typeof Map<"u"&&de(new Map);function Rt(g){return typeof Map>"u"?!1:de.working?de(g):g instanceof Map}t.isMap=Rt;function ve(g){return u(g)==="[object Set]"}ve.working=typeof Set<"u"&&ve(new Set);function We(g){return typeof Set>"u"?!1:ve.working?ve(g):g instanceof Set}t.isSet=We;function ke(g){return u(g)==="[object WeakMap]"}ke.working=typeof WeakMap<"u"&&ke(new WeakMap);function Vt(g){return typeof WeakMap>"u"?!1:ke.working?ke(g):g instanceof WeakMap}t.isWeakMap=Vt;function Ce(g){return u(g)==="[object WeakSet]"}Ce.working=typeof WeakSet<"u"&&Ce(new WeakSet);function le(g){return Ce(g)}t.isWeakSet=le;function Ne(g){return u(g)==="[object ArrayBuffer]"}Ne.working=typeof ArrayBuffer<"u"&&Ne(new ArrayBuffer);function rt(g){return typeof ArrayBuffer>"u"?!1:Ne.working?Ne(g):g instanceof ArrayBuffer}t.isArrayBuffer=rt;function f(g){return u(g)==="[object DataView]"}f.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&f(new DataView(new ArrayBuffer(1),0,1));function y(g){return typeof DataView>"u"?!1:f.working?f(g):g instanceof DataView}t.isDataView=y;var b=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function I(g){return u(g)==="[object SharedArrayBuffer]"}function D(g){return typeof b>"u"?!1:(typeof I.working>"u"&&(I.working=I(new b)),I.working?I(g):g instanceof b)}t.isSharedArrayBuffer=D;function R(g){return u(g)==="[object AsyncFunction]"}t.isAsyncFunction=R;function k(g){return u(g)==="[object Map Iterator]"}t.isMapIterator=k;function F(g){return u(g)==="[object Set Iterator]"}t.isSetIterator=F;function U(g){return u(g)==="[object Generator]"}t.isGeneratorObject=U;function W(g){return u(g)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=W;function Te(g){return E(g,d)}t.isNumberObject=Te;function it(g){return E(g,c)}t.isStringObject=it;function Le(g){return E(g,l)}t.isBooleanObject=Le;function ot(g){return s&&E(g,p)}t.isBigIntObject=ot;function Cn(g){return a&&E(g,v)}t.isSymbolObject=Cn;function si(g){return Te(g)||it(g)||Le(g)||ot(g)||Cn(g)}t.isBoxedPrimitive=si;function ai(g){return typeof Uint8Array<"u"&&(rt(g)||D(g))}t.isAnyArrayBuffer=ai,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(g){Object.defineProperty(t,g,{enumerable:!1,value:function(){throw new Error(g+" is not supported in userland")}})})})($r);var xa=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},fn={exports:{}};typeof Object.create=="function"?fn.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:fn.exports=function(e,n){if(n){e.super_=n;var r=function(){};r.prototype=n.prototype,e.prototype=new r,e.prototype.constructor=e}};var Ga=fn.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(y){for(var b=Object.keys(y),I={},D=0;D<b.length;D++)I[b[D]]=Object.getOwnPropertyDescriptor(y,b[D]);return I},n=/%[sdj%]/g;t.format=function(f){if(!O(f)){for(var y=[],b=0;b<arguments.length;b++)y.push(s(arguments[b]));return y.join(" ")}for(var b=1,I=arguments,D=I.length,R=String(f).replace(n,function(F){if(F==="%%")return"%";if(b>=D)return F;switch(F){case"%s":return String(I[b++]);case"%d":return Number(I[b++]);case"%j":try{return JSON.stringify(I[b++])}catch{return"[Circular]"}default:return F}}),k=I[b];b<D;k=I[++b])S(k)||!ie(k)?R+=" "+k:R+=" "+s(k);return R},t.deprecate=function(f,y){if(typeof _<"u"&&_.noDeprecation===!0)return f;if(typeof _>"u")return function(){return t.deprecate(f,y).apply(this,arguments)};var b=!1;function I(){if(!b){if(_.throwDeprecation)throw new Error(y);_.traceDeprecation?console.trace(y):console.error(y),b=!0}return f.apply(this,arguments)}return I};var r={},i=/^$/;if(_.env.NODE_DEBUG){var o=_.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(f){if(f=f.toUpperCase(),!r[f])if(i.test(f)){var y=_.pid;r[f]=function(){var b=t.format.apply(t,arguments);console.error("%s %d: %s",f,y,b)}}else r[f]=function(){};return r[f]};function s(f,y){var b={seen:[],stylize:u};return arguments.length>=3&&(b.depth=arguments[2]),arguments.length>=4&&(b.colors=arguments[3]),L(y)?b.showHidden=y:y&&t._extend(b,y),N(b.showHidden)&&(b.showHidden=!1),N(b.depth)&&(b.depth=2),N(b.colors)&&(b.colors=!1),N(b.customInspect)&&(b.customInspect=!0),b.colors&&(b.stylize=a),c(b,f,b.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(f,y){var b=s.styles[y];return b?"\x1B["+s.colors[b][0]+"m"+f+"\x1B["+s.colors[b][1]+"m":f}function u(f,y){return f}function d(f){var y={};return f.forEach(function(b,I){y[b]=!0}),y}function c(f,y,b){if(f.customInspect&&y&&de(y.inspect)&&y.inspect!==t.inspect&&!(y.constructor&&y.constructor.prototype===y)){var I=y.inspect(b,f);return O(I)||(I=c(f,I,b)),I}var D=l(f,y);if(D)return D;var R=Object.keys(y),k=d(R);if(f.showHidden&&(R=Object.getOwnPropertyNames(y)),we(y)&&(R.indexOf("message")>=0||R.indexOf("description")>=0))return p(y);if(R.length===0){if(de(y)){var F=y.name?": "+y.name:"";return f.stylize("[Function"+F+"]","special")}if(re(y))return f.stylize(RegExp.prototype.toString.call(y),"regexp");if(Pe(y))return f.stylize(Date.prototype.toString.call(y),"date");if(we(y))return p(y)}var U="",W=!1,Te=["{","}"];if(A(y)&&(W=!0,Te=["[","]"]),de(y)){var it=y.name?": "+y.name:"";U=" [Function"+it+"]"}if(re(y)&&(U=" "+RegExp.prototype.toString.call(y)),Pe(y)&&(U=" "+Date.prototype.toUTCString.call(y)),we(y)&&(U=" "+p(y)),R.length===0&&(!W||y.length==0))return Te[0]+U+Te[1];if(b<0)return re(y)?f.stylize(RegExp.prototype.toString.call(y),"regexp"):f.stylize("[Object]","special");f.seen.push(y);var Le;return W?Le=v(f,y,b,k,R):Le=R.map(function(ot){return E(f,y,b,k,ot,W)}),f.seen.pop(),w(Le,U,Te)}function l(f,y){if(N(y))return f.stylize("undefined","undefined");if(O(y)){var b="'"+JSON.stringify(y).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return f.stylize(b,"string")}if(P(y))return f.stylize(""+y,"number");if(L(y))return f.stylize(""+y,"boolean");if(S(y))return f.stylize("null","null")}function p(f){return"["+Error.prototype.toString.call(f)+"]"}function v(f,y,b,I,D){for(var R=[],k=0,F=y.length;k<F;++k)Ce(y,String(k))?R.push(E(f,y,b,I,String(k),!0)):R.push("");return D.forEach(function(U){U.match(/^\d+$/)||R.push(E(f,y,b,I,U,!0))}),R}function E(f,y,b,I,D,R){var k,F,U;if(U=Object.getOwnPropertyDescriptor(y,D)||{value:y[D]},U.get?U.set?F=f.stylize("[Getter/Setter]","special"):F=f.stylize("[Getter]","special"):U.set&&(F=f.stylize("[Setter]","special")),Ce(I,D)||(k="["+D+"]"),F||(f.seen.indexOf(U.value)<0?(S(b)?F=c(f,U.value,null):F=c(f,U.value,b-1),F.indexOf(`
|
|
3
3
|
`)>-1&&(R?F=F.split(`
|
|
4
4
|
`).map(function(W){return" "+W}).join(`
|
|
5
5
|
`).slice(2):F=`
|
|
6
6
|
`+F.split(`
|
|
7
7
|
`).map(function(W){return" "+W}).join(`
|
|
8
|
-
`))):F=f.stylize("[Circular]","special")),N(
|
|
8
|
+
`))):F=f.stylize("[Circular]","special")),N(k)){if(R&&D.match(/^\d+$/))return F;k=JSON.stringify(""+D),k.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(k=k.slice(1,-1),k=f.stylize(k,"name")):(k=k.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),k=f.stylize(k,"string"))}return k+": "+F}function w(f,y,b){var I=f.reduce(function(D,R){return R.indexOf(`
|
|
9
9
|
`)>=0,D+R.replace(/\u001b\[\d\d?m/g,"").length+1},0);return I>60?b[0]+(y===""?"":y+`
|
|
10
10
|
`)+" "+f.join(`,
|
|
11
|
-
`)+" "+b[1]:b[0]+y+" "+f.join(", ")+" "+b[1]}t.types=$r;function A(f){return Array.isArray(f)}t.isArray=A;function L(f){return typeof f=="boolean"}t.isBoolean=L;function S(f){return f===null}t.isNull=S;function T(f){return f==null}t.isNullOrUndefined=T;function
|
|
11
|
+
`)+" "+b[1]:b[0]+y+" "+f.join(", ")+" "+b[1]}t.types=$r;function A(f){return Array.isArray(f)}t.isArray=A;function L(f){return typeof f=="boolean"}t.isBoolean=L;function S(f){return f===null}t.isNull=S;function T(f){return f==null}t.isNullOrUndefined=T;function P(f){return typeof f=="number"}t.isNumber=P;function O(f){return typeof f=="string"}t.isString=O;function $(f){return typeof f=="symbol"}t.isSymbol=$;function N(f){return f===void 0}t.isUndefined=N;function re(f){return ie(f)&&ve(f)==="[object RegExp]"}t.isRegExp=re,t.types.isRegExp=re;function ie(f){return typeof f=="object"&&f!==null}t.isObject=ie;function Pe(f){return ie(f)&&ve(f)==="[object Date]"}t.isDate=Pe,t.types.isDate=Pe;function we(f){return ie(f)&&(ve(f)==="[object Error]"||f instanceof Error)}t.isError=we,t.types.isNativeError=we;function de(f){return typeof f=="function"}t.isFunction=de;function Rt(f){return f===null||typeof f=="boolean"||typeof f=="number"||typeof f=="string"||typeof f=="symbol"||typeof f>"u"}t.isPrimitive=Rt,t.isBuffer=xa;function ve(f){return Object.prototype.toString.call(f)}function We(f){return f<10?"0"+f.toString(10):f.toString(10)}var ke=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Vt(){var f=new Date,y=[We(f.getHours()),We(f.getMinutes()),We(f.getSeconds())].join(":");return[f.getDate(),ke[f.getMonth()],y].join(" ")}t.log=function(){console.log("%s - %s",Vt(),t.format.apply(t,arguments))},t.inherits=Ga,t._extend=function(f,y){if(!y||!ie(y))return f;for(var b=Object.keys(y),I=b.length;I--;)f[b[I]]=y[b[I]];return f};function Ce(f,y){return Object.prototype.hasOwnProperty.call(f,y)}var le=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(y){if(typeof y!="function")throw new TypeError('The "original" argument must be of type Function');if(le&&y[le]){var b=y[le];if(typeof b!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(b,le,{value:b,enumerable:!1,writable:!1,configurable:!0}),b}function b(){for(var I,D,R=new Promise(function(U,W){I=U,D=W}),k=[],F=0;F<arguments.length;F++)k.push(arguments[F]);k.push(function(U,W){U?D(U):I(W)});try{y.apply(this,k)}catch(U){D(U)}return R}return Object.setPrototypeOf(b,Object.getPrototypeOf(y)),le&&Object.defineProperty(b,le,{value:b,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(b,e(y))},t.promisify.custom=le;function Ne(f,y){if(!f){var b=new Error("Promise was rejected with a falsy value");b.reason=f,f=b}return y(f)}function rt(f){if(typeof f!="function")throw new TypeError('The "original" argument must be of type Function');function y(){for(var b=[],I=0;I<arguments.length;I++)b.push(arguments[I]);var D=b.pop();if(typeof D!="function")throw new TypeError("The last argument must be of type Function");var R=this,k=function(){return D.apply(R,arguments)};f.apply(this,b).then(function(F){_.nextTick(k.bind(null,null,F))},function(F){_.nextTick(Ne.bind(null,F,k))})}return Object.setPrototypeOf(y,Object.getPrototypeOf(f)),Object.defineProperties(y,e(f)),y}t.callbackify=rt})(Ct);const{inherits:Ka,format:Ht}=Ct;function Ee(t,e,n=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 r(i,o,s){if(!new.target)return new r(i,o,s);Error.captureStackTrace(this,r),this.code=t,this.message=e,this.name="AvvioError",i&&o&&s?this.message=Ht(e,i,o,s):i&&o?this.message=Ht(e,i,o):i?this.message=Ht(e,i):this.message=e}return r.prototype[Symbol.toStringTag]="Error",r.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},Ka(r,n),r}var ni={createError:Ee,AVV_ERR_EXPOSE_ALREADY_DEFINED:Ee("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:Ee("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:Ee("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:Ee("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:Ee("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:Ee("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},Ha=function t(e,n,r){n===void 0&&(n=""),r||(r={});var i=function(u){var d={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return r.unicode===!1?d[u]:u};typeof e=="string"&&(e={label:e});var o=e.nodes||[],s=(e.label||"").split(`
|
|
12
12
|
`),a=`
|
|
13
13
|
`+n+(o.length?i("│"):" ")+" ";return n+s.join(a)+`
|
|
14
|
-
`+o.map(function(u,d){var c=d===o.length-1,l=u.nodes&&u.nodes.length,p=n+(c?" ":i("│"))+" ";return n+i(c?"└":"├")+i("─")+i(l?"┬":"─")+" "+t(u,p,r).slice(n.length+2)}).join("")};const za=Ha,ar=Symbol("avvio.TimeTree.untrackNode"),zt=Symbol("avvio.TimeTree.trackNode"),ur=Symbol("avvio.TimeTree.getParent"),cr=Symbol("avvio.TimeTree.getNode"),dr=Symbol("avvio.TimeTree.addNode");let Wa=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[zt](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])}[ar](e){this.tableId.delete(e.id);const n=this.tableLabel.get(e.label);if(n.id){this.tableLabel.delete(e.label);return}n.pop(),n.length===0&&this.tableLabel.delete(e.label)}[ur](e){if(e===null)return this.root;const n=this.tableLabel.get(e);return n.id?n:n[n.length-1]}[cr](e){return this.tableId.get(e)}[dr](e,n,r){if(e===null)return this.root={id:"root",label:n,start:r,nodes:[]},this[zt](this.root),this.root.id;const o=this[ur](e),s=`${n}-${Math.random()}`,a={id:s,parent:e,start:r,label:n,nodes:[]};return o.nodes.push(a),this[zt](a),s}start(e,n,r=Date.now()){return this[dr](e,n,r)}stop(e,n=Date.now()){const r=this[cr](e);r&&(r.stop=n,r.diff=r.stop-r.start||0,this[ar](r))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const e=r=>(r.label=`${r.label} ${r.diff} ms`,r.nodes.length>0&&(r.nodes=r.nodes.map(i=>e(i))),r),n=e(this.toJSON());return za(n)}};var Ya=Wa,
|
|
15
|
-
`).slice(0,2).map(n=>n.trim()).join(" -- ")}function ou(){const t={};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}function ze(t,e,n,r,i){this.started=!1,this.func=e,this.opts=n,this.onFinish=null,this.parent=t,this.timeout=i===void 0?t._timeout:i,this.name=iu(e,n),this.isAfter=r,this.q=eu(t,su,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}nu(ze,tu);ze.prototype.exec=function(t,e){const n=this.func;let r=!1;const i=this.name;if(this.parent._error&&!this.isAfter){K("skipping loading of plugin as parent errored and it is not an after",i),_.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,n,this.opts)}catch(u){return K("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,K("exec",i);let o;const s=u=>{if(r){K("loading complete",i);return}this._error=u,K(u?"exec errored":"exec completed",i),r=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(K("setting up timeout",i,this.timeout),o=setTimeout(function(){K("timed out",i),o=null;const u=new ru(i);u.fn=n,s(u)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const a=n(this.server,this.opts,s);a&&typeof a.then=="function"&&(K("exec: resolving promise",i),a.then(()=>_.nextTick(s),u=>_.nextTick(s,u)))};ze.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((n,r)=>{this._error=n,this.q.pause(),n?(K("rejecting promise",this.name,n),this._promise.reject(n)):(K("resolving promise",this.name),this._promise.resolve()),this._promise=null,_.nextTick(r,n)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=ou(),e=this._promise.promise,this.server?t():this.on("start",t)),e};ze.prototype.enqueue=function(t,e){K("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};ze.prototype.finish=function(t,e){K("finish",this.name,t);const n=()=>{this.loaded||(K("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),n();return}const r=()=>{if(K("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{K("wrap"),queueMicrotask(r)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else n();else K("delayed",this.name),this.q.drain=()=>{K("drain",this.name),this.q.drain=au,queueMicrotask(r)}};queueMicrotask(r),this.q.resume()};function su(t,e){const n=this;_.nextTick(Pn.bind(n),t,e)}function Pn(t,e){if(typeof t.func.then=="function"){t.func.then(r=>{typeof r.default=="function"&&(r=r.default),t.func=r,Pn.call(this,t,e)},e);return}const n=this._current[0];this._current.unshift(t),t.exec(n&&n.server||this._server,r=>{t.finish(r,i=>{this._current.shift(),e(i)})})}function au(){}kn.exports=ze;kn.exports.loadPlugin=Pn;var uu=kn.exports;const fr=Cr,cu=Mr.EventEmitter,du=Ct.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Jt,AVV_ERR_CALLBACK_NOT_FN:Ze,AVV_ERR_PLUGIN_NOT_VALID:lu,AVV_ERR_ROOT_PLG_BOOTED:fu,AVV_ERR_READY_TIMEOUT:pu}=ni,hu=Ya,hn=uu,Ke=ri("avvio"),It=Symbol("kAvvio"),Xt=Symbol("kThenifyDoNotWrap");function yu(t,e,n){const r=e.expose||{},i=r.use||"use",o=r.after||"after",s=r.ready||"ready",a=r.onClose||"onClose",u=r.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 n.use(d,c),this},Object.defineProperty(t,"then",{get:ii.bind(n)}),t[It]=!0,t[o]=function(d){return typeof d!="function"?n._loadRegistered():(n.after(Zt(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new Ze(s,typeof d);return n.ready(d?Zt(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new Ze(a,typeof d);return n.onClose(Su(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new Ze(u,typeof d);return d?(n.close(Zt(d,this)),this):n.close()}}function H(t,e,n){if(typeof t=="function"&&arguments.length===1&&(n=t,e={},t=null),typeof e=="function"&&(n=e,e={}),e=e||{},!(this instanceof H)){const r=new H(t,e,n);return t&&yu(t,e,r),r}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),n&&this.once("start",n),this.started=!1,this.booted=!1,this.pluginTree=new hu,this._readyQ=fr(this,oi,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=pr},this._closeQ=fr(this,vu,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=pr},this._doStart=null,this._root=new hn(this,mu.bind(this),e,!1,0),this._root.once("start",(r,i,o)=>{const s=this.pluginTree.start(null,i,o);this._root.once("loaded",(a,u,d)=>{this.pluginTree.stop(s,d)})}),hn.loadPlugin.call(this,this._root,r=>{Ke("root plugin ready");try{this.emit("preReady"),this._root=null}catch(i){r=r||this._error||i}if(r){if(this._error=r,this._readyQ.length()===0)throw r}else this.booted=!0;this._readyQ.resume()})}function mu(t,e,n){this._doStart=n,e.autostart&&this.start()}du(H,cu);H.prototype.start=function(){return this.started=!0,_.nextTick(this._doStart),this};H.prototype.override=function(t,e,n){return t};function gu(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new lu(typeof t);return t}H.prototype[It]=!0;H.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};H.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&_.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(H.prototype,"then",{get:ii});H.prototype._addPlugin=function(t,e,n){if(t=gu(t),e=e||{},this.booted)throw new fu;const r=this._current[0],i=new hn(this,t,e,n);if(i.once("start",(o,s,a)=>{const u=this.pluginTree.start(r.name,s,a);i.once("loaded",(d,c,l)=>{this.pluginTree.stop(u,l)})}),r.loaded)throw new Error(i.name,r.name);return r.enqueue(i,o=>{o&&(this._error=o)}),i};H.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(n,r,i){oi.call(this,t,i)}return this};H.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(n){n&&(this._error=n)}return this};H.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new Ze("close",typeof t)}else e=new Promise(function(n,r){t=function(i){if(i)return r(i);n()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),_.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};H.prototype.ready=function(t){if(t){if(typeof t!="function")throw new Ze("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,n)=>{this._readyQ.push(i),this.start();const r=this._current[0].server;function i(o,s,a){o?n(o):e(r),_.nextTick(a)}})};H.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};H.prototype.toJSON=function(){return this.pluginTree.toJSON()};function pr(){}function ii(){if(this.booted){Ke("thenify returning null because we are already booted");return}if(this[Xt]){this[Xt]=!1;return}return Ke("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Xt]=!0,t(this._server)),e)}function oi(t,e){const n=this._server,r=this._error;let i;if(this._error=null,t.length===0)this._error=r,i=t(),i&&!i[It]&&typeof i.then=="function"?i.then(()=>_.nextTick(e),o=>_.nextTick(e,o)):_.nextTick(e);else if(t.length===1)i=t(r),i&&!i[It]&&typeof i.then=="function"?i.then(()=>_.nextTick(e),o=>_.nextTick(e,o)):_.nextTick(e);else if(this._timeout===0){const o=s=>{this._error=s,e(this._error)};t.length===2?t(r,o):t(r,n,o)}else bu.call(this,t,r,n,e)}function bu(t,e,n,r){const i=t.name;Ke("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{Ke("timed out",i),o=null;const a=new pu(i);a.fn=t,this._error=a,r(a)},this._timeout);t.length===2?t(e,s.bind(this)):t(e,n,s.bind(this));function s(a){o&&(clearTimeout(o),this._error=a,r(this._error))}}function vu(t,e){const n=this._server,r=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let i;r?i=t(n):i=t(this._error),i&&typeof i.then=="function"?(Ke("resolving close/onClose promise"),i.then(()=>_.nextTick(e),o=>_.nextTick(e,o))):_.nextTick(e)}else t.length===2?t(r?n:this._error,e):r?t(n,e):t(this._error,n,e)}function Su(t,e){return n.bind(e);function n(r,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){_.nextTick(i)},i):_.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){_.nextTick(i)},i):_.nextTick(i)):t(this,i)}}function Zt(t,e){return n.bind(e);function n(r,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){_.nextTick(i,r)},i):_.nextTick(i,r)):t.length===1?(o=t(r),o&&o.then?o.then(function(){_.nextTick(i)},i):_.nextTick(i)):t.length===2?t(r,i):t(r,this,i):_.nextTick(i)}}gn.exports=H;gn.exports.express=function(t){return H(t,{expose:{use:"load"}})};var wu=gn.exports;const Tu=Yo(wu);(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 n=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(r){const i=n?window.performance.now():new Date().getTime(),o=Math.max(0,16-(i-e)),s=window.setTimeout(function(){r(i+o)},o);return e=i+o,s},window.cancelAnimationFrame=clearTimeout}})();function Eu(t,e=!0,n=!0,r={friendsTab:"enabled"}){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=Tu(Object.create({}),{autostart:!1});return s.use(_o,{hideFriends:r.hideFriends,skipOnboarding:r.skipOnboarding,betPack:r.betPack,friendsTab:r.friendsTab,theme:r.theme,themeMode:r.themeMode}),s.use(So,{onDeepLinkHandled:r?.onDeepLinkHandled}),s.use(Ao,{videoPlayerController:r?.videoPlayerController}),s.use(Io,{onContentActivate:r?.onContentActivate,withAd:r?.withAd,withAdNotification:r?.withAdNotification}),s.use(Mi,{sdkKey:t,host:i,analyticsHost:o,version:r?.version,webOS:r?.webOS}),s.use(xi),s.use(Eo),s.use(Bo),s.use(po),s.use(Wo),s.after((a,u,d)=>{if(a)throw a;u.ready(),d()}),n&&s.after(async(a,u,d)=>{if(a)throw a;await u.sdk.initializeApp(),d()}),s.onClose(()=>{console.log("close")}),s}exports.StreamLayer=Eu;
|
|
14
|
+
`+o.map(function(u,d){var c=d===o.length-1,l=u.nodes&&u.nodes.length,p=n+(c?" ":i("│"))+" ";return n+i(c?"└":"├")+i("─")+i(l?"┬":"─")+" "+t(u,p,r).slice(n.length+2)}).join("")};const za=Ha,ar=Symbol("avvio.TimeTree.untrackNode"),zt=Symbol("avvio.TimeTree.trackNode"),ur=Symbol("avvio.TimeTree.getParent"),cr=Symbol("avvio.TimeTree.getNode"),dr=Symbol("avvio.TimeTree.addNode");let Wa=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[zt](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])}[ar](e){this.tableId.delete(e.id);const n=this.tableLabel.get(e.label);if(n.id){this.tableLabel.delete(e.label);return}n.pop(),n.length===0&&this.tableLabel.delete(e.label)}[ur](e){if(e===null)return this.root;const n=this.tableLabel.get(e);return n.id?n:n[n.length-1]}[cr](e){return this.tableId.get(e)}[dr](e,n,r){if(e===null)return this.root={id:"root",label:n,start:r,nodes:[]},this[zt](this.root),this.root.id;const o=this[ur](e),s=`${n}-${Math.random()}`,a={id:s,parent:e,start:r,label:n,nodes:[]};return o.nodes.push(a),this[zt](a),s}start(e,n,r=Date.now()){return this[dr](e,n,r)}stop(e,n=Date.now()){const r=this[cr](e);r&&(r.stop=n,r.diff=r.stop-r.start||0,this[ar](r))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const e=r=>(r.label=`${r.label} ${r.diff} ms`,r.nodes.length>0&&(r.nodes=r.nodes.map(i=>e(i))),r),n=e(this.toJSON());return za(n)}};var Ya=Wa,Pn={exports:{}},pn={exports:{}},Wt,lr;function Ja(){if(lr)return Wt;lr=1;var t=1e3,e=t*60,n=e*60,r=n*24,i=r*7,o=r*365.25;Wt=function(c,l){l=l||{};var p=typeof c;if(p==="string"&&c.length>0)return s(c);if(p==="number"&&isFinite(c))return l.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 l=/^(-?(?:\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(l){var p=parseFloat(l[1]),v=(l[2]||"ms").toLowerCase();switch(v){case"years":case"year":case"yrs":case"yr":case"y":return p*o;case"weeks":case"week":case"w":return p*i;case"days":case"day":case"d":return p*r;case"hours":case"hour":case"hrs":case"hr":case"h":return p*n;case"minutes":case"minute":case"mins":case"min":case"m":return p*e;case"seconds":case"second":case"secs":case"sec":case"s":return p*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function a(c){var l=Math.abs(c);return l>=r?Math.round(c/r)+"d":l>=n?Math.round(c/n)+"h":l>=e?Math.round(c/e)+"m":l>=t?Math.round(c/t)+"s":c+"ms"}function u(c){var l=Math.abs(c);return l>=r?d(c,l,r,"day"):l>=n?d(c,l,n,"hour"):l>=e?d(c,l,e,"minute"):l>=t?d(c,l,t,"second"):c+" ms"}function d(c,l,p,v){var E=l>=p*1.5;return Math.round(c/p)+" "+v+(E?"s":"")}return Wt}function Xa(t){n.debug=n,n.default=n,n.coerce=u,n.disable=o,n.enable=i,n.enabled=s,n.humanize=Ja(),n.destroy=d,Object.keys(t).forEach(c=>{n[c]=t[c]}),n.names=[],n.skips=[],n.formatters={};function e(c){let l=0;for(let p=0;p<c.length;p++)l=(l<<5)-l+c.charCodeAt(p),l|=0;return n.colors[Math.abs(l)%n.colors.length]}n.selectColor=e;function n(c){let l,p=null,v,E;function w(...A){if(!w.enabled)return;const L=w,S=Number(new Date),T=S-(l||S);L.diff=T,L.prev=l,L.curr=S,l=S,A[0]=n.coerce(A[0]),typeof A[0]!="string"&&A.unshift("%O");let P=0;A[0]=A[0].replace(/%([a-zA-Z%])/g,($,N)=>{if($==="%%")return"%";P++;const re=n.formatters[N];if(typeof re=="function"){const ie=A[P];$=re.call(L,ie),A.splice(P,1),P--}return $}),n.formatArgs.call(L,A),(L.log||n.log).apply(L,A)}return w.namespace=c,w.useColors=n.useColors(),w.color=n.selectColor(c),w.extend=r,w.destroy=n.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(v!==n.namespaces&&(v=n.namespaces,E=n.enabled(c)),E),set:A=>{p=A}}),typeof n.init=="function"&&n.init(w),w}function r(c,l){const p=n(this.namespace+(typeof l>"u"?":":l)+c);return p.log=this.log,p}function i(c){n.save(c),n.namespaces=c,n.names=[],n.skips=[];let l;const p=(typeof c=="string"?c:"").split(/[\s,]+/),v=p.length;for(l=0;l<v;l++)p[l]&&(c=p[l].replace(/\*/g,".*?"),c[0]==="-"?n.skips.push(new RegExp("^"+c.slice(1)+"$")):n.names.push(new RegExp("^"+c+"$")))}function o(){const c=[...n.names.map(a),...n.skips.map(a).map(l=>"-"+l)].join(",");return n.enable(""),c}function s(c){if(c[c.length-1]==="*")return!0;let l,p;for(l=0,p=n.skips.length;l<p;l++)if(n.skips[l].test(c))return!1;for(l=0,p=n.names.length;l<p;l++)if(n.names[l].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 n.enable(n.load()),n}var Za=Xa;(function(t,e){e.formatArgs=r,e.save=i,e.load=o,e.useColors=n,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 n(){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 r(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,l=0;u[0].replace(/%[a-zA-Z%]/g,p=>{p!=="%%"&&(c++,p==="%c"&&(l=c))}),u.splice(l,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 _<"u"&&"env"in _&&(u=_.env.DEBUG),u}function s(){try{return localStorage}catch{}}t.exports=Za(e);const{formatters:a}=t.exports;a.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(pn,pn.exports);var ri=pn.exports;const eu=Cr,tu=Mr.EventEmitter,nu=Ct.inherits,K=ri("avvio"),{AVV_ERR_READY_TIMEOUT:ru}=ni,Yt=Symbol.for("plugin-meta");function iu(t,e){return t[Yt]&&t[Yt].name?t[Yt].name:typeof e<"u"&&typeof e!="function"&&e.name?e.name:t.name?t.name:t.toString().split(`
|
|
15
|
+
`).slice(0,2).map(n=>n.trim()).join(" -- ")}function ou(){const t={};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}function ze(t,e,n,r,i){this.started=!1,this.func=e,this.opts=n,this.onFinish=null,this.parent=t,this.timeout=i===void 0?t._timeout:i,this.name=iu(e,n),this.isAfter=r,this.q=eu(t,su,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}nu(ze,tu);ze.prototype.exec=function(t,e){const n=this.func;let r=!1;const i=this.name;if(this.parent._error&&!this.isAfter){K("skipping loading of plugin as parent errored and it is not an after",i),_.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,n,this.opts)}catch(u){return K("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,K("exec",i);let o;const s=u=>{if(r){K("loading complete",i);return}this._error=u,K(u?"exec errored":"exec completed",i),r=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(K("setting up timeout",i,this.timeout),o=setTimeout(function(){K("timed out",i),o=null;const u=new ru(i);u.fn=n,s(u)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const a=n(this.server,this.opts,s);a&&typeof a.then=="function"&&(K("exec: resolving promise",i),a.then(()=>_.nextTick(s),u=>_.nextTick(s,u)))};ze.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((n,r)=>{this._error=n,this.q.pause(),n?(K("rejecting promise",this.name,n),this._promise.reject(n)):(K("resolving promise",this.name),this._promise.resolve()),this._promise=null,_.nextTick(r,n)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=ou(),e=this._promise.promise,this.server?t():this.on("start",t)),e};ze.prototype.enqueue=function(t,e){K("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};ze.prototype.finish=function(t,e){K("finish",this.name,t);const n=()=>{this.loaded||(K("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),n();return}const r=()=>{if(K("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{K("wrap"),queueMicrotask(r)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else n();else K("delayed",this.name),this.q.drain=()=>{K("drain",this.name),this.q.drain=au,queueMicrotask(r)}};queueMicrotask(r),this.q.resume()};function su(t,e){const n=this;_.nextTick(kn.bind(n),t,e)}function kn(t,e){if(typeof t.func.then=="function"){t.func.then(r=>{typeof r.default=="function"&&(r=r.default),t.func=r,kn.call(this,t,e)},e);return}const n=this._current[0];this._current.unshift(t),t.exec(n&&n.server||this._server,r=>{t.finish(r,i=>{this._current.shift(),e(i)})})}function au(){}Pn.exports=ze;Pn.exports.loadPlugin=kn;var uu=Pn.exports;const fr=Cr,cu=Mr.EventEmitter,du=Ct.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Jt,AVV_ERR_CALLBACK_NOT_FN:Ze,AVV_ERR_PLUGIN_NOT_VALID:lu,AVV_ERR_ROOT_PLG_BOOTED:fu,AVV_ERR_READY_TIMEOUT:pu}=ni,hu=Ya,hn=uu,Ke=ri("avvio"),It=Symbol("kAvvio"),Xt=Symbol("kThenifyDoNotWrap");function yu(t,e,n){const r=e.expose||{},i=r.use||"use",o=r.after||"after",s=r.ready||"ready",a=r.onClose||"onClose",u=r.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 n.use(d,c),this},Object.defineProperty(t,"then",{get:ii.bind(n)}),t[It]=!0,t[o]=function(d){return typeof d!="function"?n._loadRegistered():(n.after(Zt(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new Ze(s,typeof d);return n.ready(d?Zt(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new Ze(a,typeof d);return n.onClose(Su(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new Ze(u,typeof d);return d?(n.close(Zt(d,this)),this):n.close()}}function H(t,e,n){if(typeof t=="function"&&arguments.length===1&&(n=t,e={},t=null),typeof e=="function"&&(n=e,e={}),e=e||{},!(this instanceof H)){const r=new H(t,e,n);return t&&yu(t,e,r),r}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),n&&this.once("start",n),this.started=!1,this.booted=!1,this.pluginTree=new hu,this._readyQ=fr(this,oi,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=pr},this._closeQ=fr(this,vu,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=pr},this._doStart=null,this._root=new hn(this,mu.bind(this),e,!1,0),this._root.once("start",(r,i,o)=>{const s=this.pluginTree.start(null,i,o);this._root.once("loaded",(a,u,d)=>{this.pluginTree.stop(s,d)})}),hn.loadPlugin.call(this,this._root,r=>{Ke("root plugin ready");try{this.emit("preReady"),this._root=null}catch(i){r=r||this._error||i}if(r){if(this._error=r,this._readyQ.length()===0)throw r}else this.booted=!0;this._readyQ.resume()})}function mu(t,e,n){this._doStart=n,e.autostart&&this.start()}du(H,cu);H.prototype.start=function(){return this.started=!0,_.nextTick(this._doStart),this};H.prototype.override=function(t,e,n){return t};function gu(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new lu(typeof t);return t}H.prototype[It]=!0;H.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};H.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&_.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(H.prototype,"then",{get:ii});H.prototype._addPlugin=function(t,e,n){if(t=gu(t),e=e||{},this.booted)throw new fu;const r=this._current[0],i=new hn(this,t,e,n);if(i.once("start",(o,s,a)=>{const u=this.pluginTree.start(r.name,s,a);i.once("loaded",(d,c,l)=>{this.pluginTree.stop(u,l)})}),r.loaded)throw new Error(i.name,r.name);return r.enqueue(i,o=>{o&&(this._error=o)}),i};H.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(n,r,i){oi.call(this,t,i)}return this};H.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(n){n&&(this._error=n)}return this};H.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new Ze("close",typeof t)}else e=new Promise(function(n,r){t=function(i){if(i)return r(i);n()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),_.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};H.prototype.ready=function(t){if(t){if(typeof t!="function")throw new Ze("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,n)=>{this._readyQ.push(i),this.start();const r=this._current[0].server;function i(o,s,a){o?n(o):e(r),_.nextTick(a)}})};H.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};H.prototype.toJSON=function(){return this.pluginTree.toJSON()};function pr(){}function ii(){if(this.booted){Ke("thenify returning null because we are already booted");return}if(this[Xt]){this[Xt]=!1;return}return Ke("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Xt]=!0,t(this._server)),e)}function oi(t,e){const n=this._server,r=this._error;let i;if(this._error=null,t.length===0)this._error=r,i=t(),i&&!i[It]&&typeof i.then=="function"?i.then(()=>_.nextTick(e),o=>_.nextTick(e,o)):_.nextTick(e);else if(t.length===1)i=t(r),i&&!i[It]&&typeof i.then=="function"?i.then(()=>_.nextTick(e),o=>_.nextTick(e,o)):_.nextTick(e);else if(this._timeout===0){const o=s=>{this._error=s,e(this._error)};t.length===2?t(r,o):t(r,n,o)}else bu.call(this,t,r,n,e)}function bu(t,e,n,r){const i=t.name;Ke("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{Ke("timed out",i),o=null;const a=new pu(i);a.fn=t,this._error=a,r(a)},this._timeout);t.length===2?t(e,s.bind(this)):t(e,n,s.bind(this));function s(a){o&&(clearTimeout(o),this._error=a,r(this._error))}}function vu(t,e){const n=this._server,r=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let i;r?i=t(n):i=t(this._error),i&&typeof i.then=="function"?(Ke("resolving close/onClose promise"),i.then(()=>_.nextTick(e),o=>_.nextTick(e,o))):_.nextTick(e)}else t.length===2?t(r?n:this._error,e):r?t(n,e):t(this._error,n,e)}function Su(t,e){return n.bind(e);function n(r,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){_.nextTick(i)},i):_.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){_.nextTick(i)},i):_.nextTick(i)):t(this,i)}}function Zt(t,e){return n.bind(e);function n(r,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){_.nextTick(i,r)},i):_.nextTick(i,r)):t.length===1?(o=t(r),o&&o.then?o.then(function(){_.nextTick(i)},i):_.nextTick(i)):t.length===2?t(r,i):t(r,this,i):_.nextTick(i)}}gn.exports=H;gn.exports.express=function(t){return H(t,{expose:{use:"load"}})};var wu=gn.exports;const Tu=Yo(wu);(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 n=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(r){const i=n?window.performance.now():new Date().getTime(),o=Math.max(0,16-(i-e)),s=window.setTimeout(function(){r(i+o)},o);return e=i+o,s},window.cancelAnimationFrame=clearTimeout}})();function Eu(t,e=!0,n=!0,r={friendsTab:"enabled"}){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=Tu(Object.create({}),{autostart:!1});return s.use(_o,{hideFriends:r.hideFriends,skipOnboarding:r.skipOnboarding,betPack:r.betPack,friendsTab:r.friendsTab,theme:r.theme,themeMode:r.themeMode}),s.use(So,{onDeepLinkHandled:r?.onDeepLinkHandled}),s.use(Ao,{videoPlayerController:r?.videoPlayerController}),s.use(Io,{onContentActivate:r?.onContentActivate,withAd:r?.withAd,withAdNotification:r?.withAdNotification}),s.use(Mi,{sdkKey:t,host:i,analyticsHost:o,version:r?.version,webOS:r?.webOS}),s.use(xi),s.use(Eo),s.use(Bo),s.use(po),s.use(Wo),s.after((a,u,d)=>{if(a)throw a;u.ready(),d()}),n&&s.after(async(a,u,d)=>{if(a)throw a;await u.sdk.initializeApp(),d()}),s.onClose(()=>{console.log("close StreamLayer instance")}),s}exports.StreamLayer=Eu;
|