@goodgamestudios/cxf-webshop 7.1.4 → 7.1.5-ef-qa.6

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 +1,1618 @@
1
- "use strict";(()=>{var Ze=Object.create;var ce=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var qe=(e,r)=>()=>(e&&(r=e(e=0)),r);var O=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var We=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ke(r))!Ye.call(e,i)&&i!==t&&ce(e,i,{get:()=>r[i],enumerable:!(n=Je(r,i))||n.enumerable});return e};var B=(e,r,t)=>(t=e!=null?Ze(Qe(e)):{},We(r||!e||!e.__esModule?ce(t,"default",{value:e,enumerable:!0}):t,e));var a,o=qe(()=>{a={env:{BASE_URL:{"12":"https://canvas.goodgamestudios.com","15":"https://canvas.goodgamestudios.com","16":"https://canvas.goodgamestudios.com",default:"https://canvas.goodgamestudios.com"},CANVAS_AGENT_URL:"https://app.canvas.stillfront.com/agent.js",CANVAS_APP_ID_BY_GAME:{"12":"","15":{google:"a9510af7-9092-4f2f-8c09-4e9dde1a0d91",stillpay:"729bbc22-2cc0-4025-bcda-05aa01b41db2"},"16":""},CUSTOMIZATION_URL_TEMPLATE:"",CUSTOMIZATION_URL:"https://cdn.jsdelivr.net/npm/@lemonstand.org/config-goodgamestudios/dist/goodgamestudios-{0}.json"}}});var le=O((zt,ue)=>{o();var N=1e3,L=N*60,U=L*60,P=U*24,rt=P*7,ot=P*365.25;ue.exports=function(e,r){r=r||{};var t=typeof e;if(t==="string"&&e.length>0)return nt(e);if(t==="number"&&isFinite(e))return r.long?it(e):st(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function nt(e){if(e=String(e),!(e.length>100)){var r=/^(-?(?:\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(r){var t=parseFloat(r[1]),n=(r[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*ot;case"weeks":case"week":case"w":return t*rt;case"days":case"day":case"d":return t*P;case"hours":case"hour":case"hrs":case"hr":case"h":return t*U;case"minutes":case"minute":case"mins":case"min":case"m":return t*L;case"seconds":case"second":case"secs":case"sec":case"s":return t*N;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function st(e){var r=Math.abs(e);return r>=P?Math.round(e/P)+"d":r>=U?Math.round(e/U)+"h":r>=L?Math.round(e/L)+"m":r>=N?Math.round(e/N)+"s":e+"ms"}function it(e){var r=Math.abs(e);return r>=P?V(e,r,P,"day"):r>=U?V(e,r,U,"hour"):r>=L?V(e,r,L,"minute"):r>=N?V(e,r,N,"second"):e+" ms"}function V(e,r,t,n){var i=r>=t*1.5;return Math.round(e/t)+" "+n+(i?"s":"")}});var ge=O((Ht,me)=>{o();function at(e){t.debug=t,t.default=t,t.coerce=y,t.disable=C,t.enable=i,t.enabled=w,t.humanize=le(),t.destroy=E,Object.keys(e).forEach(d=>{t[d]=e[d]}),t.names=[],t.skips=[],t.formatters={};function r(d){let c=0;for(let m=0;m<d.length;m++)c=(c<<5)-c+d.charCodeAt(m),c|=0;return t.colors[Math.abs(c)%t.colors.length]}t.selectColor=r;function t(d){let c,m=null,I,b;function l(...g){if(!l.enabled)return;let v=l,S=Number(new Date),_=S-(c||S);v.diff=_,v.prev=c,v.curr=S,c=S,g[0]=t.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let A=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(F,te)=>{if(F==="%%")return"%";A++;let ae=t.formatters[te];if(typeof ae=="function"){let $e=g[A];F=ae.call(v,$e),g.splice(A,1),A--}return F}),t.formatArgs.call(v,g),(v.log||t.log).apply(v,g)}return l.namespace=d,l.useColors=t.useColors(),l.color=t.selectColor(d),l.extend=n,l.destroy=t.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(I!==t.namespaces&&(I=t.namespaces,b=t.enabled(d)),b),set:g=>{m=g}}),typeof t.init=="function"&&t.init(l),l}function n(d,c){let m=t(this.namespace+(typeof c>"u"?":":c)+d);return m.log=this.log,m}function i(d){t.save(d),t.namespaces=d,t.names=[],t.skips=[];let c=(typeof d=="string"?d:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of c)m[0]==="-"?t.skips.push(m.slice(1)):t.names.push(m)}function u(d,c){let m=0,I=0,b=-1,l=0;for(;m<d.length;)if(I<c.length&&(c[I]===d[m]||c[I]==="*"))c[I]==="*"?(b=I,l=m,I++):(m++,I++);else if(b!==-1)I=b+1,l++,m=l;else return!1;for(;I<c.length&&c[I]==="*";)I++;return I===c.length}function C(){let d=[...t.names,...t.skips.map(c=>"-"+c)].join(",");return t.enable(""),d}function w(d){for(let c of t.skips)if(u(d,c))return!1;for(let c of t.names)if(u(d,c))return!0;return!1}function y(d){return d instanceof Error?d.stack||d.message:d}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 t.enable(t.load()),t}me.exports=at});var pe=O((h,j)=>{o();h.formatArgs=dt;h.save=ft;h.load=ut;h.useColors=ct;h.storage=lt();h.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`."))}})();h.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 ct(){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 dt(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+j.exports.humanize(this.diff),!this.useColors)return;let r="color: "+this.color;e.splice(1,0,r,"color: inherit");let t=0,n=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(t++,i==="%c"&&(n=t))}),e.splice(n,0,r)}h.log=console.debug||console.log||(()=>{});function ft(e){try{e?h.storage.setItem("debug",e):h.storage.removeItem("debug")}catch{}}function ut(){let e;try{e=h.storage.getItem("debug")||h.storage.getItem("DEBUG")}catch{}return!e&&typeof a<"u"&&"env"in a&&(e=a.env.DEBUG),e}function lt(){try{return localStorage}catch{}}j.exports=ge()(h);var{formatters:mt}=j.exports;mt.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}});var re=O((qt,Ie)=>{"use strict";o();var $=window&&window.CXF;Ie.exports=new Promise(function(e,r){if(window||r(),$)return e($);window.addEventListener("cxf.initialized",function(t){$=t.cxf,e($)},{capture:!0,once:!0,passive:!0})})});var Oe=O((_e,oe)=>{o();(function(){var e={};function r(l,g){return i(l)||n(l,g)||t()}function t(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function n(l,g){var v=[],S=!0,_=!1,A=void 0;try{for(var ee,F=l[Symbol.iterator]();!(S=(ee=F.next()).done)&&(v.push(ee.value),!g||v.length!==g);S=!0);}catch(te){_=!0,A=te}finally{try{S||F.return==null||F.return()}finally{if(_)throw A}}return v}function i(l){if(Array.isArray(l))return l}var u=0,C=1,w=2,y={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(y).reduce(function(l,g){var v=r(g,2),S=v[0],_=v[1];return S=parseInt(S,10),l[S]=S,_.forEach(function(A){l[A]=S}),l},{}),d=function(l){l=l.toString().toLowerCase();var g=E[l];return g&&0|g},c=function(l,g){return(g=E[g])&&y[g][l]},m=c.bind(null,u),I=c.bind(null,C),b=c.bind(null,w);e={id:d,name:m,codename:I,acronym:b},typeof _e=="object"&&typeof oe<"u"?oe.exports=e:typeof define=="function"&&define.amd&&define(function(){return e})})()});var ne=O(z=>{"use strict";o();Object.defineProperty(z,"__esModule",{value:!0});z.CxfEvents=void 0;var vt;(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"})(vt=z.CxfEvents||(z.CxfEvents={}))});o();o();o();o();o();function de(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 H({legendLevel:e,level:r}){return{legendLevel:e,level:r}}o();o();var tt=e=>{let r=e.match(/^https?:\/\/([^#/?]+)(?:[#/?]|$)/i);if(!r||!r[1])return;let t=r[1].match(/[^.]+\.[^.]+$/);if(t)return t[0]},fe=e=>tt(e);o();o();var Ce=B(pe()),gt=(0,Ce.default)("CXF-WEBSHOP"),f=(e,...r)=>gt(e,...r),x=(...e)=>console.error("%c CXF-WEBSHOP ->","background: #ff0000; color: #fff",...e);var X=e=>(...r)=>{try{return e(...r)}catch(t){x(t),pt(t)}},pt=e=>{let r=s.getConfig();s.getCxf().emit(r.CXF_ERROR,e)};o();var Ct=(e,r)=>{let t=setTimeout(e,r);return()=>clearTimeout(t)},It=(e,r)=>t=>new Promise((n,i)=>{let u=Ct(()=>{i(new Error(`Timeout has exceeded ${r}`))},r);e(t).then(C=>{n(C),u()}).catch(i)}),ve=e=>new Promise((r,t)=>{let n=document.createElement("script");n.type="text/javascript",n.type="module",n.async=!0,n.src=e,n.addEventListener("load",r),n.addEventListener("error",t),document.body.append(n)}),er=It(()=>re(),1e4);o();var Se=e=>e.reduce((r,t,n)=>(r.offers.push({id:t,tier:0,productIds:{googleplay:t}}),r),{category:"all",offers:[],eventName:"lemonstand.nativePrice",eventType:"bubble"});o();var he={itunes:"apple",Android:"google",googleplay:"google",amazonmobile:"amazon",facebook:"facebook",samsung:"samsung",huawei:"huawei"},Ee=(e="stillpay")=>{let r=navigator.userAgent.match(/(itunes)|(googleplay)|(Android)|(amazonmobile)|(facebook)|(samsung)|(huawei)/g);if(!r)return e;let t=r[0];return Object.prototype.hasOwnProperty.call(he,t)?he[t]:e},ye={apple:"itunes",google:"googleplay",amazon:"amazonmobile",facebook:"facebook",samsung:"samsung",huawei:"huawei"},be=(e,r)=>{if(!Object.prototype.hasOwnProperty.call(ye,e))throw new Error(`Platform ${e} is not supported`);let t=Object.create(null);return t[ye[e]]=r,t};o();function xe(e){return Object.entries(e).filter(([r,t])=>t!=null).map(([r,t])=>`${r}=${encodeURIComponent(t)}`).join("&")}var we=()=>ggsGetQueryParameters(),Ae=()=>ggsGetReferrer();o();o();var T=256,J=[],Z;for(;T--;)J[T]=(T+256).toString(16).substring(1);function Fe(){var e=0,r,t="";if(!Z||T+16>256){for(Z=Array(e=256);e--;)Z[e]=256*Math.random()|0;e=T=0}for(;e<16;e++)r=Z[T+e],e==6?t+=J[r&15|64]:e==8?t+=J[r&63|128]:t+=J[r],e&1&&e>1&&e<11&&(t+="-");return T++,t}o();var R=class extends Error{constructor(r,t){super(`${r} has null value: ${t}`),this.name="ArgumentNullError"}};o();function Pe({gameId:e,networkId:r,instanceId:t,playerId:n}){return[e,r,t,n].join("-")}var G=()=>Fe(),K=e=>{let{playerId:r,token:t,zoneId:n,language:i}=e;if(!r)throw new R("playerId",r);return{token:t,zoneId:n,locale:i,ping:Pe({...e,playerId:r})}};o();function Te(e){return Math.floor(e/1e3)}o();var Me=B(Oe());o();var Ne=B(ne());o();o();o();var Q=e=>{let r=e;return{get:()=>r,set:t=>{r=t}}};var St=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch{return{default:e}}return e||{default:""}},Le={CANVAS_AGENT_URL:a.env.CANVAS_AGENT_URL,CANVAS_APP_ID_BY_GAME:a.env.CANVAS_APP_ID_BY_GAME,CUSTOMIZATION_URL:a.env.CUSTOMIZATION_URL,CUSTOMIZATION_URL_TEMPLATE:a.env.CUSTOMIZATION_URL_TEMPLATE,BASE_URL:St(a.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:Ne.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"},ht={12:{LEGEND_LEVEL_IS_USED:!0},15:{LEGEND_LEVEL_IS_USED:!1},16:{LEGEND_LEVEL_IS_USED:!0}},Ue=e=>({...Le,...ht[e]}),Re=e=>{let r=Le.BASE_URL,t=String(e);return r[t]||r.default||""};o();var Ge=e=>{for(let r of Object.keys(e)){let t=e[r];if(t==null||Number.isNaN(t))throw new R(r,t)}};var M=({page:e,route:r,sid:t,config:n={}})=>{let i=s.getStore(),{token:u,zoneId:C,locale:w}=K(i),y={token:u,zoneId:C,locale:w,sid:t||G()};Object.keys(n).length>0&&(y.config=JSON.stringify(n)),Ge(y);let E=new URLSearchParams(we()),d={...y,"lemonstand.customization.url":i.resolvedCustomizationUrl||Y(),domain:fe(Ae()),websiteId:E.get("w"),criteria:JSON.stringify(H(i)),level:i.level},c=E.get("network");return E.get("usekeybaselogin")==="false"&&Number(c)>0&&(d.network=c),i.adStatus?.areBannersAvailable&&(d.ads=!0),`${Re(i.gameId)}/?${xe(d)}${e?`#${e}`:""}${r?`--${r}--${Date.now()}`:""}`},Y=()=>{let e=s.getConfig(),r=s.getStore(),t=s.getCxf(),n=(0,Me.acronym)(r.gameId),i=r.customizationSuffix?`-${r.customizationSuffix}`:"",u=`${n}${i}`;if(t.env==="test"){let C=new URLSearchParams(window.location.search).get("configGGS");if(C!==null)return e.CUSTOMIZATION_URL_TEMPLATE.replace("{0}",u).replace("{1}",C)}return e.CUSTOMIZATION_URL.replace("{0}",u)};var D=async()=>{let e=s.getConfig(),r=s.getStore();if(e.LEGEND_LEVEL_IS_USED&&r.legendLevel===void 0){f("Skip fetchUnreadOfferNotificationsCount due to legendLevel is undefined");return}if(!r.isCanvas&&r.token&&r.unreadOfferNotifsCountUrl){f("fetchUnreadOfferNotificationsCount");let t=0,n={Authorization:`Bearer ${r.token}`},i=r.unreadOfferNotifsCountUrl.replace("{locale}",r.language||"").replace("{zoneId}",r.zoneId||"").replace("{criteria}",encodeURIComponent(JSON.stringify(H(r))));try{f("fetch",i);let u=await fetch(i,{headers:n});if(u.ok){let C=await u.json();t=Number(C?.notifCount)}}catch(u){x(`cannot fetch ${i}`,u)}f("setUnseenOffersCounter",t),r.gameApi.invokeFn("setUnseenOffersCounter",t).catch(u=>{x("setUnseenOffersCounter error:",u)})}};o();var q=class{post(r){let t=document.querySelector("#dialog");t&&t.tagName.toLocaleLowerCase()==="iframe"&&t.contentWindow?.postMessage(r,"*")}};o();var De=()=>{if(typeof fetch!="function")return;let e=Y(),r="";fetch(e).then(t=>{if(Y()===e)return r=t.url,f("parsed customization url is "+r),s.updateStore({resolvedCustomizationUrl:r}),t.json()}).then(t=>{t&&s.updateStore({unreadOfferNotifsCountUrl:t.unreadOfferNotifsCountUrl||""})})};var ie=class{constructor(){this.config=void 0;this.cxfProvider=Q();this.dialogProvider=Q();this.storeProvider=Q();this.shopMessageBus=new q;this.fetchUnreadOfferNotificationsCount=D;this.preResolveConfig=De}setConfig(r){this.config=r}getConfig(){if(this.config===void 0)throw new Error("Config is not initialized");return this.config}setCxf(r){this.cxfProvider.set(r)}getCxf(){let r=this.cxfProvider.get();if(!r)throw new Error("CXF is not loaded");return r}setStore(r){this.storeProvider.set(r)}getStore(){let r=this.storeProvider.get();if(!r)throw new Error("Store is not initialized");return r}updateStore(r){let t=this.getStore();this.setStore({...t,...r})}},s=new ie;o();var p=B(ne());o();var k=e=>{let r=s.getConfig();s.getCxf().emit(r.CXF_DIALOG_OPEN,e)};o();var W=e=>{let r=s.getConfig(),t=s.getStore(),n=Date.now(),i=K(t),{zoneId:u}=i,C=e,{playerId:w,gameId:y,networkId:E,instanceId:d,sourceId:c}=t;yt({eventId:r.WEB_SHOP_CALL_TRACK_ID,date:Te(n),unixtimeMS:n,sessionId:C,zoneId:u?Number.parseInt(u,10):void 0,playerId:Number.parseInt(w,10),gameId:Number.parseInt(y,10),networkId:Number.parseInt(E,10),instanceId:Number.parseInt(d,10),sourceId:c})},yt=e=>{let r=s.getConfig();s.getCxf().emit(r.CXF_TRACK_MSG,e)};o();var ke=new Set([218,316,318,460,461,768,802,814,830,877]);o();var Xe=e=>{f("OnReward: payload",e);let{isCanvas:r}=s.getStore();if(r){window.CanvasAgent?.instance?.hide(),window.CanvasAgent?.instance?.navigate();return}let t=M({route:encodeURIComponent(e.successUrl),...e});s.updateStore({lastPurchaseTab:e.page,sourceId:"successfulPayoutReward"}),W(e.sid),k(t)},Et=({target:e,action:r,data:t})=>{s.shopMessageBus.post({eventName:"lemonstand.category.update",target:e,data:{action:r,data:t}})},bt=({notifCount:e})=>{f("onLemonstandNotificationsCreated -> notifCount:",e);let r=s.getStore();if(e>0){let t=Math.floor(Math.random()*(Number(r.networkId)<250?12e4:15e3));setTimeout(()=>{D()},t)}else r.gameApi.invokeFn("setUnseenOffersCounter",0).catch(t=>{x("setUnseenOffersCounter error:",t)})},ze=()=>({reward:Xe,reward_received:Xe,"lemonstand.category.update":Et,"lemonstand.notifs.created":bt});var Be=!1,xt=e=>{switch(f(`Canvas event "${e.eventType}" received:`,e),e.eventType){case"native_catalog_request":{if(e?.paymentContractIds?.length>0){Be||(window.addEventListener("message",({data:t})=>{if(t?.eventName==="lemonstand.category.update"&&t?.data?.action==="nativePriceUpdate"){if(f("lemonstand.category.update event",t.data),!t.data.data)return;let n={};for(let i in t.data.data){let{priceString:u,...C}=t.data.data[i];n[i]=C}f("nativeCatalog:",n),window.CanvasAgent?.instance?.setNativeCatalog(n)}}),Be=!0);let r=Se(e.paymentContractIds);window.postMessage(r,"*"),f("Event `lemonstand.nativePrice` sent")}break}case"native_checkout_request":{let{paymentContract:r,sessionId:t,offerId:n,distributionPlatform:i}=e,{zoneId:u}=s.getStore();window.postMessage({eventName:"lemonstand.nativePay",eventType:"bubble",nativePayInfo:{pkg:{price:r?.price?.amount,productIdMS:"",productIds:be(i,r?.id),tier:Number(r?.id?.split("_")?.at(-1))},meta:{criteria:window.CanvasAgent?.instance?.getState()?.appConfig?.canvasAppId,lemonstand:!0,offerId:n,sid:t,type:"canvas",zoneId:u,successUrl:window.location.href}}},"*"),f("Event `lemonstand.nativePay` sent");break}default:break}},wt=(e={})=>{f(p.CxfEvents.OpenIGS,"payload:",e),e.sourceId&&s.updateStore({sourceId:e.sourceId});let{isCanvas:r,lastPurchaseTab:t,gameApi:n}=s.getStore();if(r){e.page&&window.CanvasAgent?.instance?.navigate(e.page),window.CanvasAgent?.instance?.show();return}let i=G();W(i);let u=M({sid:i,page:t,...e});k(u),setTimeout(()=>{n.invokeFn("setUnseenOffersCounter",0)},1e3)},At=e=>{let r=ze();e.on(p.CxfEvents.OpenIGS,X(wt)),e.on(p.CxfEvents.Push,X(({id:t,payload:n})=>{f(p.CxfEvents.Push,t,n);let i=r[t];i&&i(n)}))},Ft=(e,r)=>{let t=0;return(...n)=>{let i=Date.now();i-t>=r&&(t=i,e(...n))}},Pt=e=>{let r=Ft(t=>{let{gameEvents:n,language:i,token:u,zoneId:C}=t;ke.has(Number(C))?s.updateStore({isCanvas:!0}):s.updateStore({isCanvas:!1});let{gameEvents:w,isCanvas:y}=s.getStore(),E=d=>c=>!d.map(m=>m.type).includes(c.type);if(s.updateStore({...t,gameEvents:[...w.filter(E(n)),...n]}),f(p.CxfEvents.Login,s.getStore()),!y){s.fetchUnreadOfferNotificationsCount();return}if(typeof window.CanvasAgent?.create=="function"){let{CANVAS_APP_ID_BY_GAME:d}=s.getConfig(),c=Ee(),m=d[e.gameId],I=typeof m=="string"?m:m[c];if(!I){x("Canvas app id not found for platform",{platform:c,canvasApps:m});return}window.CanvasAgent?.instance?.destroy(),window.CanvasAgent.create({authClientId:"lemonstand",canvasAppId:I,eventListener:xt,locale:i,token:u}).then(b=>{window.CanvasAgent.instance=b,f(p.CxfEvents.Login,"Canvas created")}).catch(b=>{x("Cannot create instance of Canvas",b)})}},3e3);e.on(p.CxfEvents.Login,r),e.on(p.CxfEvents.GameEventUpdate,t=>{f(p.CxfEvents.GameEventUpdate,t);let{gameEvents:n,isCanvas:i}=s.getStore(),u=new Set(t.map(C=>C.type));s.updateStore({gameEvents:[...n.filter(C=>!u.has(C.type)),...t]}),i&&window.CanvasAgent?.instance?.refresh(),f(p.CxfEvents.GameEventUpdate,"reducer",s.getStore())}),e.on(p.CxfEvents.GameEventAdd,t=>{f(p.CxfEvents.GameEventAdd,t);let{gameEvents:n,isCanvas:i}=s.getStore();s.updateStore({gameEvents:[...n,t]}),i&&window.CanvasAgent?.instance?.refresh(),f(p.CxfEvents.GameEventAdd,"reducer",s.getStore())}),e.on(p.CxfEvents.GameEventRemove,t=>{f(p.CxfEvents.GameEventRemove,t);let{gameEvents:n,isCanvas:i}=s.getStore();s.updateStore({gameEvents:n.filter(({type:u})=>u!==t)}),i&&window.CanvasAgent?.instance?.refresh(),f(p.CxfEvents.GameEventRemove,"reducer",s.getStore())}),e.on(p.CxfEvents.LevelChanged,t=>{f(p.CxfEvents.LevelChanged,t);let{isCanvas:n}=s.getStore();s.updateStore({level:t}),f(p.CxfEvents.LevelChanged,"reducer",s.getStore()),n?window.CanvasAgent?.instance?.refresh():s.fetchUnreadOfferNotificationsCount()}),e.on(p.CxfEvents.LegendLevelChanged,t=>{f(p.CxfEvents.LegendLevelChanged,`legendLevel: ${t}`),s.updateStore({legendLevel:t});let n=s.getStore();f(p.CxfEvents.LegendLevelChanged,"reducer",n),s.fetchUnreadOfferNotificationsCount()})},Tt=e=>{e.on("cxf.native.subscription.enable",r=>{s.updateStore({subscriptionDisabled:r===0,customizationSuffix:r===0?"no-subscription":""}),s.preResolveConfig()})},_t=e=>{e.on("cxf.set.customization.surfix",r=>{let{customizationSuffix:t}=s.getStore();r!==t&&(s.updateStore({customizationSuffix:r||""}),s.preResolveConfig())})},Ot=e=>{let r=s.getConfig();e.on(r.CXF_AD_STATUS,({areBannersAvailable:t,bannersDetails:n})=>{s.updateStore({adStatus:{areBannersAvailable:t,bannersDetails:n}})})},Nt=e=>{e.on("cxf.join.temp.server",r=>{let t=s.getStore();s.updateStore({isTempServer:!!r}),(t.customizationSuffix===""||t.customizationSuffix==="temp")&&(s.updateStore({customizationSuffix:r?"temp":""}),s.preResolveConfig())})},He=()=>[At,Pt,Ot,Nt,Tt,_t];o();var Lt=()=>{f("OnOpenSalesOffersPage");let{isCanvas:e}=s.getStore();if(e){window.CanvasAgent?.instance?.navigate("supersale");return}let r=G(),t=M({page:"sale-offers",sid:r});k(t)},Ut=()=>{let e=s.getStore();f("onLemonstandClose",e),D()},Ve=()=>({"cxf.webshop.sales.open":Lt,"cxf.dialog.close":Ut});var je=e=>{let r=Ve(),t=He();window.addEventListener("message",X(({data:n})=>{if(n){let i=r[n.name];i&&(f("POST MESSAGE",n),i(n.payload))}}));for(let n of t)n(e);s.preResolveConfig(),f("App has started")};re().then(e=>{let r=Ue(e.gameId);s.setConfig(r),s.setCxf(e);let t=de(e);s.setStore(t),ve(r.CANVAS_AGENT_URL).then(()=>{f(`Canvas agent loaded: ${r.CANVAS_AGENT_URL}`)}).catch(n=>{x("Canvas agent load error",n)}),je(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: { "12": "https://ef-canvas-test.public.ggs-ep.com", "15": "https://canvas-test.goodgamestudios.com", "16": "https://ef-canvas-test.public.ggs-ep.com", default: "https://canvas-test.goodgamestudios.com" }, BASE_URL_BY_GAME_ZONE: {}, CANVAS_AGENT_URL: "https://app.canvas.stillfront.com/agent.js", CANVAS_APP_ID_BY_GAME: { "12": "", "15": { google: "25facd0c-e850-4ebf-b6c4-8c60240e4cf8", stillpay: "bec451f9-8db4-4ca1-8a5a-54494429ff5e" }, "16": "" }, 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", CUSTOMIZATION_URL_BY_GAME_ZONE: {} } };
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
+ externalCustomizationSuffix: "",
648
+ resolvedCustomizationUrl: "",
649
+ sourceId: "unknown",
650
+ unreadOfferNotifsCountUrl: ""
651
+ };
652
+ }
653
+ function criteriaSelector({ legendLevel, level }) {
654
+ return {
655
+ legendLevel,
656
+ level
657
+ };
658
+ }
659
+
660
+ // src/utils/index.ts
661
+ init_define_process();
662
+
663
+ // src/utils/domain.ts
664
+ init_define_process();
665
+ var parentDomain = (referrer) => {
666
+ const matches = referrer.match(/^https?:\/\/([^#/?]+)(?:[#/?]|$)/i);
667
+ if (!matches || !matches[1]) {
668
+ return;
669
+ }
670
+ const result = matches[1].match(/[^.]+\.[^.]+$/);
671
+ if (!result) {
672
+ return;
673
+ }
674
+ return result[0];
675
+ };
676
+ var getDomain = (referrer) => {
677
+ return parentDomain(referrer);
678
+ };
679
+
680
+ // src/utils/error-handling.ts
681
+ init_define_process();
682
+
683
+ // src/utils/logging.ts
684
+ init_define_process();
685
+ var import_debug = __toESM(require_browser());
686
+ var logger = (0, import_debug.default)("CXF-WEBSHOP");
687
+ var log = (argument0, ...rest) => logger(argument0, ...rest);
688
+ var logError = (...arguments_) => (
689
+ // tslint:disable-next-line:no-console
690
+ console.error("%c CXF-WEBSHOP ->", "background: #ff0000; color: #fff", ...arguments_)
691
+ );
692
+
693
+ // src/utils/error-handling.ts
694
+ var tryCatch = (fn) => (...args) => {
695
+ try {
696
+ return fn(...args);
697
+ } catch (error) {
698
+ logError(error);
699
+ throwCxfError(error);
700
+ }
701
+ };
702
+ var throwCxfError = (e) => {
703
+ const config = globalState.getConfig();
704
+ const cxf = globalState.getCxf();
705
+ cxf.emit(config.CXF_ERROR, e);
706
+ };
707
+
708
+ // src/utils/loaders.ts
709
+ init_define_process();
710
+ var startTimer = (function_, time) => {
711
+ const id = setTimeout(function_, time);
712
+ return () => clearTimeout(id);
713
+ };
714
+ var timeout = (function_, time) => (a) => {
715
+ return new Promise((resolve, reject) => {
716
+ const stopTimer = startTimer(() => {
717
+ reject(new Error(`Timeout has exceeded ${time}`));
718
+ }, time);
719
+ function_(a).then((value) => {
720
+ resolve(value);
721
+ stopTimer();
722
+ }).catch(reject);
723
+ });
724
+ };
725
+ var loadScript = (src) => new Promise((resolve, reject) => {
726
+ const script = document.createElement("script");
727
+ script.type = "text/javascript";
728
+ script.type = "module";
729
+ script.async = true;
730
+ script.src = src;
731
+ script.addEventListener("load", resolve);
732
+ script.addEventListener("error", reject);
733
+ document.body.append(script);
734
+ });
735
+ var loadCxf = timeout(() => require_dist(), 1e4);
736
+
737
+ // src/utils/payment.ts
738
+ init_define_process();
739
+ var transformPaymentContractIdsToNativePriceEvent = (ids) => (
740
+ // eslint-disable-next-line unicorn/no-array-reduce
741
+ ids.reduce(
742
+ (prev, cur, idx) => {
743
+ prev.offers.push({
744
+ id: cur,
745
+ tier: 0,
746
+ productIds: {
747
+ googleplay: cur
748
+ }
749
+ });
750
+ return prev;
751
+ },
752
+ {
753
+ category: "all",
754
+ offers: [],
755
+ eventName: "lemonstand.nativePrice",
756
+ eventType: "bubble"
757
+ }
758
+ )
759
+ );
760
+
761
+ // src/utils/platform.ts
762
+ init_define_process();
763
+ var userAgentToDistribPlatformMatrix = {
764
+ itunes: "apple",
765
+ Android: "google",
766
+ googleplay: "google",
767
+ amazonmobile: "amazon",
768
+ facebook: "facebook",
769
+ samsung: "samsung",
770
+ huawei: "huawei"
771
+ };
772
+ var detectPlatform = (defaultPlatform = "stillpay") => {
773
+ const nativePlatform = navigator.userAgent.match(
774
+ /(itunes)|(googleplay)|(Android)|(amazonmobile)|(facebook)|(samsung)|(huawei)/g
775
+ );
776
+ if (!nativePlatform) return defaultPlatform;
777
+ const activePlatform = nativePlatform[0];
778
+ return Object.prototype.hasOwnProperty.call(userAgentToDistribPlatformMatrix, activePlatform) ? userAgentToDistribPlatformMatrix[activePlatform] : defaultPlatform;
779
+ };
780
+ var distribPlatformToProviderMatrix = {
781
+ apple: "itunes",
782
+ google: "googleplay",
783
+ amazon: "amazonmobile",
784
+ facebook: "facebook",
785
+ samsung: "samsung",
786
+ huawei: "huawei"
787
+ };
788
+ var createProductIdsForPlatform = (platform, id) => {
789
+ if (!Object.prototype.hasOwnProperty.call(distribPlatformToProviderMatrix, platform))
790
+ throw new Error(`Platform ${platform} is not supported`);
791
+ const res = /* @__PURE__ */ Object.create(null);
792
+ res[distribPlatformToProviderMatrix[platform]] = id;
793
+ return res;
794
+ };
795
+
796
+ // src/utils/query-params.ts
797
+ init_define_process();
798
+ function formatQueryString(object) {
799
+ return Object.entries(object).filter(([key, value]) => value !== null && value !== void 0).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
800
+ }
801
+ var ggsGetQueryParams = () => {
802
+ return ggsGetQueryParameters();
803
+ };
804
+ var ggsGetReferrerValue = () => {
805
+ return ggsGetReferrer();
806
+ };
807
+
808
+ // src/utils/session.ts
809
+ init_define_process();
810
+
811
+ // node_modules/@lukeed/uuid/dist/index.mjs
812
+ init_define_process();
813
+ var IDX = 256;
814
+ var HEX = [];
815
+ var BUFFER;
816
+ while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
817
+ function v4() {
818
+ var i = 0, num, out = "";
819
+ if (!BUFFER || IDX + 16 > 256) {
820
+ BUFFER = Array(i = 256);
821
+ while (i--) BUFFER[i] = 256 * Math.random() | 0;
822
+ i = IDX = 0;
823
+ }
824
+ for (; i < 16; i++) {
825
+ num = BUFFER[IDX + i];
826
+ if (i == 6) out += HEX[num & 15 | 64];
827
+ else if (i == 8) out += HEX[num & 63 | 128];
828
+ else out += HEX[num];
829
+ if (i & 1 && i > 1 && i < 11) out += "-";
830
+ }
831
+ IDX++;
832
+ return out;
833
+ }
834
+
835
+ // src/ArgumentNullError.ts
836
+ init_define_process();
837
+ var ArgumentNullError = class extends Error {
838
+ constructor(parameterName, parameterValue) {
839
+ super(`${parameterName} has null value: ${parameterValue}`);
840
+ this.name = "ArgumentNullError";
841
+ }
842
+ };
843
+
844
+ // src/types/models.ts
845
+ init_define_process();
846
+ function encodeGnip({ gameId, networkId, instanceId, playerId }) {
847
+ return [gameId, networkId, instanceId, playerId].join("-");
848
+ }
849
+
850
+ // src/utils/session.ts
851
+ var createSessionId = () => v4();
852
+ var getTokenAndLanguage = (store) => {
853
+ const { playerId, token, zoneId, language } = store;
854
+ if (!playerId) {
855
+ throw new ArgumentNullError("playerId", playerId);
856
+ }
857
+ return {
858
+ token,
859
+ zoneId,
860
+ locale: language,
861
+ ping: encodeGnip({ ...store, playerId })
862
+ };
863
+ };
864
+
865
+ // src/utils/time.ts
866
+ init_define_process();
867
+ function msToSec(value) {
868
+ return Math.floor(value / 1e3);
869
+ }
870
+
871
+ // src/utils/url.ts
872
+ init_define_process();
873
+ var import_game_alias = __toESM(require_dist2());
874
+
875
+ // src/config.ts
876
+ init_define_process();
877
+ var import_cxf_events = __toESM(require_typings());
878
+
879
+ // src/types/index.ts
880
+ init_define_process();
881
+
882
+ // src/types/config.ts
883
+ init_define_process();
884
+
885
+ // src/types/store.ts
886
+ init_define_process();
887
+ var entityProvider = (initial) => {
888
+ let element = initial;
889
+ return {
890
+ get: () => element,
891
+ set: (value) => {
892
+ element = value;
893
+ }
894
+ };
895
+ };
896
+
897
+ // src/config.ts
898
+ var parseBaseUrl = (value) => {
899
+ if (typeof value === "string") {
900
+ try {
901
+ return JSON.parse(value);
902
+ } catch {
903
+ return { default: value };
904
+ }
905
+ }
906
+ return value || { default: "" };
907
+ };
908
+ var COMMON_CONFIG = {
909
+ CANVAS_AGENT_URL: define_process_default.env.CANVAS_AGENT_URL,
910
+ CANVAS_APP_ID_BY_GAME: define_process_default.env.CANVAS_APP_ID_BY_GAME,
911
+ CUSTOMIZATION_URL: define_process_default.env.CUSTOMIZATION_URL,
912
+ CUSTOMIZATION_URL_TEMPLATE: define_process_default.env.CUSTOMIZATION_URL_TEMPLATE,
913
+ CUSTOMIZATION_URL_BY_GAME_ZONE: define_process_default.env.CUSTOMIZATION_URL_BY_GAME_ZONE,
914
+ BASE_URL: parseBaseUrl(define_process_default.env.BASE_URL),
915
+ BASE_URL_BY_GAME_ZONE: define_process_default.env.BASE_URL_BY_GAME_ZONE,
916
+ CXF_DIALOG_OPEN: "cxf.dialog.open",
917
+ CXF_DIALOG_CLOSE: "cxf.dialog.close",
918
+ CXF_TRACK_MSG: "cxf.tracking.message",
919
+ CXF_BTN_CLICK_MSG: import_cxf_events.CxfEvents.OpenIGS,
920
+ CXF_OPEN_SALES_MSG: "cxf.webshop.sales.open" /* CXF_OPEN_SALES_MSG */,
921
+ WEB_SHOP_CALL_TRACK_ID: 1181,
922
+ CXF_ERROR: "cxf.error",
923
+ CXF_PUSH: "cxf.push",
924
+ CXF_AD_STATUS: "cxf.adBanner.status"
925
+ };
926
+ var GAME_SPECIFIC_CONFIG = {
927
+ 12: {
928
+ LEGEND_LEVEL_IS_USED: true
929
+ },
930
+ 15: {
931
+ LEGEND_LEVEL_IS_USED: false
932
+ },
933
+ 16: {
934
+ LEGEND_LEVEL_IS_USED: true
935
+ }
936
+ };
937
+ var createConfig = (gameId) => {
938
+ return {
939
+ ...COMMON_CONFIG,
940
+ ...GAME_SPECIFIC_CONFIG[gameId]
941
+ };
942
+ };
943
+ var getBaseUrlForGame = (gameId, zoneId) => {
944
+ const gameZoneUrl = getBaseUrlForGameZone(gameId, zoneId);
945
+ if (gameZoneUrl) {
946
+ return gameZoneUrl;
947
+ }
948
+ const baseUrl = COMMON_CONFIG.BASE_URL;
949
+ const gameIdKey = String(gameId);
950
+ return baseUrl[gameIdKey] || baseUrl.default || "";
951
+ };
952
+ var getCustomizationUrlForGameZone = (gameId, zoneId) => {
953
+ if (!zoneId) {
954
+ return void 0;
955
+ }
956
+ const customizationUrlByGameZone = COMMON_CONFIG.CUSTOMIZATION_URL_BY_GAME_ZONE;
957
+ const gameZoneKey = `${gameId}-${zoneId}`;
958
+ if (typeof customizationUrlByGameZone === "string") {
959
+ try {
960
+ const parsed = JSON.parse(customizationUrlByGameZone);
961
+ return parsed[gameZoneKey];
962
+ } catch {
963
+ return void 0;
964
+ }
965
+ }
966
+ return customizationUrlByGameZone?.[gameZoneKey];
967
+ };
968
+ var getBaseUrlForGameZone = (gameId, zoneId) => {
969
+ if (!zoneId) {
970
+ return void 0;
971
+ }
972
+ const baseUrlByGameZone = COMMON_CONFIG.BASE_URL_BY_GAME_ZONE;
973
+ const gameZoneKey = `${gameId}-${zoneId}`;
974
+ if (typeof baseUrlByGameZone === "string") {
975
+ try {
976
+ const parsed = JSON.parse(baseUrlByGameZone);
977
+ return parsed[gameZoneKey];
978
+ } catch {
979
+ return void 0;
980
+ }
981
+ }
982
+ return baseUrlByGameZone?.[gameZoneKey];
983
+ };
984
+
985
+ // src/utils/validation.ts
986
+ init_define_process();
987
+ var validateForNull = (properties) => {
988
+ for (const key of Object.keys(properties)) {
989
+ const value = properties[key];
990
+ if (value === void 0 || value === null || Number.isNaN(value)) {
991
+ throw new ArgumentNullError(key, value);
992
+ }
993
+ }
994
+ };
995
+
996
+ // src/utils/url.ts
997
+ var createIframeUrl = ({ page, route, sid, config: igsConfig = {} }) => {
998
+ const store = globalState.getStore();
999
+ const { token, zoneId, locale } = getTokenAndLanguage(store);
1000
+ const parameters = {
1001
+ token,
1002
+ zoneId,
1003
+ locale,
1004
+ sid: sid || createSessionId()
1005
+ };
1006
+ if (Object.keys(igsConfig).length > 0) {
1007
+ parameters.config = JSON.stringify(igsConfig);
1008
+ }
1009
+ validateForNull(parameters);
1010
+ const urlParameters = new URLSearchParams(ggsGetQueryParams());
1011
+ const queryParameters = {
1012
+ ...parameters,
1013
+ "lemonstand.customization.url": store.resolvedCustomizationUrl || createCustomizationUrl(),
1014
+ domain: getDomain(ggsGetReferrerValue()),
1015
+ websiteId: urlParameters.get("w"),
1016
+ criteria: JSON.stringify(criteriaSelector(store)),
1017
+ level: store.level
1018
+ };
1019
+ const network = urlParameters.get("network");
1020
+ if (urlParameters.get("usekeybaselogin") === "false" && Number(network) > 0) {
1021
+ queryParameters.network = network;
1022
+ }
1023
+ if (store.adStatus?.areBannersAvailable) {
1024
+ queryParameters.ads = true;
1025
+ }
1026
+ const baseUrl = getBaseUrlForGame(store.gameId, store.zoneId);
1027
+ return `${baseUrl}/?${formatQueryString(queryParameters)}${page ? `#${page}` : ""}${route ? `--${route}--${Date.now()}` : ""}`;
1028
+ };
1029
+ var createCustomizationUrl = () => {
1030
+ const config = globalState.getConfig();
1031
+ const store = globalState.getStore();
1032
+ const cxf = globalState.getCxf();
1033
+ const configBase = (0, import_game_alias.acronym)(store.gameId);
1034
+ const configVariance = store.customizationSuffix ? `-${store.customizationSuffix}` : "";
1035
+ const configBranch = `${configBase}${configVariance}`;
1036
+ const gameZoneSpecificUrl = getCustomizationUrlForGameZone(store.gameId, store.zoneId);
1037
+ if (gameZoneSpecificUrl) {
1038
+ return gameZoneSpecificUrl.replace("{0}", configBranch);
1039
+ }
1040
+ if (cxf.env === "test") {
1041
+ const configVersion = new URLSearchParams(window.location.search).get("configGGS");
1042
+ if (configVersion !== null) {
1043
+ return config.CUSTOMIZATION_URL_TEMPLATE.replace("{0}", configBranch).replace("{1}", configVersion);
1044
+ }
1045
+ }
1046
+ return config.CUSTOMIZATION_URL.replace("{0}", configBranch);
1047
+ };
1048
+
1049
+ // src/fetch.ts
1050
+ var fetchUnreadOfferNotificationsCount = async () => {
1051
+ const config = globalState.getConfig();
1052
+ const store = globalState.getStore();
1053
+ if (config.LEGEND_LEVEL_IS_USED && store.legendLevel === void 0) {
1054
+ log("Skip fetchUnreadOfferNotificationsCount due to legendLevel is undefined");
1055
+ return;
1056
+ }
1057
+ if (!store.isCanvas && store.token && store.unreadOfferNotifsCountUrl) {
1058
+ log("fetchUnreadOfferNotificationsCount");
1059
+ let unreadCount = 0;
1060
+ const headers = {
1061
+ Authorization: `Bearer ${store.token}`
1062
+ };
1063
+ const url = store.unreadOfferNotifsCountUrl.replace("{locale}", store.language || "").replace("{zoneId}", store.zoneId || "").replace("{criteria}", encodeURIComponent(JSON.stringify(criteriaSelector(store))));
1064
+ try {
1065
+ log("fetch", url);
1066
+ const resp = await fetch(url, {
1067
+ headers
1068
+ });
1069
+ if (resp.ok) {
1070
+ const data = await resp.json();
1071
+ unreadCount = Number(data?.notifCount);
1072
+ }
1073
+ } catch (error) {
1074
+ logError(`cannot fetch ${url}`, error);
1075
+ }
1076
+ log("setUnseenOffersCounter", unreadCount);
1077
+ store.gameApi.invokeFn("setUnseenOffersCounter", unreadCount).catch((error) => {
1078
+ logError("setUnseenOffersCounter error:", error);
1079
+ });
1080
+ }
1081
+ };
1082
+
1083
+ // src/messages/ShopMessageBus.ts
1084
+ init_define_process();
1085
+ var ShopMessageBus = class {
1086
+ post(message) {
1087
+ const element = document.querySelector("#dialog");
1088
+ if (element && element.tagName.toLocaleLowerCase() === "iframe") {
1089
+ element.contentWindow?.postMessage(message, "*");
1090
+ }
1091
+ }
1092
+ };
1093
+
1094
+ // src/preFetch.ts
1095
+ init_define_process();
1096
+ var preResolveConfig = () => {
1097
+ if (typeof fetch !== "function") {
1098
+ return;
1099
+ }
1100
+ const originalCustomUrl = createCustomizationUrl();
1101
+ let resolvedUrl = "";
1102
+ fetch(originalCustomUrl).then((resp) => {
1103
+ const currentCustomUrl = createCustomizationUrl();
1104
+ if (currentCustomUrl === originalCustomUrl) {
1105
+ resolvedUrl = resp.url;
1106
+ log("parsed customization url is " + resolvedUrl);
1107
+ globalState.updateStore({
1108
+ resolvedCustomizationUrl: resolvedUrl
1109
+ });
1110
+ return resp.json();
1111
+ }
1112
+ }).then((config) => {
1113
+ if (config) {
1114
+ globalState.updateStore({
1115
+ unreadOfferNotifsCountUrl: config.unreadOfferNotifsCountUrl || ""
1116
+ });
1117
+ }
1118
+ });
1119
+ };
1120
+
1121
+ // src/globalState.ts
1122
+ var GlobalState = class {
1123
+ constructor() {
1124
+ this.config = void 0;
1125
+ this.cxfProvider = entityProvider();
1126
+ this.dialogProvider = entityProvider();
1127
+ this.storeProvider = entityProvider();
1128
+ this.shopMessageBus = new ShopMessageBus();
1129
+ this.fetchUnreadOfferNotificationsCount = fetchUnreadOfferNotificationsCount;
1130
+ this.preResolveConfig = preResolveConfig;
1131
+ }
1132
+ setConfig(config) {
1133
+ this.config = config;
1134
+ }
1135
+ getConfig() {
1136
+ if (this.config === void 0) {
1137
+ throw new Error("Config is not initialized");
1138
+ }
1139
+ return this.config;
1140
+ }
1141
+ setCxf(cxf) {
1142
+ this.cxfProvider.set(cxf);
1143
+ }
1144
+ getCxf() {
1145
+ const cxf = this.cxfProvider.get();
1146
+ if (!cxf) {
1147
+ throw new Error("CXF is not loaded");
1148
+ }
1149
+ return cxf;
1150
+ }
1151
+ setStore(store) {
1152
+ this.storeProvider.set(store);
1153
+ }
1154
+ getStore() {
1155
+ const store = this.storeProvider.get();
1156
+ if (!store) {
1157
+ throw new Error("Store is not initialized");
1158
+ }
1159
+ return store;
1160
+ }
1161
+ updateStore(data) {
1162
+ const currentStore = this.getStore();
1163
+ this.setStore({
1164
+ ...currentStore,
1165
+ ...data
1166
+ });
1167
+ }
1168
+ };
1169
+ var globalState = new GlobalState();
1170
+
1171
+ // src/handlers/cxfEventHandlers.ts
1172
+ init_define_process();
1173
+ var import_cxf_events2 = __toESM(require_typings());
1174
+
1175
+ // src/dialog.ts
1176
+ init_define_process();
1177
+ var createDialog = (url) => {
1178
+ const config = globalState.getConfig();
1179
+ const cxf = globalState.getCxf();
1180
+ cxf.emit(config.CXF_DIALOG_OPEN, url);
1181
+ };
1182
+
1183
+ // src/track.ts
1184
+ init_define_process();
1185
+ var trackOpenAction = (sid) => {
1186
+ const config = globalState.getConfig();
1187
+ const store = globalState.getStore();
1188
+ const now = Date.now();
1189
+ const parameters = getTokenAndLanguage(store);
1190
+ const { zoneId } = parameters;
1191
+ const sessionId = sid;
1192
+ const { playerId, gameId, networkId, instanceId, sourceId } = store;
1193
+ trackAction({
1194
+ eventId: config.WEB_SHOP_CALL_TRACK_ID,
1195
+ date: msToSec(now),
1196
+ unixtimeMS: now,
1197
+ sessionId,
1198
+ zoneId: zoneId ? Number.parseInt(zoneId, 10) : void 0,
1199
+ playerId: Number.parseInt(playerId, 10),
1200
+ gameId: Number.parseInt(gameId, 10),
1201
+ networkId: Number.parseInt(networkId, 10),
1202
+ instanceId: Number.parseInt(instanceId, 10),
1203
+ sourceId
1204
+ });
1205
+ };
1206
+ var trackAction = (payload) => {
1207
+ const config = globalState.getConfig();
1208
+ const cxf = globalState.getCxf();
1209
+ cxf.emit(config.CXF_TRACK_MSG, payload);
1210
+ };
1211
+
1212
+ // src/utils/customizationSuffix.ts
1213
+ init_define_process();
1214
+ var resolveCustomizationSuffix = ({
1215
+ externalCustomizationSuffix,
1216
+ isTempServer,
1217
+ subscriptionDisabled
1218
+ }) => {
1219
+ if (externalCustomizationSuffix) {
1220
+ return externalCustomizationSuffix;
1221
+ }
1222
+ if (isTempServer) {
1223
+ return "temp";
1224
+ }
1225
+ if (subscriptionDisabled) {
1226
+ return "no-subscription";
1227
+ }
1228
+ return "";
1229
+ };
1230
+
1231
+ // src/whitelist.ts
1232
+ init_define_process();
1233
+ var whitelistedZones = /* @__PURE__ */ new Set([218, 316, 318, 460, 461, 768, 802, 814, 830, 877]);
1234
+
1235
+ // src/handlers/pushHandlers.ts
1236
+ init_define_process();
1237
+ var onReward = (payload) => {
1238
+ log("OnReward: payload", payload);
1239
+ const { isCanvas } = globalState.getStore();
1240
+ if (isCanvas) {
1241
+ window.CanvasAgent?.instance?.hide();
1242
+ window.CanvasAgent?.instance?.navigate();
1243
+ return;
1244
+ }
1245
+ const url = createIframeUrl({
1246
+ route: encodeURIComponent(payload.successUrl),
1247
+ ...payload
1248
+ });
1249
+ globalState.updateStore({
1250
+ lastPurchaseTab: payload.page,
1251
+ sourceId: "successfulPayoutReward"
1252
+ });
1253
+ trackOpenAction(payload.sid);
1254
+ createDialog(url);
1255
+ };
1256
+ var onLemonstandCategoryUpdate = ({ target, action, data }) => {
1257
+ globalState.shopMessageBus.post({
1258
+ eventName: "lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */,
1259
+ target,
1260
+ data: { action, data }
1261
+ });
1262
+ };
1263
+ var onLemonstandNotificationsCreated = ({ notifCount }) => {
1264
+ log("onLemonstandNotificationsCreated -> notifCount:", notifCount);
1265
+ const store = globalState.getStore();
1266
+ if (notifCount > 0) {
1267
+ const randomDelayMs = Math.floor(Math.random() * (Number(store.networkId) < 250 ? 12e4 : 15e3));
1268
+ setTimeout(() => {
1269
+ fetchUnreadOfferNotificationsCount();
1270
+ }, randomDelayMs);
1271
+ } else {
1272
+ store.gameApi.invokeFn("setUnseenOffersCounter", 0).catch((error) => {
1273
+ logError("setUnseenOffersCounter error:", error);
1274
+ });
1275
+ }
1276
+ };
1277
+ var createPushHandlers = () => {
1278
+ return {
1279
+ reward: onReward,
1280
+ reward_received: onReward,
1281
+ ["lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */]: onLemonstandCategoryUpdate,
1282
+ ["lemonstand.notifs.created" /* LEMONSTAND_NOTIFICATIONS_CREATED */]: onLemonstandNotificationsCreated
1283
+ };
1284
+ };
1285
+
1286
+ // src/handlers/cxfEventHandlers.ts
1287
+ var isWindowMessageListenerAttached = false;
1288
+ var eventListener = (event) => {
1289
+ log(`Canvas event "${event.eventType}" received:`, event);
1290
+ switch (event.eventType) {
1291
+ case "native_catalog_request" /* NATIVE_CATALOG_REQUEST */: {
1292
+ if (event?.paymentContractIds?.length > 0) {
1293
+ if (!isWindowMessageListenerAttached) {
1294
+ window.addEventListener("message", ({ data }) => {
1295
+ if (data?.eventName === "lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */ && data?.data?.action === "nativePriceUpdate") {
1296
+ log(`${"lemonstand.category.update" /* LEMONSTAND_CATEGORY_UPDATE */} event`, data.data);
1297
+ if (!data.data.data) return;
1298
+ const nativeCatalog = {};
1299
+ for (const key in data.data.data) {
1300
+ const { priceString, ...rest } = data.data.data[key];
1301
+ nativeCatalog[key] = rest;
1302
+ }
1303
+ log("nativeCatalog:", nativeCatalog);
1304
+ window.CanvasAgent?.instance?.setNativeCatalog(nativeCatalog);
1305
+ }
1306
+ });
1307
+ isWindowMessageListenerAttached = true;
1308
+ }
1309
+ const msg = transformPaymentContractIdsToNativePriceEvent(event.paymentContractIds);
1310
+ window.postMessage(msg, "*");
1311
+ log("Event `lemonstand.nativePrice` sent");
1312
+ }
1313
+ break;
1314
+ }
1315
+ case "native_checkout_request" /* NATIVE_CHECKOUT_REQUEST */: {
1316
+ const { paymentContract, sessionId, offerId, distributionPlatform } = event;
1317
+ const { zoneId } = globalState.getStore();
1318
+ window.postMessage(
1319
+ {
1320
+ eventName: "lemonstand.nativePay",
1321
+ eventType: "bubble",
1322
+ nativePayInfo: {
1323
+ pkg: {
1324
+ price: paymentContract?.price?.amount,
1325
+ productIdMS: "",
1326
+ productIds: createProductIdsForPlatform(distributionPlatform, paymentContract?.id),
1327
+ tier: Number(paymentContract?.id?.split("_")?.at(-1))
1328
+ },
1329
+ meta: {
1330
+ criteria: window.CanvasAgent?.instance?.getState()?.appConfig?.canvasAppId,
1331
+ lemonstand: true,
1332
+ offerId,
1333
+ sid: sessionId,
1334
+ type: "canvas",
1335
+ // IMPORTANT: type must be 'canvas'
1336
+ zoneId,
1337
+ successUrl: window.location.href
1338
+ }
1339
+ }
1340
+ },
1341
+ "*"
1342
+ );
1343
+ log("Event `lemonstand.nativePay` sent");
1344
+ break;
1345
+ }
1346
+ default: {
1347
+ break;
1348
+ }
1349
+ }
1350
+ };
1351
+ var onOpen = (payload = {}) => {
1352
+ log(import_cxf_events2.CxfEvents.OpenIGS, "payload:", payload);
1353
+ if (payload.sourceId) {
1354
+ globalState.updateStore({
1355
+ sourceId: payload.sourceId
1356
+ });
1357
+ }
1358
+ const { isCanvas, lastPurchaseTab, gameApi } = globalState.getStore();
1359
+ if (isCanvas) {
1360
+ if (payload.page) {
1361
+ window.CanvasAgent?.instance?.navigate(payload.page);
1362
+ }
1363
+ window.CanvasAgent?.instance?.show();
1364
+ return;
1365
+ }
1366
+ const sid = createSessionId();
1367
+ trackOpenAction(sid);
1368
+ const url = createIframeUrl({
1369
+ sid,
1370
+ page: lastPurchaseTab,
1371
+ ...payload
1372
+ });
1373
+ createDialog(url);
1374
+ setTimeout(() => {
1375
+ gameApi.invokeFn("setUnseenOffersCounter", 0);
1376
+ }, 1e3);
1377
+ };
1378
+ var subscribeToCommonCxfEvents = (cxf) => {
1379
+ const pushHandlers = createPushHandlers();
1380
+ cxf.on(import_cxf_events2.CxfEvents.OpenIGS, tryCatch(onOpen));
1381
+ cxf.on(
1382
+ import_cxf_events2.CxfEvents.Push,
1383
+ tryCatch(({ id, payload }) => {
1384
+ log(import_cxf_events2.CxfEvents.Push, id, payload);
1385
+ const handler = pushHandlers[id];
1386
+ handler && handler(payload);
1387
+ })
1388
+ );
1389
+ };
1390
+ var createLeadingEdgeThrottle = (fn, delay) => {
1391
+ let lastCall = 0;
1392
+ return (...args) => {
1393
+ const now = Date.now();
1394
+ if (now - lastCall >= delay) {
1395
+ lastCall = now;
1396
+ fn(...args);
1397
+ }
1398
+ };
1399
+ };
1400
+ var subscribeToGameEvents = (cxf) => {
1401
+ const throttledLoginHandler = createLeadingEdgeThrottle((e) => {
1402
+ const { gameEvents: eventsInLogin, language, token, zoneId } = e;
1403
+ if (whitelistedZones.has(Number(zoneId))) {
1404
+ globalState.updateStore({
1405
+ isCanvas: true
1406
+ });
1407
+ } else {
1408
+ globalState.updateStore({
1409
+ isCanvas: false
1410
+ });
1411
+ }
1412
+ const { gameEvents, isCanvas } = globalState.getStore();
1413
+ const eventNotExistPredicateGenerator = (existingEvents) => (event) => !existingEvents.map((event_) => event_.type).includes(event.type);
1414
+ globalState.updateStore({
1415
+ ...e,
1416
+ gameEvents: [...gameEvents.filter(eventNotExistPredicateGenerator(eventsInLogin)), ...eventsInLogin]
1417
+ });
1418
+ log(import_cxf_events2.CxfEvents.Login, globalState.getStore());
1419
+ globalState.preResolveConfig();
1420
+ if (!isCanvas) {
1421
+ globalState.fetchUnreadOfferNotificationsCount();
1422
+ return;
1423
+ }
1424
+ if (typeof window.CanvasAgent?.create === "function") {
1425
+ const { CANVAS_APP_ID_BY_GAME } = globalState.getConfig();
1426
+ const platform = detectPlatform();
1427
+ const canvasApps = CANVAS_APP_ID_BY_GAME[cxf.gameId];
1428
+ const canvasAppId = typeof canvasApps === "string" ? canvasApps : canvasApps[platform];
1429
+ if (!canvasAppId) {
1430
+ logError("Canvas app id not found for platform", { platform, canvasApps });
1431
+ return;
1432
+ }
1433
+ window.CanvasAgent?.instance?.destroy();
1434
+ window.CanvasAgent.create({
1435
+ authClientId: "lemonstand",
1436
+ canvasAppId,
1437
+ eventListener,
1438
+ locale: language,
1439
+ token
1440
+ }).then((res) => {
1441
+ window.CanvasAgent.instance = res;
1442
+ log(import_cxf_events2.CxfEvents.Login, "Canvas created");
1443
+ }).catch((error) => {
1444
+ logError("Cannot create instance of Canvas", error);
1445
+ });
1446
+ }
1447
+ }, 3e3);
1448
+ cxf.on(import_cxf_events2.CxfEvents.Login, throttledLoginHandler);
1449
+ cxf.on(import_cxf_events2.CxfEvents.GameEventUpdate, (e) => {
1450
+ log(import_cxf_events2.CxfEvents.GameEventUpdate, e);
1451
+ const { gameEvents, isCanvas } = globalState.getStore();
1452
+ const updatedEventTypes = new Set(e.map((event) => event.type));
1453
+ globalState.updateStore({
1454
+ gameEvents: [...gameEvents.filter((event) => !updatedEventTypes.has(event.type)), ...e]
1455
+ });
1456
+ if (isCanvas) {
1457
+ window.CanvasAgent?.instance?.refresh();
1458
+ }
1459
+ log(import_cxf_events2.CxfEvents.GameEventUpdate, "reducer", globalState.getStore());
1460
+ });
1461
+ cxf.on(import_cxf_events2.CxfEvents.GameEventAdd, (e) => {
1462
+ log(import_cxf_events2.CxfEvents.GameEventAdd, e);
1463
+ const { gameEvents, isCanvas } = globalState.getStore();
1464
+ globalState.updateStore({
1465
+ gameEvents: [...gameEvents, e]
1466
+ });
1467
+ if (isCanvas) {
1468
+ window.CanvasAgent?.instance?.refresh();
1469
+ }
1470
+ log(import_cxf_events2.CxfEvents.GameEventAdd, "reducer", globalState.getStore());
1471
+ });
1472
+ cxf.on(import_cxf_events2.CxfEvents.GameEventRemove, (e) => {
1473
+ log(import_cxf_events2.CxfEvents.GameEventRemove, e);
1474
+ const { gameEvents, isCanvas } = globalState.getStore();
1475
+ globalState.updateStore({
1476
+ gameEvents: gameEvents.filter(({ type }) => type !== e)
1477
+ });
1478
+ if (isCanvas) {
1479
+ window.CanvasAgent?.instance?.refresh();
1480
+ }
1481
+ log(import_cxf_events2.CxfEvents.GameEventRemove, "reducer", globalState.getStore());
1482
+ });
1483
+ cxf.on(import_cxf_events2.CxfEvents.LevelChanged, (level) => {
1484
+ log(import_cxf_events2.CxfEvents.LevelChanged, level);
1485
+ const { isCanvas } = globalState.getStore();
1486
+ globalState.updateStore({
1487
+ level
1488
+ });
1489
+ log(import_cxf_events2.CxfEvents.LevelChanged, "reducer", globalState.getStore());
1490
+ if (isCanvas) {
1491
+ window.CanvasAgent?.instance?.refresh();
1492
+ } else {
1493
+ globalState.fetchUnreadOfferNotificationsCount();
1494
+ }
1495
+ });
1496
+ cxf.on(import_cxf_events2.CxfEvents.LegendLevelChanged, (legendLevel) => {
1497
+ log(import_cxf_events2.CxfEvents.LegendLevelChanged, `legendLevel: ${legendLevel}`);
1498
+ globalState.updateStore({
1499
+ legendLevel
1500
+ });
1501
+ const store = globalState.getStore();
1502
+ log(import_cxf_events2.CxfEvents.LegendLevelChanged, "reducer", store);
1503
+ globalState.fetchUnreadOfferNotificationsCount();
1504
+ });
1505
+ };
1506
+ var applySuffixState = (patch) => {
1507
+ globalState.updateStore(patch);
1508
+ const store = globalState.getStore();
1509
+ const customizationSuffix = resolveCustomizationSuffix(store);
1510
+ if (customizationSuffix !== store.customizationSuffix) {
1511
+ globalState.updateStore({ customizationSuffix });
1512
+ globalState.preResolveConfig();
1513
+ }
1514
+ };
1515
+ var subscribeToNativeSubscriptionEnable = (cxf) => {
1516
+ cxf.on("cxf.native.subscription.enable" /* CXF_NATIVE_SUBSCRIPTION_ENABLE */, (enabled) => {
1517
+ applySuffixState({ subscriptionDisabled: enabled === 0 });
1518
+ });
1519
+ };
1520
+ var subscribeToCustomizationSuffix = (cxf) => {
1521
+ cxf.on("cxf.set.customization.surfix" /* CXF_SET_CUSTOMIZATION_SUFFIX */, (suffix) => {
1522
+ applySuffixState({ externalCustomizationSuffix: suffix || "" });
1523
+ });
1524
+ };
1525
+ var subscribeToAdStatus = (cxf) => {
1526
+ const config = globalState.getConfig();
1527
+ cxf.on(config.CXF_AD_STATUS, ({ areBannersAvailable, bannersDetails }) => {
1528
+ globalState.updateStore({
1529
+ adStatus: {
1530
+ areBannersAvailable,
1531
+ bannersDetails
1532
+ }
1533
+ });
1534
+ });
1535
+ };
1536
+ var subscribeToTempServerContext = (cxf) => {
1537
+ cxf.on("cxf.join.temp.server" /* CXF_JOIN_TEMP_SERVER */, (isTemp) => {
1538
+ applySuffixState({ isTempServer: Boolean(isTemp) });
1539
+ });
1540
+ };
1541
+ var createCxfEventHandlers = () => {
1542
+ return [
1543
+ subscribeToCommonCxfEvents,
1544
+ subscribeToGameEvents,
1545
+ subscribeToAdStatus,
1546
+ subscribeToTempServerContext,
1547
+ subscribeToNativeSubscriptionEnable,
1548
+ subscribeToCustomizationSuffix
1549
+ ];
1550
+ };
1551
+
1552
+ // src/handlers/postMessageHandlers.ts
1553
+ init_define_process();
1554
+ var onSalesPageOpen = () => {
1555
+ log("OnOpenSalesOffersPage");
1556
+ const { isCanvas } = globalState.getStore();
1557
+ if (isCanvas) {
1558
+ window.CanvasAgent?.instance?.navigate("supersale");
1559
+ return;
1560
+ }
1561
+ const sid = createSessionId();
1562
+ const url = createIframeUrl({
1563
+ page: "sale-offers",
1564
+ sid
1565
+ });
1566
+ createDialog(url);
1567
+ };
1568
+ var onLemonstandClose = () => {
1569
+ const store = globalState.getStore();
1570
+ log("onLemonstandClose", store);
1571
+ fetchUnreadOfferNotificationsCount();
1572
+ };
1573
+ var createPostMessageHandlers = () => {
1574
+ return {
1575
+ ["cxf.webshop.sales.open" /* CXF_OPEN_SALES_MSG */]: onSalesPageOpen,
1576
+ ["cxf.dialog.close" /* CXF_DIALOG_CLOSE */]: onLemonstandClose
1577
+ };
1578
+ };
1579
+
1580
+ // src/app.ts
1581
+ var app = (cxf) => {
1582
+ const postMessageHandlers = createPostMessageHandlers();
1583
+ const subscribeCxf = createCxfEventHandlers();
1584
+ window.addEventListener(
1585
+ "message",
1586
+ tryCatch(({ data }) => {
1587
+ if (data) {
1588
+ const handler = postMessageHandlers[data.name];
1589
+ if (handler) {
1590
+ log("POST MESSAGE", data);
1591
+ handler(data.payload);
1592
+ }
1593
+ }
1594
+ })
1595
+ );
1596
+ for (const handler of subscribeCxf) {
1597
+ handler(cxf);
1598
+ }
1599
+ globalState.preResolveConfig();
1600
+ log("App has started");
1601
+ };
1602
+
1603
+ // src/index.ts
1604
+ require_dist().then((cxf) => {
1605
+ const config = createConfig(cxf.gameId);
1606
+ globalState.setConfig(config);
1607
+ globalState.setCxf(cxf);
1608
+ const store = initializeStore(cxf);
1609
+ globalState.setStore(store);
1610
+ loadScript(config.CANVAS_AGENT_URL).then(() => {
1611
+ log(`Canvas agent loaded: ${config.CANVAS_AGENT_URL}`);
1612
+ }).catch((error) => {
1613
+ logError("Canvas agent load error", error);
1614
+ });
1615
+ app(cxf);
1616
+ });
1617
+ })();
1618
+ //# sourceMappingURL=webshop-cxf.js.map