@streamlayer/react 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare const StreamLayerSDKAdvertisement: React.FC;
package/lib/app/app.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- import type { StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
1
+ import { StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
2
+
3
3
  export declare const useStreamLayer: () => StreamLayerSDK | null;
4
4
  export declare const StreamLayerSDKReact: React.FC<{
5
5
  event: string;
package/lib/app/auth.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const StreamLayerLogin: React.FC<{
3
2
  token: string;
4
3
  schema: string;
@@ -1,5 +1,6 @@
1
1
  import { Component } from 'react';
2
2
  import { StreamLayerProps } from './provider';
3
+
3
4
  import '@streamlayer/react-ui/style.css';
4
5
  export declare const MastersStreamLayerProvider: React.FC<Omit<StreamLayerProps, 'autoEnable'> & {
5
6
  children: React.ReactNode;
@@ -23,6 +24,6 @@ export declare class MastersStreamLayerSDKReact extends Component<MastersAppProp
23
24
  hasError: boolean;
24
25
  };
25
26
  componentDidCatch(error: any, info: any): void;
26
- render(): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
27
+ render(): string | number | boolean | Iterable<import('react').ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
27
28
  }
28
29
  export {};
@@ -1,13 +1,13 @@
1
- /// <reference types="react" />
2
- import type { StreamLayerSDK, StreamLayerPlugin } from '@streamlayer/sdk-web-interfaces';
3
- import type { DeepLinkCallback, VideoPlayerCallback } from '@streamlayer/sdk-web-core';
1
+ import { StreamLayerSDK, StreamLayerPlugin } from '@streamlayer/sdk-web-interfaces';
2
+ import { DeepLinkCallback, VideoPlayerCallback } from '@streamlayer/sdk-web-core';
3
+
4
4
  export type { DeepLinkCallback, VideoPlayerCallback } from '@streamlayer/sdk-web-core';
5
5
  export declare enum StreamLayerStatus {
6
6
  UNSET = 0,
7
7
  CONNECTED = 1,
8
8
  READY = 2
9
9
  }
10
- export declare const StreamLayerContext: import("react").Context<{
10
+ export declare const StreamLayerContext: import('react').Context<{
11
11
  status: StreamLayerStatus;
12
12
  sdk: StreamLayerSDK | null;
13
13
  }>;
@@ -1,5 +1,6 @@
1
- import type { StreamLayerSDK, StreamLayerPlugin } from '@streamlayer/sdk-web-interfaces';
2
- import type { DeepLinkCallback, VideoPlayerCallback } from '@streamlayer/sdk-web-core';
1
+ import { StreamLayerSDK, StreamLayerPlugin } from '@streamlayer/sdk-web-interfaces';
2
+ import { DeepLinkCallback, VideoPlayerCallback } from '@streamlayer/sdk-web-core';
3
+
3
4
  declare global {
4
5
  interface Window {
5
6
  sl: unknown;
@@ -7,9 +8,9 @@ declare global {
7
8
  }
8
9
  export declare const useStreamLayerApp: ({ sdkKey, plugins, production, autoEnable, onDeepLinkHandled, videoPlayerController, }: {
9
10
  sdkKey: string;
10
- plugins?: Set<StreamLayerPlugin> | undefined;
11
- production?: boolean | undefined;
12
- autoEnable?: boolean | undefined;
13
- onDeepLinkHandled?: DeepLinkCallback | undefined;
14
- videoPlayerController?: VideoPlayerCallback | undefined;
11
+ plugins?: Set<StreamLayerPlugin>;
12
+ production?: boolean;
13
+ autoEnable?: boolean;
14
+ onDeepLinkHandled?: DeepLinkCallback;
15
+ videoPlayerController?: VideoPlayerCallback;
15
16
  }) => StreamLayerSDK | null;
package/lib/cjs/app.js CHANGED
@@ -1 +1 @@
1
- "use strict";var K=Object.defineProperty;var U=(e,t,n)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t,n)=>(U(e,typeof t!="symbol"?t+"":t,n),n);const o=require("react/jsx-runtime"),s=require("./index2.js"),d=require("react"),g=require("./useStreamLayerApp2.js");window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function z(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")}class B{constructor(t="main",n=window.localStorage){m(this,"delimiter",":");m(this,"prefix");m(this,"storage");m(this,"clear",()=>{for(const t in window.localStorage)t.startsWith(this.prefix)&&this.storage.removeItem(t)});m(this,"generateKey",t=>`${this.prefix}${this.delimiter}${t.join(this.delimiter)}`);m(this,"write",(...t)=>{const n=t.pop()||"",i=this.generateKey(t);try{this.storage.setItem(i,n)}catch(a){z(a)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(i,n))}});m(this,"read",(...t)=>{const n=this.storage.getItem(this.generateKey(t));return n===null?void 0:n});m(this,"remove",(...t)=>{this.storage.removeItem(this.generateKey(t))});this.prefix=`sl-sdk${this.delimiter}${t}`,this.storage=n}}var $;(function(e){e.Init="init",e.Ready="ready",e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e.Failed="failed",e.Reconnect="reconnect",e.Reconnecting="reconnecting"})($||($={}));g.Code.Unknown,g.Code.Internal,g.Code.DeadlineExceeded,g.Code.ResourceExhausted,g.Code.FailedPrecondition,g.Code.Unavailable,g.Code.DataLoss;s.createLogger("grpc:retry");g.createContextKey(10,{description:"Number of attempts to retry"}),g.createContextKey(3e4,{description:"Max delay between retries in milliseconds"});var N;(function(e){e.SCHEMA="schema",e.EXTERNAL_TOKEN="eToken",e.TOKEN="token"})(N||(N={}));class W extends B{constructor(){super("user");m(this,"setSchema",n=>{this.write(N.SCHEMA,n)});m(this,"getSchema",()=>this.read(N.SCHEMA));m(this,"setToken",n=>{this.write(N.TOKEN,n)});m(this,"getToken",()=>this.read(N.TOKEN));m(this,"setExternalToken",n=>{this.write(N.EXTERNAL_TOKEN,n)});m(this,"getExternalToken",()=>this.read(N.EXTERNAL_TOKEN));m(this,"removeToken",()=>{this.remove(N.TOKEN)})}}var L;(function(e){e.DISABLED="disabled",e.INITIALIZATION="initialization",e.READY="ready",e.FAILED="failed",e.SUSPENDED="suspended"})(L||(L={}));s.createLogger("deep_link");s.createLogger("bypass");new W;s.createLogger("video_player");var T;(function(e){e.ALLOWED="allowed",e.DISALLOWED="disallowed"})(T||(T={}));var D;(function(e){e.UNKNOWN="unknown",e.ALREADY_VOTED="already_voted"})(D||(D={}));var O;(function(e){e.ONBOARDING="onboarding",e.ONBOARDING_IO="onboarding_io"})(O||(O={}));var _;(function(e){e.Unset="unset",e.Required="required",e.Optional="optional",e.Completed="completed",e.Disabled="disabled",e.Unavailable="unavailable"})(_||(_={}));g.QuestionType.POLL,g.QuestionType.PREDICTION,g.QuestionType.TRIVIA;const G={[g.SdkOverlayType.GAMES]:!0},C=s.styled_default("div")({name:"LoadingContainer",class:"l1a1b29x",propsAsIs:!1}),H=({feature:e,sdk:t,children:n,className:i,noWait:a})=>{const l=s.useStore(e.status),r=s.useStore(t.sdkStore.slStreamId);if(!a){if(r!=null&&r.loading&&!r.data)return o.jsx(C,{className:i,children:"Event is loading..."});if(!(r!=null&&r.data))return o.jsx(C,{className:i,children:"Event is forbidden..."});if(l!==s.FeatureStatus.Ready)return o.jsx(C,{className:i,children:"Wait feature..."})}return n},M=d.createContext({sdk:null}),A=()=>d.useContext(M),X=s.styled_default("div")({name:"QuestionContainer",class:"qfnqmpg",propsAsIs:!1}),Y=({openedQuestion:e})=>{var t,n;const{sdk:i}=A();return((t=e==null?void 0:e.attributes)==null?void 0:t.attributes.case)==="insight"?o.jsx(s.x,{...e.attributes.attributes.value,controlVideo:i==null?void 0:i.controlVideoPlayer}):((n=e==null?void 0:e.attributes)==null?void 0:n.attributes.case)==="tweet"?o.jsx(s.a,{...e.attributes.attributes.value,controlVideo:i==null?void 0:i.controlVideoPlayer}):null},Z=({extendedQuestion:e,vote:t,close:n})=>{const{loading:i,data:a}=e;return a?o.jsx(s.Nt,{vote:t,close:n,openedQuestion:a,isLoading:!!i}):o.jsx(s.kt,{})},J=({gamification:e})=>{var t;const n=s.useStore(e.openedQuestion.$store),i=s.useStore(e.openedQuestion.$extendedStore);if(!n)return null;const a=n.type;return o.jsxs(X,{children:[o.jsx(s.T,{close:e.closeQuestion,type:((t=n.attributes)==null?void 0:t.type)||g.QuestionType.UNSET}),a==="question"&&o.jsx(Z,{vote:e.submitAnswer,close:e.closeQuestion,extendedQuestion:i}),a!=="question"&&o.jsx(Y,{openedQuestion:n}),o.jsx(s.c,{sponsorLogo:""})]})},ee=s.styled_default("div")({name:"InviteFriendsContainer",class:"i1d1hf8u",propsAsIs:!1}),se=({deepLink:e})=>o.jsx(ee,{children:o.jsx(s.M,{inviteLink:e,inviteCardTitle:"It’s More Fun With Friends",inviteCardSubtext:"Invite and compete against your friends for the top spot on the leaderboard."})}),te=s.styled_default("div")({name:"InviteLinkContainer",class:"i9tvant",propsAsIs:!1}),ne=({gamification:e,scrollNode:t,scrollStore:n})=>{const i=d.useRef(null),{data:a,hasMore:l,loading:r,key:c}=s.useStore(e.leaderboardList.$store),{data:p}=s.useStore(e.deepLink.$store),[u,h]=s.T$1(i);return!a.length&&!r?o.jsx(se,{deepLink:p}):o.jsxs(o.Fragment,{children:[o.jsx(s.S,{items:a,scrollNode:t,scrollStore:n,fetchMore:e.leaderboardList.fetchMore,hasMore:l,openItemDetail:e.openUser,currentUserId:e.currentUserId.get()},c),p&&o.jsx(te,{ref:i,children:o.jsx(s.g,{onClick:()=>u(p),title:"Invite Friends",description:"Challenge them now!"})}),h]})},oe=({store:e,openQuestion:t})=>{const{sdk:n}=A(),i=s.useStore(e);return o.jsx(s.k,{openQuestion:t,questions:i.data,controlVideo:n==null?void 0:n.controlVideoPlayer})},ie=({userSummary:e})=>{var t;const[n,i]=d.useState(void 0);return d.useEffect(()=>{const a=e.$store.subscribe(l=>{l&&i(l)});return()=>{a()}},[e]),o.jsx(s.O,{loading:!(n!=null&&n.summary),...n==null?void 0:n.summary,successRate:(t=n==null?void 0:n.percentage)==null?void 0:t.correct})},re=({gamification:e,className:t,scrollStore:n,scrollNode:i,appNode:a,style:l,responsiveStore:r})=>{const{tabsShown:c}=s.useStore(n,{keys:["tabsShown"]}),[p,u]=d.useState(s.m.HOME),[,h]=d.useTransition(),{sdkInDesktopView:v,screen:f}=s.useStore(r,{keys:["sdkInDesktopView"]}),y=S=>{h(()=>{var b;u(S),v===!1&&(((b=a.current)==null?void 0:b.getBoundingClientRect().y)||0)<0&&s.C$1(a,f.size,{behavior:"instant"})})};d.useEffect(()=>n.subscribe(S=>{if(S.scrollPosition===0){n.setKey("tabsShown",!0);return}r.get().sdkInDesktopView?n.setKey("tabsShown",S.scrollDirection==="backward"):n.setKey("tabsShown",S.scrollDirection==="forward")}),[n,r]);let x="0px";return v?x=c?"0px":"calc(8px - var(--header-height) - var(--header-offset))":x=c?"calc(var(--header-height) + var(--header-offset) - 2px)":"0px",o.jsxs(s.p$1,{className:t,style:l,children:[o.jsx(s.C,{style:{top:x},children:o.jsx(s.b,{activePage:p,toggleActivePage:y})}),p===s.m.HOME&&o.jsxs(o.Fragment,{children:[o.jsx(s.n,{style:{paddingTop:"8px"},children:o.jsx(s.m$1,{children:o.jsx(ie,{userSummary:e.userSummary})})}),o.jsx(s.a$1,{style:{flex:1},children:o.jsx(oe,{openQuestion:e.openQuestion,store:e.feedList.getStore()})})]}),p===s.m.LEADERBOARD&&o.jsx(s.l,{children:o.jsx(ne,{scrollStore:n,scrollNode:i,gamification:e})})]})},ae=()=>s.x$2,R=s.styled_default(ae())({name:"OpenedContainer",class:"o1o2cpiy",propsAsIs:!0}),le=s.styled_default("div")({name:"UserContainer",class:"u1ob6f8q",propsAsIs:!1}),de=({correct:e,incorrect:t})=>{const n=e+t;return n===0?0:Math.round(e/n*100)},ce=({gamification:e,scrollStore:t,className:n,appNode:i,scrollNode:a,responsiveStore:l})=>o.jsx(re,{appNode:i,scrollStore:t,scrollNode:a,className:n,gamification:e,responsiveStore:l}),ue=({gamification:e,className:t,appNode:n,responsiveStore:i})=>{const a=s.useStore(e.openedQuestion.$store),l=s.useStore(e.openedUser),{sdkInDesktopView:r}=s.useStore(i,{keys:["sdkInDesktopView"]}),{hiding:c,onAnimationEnd:p}=s.S$1();if(!n.current||!a&&!l)return null;const u=a?o.jsx(R,{className:t,hiding:c,onAnimationEnd:p,children:o.jsx(J,{gamification:e})}):l?o.jsx(R,{className:t,hiding:c,onAnimationEnd:p,children:o.jsxs(le,{children:[o.jsx(s.T,{label:"Friend's Rank",close:e.closeUser}),o.jsx(s.n,{children:o.jsx(s.O,{...l,successRate:de(l)})})]})}):null;return o.jsx(s.x$1,{container:n,useContainer:!r,children:u})},pe=d.lazy(()=>Promise.resolve().then(()=>require("./gamification-feature.js"))),he=({sdk:e,feature:t,className:n,scrollStore:i,appNode:a,scrollNode:l,responsiveStore:r})=>{const c=d.useMemo(()=>t&&t.featureConfig.get().type===g.SdkOverlayType.GAMES?o.jsx(H,{className:n,sdk:e,feature:t,children:o.jsx(pe,{appNode:a,scrollStore:i,scrollNode:l,className:n,responsiveStore:r,gamification:t})}):null,[e,t,n,r,i,l,a]);return o.jsx(d.Suspense,{fallback:o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:"page loading..."}),children:c})},ve=({feature:e,className:t,appNode:n,responsiveStore:i})=>e&&e.featureConfig.get().type===g.SdkOverlayType.GAMES?o.jsx(ue,{className:t,appNode:n,responsiveStore:i,gamification:e}):null,ge=()=>s.i,me=s.styled_default(ge())({name:"Container",class:"ckodz37",propsAsIs:!0}),fe=({sdk:e})=>{const t=s.useStore(e.sdkStore.organizationSettings),n=s.useStore(e.sdkStore.streamSettings),i=s.useStore(e.getActiveFeature()),a=d.useMemo(()=>{const r=(n==null?void 0:n.data)||(t==null?void 0:t.data);return r!=null&&r.overlays?r.overlays:[]},[t,n]),l=d.useMemo(()=>[...a.filter(({enableSdkButton:r})=>r).map(r=>({id:r.type,onClick:()=>e.openFeature(r.type),disabled:!(r.type in G),label:r.name,icon:o.jsx("img",{src:r.icon,alt:""}),position:r.position*10}))].sort((r,c)=>r.position-c.position),[a,e]);return o.jsx(me,{children:l.map(r=>o.jsx(s.I,{...r,icon:void 0,active:r.id===i},r.id))})},ye=s.styled_default("div")({name:"Container",class:"c3q0amv",propsAsIs:!1}),xe=s.styled_default("div")({name:"CloseIconWrap",class:"cqihknq",propsAsIs:!1}),Se=()=>s.r1,ke=s.styled_default(Se())({name:"CloseIcon",class:"cl5ln9o",propsAsIs:!0}),Ne=s.styled_default("div")({name:"Title",class:"t1bejf60",propsAsIs:!1}),je=s.styled_default("img")({name:"SponsorLogo",class:"sb0t4y8",propsAsIs:!1}),be=s.styled_default("div")({name:"PresentsTitle",class:"p1nmyo08",propsAsIs:!1}),Ie=s.styled_default("div")({name:"Subtitle",class:"sgd2pup",propsAsIs:!1}),Ce=s.styled_default("div")({name:"Description",class:"d6e19hw",propsAsIs:!1}),Ee=s.styled_default("button")({name:"ActionButton",class:"a17h53j4",propsAsIs:!1}),q=({close:e,action:t,onboarding:n})=>{var i,a,l,r,c,p,u,h;return o.jsxs(ye,{children:[o.jsx(xe,{onClick:e,children:o.jsx(ke,{name:"icon-cross"})}),((a=(i=n==null?void 0:n.titleCard)==null?void 0:i.media)==null?void 0:a.sponsorLogo)&&o.jsxs(Ne,{children:[o.jsx(je,{alt:"sponsor-logo",src:(r=(l=n==null?void 0:n.titleCard)==null?void 0:l.media)==null?void 0:r.sponsorLogo}),o.jsx(be,{children:"PRESENTS"})]}),((c=n==null?void 0:n.titleCard)==null?void 0:c.title)&&o.jsx(Ie,{children:(p=n==null?void 0:n.titleCard)==null?void 0:p.title}),((u=n==null?void 0:n.titleCard)==null?void 0:u.subtitle)&&o.jsx(Ce,{children:(h=n==null?void 0:n.titleCard)==null?void 0:h.subtitle}),o.jsx(Ee,{onClick:t,children:"Play Now"})]})},E=[{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_1.png",tagline:"Featured groups+ experience",headline:o.jsxs(o.Fragment,{children:["Welcome to ",o.jsx("br",{})," Featured Groups +"]})},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_2.png",headline:"Get real-time insights"},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_3.png",headline:"Predictions, trivia & polls synced to match play"},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_4.png",headline:"Win points for every answer you get right"},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_5.png",headline:"Compete against friends on the leaderboard"}],Ae=s.styled_default("div")({name:"OnboardingContainer",class:"o1xcysoz",propsAsIs:!1}),we=()=>s.x$2,$e=s.styled_default(we())({name:"OnboardingNotificationContainer",class:"oejzp3v",propsAsIs:!0}),V=s.styled_default("div")({name:"InnerContainer",class:"i134gfua",propsAsIs:!1}),Le=({deepLink:e,onboardingOpts:t,notification:n,gamification:i,loading:a,renderToNode:l,sdk:r})=>{var c,p,u,h,v,f,y;const x=s.useStore(i.friends.getStore()),[S,b]=d.useState(void 0),k=d.useMemo(()=>{var j,I;const w=r.getInviter();return w?(I=(j=x.data)==null?void 0:j.find(({slId:F})=>F===w))==null?void 0:I.name:""},[x.data,r]);return d.useEffect(()=>{const j=e.$store.subscribe(I=>{I&&b(I.data)});return()=>{j()}},[e.$store]),o.jsx(Ae,{children:o.jsx(s.rn,{loading:a,renderToNode:l,rules:[{label:"Answer as many questions as you like.",icon:"icon-btn-feature-groups"},{label:"Win points for each correct trivia or prediction answer.",icon:"icon-thumb-up"},{label:"Top the leader board and best your friends.",icon:"icon-trophy"}],rulesBtnLabel:(c=t.rules)==null?void 0:c.buttonLabel,rulesTitle:(p=t.rules)==null?void 0:p.heading,termsTitle:"Terms and Conditions",termsText:(u=t.rules)==null?void 0:u.terms,steps:E,primaryColor:(h=t.inviteCard)==null?void 0:h.iconColor,inviteLink:S,inviteCardTitle:(v=t.inviteCard)==null?void 0:v.heading,inviteCardSubtext:(f=t.inviteCard)==null?void 0:f.subtext,inviteCardBtnLabel:(y=t.inviteCard)==null?void 0:y.buttonLabel,onClose:()=>{var j;(j=n.close)==null||j.call(n)},gamification:i,sdk:r,inviterName:k})})},Te=({sdk:e,notification:t,saveHeight:n,style:i,appNode:a,sdkInDesktopView:l,responsiveStore:r})=>{var c;const p=d.useRef(null),u=t.data.onboarding,[h,v]=d.useState(u==null?void 0:u.instantOpen),f=e.getFeature(g.SdkOverlayType.GAMES),y=d.useMemo(()=>E==null?void 0:E.map(({graphicSrc:k})=>k),[]),{screen:x}=s.useStore(r,{keys:["screen"]});(c=u==null?void 0:u.titleCard)!=null&&c.media&&(u.titleCard.media.sponsorLogo=s.C$2),d.useLayoutEffect(()=>{var k;n(((k=p.current)==null?void 0:k.getBoundingClientRect().height)||0)},[n]);const{loading:S,throttled:b}=s.I$1(y);return h&&f&&u&&a.current&&!b?o.jsx(s.x$1,{container:a,useContainer:!l,children:o.jsx(Le,{notification:t,setOpened:v,gamification:f,onboardingOpts:u,deepLink:f.deepLink,loading:S,renderToNode:a,sdk:e})}):o.jsxs(o.Fragment,{children:[o.jsx(V,{ref:p,style:{position:"absolute",visibility:"hidden"},children:o.jsx(q,{close:()=>{},action:()=>{},onboarding:u})}),o.jsx($e,{style:i,hiding:t.hiding,children:o.jsx(V,{children:o.jsx(q,{close:t.close,action:()=>{var k;v(!0),(((k=a.current)==null?void 0:k.getBoundingClientRect().y)||0)<0&&s.C$1(a,x.size,{behavior:"smooth"})},onboarding:u})})})]})},De=()=>s.x$2,Oe=s.styled_default(De())({name:"Container",class:"c1cu0box",propsAsIs:!0}),P=s.styled_default("div")({name:"InnerContainer",class:"i1p534h4",propsAsIs:!1}),_e=()=>P,Re=s.styled_default(_e())({name:"HiddenContainer",class:"hyh76ez",propsAsIs:!0}),qe=s.styled_default("div")({name:"NotificationRefreshing",class:"n1pj3cvw",propsAsIs:!1}),Ve=()=>s.h,Me=s.styled_default(Ve())({name:"Pill",class:"pk13by5",propsAsIs:!0}),Pe=e=>{const[t,n]=d.useState(0),i=d.useRef(null),a=d.useCallback(r=>{i.current=r},[]);d.useEffect(()=>{var r;const c=(r=i.current)==null?void 0:r.getBoundingClientRect();c&&n(c.height)},[e]);const l=d.useCallback(r=>{n(r)},[]);return[a,t,l]},Qe=({sdk:e,notification:t,appNode:n,responsiveStore:i})=>{var a,l;const{sdkInDesktopView:r}=s.useStore(i,{keys:["sdkInDesktopView"]}),{sdk:c}=A(),[p,u,h]=Pe(t.id);return t.type===s.NotificationType.QUESTION?o.jsxs(o.Fragment,{children:[o.jsx(Re,{ref:p,children:o.jsx(s.k$1,{...t})}),o.jsxs(Oe,{style:{height:t.hiding?0:u},hiding:t.hiding,children:[o.jsx(P,{style:{height:"100%"},children:o.jsx(s.k$1,{...t,controlVideo:c==null?void 0:c.controlVideoPlayer})}),o.jsx(qe,{},t.id)]})]}):t.type===s.NotificationType.QUESTION_RESOLVED&&(l=(a=t.data)==null?void 0:a.question)!=null&&l.predictionResult?o.jsx(s.$,{style:{height:t.hiding?0:u},saveHeight:h,close:t.close,hiding:t.hiding,...t.data.question}):t.type===s.NotificationType.ONBOARDING?o.jsx(Te,{style:{height:t.hiding?0:u},saveHeight:h,sdk:e,notification:t,sdkInDesktopView:r,appNode:n,responsiveStore:i}):null},Fe="p6vl6vu",Ke=({pill:e,setPill:t,appNode:n,headerNode:i,scrollNode:a,responsiveStore:l,scrollStore:r})=>{var c,p;const{screen:u}=s.useStore(l,{keys:["screen"]}),{tabsShown:h,scrollPosition:v}=s.useStore(r,{keys:["tabsShown","scrollPosition"]});d.useEffect(()=>{l.get().sdkInDesktopView?v<50&&t(null):v>-50&&t(null)},[v,l,t]);const f=l.get().sdkInDesktopView?n:i;return!e||!f.current?null:s.Pk.createPortal(o.jsx(Me,{title:e.type===s.NotificationType.QUESTION_RESOLVED?"Prediction result":`New ${((p=s.o[(c=e.data)==null?void 0:c.questionType])==null?void 0:p.label)||"notification"}`,onClick:()=>{var y;l.get().sdkInDesktopView?(y=a.current)==null||y.scrollTo({top:0,behavior:"smooth"}):s.C$1(n,u.size,{behavior:"smooth"}),t(null)},className:s.cx_default(h&&Fe,"sl-pill-button")}),f.current)},Ue=({sdk:e,headerNode:t,scrollNode:n,responsiveStore:i,appNode:a,scrollStore:l})=>{const[r]=d.useState(e.getNotificationsStore()),c=s.useStore(r),[p,u]=d.useState(null),h=d.useMemo(()=>e.getActiveNotification(),[e,c]);return d.useEffect(()=>{h&&s.eventBus.emit("notification",{action:"rendered",payload:{questionId:h.data.questionId,questionType:h.data.questionType}})},[h]),d.useEffect(()=>{h&&(i.get().sdkInDesktopView||i.get().sdkInView)&&(!i.get().sdkInDesktopView&&i.get().sdkInView&&u(h),i.get().sdkInDesktopView&&window.requestAnimationFrame(()=>{l.get().scrollPosition!==0&&u(h)}))},[h]),d.useEffect(()=>{h||u(null)},[h]),o.jsxs(o.Fragment,{children:[!p&&h&&o.jsx(Qe,{headerNode:t,appNode:a,sdk:e,notification:h,responsiveStore:i}),p&&o.jsx(Ke,{pill:p,setPill:u,appNode:a,notification:h,headerNode:t,scrollNode:n,scrollStore:l,responsiveStore:i})]})},ze=e=>{const t=d.useRef(""),[n,i]=d.useState(!1),a=s.useStore(e.status),l=s.useStore(e.sdkStore.slStreamId),r=s.useStore(e.userId()),c=s.useStore(e.getActiveFeature()),p=a==="ready"&&!!l.data;d.useEffect(()=>{const v=e.getFeature(g.SdkOverlayType.GAMES);v&&(v.closeQuestion(),v.closeUser())},[c,e]);const u=v=>{t.current=v,i(!0),e.initializeApp({skipOrganizationSettings:!0}).then(({enabled:f,err:y})=>{if(!y&&f){e.isUserAuthorized().then(x=>{x||e.disableApp()});return}})},h=()=>{i(!1),e.disableApp()};return d.useEffect(()=>{if(!r){p&&e.disableApp();return}if(r&&t.current&&n){e.initializeApp({skipOrganizationSettings:!0}).then(()=>{e.createEventSession(t.current)});return}},[r]),d.useEffect(()=>()=>{i(!1),e.disableApp()},[i,e]),{sdkEnabled:n,sdkReady:p,activateEventWithId:u,deactivate:h,isLogged:!!r}},Be=({sdk:e,className:t,scrollStore:n,appNode:i,scrollNode:a,responsiveStore:l})=>{const[,r]=s.p$2(e);return o.jsx(he,{className:t,scrollNode:a,appNode:i,scrollStore:n,feature:r,responsiveStore:l,sdk:e})},We=({sdk:e,className:t,appNode:n,responsiveStore:i})=>{const a=s.useStore(e.featuresList.getStore());return a?Array.from(a,l=>{const r=e.getFeature(l);return r?o.jsx(ve,{className:t,appNode:n,feature:r,responsiveStore:i,sdk:e},l):null}):null},Ge=({sdk:e,event:t})=>{const n=d.useRef(null),i=d.useRef(null),[a]=s.v(n),[l,r]=s.D(n,a),{sdkEnabled:c,sdkReady:p,activateEventWithId:u,deactivate:h,isLogged:v}=ze(e);d.useEffect(()=>{t?(e.createEventSession(t),u(t)):h()},[t,u,h,e]),s.L(n,{enabled:c,event:"click",listener:s.b$1}),s.L(l,{enabled:c,event:"scrollend",listener:s.y,useDomNode:!0}),s.L(l,{enabled:c,event:"click",listener:s.w,useDomNode:!0});const f=d.useMemo(()=>({sdk:e}),[e]);return d.useEffect(()=>{Promise.resolve().then(()=>require("./gamification-feature.js"))},[]),o.jsx(M.Provider,{value:f,children:o.jsxs(s.i$1,{ref:n,children:[c&&o.jsx(fe,{sdk:e}),o.jsxs(s.c$1,{className:"sl-hide-on-modal",ref:l,"data-nav":c.toString(),children:[p&&o.jsx(Ue,{sdk:e,scrollNode:l,headerNode:i,appNode:n,scrollStore:r,responsiveStore:a}),p&&o.jsx(Be,{scrollStore:r,responsiveStore:a,scrollNode:l,appNode:n,className:s.p,sdk:e}),p&&o.jsx(We,{responsiveStore:a,appNode:n,className:s.p,sdk:e})]}),c&&!v&&o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:"You are not logged in."})]})})},Q=({children:e,style:t})=>o.jsx("div",{className:"StreamLayerSDKTheme",children:o.jsx("div",{className:s.m$2,style:t,children:e})}),He=()=>{const{sdk:e}=d.useContext(s.StreamLayerContext);return e},Xe=({event:e})=>{const{sdk:t,status:n}=d.useContext(s.StreamLayerContext);if(n===s.StreamLayerStatus.UNSET)throw new Error("Wrap app in `StreamLayerProvider`");return n===s.StreamLayerStatus.CONNECTED?o.jsx("div",{className:"StreamLayerSDK",children:"wait"}):t===null?o.jsx("div",{className:"StreamLayerSDK",children:"sdk not initialized"}):o.jsx("div",{className:"StreamLayerSDK",children:o.jsx(Q,{children:o.jsx(Ge,{sdk:t,event:e})})})};exports.StreamLayerSDKReact=Xe;exports.i=Q;exports.q=ce;exports.useStreamLayer=He;
1
+ "use strict";var K=Object.defineProperty;var U=(e,t,n)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t,n)=>U(e,typeof t!="symbol"?t+"":t,n);const o=require("react/jsx-runtime"),s=require("./index2.js"),c=require("react"),g=require("./useStreamLayerApp2.js");window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function z(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")}class B{constructor(t="main",n=window.localStorage){m(this,"delimiter",":");m(this,"prefix");m(this,"storage");m(this,"clear",()=>{for(const t in window.localStorage)t.startsWith(this.prefix)&&this.storage.removeItem(t)});m(this,"generateKey",t=>`${this.prefix}${this.delimiter}${t.join(this.delimiter)}`);m(this,"write",(...t)=>{const n=t.pop()||"",i=this.generateKey(t);try{this.storage.setItem(i,n)}catch(r){z(r)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(i,n))}});m(this,"read",(...t)=>{const n=this.storage.getItem(this.generateKey(t));return n===null?void 0:n});m(this,"remove",(...t)=>{this.storage.removeItem(this.generateKey(t))});this.prefix=`sl-sdk${this.delimiter}${t}`,this.storage=n}}var w;(function(e){e.Init="init",e.Ready="ready",e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e.Failed="failed",e.Reconnect="reconnect",e.Reconnecting="reconnecting"})(w||(w={}));g.Code.Unknown,g.Code.Internal,g.Code.DeadlineExceeded,g.Code.ResourceExhausted,g.Code.FailedPrecondition,g.Code.Unavailable,g.Code.DataLoss;s.createLogger("grpc:retry");g.createContextKey(10,{description:"Number of attempts to retry"}),g.createContextKey(3e4,{description:"Max delay between retries in milliseconds"});var N;(function(e){e.SCHEMA="schema",e.EXTERNAL_TOKEN="eToken",e.TOKEN="token"})(N||(N={}));class W extends B{constructor(){super("user");m(this,"setSchema",n=>{this.write(N.SCHEMA,n)});m(this,"getSchema",()=>this.read(N.SCHEMA));m(this,"setToken",n=>{this.write(N.TOKEN,n)});m(this,"getToken",()=>this.read(N.TOKEN));m(this,"setExternalToken",n=>{this.write(N.EXTERNAL_TOKEN,n)});m(this,"getExternalToken",()=>this.read(N.EXTERNAL_TOKEN));m(this,"removeToken",()=>{this.remove(N.TOKEN)})}}var L;(function(e){e.DISABLED="disabled",e.INITIALIZATION="initialization",e.READY="ready",e.FAILED="failed",e.SUSPENDED="suspended"})(L||(L={}));s.createLogger("deep_link");s.createLogger("bypass");new W;s.createLogger("video_player");var T;(function(e){e.SHOWED="showed"})(T||(T={}));var D;(function(e){e.ALLOWED="allowed",e.DISALLOWED="disallowed"})(D||(D={}));var $;(function(e){e.UNKNOWN="unknown",e.ALREADY_VOTED="already_voted"})($||($={}));var O;(function(e){e.ONBOARDING="onboarding",e.ONBOARDING_IO="onboarding_io"})(O||(O={}));var _;(function(e){e.Unset="unset",e.Required="required",e.Optional="optional",e.Completed="completed",e.Disabled="disabled",e.Unavailable="unavailable"})(_||(_={}));g.QuestionType.POLL,g.QuestionType.PREDICTION,g.QuestionType.TRIVIA;const G={[g.SdkOverlayType.GAMES]:!0},I=s.styled_default("div")({name:"LoadingContainer",class:"lclc0ej",propsAsIs:!1}),H=({feature:e,sdk:t,children:n,className:i,noWait:r})=>{const l=s.useStore(e.status),d=s.useStore(t.sdkStore.slStreamId);if(!r){if(d!=null&&d.loading&&!d.data)return o.jsx(I,{className:i,children:"Event is loading..."});if(!(d!=null&&d.data))return o.jsx(I,{className:i,children:"Event is forbidden..."});if(l!==s.FeatureStatus.Ready)return o.jsx(I,{className:i,children:"Wait feature..."})}return n},M=c.createContext({sdk:null}),C=()=>c.useContext(M),X=s.styled_default("div")({name:"QuestionContainer",class:"q14ckf9e",propsAsIs:!1}),Y=({openedQuestion:e})=>{var t,n;const{sdk:i}=C();return((t=e==null?void 0:e.attributes)==null?void 0:t.attributes.case)==="insight"?o.jsx(s.x,{...e.attributes.attributes.value,controlVideo:i==null?void 0:i.controlVideoPlayer}):((n=e==null?void 0:e.attributes)==null?void 0:n.attributes.case)==="tweet"?o.jsx(s.a,{...e.attributes.attributes.value,controlVideo:i==null?void 0:i.controlVideoPlayer}):null},Z=({extendedQuestion:e,vote:t,close:n})=>{const{loading:i,data:r}=e;return r?o.jsx(s.Nt,{vote:t,close:n,openedQuestion:r,isLoading:!!i}):o.jsx(s.kt,{})},J=({gamification:e})=>{var t,n,i;const r=s.useStore(e.openedQuestion.$store),l=s.useStore(e.openedQuestion.$extendedStore);if(!r)return null;const d=r.type;return o.jsxs(X,{children:[o.jsx(s.T,{close:e.closeQuestion,type:((t=r.attributes)==null?void 0:t.type)||g.QuestionType.UNSET}),d==="question"&&o.jsx(Z,{vote:e.submitAnswer,close:e.closeQuestion,extendedQuestion:l}),d!=="question"&&o.jsx(Y,{openedQuestion:r}),o.jsx(s.i,{sponsorLogo:(i=(n=l.data)==null?void 0:n.sponsorship)==null?void 0:i.logo})]})},ee=s.styled_default("div")({name:"InviteFriendsContainer",class:"i1c9dygq",propsAsIs:!1}),se=({deepLink:e})=>o.jsx(ee,{children:o.jsx(s.M,{inviteLink:e,inviteCardTitle:"It’s More Fun With Friends",inviteCardSubtext:"Invite and compete against your friends for the top spot on the leaderboard."})}),te=s.styled_default("div")({name:"InviteLinkContainer",class:"i1odbhm4",propsAsIs:!1}),ne=({gamification:e,scrollNode:t,scrollStore:n})=>{const i=c.useRef(null),{data:r,hasMore:l,loading:d,key:u}=s.useStore(e.leaderboardList.$store),{data:a}=s.useStore(e.deepLink.$store),[v,p]=s.T$1(i);return!r.length&&!d?o.jsx(se,{deepLink:a}):o.jsxs(o.Fragment,{children:[o.jsx(s.S,{items:r,scrollNode:t,scrollStore:n,fetchMore:e.leaderboardList.fetchMore,hasMore:l,openItemDetail:e.openUser,currentUserId:e.currentUserId.get()},u),a&&o.jsx(te,{ref:i,children:o.jsx(s.C,{onClick:()=>v(a),title:"Invite Friends",description:"Challenge them now!"})}),p]})},oe=({store:e,openQuestion:t})=>{const{sdk:n}=C(),i=s.useStore(e);return o.jsx(s.k,{openQuestion:t,questions:i.data,controlVideo:n==null?void 0:n.controlVideoPlayer})},ie=({userSummary:e})=>{var t;const[n,i]=c.useState(void 0);return c.useEffect(()=>{const r=e.$store.subscribe(l=>{l&&i(l)});return()=>{r()}},[e]),o.jsx(s.O,{loading:!(n!=null&&n.summary),...n==null?void 0:n.summary,successRate:(t=n==null?void 0:n.percentage)==null?void 0:t.correct})},re=({gamification:e,className:t,scrollStore:n,scrollNode:i,appNode:r,style:l,responsiveStore:d})=>{const{tabsShown:u}=s.useStore(n,{keys:["tabsShown"]}),[a,v]=c.useState(s.m.HOME),[,p]=c.useTransition(),{sdkInDesktopView:h,screen:f}=s.useStore(d,{keys:["sdkInDesktopView"]}),x=k=>{p(()=>{var y;v(k),h===!1&&(((y=r.current)==null?void 0:y.getBoundingClientRect().y)||0)<0&&s.C$2(r,f.size,{behavior:"instant"})})};c.useEffect(()=>n.subscribe(k=>{if(k.scrollPosition===0){n.setKey("tabsShown",!0);return}d.get().sdkInDesktopView?n.setKey("tabsShown",k.scrollDirection==="backward"):n.setKey("tabsShown",k.scrollDirection==="forward")}),[n,d]);let S="0px";return h?S=u?"0px":"calc(8px - var(--header-height) - var(--header-offset))":S=u?"calc(var(--header-height) + var(--header-offset) - 2px)":"0px",o.jsxs(s.l,{className:t,style:l,children:[o.jsx(s.C$1,{style:{top:S},children:o.jsx(s.b,{activePage:a,toggleActivePage:x})}),a===s.m.HOME&&o.jsxs(o.Fragment,{children:[o.jsx(s.n,{style:{paddingTop:"8px"},children:o.jsx(s.m$1,{children:o.jsx(ie,{userSummary:e.userSummary})})}),o.jsx(s.a$1,{style:{flex:1},children:o.jsx(oe,{openQuestion:e.openQuestion,store:e.feedList.getStore()})})]}),a===s.m.LEADERBOARD&&o.jsx(s.p$1,{children:o.jsx(ne,{scrollStore:n,scrollNode:i,gamification:e})})]})},ae=()=>s.x$2,R=s.styled_default(ae())({name:"OpenedContainer",class:"ouvguos",propsAsIs:!0}),le=s.styled_default("div")({name:"UserContainer",class:"u1eu4lbg",propsAsIs:!1}),de=({correct:e,incorrect:t})=>{const n=e+t;return n===0?0:Math.round(e/n*100)},ce=({gamification:e,scrollStore:t,className:n,appNode:i,scrollNode:r,responsiveStore:l})=>o.jsx(re,{appNode:i,scrollStore:t,scrollNode:r,className:n,gamification:e,responsiveStore:l}),ue=({gamification:e,className:t,appNode:n,responsiveStore:i})=>{const r=s.useStore(e.openedQuestion.$store),l=s.useStore(e.openedUser),{sdkInDesktopView:d}=s.useStore(i,{keys:["sdkInDesktopView"]}),{hiding:u,onAnimationEnd:a}=s.S$1();if(!n.current||!r&&!l)return null;const v=r?o.jsx(R,{className:t,hiding:u,onAnimationEnd:a,children:o.jsx(J,{gamification:e})}):l?o.jsx(R,{className:t,hiding:u,onAnimationEnd:a,children:o.jsxs(le,{children:[o.jsx(s.T,{label:"Friend's Rank",close:e.closeUser}),o.jsx(s.n,{children:o.jsx(s.O,{...l,successRate:de(l)})})]})}):null;return o.jsx(s.x$1,{container:n,useContainer:!d,children:v})},pe=c.lazy(()=>Promise.resolve().then(()=>require("./gamification-feature.js"))),ve=({sdk:e,feature:t,className:n,scrollStore:i,appNode:r,scrollNode:l,responsiveStore:d})=>{const u=c.useMemo(()=>t&&t.featureConfig.get().type===g.SdkOverlayType.GAMES?o.jsx(H,{className:n,sdk:e,feature:t,children:o.jsx(pe,{appNode:r,scrollStore:i,scrollNode:l,className:n,responsiveStore:d,gamification:t})}):null,[e,t,n,d,i,l,r]);return o.jsx(c.Suspense,{fallback:o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:"page loading..."}),children:u})},he=({feature:e,className:t,appNode:n,responsiveStore:i})=>e&&e.featureConfig.get().type===g.SdkOverlayType.GAMES?o.jsx(ue,{className:t,appNode:n,responsiveStore:i,gamification:e}):null,ge=()=>s.c1,me=s.styled_default(ge())({name:"ButtonIcon",class:"b11wpe79",propsAsIs:!0}),fe=c.forwardRef(({sdk:e,className:t},n)=>{const i=s.useStore(e.sdkStore.organizationSettings),r=s.useStore(e.sdkStore.streamSettings),l=s.useStore(e.getActiveFeature()),d=c.useMemo(()=>{const a=(r==null?void 0:r.data)||(i==null?void 0:i.data);return a!=null&&a.overlays?a.overlays:[]},[i,r]),u=c.useMemo(()=>[...d.filter(({enableSdkButton:a})=>a).map(a=>({id:a.type,onClick:()=>e.openFeature(a.type),disabled:!(a.type in G),label:a.name,icon:o.jsx("img",{src:a.icon,alt:""}),position:a.position*10}))].sort((a,v)=>a.position-v.position),[d,e]);return o.jsxs(s.n$1,{className:t,children:[o.jsx(s.e,{children:[o.jsx(s.I,{id:"Channels",onClick:()=>e.closeFeature(),label:"Channels",active:l===0},"Channels"),...u.map(a=>a.id===g.SdkOverlayType.GAMES?o.jsx(s.I,{...a,active:a.id===l,label:"StreamLayer +",id:"featuredGroups",icon:o.jsx(me,{name:"icon-btn-feature-groups","data-selected":a.id===l})},a.id):o.jsx(s.I,{...a,icon:void 0,active:a.id===l},a.id))]}),o.jsx("div",{ref:n})]})}),ye=s.styled_default("div")({name:"Container",class:"c1qjj4d4",propsAsIs:!1}),xe=s.styled_default("div")({name:"CloseIconWrap",class:"c1lg6b8a",propsAsIs:!1}),Se=()=>s.c1,ke=s.styled_default(Se())({name:"CloseIcon",class:"c159el66",propsAsIs:!0}),Ne=s.styled_default("div")({name:"Title",class:"t16xmufv",propsAsIs:!1}),je=s.styled_default("img")({name:"SponsorLogo",class:"s83lc21",propsAsIs:!1}),be=s.styled_default("div")({name:"PresentsTitle",class:"p1p7igia",propsAsIs:!1}),Ie=s.styled_default("div")({name:"Subtitle",class:"s1eftsbu",propsAsIs:!1}),Ee=s.styled_default("div")({name:"Description",class:"d8uezec",propsAsIs:!1}),Ce=s.styled_default("button")({name:"ActionButton",class:"a1h1bk90",propsAsIs:!1}),V=({close:e,action:t,onboarding:n})=>{var i,r,l,d,u,a,v,p;return o.jsxs(ye,{children:[o.jsx(xe,{onClick:e,children:o.jsx(ke,{name:"icon-cross"})}),((r=(i=n==null?void 0:n.titleCard)==null?void 0:i.media)==null?void 0:r.sponsorLogo)&&o.jsxs(Ne,{children:[o.jsx(je,{alt:"sponsor-logo",src:(d=(l=n==null?void 0:n.titleCard)==null?void 0:l.media)==null?void 0:d.sponsorLogo}),o.jsx(be,{children:"PRESENTS"})]}),((u=n==null?void 0:n.titleCard)==null?void 0:u.title)&&o.jsx(Ie,{children:(a=n==null?void 0:n.titleCard)==null?void 0:a.title}),((v=n==null?void 0:n.titleCard)==null?void 0:v.subtitle)&&o.jsx(Ee,{children:(p=n==null?void 0:n.titleCard)==null?void 0:p.subtitle}),o.jsx(Ce,{onClick:t,children:"Play Now"})]})},E=[{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_0.png",tagline:"",headline:o.jsxs(o.Fragment,{children:["Welcome to ",o.jsx("br",{})," StreamLayer +"]})},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_2.png",headline:"Get real-time insights"},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_3.png",headline:"Predictions, trivia & polls synced to match play"},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_4.png",headline:"Win points for every answer you get right"},{graphicSrc:"https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_5.png",headline:"Compete against friends on the leaderboard"}],Ae=s.styled_default("div")({name:"OnboardingContainer",class:"o1xni1kr",propsAsIs:!1}),we=()=>s.x$2,Le=s.styled_default(we())({name:"OnboardingNotificationContainer",class:"o1vnouv7",propsAsIs:!0}),q=s.styled_default("div")({name:"InnerContainer",class:"i59uefw",propsAsIs:!1}),Te=({deepLink:e,onboardingOpts:t,notification:n,gamification:i,loading:r,sdk:l})=>{var d,u,a,v,p,h,f;const x=s.useStore(i.friends.getStore()),[S,k]=c.useState(void 0),y=c.useMemo(()=>{var j,b;const A=l.getInviter();return A?(b=(j=x.data)==null?void 0:j.find(({slId:Q})=>Q===A))==null?void 0:b.name:""},[x.data,l]);return c.useEffect(()=>{const j=e.$store.subscribe(b=>{b&&k(b.data)});return()=>{j()}},[e.$store]),o.jsx(Ae,{children:o.jsx(s.rn,{loading:r,rules:[{label:"Answer as many questions as you like.",icon:"icon-btn-feature-groups"},{label:"Win points for each correct trivia or prediction answer.",icon:"icon-thumb-up"},{label:"Top the leader board and best your friends.",icon:"icon-trophy"}],rulesBtnLabel:(d=t.rules)==null?void 0:d.buttonLabel,rulesTitle:(u=t.rules)==null?void 0:u.heading,termsTitle:"Terms and Conditions",termsText:(a=t.rules)==null?void 0:a.terms,steps:E,primaryColor:(v=t.inviteCard)==null?void 0:v.iconColor,inviteLink:S,inviteCardTitle:(p=t.inviteCard)==null?void 0:p.heading,inviteCardSubtext:(h=t.inviteCard)==null?void 0:h.subtext,inviteCardBtnLabel:(f=t.inviteCard)==null?void 0:f.buttonLabel,onClose:()=>{var j;(j=n.close)==null||j.call(n)},gamification:i,sdk:l,inviterName:y})})},De=({sdk:e,notification:t,saveHeight:n,style:i,appNode:r,sdkInDesktopView:l,responsiveStore:d})=>{const u=c.useRef(null),a=t.data.onboarding,[v,p]=c.useState(a==null?void 0:a.instantOpen),h=e.getFeature(g.SdkOverlayType.GAMES),f=c.useMemo(()=>E==null?void 0:E.map(({graphicSrc:y})=>y),[]),{screen:x}=s.useStore(d,{keys:["screen"]});c.useLayoutEffect(()=>{var y;n(((y=u.current)==null?void 0:y.getBoundingClientRect().height)||0)},[n]);const{loading:S,throttled:k}=s.I$1(f);return v&&h&&a&&r.current&&!k?o.jsx(s.x$1,{container:r,useContainer:!l,children:o.jsx(Te,{notification:t,setOpened:p,gamification:h,onboardingOpts:a,deepLink:h.deepLink,loading:S,renderToNode:r,sdk:e})}):o.jsxs(o.Fragment,{children:[o.jsx(q,{ref:u,style:{position:"absolute",visibility:"hidden"},children:o.jsx(V,{close:()=>{},action:()=>{},onboarding:a})}),o.jsx(Le,{style:i,hiding:t.hiding,children:o.jsx(q,{children:o.jsx(V,{close:t.close,action:()=>{var y;p(!0),(((y=r.current)==null?void 0:y.getBoundingClientRect().y)||0)<0&&s.C$2(r,x.size,{behavior:"smooth"})},onboarding:a})})})]})},$e=()=>s.x$2,Oe=s.styled_default($e())({name:"Container",class:"c8ol1ve",propsAsIs:!0}),F=s.styled_default("div")({name:"InnerContainer",class:"iqfywam",propsAsIs:!1}),_e=()=>F,Re=s.styled_default(_e())({name:"HiddenContainer",class:"hokmtod",propsAsIs:!0}),Ve=s.styled_default("div")({name:"NotificationRefreshing",class:"n192d1q8",propsAsIs:!1}),qe=()=>s.h,Me=s.styled_default(qe())({name:"Pill",class:"p1lha68t",propsAsIs:!0}),Fe=e=>{const[t,n]=c.useState(0),i=c.useRef(null),r=c.useCallback(d=>{i.current=d},[]);c.useEffect(()=>{var d;const u=(d=i.current)==null?void 0:d.getBoundingClientRect();u&&n(u.height)},[e]);const l=c.useCallback(d=>{n(d)},[]);return[r,t,l]},Pe=({sdk:e,notification:t,appNode:n,responsiveStore:i})=>{var r,l;const{sdkInDesktopView:d}=s.useStore(i,{keys:["sdkInDesktopView"]}),{sdk:u}=C(),[a,v,p]=Fe(t.id);return t.type===s.NotificationType.QUESTION?o.jsxs(o.Fragment,{children:[o.jsx(Re,{ref:a,children:o.jsx(s.k$1,{...t})}),o.jsxs(Oe,{style:{height:t.hiding?0:v},hiding:t.hiding,children:[o.jsx(F,{style:{height:"100%"},children:o.jsx(s.k$1,{...t,controlVideo:u==null?void 0:u.controlVideoPlayer})}),o.jsx(Ve,{},t.id)]})]}):t.type===s.NotificationType.QUESTION_RESOLVED&&(l=(r=t.data)==null?void 0:r.question)!=null&&l.predictionResult?o.jsx(s.q,{style:{height:t.hiding?0:v},saveHeight:p,close:t.close,hiding:t.hiding,...t.data.question}):t.type===s.NotificationType.ONBOARDING?o.jsx(De,{style:{height:t.hiding?0:v},saveHeight:p,sdk:e,notification:t,sdkInDesktopView:d,appNode:n,responsiveStore:i}):null},Qe="p7vfi6t",Ke=({pill:e,setPill:t,appNode:n,headerNode:i,scrollNode:r,responsiveStore:l,scrollStore:d})=>{var u,a;const{screen:v}=s.useStore(l,{keys:["screen"]}),{tabsShown:p,scrollPosition:h}=s.useStore(d,{keys:["tabsShown","scrollPosition"]});c.useEffect(()=>{l.get().sdkInDesktopView?h<50&&t(null):h>-50&&t(null)},[h,l,t]);const f=l.get().sdkInDesktopView?n:i;return!e||!f.current?null:s.Ik.createPortal(o.jsx(Me,{title:e.type===s.NotificationType.QUESTION_RESOLVED?"Prediction result":`New ${((a=s.o[(u=e.data)==null?void 0:u.questionType])==null?void 0:a.label)||"notification"}`,onClick:()=>{var x;l.get().sdkInDesktopView?(x=r.current)==null||x.scrollTo({top:0,behavior:"smooth"}):s.C$2(n,v.size,{behavior:"smooth"}),t(null)},className:s.cx_default(p&&Qe,"sl-pill-button")}),f.current)},Ue=({sdk:e,headerNode:t,scrollNode:n,responsiveStore:i,appNode:r,scrollStore:l})=>{const[d]=c.useState(e.getNotificationsStore()),u=s.useStore(d),[a,v]=c.useState(null),p=c.useMemo(()=>e.getActiveNotification(),[e,u]);return c.useEffect(()=>{p&&s.eventBus.emit("notification",{action:"rendered",payload:{questionId:p.data.questionId,questionType:p.data.questionType}})},[p]),c.useEffect(()=>{p&&(i.get().sdkInDesktopView||i.get().sdkInView)&&(!i.get().sdkInDesktopView&&i.get().sdkInView&&v(p),i.get().sdkInDesktopView&&window.requestAnimationFrame(()=>{l.get().scrollPosition!==0&&v(p)}))},[p]),c.useEffect(()=>{p||v(null)},[p]),o.jsxs(o.Fragment,{children:[!a&&p&&o.jsx(Pe,{headerNode:t,appNode:r,sdk:e,notification:p,responsiveStore:i}),a&&o.jsx(Ke,{pill:a,setPill:v,appNode:r,notification:p,headerNode:t,scrollNode:n,scrollStore:l,responsiveStore:i})]})},ze=e=>{const t=c.useRef(""),[n,i]=c.useState(!1),r=s.useStore(e.status),l=s.useStore(e.sdkStore.slStreamId),d=s.useStore(e.userId()),u=s.useStore(e.getActiveFeature()),a=r==="ready"&&!!l.data;c.useEffect(()=>{const h=e.getFeature(g.SdkOverlayType.GAMES);h&&(h.closeQuestion(),h.closeUser())},[u,e]);const v=c.useCallback(h=>{t.current=h,i(!0),e.initializeApp({skipOrganizationSettings:!0}).then(({enabled:f,err:x})=>{if(!x&&f){e.isUserAuthorized().then(S=>{S||e.disableApp()});return}})},[e]),p=c.useCallback(()=>{i(!1),e.disableApp()},[e]);return c.useEffect(()=>{if(!d){a&&e.disableApp();return}if(d&&t.current&&n){e.initializeApp({skipOrganizationSettings:!0}).then(()=>{e.createEventSession(t.current)});return}},[d]),c.useEffect(()=>()=>{i(!1),e.disableApp()},[i,e]),{sdkEnabled:n,sdkReady:a,activateEventWithId:v,deactivate:p,isLogged:!!d}},Be=({sdk:e,className:t,scrollStore:n,appNode:i,scrollNode:r,responsiveStore:l})=>{const[,d]=s.p$2(e);return o.jsx(ve,{className:t,scrollNode:r,appNode:i,scrollStore:n,feature:d,responsiveStore:l,sdk:e})},We=({sdk:e,className:t,appNode:n,responsiveStore:i})=>{const r=s.useStore(e.featuresList.getStore());return r?Array.from(r,l=>{const d=e.getFeature(l);return d?o.jsx(he,{className:t,appNode:n,feature:d,responsiveStore:i,sdk:e},l):null}):null},Ge=({sdk:e,event:t})=>{const n=c.useRef(null),i=c.useRef(null),[r]=s.v(n),[l,d]=s.D(n,r),{sdkEnabled:u,sdkReady:a,activateEventWithId:v,deactivate:p,isLogged:h}=ze(e);c.useEffect(()=>{t?(e.createEventSession(t),v(t)):p()},[t,v,p,e]),s.L(n,{enabled:u,event:"click",listener:s.b$1}),s.L(l,{enabled:u,event:"scrollend",listener:s.y,useDomNode:!0}),s.L(l,{enabled:u,event:"click",listener:s.w,useDomNode:!0});const f=c.useMemo(()=>({sdk:e}),[e]);return c.useEffect(()=>{Promise.resolve().then(()=>require("./gamification-feature.js"))},[]),o.jsx(M.Provider,{value:f,children:o.jsxs(s.i$1,{ref:n,children:[u&&o.jsx(fe,{className:s.p,sdk:e,ref:i}),o.jsxs(s.c,{className:"sl-hide-on-modal",ref:l,"data-nav":u.toString(),children:[a&&o.jsx(Ue,{sdk:e,scrollNode:l,headerNode:i,appNode:n,scrollStore:d,responsiveStore:r}),a&&o.jsx(Be,{scrollStore:d,responsiveStore:r,scrollNode:l,appNode:n,className:s.p,sdk:e}),a&&o.jsx(We,{responsiveStore:r,appNode:n,className:s.p,sdk:e})]}),u&&!h&&o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:"You are not logged in."})]})})},P=({children:e,style:t})=>o.jsx("div",{className:"StreamLayerSDKTheme",children:o.jsx("div",{className:s.m$2,style:t,children:e})}),He=()=>{const{sdk:e}=c.useContext(s.StreamLayerContext);return e},Xe=({event:e})=>{const{sdk:t,status:n}=c.useContext(s.StreamLayerContext);if(n===s.StreamLayerStatus.UNSET)throw new Error("Wrap app in `StreamLayerProvider`");return n===s.StreamLayerStatus.CONNECTED?o.jsx("div",{className:"StreamLayerSDK",children:"wait"}):t===null?o.jsx("div",{className:"StreamLayerSDK",children:"sdk not initialized"}):o.jsx("div",{className:"StreamLayerSDK",children:o.jsx(P,{children:o.jsx(Ge,{sdk:t,event:e})})})};exports.E=ce;exports.StreamLayerSDKReact=Xe;exports.i=P;exports.useStreamLayer=He;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./app.js");exports.default=e.q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./app.js");exports.default=e.E;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./masters2.js");exports.default=e.E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./masters2.js");exports.default=e.z;