@goodgamestudios/cxf-webshop 7.0.0-qa.17 → 7.0.0-qa.19

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.
@@ -1,2 +1,1540 @@
1
- "use strict";(()=>{var Be=Object.create;var ce=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var Je=(e,t)=>()=>(e&&(t=e(e=0)),t);var T=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of je(t))!Ze.call(e,i)&&i!==r&&ce(e,i,{get:()=>t[i],enumerable:!(o=Ve(t,i))||o.enumerable});return e};var H=(e,t,r)=>(r=e!=null?Be($e(e)):{},Ye(t||!e||!e.__esModule?ce(r,"default",{value:e,enumerable:!0}):r,e));var l,s=Je(()=>{l={env:{BASE_URL:"https://canvas-test.goodgamestudios.com",CANVAS_AGENT_URL:"https://app.canvas.stillfront.com/agent.js",CANVAS_APP_ID_BY_GAME:{"12":"81199abb-592e-465c-b926-8656628a64c7","15":{google:"25facd0c-e850-4ebf-b6c4-8c60240e4cf8",stillpay:"bec451f9-8db4-4ca1-8a5a-54494429ff5e"},"16":"18f5521d-7df2-4bb3-88a3-c162ba072d73"},CUSTOMIZATION_URL_TEMPLATE:"https://cdn.jsdelivr.net/npm/@lemonstand.org/config-goodgamestudios@{1}/dist/goodgamestudios-{0}.json",CUSTOMIZATION_URL:"https://cdn.jsdelivr.net/npm/@lemonstand.org/config-goodgamestudios@qa/dist/goodgamestudios-{0}.json"}}});var ue=T((Nt,fe)=>{s();var N=1e3,L=N*60,U=L*60,P=U*24,Qe=P*7,We=P*365.25;fe.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Ke(e);if(r==="number"&&isFinite(e))return t.long?tt(e):et(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ke(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*We;case"weeks":case"week":case"w":return r*Qe;case"days":case"day":case"d":return r*P;case"hours":case"hour":case"hrs":case"hr":case"h":return r*U;case"minutes":case"minute":case"mins":case"min":case"m":return r*L;case"seconds":case"second":case"secs":case"sec":case"s":return r*N;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function et(e){var t=Math.abs(e);return t>=P?Math.round(e/P)+"d":t>=U?Math.round(e/U)+"h":t>=L?Math.round(e/L)+"m":t>=N?Math.round(e/N)+"s":e+"ms"}function tt(e){var t=Math.abs(e);return t>=P?j(e,t,P,"day"):t>=U?j(e,t,U,"hour"):t>=L?j(e,t,L,"minute"):t>=N?j(e,t,N,"second"):e+" ms"}function j(e,t,r,o){var i=t>=r*1.5;return Math.round(e/r)+" "+o+(i?"s":"")}});var ge=T((Ut,le)=>{s();function rt(e){r.debug=r,r.default=r,r.coerce=x,r.disable=h,r.enable=i,r.enabled=w,r.humanize=ue(),r.destroy=E,Object.keys(e).forEach(c=>{r[c]=e[c]}),r.names=[],r.skips=[],r.formatters={};function t(c){let a=0;for(let m=0;m<c.length;m++)a=(a<<5)-a+c.charCodeAt(m),a|=0;return r.colors[Math.abs(a)%r.colors.length]}r.selectColor=t;function r(c){let a,m=null,C,v;function u(...g){if(!u.enabled)return;let I=u,S=Number(new Date),F=S-(a||S);I.diff=F,I.prev=a,I.curr=S,a=S,g[0]=r.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let b=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(_,ee)=>{if(_==="%%")return"%";b++;let ae=r.formatters[ee];if(typeof ae=="function"){let He=g[b];_=ae.call(I,He),g.splice(b,1),b--}return _}),r.formatArgs.call(I,g),(I.log||r.log).apply(I,g)}return u.namespace=c,u.useColors=r.useColors(),u.color=r.selectColor(c),u.extend=o,u.destroy=r.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(C!==r.namespaces&&(C=r.namespaces,v=r.enabled(c)),v),set:g=>{m=g}}),typeof r.init=="function"&&r.init(u),u}function o(c,a){let m=r(this.namespace+(typeof a>"u"?":":a)+c);return m.log=this.log,m}function i(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let a=(typeof c=="string"?c:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of a)m[0]==="-"?r.skips.push(m.slice(1)):r.names.push(m)}function f(c,a){let m=0,C=0,v=-1,u=0;for(;m<c.length;)if(C<a.length&&(a[C]===c[m]||a[C]==="*"))a[C]==="*"?(v=C,u=m,C++):(m++,C++);else if(v!==-1)C=v+1,u++,m=u;else return!1;for(;C<a.length&&a[C]==="*";)C++;return C===a.length}function h(){let c=[...r.names,...r.skips.map(a=>"-"+a)].join(",");return r.enable(""),c}function w(c){for(let a of r.skips)if(f(c,a))return!1;for(let a of r.names)if(f(c,a))return!0;return!1}function x(c){return c instanceof Error?c.stack||c.message:c}function E(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}le.exports=rt});var me=T((y,$)=>{s();y.formatArgs=ot;y.save=st;y.load=it;y.useColors=nt;y.storage=at();y.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();y.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function nt(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ot(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+$.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(r++,i==="%c"&&(o=r))}),e.splice(o,0,t)}y.log=console.debug||console.log||(()=>{});function st(e){try{e?y.storage.setItem("debug",e):y.storage.removeItem("debug")}catch{}}function it(){let e;try{e=y.storage.getItem("debug")||y.storage.getItem("DEBUG")}catch{}return!e&&typeof l<"u"&&"env"in l&&(e=l.env.DEBUG),e}function at(){try{return localStorage}catch{}}$.exports=ge()(y);var{formatters:ct}=$.exports;ct.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var te=T((Ht,Se)=>{"use strict";s();var Z=window&&window.CXF;Se.exports=new Promise(function(e,t){if(window||t(),Z)return e(Z);window.addEventListener("cxf.initialized",function(r){Z=r.cxf,e(Z)},{capture:!0,once:!0,passive:!0})})});var Pe=T((Oe,re)=>{s();(function(){var e={};function t(u,g){return i(u)||o(u,g)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function o(u,g){var I=[],S=!0,F=!1,b=void 0;try{for(var K,_=u[Symbol.iterator]();!(S=(K=_.next()).done)&&(I.push(K.value),!g||I.length!==g);S=!0);}catch(ee){F=!0,b=ee}finally{try{S||_.return==null||_.return()}finally{if(F)throw b}}return I}function i(u){if(Array.isArray(u))return u}var f=0,h=1,w=2,x={1:["poker","poker2","poker"],12:["empire","castle","em"],15:["bigfarm","ranch","bf"],16:["empirefourkingdoms","fourkingdoms","e4k"],23:["legendsofhonor",void 0,"loh"],41:["empiremillenniumwars",void 0,"emmw"]},E=Object.entries(x).reduce(function(u,g){var I=t(g,2),S=I[0],F=I[1];return S=parseInt(S,10),u[S]=S,F.forEach(function(b){u[b]=S}),u},{}),c=function(u){u=u.toString().toLowerCase();var g=E[u];return g&&0|g},a=function(u,g){return(g=E[g])&&x[g][u]},m=a.bind(null,f),C=a.bind(null,h),v=a.bind(null,w);e={id:c,name:m,codename:C,acronym:v},typeof Oe=="object"&&typeof re<"u"?re.exports=e:typeof define=="function"&&define.amd&&define(function(){return e})})()});var se=T(z=>{"use strict";s();Object.defineProperty(z,"__esModule",{value:!0});z.CxfEvents=void 0;var gt;(function(e){e.Token="cxf.token",e.Login="cxf.login",e.Signup="cxf.signup",e.GameEventUpdate="cxf.gameEvent.update",e.GameEventAdd="cxf.gameEvent.add",e.GameEventRemove="cxf.gameEvent.remove",e.XpChanged="cxf.xp.changed",e.LevelChanged="cxf.level.changed",e.LegendLevelChanged="cxf.legendLevel.changed",e.Push="cxf.push",e.OpenIGS="cxf.igs.open",e.JoinTempServer="cxf.join.temp.server",e.Subscription="cxf.subscription",e.RewardedAdStart="cxf.rewardedad.start",e.RewardedAdDone="cxf.rewardedad.done"})(gt=z.CxfEvents||(z.CxfEvents={}))});s();s();s();s();s();s();var O=256,V=[],B;for(;O--;)V[O]=(O+256).toString(16).substring(1);function de(){var e=0,t,r="";if(!B||O+16>256){for(B=Array(e=256);e--;)B[e]=256*Math.random()|0;e=O=0}for(;e<16;e++)t=B[O+e],e==6?r+=V[t&15|64]:e==8?r+=V[t&63|128]:r+=V[t],e&1&&e>1&&e<11&&(r+="-");return O++,r}var he=H(me());s();var R=class extends Error{constructor(t,r){super(`${t} has null value: ${r}`),this.name="ArgumentNullError"}};s();var dt=(e,t)=>{let r=setTimeout(e,t);return()=>clearTimeout(r)},pe=(e,t)=>r=>new Promise((o,i)=>{let f=dt(()=>{i(new Error(`Timeout has exceeded ${t}`))},t);e(r).then(h=>{o(h),f()}).catch(i)}),Ce=e=>{for(let t of Object.keys(e)){let r=e[t];if(r==null||Number.isNaN(r))throw new R(t,r)}};function Ie(e){return Math.floor(e/1e3)}var ve=e=>{let t=e.match(/^https?:\/\/([^#/?]+)(?:[#/?]|$)/i);if(!t||!t[1])return;let r=t[1].match(/[^.]+\.[^.]+$/);if(r)return r[0]};function ft({gameId:e,networkId:t,instanceId:r,playerId:o}){return[e,t,r,o].join("-")}var Ee=(e="stillpay")=>{let t=navigator.userAgent.match(/(itunes)|(googleplay)|(Android)|(amazonmobile)|(facebook)|(samsung)|(huawei)/g);if(!t)return e;let r=t[0],o={itunes:"apple",Android:"google",googleplay:"google",amazonmobile:"amazon",facebook:"facebook",samsung:"samsung",huawei:"huawei"};return Object.prototype.hasOwnProperty.call(o,r)?o[r]:e};function ye(e){return Object.entries(e).filter(([t,r])=>r!=null).map(([t,r])=>`${t}=${encodeURIComponent(r)}`).join("&")}var J=e=>{let{playerId:t,token:r,zoneId:o,language:i}=e;if(!t)throw new R("playerId",t);return{token:r,zoneId:o,locale:i,ping:ft({...e,playerId:t})}};var be=e=>new Promise((t,r)=>{let o=document.createElement("script");o.type="text/javascript",o.type="module",o.async=!0,o.src=e,o.addEventListener("load",t),o.addEventListener("error",r),document.body.append(o)}),X=e=>(...t)=>{try{return e(...t)}catch(r){A(r),ut(r)}},ut=e=>{let t=n.getConfig();n.getCxf().emit(t.CXF_ERROR,e)};var Jt=pe(()=>te(),1e4),lt=(0,he.default)("CXF-WEBSHOP"),A=(...e)=>console.error("%c CXF-WEBSHOP ->","background: #ff0000; color: #fff",...e),d=(...e)=>{lt("%c CXF-WEBSHOP ->","background: pink; color: #bada55, font-size:20px",...e)},G=()=>de(),xe=e=>ve(e),Ae=()=>ggsGetQueryParameters(),we=()=>ggsGetReferrer(),Fe=e=>e.reduce((t,r,o)=>(t.offers.push({id:r,tier:0,productIds:{googleplay:r}}),t),{category:"all",offers:[],eventName:"lemonstand.nativePrice",eventType:"bubble"});s();function _e(e){return{isCanvas:!1,playerId:e.playerId,instanceId:e.instanceId,networkId:e.networkId,gameId:e.gameId,gameApi:e.gameApi,language:e.language,token:e.token,zoneId:e.zoneId,gameEvents:[],xp:0,level:0,legendLevel:void 0,countryCode:"",lastPurchaseTab:"",subscriptionDisabled:!1,isTempServer:!1,customizationSuffix:"",resolvedCustomizationUrl:"",sourceId:"unknown",unreadOfferNotifsCountUrl:""}}function Y({legendLevel:e,level:t}){return{legendLevel:e,level:t}}var D=async()=>{let e=n.getConfig(),t=n.getStore();if(e.LEGEND_LEVEL_IS_USED&&t.legendLevel===void 0){d("Skip fetchUnreadOfferNotificationsCount due to legendLevel is undefined");return}if(!t.isCanvas&&t.token&&t.unreadOfferNotifsCountUrl){d("fetchUnreadOfferNotificationsCount");let r=0,o={Authorization:`Bearer ${t.token}`},i=t.unreadOfferNotifsCountUrl.replace("{locale}",t.language||"").replace("{zoneId}",t.zoneId||"").replace("{criteria}",encodeURIComponent(JSON.stringify(Y(t))));try{d("fetch",i);let f=await fetch(i,{headers:o});if(f.ok){let h=await f.json();r=Number(h?.notifCount)}}catch(f){A(`cannot fetch ${i}`,f)}d("setUnseenOffersCounter",r),t.gameApi.invokeFn("setUnseenOffersCounter",r).catch(f=>{A("setUnseenOffersCounter error:",f)})}};s();var q=class{post(t){let r=document.querySelector("#dialog");r&&r.tagName.toLocaleLowerCase()==="iframe"&&r.contentWindow?.postMessage(t,"*")}};s();s();var Te=H(Pe());var M=({page:e,route:t,sid:r,config:o={}})=>{let i=n.getConfig(),f=n.getStore(),{token:h,zoneId:w,locale:x}=J(f),E={token:h,zoneId:w,locale:x,sid:r||G()};Object.keys(o).length>0&&(E.config=JSON.stringify(o)),Ce(E);let c=new URLSearchParams(Ae()),a={...E,"lemonstand.customization.url":f.resolvedCustomizationUrl||Q(),domain:xe(we()),websiteId:c.get("w"),criteria:JSON.stringify(Y(f)),level:f.level},m=c.get("network");return c.get("usekeybaselogin")==="false"&&Number(m)>0&&(a.network=m),f.adStatus?.areBannersAvailable&&(a.ads=!0),`${i.BASE_URL}/?${ye(a)}${e?`#${e}`:""}${t?`--${t}--${Date.now()}`:""}`},Q=()=>{let e=n.getConfig(),t=n.getStore(),r=n.getCxf(),o=(0,Te.acronym)(t.gameId),i=t.customizationSuffix?`-${t.customizationSuffix}`:"",f=`${o}${i}`;if(r.env==="test"){let h=new URLSearchParams(window.location.search).get("configGGS");if(h!==null)return e.CUSTOMIZATION_URL_TEMPLATE.replace("{0}",f).replace("{1}",h)}return e.CUSTOMIZATION_URL.replace("{0}",f)};var Ne=()=>{if(typeof fetch!="function")return;let e=Q(),t="";fetch(e).then(r=>{if(Q()===e)return t=r.url,d("parsed customization url is "+t),n.updateStore({resolvedCustomizationUrl:t}),r.json()}).then(r=>{r&&n.updateStore({unreadOfferNotifsCountUrl:r.unreadOfferNotifsCountUrl||""})})};var ne=e=>{let t=e;return{get:()=>t,set:r=>{t=r}}},oe=class{constructor(){this.config=void 0;this.cxfProvider=ne();this.dialogProvider=ne();this.storeProvider=ne();this.shopMessageBus=new q;this.fetchUnreadOfferNotificationsCount=D;this.preResolveConfig=Ne}setConfig(t){this.config=t}getConfig(){if(this.config===void 0)throw new Error("Config is not initialized");return this.config}setCxf(t){this.cxfProvider.set(t)}getCxf(){let t=this.cxfProvider.get();if(!t)throw new Error("CXF is not loaded");return t}setStore(t){this.storeProvider.set(t)}getStore(){let t=this.storeProvider.get();if(!t)throw new Error("Store is not initialized");return t}updateStore(t){let r=this.getStore();this.setStore({...r,...t})}},n=new oe;s();var p=H(se());s();var k=e=>{let t=n.getConfig();n.getCxf().emit(t.CXF_DIALOG_OPEN,e)};s();var W=e=>{let t=n.getConfig(),r=n.getStore(),o=Date.now(),i=J(r),{zoneId:f}=i,h=e,{playerId:w,gameId:x,networkId:E,instanceId:c,sourceId:a}=r;mt({eventId:t.WEB_SHOP_CALL_TRACK_ID,date:Ie(o),unixtimeMS:o,sessionId:h,zoneId:f?Number.parseInt(f,10):void 0,playerId:Number.parseInt(w,10),gameId:Number.parseInt(x,10),networkId:Number.parseInt(E,10),instanceId:Number.parseInt(c,10),sourceId:a})},mt=e=>{let t=n.getConfig();n.getCxf().emit(t.CXF_TRACK_MSG,e)};s();s();var Le=new Set([316,318,460,461,767,768,802,814,830,877]);s();var Ue=e=>{d("OnReward: payload",e);let{isCanvas:t}=n.getStore();if(t){window.CanvasAgent?.instance?.hide(),window.CanvasAgent?.instance?.navigate();return}let r=M({route:encodeURIComponent(e.successUrl),...e});n.updateStore({lastPurchaseTab:e.page,sourceId:"successfulPayoutReward"}),W(e.sid),k(r)},pt=({target:e,action:t,data:r})=>{n.shopMessageBus.post({eventName:"lemonstand.category.update",target:e,data:{action:t,data:r}})},Ct=({notifCount:e})=>{d("onLemonstandNotificationsCreated -> notifCount:",e);let t=n.getStore();if(e>0){let r=Math.floor(Math.random()*(Number(t.networkId)<250?12e4:15e3));setTimeout(()=>{D()},r)}else t.gameApi.invokeFn("setUnseenOffersCounter",0).catch(r=>{A("setUnseenOffersCounter error:",r)})},Re=()=>({reward:Ue,reward_received:Ue,"lemonstand.category.update":pt,"lemonstand.notifs.created":Ct});var Ge=!1,It=(e={})=>{d(p.CxfEvents.OpenIGS,"payload:",e),e.sourceId&&n.updateStore({sourceId:e.sourceId});let{isCanvas:t,lastPurchaseTab:r,gameApi:o}=n.getStore();if(t){e.page&&window.CanvasAgent?.instance?.navigate(e.page),window.CanvasAgent?.instance?.show();return}let i=G();W(i);let f=M({sid:i,page:r,...e});k(f),setTimeout(()=>{o.invokeFn("setUnseenOffersCounter",0)},1e3)},vt=e=>{let t=Re();e.on(p.CxfEvents.OpenIGS,X(It)),e.on(p.CxfEvents.Push,X(({id:r,payload:o})=>{d(p.CxfEvents.Push,r,o);let i=t[r];i&&i(o)}))},St=e=>{e.on(p.CxfEvents.Login,t=>{let{gameEvents:r,language:o,token:i,zoneId:f}=t;Le.has(Number(f))&&(Number(f)>300||localStorage.getItem("cxf_canvas")==="enabled")&&n.updateStore({isCanvas:!0});let{gameEvents:h,isCanvas:w}=n.getStore(),x=E=>c=>!E.map(a=>a.type).includes(c.type);if(n.updateStore({...t,gameEvents:[...h.filter(x(r)),...r]}),d(p.CxfEvents.Login,n.getStore()),!w){n.fetchUnreadOfferNotificationsCount();return}if(typeof window.CanvasAgent?.create=="function"){let{CANVAS_APP_ID_BY_GAME:E}=n.getConfig(),c=Ee(),a=E[e.gameId],m=typeof a=="string"?a:a?.[c],C=v=>{if(d("Canvas event received:",v),v?.eventType==="native_catalog_request"&&v?.paymentContractIds?.length>0){Ge||(window.addEventListener("message",({data:g})=>{if(g?.eventName==="lemonstand.category.update"&&g?.data?.action==="nativePriceUpdate"){if(d("lemonstand.category.update event",g.data),!g.data.data)return;let I={};for(let S in g.data.data){let{priceString:F,...b}=g.data.data[S];I[S]=b}d("nativeCatalog:",I),window.CanvasAgent?.instance?.setNativeCatalog(I)}}),Ge=!0);let u=Fe(v.paymentContractIds);window.postMessage(u,"*"),d("Event `lemonstand.nativePrice` sent")}};window.CanvasAgent.create({authClientId:"lemonstand",canvasAppId:m,eventListener:C,locale:o,token:i}).then(v=>{window.CanvasAgent.instance=v,d(p.CxfEvents.Login,"Canvas created")}).catch(v=>{A("Cannot create instance of Canvas",v)})}}),e.on(p.CxfEvents.GameEventUpdate,t=>{d(p.CxfEvents.GameEventUpdate,t);let{gameEvents:r,isCanvas:o}=n.getStore(),i=new Set(t.map(f=>f.type));n.updateStore({gameEvents:[...r.filter(f=>!i.has(f.type)),...t]}),o&&window.CanvasAgent?.instance?.refresh(),d(p.CxfEvents.GameEventUpdate,"reducer",n.getStore())}),e.on(p.CxfEvents.GameEventAdd,t=>{d(p.CxfEvents.GameEventAdd,t);let{gameEvents:r,isCanvas:o}=n.getStore();n.updateStore({gameEvents:[...r,t]}),o&&window.CanvasAgent?.instance?.refresh(),d(p.CxfEvents.GameEventAdd,"reducer",n.getStore())}),e.on(p.CxfEvents.GameEventRemove,t=>{d(p.CxfEvents.GameEventRemove,t);let{gameEvents:r,isCanvas:o}=n.getStore();n.updateStore({gameEvents:r.filter(({type:i})=>i!==t)}),o&&window.CanvasAgent?.instance?.refresh(),d(p.CxfEvents.GameEventRemove,"reducer",n.getStore())}),e.on(p.CxfEvents.LevelChanged,t=>{d(p.CxfEvents.LevelChanged,t);let{isCanvas:r}=n.getStore();n.updateStore({level:t}),d(p.CxfEvents.LevelChanged,"reducer",n.getStore()),r?window.CanvasAgent?.instance?.refresh():n.fetchUnreadOfferNotificationsCount()}),e.on(p.CxfEvents.LegendLevelChanged,t=>{d(p.CxfEvents.LegendLevelChanged,`legendLevel: ${t}`),n.updateStore({legendLevel:t});let r=n.getStore();d(p.CxfEvents.LegendLevelChanged,"reducer",r),n.fetchUnreadOfferNotificationsCount()})},ht=e=>{e.on("cxf.native.subscription.enable",t=>{n.updateStore({subscriptionDisabled:t===0,customizationSuffix:t===0?"no-subscription":""}),n.preResolveConfig()})},Et=e=>{e.on("cxf.set.customization.surfix",t=>{let{customizationSuffix:r}=n.getStore();t!==r&&(n.updateStore({customizationSuffix:t||""}),n.preResolveConfig())})},yt=e=>{let t=n.getConfig();e.on(t.CXF_AD_STATUS,({areBannersAvailable:r,bannersDetails:o})=>{n.updateStore({adStatus:{areBannersAvailable:r,bannersDetails:o}})})},bt=e=>{e.on("cxf.join.temp.server",t=>{let r=n.getStore();n.updateStore({isTempServer:!!t}),(r.customizationSuffix===""||r.customizationSuffix==="temp")&&(n.updateStore({customizationSuffix:t?"temp":""}),n.preResolveConfig())})},De=()=>[vt,St,yt,bt,ht,Et];s();var xt=()=>{d("OnOpenSalesOffersPage");let{isCanvas:e}=n.getStore();if(e){window.CanvasAgent?.instance?.navigate("supersale");return}let t=G(),r=M({page:"sale-offers",sid:t});k(r)},At=()=>{let e=n.getStore();d("onLemonstandClose",e),D()},Me=()=>({"cxf.webshop.sales.open":xt,"cxf.dialog.close":At});var ke=e=>{let t=Me(),r=De();window.addEventListener("message",X(({data:o})=>{if(o){let i=t[o.name];i&&(d("POST MESSAGE",o),i(o.payload))}}));for(let o of r)o(e);n.preResolveConfig(),d("App has started")};s();var Xe=H(se());var wt={CANVAS_AGENT_URL:l.env.CANVAS_AGENT_URL,CANVAS_APP_ID_BY_GAME:l.env.CANVAS_APP_ID_BY_GAME,CUSTOMIZATION_URL:l.env.CUSTOMIZATION_URL,CUSTOMIZATION_URL_TEMPLATE:l.env.CUSTOMIZATION_URL_TEMPLATE,BASE_URL:l.env.BASE_URL,CXF_DIALOG_OPEN:"cxf.dialog.open",CXF_DIALOG_CLOSE:"cxf.dialog.close",CXF_TRACK_MSG:"cxf.tracking.message",CXF_BTN_CLICK_MSG:Xe.CxfEvents.OpenIGS,CXF_OPEN_SALES_MSG:"cxf.webshop.sales.open",WEB_SHOP_CALL_TRACK_ID:1181,CXF_ERROR:"cxf.error",CXF_PUSH:"cxf.push",CXF_AD_STATUS:"cxf.adBanner.status"},Ft={12:{LEGEND_LEVEL_IS_USED:!0},15:{LEGEND_LEVEL_IS_USED:!1},16:{LEGEND_LEVEL_IS_USED:!0}},ze=e=>({...wt,...Ft[e]});te().then(e=>{let t=ze(e.gameId);n.setConfig(t),n.setCxf(e);let r=_e(e);n.setStore(r),be(t.CANVAS_AGENT_URL).then(()=>{d(`Canvas agent loaded: ${t.CANVAS_AGENT_URL}`)}).catch(o=>{A("Canvas agent load error",o)}),ke(e)});})();
1
+ "use strict";
2
+ (() => {
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
12
+ var __commonJS = (cb, mod) => function __require() {
13
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+
32
+ // <define:process>
33
+ var define_process_default;
34
+ var init_define_process = __esm({
35
+ "<define:process>"() {
36
+ define_process_default = { env: { BASE_URL: "https://canvas-test.goodgamestudios.com", CANVAS_AGENT_URL: "https://app.canvas.stillfront.com/agent.js", CANVAS_APP_ID_BY_GAME: { "12": "81199abb-592e-465c-b926-8656628a64c7", "15": { google: "25facd0c-e850-4ebf-b6c4-8c60240e4cf8", stillpay: "bec451f9-8db4-4ca1-8a5a-54494429ff5e" }, "16": "18f5521d-7df2-4bb3-88a3-c162ba072d73" }, CUSTOMIZATION_URL_TEMPLATE: "https://cdn.jsdelivr.net/npm/@lemonstand.org/config-goodgamestudios@{1}/dist/goodgamestudios-{0}.json", CUSTOMIZATION_URL: "https://cdn.jsdelivr.net/npm/@lemonstand.org/config-goodgamestudios@qa/dist/goodgamestudios-{0}.json" } };
37
+ }
38
+ });
39
+
40
+ // node_modules/debug/node_modules/ms/index.js
41
+ var require_ms = __commonJS({
42
+ "node_modules/debug/node_modules/ms/index.js"(exports, module) {
43
+ init_define_process();
44
+ var s = 1e3;
45
+ var m = s * 60;
46
+ var h = m * 60;
47
+ var d = h * 24;
48
+ var w = d * 7;
49
+ var y = d * 365.25;
50
+ module.exports = function(val, options) {
51
+ options = options || {};
52
+ var type = typeof val;
53
+ if (type === "string" && val.length > 0) {
54
+ return parse(val);
55
+ } else if (type === "number" && isFinite(val)) {
56
+ return options.long ? fmtLong(val) : fmtShort(val);
57
+ }
58
+ throw new Error(
59
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
60
+ );
61
+ };
62
+ function parse(str) {
63
+ str = String(str);
64
+ if (str.length > 100) {
65
+ return;
66
+ }
67
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
68
+ str
69
+ );
70
+ if (!match) {
71
+ return;
72
+ }
73
+ var n = parseFloat(match[1]);
74
+ var type = (match[2] || "ms").toLowerCase();
75
+ switch (type) {
76
+ case "years":
77
+ case "year":
78
+ case "yrs":
79
+ case "yr":
80
+ case "y":
81
+ return n * y;
82
+ case "weeks":
83
+ case "week":
84
+ case "w":
85
+ return n * w;
86
+ case "days":
87
+ case "day":
88
+ case "d":
89
+ return n * d;
90
+ case "hours":
91
+ case "hour":
92
+ case "hrs":
93
+ case "hr":
94
+ case "h":
95
+ return n * h;
96
+ case "minutes":
97
+ case "minute":
98
+ case "mins":
99
+ case "min":
100
+ case "m":
101
+ return n * m;
102
+ case "seconds":
103
+ case "second":
104
+ case "secs":
105
+ case "sec":
106
+ case "s":
107
+ return n * s;
108
+ case "milliseconds":
109
+ case "millisecond":
110
+ case "msecs":
111
+ case "msec":
112
+ case "ms":
113
+ return n;
114
+ default:
115
+ return void 0;
116
+ }
117
+ }
118
+ function fmtShort(ms) {
119
+ var msAbs = Math.abs(ms);
120
+ if (msAbs >= d) {
121
+ return Math.round(ms / d) + "d";
122
+ }
123
+ if (msAbs >= h) {
124
+ return Math.round(ms / h) + "h";
125
+ }
126
+ if (msAbs >= m) {
127
+ return Math.round(ms / m) + "m";
128
+ }
129
+ if (msAbs >= s) {
130
+ return Math.round(ms / s) + "s";
131
+ }
132
+ return ms + "ms";
133
+ }
134
+ function fmtLong(ms) {
135
+ var msAbs = Math.abs(ms);
136
+ if (msAbs >= d) {
137
+ return plural(ms, msAbs, d, "day");
138
+ }
139
+ if (msAbs >= h) {
140
+ return plural(ms, msAbs, h, "hour");
141
+ }
142
+ if (msAbs >= m) {
143
+ return plural(ms, msAbs, m, "minute");
144
+ }
145
+ if (msAbs >= s) {
146
+ return plural(ms, msAbs, s, "second");
147
+ }
148
+ return ms + " ms";
149
+ }
150
+ function plural(ms, msAbs, n, name) {
151
+ var isPlural = msAbs >= n * 1.5;
152
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
153
+ }
154
+ }
155
+ });
156
+
157
+ // node_modules/debug/src/common.js
158
+ var require_common = __commonJS({
159
+ "node_modules/debug/src/common.js"(exports, module) {
160
+ init_define_process();
161
+ function setup(env) {
162
+ createDebug.debug = createDebug;
163
+ createDebug.default = createDebug;
164
+ createDebug.coerce = coerce;
165
+ createDebug.disable = disable;
166
+ createDebug.enable = enable;
167
+ createDebug.enabled = enabled;
168
+ createDebug.humanize = require_ms();
169
+ createDebug.destroy = destroy;
170
+ Object.keys(env).forEach((key) => {
171
+ createDebug[key] = env[key];
172
+ });
173
+ createDebug.names = [];
174
+ createDebug.skips = [];
175
+ createDebug.formatters = {};
176
+ function selectColor(namespace) {
177
+ let hash = 0;
178
+ for (let i = 0; i < namespace.length; i++) {
179
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
180
+ hash |= 0;
181
+ }
182
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
183
+ }
184
+ createDebug.selectColor = selectColor;
185
+ function createDebug(namespace) {
186
+ let prevTime;
187
+ let enableOverride = null;
188
+ let namespacesCache;
189
+ let enabledCache;
190
+ function debug2(...args) {
191
+ if (!debug2.enabled) {
192
+ return;
193
+ }
194
+ const self = debug2;
195
+ const curr = Number(/* @__PURE__ */ new Date());
196
+ const ms = curr - (prevTime || curr);
197
+ self.diff = ms;
198
+ self.prev = prevTime;
199
+ self.curr = curr;
200
+ prevTime = curr;
201
+ args[0] = createDebug.coerce(args[0]);
202
+ if (typeof args[0] !== "string") {
203
+ args.unshift("%O");
204
+ }
205
+ let index = 0;
206
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
207
+ if (match === "%%") {
208
+ return "%";
209
+ }
210
+ index++;
211
+ const formatter = createDebug.formatters[format];
212
+ if (typeof formatter === "function") {
213
+ const val = args[index];
214
+ match = formatter.call(self, val);
215
+ args.splice(index, 1);
216
+ index--;
217
+ }
218
+ return match;
219
+ });
220
+ createDebug.formatArgs.call(self, args);
221
+ const logFn = self.log || createDebug.log;
222
+ logFn.apply(self, args);
223
+ }
224
+ debug2.namespace = namespace;
225
+ debug2.useColors = createDebug.useColors();
226
+ debug2.color = createDebug.selectColor(namespace);
227
+ debug2.extend = extend;
228
+ debug2.destroy = createDebug.destroy;
229
+ Object.defineProperty(debug2, "enabled", {
230
+ enumerable: true,
231
+ configurable: false,
232
+ get: () => {
233
+ if (enableOverride !== null) {
234
+ return enableOverride;
235
+ }
236
+ if (namespacesCache !== createDebug.namespaces) {
237
+ namespacesCache = createDebug.namespaces;
238
+ enabledCache = createDebug.enabled(namespace);
239
+ }
240
+ return enabledCache;
241
+ },
242
+ set: (v) => {
243
+ enableOverride = v;
244
+ }
245
+ });
246
+ if (typeof createDebug.init === "function") {
247
+ createDebug.init(debug2);
248
+ }
249
+ return debug2;
250
+ }
251
+ function extend(namespace, delimiter) {
252
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
253
+ newDebug.log = this.log;
254
+ return newDebug;
255
+ }
256
+ function enable(namespaces) {
257
+ createDebug.save(namespaces);
258
+ createDebug.namespaces = namespaces;
259
+ createDebug.names = [];
260
+ createDebug.skips = [];
261
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
262
+ for (const ns of split) {
263
+ if (ns[0] === "-") {
264
+ createDebug.skips.push(ns.slice(1));
265
+ } else {
266
+ createDebug.names.push(ns);
267
+ }
268
+ }
269
+ }
270
+ function matchesTemplate(search, template) {
271
+ let searchIndex = 0;
272
+ let templateIndex = 0;
273
+ let starIndex = -1;
274
+ let matchIndex = 0;
275
+ while (searchIndex < search.length) {
276
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
277
+ if (template[templateIndex] === "*") {
278
+ starIndex = templateIndex;
279
+ matchIndex = searchIndex;
280
+ templateIndex++;
281
+ } else {
282
+ searchIndex++;
283
+ templateIndex++;
284
+ }
285
+ } else if (starIndex !== -1) {
286
+ templateIndex = starIndex + 1;
287
+ matchIndex++;
288
+ searchIndex = matchIndex;
289
+ } else {
290
+ return false;
291
+ }
292
+ }
293
+ while (templateIndex < template.length && template[templateIndex] === "*") {
294
+ templateIndex++;
295
+ }
296
+ return templateIndex === template.length;
297
+ }
298
+ function disable() {
299
+ const namespaces = [
300
+ ...createDebug.names,
301
+ ...createDebug.skips.map((namespace) => "-" + namespace)
302
+ ].join(",");
303
+ createDebug.enable("");
304
+ return namespaces;
305
+ }
306
+ function enabled(name) {
307
+ for (const skip of createDebug.skips) {
308
+ if (matchesTemplate(name, skip)) {
309
+ return false;
310
+ }
311
+ }
312
+ for (const ns of createDebug.names) {
313
+ if (matchesTemplate(name, ns)) {
314
+ return true;
315
+ }
316
+ }
317
+ return false;
318
+ }
319
+ function coerce(val) {
320
+ if (val instanceof Error) {
321
+ return val.stack || val.message;
322
+ }
323
+ return val;
324
+ }
325
+ function destroy() {
326
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
327
+ }
328
+ createDebug.enable(createDebug.load());
329
+ return createDebug;
330
+ }
331
+ module.exports = setup;
332
+ }
333
+ });
334
+
335
+ // node_modules/debug/src/browser.js
336
+ var require_browser = __commonJS({
337
+ "node_modules/debug/src/browser.js"(exports, module) {
338
+ init_define_process();
339
+ exports.formatArgs = formatArgs;
340
+ exports.save = save;
341
+ exports.load = load;
342
+ exports.useColors = useColors;
343
+ exports.storage = localstorage();
344
+ exports.destroy = /* @__PURE__ */ (() => {
345
+ let warned = false;
346
+ return () => {
347
+ if (!warned) {
348
+ warned = true;
349
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
350
+ }
351
+ };
352
+ })();
353
+ exports.colors = [
354
+ "#0000CC",
355
+ "#0000FF",
356
+ "#0033CC",
357
+ "#0033FF",
358
+ "#0066CC",
359
+ "#0066FF",
360
+ "#0099CC",
361
+ "#0099FF",
362
+ "#00CC00",
363
+ "#00CC33",
364
+ "#00CC66",
365
+ "#00CC99",
366
+ "#00CCCC",
367
+ "#00CCFF",
368
+ "#3300CC",
369
+ "#3300FF",
370
+ "#3333CC",
371
+ "#3333FF",
372
+ "#3366CC",
373
+ "#3366FF",
374
+ "#3399CC",
375
+ "#3399FF",
376
+ "#33CC00",
377
+ "#33CC33",
378
+ "#33CC66",
379
+ "#33CC99",
380
+ "#33CCCC",
381
+ "#33CCFF",
382
+ "#6600CC",
383
+ "#6600FF",
384
+ "#6633CC",
385
+ "#6633FF",
386
+ "#66CC00",
387
+ "#66CC33",
388
+ "#9900CC",
389
+ "#9900FF",
390
+ "#9933CC",
391
+ "#9933FF",
392
+ "#99CC00",
393
+ "#99CC33",
394
+ "#CC0000",
395
+ "#CC0033",
396
+ "#CC0066",
397
+ "#CC0099",
398
+ "#CC00CC",
399
+ "#CC00FF",
400
+ "#CC3300",
401
+ "#CC3333",
402
+ "#CC3366",
403
+ "#CC3399",
404
+ "#CC33CC",
405
+ "#CC33FF",
406
+ "#CC6600",
407
+ "#CC6633",
408
+ "#CC9900",
409
+ "#CC9933",
410
+ "#CCCC00",
411
+ "#CCCC33",
412
+ "#FF0000",
413
+ "#FF0033",
414
+ "#FF0066",
415
+ "#FF0099",
416
+ "#FF00CC",
417
+ "#FF00FF",
418
+ "#FF3300",
419
+ "#FF3333",
420
+ "#FF3366",
421
+ "#FF3399",
422
+ "#FF33CC",
423
+ "#FF33FF",
424
+ "#FF6600",
425
+ "#FF6633",
426
+ "#FF9900",
427
+ "#FF9933",
428
+ "#FFCC00",
429
+ "#FFCC33"
430
+ ];
431
+ function useColors() {
432
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
433
+ return true;
434
+ }
435
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
436
+ return false;
437
+ }
438
+ let m;
439
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
440
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
441
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
442
+ typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
443
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
444
+ }
445
+ function formatArgs(args) {
446
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
447
+ if (!this.useColors) {
448
+ return;
449
+ }
450
+ const c = "color: " + this.color;
451
+ args.splice(1, 0, c, "color: inherit");
452
+ let index = 0;
453
+ let lastC = 0;
454
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
455
+ if (match === "%%") {
456
+ return;
457
+ }
458
+ index++;
459
+ if (match === "%c") {
460
+ lastC = index;
461
+ }
462
+ });
463
+ args.splice(lastC, 0, c);
464
+ }
465
+ exports.log = console.debug || console.log || (() => {
466
+ });
467
+ function save(namespaces) {
468
+ try {
469
+ if (namespaces) {
470
+ exports.storage.setItem("debug", namespaces);
471
+ } else {
472
+ exports.storage.removeItem("debug");
473
+ }
474
+ } catch (error) {
475
+ }
476
+ }
477
+ function load() {
478
+ let r;
479
+ try {
480
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
481
+ } catch (error) {
482
+ }
483
+ if (!r && typeof define_process_default !== "undefined" && "env" in define_process_default) {
484
+ r = define_process_default.env.DEBUG;
485
+ }
486
+ return r;
487
+ }
488
+ function localstorage() {
489
+ try {
490
+ return localStorage;
491
+ } catch (error) {
492
+ }
493
+ }
494
+ module.exports = require_common()(exports);
495
+ var { formatters } = module.exports;
496
+ formatters.j = function(v) {
497
+ try {
498
+ return JSON.stringify(v);
499
+ } catch (error) {
500
+ return "[UnexpectedJSONParseError]: " + error.message;
501
+ }
502
+ };
503
+ }
504
+ });
505
+
506
+ // node_modules/@goodgamestudios/cxf-ready/dist/index.js
507
+ var require_dist = __commonJS({
508
+ "node_modules/@goodgamestudios/cxf-ready/dist/index.js"(exports, module) {
509
+ "use strict";
510
+ init_define_process();
511
+ var cxf = window && window.CXF;
512
+ module.exports = new Promise(function(resolve, reject) {
513
+ if (!window) {
514
+ reject();
515
+ }
516
+ if (cxf) {
517
+ return resolve(cxf);
518
+ }
519
+ window.addEventListener("cxf.initialized", function(event) {
520
+ cxf = event.cxf;
521
+ resolve(cxf);
522
+ }, {
523
+ capture: true,
524
+ once: true,
525
+ passive: true
526
+ });
527
+ });
528
+ }
529
+ });
530
+
531
+ // node_modules/@goodgamestudios/game-alias/dist/index.js
532
+ var require_dist2 = __commonJS({
533
+ "node_modules/@goodgamestudios/game-alias/dist/index.js"(exports, module) {
534
+ init_define_process();
535
+ (function() {
536
+ var b = {};
537
+ function f(r, $) {
538
+ return h(r) || g(r, $) || e();
539
+ }
540
+ function e() {
541
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
542
+ }
543
+ function g(r, $) {
544
+ var a2 = [], o2 = true, e2 = false, n2 = void 0;
545
+ try {
546
+ for (var c2, i2 = r[Symbol.iterator](); !(o2 = (c2 = i2.next()).done) && (a2.push(c2.value), !$ || a2.length !== $); o2 = true) ;
547
+ } catch (m2) {
548
+ e2 = true, n2 = m2;
549
+ } finally {
550
+ try {
551
+ o2 || null == i2.return || i2.return();
552
+ } finally {
553
+ if (e2) throw n2;
554
+ }
555
+ }
556
+ return a2;
557
+ }
558
+ function h(r) {
559
+ if (Array.isArray(r)) return r;
560
+ }
561
+ var i = 0, j = 1, k = 2, c = { 1: ["poker", "poker2", "poker"], 12: ["empire", "castle", "em"], 15: ["bigfarm", "ranch", "bf"], 16: ["empirefourkingdoms", "fourkingdoms", "e4k"], 23: ["legendsofhonor", void 0, "loh"], 41: ["empiremillenniumwars", void 0, "emmw"] }, d = Object.entries(c).reduce(function(r, $) {
562
+ var a2 = f($, 2), o2 = a2[0], e2 = a2[1];
563
+ return o2 = parseInt(o2, 10), r[o2] = o2, e2.forEach(function($2) {
564
+ r[$2] = o2;
565
+ }), r;
566
+ }, {}), l = function(r) {
567
+ r = r.toString().toLowerCase();
568
+ var $ = d[r];
569
+ return $ && 0 | $;
570
+ }, a = function(r, $) {
571
+ return ($ = d[$]) && c[$][r];
572
+ }, m = a.bind(null, i), n = a.bind(null, j), o = a.bind(null, k);
573
+ b = { id: l, name: m, codename: n, acronym: o };
574
+ if (typeof exports === "object" && typeof module !== "undefined") {
575
+ module.exports = b;
576
+ } else if (typeof define === "function" && define.amd) {
577
+ define(function() {
578
+ return b;
579
+ });
580
+ }
581
+ })();
582
+ }
583
+ });
584
+
585
+ // node_modules/@goodgamestudios/cxf-events/dist/typings.js
586
+ var require_typings = __commonJS({
587
+ "node_modules/@goodgamestudios/cxf-events/dist/typings.js"(exports) {
588
+ "use strict";
589
+ init_define_process();
590
+ Object.defineProperty(exports, "__esModule", { value: true });
591
+ exports.CxfEvents = void 0;
592
+ var CxfEvents3;
593
+ (function(CxfEvents4) {
594
+ CxfEvents4["Token"] = "cxf.token";
595
+ CxfEvents4["Login"] = "cxf.login";
596
+ CxfEvents4["Signup"] = "cxf.signup";
597
+ CxfEvents4["GameEventUpdate"] = "cxf.gameEvent.update";
598
+ CxfEvents4["GameEventAdd"] = "cxf.gameEvent.add";
599
+ CxfEvents4["GameEventRemove"] = "cxf.gameEvent.remove";
600
+ CxfEvents4["XpChanged"] = "cxf.xp.changed";
601
+ CxfEvents4["LevelChanged"] = "cxf.level.changed";
602
+ CxfEvents4["LegendLevelChanged"] = "cxf.legendLevel.changed";
603
+ CxfEvents4["Push"] = "cxf.push";
604
+ CxfEvents4["OpenIGS"] = "cxf.igs.open";
605
+ CxfEvents4["JoinTempServer"] = "cxf.join.temp.server";
606
+ CxfEvents4["Subscription"] = "cxf.subscription";
607
+ CxfEvents4["RewardedAdStart"] = "cxf.rewardedad.start";
608
+ CxfEvents4["RewardedAdDone"] = "cxf.rewardedad.done";
609
+ })(CxfEvents3 = exports.CxfEvents || (exports.CxfEvents = {}));
610
+ }
611
+ });
612
+
613
+ // src/index.ts
614
+ init_define_process();
615
+
616
+ // src/app.ts
617
+ init_define_process();
618
+
619
+ // src/globalState.ts
620
+ init_define_process();
621
+
622
+ // src/fetch.ts
623
+ init_define_process();
624
+
625
+ // src/store.ts
626
+ init_define_process();
627
+ function initializeStore(cxf) {
628
+ return {
629
+ isCanvas: false,
630
+ playerId: cxf.playerId,
631
+ instanceId: cxf.instanceId,
632
+ networkId: cxf.networkId,
633
+ gameId: cxf.gameId,
634
+ gameApi: cxf.gameApi,
635
+ language: cxf.language,
636
+ token: cxf.token,
637
+ zoneId: cxf.zoneId,
638
+ gameEvents: [],
639
+ xp: 0,
640
+ level: 0,
641
+ legendLevel: void 0,
642
+ countryCode: "",
643
+ lastPurchaseTab: "",
644
+ subscriptionDisabled: false,
645
+ isTempServer: false,
646
+ customizationSuffix: "",
647
+ resolvedCustomizationUrl: "",
648
+ sourceId: "unknown",
649
+ unreadOfferNotifsCountUrl: ""
650
+ };
651
+ }
652
+ function criteriaSelector({ legendLevel, level }) {
653
+ return {
654
+ legendLevel,
655
+ level
656
+ };
657
+ }
658
+
659
+ // src/utils/index.ts
660
+ init_define_process();
661
+
662
+ // src/utils/domain.ts
663
+ init_define_process();
664
+ var parentDomain = (referrer) => {
665
+ const matches = referrer.match(/^https?:\/\/([^#/?]+)(?:[#/?]|$)/i);
666
+ if (!matches || !matches[1]) {
667
+ return;
668
+ }
669
+ const result = matches[1].match(/[^.]+\.[^.]+$/);
670
+ if (!result) {
671
+ return;
672
+ }
673
+ return result[0];
674
+ };
675
+ var getDomain = (referrer) => {
676
+ return parentDomain(referrer);
677
+ };
678
+
679
+ // src/utils/error-handling.ts
680
+ init_define_process();
681
+
682
+ // src/utils/logging.ts
683
+ init_define_process();
684
+ var import_debug = __toESM(require_browser());
685
+ var logger = (0, import_debug.default)("CXF-WEBSHOP");
686
+ var log = (argument0, ...rest) => logger(argument0, ...rest);
687
+ var logError = (...arguments_) => (
688
+ // tslint:disable-next-line:no-console
689
+ console.error("%c CXF-WEBSHOP ->", "background: #ff0000; color: #fff", ...arguments_)
690
+ );
691
+
692
+ // src/utils/error-handling.ts
693
+ var tryCatch = (fn) => (...args) => {
694
+ try {
695
+ return fn(...args);
696
+ } catch (error) {
697
+ logError(error);
698
+ throwCxfError(error);
699
+ }
700
+ };
701
+ var throwCxfError = (e) => {
702
+ const config = globalState.getConfig();
703
+ const cxf = globalState.getCxf();
704
+ cxf.emit(config.CXF_ERROR, e);
705
+ };
706
+
707
+ // src/utils/loaders.ts
708
+ init_define_process();
709
+ var startTimer = (function_, time) => {
710
+ const id = setTimeout(function_, time);
711
+ return () => clearTimeout(id);
712
+ };
713
+ var timeout = (function_, time) => (a) => {
714
+ return new Promise((resolve, reject) => {
715
+ const stopTimer = startTimer(() => {
716
+ reject(new Error(`Timeout has exceeded ${time}`));
717
+ }, time);
718
+ function_(a).then((value) => {
719
+ resolve(value);
720
+ stopTimer();
721
+ }).catch(reject);
722
+ });
723
+ };
724
+ var loadScript = (src) => new Promise((resolve, reject) => {
725
+ const script = document.createElement("script");
726
+ script.type = "text/javascript";
727
+ script.type = "module";
728
+ script.async = true;
729
+ script.src = src;
730
+ script.addEventListener("load", resolve);
731
+ script.addEventListener("error", reject);
732
+ document.body.append(script);
733
+ });
734
+ var loadCxf = timeout(() => require_dist(), 1e4);
735
+
736
+ // src/utils/payment.ts
737
+ init_define_process();
738
+ var transformPaymentContractIdsToNativePriceEvent = (ids) => (
739
+ // eslint-disable-next-line unicorn/no-array-reduce
740
+ ids.reduce(
741
+ (prev, cur, idx) => {
742
+ prev.offers.push({
743
+ id: cur,
744
+ tier: 0,
745
+ productIds: {
746
+ googleplay: cur
747
+ }
748
+ });
749
+ return prev;
750
+ },
751
+ {
752
+ category: "all",
753
+ offers: [],
754
+ eventName: "lemonstand.nativePrice",
755
+ eventType: "bubble"
756
+ }
757
+ )
758
+ );
759
+
760
+ // src/utils/platform.ts
761
+ init_define_process();
762
+ var userAgentToDistribPlatformMatrix = {
763
+ itunes: "apple",
764
+ Android: "google",
765
+ googleplay: "google",
766
+ amazonmobile: "amazon",
767
+ facebook: "facebook",
768
+ samsung: "samsung",
769
+ huawei: "huawei"
770
+ };
771
+ var detectPlatform = (defaultPlatform = "stillpay") => {
772
+ const nativePlatform = navigator.userAgent.match(
773
+ /(itunes)|(googleplay)|(Android)|(amazonmobile)|(facebook)|(samsung)|(huawei)/g
774
+ );
775
+ if (!nativePlatform) return defaultPlatform;
776
+ const activePlatform = nativePlatform[0];
777
+ return Object.prototype.hasOwnProperty.call(userAgentToDistribPlatformMatrix, activePlatform) ? userAgentToDistribPlatformMatrix[activePlatform] : defaultPlatform;
778
+ };
779
+ var distribPlatformToProviderMatrix = {
780
+ apple: "itunes",
781
+ google: "googleplay",
782
+ amazon: "amazonmobile",
783
+ facebook: "facebook",
784
+ samsung: "samsung",
785
+ huawei: "huawei"
786
+ };
787
+ var createProductIdsForPlatform = (platform, id) => {
788
+ if (!Object.prototype.hasOwnProperty.call(distribPlatformToProviderMatrix, platform))
789
+ throw new Error(`Platform ${platform} is not supported`);
790
+ const res = /* @__PURE__ */ Object.create(null);
791
+ res[distribPlatformToProviderMatrix[platform]] = id;
792
+ return res;
793
+ };
794
+
795
+ // src/utils/query-params.ts
796
+ init_define_process();
797
+ function formatQueryString(object) {
798
+ return Object.entries(object).filter(([key, value]) => value !== null && value !== void 0).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
799
+ }
800
+ var ggsGetQueryParams = () => {
801
+ return ggsGetQueryParameters();
802
+ };
803
+ var ggsGetReferrerValue = () => {
804
+ return ggsGetReferrer();
805
+ };
806
+
807
+ // src/utils/session.ts
808
+ init_define_process();
809
+
810
+ // node_modules/@lukeed/uuid/dist/index.mjs
811
+ init_define_process();
812
+ var IDX = 256;
813
+ var HEX = [];
814
+ var BUFFER;
815
+ while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
816
+ function v4() {
817
+ var i = 0, num, out = "";
818
+ if (!BUFFER || IDX + 16 > 256) {
819
+ BUFFER = Array(i = 256);
820
+ while (i--) BUFFER[i] = 256 * Math.random() | 0;
821
+ i = IDX = 0;
822
+ }
823
+ for (; i < 16; i++) {
824
+ num = BUFFER[IDX + i];
825
+ if (i == 6) out += HEX[num & 15 | 64];
826
+ else if (i == 8) out += HEX[num & 63 | 128];
827
+ else out += HEX[num];
828
+ if (i & 1 && i > 1 && i < 11) out += "-";
829
+ }
830
+ IDX++;
831
+ return out;
832
+ }
833
+
834
+ // src/ArgumentNullError.ts
835
+ init_define_process();
836
+ var ArgumentNullError = class extends Error {
837
+ constructor(parameterName, parameterValue) {
838
+ super(`${parameterName} has null value: ${parameterValue}`);
839
+ this.name = "ArgumentNullError";
840
+ }
841
+ };
842
+
843
+ // src/types/models.ts
844
+ init_define_process();
845
+ function encodeGnip({ gameId, networkId, instanceId, playerId }) {
846
+ return [gameId, networkId, instanceId, playerId].join("-");
847
+ }
848
+
849
+ // src/utils/session.ts
850
+ var createSessionId = () => v4();
851
+ var getTokenAndLanguage = (store) => {
852
+ const { playerId, token, zoneId, language } = store;
853
+ if (!playerId) {
854
+ throw new ArgumentNullError("playerId", playerId);
855
+ }
856
+ return {
857
+ token,
858
+ zoneId,
859
+ locale: language,
860
+ ping: encodeGnip({ ...store, playerId })
861
+ };
862
+ };
863
+
864
+ // src/utils/time.ts
865
+ init_define_process();
866
+ function msToSec(value) {
867
+ return Math.floor(value / 1e3);
868
+ }
869
+
870
+ // src/utils/url.ts
871
+ init_define_process();
872
+ var import_game_alias = __toESM(require_dist2());
873
+
874
+ // src/utils/validation.ts
875
+ init_define_process();
876
+ var validateForNull = (properties) => {
877
+ for (const key of Object.keys(properties)) {
878
+ const value = properties[key];
879
+ if (value === void 0 || value === null || Number.isNaN(value)) {
880
+ throw new ArgumentNullError(key, value);
881
+ }
882
+ }
883
+ };
884
+
885
+ // src/utils/url.ts
886
+ var createIframeUrl = ({ page, route, sid, config: igsConfig = {} }) => {
887
+ const config = globalState.getConfig();
888
+ const store = globalState.getStore();
889
+ const { token, zoneId, locale } = getTokenAndLanguage(store);
890
+ const parameters = {
891
+ token,
892
+ zoneId,
893
+ locale,
894
+ sid: sid || createSessionId()
895
+ };
896
+ if (Object.keys(igsConfig).length > 0) {
897
+ parameters.config = JSON.stringify(igsConfig);
898
+ }
899
+ validateForNull(parameters);
900
+ const urlParameters = new URLSearchParams(ggsGetQueryParams());
901
+ const queryParameters = {
902
+ ...parameters,
903
+ "lemonstand.customization.url": store.resolvedCustomizationUrl || createCustomizationUrl(),
904
+ domain: getDomain(ggsGetReferrerValue()),
905
+ websiteId: urlParameters.get("w"),
906
+ criteria: JSON.stringify(criteriaSelector(store)),
907
+ level: store.level
908
+ };
909
+ const network = urlParameters.get("network");
910
+ if (urlParameters.get("usekeybaselogin") === "false" && Number(network) > 0) {
911
+ queryParameters.network = network;
912
+ }
913
+ if (store.adStatus?.areBannersAvailable) {
914
+ queryParameters.ads = true;
915
+ }
916
+ return `${config.BASE_URL}/?${formatQueryString(queryParameters)}${page ? `#${page}` : ""}${route ? `--${route}--${Date.now()}` : ""}`;
917
+ };
918
+ var createCustomizationUrl = () => {
919
+ const config = globalState.getConfig();
920
+ const store = globalState.getStore();
921
+ const cxf = globalState.getCxf();
922
+ const configBase = (0, import_game_alias.acronym)(store.gameId);
923
+ const configVariance = store.customizationSuffix ? `-${store.customizationSuffix}` : "";
924
+ const configBranch = `${configBase}${configVariance}`;
925
+ if (cxf.env === "test") {
926
+ const configVersion = new URLSearchParams(window.location.search).get("configGGS");
927
+ if (configVersion !== null) {
928
+ return config.CUSTOMIZATION_URL_TEMPLATE.replace("{0}", configBranch).replace("{1}", configVersion);
929
+ }
930
+ }
931
+ return config.CUSTOMIZATION_URL.replace("{0}", configBranch);
932
+ };
933
+
934
+ // src/fetch.ts
935
+ var fetchUnreadOfferNotificationsCount = async () => {
936
+ const config = globalState.getConfig();
937
+ const store = globalState.getStore();
938
+ if (config.LEGEND_LEVEL_IS_USED && store.legendLevel === void 0) {
939
+ log("Skip fetchUnreadOfferNotificationsCount due to legendLevel is undefined");
940
+ return;
941
+ }
942
+ if (!store.isCanvas && store.token && store.unreadOfferNotifsCountUrl) {
943
+ log("fetchUnreadOfferNotificationsCount");
944
+ let unreadCount = 0;
945
+ const headers = {
946
+ Authorization: `Bearer ${store.token}`
947
+ };
948
+ const url = store.unreadOfferNotifsCountUrl.replace("{locale}", store.language || "").replace("{zoneId}", store.zoneId || "").replace("{criteria}", encodeURIComponent(JSON.stringify(criteriaSelector(store))));
949
+ try {
950
+ log("fetch", url);
951
+ const resp = await fetch(url, {
952
+ headers
953
+ });
954
+ if (resp.ok) {
955
+ const data = await resp.json();
956
+ unreadCount = Number(data?.notifCount);
957
+ }
958
+ } catch (error) {
959
+ logError(`cannot fetch ${url}`, error);
960
+ }
961
+ log("setUnseenOffersCounter", unreadCount);
962
+ store.gameApi.invokeFn("setUnseenOffersCounter", unreadCount).catch((error) => {
963
+ logError("setUnseenOffersCounter error:", error);
964
+ });
965
+ }
966
+ };
967
+
968
+ // src/messages/ShopMessageBus.ts
969
+ init_define_process();
970
+ var ShopMessageBus = class {
971
+ post(message) {
972
+ const element = document.querySelector("#dialog");
973
+ if (element && element.tagName.toLocaleLowerCase() === "iframe") {
974
+ element.contentWindow?.postMessage(message, "*");
975
+ }
976
+ }
977
+ };
978
+
979
+ // src/preFetch.ts
980
+ init_define_process();
981
+ var preResolveConfig = () => {
982
+ if (typeof fetch !== "function") {
983
+ return;
984
+ }
985
+ const originalCustomUrl = createCustomizationUrl();
986
+ let resolvedUrl = "";
987
+ fetch(originalCustomUrl).then((resp) => {
988
+ const currentCustomUrl = createCustomizationUrl();
989
+ if (currentCustomUrl === originalCustomUrl) {
990
+ resolvedUrl = resp.url;
991
+ log("parsed customization url is " + resolvedUrl);
992
+ globalState.updateStore({
993
+ resolvedCustomizationUrl: resolvedUrl
994
+ });
995
+ return resp.json();
996
+ }
997
+ }).then((config) => {
998
+ if (config) {
999
+ globalState.updateStore({
1000
+ unreadOfferNotifsCountUrl: config.unreadOfferNotifsCountUrl || ""
1001
+ });
1002
+ }
1003
+ });
1004
+ };
1005
+
1006
+ // src/types/store.ts
1007
+ init_define_process();
1008
+ var entityProvider = (initial) => {
1009
+ let element = initial;
1010
+ return {
1011
+ get: () => element,
1012
+ set: (value) => {
1013
+ element = value;
1014
+ }
1015
+ };
1016
+ };
1017
+
1018
+ // src/globalState.ts
1019
+ var GlobalState = class {
1020
+ constructor() {
1021
+ this.config = void 0;
1022
+ this.cxfProvider = entityProvider();
1023
+ this.dialogProvider = entityProvider();
1024
+ this.storeProvider = entityProvider();
1025
+ this.shopMessageBus = new ShopMessageBus();
1026
+ this.fetchUnreadOfferNotificationsCount = fetchUnreadOfferNotificationsCount;
1027
+ this.preResolveConfig = preResolveConfig;
1028
+ }
1029
+ setConfig(config) {
1030
+ this.config = config;
1031
+ }
1032
+ getConfig() {
1033
+ if (this.config === void 0) {
1034
+ throw new Error("Config is not initialized");
1035
+ }
1036
+ return this.config;
1037
+ }
1038
+ setCxf(cxf) {
1039
+ this.cxfProvider.set(cxf);
1040
+ }
1041
+ getCxf() {
1042
+ const cxf = this.cxfProvider.get();
1043
+ if (!cxf) {
1044
+ throw new Error("CXF is not loaded");
1045
+ }
1046
+ return cxf;
1047
+ }
1048
+ setStore(store) {
1049
+ this.storeProvider.set(store);
1050
+ }
1051
+ getStore() {
1052
+ const store = this.storeProvider.get();
1053
+ if (!store) {
1054
+ throw new Error("Store is not initialized");
1055
+ }
1056
+ return store;
1057
+ }
1058
+ updateStore(data) {
1059
+ const currentStore = this.getStore();
1060
+ this.setStore({
1061
+ ...currentStore,
1062
+ ...data
1063
+ });
1064
+ }
1065
+ };
1066
+ var globalState = new GlobalState();
1067
+
1068
+ // src/handlers/cxfEventHandlers.ts
1069
+ init_define_process();
1070
+ var import_cxf_events = __toESM(require_typings());
1071
+
1072
+ // src/dialog.ts
1073
+ init_define_process();
1074
+ var createDialog = (url) => {
1075
+ const config = globalState.getConfig();
1076
+ const cxf = globalState.getCxf();
1077
+ cxf.emit(config.CXF_DIALOG_OPEN, url);
1078
+ };
1079
+
1080
+ // src/track.ts
1081
+ init_define_process();
1082
+ var trackOpenAction = (sid) => {
1083
+ const config = globalState.getConfig();
1084
+ const store = globalState.getStore();
1085
+ const now = Date.now();
1086
+ const parameters = getTokenAndLanguage(store);
1087
+ const { zoneId } = parameters;
1088
+ const sessionId = sid;
1089
+ const { playerId, gameId, networkId, instanceId, sourceId } = store;
1090
+ trackAction({
1091
+ eventId: config.WEB_SHOP_CALL_TRACK_ID,
1092
+ date: msToSec(now),
1093
+ unixtimeMS: now,
1094
+ sessionId,
1095
+ zoneId: zoneId ? Number.parseInt(zoneId, 10) : void 0,
1096
+ playerId: Number.parseInt(playerId, 10),
1097
+ gameId: Number.parseInt(gameId, 10),
1098
+ networkId: Number.parseInt(networkId, 10),
1099
+ instanceId: Number.parseInt(instanceId, 10),
1100
+ sourceId
1101
+ });
1102
+ };
1103
+ var trackAction = (payload) => {
1104
+ const config = globalState.getConfig();
1105
+ const cxf = globalState.getCxf();
1106
+ cxf.emit(config.CXF_TRACK_MSG, payload);
1107
+ };
1108
+
1109
+ // src/types/index.ts
1110
+ init_define_process();
1111
+
1112
+ // src/types/config.ts
1113
+ init_define_process();
1114
+
1115
+ // src/whitelist.ts
1116
+ init_define_process();
1117
+ var whitelistedZones = /* @__PURE__ */ new Set([
1118
+ // 264, Poland
1119
+ 316,
1120
+ 318,
1121
+ 460,
1122
+ 461,
1123
+ 767,
1124
+ 768,
1125
+ 802,
1126
+ 814,
1127
+ 830,
1128
+ 877
1129
+ ]);
1130
+
1131
+ // src/handlers/pushHandlers.ts
1132
+ init_define_process();
1133
+ var onReward = (payload) => {
1134
+ log("OnReward: payload", payload);
1135
+ const { isCanvas } = globalState.getStore();
1136
+ if (isCanvas) {
1137
+ window.CanvasAgent?.instance?.hide();
1138
+ window.CanvasAgent?.instance?.navigate();
1139
+ return;
1140
+ }
1141
+ const url = createIframeUrl({
1142
+ route: encodeURIComponent(payload.successUrl),
1143
+ ...payload
1144
+ });
1145
+ globalState.updateStore({
1146
+ lastPurchaseTab: payload.page,
1147
+ sourceId: "successfulPayoutReward"
1148
+ });
1149
+ trackOpenAction(payload.sid);
1150
+ createDialog(url);
1151
+ };
1152
+ var onLemonstandCategoryUpdate = ({ target, action, data }) => {
1153
+ globalState.shopMessageBus.post({
1154
+ eventName: "lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */,
1155
+ target,
1156
+ data: { action, data }
1157
+ });
1158
+ };
1159
+ var onLemonstandNotificationsCreated = ({ notifCount }) => {
1160
+ log("onLemonstandNotificationsCreated -> notifCount:", notifCount);
1161
+ const store = globalState.getStore();
1162
+ if (notifCount > 0) {
1163
+ const randomDelayMs = Math.floor(Math.random() * (Number(store.networkId) < 250 ? 12e4 : 15e3));
1164
+ setTimeout(() => {
1165
+ fetchUnreadOfferNotificationsCount();
1166
+ }, randomDelayMs);
1167
+ } else {
1168
+ store.gameApi.invokeFn("setUnseenOffersCounter", 0).catch((error) => {
1169
+ logError("setUnseenOffersCounter error:", error);
1170
+ });
1171
+ }
1172
+ };
1173
+ var createPushHandlers = () => {
1174
+ return {
1175
+ reward: onReward,
1176
+ reward_received: onReward,
1177
+ ["lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */]: onLemonstandCategoryUpdate,
1178
+ ["lemonstand.notifs.created" /* LEMONSTAND_NOTIFICATIONS_CREATED */]: onLemonstandNotificationsCreated
1179
+ };
1180
+ };
1181
+
1182
+ // src/handlers/cxfEventHandlers.ts
1183
+ var isWindowMessageListenerAttached = false;
1184
+ var eventListener = (event) => {
1185
+ log(`Canvas event "${event.eventType}" received:`, event);
1186
+ switch (event.eventType) {
1187
+ case "native_catalog_request" /* NATIVE_CATALOG_REQUEST */: {
1188
+ if (event?.paymentContractIds?.length > 0) {
1189
+ if (!isWindowMessageListenerAttached) {
1190
+ window.addEventListener("message", ({ data }) => {
1191
+ if (data?.eventName === "lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */ && data?.data?.action === "nativePriceUpdate") {
1192
+ log(`${"lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */} event`, data.data);
1193
+ if (!data.data.data) return;
1194
+ const nativeCatalog = {};
1195
+ for (const key in data.data.data) {
1196
+ const { priceString, ...rest } = data.data.data[key];
1197
+ nativeCatalog[key] = rest;
1198
+ }
1199
+ log("nativeCatalog:", nativeCatalog);
1200
+ window.CanvasAgent?.instance?.setNativeCatalog(nativeCatalog);
1201
+ }
1202
+ });
1203
+ isWindowMessageListenerAttached = true;
1204
+ }
1205
+ const msg = transformPaymentContractIdsToNativePriceEvent(event.paymentContractIds);
1206
+ window.postMessage(msg, "*");
1207
+ log("Event `lemonstand.nativePrice` sent");
1208
+ }
1209
+ break;
1210
+ }
1211
+ case "native_checkout_request" /* NATIVE_CHECKOUT_REQUEST */: {
1212
+ const { paymentContract, sessionId, collectionAlias, offerId, distributionPlatform } = event;
1213
+ const { zoneId } = globalState.getStore();
1214
+ window.postMessage(
1215
+ {
1216
+ eventName: "lemonstand.nativePay",
1217
+ eventType: "bubble",
1218
+ nativePayInfo: {
1219
+ pkg: {
1220
+ price: paymentContract?.price?.amount,
1221
+ productIdMS: "",
1222
+ productIds: createProductIdsForPlatform(distributionPlatform, paymentContract?.id),
1223
+ tier: Number(paymentContract?.id?.split("_")?.at(-1))
1224
+ },
1225
+ meta: {
1226
+ criteria: JSON.stringify({}),
1227
+ lemonstand: true,
1228
+ offerId,
1229
+ sid: sessionId,
1230
+ type: collectionAlias,
1231
+ zoneId,
1232
+ successUrl: window.location.href
1233
+ }
1234
+ }
1235
+ },
1236
+ "*"
1237
+ );
1238
+ log("Event `lemonstand.nativePay` sent");
1239
+ break;
1240
+ }
1241
+ default: {
1242
+ break;
1243
+ }
1244
+ }
1245
+ };
1246
+ var onOpen = (payload = {}) => {
1247
+ log(import_cxf_events.CxfEvents.OpenIGS, "payload:", payload);
1248
+ if (payload.sourceId) {
1249
+ globalState.updateStore({
1250
+ sourceId: payload.sourceId
1251
+ });
1252
+ }
1253
+ const { isCanvas, lastPurchaseTab, gameApi } = globalState.getStore();
1254
+ if (isCanvas) {
1255
+ if (payload.page) {
1256
+ window.CanvasAgent?.instance?.navigate(payload.page);
1257
+ }
1258
+ window.CanvasAgent?.instance?.show();
1259
+ return;
1260
+ }
1261
+ const sid = createSessionId();
1262
+ trackOpenAction(sid);
1263
+ const url = createIframeUrl({
1264
+ sid,
1265
+ page: lastPurchaseTab,
1266
+ ...payload
1267
+ });
1268
+ createDialog(url);
1269
+ setTimeout(() => {
1270
+ gameApi.invokeFn("setUnseenOffersCounter", 0);
1271
+ }, 1e3);
1272
+ };
1273
+ var subscribeToCommonCxfEvents = (cxf) => {
1274
+ const pushHandlers = createPushHandlers();
1275
+ cxf.on(import_cxf_events.CxfEvents.OpenIGS, tryCatch(onOpen));
1276
+ cxf.on(
1277
+ import_cxf_events.CxfEvents.Push,
1278
+ tryCatch(({ id, payload }) => {
1279
+ log(import_cxf_events.CxfEvents.Push, id, payload);
1280
+ const handler = pushHandlers[id];
1281
+ handler && handler(payload);
1282
+ })
1283
+ );
1284
+ };
1285
+ var subscribeToGameEvents = (cxf) => {
1286
+ cxf.on(import_cxf_events.CxfEvents.Login, (e) => {
1287
+ const { gameEvents: eventsInLogin, language, token, zoneId } = e;
1288
+ if (whitelistedZones.has(Number(zoneId)) && (Number(zoneId) > 300 || localStorage.getItem("cxf_canvas") === "enabled")) {
1289
+ globalState.updateStore({
1290
+ isCanvas: true
1291
+ });
1292
+ }
1293
+ const { gameEvents, isCanvas } = globalState.getStore();
1294
+ const eventNotExistPredicateGenerator = (existingEvents) => (event) => !existingEvents.map((event_) => event_.type).includes(event.type);
1295
+ globalState.updateStore({
1296
+ ...e,
1297
+ gameEvents: [...gameEvents.filter(eventNotExistPredicateGenerator(eventsInLogin)), ...eventsInLogin]
1298
+ });
1299
+ log(import_cxf_events.CxfEvents.Login, globalState.getStore());
1300
+ if (!isCanvas) {
1301
+ globalState.fetchUnreadOfferNotificationsCount();
1302
+ return;
1303
+ }
1304
+ if (typeof window.CanvasAgent?.create === "function") {
1305
+ const { CANVAS_APP_ID_BY_GAME } = globalState.getConfig();
1306
+ const platform = detectPlatform();
1307
+ const canvasApps = CANVAS_APP_ID_BY_GAME[cxf.gameId];
1308
+ const canvasAppId = typeof canvasApps === "string" ? canvasApps : canvasApps?.[platform];
1309
+ window.CanvasAgent.create({
1310
+ authClientId: "lemonstand",
1311
+ canvasAppId,
1312
+ eventListener,
1313
+ locale: language,
1314
+ token
1315
+ }).then((res) => {
1316
+ window.CanvasAgent.instance = res;
1317
+ log(import_cxf_events.CxfEvents.Login, "Canvas created");
1318
+ }).catch((error) => {
1319
+ logError("Cannot create instance of Canvas", error);
1320
+ });
1321
+ }
1322
+ });
1323
+ cxf.on(import_cxf_events.CxfEvents.GameEventUpdate, (e) => {
1324
+ log(import_cxf_events.CxfEvents.GameEventUpdate, e);
1325
+ const { gameEvents, isCanvas } = globalState.getStore();
1326
+ const updatedEventTypes = new Set(e.map((event) => event.type));
1327
+ globalState.updateStore({
1328
+ gameEvents: [...gameEvents.filter((event) => !updatedEventTypes.has(event.type)), ...e]
1329
+ });
1330
+ if (isCanvas) {
1331
+ window.CanvasAgent?.instance?.refresh();
1332
+ }
1333
+ log(import_cxf_events.CxfEvents.GameEventUpdate, "reducer", globalState.getStore());
1334
+ });
1335
+ cxf.on(import_cxf_events.CxfEvents.GameEventAdd, (e) => {
1336
+ log(import_cxf_events.CxfEvents.GameEventAdd, e);
1337
+ const { gameEvents, isCanvas } = globalState.getStore();
1338
+ globalState.updateStore({
1339
+ gameEvents: [...gameEvents, e]
1340
+ });
1341
+ if (isCanvas) {
1342
+ window.CanvasAgent?.instance?.refresh();
1343
+ }
1344
+ log(import_cxf_events.CxfEvents.GameEventAdd, "reducer", globalState.getStore());
1345
+ });
1346
+ cxf.on(import_cxf_events.CxfEvents.GameEventRemove, (e) => {
1347
+ log(import_cxf_events.CxfEvents.GameEventRemove, e);
1348
+ const { gameEvents, isCanvas } = globalState.getStore();
1349
+ globalState.updateStore({
1350
+ gameEvents: gameEvents.filter(({ type }) => type !== e)
1351
+ });
1352
+ if (isCanvas) {
1353
+ window.CanvasAgent?.instance?.refresh();
1354
+ }
1355
+ log(import_cxf_events.CxfEvents.GameEventRemove, "reducer", globalState.getStore());
1356
+ });
1357
+ cxf.on(import_cxf_events.CxfEvents.LevelChanged, (level) => {
1358
+ log(import_cxf_events.CxfEvents.LevelChanged, level);
1359
+ const { isCanvas } = globalState.getStore();
1360
+ globalState.updateStore({
1361
+ level
1362
+ });
1363
+ log(import_cxf_events.CxfEvents.LevelChanged, "reducer", globalState.getStore());
1364
+ if (isCanvas) {
1365
+ window.CanvasAgent?.instance?.refresh();
1366
+ } else {
1367
+ globalState.fetchUnreadOfferNotificationsCount();
1368
+ }
1369
+ });
1370
+ cxf.on(import_cxf_events.CxfEvents.LegendLevelChanged, (legendLevel) => {
1371
+ log(import_cxf_events.CxfEvents.LegendLevelChanged, `legendLevel: ${legendLevel}`);
1372
+ globalState.updateStore({
1373
+ legendLevel
1374
+ });
1375
+ const store = globalState.getStore();
1376
+ log(import_cxf_events.CxfEvents.LegendLevelChanged, "reducer", store);
1377
+ globalState.fetchUnreadOfferNotificationsCount();
1378
+ });
1379
+ };
1380
+ var subscribeToNativeSubscriptionEnable = (cxf) => {
1381
+ cxf.on("cxf.native.subscription.enable" /* CXF_NATIVE_SUBSCRIPTION_ENABLE */, (enabled) => {
1382
+ globalState.updateStore({
1383
+ subscriptionDisabled: enabled === 0,
1384
+ customizationSuffix: enabled === 0 ? "no-subscription" : ""
1385
+ });
1386
+ globalState.preResolveConfig();
1387
+ });
1388
+ };
1389
+ var subscribeToCustomizationSuffix = (cxf) => {
1390
+ cxf.on("cxf.set.customization.surfix" /* CXF_SET_CUSTOMIZATION_SUFFIX */, (suffix) => {
1391
+ const { customizationSuffix } = globalState.getStore();
1392
+ if (suffix === customizationSuffix) {
1393
+ return;
1394
+ }
1395
+ globalState.updateStore({
1396
+ customizationSuffix: suffix || ""
1397
+ });
1398
+ globalState.preResolveConfig();
1399
+ });
1400
+ };
1401
+ var subscribeToAdStatus = (cxf) => {
1402
+ const config = globalState.getConfig();
1403
+ cxf.on(config.CXF_AD_STATUS, ({ areBannersAvailable, bannersDetails }) => {
1404
+ globalState.updateStore({
1405
+ adStatus: {
1406
+ areBannersAvailable,
1407
+ bannersDetails
1408
+ }
1409
+ });
1410
+ });
1411
+ };
1412
+ var subscribeToTempServerContext = (cxf) => {
1413
+ cxf.on("cxf.join.temp.server" /* CXF_JOIN_TEMP_SERVER */, (isTemp) => {
1414
+ const store = globalState.getStore();
1415
+ globalState.updateStore({
1416
+ isTempServer: Boolean(isTemp)
1417
+ });
1418
+ if (store.customizationSuffix === "" || store.customizationSuffix === "temp") {
1419
+ globalState.updateStore({
1420
+ customizationSuffix: isTemp ? "temp" : ""
1421
+ });
1422
+ globalState.preResolveConfig();
1423
+ }
1424
+ });
1425
+ };
1426
+ var createCxfEventHandlers = () => {
1427
+ return [
1428
+ subscribeToCommonCxfEvents,
1429
+ subscribeToGameEvents,
1430
+ subscribeToAdStatus,
1431
+ subscribeToTempServerContext,
1432
+ subscribeToNativeSubscriptionEnable,
1433
+ subscribeToCustomizationSuffix
1434
+ ];
1435
+ };
1436
+
1437
+ // src/handlers/postMessageHandlers.ts
1438
+ init_define_process();
1439
+ var onSalesPageOpen = () => {
1440
+ log("OnOpenSalesOffersPage");
1441
+ const { isCanvas } = globalState.getStore();
1442
+ if (isCanvas) {
1443
+ window.CanvasAgent?.instance?.navigate("supersale");
1444
+ return;
1445
+ }
1446
+ const sid = createSessionId();
1447
+ const url = createIframeUrl({
1448
+ page: "sale-offers",
1449
+ sid
1450
+ });
1451
+ createDialog(url);
1452
+ };
1453
+ var onLemonstandClose = () => {
1454
+ const store = globalState.getStore();
1455
+ log("onLemonstandClose", store);
1456
+ fetchUnreadOfferNotificationsCount();
1457
+ };
1458
+ var createPostMessageHandlers = () => {
1459
+ return {
1460
+ ["cxf.webshop.sales.open" /* CXF_OPEN_SALES_MSG */]: onSalesPageOpen,
1461
+ ["cxf.dialog.close" /* CXF_DIALOG_CLOSE */]: onLemonstandClose
1462
+ };
1463
+ };
1464
+
1465
+ // src/app.ts
1466
+ var app = (cxf) => {
1467
+ const postMessageHandlers = createPostMessageHandlers();
1468
+ const subscribeCxf = createCxfEventHandlers();
1469
+ window.addEventListener(
1470
+ "message",
1471
+ tryCatch(({ data }) => {
1472
+ if (data) {
1473
+ const handler = postMessageHandlers[data.name];
1474
+ if (handler) {
1475
+ log("POST MESSAGE", data);
1476
+ handler(data.payload);
1477
+ }
1478
+ }
1479
+ })
1480
+ );
1481
+ for (const handler of subscribeCxf) {
1482
+ handler(cxf);
1483
+ }
1484
+ globalState.preResolveConfig();
1485
+ log("App has started");
1486
+ };
1487
+
1488
+ // src/config.ts
1489
+ init_define_process();
1490
+ var import_cxf_events2 = __toESM(require_typings());
1491
+ var COMMON_CONFIG = {
1492
+ CANVAS_AGENT_URL: define_process_default.env.CANVAS_AGENT_URL,
1493
+ CANVAS_APP_ID_BY_GAME: define_process_default.env.CANVAS_APP_ID_BY_GAME,
1494
+ CUSTOMIZATION_URL: define_process_default.env.CUSTOMIZATION_URL,
1495
+ CUSTOMIZATION_URL_TEMPLATE: define_process_default.env.CUSTOMIZATION_URL_TEMPLATE,
1496
+ BASE_URL: define_process_default.env.BASE_URL,
1497
+ CXF_DIALOG_OPEN: "cxf.dialog.open",
1498
+ CXF_DIALOG_CLOSE: "cxf.dialog.close",
1499
+ CXF_TRACK_MSG: "cxf.tracking.message",
1500
+ CXF_BTN_CLICK_MSG: import_cxf_events2.CxfEvents.OpenIGS,
1501
+ CXF_OPEN_SALES_MSG: "cxf.webshop.sales.open" /* CXF_OPEN_SALES_MSG */,
1502
+ WEB_SHOP_CALL_TRACK_ID: 1181,
1503
+ CXF_ERROR: "cxf.error",
1504
+ CXF_PUSH: "cxf.push",
1505
+ CXF_AD_STATUS: "cxf.adBanner.status"
1506
+ };
1507
+ var GAME_SPECIFIC_CONFIG = {
1508
+ 12: {
1509
+ LEGEND_LEVEL_IS_USED: true
1510
+ },
1511
+ 15: {
1512
+ LEGEND_LEVEL_IS_USED: false
1513
+ },
1514
+ 16: {
1515
+ LEGEND_LEVEL_IS_USED: true
1516
+ }
1517
+ };
1518
+ var createConfig = (gameId) => {
1519
+ return {
1520
+ ...COMMON_CONFIG,
1521
+ ...GAME_SPECIFIC_CONFIG[gameId]
1522
+ };
1523
+ };
1524
+
1525
+ // src/index.ts
1526
+ require_dist().then((cxf) => {
1527
+ const config = createConfig(cxf.gameId);
1528
+ globalState.setConfig(config);
1529
+ globalState.setCxf(cxf);
1530
+ const store = initializeStore(cxf);
1531
+ globalState.setStore(store);
1532
+ loadScript(config.CANVAS_AGENT_URL).then(() => {
1533
+ log(`Canvas agent loaded: ${config.CANVAS_AGENT_URL}`);
1534
+ }).catch((error) => {
1535
+ logError("Canvas agent load error", error);
1536
+ });
1537
+ app(cxf);
1538
+ });
1539
+ })();
2
1540
  //# sourceMappingURL=webshop-cxf.js.map