PageSourceSearch

https://klirr.com/_next/static/immutable/chunks/0ro6suw43cr65.js

js klirr.com collected 2026-10-08 03:28:19 UTC 50,657 bytes, 4 lines download raw bytes

1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="54200748-8cc3-b1b9-0842-cb4b88c14401")}catch(e){}}();
2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,32682,148715,t=>{"use strict";var e=t.i(699018),n=t.i(677309),r=t.i(271235);let s=new WeakMap,i=(0,r.withMiddleware)(e.u,t=>(e,r,i)=>{let[o,a]=(0,n.s)(e),c=o?"$sub$"+o:void 0,u=t(c,null,i),{cache:l}=i;s.has(l)||s.set(l,[new Map,new Map]);let[h,d]=s.get(l);return(0,n.u)(()=>{if(!c)return;let[,t]=(0,n.c)(l,c),e=h.get(c)||0;if(h.set(c,e+1),!e){let e=r(a,{next:(e,n)=>{null!=e?t({error:e}):(t({error:void 0}),u.mutate(n,!1))}});if("function"!=typeof e)throw Error("The `subscribe` function must return a function to unsubscribe.");d.set(c,e)}return()=>{let t=h.get(c)-1;if(h.set(c,t),!t){let t=d.get(c);null==t||t(),h.delete(c),d.delete(c)}}},[c]),{get data(){return u.data},get error(){return u.error}}});t.s(["default",0,i],32682);var o=t.i(968962),a=t.i(628615);t.s(["subscribeToConnection",0,(t,{next:e})=>{let n=(0,a.getThrillConnectClient)(),r=()=>{(0,a.setConnectionState)(!0),e(null,!0)},s=()=>{(0,a.setConnectionState)(!1),e(null,!1)},i=()=>{(0,a.setConnectionState)(!1),e(null,!1)};return n.on(o.ConnectEvents.Connected,r),n.on(o.ConnectEvents.Disconnected,s),n.on(o.ConnectEvents.ConnectionFailed,i),e(null,(0,a.getConnectionState)()),()=>{try{n.off(o.ConnectEvents.Connected,r),n.off(o.ConnectEvents.Disconnected,s),n.off(o.ConnectEvents.ConnectionFailed,i)}catch(t){console.log("[ThrillConnect] Connection subscription cleanup:",t)}}}],148715)},858050,t=>{"use strict";var e=t.i(479017);let n="tma-casino",r={"tma-quickhit":{[e.CurrencyCode.SEK]:{tier1:27e5,tier2:4e5,tier3:8e4,tier4:2e4},[e.CurrencyCode.EUR]:{tier1:235e3,tier2:35e3,tier3:7e3,tier4:1750}},"tma-casino":{[e.CurrencyCode.SEK]:{tier1:5e6,tier2:5e5,tier3:5e4,tier4:5e3},[e.CurrencyCode.EUR]:{tier1:435e3,tier2:43500,tier3:4350,tier4:435}}},s={[e.CurrencyCode.SEK]:[{key:"single",amount:1},{key:"double",amount:2},{key:"standard",amount:3},{key:"plus",amount:5}],[e.CurrencyCode.EUR]:[{key:"single",amount:.1},{key:"double",amount:.2},{key:"standard",amount:.3},{key:"plus",amount:.5}]},i={sourceId:n,mustDropAt:r[n][e.AppConfig.currency],contributionOptions:s[e.AppConfig.currency]};t.s(["JackpotConfig",0,i,"jackpotTierTranslationKeys",0,{tier1:"JACKPOT_TIER_1",tier2:"JACKPOT_TIER_2",tier3:"JACKPOT_TIER_3",tier4:"JACKPOT_TIER_4"}])},175139,329248,t=>{"use strict";var e=t.i(843476),n=t.i(183330),r=t.i(699018),r=r;t.s(["SWRProvider",0,function({children:t}){return(0,e.jsx)(r.S,{value:{revalidateOnFocus:!1,keepPreviousData:!0,errorRetryCount:3,onError(t,e){(0,n.addBreadcrumb)({category:"swr",level:"warning",message:"SWR fetch failed",data:{swrKey:e,error:t}})}},children:t})}],175139),t.s(["ThrillConnectSWRKeys",0,{CONNECTION_STATUS:"connection-status",JACKPOT:"jackpot",JACKPOT_WINS:"jackpot-wins",OPT_IN:"opt-in",OPT_IN_MUTATION:"opt-in-mutation",OPT_OUT_MUTATION:"opt-out-mutation",SOURCES:"sources",CURRENCY_MULTIPLIERS:"currency-multipliers"}],329248)},991039,461914,807275,516856,394952,t=>{"use strict";let e;var n=t.i(673467);t.i(348175);var r=t.i(157773),s=t.i(964964),i=t.i(760516),o=t.i(271645);t.i(175139);var a=t.i(329248),c=t.i(664287),u=t.i(560491),l=t.i(32682),h=t.i(628615);t.i(129533);var d=t.i(271348),p=t.i(479017),y=t.i(858050),g=t.i(968962);let _={instance_id:"",last_updated:0,opted_in:!1,requested_optin:!1,player_brand_id:"",player_id:"",preferred_contribution_currency:p.AppConfig.currency,preferred_contribution_value:(e=y.JackpotConfig.contributionOptions.find(t=>"standard"===t.key),e?.amount??y.JackpotConfig.contributionOptions[1].amount)},v={tier1:1,tier2:2,tier3:3,tier4:4};async function b(){for(let t=0;t<3;t++){if((0,h.getConnectionState)())return!0;t<2&&await new Promise(t=>setTimeout(t,1e3))}return!1}function C(t,e){return Promise.race([t,new Promise((t,n)=>setTimeout(()=>n(Error("Request timeout")),e))])}function f(t,e){let n=(0,h.getThrillConnectClient)();return new Promise(r=>{let s=()=>{clearTimeout(o);try{n.off(g.ConnectEvents.OptInEvent,i)}catch{}},i=e=>{t(e)&&(s(),r(e))},o=setTimeout(()=>{s(),r(null)},e);n.on(g.ConnectEvents.OptInEvent,i)})}async function w(){if(!(0,h.getConnectionState)())return null;let t=(0,h.getThrillConnectClient)(),e=await t.request().getOptInStatusForSource(y.JackpotConfig.sourceId);return e?function(t){let e,n,{currency:r,value:s}=(n=(e=Object.keys(t.contribution_preferences??{})[0])?t.contribution_preferences?.[e]:void 0,{currency:e,value:n});return{instance_id:t.instance_id,last_updated:t.last_updated,opted_in:t.opted_in,requested_o
2ptin:t.opted_in,player_brand_id:t.player_brand_id,player_id:t.player_id,preferred_contribution_currency:r,preferred_contribution_value:s}}(e):_}async function m(){let t=(0,h.getThrillConnectClient)();return await t.request().getJackpotForSource(y.JackpotConfig.sourceId)}function P(){return(0,h.getThrillConnectClient)().request().getCurrencies()}function S(){let{sessionId:t,isLoggedIn:e}=(0,s.useAuth)(),{currencies:n}=function(){let{data:t,error:e,mutate:n}=(0,u.default)(a.ThrillConnectSWRKeys.CURRENCY_MULTIPLIERS,P);return{currencies:t,loading:!e&&!t,error:e??null,refetch:n}}(),r=e===i.IsLoggedIn.YES&&!!t,p=r?[a.ThrillConnectSWRKeys.JACKPOT,t]:null,{data:y}=(0,l.default)(p,d.subscribeToJackpotUpdate),g=r&&(!r||y)?null:[a.ThrillConnectSWRKeys.JACKPOT,"polling",t??"anon"],{data:_,error:b}=(0,u.default)(g,m,{refreshInterval:r?1e4:5e3,revalidateOnFocus:!1,revalidateOnReconnect:!0,revalidateOnMount:!0,dedupingInterval:2e3,errorRetryCount:3,errorRetryInterval:5e3,shouldRetryOnError:!0}),C=y??_,f=C?null:b,w=(0,h.getConnectionState)(),S=(0,o.useMemo)(()=>C?.pots?[...(0,c.convertPots)(C.pots,C.currency,n)].sort((t,e)=>(v[t.id]??99)-(v[e.id]??99)):[],[C?.pots,C?.currency,n]);return{jackpot:C??null,pots:S,loading:!f&&!C,error:f??null,isUsingFallback:r&&!w&&!!C}}t.s(["useJackpotTicker",0,S],461914),t.s(["useJackpotAvailable",0,function(){let{isHydrated:t}=(0,r.useIsHydrated)(),{isLoggedIn:e}=(0,s.useAuth)(),a=(0,n.useThrillConnectStatus)(),c=e===i.IsLoggedIn.YES,{jackpot:u,loading:l,error:h,isUsingFallback:d}=S(),[p,y]=(0,o.useState)(!1),g=(0,o.useRef)(null),_=(0,o.useRef)(null),v=!!u,b=!!h&&!v,C=l&&!u;(0,o.useEffect)(()=>{if(!t)return;let e=c&&!a,n=!c&&b,r=c&&a,s=!c&&v&&!b;return r||s?(g.current=null,y(!1),_.current&&(clearTimeout(_.current),_.current=null)):(e||n)&&!C&&!g.current&&(g.current=Date.now(),_.current=setTimeout(()=>{y(!0)},15e3)),()=>{_.current&&clearTimeout(_.current)}},[t,a,c,b,v,C]);let f=t&&c&&!a,w=t&&!c&&b;return{isAvailable:v,isReconnecting:f&&!p,isUnavailable:p&&!v,isLoading:C,isUsingFallback:d,hasConnectionIssue:(f||w)&&!p}}],807275);var E=t.i(631164);t.s(["useJackpotWins",0,function(){let{isLoggedIn:t,sessionId:e}=(0,s.useAuth)(),n=t===i.IsLoggedIn.YES&&e?[a.ThrillConnectSWRKeys.JACKPOT_WINS,e]:null,{data:r}=(0,l.default)(n,E.subscribeToJackpotWin);return{latestWin:r??null}}],516856);var T=t.i(839899);t.i(430656);var k=t.i(876499),W=t.i(699018),I=t.i(677309),O=t.i(271235);let J=I.j?t=>{t()}:o.default.startTransition,R=(0,O.withMiddleware)(W.u,()=>(t,e,n={})=>{let{mutate:r}=(0,O.useSWRConfig)(),s=(0,o.useRef)(t),i=(0,o.useRef)(e),a=(0,o.useRef)(n),c=(0,o.useRef)(0),[u,l,h]=(t=>{let[,e]=(0,o.useState)({}),n=(0,o.useRef)(!1),r=(0,o.useRef)(t),s=(0,o.useRef)({data:!1,error:!1,isValidating:!1}),i=(0,o.useCallback)(t=>{let i=!1,o=r.current;for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&o[e]!==t[e]&&(o[e]=t[e],s.current[e]&&(i=!0));i&&!n.current&&e({})},[]);return(0,I.u)(()=>(n.current=!1,()=>{n.current=!0})),[r,s.current,i]})({data:I.U,error:I.U,isMutating:!1}),d=u.current,p=(0,o.useCallback)(async(t,e)=>{let[n,o]=(0,I.s)(s.current);if(!i.current)throw Error("Can’t trigger the mutation: missing fetcher.");if(!n)throw Error("Can’t trigger the mutation: missing key.");let u=(0,I.m)((0,I.m)({populateCache:!1,throwOnError:!0},a.current),e),l=(0,I.g)();c.current=l,h({isMutating:!0});try{let e=await r(n,i.current(o,{arg:t}),(0,I.m)(u,{throwOnError:!0}));return c.current<=l&&(J(()=>h({data:e,isMutating:!1,error:void 0})),null==u.onSuccess||u.onSuccess.call(u,e,n,u)),e}catch(t){if(c.current<=l&&(J(()=>h({error:t,isMutating:!1})),null==u.onError||u.onError.call(u,t,n,u),u.throwOnError))throw t}},[]),y=(0,o.useCallback)(()=>{c.current=(0,I.g)(),h({data:I.U,error:I.U,isMutating:!1})},[]);return(0,I.u)(()=>{s.current=t,i.current=e,a.current=n}),{trigger:p,reset:y,get data(){return l.data=!0,d.data},get error(){return l.error=!0,d.error},get isMutating(){return l.isMutating=!0,d.isMutating}}});var U=t.i(604181),q=t.i(220981);t.s(["useOptInStatus",0,function({enabled:t=!0}={}){let{sessionId:e,isLoggedIn:n}=(0,s.useAuth)(),{gtmEvent:r}=(0,T.useGoogleTagManager)(),o=(0,U.useClient)(),c=n===i.IsLoggedIn.YES&&!!e,d=t&&c?[a.ThrillConnectSWRKeys.OPT_IN,e]:null,{data:g}=(0,l.default)(d,q.subscribeToOptIn),_=(0,h.getConnectionState)(),v=t&&c&&_?[a.ThrillConnectSWRKeys.OPT_IN,"http",e]:null,{data:m}=(0,u.default)(v,w),{trigger:P,isMutating:S,error:E}=R(t&&c?a.ThrillConnectSWRKeys.OPT_IN_MUTATION:null,async(t,{arg:e})=>
2{r({event:e.isContributionChange?T.EventName.JACKPOT_CHANGE_ATTEMPT:T.EventName.JACKPOT_OPT_IN_ATTEMPT});let{confirmation:n}=await J(e.amount);n.then(t=>{t&&r({event:e.isContributionChange?T.EventName.JACKPOT_CHANGE_CONFIRMED:T.EventName.JACKPOT_OPT_IN_CONFIRMED})})}),{trigger:W,isMutating:I,error:O}=R(t&&c?a.ThrillConnectSWRKeys.OPT_OUT_MUTATION:null,async()=>{r({event:T.EventName.JACKPOT_OPT_OUT_ATTEMPT});let{confirmation:t}=await x();t.then(t=>{t&&r({event:T.EventName.JACKPOT_OPT_OUT_CONFIRMED})})}),J=async t=>{if(!await b())throw Error("No connection");let e=(0,h.getThrillConnectClient)(),n=f(e=>e.opted_in&&e.preferred_contribution_value===t,1e4);return await C(e.request().optIntoSource(y.JackpotConfig.sourceId,!0,t,p.AppConfig.currency),1e4),{confirmation:n}},x=async()=>{if(!await b())throw Error("No connection");let t=(0,h.getThrillConnectClient)(),e=f(t=>!t.opted_in,1e4);return await C(t.request().optIntoSource(y.JackpotConfig.sourceId,!1,void 0,p.AppConfig.currency),1e4),o.mutation(k.leaveLocalJackpotMutation,{input:{brandId:p.AppConfig.tmaBrandId,sourceId:y.JackpotConfig.sourceId}}).toPromise().catch(()=>{}),{confirmation:e}};return{optInStatus:g??m,loading:S||I,error:E||O||null,optIn:t=>P({amount:t}),changeContribution:t=>P({amount:t,isContributionChange:!0}),optOut:W}}],394952),t.s([],991039)},673467,271348,631164,220981,129533,t=>{"use strict";var e=t.i(964964);t.i(175139);var n=t.i(329248),r=t.i(32682),s=t.i(628615),i=t.i(148715),o=t.i(858050),a=t.i(968962);t.s(["subscribeToJackpotUpdate",0,function(t,{next:e}){let n=null,r=t=>
2{if(!t.allowed_sources?.includes(o.JackpotConfig.sourceId))return;let r={...n??{},pots:t.pots,status:t.status,currency:t.currency,timestamp_start:t.timestamp_start,timestamp_end:t.timestamp_end};n=r,e(null,r)},i=(0,s.getThrillConnectClient)();return i.on(a.ConnectEvents.JackpotUpdateEvent,r),()=>{try{i.off(a.ConnectEvents.JackpotUpdateEvent,r)}catch(t){console.log("[ThrillConnect] JackpotUpdate subscription cleanup:",t)}}}],271348),t.s(["subscribeToJackpotWin",0,(t,{next:e})=>{let n=(0,s.getThrillConnectClient)(),r=t=>{e(null,t)};return n.on(a.ConnectEvents.JackpotWinEvent,r),()=>{try{n.off(a.ConnectEvents.JackpotWinEvent,r)}catch(t){console.log("[ThrillConnect] JackpotWin subscription cleanup:",t)}}}],631164),t.s(["subscribeToOptIn",0,function(t,{next:e}){let n=t=>{e(null,t)},r=(0,s.getThrillConnectClient)();return r.on(a.ConnectEvents.OptInEvent,n),()=>{try{r.off(a.ConnectEvents.OptInEvent,n)}catch(t){console.log("[ThrillConnect] OptIn subscription cleanup:",t)}}}],220981),t.s([],129533),t.s(["useThrillConnectStatus",0,function(){let{sessionId:t}=(0,e.useAuth)(),{data:o}=(0,r.default)([n.ThrillConnectSWRKeys.CONNECTION_STATUS,t],i.subscribeToConnection);return o??(0,s.getConnectionState)()}],673467)},628615,968962,t=>{"use strict";let e,n,r,s;var i=Object.defineProperty,o=(t,e,n)=>{let r;return(r="symbol"!=typeof e?e+"":e)in t?i(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n},a=((e=a||{}).ThrillDrops="thrilldrops",e.ThrillConnect="thrillconnect",e.ThrillPots="thrillpots",e.ThrillGate="thrillgate",e),c=((n=c||{}).ConnectionFailed="ws_failed_to_connect",n.Connected="ws_connected",n.Disconnected="ws_disconnected",n.Message="ws_message",n.CampaignStarted="CampaignStarted",n.CampaignEnded="CampaignEnded",n.CampaignDropWin="CampaignDropWin",n.JackpotUpdateEvent="JackpotUpdate",n.OptInEvent="OptInEvent",n.JackpotWinEvent="WinEvent",n.JackpotContributionEvent="ContributionEvent",n.RaffleWinEvent="RaffleWinEvent",n.CurrencyUpdateEvent="CurrencyUpdateEvent",n.PlayerBonusAdded="PlayerBonusAdded",n.PlayerBonusRemoved="PlayerBonusRemoved",n.PlayerBonusUpdated="PlayerBonusUpdated",n.PlayerBonusConsumed="PlayerBonusConsumed",n.PlayerBonusExpired="PlayerBonusExpired",n.PlayerBonusMessage="PlayerBonusResponse",n.AllEvents="*",n);let u={[a.ThrillDrops]:["*","CampaignStarted","CampaignEnded","CampaignDropWin"],[a.ThrillPots]:["*","JackpotUpdate","OptInEvent","WinEvent","ContributionEvent","RaffleWinEvent"],[a.ThrillConnect]:["*","CurrencyUpdateEvent"],[a.ThrillGate]:["PlayerBonusAdded","PlayerBonusRemoved","PlayerBonusUpdated","PlayerBonusConsumed","PlayerBonusExpired","PlayerBonusResponse"]};async function l(t){let e=await fetch(t);if(e.status,"string"==typeof e)throw{message:e};let n=await e.json();if(!e.ok)throw{status:e.status,...n};return n}class h{constructor(t){o(this,"httpHost"),o(this,"brand_context"),o(this,"ws"),o(this,"player_context");const e=t.dev?.secure!==!1;this.httpHost=(e?"https://":"http://")+t.host,this.brand_context=t.brand}setPlayerContext(t,e){this.ws=t,this.player_context=e}async isAuthenticated(){if(null==(this.ws&&this.player_context))return!1;let t=Date.now()+5e3;for(;this.ws?.readyState!==WebSocket.OPEN;){if(this.ws?.readyState===WebSocket.CLOSING||this.ws?.readyState===WebSocket.CLOSED||Date.now()>=t)return!1;await new Promise(t=>setTimeout(t,50))}return!0}brandPair(){return`${this.brand_context.operator_id}:${this.brand_context.brand_id}`}async getSources(){return l(new URL(`${this.httpHost}/v1/thrillpots/sources?owner_id=${this.brandPair()}`))}async getCurrencies(){return l(new URL(`${this.httpHost}/v1/currencies`))}async getJackpotForSource(t,e,n,r){let s=new URL(`${this.httpHost}/v1/thrillpots/instances/source/${t}/brand/${this.brandPair()}`);return this.player_context&&(s.searchParams.append("player_id",this.player_context.id),s.searchParams.append("country_code",this.player_context.country),this.player_context.jurisdiction&&s.searchParams.append("jurisdiction",this.player_context.jurisdiction),this.player_context.segments&&s.searchParams.append("segments",this.player_context.segments.join(","))),e&&s.searchParams.append("game_code",e),n&&s.searchParams.append("game_category",n),r&&s.searchParams.append("vertical_id",r),l(s)}async getLatestWinners(t,e,n){let r=new URL(`${this.httpHost}/v1/thrillpots/instances/${t}/latest_winners`);return e&&r.searchParams.append("brand_id",e),n&&r.searchParams.append("limit",n.toString()),l(r)}async getLatestPotWinners(t,e,n){let r=new URL(`${this.httpHost}/v1/thrillpots/instances/${t}/pot_winners`);return e&&r.searchParams.append("brand_id",e),n&&r.searchParams.append("limit",n.toString()),l(r)}async getTickers(t){return l(new URL(`${this.httpHost}/v1/thrillpots/ticker/${t}`))}async getOptInStatusForSource(t,e){return(await this.getJackpotForSource(t,e).catch(t=>{}))?.optin_status}async optIntoSource(t,e,n,r,s){if(!await this.isAuthenticated())return;!1===e&&(n=void 0);let i={opt_in:e,opt_linked:s||!1,target:{type:"source",id:t},operator_id:this.brand_context.operator_id,country:this.player_context?.country,jurisdiction:this.player_context?.jurisdiction,contribution_preference:{}};void 0!==n?(i.contribution_preference={value:n},r&&(i.contribution_preference={value:n,currency:r})):r&&(i.contribution_preference={currency:r}),this.ws?.send(JSON.stringify({PlayerOptInRequestV2:i}))}async optIntoInstance(t,e,n,r,s){if(!await this.isAuthenticated())return;!1===e&&(n=void 0);let i={opt_in:e,opt_linked:s||!1,target:{type:"instance",id:t},country:this.player_context?.country,jurisdiction:this.player_context?.jurisdiction,contribution_preference:{}};void 0!==n?(i.contribution_preference={value:n},r&&(i.contribution_preference={value:n,currency:r})):r&&(i.contribution_preference={currency:r}),this.ws?.send(JSON.stringify({PlayerOptInRequestV2:i}))}async requestPlayerBonuses(t,e,n){await this.isAuthenticated()&&this.ws?.send(JSON.stringify({PlayerBonusRequest:{bonus_id:t,provider_id:e,game_code:n}}))}}function d(t,e,n,r){if(e===n)return t;let s=e===r.base_currency?1:r.multipliers[e],i=n===r.base_currency?1:r.multipliers[n];if("number"==typeof s&&"number"==typeof i)return t/s*i}
2function p(t,e,n,r,s){let i=d(e,n,r,s);return void 0===i?{currency:n,[t]:e}:{currency:r,[t]:i}}function y(t,e,n){return void 0===d(1,t,e,n)?t:e}function g(t,e,n,r){return{...t,converted:p("current_value",t.current_value,e,n,r)}}function _(t,e,n){let r=t.contribution_type?.Fixed,s="number"==typeof r?p("Fixed",r,t.currency,e,n):void 0,i=t.contribution_values_alt||null,o="number"==typeof r?i?.map(t=>({...t,converted:p("value",t.value,t.currency,e,n)}))||null:i;return{...t,pots:t.pots.map(r=>g(r,t.currency,e,n)),contribution_type:{...t.contribution_type,...s?{converted:s}:{}},contribution_values_alt:o,converted:{currency:y(t.currency,e,n)}}}function v(t,e,n){return{...t,pots:t.pots.map(r=>g(r,t.currency,e,n)),converted:{currency:y(t.currency,e,n)}}}function b(t,e,n){return{...t,converted:p("win_amount",t.win_amount,t.jackpot_currency,e,n)}}function C(t,e,n){return{...t,converted:p("win_amount",t.win_amount,t.currency,e,n)}}function f(t,e,n){let r=t.currency_multipliers||n;return{...t,converted:p("win_amount",t.win_amount,t.jackpot_currency,e,r),community_winners:t.community_winners?.map(t=>C(t,e,r))}}function w(t,e,n){let r=t.currency_multipliers||n;return{...t,winners:t.winners.map(t=>C(t,e,r)),converted:{currency:y(t.jackpot_currency,e,r)}}}function m(t,e,n){return{...t,converted:{...p("contributed_amount",t.contributed_amount,t.contributed_currency,e,n),...p("win_amount",t.win_amount,t.contributed_currency,e,n)}}}class P{constructor(t,e,n){o(this,"delegate"),o(this,"targetCurrency"),o(this,"tableProvider"),this.delegate=t,this.targetCurrency=e,this.tableProvider=n}getCurrencies(){return this.delegate.getCurrencies()}getSources(){return this.delegate.getSources()}async getJackpotForSource(t,e,n,r){let[s,i]=await Promise.all([this.delegate.getJackpotForSource(t,e,n,r),this.tableProvider.getCurrencyTable()]);return _(s,this.targetCurrency,i)}async getLatestWinners(t,e,n){let[r,s]=await Promise.all([this.delegate.getLatestWinners(t,e,n),this.tableProvider.getCurrencyTable()]);return r.map(t=>b(t,this.targetCurrency,s))}async getLatestPotWinners(t,e,n){let[r,s]=await Promise.all([this.delegate.getLatestPotWinners(t,e,n),this.tableProvider.getCurrencyTable()]);return Object.fromEntries(Object.entries(r).map(([t,e])=>[t,e.map(t=>b(t,this.targetCurrency,s))]))}async getTickers(t){let[e,n]=await Promise.all([this.delegate.getTickers(t),this.tableProvider.getCurrencyTable()]);return v(e,this.targetCurrency,n)}getOptInStatusForSource(t,e){return this.delegate.getOptInStatusForSource(t,e)}optIntoSource(t,e,n,r,s){return this.delegate.optIntoSource(t,e,n,r,s)}optIntoInstance(t,e,n,r,s){return this.delegate.optIntoInstance(t,e,n,r,s)}requestPlayerBonuses(t,e,n){return this.delegate.requestPlayerBonuses(t,e,n)}}class S{constructor(t,e){o(this,"client"),o(this,"targetCurrency"),o(this,"requests"),this.client=t,this.targetCurrency=e,this.requests=new P(t.request(),e,t)}request(){return this.requests}on(t,e){let n=this.getWrappedEventHandler(t,e);return this.client.on(t,n),n}once(t,e){let n=this.getWrappedEventHandler(t,e);return this.client.once(t,n)}off(t,e){this.client.off(t,e)}getWrappedEventHandler(t,e){return t===c.JackpotUpdateEvent?async t=>e(v(t,this.targetCurrency,await this.client.getCurrencyTable())):t===c.JackpotWinEvent?async t=>e(f(t,this.targetCurrency,await this.client.getCurrencyTable())):t===c.RaffleWinEvent?async t=>e(w(t,this.targetCurrency,await this.client.getCurrencyTable())):t===c.JackpotContributionEvent?async t=>e(m(t,this.targetCurrency,await this.client.getCurrencyTable())):e}}class E{constructor(t,e,n){o(this,"sourceClient"),o(this,"targetCurrency"),o(this,"tableProvider"),this.sourceClient=t,this.targetCurrency=e,this.tableProvider=n}async getJackpot(t,e,n){let[r,s]=await Promise.all([this.sourceClient.getJackpot(t,e,n),this.tableProvider.getCurrencyTable()]);return _(r,this.targetCurrency,s)}optIn(t,e,n,r){return this.sourceClient.optIn(t,e,n,r)}async getTickers(){let[t,e]=await Promise.all([this.sourceClient.getTickers(),this.tableProvider.getCurrencyTable()]);return t&&v(t,this.targetCurrency,e)}async getLatestWinners(t,e){let[n,r]=await Promise.all([this.sourceClient.getLatestWinners(t,e),this.tableProvider.getCurrencyTable()]);return n.map(t=>b(t,this.targetCurrency,r))}async getLatestPotWinners(t,e){let[n,r]=await Promise.all([this.sourceClient.getLatestPotWinners(t,e),this.tableProvider.getCurrencyTable()]);return Object.fromEntries(Object.entries(n).map(([t,e])=>[t,e.map(t=>b(t,this.targetCurrency,r))]))}getOptInStatus(t){return this.sourceClient.getOptInStatus(t)}on(t,e){let n=this.getWrappedEventHandler(t,e);return this.sourceClient.on(t,n)}once(t,e){let n=this.getWrappedEventHandler(t,e);return this.sourceClient.once(t,n)}off(t,e){this.sourceClient.off(t,e)}withCurrency(t){return Promise.resolve(new E(this.sourceClient,t,this.tableProvider))}getWrappedEventHandler(t,e){return t===c.JackpotUpdateEvent?async t=>e(v(t,this.targetCurrency,await this.tableProvider.getCurrencyTable())):t===c.JackpotWinEvent?async t=>e(f(t,this.targetCurrency,await this.tableProvider.getCurrencyTable())):t===c.RaffleWinEvent?async t=>e(w(t,this.targetCurrency,await this.tableProvider.getCurrencyTable())):t===c.JackpotContributionEvent?async t=>e(m(t,this.targetCurrency,await this.tableProvider.getCurrencyTable())):e}}let T=class{constructor(t,e){o(this,"log"),o(this,"ws"),o(this,"settings"),o(this,"subscribers"),o(this,"requests"),o(this,"destroyed"),o(this,"with_source"),o(this,"events_pipe"),o(this,"currency_table"),o(this,"currency_table_request"),o(this,"currency_updates_handler_registered"),this.log=t.dev?.log?console.log:()=>{},this.settings=t,this.subscribers=new Map,this.requests=new h(t),this.destroyed=!1,this.with_source=new Map,this.events_pipe=e,this.currency_updates_handler_registered=!1,t.player&&this.initializeWebSocket()}async notify(t,e){this.events_pipe&&await this.events_pipe(t,e);let n=this.subscribers.get(t);if(!n)return void this.log("Warn! Received an event with no subscribers ",t);for(let t of n)await t(e)}initializeWebSocket(){let{settings:t,log:e}=this,n=async()=>{e("[x] Websocket connection failed!"),o(),await this.notify(c.ConnectionFailed),this.destroyed||setTimeout(a,1e3)},r=async()=>{e("[i] Websocket connected"),await this.notify(c.Connected),this.subscribeToEvents()},s=async()=>{e("[i] Websocket closed"),await this.notify(c.Disconnected),o(),this.destroyed||setTimeout(a,1e3)},i=t=>{let n=t.data;e("[<] ",n),this.intercept(n).catch(t=>{e("[x] failed to handle websocket message",t)})},o=()=>
2{this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null)},a=()=>{let o=new URL((t.dev?.secure!==!1?"wss://":"ws://")+t.host);o.pathname=`/v1/events/${encodeURIComponent(t.brand.operator_id)}/${encodeURIComponent(t.brand.brand_id)}`,t.player&&(o.searchParams.set("token",t.player.token),o.searchParams.set("currency",t.player.currency)),t.websocket?.include_player_id_query_param&&t.player?.id&&o.searchParams.set("player_id",t.player.id);let a=o.toString();e("[i] Connecting to ",a),this.ws=new WebSocket(a),this.ws.onopen=r,this.ws.onclose=s,this.ws.onerror=n,this.ws.onmessage=i,t.player&&this.requests.setPlayerContext(this.ws,t.player)};a()}subscribeToEvents(t=this.settings.events){let{log:e,ws:n}=this;t?.length||e("No events subscriptions defined."),[a.ThrillDrops,a.ThrillPots,a.ThrillConnect,a.ThrillGate].forEach(r=>{var s;let i,o=new Set(t?.filter(t=>u[r].includes(t))||[]);o.size>0&&(s=Array.from(o),e(`Subscribing to ${r} event: ${s}`),i=s.map(t=>({source:r,event_type:t})),n?.send(JSON.stringify({SubscribeRequest:{events:i}})))})}ensureEventSubscriptions(t){let e=new Set(this.settings.events||[]),n=t.filter(t=>!e.has(t));0!==n.length&&(this.settings.events=Array.from(new Set([...e,...n])),this.ws?.readyState===WebSocket.OPEN&&this.subscribeToEvents(n))}async intercept(t){let{log:e}=this;e("NOTIFY---",t);try{let n=JSON.parse(t);if(!1===["Message","Event"].includes(n.msg_type))return e("[x] unknown message type"),!1;if(!1===Object.values(a).includes(n.source))return e("[x] unknown message source"),!1;await this.notify(c.Message,t),await this.handle(n)}catch{return!1}return!0}async handle(t){var e;let{log:n}=this;n("[i] handling event"),await this.notify("JackpotUpdate"===(e=t.msg_name)?"JackpotUpdate":"WinEvent"===e?"WinEvent":"ContributionEvent"===e?"ContributionEvent":"PlayerBonusResponse"===e?"PlayerBonusResponse":"CurrencyMultipliers"===e?"CurrencyUpdateEvent":c[e],t.data)}checkState(){if(this.destroyed)throw Error("Client has been destroyed. Initialize a new one.")}on(t,e){this.checkState();let{subscribers:n}=this;return void 0===n.get(t)&&n.set(t,[]),n.get(t)?.push(e),e}once(t,e){this.checkState();let n=r=>{e(r),this.off(t,n)};return this.on(t,n),n}off(t,e){if(this.checkState(),!e)return void this.subscribers.delete(t);let n=this.subscribers.get(t);if(!n)return;let r=n.indexOf(e);for(;-1!==r;)n.splice(r,1),r=n.indexOf(e);this.subscribers.set(t,n)}authenticate(t){this.checkState(),this.settings.player=t,this.requests.setPlayerContext(this.ws,t),this.ws||(this.log("No WS connection present! Initializing..."),this.initializeWebSocket())}request(){return this.requests}async getCurrencyTable(){return this.checkState(),this.ensureCurrencyUpdateHandling(),this.currency_table?this.currency_table:(this.currency_table_request||(this.currency_table_request=this.requests.getCurrencies().then(t=>(this.currency_table=t,t)).finally(()=>{this.currency_table_request=void 0})),this.currency_table_request)}ensureCurrencyUpdateHandling(){this.currency_updates_handler_registered||(this.currency_updates_handler_registered=!0,this.on(c.CurrencyUpdateEvent,t=>{this.log("Received updated currencies",t),this.currency_table=t}),this.ensureEventSubscriptions([c.CurrencyUpdateEvent]))}async withCurrency(t){return await this.getCurrencyTable(),new S(this,t)}async withSource(t){let e=this.with_source.get(t);if(!e){let e=(await this.requests.getJackpotForSource(t)).id,n=new I(t,e,this);return this.with_source.set(t,n),n}return e}supportsSettings(t){return this.settings.brand.operator_id===t.brand.operator_id&&this.settings.brand.brand_id===t.brand.brand_id&&this.settings.player?.id===t.player?.id}isConnected(){return this.ws?.readyState===WebSocket.OPEN}updateSettings(t){this.ensureEventSubscriptions(t.events||[])}destroy(){this.ws&&(this.ws.close(),this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws=void 0),this.destroyed=!0,this.with_source=new Map,this.subscribers=new Map,this.currency_table=void 0,this.currency_table_request=void 0}};class k extends h{constructor(t,e){super(t),o(this,"postWSCommand"),this.postWSCommand=e}async optIntoSource(t,e,n,r,s){this.postWSCommand(["optIntoSource",[t,e,n,r,s]])}async optIntoInstance(t,e,n,r,s){this.postWSCommand(["optIntoInstance",[t,e,n,r,s]])}async requestPlayerBonuses(t,e,n){this.postWSCommand(["requestPlayerBonuses",[t,e,n]])}}function W(t){return new SharedWorker("data:text/javascript;charset=utf-8,"+encodeURIComponent('var A=Object.defineProperty;var M=(l,c,g)=>c in l?A(l,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[c]=g;var a=(l,c,g)=>M(l,typeof c!="symbol"?c+"":c,g);(function(){"use strict";var l=(n=>(n.ThrillDrops="thrilldrops",n.ThrillConnect="thrillconnect",n.ThrillPots="thrillpots",n.ThrillGate="thrillgate",n))(l||{}),c=(n=>(n.ConnectionFailed="ws_failed_to_connect",n.Connected="ws_connected",n.Disconnected="ws_disconnected",n.Message="ws_message",n.CampaignStarted="CampaignStarted",n.CampaignEnded="CampaignEnded",n.CampaignDropWin="CampaignDropWin",n.JackpotUpdateEvent="JackpotUpdate",n.OptInEvent="OptInEvent",n.JackpotWinEvent="WinEvent",n.JackpotContributionEvent="ContributionEvent",n.RaffleWinEvent="RaffleWinEvent",n.CurrencyUpdateEvent="CurrencyUpdateEvent",n.PlayerBonusAdded="PlayerBonusAdded",n.PlayerBonusRemoved="PlayerBonusRemoved",n.PlayerBonusUpdated="PlayerBonusUpdated",n.PlayerBonusConsumed="PlayerBonusConsumed",n.PlayerBonusExpired="PlayerBonusExpired",n.PlayerBonusMessage="PlayerBonusResponse",n.AllEvents="*",n))(c||{});const g={[l.ThrillDrops]:["*","CampaignStarted","CampaignEnded","CampaignDropWin"],[l.ThrillPots]:["*","JackpotUpdate","OptInEvent","WinEvent","ContributionEvent","RaffleWinEvent"],[l.ThrillConnect]:["*","CurrencyUpdateEvent"],[l.ThrillGate]:["PlayerBonusAdded","PlayerBonusRemoved","PlayerBonusUpdated","PlayerBonusConsumed","PlayerBonusExpired","PlayerBonusResponse"]};function H(n){return n==="JackpotUpdate"?"JackpotUpdate":n==="WinEvent"?"WinEvent":n==="ContributionEvent"?"ContributionEvent":n==="PlayerBonusResponse"?"PlayerBonusResponse":n==="CurrencyMultipliers"?"CurrencyUpdateEvent":c[n]}const L=5e3;async function w(n){let t=await fetch(n);if(t.status,typeof t=="string")throw{message:t};let e=await t.json();if(!t.ok)throw{status:t.status,...e};return e}class F{constructor(t){a(this,"httpHost");a(this,"brand_context");a(this,"ws");a(this,"player_context");const e=t.dev?.secure!==!1;this.httpHost=(e?"https://":"http://")+t.host,this.brand_context=t.brand}setPlayerContext(t,e){this.ws=t,this.player_context=e}async isAuthenticated(){if((this.ws&&this.player_context)==null)return!1;const t=Date.now()+L;for(;this.ws?.readyState!==WebSocket.OPEN;){if(this.ws?.readyState===WebSocket.CLOSING||this.ws?.readyState===WebSocket.CLOSED||Date.now()>=t)return!1;await new Promise(e=>setTimeout(e,50))}return!0}brandPair(){return`${this.brand_context.operator_id}:${this.brand_context.brand_id}`}async getSources(){const t=new URL(`${this.httpHost}/v1/thrillpots/sources?owner_id=${this.brandPair()}`);return w(t)}async getCurrencies(){const t=new URL(`${this.httpHost}/v1/currencies`);return w(t)}async getJackpotForSource(t,e,r,s){let i=new URL(`${this.httpHost}/v1/thrillpots/instances/source/${t}/brand/${this.brandPair()}`);return this.player_context&&(i.searchParams.append("player_id",this.player_context.
2id),i.searchParams.append("country_code",this.player_context.country),this.player_context.jurisdiction&&i.searchParams.append("jurisdiction",this.player_context.jurisdiction),this.player_context.segments&&i.searchParams.append("segments",this.player_context.segments.join(","))),e&&i.searchParams.append("game_code",e),r&&i.searchParams.append("game_category",r),s&&i.searchParams.append("vertical_id",s),w(i)}async getLatestWinners(t,e=void 0,r=void 0){const s=new URL(`${this.httpHost}/v1/thrillpots/instances/${t}/latest_winners`);return e&&s.searchParams.append("brand_id",e),r&&s.searchParams.append("limit",r.toString()),w(s)}async getLatestPotWinners(t,e=void 0,r=void 0){const s=new URL(`${this.httpHost}/v1/thrillpots/instances/${t}/pot_winners`);return e&&s.searchParams.append("brand_id",e),r&&s.searchParams.append("limit",r.toString()),w(s)}async getTickers(t){const e=new URL(`${this.httpHost}/v1/thrillpots/ticker/${t}`);return w(e)}async getOptInStatusForSource(t,e){return(await this.getJackpotForSource(t,e).catch(s=>{}))?.optin_status}async optIntoSource(t,e,r,s,i){if(!await this.isAuthenticated())return;e===!1&&(r=void 0);const o={opt_in:e,opt_linked:i||!1,target:{type:"source",id:t},operator_id:this.brand_context.operator_id,country:this.player_context?.country,jurisdiction:this.player_context?.jurisdiction,contribution_preference:{}};r!==void 0?(o.contribution_preference={value:r},s&&(o.contribution_preference={value:r,currency:s})):s&&(o.contribution_preference={currency:s}),this.ws?.send(JSON.stringify({PlayerOptInRequestV2:o}))}async optIntoInstance(t,e,r,s,i){if(!await this.isAuthenticated())return;e===!1&&(r=void 0);const o={opt_in:e,opt_linked:i||!1,target:{type:"instance",id:t},country:this.player_context?.country,jurisdiction:this.player_context?.jurisdiction,contribution_preference:{}};r!==void 0?(o.contribution_preference={value:r},s&&(o.contribution_preference={value:r,currency:s})):s&&(o.contribution_preference={currency:s}),this.ws?.send(JSON.stringify({PlayerOptInRequestV2:o}))}async requestPlayerBonuses(t=void 0,e=void 0,r=void 0){if(!await this.isAuthenticated())return;let i={bonus_id:t,provider_id:e,game_code:r};this.ws?.send(JSON.stringify({PlayerBonusRequest:i}))}}function S(n,t,e,r){if(t===e)return n;const s=t===r.base_currency?1:r.multipliers[t],i=e===r.base_currency?1:r.multipliers[e];if(!(typeof s!="number"||typeof i!="number"))return n/s*i}function p(n,t,e,r,s){const i=S(t,e,r,s);return i===void 0?{currency:e,[n]:t}:{currency:r,[n]:i}}function v(n,t,e){return S(1,n,t,e)===void 0?n:t}function k(n,t,e,r){return{...n,converted:p("current_value",n.current_value,t,e,r)}}function W(n,t,e){const r=n.contribution_type?.Fixed,s=typeof r=="number"?p("Fixed",r,n.currency,t,e):void 0,i=n.contribution_values_alt||null,u=typeof r=="number"?i?.map(o=>({...o,converted:p("value",o.value,o.currency,t,e)}))||null:i;return{...n,pots:n.pots.map(o=>k(o,n.currency,t,e)),contribution_type:{...n.contribution_type,...s?{converted:s}:{}},contribution_values_alt:u,converted:{currency:v(n.currency,t,e)}}}function m(n,t,e){return{...n,pots:n.pots.map(r=>k(r,n.currency,t,e)),converted:{currency:v(n.currency,t,e)}}}function b(n,t,e){return{...n,converted:p("win_amount",n.win_amount,n.jackpot_currency,t,e)}}function E(n,t,e){return{...n,converted:p("win_amount",n.win_amount,n.currency,t,e)}}function I(n,t,e){return m(n,t,e)}function q(n,t,e){const r=n.currency_multipliers||e;return{...n,converted:p("win_amount",n.win_amount,n.jackpot_currency,t,r),community_winners:n.community_winners?.map(s=>E(s,t,r))}}function J(n,t,e){const r=n.currency_multipliers||e;return{...n,winners:n.winners.map(s=>E(s,t,r)),converted:{currency:v(n.jackpot_currency,t,r)}}}function O(n,t,e){return{...n,converted:{...p("contributed_amount",n.contributed_amount,n.contributed_currency,t,e),...p("win_amount",n.win_amount,n.contributed_currency,t,e)}}}class ${constructor(t,e,r){a(this,"delegate");a(this,"targetCurrency");a(this,"tableProvider");this.delegate=t,this.targetCurrency=e,this.tableProvider=r}getCurrencies(){return this.delegate.getCurrencies()}getSources(){return this.delegate.getSources()}async getJackpotForSource(t,e,r,s){const[i,u]=await Promise.all([this.delegate.getJackpotForSource(t,e,r,s),this.tableProvider.getCurrencyTable()]);return W(i,this.targetCurrency,u)}async getLatestWinners(t,e=void 0,r=void 0){const[s,i]=await Promise.all([this.delegate.getLatestWinners(t,e,r),this.tableProvider.getCurrencyTable()]);return s.map(u=>b(u,this.targetCurrency,i))}async getLatestPotWinners(t,e=void 0,r=void 0){const[s,i]=await Promise.all([this.delegate.getLatestPotWinners(t,e,r),this.tableProvider.getCurrencyTable()]);return Object.fromEntries(Object.entries(s).map(([u,o])=>[u,o.map(h=>b(h,this.targetCurrency,i))]))}async getTickers(t){const[e,r]=await Promise.all([this.delegate.getTickers(t),this.tableProvider.getCurrencyTable()]);return m(e,this.targetCurrency,r)}getOptInStatusForSource(t,e){return this.delegate.getOptInStatusForSource(t,e)}optIntoSource(t,e,r,s,i){return this.delegate.optIntoSource(t,e,r,s,i)}optIntoInstance(t,e,r,s,i){return this.delegate.optIntoInstance(t,e,r,s,i)}requestPlayerBonuses(t,e,r){return this.delegate.requestPlayerBonuses(t,e,r)}}class j{constructor(t,e){a(this,"client");a(this,"targetCurrency");a(this,"requests");this.client=t,this.targetCurrency=e,this.requests=new $(t.request(),e,t)}request(){return this.requests}on(t,e){const r=this.getWrappedEventHandler(t,e);return this.client.on(t,r),r}once(t,e){const r=this.getWrappedEventHandler(t,e);return this.client.once(t,r)}off(t,e){this.client.off(t,e)}getWrappedEventHandler(t,e){return t===c.JackpotUpdateEvent?async r=>e(I(r,this.targetCurrency,await this.client.getCurrencyTable())):t===c.JackpotWinEvent?async r=>e(q(r,this.targetCurrency,await this.client.getCurrencyTable())):t===c.RaffleWinEvent?async r=>e(J(r,this.targetCurrency,await this.client.getCurrencyTable())):t===c.JackpotContributionEvent?async r=>e(O(r,this.targetCurrency,await this.client.getCurrencyTable())):e}}class P{constructor(t,e,r){a(this,"sourceClient");a(this,"targetCurrency");a(this,"tableProvider");this.sourceClient=t,this.targetCurrency=e,this.tableProvider=r}async getJackpot(t,e,r){const[s,i]=await Promise.all([this.sourceClient.getJackpot(t,e,r),this.tableProvider.getCurrencyTable()]);return W(s,this.targetCurrency,i)}optIn(t,e,r,s){return this.sourceClient.optIn(t,e,r,s)}async getTickers(){const[t,e]=await Promise.all([this.sourceClient.getTickers(),this.tableProvider.getCurrencyTable()]);return t&&m(t,this.targetCurrency,e)}async getLatestWinners(t=void 0,e=void 0){const[r,s]=await Promise.all([this.sourceClient.getLatestWinners(t,e),this.tableProvider.getCurrencyTable()]);return r.map(i=>b(i,this.targetCurrency,s))}async getLatestPotWinners(t=void 0,e=void 0){const[r,s]=await Promise.all([this.sourceClient.getLatestPotWinners(t,e),this.tableProvider.getCurrencyTable()]);return Object.fromEntries(Object.entries(r).map(([i,u])=>[i,u.map(o=>b(o,this.targetCurrency,s))]))}getOptInStatus(t){return this.sourceClient.getOptInStatus(t)}on(t,e){const r=this.getWrappedEventHandler(t,e);return this.sourceClient.on(t,r)}once(t,e){const r=this.getWrappedEventHandler(t,e);return this.sourceClient.once(t,r)}off(t,e){this.sourceClient.off(t,e)}withCurrency(t){return Promise.resolve(new P(this.sourceClient,t,this.tableProvider))}getWrappedEventHandler(t,e){return t===c.JackpotUpdateEvent?async r=>e(I(r,this.targetCurrency,await this.tableProvider.getCurrencyTable())):t===c.JackpotWinEvent?async r=>e(q(r,this.targetCurrency,await this.tableProvider.getCurrencyTable())):t===c.RaffleWinEvent?async r=>e(J(r,this.targetCurrency,await this.tableProvider.getCurrencyTable())):t===c.JackpotContributionEvent?async r=>e(O(r,this.targetCurrency,await this.tableProvider.getCurrencyTable())):e}}const x=1e3;let T=class{constructor(t,e=void 0){a(this,"log");a(this,"ws");a(this,"settings");a(this,"subscribers");a(this,"requests");a(this,"destroyed");a(this,"with_source");a(this,"events_pipe");a(this,"currency_table");a(this,"currency_table_request");a(this,"currency_updates_handler_registered");this.log=t.dev?.log?console.log:()=>{},this.settings=t,this.subscribers=new Map,this.requests=new F(t),this.destroyed=!1,this.with_source=new Map,this.events_pipe=e,this.currency_updates_handler_registered=!1,t.player&&this.initializeWebSocket()}async notify(t,e){this.events_pipe&&await this.events_pipe(t,e);const r=this.subscribers.get(t);if(!r){this.log("Warn! Received an event with no subscribers ",t);return}for(const s of r)await s(e)}initializeWebSocket(){const{settings:t,log:e}=this,r=async()=>{e("[x] Websocket connection failed!"),o(),await this.notify(c.ConnectionFailed),this.destroyed||setTimeout(h,x)},s=async()=>{e("[i] Websocket connected"),await this.notify(c.Connected),this.subscribeToEvents()},i=async()=>{e("[i] Websocket closed"),await this.notify(c.Disconnected),o(),this.destroyed||setTimeout(h,x)},u=C=>{const f=C.data;e("[<] ",f),this.intercept(f).catch(_=>{e("[x] failed to handle websocket message",_)})},o=()=>
2{this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null)},h=()=>{const C=t.dev?.secure!==!1,f=new URL((C?"wss://":"ws://")+t.host);f.pathname=`/v1/events/${encodeURIComponent(t.brand.operator_id)}/${encodeURIComponent(t.brand.brand_id)}`,t.player&&(f.searchParams.set("token",t.player.token),f.searchParams.set("currency",t.player.currency)),t.websocket?.include_player_id_query_param&&t.player?.id&&f.searchParams.set("player_id",t.player.id);const _=f.toString();e("[i] Connecting to ",_),this.ws=new WebSocket(_),this.ws.onopen=s,this.ws.onclose=i,this.ws.onerror=r,this.ws.onmessage=u,t.player&&this.requests.setPlayerContext(this.ws,t.player)};h()}subscribeToEvents(t=this.settings.events){const{log:e,ws:r}=this,s=(i,u)=>{e(`Subscribing to ${i} event: ${u}`);const o=u.map(h=>({source:i,event_type:h}));r?.send(JSON.stringify({SubscribeRequest:{events:o}}))};t?.length||e("No events subscriptions defined."),[l.ThrillDrops,l.ThrillPots,l.ThrillConnect,l.ThrillGate].forEach(i=>{const u=t?.filter(h=>g[i].includes(h))||[],o=new Set(u);o.size>0&&s(i,Array.from(o))})}ensureEventSubscriptions(t){const e=new Set(this.settings.events||[]),r=t.filter(s=>!e.has(s));r.length!==0&&(this.settings.events=Array.from(new Set([...e,...r])),this.ws?.readyState===WebSocket.OPEN&&this.subscribeToEvents(r))}async intercept(t){const{log:e}=this;e("NOTIFY---",t);try{const r=JSON.parse(t);if(["Message","Event"].includes(r.msg_type)===!1)return e("[x] unknown message type"),!1;if(Object.values(l).includes(r.source)===!1)return e("[x] unknown message source"),!1;await this.notify(c.Message,t),await this.handle(r)}catch{return!1}return!0}async handle(t){const{log:e}=this;e("[i] handling event"),await this.notify(H(t.msg_name),t.data)}checkState(){if(this.destroyed)throw new Error("Client has been destroyed. Initialize a new one.")}on(t,e){this.checkState();const{subscribers:r}=this;return r.get(t)===void 0&&r.set(t,[]),r.get(t)?.push(e),e}once(t,e){this.checkState();const r=s=>{e(s),this.off(t,r)};return this.on(t,r),r}off(t,e){if(this.checkState(),!e){this.subscribers.delete(t);return}const r=this.subscribers.get(t);if(!r)return;let s=r.indexOf(e);for(;s!==-1;)r.splice(s,1),s=r.indexOf(e);this.subscribers.set(t,r)}authenticate(t){this.checkState(),this.settings.player=t,this.requests.setPlayerContext(this.ws,t),this.ws||(this.log("No WS connection present! Initializing..."),this.initializeWebSocket())}request(){return this.requests}async getCurrencyTable(){return this.checkState(),this.ensureCurrencyUpdateHandling(),this.currency_table?this.currency_table:(this.currency_table_request||(this.currency_table_request=this.requests.getCurrencies().then(t=>(this.currency_table=t,t)).finally(()=>{this.currency_table_request=void 0})),this.currency_table_request)}ensureCurrencyUpdateHandling(){this.currency_updates_handler_registered||(this.currency_updates_handler_registered=!0,this.on(c.CurrencyUpdateEvent,t=>{this.log("Received updated currencies",t),this.currency_table=t}),this.ensureEventSubscriptions([c.CurrencyUpdateEvent]))}async withCurrency(t){return await this.getCurrencyTable(),new j(this,t)}async withSource(t){const e=this.with_source.get(t);if(!e){const r=(await this.requests.getJackpotForSource(t)).id,s=new N(t,r,this);return this.with_source.set(t,s),s}return e}supportsSettings(t){return this.settings.brand.operator_id===t.brand.operator_id&&this.settings.brand.brand_id===t.brand.brand_id&&this.settings.player?.id===t.player?.id}isConnected(){return this.ws?.readyState===WebSocket.OPEN}updateSettings(t){this.ensureEventSubscriptions(t.events||[])}destroy(){this.ws&&(this.ws.close(),this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws=void 0),this.destroyed=!0,this.with_source=new Map,this.subscribers=new Map,this.currency_table=void 0,this.currency_table_request=void 0}};class N{constructor(t,e,r){a(this,"source_id");a(this,"instance_id");a(this,"client");this.source_id=t,this.instance_id=e,this.client=r}getJackpot(t,e,r){return this.client.request().getJackpotForSource(this.source_id,t,e,r)}optIn(t,e,r,s){return this.client.request().optIntoInstance(this.instance_id,t,e,r,s)}getTickers(){return this.client.request().getTickers(this.instance_id)}getLatestWinners(t=void 0,e=void 0){return this.client.request().getLatestWinners(this.instance_id,t,e)}
2getLatestPotWinners(t=void 0,e=void 0){return this.client.request().getLatestPotWinners(this.instance_id,t,e)}getOptInStatus(t){return this.client.request().getOptInStatusForSource(this.source_id,t)}async withCurrency(t){return await this.client.getCurrencyTable(),new P(this,t,this.client)}on(t,e){const r=this.getWrappedEventHandler(t,e);return this.client.on(t,r),r}once(t,e){const r=this.getWrappedEventHandler(t,e);return this.client.once(t,r)}off(t,e){this.client.off(t,e)}getWrappedEventHandler(t,e){const r=i=>{i.id===this.instance_id&&e(i)},s=i=>{i.instance_id===this.instance_id&&e(i)};return t===c.JackpotUpdateEvent?r:t===c.JackpotWinEvent?s:e}}let d;const y=new Set,U=()=>{y.size==0&&d&&(d.destroy(),d=null)},R=n=>{for(const t of y)try{t.postMessage(n)}catch{y.delete(t)}U()};onconnect=n=>{const t=n.ports[0];t.start(),y.add(t),t.addEventListener("message",e=>{let[r,s]=e.data;if(r==="initialize"){const i=s[0];if(d)if(d.supportsSettings(i))d.updateSettings(i),d.authenticate(i?.player),d.isConnected()&&t.postMessage(JSON.stringify({eventType:"ws_connected"}));else{d.destroy(),d=new T(i,B);for(let u of y)u!==t&&u.close();y.clear(),y.add(t)}else d=new T(i,B)}else r==="close"?(t.close(),y.delete(t),U()):r==="authenticate"?d.authenticate(...s):r==="updateSettings"?d.updateSettings(...s):r==="optIntoSource"?d.request().optIntoSource(...s):r==="optIntoInstance"?d.request().optIntoInstance(...s):r==="requestPlayerBonuses"?d.request().requestPlayerBonuses(...s):R(JSON.stringify({eventType:"warning",data:{message:`Unknown worker method: ${String(r)}`}}))})};const B=(n,t)=>{R(JSON.stringify({eventType:n,data:t}))}})();\n'),{name:t?.name})}class I{constructor(t,e,n){o(this,"source_id"),o(this,"instance_id"),o(this,"client"),this.source_id=t,this.instance_id=e,this.client=n}getJackpot(t,e,n){return this.client.request().getJackpotForSource(this.source_id,t,e,n)}optIn(t,e,n,r){return this.client.request().optIntoInstance(this.instance_id,t,e,n,r)}getTickers(){return this.client.request().getTickers(this.instance_id)}getLatestWinners(t,e){return this.client.request().getLatestWinners(this.instance_id,t,e)}getLatestPotWinners(t,e){return this.client.request().getLatestPotWinners(this.instance_id,t,e)}getOptInStatus(t){return this.client.request().getOptInStatusForSource(this.source_id,t)}async withCurrency(t){return await this.client.getCurrencyTable(),new E(this,t,this.client)}on(t,e){let n=this.getWrappedEventHandler(t,e);return this.client.on(t,n),n}once(t,e){let n=this.getWrappedEventHandler(t,e);return this.client.once(t,n)}off(t,e){this.client.off(t,e)}getWrappedEventHandler(t,e){let n=t=>{t.id===this.instance_id&&e(t)},r=t=>{t.instance_id===this.instance_id&&e(t)};return t===c.JackpotUpdateEvent?n:t===c.JackpotWinEvent?r:e}}var O=((r=O||{}).Jackpot="Jackpot",r.Raffle="Raffle",r),J=((s=J||{}).Running="Running",s.Pending="Pending",s.Paused="Paused",s);class R{constructor(t){window.SharedWorker&&!t.disable_worker?this.impl=new U(t):this.impl=new T(t)}on(t,e){return this.impl.on(t,e)}once(t,e){return this.impl.once(t,e)}off(t,e){return this.impl.off(t,e)}authenticate(t){return this.impl.authenticate(t)}request(){return this.impl.request()}async withSource(t){return this.impl.withSource(t)}async withCurrency(t){return this.impl.withCurrency(t)}destroy(){this.impl?.destroy(),this.impl=null}}class U extends T{constructor(t){super({...t,player:void 0}),o(this,"worker"),o(this,"worker_request"),this.worker_request=new k(this.settings,this.postWS.bind(this)),t.player&&this.initWorker(t.player)}initWorker(t){let e=new W;this.worker=e,this.worker_request.setPlayerContext(void 0,t),e.port.start(),e.port.postMessage(["initialize",[{...this.settings,player:t}]]),e.port.onmessage=t=>{try{let{eventType:e,data:n}=JSON.parse(t.data);this.notify(e,n)}catch{}},window.addEventListener("beforeunload",()=>e?.port?.postMessage(["close"]))}authenticate(t){this.checkState(),this.worker_request.setPlayerContext(void 0,t),this.worker?this.postWS(["authenticate",[t]]):this.initWorker(t)}postWS(t){this.worker?.port?.postMessage(t)}ensureEventSubscriptions(t){super.ensureEventSubscriptions(t),this.postWS(["updateSettings",[{events:t}]])}request(){return this.worker_request}destroy(){this?.worker?.port&&(this.worker.port.postMessage(["close"]),this.worker.port.close()),super.destroy()}}t.s(["ConnectEvents",0,c,"ThrillConnect",0,R],968962);let q=null,x=!1;t.s(["destroyThrillConnectClient",0,function(){q&&(q.destroy(),q=null,x=!1)},"getConnectionState",0,function(){return x},"getThrillConnectClient",0,function(){if(q)return q;let[t,e]="tma:klirr".split(":");return(q=new R({host:"connect-tma.production.thrilltechapi-saas.com",brand:{operator_id:t,brand_id:e},events:[c.JackpotUpdateEvent,c.JackpotWinEvent,c.OptInEvent,c.Connected,c.Disconnected,c.ConnectionFailed],dev:{log:!1,secure:!0},disable_worker:!0})).on(c.Connected,()=>{x=!0}),q.on(c.Disconnected,()=>{x=!1}),q.on(c.ConnectionFailed,()=>{x=!1}),q},"setConnectionState",0,function(t){x=t}],628615)},664287,t=>{"use strict";t.i(989249);var e=t.i(479017),n=t.i(858050),r=t.i(183330);function s(t){return Math.max(0,Math.min(1,t))}function i(t,e){let n=s(t/e),r=.5+.5*(1-Math.pow(1-s(1.1*n),2));return s(r=Math.min(r,.99))}function o(t){return"SEK"===t&&"EUR"===e.AppConfig.currency?.087:1}function a(t,n){if(!t)return 1;if(!n)return o(t);let s=n.multipliers??{},i=function(t,e,n){if(t===e)return 1;let r=n[e],s=n[t];return r&&s?r/s:1}(t,e.AppConfig.currency,s);return 1!==i||t===e.AppConfig.currency?i:((0,r.addBreadcrumb)({category:"jackpot",message:"Currency conversion fallback used (rate missing from multipliers table)",level:"warning",data:{jackpotCurrency:t,playerCurrency:e.AppConfig.currency}}),o(t))}t.s(["convertAmount",0,function(t,e,n){return t*a(e,n)},"convertPots",0,function(t,e,n){let r=a(e,n);return 1===r?t:t.map(t=>({...t,current_value:t.current_value*r}))},"formatContributionAmount",0,(t,e)=>{let r=n.JackpotConfig.contributionOptions.find(e=>e.amount===t);return r?.key==="max"?"MAX":t?e(t):""},"getJackpotProgress",0,i,"getPotHotness",0,(t,e)=>{let r=n.JackpotConfig.mustDropAt[t];if(!r)return"normal";let s=i(e,r);return s>=.85?"superhot":s>=.7?"hot":"normal"}],664287)}]);
3
4//# debugId=54200748-8cc3-b1b9-0842-cb4b88c14401

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.