(function() { var connector = {}; window.connector = connector; connector.AMAZON = "amazon"; connector.ANDROID = "android"; connector.APPLE = "apple"; connector.CLEVERAPPS = "cleverapps"; connector.CRAZY = "crazy"; connector.DRAUGIEM = "draugiem"; connector.FACEBOOK = "facebook"; connector.FOTOSTRANA = "fotostrana"; connector.GDCOM = "gdcom"; connector.COOLMATHGAMES = "coolmath"; connector.GPG = "gpg"; connector.INSTANT = "instant"; connector.IOS = "ios"; connector.KONGREGATE = "kongregate"; connector.MACOS = "macos"; connector.MICROSOFT = "microsoft"; connector.MOBAGE = "mbga"; connector.SP_MOBAGE = "sp_mbga"; connector.MSSTART = "msstart"; connector.MYGAMES = "mygames"; connector.MM = "mm"; connector.OK = "ok"; connector.PLAYABLE = "playable"; connector.PLIEGA = "pliega"; connector.PLINGA = "plng"; connector.PWA = "pwa"; connector.RUSTORE = "rustore"; connector.SAMSUNG = "samsung"; connector.TEST = "test"; connector.TON = "ton"; connector.VK = "vk"; connector.WECHAT = "wechat"; connector.WORTAL = "wortal"; connector.XIAOMI = "xiaomi"; connector.YANDEX = "yandex"; connector.PLAYHOP = "playhop"; connector.YOUTUBE = "youtube"; connector.GAMESNACK = "gamesnack"; connector.DISCORD = "discord"; connector.XSOLLA = "xsolla"; connector.IAP = "iap"; connector.YOOKASSA = "yookassa"; connector.AD_MOB = "ad_mob"; connector.APP_LOVIN = "app_lovin"; connector.GOOGLE_ADS = "google_ads"; connector.MULTI_ADS = "multi_ads"; connector.YANDEX_APP_ADS = "yandex_app_ads"; connector.YANDEX_WEB_ADS = "yandex_web_ads"; connector.MULTI_SOCIAL = "multi_social"; connector.NONE = "none"; var ERRORS = connector.ERRORS = { NOT_CONNECTED: "not_connected" }; ERRORS.SHOW_REWARDED = { NOT_SUPPORTED: "rewarded_not_supported", NO_ADS: "rewarded_not_found", NOT_CONFIGURED: "rewarded_not_configured", AD_BLOCK: "rewarded_ad_block", THROTTLED: "rewarded_throttled", AD_ALREADY_RUNNING: "ad_already_running", CLOSED_BY_USER: "closed_by_user", AD_EXPIRED: "rewarded_expired_error", UNKNOWN: "rewarded_unknown_error" }; ERRORS.SHOW_INTERSTITIAL = { NOT_SUPPORTED: "interstitial_not_supported", NO_ADS: "interstitial_not_found", NOT_CONFIGURED: "interstitial_not_configured", AD_BLOCK: "interstitial_ad_block", THROTTLED: "interstitial_throttled", AD_ALREADY_RUNNING: "ad_already_running", CLOSED_BY_USER: "closed_by_user", UNKNOWN: "interstitial_unknown_error" }; ERRORS.SHOW_STICKY = { NOT_SUPPORTED: "sticky_not_supported", NO_STICKY: "sticky_not_found", NOT_CONFIGURED: "sticky_not_configured", AD_BLOCK: "sticky_ad_block", TIMEOUT: "show_sticky_timeout", UNKNOWN: "show_sticky_unknown_error" }; ERRORS.CLOSE_STICKY = { TIMEOUT: "close_sticky_timeout", UNKNOWN: "close_sticky_unknown_error" }; ERRORS.PURCHASE = { ALREADY_OPEN: "purchase_already_open", PRODUCT_NOT_FOUND: "product_not_found", LOGIN_REQUIRED: "login_required", EMAIL_REQUIRED: "email_required", INVALID_EMAIL: "invalid_email", TIMEOUT: "purchase_timeout", CANCEL: "purchase_canceled_by_user", UNKNOWN: "purchase_unknown_error" }; ERRORS.CONSUME = { UNKNOWN: "consume_unknown_error" }; ERRORS.SWITCH_GAME = { CANCEL: "switch_game_canceled_by_user", UNKNOWN: "switch_game_unknown_error" }; ERRORS.STORAGE = { NOT_READY: "storage_not_ready", LOAD: { UNKNOWN: "storage_load_unknown_error" }, SET: { UNKNOWN: "storage_set_unknown_error" } }; connector.CODE_SUCCEED = 0; connector.CODE_FAILED = 1; connector.CODE_CANCELLED = 2; connector.CODE_PENDING = 3; connector.STATUS_CONNECTED = "connected"; connector.STATUS_DISCONNECTED = "disconnected"; connector.STATUS_DISABLED = "disabled"; connector.utils = { INTERVALS: { second: 1, minute: 60, hour: 3600, day: 86400, week: 604800, month: 2592E3 }, parseInterval: function(a) { var b = connector.utils.INTERVALS, c = 1E3 * parseInt(a), d; for (d in b) if (-1 !== a.indexOf(d)) return c * b[d]; return c }, once: function(a) { return function() { if (a) { var b = a; a = void 0; return b.apply(this, arguments) } } }, waitNoMore: function(a, b) { var c = setTimeout(function() { c = void 0; b() }, a); return function() { void 0 !== c && (clearTimeout(c), c = void 0, b.apply(this, arguments)) } }, accumulate: function(a, b) { var c = void 0, d, e; return function() { d = this; e = arguments; void 0 === c && (c = setTimeout(function() { clearTimeout(c); c = void 0; var f = d , g = e; e = d = void 0; b.apply(f, g) }, a)) } }, postpone: function(a, b) { var c, d, e; return function() { c = this; d = arguments; clearTimeout(e); e = setTimeout(function() { b.apply(c, d) }, a) } }, wait: function(a, b) { if (0 === a) b(); else { var c = 0; return function() { c++; c === a && b() } } }, timeredThrottle: function(a, b) { var c, d, e, f = function() { if (!e && d) { e = setTimeout(function() { e = void 0; f() }, a); var g = c , h = d; d = c = void 0; b.apply(g, h) } }; return function() { c = this; d = arguments; f() } }, loadSdk: function(a, b) { b.onSuccessOnce = b.onSuccessOnce || connector.utils.once(b.onSuccess); b.onFailureOnce = b.onFailureOnce || connector.utils.once(b.onFailure); var c = b.onSuccessOnce , d = b.onFailureOnce; void 0 === b.attempt && (b.attempt = 3); var e = document.createElement("script"); !1 !== b.crossorigin && e.setAttribute("crossorigin", "anonymous"); e.setAttribute("type", "text/javascript"); e.setAttribute("src", a); b.attrs && Object.keys(b.attrs).forEach(function(h) { e.setAttribute(h, b.attrs[h]) }); var f = function() { clearTimeout(g); e.onload = void 0; e.onerror = void 0; 1 < b.attempt ? (document.body.contains(e) && document.body.removeChild(e), b.attempt--, connector.utils.loadSdk(a, b)) : d() }; e.onload = function() { clearTimeout(g); c() } ; e.onerror = f; var g = setTimeout(f, 3E4); document.body.appendChild(e) }, getRequestParameters: function(a, b) { var c = {}; if (a = a || window.location.search) { a = a.substr(1); a = a.split("&"); for (var d = 0; d < a.length; d++) { var e = a[d].split("=") , f = e[0]; e = e[1] || ""; if (!b) try { e = decodeURIComponent(e.replace(/\+/g, " ")) } catch (g) { console.error("getRequestParameters decodeURIComponent - " + e) } c[f] = e } } return c }, stringify: function(a) { try { if ("object" === typeof a && !(a instanceof Error)) return JSON.stringify(a) } catch (b) {} return String(a) }, isIFrame: function() { return window.top !== window.self }, clone: function(a, b) { if (null === a) return null; if ("object" !== typeof a) return a; if (Array.isArray(a)) { var c = []; for (var d = 0; d < a.length; d++) b ? c.push(connector.utils.clone(a[d], !0)) : c.push(a[d]); return c } c = {}; for (d in a) c[d] = b ? connector.utils.clone(a[d], !0) : a[d]; return c }, setUrlHash: function(a) { var b = connector.utils.getRequestParameters(window.location.hash), c; for (c in a) { var d = a[c]; void 0 === d ? delete b[c] : b[c] = d } window.location.hash = Object.keys(b).map(function(e) { return e + "=" + b[e] }).join("&") }, formatAmount: function(a) { if (1E3 > a) return a; var b = Math.floor(a / 1E3); a -= 1E3 * b; 10 > a ? a = "00" + a : 100 > a && (a = "0" + a); return b + " " + a }, substract: function(a, b, c) { c = c || function(e) { return e } ; a = a || []; b = b || []; var d = {}; b.forEach(function(e) { d[c(e)] = !0 }); return a.filter(function(e) { return void 0 === d[c(e)] }) }, loadBase64: function(a, b) { if (a.startsWith("data:image")) b(a); else { var c = new Image; c.crossOrigin = "anonymous"; c.src = a; c.onload = function() { var d = document.createElement("canvas"); d.height = c.naturalHeight; d.width = c.naturalWidth; d.getContext("2d").drawImage(c, 0, 0); b(d.toDataURL("image/jpg")) } ; c.onerror = function(d) { console.log("[connector] Error loading image:" + a, d); b() } } } }; var HtmlLocalStorage = function() { try { var a = window.localStorage; a.setItem("storage", ""); a.removeItem("storage") } catch (b) { a = function() { console.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option") } , a = { getItem: a, setItem: a, removeItem: a, clear: a } } this.localStorage = a }; HtmlLocalStorage.prototype.getItem = function(a) { a = this.localStorage.getItem(a); if (!connector.platform.oneOf(connector.WECHAT) || "" !== a) return a } ; HtmlLocalStorage.prototype.setItem = function(a, b) { this.localStorage.setItem(a, b) } ; HtmlLocalStorage.prototype.removeItem = function(a) { this.localStorage.removeItem(a) } ; HtmlLocalStorage.prototype.getData = function(a) { var b = {}; try { Object.keys(this.localStorage).forEach(function(c) { 0 === c.indexOf(a) && (b[c] = this.getItem(c)) } .bind(this)) } catch (c) { console.error("DataLoader.getData cant read all data", c) } return b } ; HtmlLocalStorage.prototype.clearData = function(a) { try { for (var b in this.localStorage) 0 === b.indexOf(a) && (console.log("[connector] clearing local storage key", b), this.localStorage.removeItem(b)) } catch (c) { console.error("[connector] error clearing local storage", c) } } ; var SimpleDataLoader = function() { this.localStorage = new HtmlLocalStorage; this.data = {}; this.enabled = !0 }; SimpleDataLoader.prototype.setEnabled = function(a) { this.enabled = !!a } ; SimpleDataLoader.prototype.getLocalStorage = function() { return this.localStorage } ; SimpleDataLoader.prototype.load = function(a) { this.data.hasOwnProperty(a) || (this.data[a] = this.localStorage.getItem(a)); a = this.data[a]; if (null !== a && void 0 !== a && "undefined" !== a) return JSON.parse(a) } ; SimpleDataLoader.prototype.save = function(a, b) { b = JSON.stringify(b); this.data[a] = b; this.enabled && this.localStorage.setItem(a, b) } ; SimpleDataLoader.prototype.remove = function(a) { delete this.data[a]; this.enabled && this.localStorage.removeItem(a) } ; SimpleDataLoader.prototype.cleanAll = function() { this.data = {}; this.localStorage.clearData(SimpleDataLoader.GetLocalStoragePrefix()) } ; SimpleDataLoader.GetLocalStoragePrefix = function() { return "pc_" + connector.config.projectId + connector.platform.getPlugin().getLocalStoragePrefix() } ; SimpleDataLoader.INIT_TYPES = function(a) { var b = SimpleDataLoader.GetLocalStoragePrefix(); if (a) { var c = connector.config.projectId + connector.platform.getPlugin().getLocalStoragePrefix(); connector.dataLoader.load(c + SimpleDataLoader.TYPES.USER_ID) && !connector.dataLoader.load(b + SimpleDataLoader.TYPES.USER_ID) && Object.values(SimpleDataLoader.TYPES).forEach(function(d) { var e = connector.dataLoader.load(c + d); void 0 !== e && connector.dataLoader.save(b + d, e) }) } Object.keys(SimpleDataLoader.TYPES).forEach(function(d) { SimpleDataLoader.TYPES[d] = b + SimpleDataLoader.TYPES[d] }) } ; SimpleDataLoader.TYPES = { USER_ID: "_user_id", SHORTCUT_CREATED: "_instant_shortcut_created", DRAUGIEM_AUTH_DATA: "_draugiem_auth_data", XSOLLA_ACCESS_TOKEN: "_xsolla_access_token", APPLE_SOCIAL: "_apple_social", MS_SOCIAL: "_ms_social", PAYMENTS_COUNTRY: "_payments_country", XSOLLA2_PAYMENTS_AUTH: "_xsolla2_payments_auth", PAYMENTS: "_payments", ANDROID_INSTALL_REFERRER: "_android_install_referrer", TESTPAYMENTS: "_test_payments" }; (function() { var a = function(b) { b = b || {}; var c = b.config || connector.config , d = void 0 !== b.debugMode ? b.debugMode : connector.config.debugMode , e = void 0 !== b.isMobile ? b.isMobile : connector.info.isMobile , f = void 0 !== b.isPlayhop ? b.isPlayhop : connector.info.playhop; switch (b.source || connector.info.source) { case "facebook": return (b = c.facebook) && "https://apps.facebook.com/" + (b.shortname ? b.shortname : b.appId); case "android": return c.android && "https://play.google.com/store/apps/details?id=" + c.android.package; case "amazon": return c.amazon && "https://www.amazon.com/dp/" + c.amazon.id; case "macos": case "ios": return c.ios && "https://apps.apple.com/app/id" + c.ios.id; case "instant": return c.instant && "https://www.facebook.com/instantgames/play/" + c.instant.appId; case "ok": return c.ok && (e ? "https://m.ok.ru/game/" : "https://ok.ru/game/") + (c.ok.shortname || c.ok.appId); case "vk": return c.vk && (e ? "https://m.vk.com/" : "https://vk.com/") + (c.vk.shortname || c.vk.appId); case "mm": return c.mm && (e ? "https://m.my.mail.ru/apps/" : "https://my.mail.ru/apps/") + c.mm.appId; case "mbga": return d ? c.mbga && "https://sb.yahoo-mbga.jp/game/" + c.mbga.appId + "/play" : c.mbga && "https://yahoo-mbga.jp/game/" + c.mbga.appId + "/play"; case "sp_mbga": return c.mbga && "http://sp.mbga.jp/_pf_install?game_id=" + c.mbga.appId; case "draugiem": return c.draugiem && "https://www.draugiem.lv/" + (parseInt(c.draugiem.appId) ? "applications/" : "") + c.draugiem.appId; case "fotostrana": return c.fotostrana && "https://fotostrana.ru/app/" + c.fotostrana.appId; case "yandex": return f ? c.yandex && "https://playhop.com/app/" + c.yandex.appId : c.yandex && "https://yandex.ru/games/play/" + c.yandex.appId; case "gdcom": return c.gdcom && "https://revision.gamedistribution.com/" + c.gdcom.appId; case "plng": return c.plinga && "https://revision.gamedistribution.com/" + c.plinga.appId; case "msstart": return c.msstart && "https://www.msn.com/en-us/play/" + (c.msstart.name.replaceAll(" ", "-") + "/cg-" + c.msstart.appId).toLowerCase(); case "kongregate": return c.kongregate && "https://www.kongregate.com/games/CleverApps/" + c.kongregate.name; case "crazy": return c.crazy && "https://www.crazygames.com/game/" + c.crazy.name; case "xsolla": return c.deployment + (d ? "/publish/html5-staging/" : "/publish/html5/") + "?source=cleverapps"; case "test": return c.deployment + (d ? "/publish/html5-staging/" : "/publish/html5/"); case "microsoft": return c.microsoft && "https://microsoft.com/store/r/" + c.microsoft.appId } }; "undefined" === typeof connector ? module.exports = a : connector.utils.guessPlatformURL = a } )(); var ConnectorRestClient = { METHODS: { GET: "GET", POST: "POST" }, isLocalhost: function() { return location.host ? !connector.info.isNative && ("localhost" === location.host || "127.0.0.1" === location.host || 0 === location.host.indexOf("192.168.")) : !1 }, getDefaultTimeout: function() { return connector.platform.oneOf(connector.WECHAT) ? 2E4 : 1E4 }, getXMLHttpRequest: function() { return "undefined" !== typeof XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP") }, get: function(a, b, c, d, e) { this.send(this.METHODS.GET, a, b, c, d, e) }, post: function(a, b, c, d, e) { this.send(this.METHODS.POST, a, b, c, d, e) }, send: function(a, b, c, d, e, f) { f = f || {}; c = c || {}; if (!connector.platform.oneOf(connector.PLIEGA, connector.PLAYABLE)) { var g = f.timeout || this.getDefaultTimeout() , h = 0 === b.indexOf("http") || 0 === b.indexOf("/.proxy/") || f.fullPath ? b : connector.config.payApiURL + b; if (f.queryParams) { var k = [], l; for (l in f.queryParams) Object.prototype.hasOwnProperty.call(f.queryParams, l) && k.push(l + "=" + f.queryParams[l]); 0 < k.length && (h += "?" + k.join("&")) } k = this.getXMLHttpRequest(); var m = setTimeout(function() { n.call({ status: -1, responseText: "our timeout" }) }, g + 1E3); var n = function() { void 0 !== m && (clearTimeout(m), m = void 0); if (200 <= this.status && 300 > this.status) { if (d) { try { var q = this.responseText && JSON.parse(this.responseText) } catch (p) { throw Error("parse json error: path - " + b + ", message - " + p.message); } d(q) } } else this.responseText && (this.errorMessage = (this.responseText.split("\n")[0] || "").trim()), console.log("XMLHttpRequest FAILED", a, this.status, this.errorMessage, h), e && e(this); d = function() {} ; e = function() {} } .bind(k); k.ontimeout = n; k.onload = n; k.onerror = n; k.onabort = n; k.open(a, h); k.timeout = g; k.setRequestHeader("Content-Type", "application/json"); f.authorization ? k.setRequestHeader("authorization", f.authorization) : k.setRequestHeader("Cache-Control", "no-cache"); k.send(JSON.stringify(c)) } } }; var ConnectorActionPlayer = function(a) { this.options = a = a || {}; Array.isArray(a) ? a = { actions: a } : "function" === typeof a && (a = { actions: [a] }); this.actions = []; this.add(a.actions || []) }; ConnectorActionPlayer.prototype.add = function(a) { Array.isArray(a) ? a.forEach(function(b) { this.add(b) } .bind(this)) : a && this.actions.push(a) } ; ConnectorActionPlayer.prototype._playNext = function() { this.actionTimeout && (clearTimeout(this.actionTimeout), this.actionTimeout = void 0); if (!this._stopped) if (this.index === this.actions.length) this._stopped = !0, this.onCompleteListener && this.onCompleteListener.call(null), this.onSuccessListener && this.onSuccessListener.call(null); else { var a = !0 , b = function() { a && (a = !1, this._playNext.apply(this, arguments)) } .bind(this) , c = function() { a && (a = !1, this.stop.apply(this, arguments)) } .bind(this); this.options.actionTimeout && (this.actionTimeout = setTimeout(c, this.options.actionTimeout)); this.actions[this.index++](b, c) } } ; ConnectorActionPlayer.prototype.onSuccess = function(a) { this.onSuccessListener = a } ; ConnectorActionPlayer.prototype.onFailure = function(a) { this.onFailureListener = a } ; ConnectorActionPlayer.prototype.onComplete = function(a) { this.onCompleteListener = a } ; ConnectorActionPlayer.prototype.play = function(a) { this.index = 0; if (a) this.onSuccess(a); this._playNext() } ; ConnectorActionPlayer.prototype.stop = function() { this._stopped || (this._stopped = !0, this.onCompleteListener && this.onCompleteListener.call(null), this.onFailureListener && this.onFailureListener.apply(null, arguments)) } ; ConnectorActionPlayer.prototype.isStopped = function() { return this._stopped } ; ConnectorActionPlayer.prototype.isRunning = function() { return !this.isStopped() } ; var ConnectorEventEmitter = function() { this.bindings = {} }; ConnectorEventEmitter.prototype.once = function(a, b) { var c = this.on(a, function() { c.clear(); b.apply(this, arguments) } .bind(this)); return c } ; ConnectorEventEmitter.prototype.on = function(a, b) { this.bindings[a] || (this.bindings[a] = []); this.bindings[a].push(b); return { clear: function() { if (this.bindings[a]) { var c = this.bindings[a].indexOf(b); 0 <= c && this.bindings[a].splice(c, 1) } } .bind(this) } } ; ConnectorEventEmitter.prototype.off = function(a) { this.bindings[a] = void 0 } ; ConnectorEventEmitter.prototype.purge = function() { this.bindings = {} } ; ConnectorEventEmitter.prototype.trigger = function() { for (var a = [], b = 0; b < arguments.length; b++) a.push(arguments[b]); this.proxyBus && this.proxyBus.trigger.apply(this.proxyBus, arguments); b = a.shift(); this.bindings[b] && this.bindings[b].slice().forEach(function(c) { c.apply(this, a) }) } ; ConnectorEventEmitter.prototype.setProxy = function(a) { this.proxyBus = a } ; var PaymentsDetector = function() { for (var a, b = ["undefined" !== typeof NoPayments && NoPayments, "undefined" !== typeof DiscordPayments && DiscordPayments, "undefined" !== typeof YooKassaPayments && YooKassaPayments, "undefined" !== typeof WebViewPayments && WebViewPayments, "undefined" !== typeof RuStorePayments && RuStorePayments, "undefined" !== typeof MSStartPayments && MSStartPayments, "undefined" !== typeof XsollaPayments && XsollaPayments, "undefined" !== typeof TestPayments && TestPayments, "undefined" !== typeof InstantPayments && InstantPayments, "undefined" !== typeof SPMobagePayments && SPMobagePayments, "undefined" !== typeof OKPayments && OKPayments, "undefined" !== typeof MobileMyMailRuPayments && MobileMyMailRuPayments, "undefined" !== typeof SamsungPayments && SamsungPayments, "undefined" !== typeof MyMailRuPayments && MyMailRuPayments, "undefined" !== typeof VKPayments && VKPayments, "undefined" !== typeof MobagePayments && MobagePayments, "undefined" !== typeof FotoStranaPayments && FotoStranaPayments, "undefined" !== typeof DraugiemPayments && DraugiemPayments, "undefined" !== typeof YandexPayments && YandexPayments, "undefined" !== typeof MicrosoftPayments && MicrosoftPayments, "undefined" !== typeof PlingaPayments && PlingaPayments, "undefined" !== typeof KongregatePayments && KongregatePayments, "undefined" !== typeof WortalPayments && WortalPayments, "undefined" !== typeof FacebookPayments && FacebookPayments, "undefined" !== typeof MygamesPayments && MygamesPayments, "undefined" !== typeof WechatPayments && WechatPayments], c = 0; c < b.length; c++) if (b[c] && b[c].isAppropriate()) { a = b[c]; break } return a }; var AdsDetector = function() { for (var a = NoAdsPlugin, b = ["undefined" !== typeof MultiAdsPlugin && MultiAdsPlugin, "undefined" !== typeof GDComAds && GDComAds, "undefined" !== typeof CrazyAds && CrazyAds, "undefined" !== typeof PlingaAds && PlingaAds, "undefined" !== typeof YandexAppAds && YandexAppAds, "undefined" !== typeof AppLovinAds && AppLovinAds, "undefined" !== typeof AdMobAds && AdMobAds, "undefined" !== typeof OKAds && OKAds, "undefined" !== typeof VKAds && VKAds, "undefined" !== typeof InstantAds && InstantAds, "undefined" !== typeof YandexWebAds && YandexWebAds, "undefined" !== typeof GoogleWebAds && GoogleWebAds, "undefined" !== typeof GameSnackAds && GameSnackAds, "undefined" !== typeof YandexAds && YandexAds, "undefined" !== typeof MSStartAds && MSStartAds, "undefined" !== typeof WortalAds && WortalAds, "undefined" !== typeof SamsungAds && SamsungAds, "undefined" !== typeof WechatAds && WechatAds, "undefined" !== typeof VideoAds && VideoAds], c = 0; c < b.length; c++) if (b[c] && b[c].isAppropriate()) { a = b[c]; break } return a }; var SocialDetector = function() { if (connector.platform.oneOf(connector.PLIEGA, connector.RUSTORE, connector.PLAYABLE, connector.GDCOM, connector.COOLMATHGAMES, connector.XIAOMI, connector.YOUTUBE, connector.GAMESNACK) || connector.platform.oneOf(connector.IOS, connector.MACOS) && !WebViewFacebook.isAvailable() && !AppleSocial.isAvailable() || connector.platform.oneOf(connector.AMAZON) && !WebViewFacebook.isAvailable() || connector.platform.oneOf(connector.MICROSOFT) && !MicrosoftFacebook.isAvailable() || connector.platform.oneOf(connector.CLEVERAPPS) && location.href.includes("scramble.cleverappssg.com")) return NoSocial; if ("undefined" !== typeof SelectSocial && WebViewFacebook.isAvailable() && ("undefined" !== typeof AndroidSocial && AndroidSocial.isAvailable() || "undefined" !== typeof AppleSocial && AppleSocial.isAvailable())) return SelectSocial; var a = { instant: "undefined" !== typeof InstantSocial && InstantSocial, ok: "undefined" !== typeof OKSocial && OKSocial, mm: "undefined" !== typeof MyMailRuSocial && MyMailRuSocial, vk: "undefined" !== typeof VKSocial && VKSocial, sp_mbga: "undefined" !== typeof SPMobageSocial && SPMobageSocial, mbga: "undefined" !== typeof MobageSocial && MobageSocial, draugiem: "undefined" !== typeof DraugiemSocial && DraugiemSocial, fotostrana: "undefined" !== typeof FotoStranaSocial && FotoStranaSocial, cleverapps: "undefined" !== typeof XsollaSocial && XsollaSocial, yandex: "undefined" !== typeof YandexSocial && YandexSocial, macos: "undefined" !== typeof AppleSocial && AppleSocial, gpg: "undefined" !== typeof AndroidSocial && AndroidSocial, amazon: "undefined" !== typeof WebViewFacebook && WebViewFacebook, ios: "undefined" !== typeof AppleSocial && AppleSocial, samsung: "undefined" !== typeof SamsungSocial && SamsungSocial, mygames: "undefined" !== typeof MygamesSocial && MygamesSocial, microsoft: "undefined" !== typeof MicrosoftFacebook && MicrosoftFacebook, msstart: "undefined" !== typeof MSStartSocial && MSStartSocial, pwa: "undefined" !== typeof XsollaSocial && XsollaSocial, plng: "undefined" !== typeof PlingaSocial && PlingaSocial, kongregate: "undefined" !== typeof KongregateSocial && KongregateSocial, crazy: "undefined" !== typeof CrazySocial && CrazySocial, ton: "undefined" !== typeof TonSocial && TonSocial, wortal: "undefined" !== typeof WortalSocial && WortalSocial, wechat: "undefined" !== typeof WechatSocial && WechatSocial, android: "undefined" !== typeof AndroidSocial && AndroidSocial, discord: "undefined" !== typeof DiscordSocial && DiscordSocial, test: "undefined" !== typeof TestSocial && TestSocial, default: "undefined" !== typeof FacebookCanvasSocial && FacebookCanvasSocial }; return a[connector.info.source] || a.default }; var PlatformDetector = function() { var a = connector.info.source , b = { microsoft: "undefined" !== typeof Microsoft && Microsoft, msstart: "undefined" !== typeof MSStart && MSStart, gdcom: "undefined" !== typeof GDCom && GDCom, coolmath: "undefined" !== typeof CoolMathGames && CoolMathGames, instant: "undefined" !== typeof Instant && Instant, ok: "undefined" !== typeof OKPlatform && OKPlatform, mm: "undefined" !== typeof MyMailRu && MyMailRu, vk: "undefined" !== typeof VKPlatform && VKPlatform, sp_mbga: "undefined" !== typeof SPMobage && SPMobage, mbga: "undefined" !== typeof Mobage && Mobage, draugiem: "undefined" !== typeof Draugiem && Draugiem, fotostrana: "undefined" !== typeof FotoStrana && FotoStrana, cleverapps: "undefined" !== typeof CleverApps && CleverApps, yandex: "undefined" !== typeof Yandex && Yandex, macos: "undefined" !== typeof MacOS && MacOS, ios: "undefined" !== typeof IOS && IOS, gpg: "undefined" !== typeof GPG && GPG, android: "undefined" !== typeof AndroidPlatform && AndroidPlatform, pliega: "undefined" !== typeof Pliega && Pliega, plng: "undefined" !== typeof Plinga && Plinga, kongregate: "undefined" !== typeof Kongregate && Kongregate, crazy: "undefined" !== typeof Crazy && Crazy, ton: "undefined" !== typeof Ton && Ton, wortal: "undefined" !== typeof WortalPlatform && WortalPlatform, rustore: "undefined" !== typeof Rustore && Rustore, amazon: "undefined" !== typeof Amazon && Amazon, mygames: "undefined" !== typeof Mygames && Mygames, samsung: "undefined" !== typeof Samsung && Samsung, facebook: "undefined" !== typeof FacebookCanvas && FacebookCanvas, xiaomi: "undefined" !== typeof Xiaomi && Xiaomi, pwa: "undefined" !== typeof PWA && PWA, wechat: "undefined" !== typeof Wechat && Wechat, youtube: "undefined" !== typeof Youtube && Youtube, gamesnack: "undefined" !== typeof GameSnack && GameSnack, discord: "undefined" !== typeof Discord && Discord, test: "undefined" !== typeof TestPlatform && TestPlatform }; connector.config[a] && void 0 !== connector.config[a].adsense && (connector.config.adsense = connector.config[a].adsense); connector.config[a] && void 0 !== connector.config[a].xsolla && (connector.config.xsolla = connector.config[a].xsolla); return b[a] || FacebookCanvas }; connector.EXCHANGE_RATES = { USD: 1, EUR: 1, RUB: 90, GBP: .85, DEM: 1.7, JPY: 132, INR: 80, FRF: 6.5, CAD: 1.3, AUD: 1.45, BEF: 40.6, CNY: 7.13, SGD: 1.34, mygames: { RUB: 20 }, wechat: { CNY: 5 }, yookassa: { RUB: 50 }, rustore: { RUB: 50 } }; connector.VIRTUAL_EXCHANGE_RATES = { FM: 1, MC: 100, KG: 10, MLK: 20, OK: 20, VK_GOLOS: 2.85, WECHAT_GEMS: 10, YAN: 20 }; var CountryManager = function() { ConnectorEventEmitter.call(this); this.country = CountryManager.UNKONWN; connector.platform.getPlugin().needsCountry && (this.load(), this.update(), connector.platform.oneOf(connector.CLEVERAPPS, connector.MSSTART, connector.ANDROID) && this.updateIpCode()) }; CountryManager.prototype = Object.create(ConnectorEventEmitter.prototype); CountryManager.prototype.constructor = CountryManager; CountryManager.prototype.updateIpCode = function() { // ConnectorRestClient.get("/country/getbyip", {}, function(a) { // this.setIpCode(a && a.countryCode) // } // .bind(this)) } ; CountryManager.prototype.setCurrency = function(a) { a && this.currency !== a && (this.currency = a, this.save(), this.update()) } ; CountryManager.prototype.setIpCode = function(a) { a && this.ipCode !== a && (this.ipCode = a, this.save(), this.update()) } ; CountryManager.prototype.forceCountry = function(a) { this.forcedCountry !== a && (this.forcedCountry = a, this.update()) } ; CountryManager.prototype.update = function() { var a = this.calculateCode(); console.log("[connector] update country: " + a + ", current: " + this.country); this.country !== a && (this.country = a, this.trigger("changed")) } ; CountryManager.prototype.calculateCode = function() { return this.forcedCountry ? this.forcedCountry : this.currency && this.currency === CountryManager.RUB ? CountryManager.RU : this.ipCode ? this.ipCode : this.currency ? CountryManager.OTHER : CountryManager.UNKONWN } ; CountryManager.prototype.load = function() { var a = connector.dataLoader.load(SimpleDataLoader.TYPES.PAYMENTS_COUNTRY) || {}; this.currency = a.currency; this.ipCode = a.ipCode } ; CountryManager.prototype.save = function() { connector.dataLoader.save(SimpleDataLoader.TYPES.PAYMENTS_COUNTRY, { currency: this.currency, ipCode: this.ipCode }) } ; CountryManager.RUB = "RUB"; CountryManager.RU = "RU"; CountryManager.OTHER = "OTHER"; CountryManager.UNKONWN = "UNKNOWN"; var SdkManager = function() { ConnectorEventEmitter.call(this); this.ready = {}; this.loading = {} }; SdkManager.prototype = Object.create(ConnectorEventEmitter.prototype); SdkManager.prototype.constructor = SdkManager; SdkManager.prototype.loadSdk = function(a, b) { var c = SdkManager.LOADERS[a]; c ? this.ready[a] ? b(connector.CODE_SUCCEED) : this.loading[a] ? this.loading[a].push(b) : (this.loading[a] = [b], b = function(d) { d === connector.CODE_SUCCEED ? (this.ready[a] = !0, console.log("SdkManager initialize " + a + " sdk done")) : console.log("SdkManager initialize " + a + " sdk failed"); var e = this.loading[a]; this.loading[a] = void 0; e.forEach(function(f) { try { f(d) } catch (g) { setTimeout(function() { throw g; }, 0) } }) } .bind(this), console.log("SdkManager loading " + a + " sdk started"), c = new ConnectorActionPlayer(c), c.onSuccess(b.bind(this, connector.CODE_SUCCEED)), c.onFailure(b.bind(this, connector.CODE_FAILED)), c.play()) : b(connector.CODE_FAILED) } ; SdkManager.timeout = function(a, b) { return function(c, d) { setTimeout(d, a); b(c, d) } } ; SdkManager.once = function(a) { return function(b) { if (a) { var c = a; a = void 0; c.apply(this, arguments) } else b() } } ; SdkManager.load = function(a, b) { return function(c, d) { connector.utils.loadSdk(a, { onSuccess: c, onFailure: d, crossorigin: b && b.crossorigin }) } } ; SdkManager.SDK_FACEBOOK_CANVAS = "facebook_canvas"; SdkManager.SDK_CRAZY = "crazy"; SdkManager.SDK_DRAUGIEM = "draugiem"; SdkManager.SDK_FOTOSTRANA = "fotostrana"; SdkManager.SDK_GDCOM = "gdcom"; SdkManager.SDK_INSTANT = "instant"; SdkManager.SDK_KONGREGATE = "kongregate"; SdkManager.SDK_MSSTART = "msstart"; SdkManager.SDK_MYMAILRU = "mymailru"; SdkManager.SDK_OK = "ok"; SdkManager.SDK_PLINGA = "plinga"; SdkManager.SDK_SAMSUNG = "samsung"; SdkManager.SDK_SPMOBAGE = "spmobage"; SdkManager.SDK_VK = "vk"; SdkManager.SDK_WORTAL = "wortal"; SdkManager.SDK_YANDEX = "yandex"; SdkManager.SDK_XSOLLA = "xsolla"; SdkManager.SDK_GOOGLE_ADS = "google_ads"; SdkManager.SDK_YANDEX_WEB_ADS = "yandex_web_ads"; SdkManager.SDK_DISCORD = "discord"; SdkManager.LOADERS = {}; var PlayerManager = function() { connector.social.whenConnected(this.refresh.bind(this)); this.bus = new ConnectorEventEmitter; this.isReady = !1; this.id = this.avatar = this.lastName = this.firstName = this.name = "" }; PlayerManager.prototype.whenReady = function(a) { if (this.isReady) a(); else this.bus.once("ready", a) } ; PlayerManager.prototype.refresh = function() { connector.social.isLoggedIn() && connector.social.getPlugin()._aboutMe(function(a, b) { a !== connector.CODE_SUCCEED || !b || this.isReady && b.id === this.id && b.name === this.name && b.avatar === this.avatar || (b.currency && connector.payments.getPlugin().setCurrency(b.currency), this.name = b.name || "", this.firstName = b.firstName || "", this.lastName = b.lastName || "", this.avatar = b.avatar || "", this.id = b.id || "", this.isReady || (this.isReady = !0, this.bus.trigger("ready")), this.bus.trigger("changed")) } .bind(this)) } ; var PlatformStorage = function() { this.isLoading = this.isReady = !1; this.data = void 0; this.bus = new ConnectorEventEmitter }; PlatformStorage.prototype.start = function() { this.isSupported() && (this.initializeInterval = setInterval(this.initialize.bind(this), 5E3), connector.platform.whenConnected(this.initialize.bind(this))) } ; PlatformStorage.prototype.whenReady = function(a) { if (this.isReady) a(); else this.bus.once("ready", a) } ; PlatformStorage.prototype.isSupported = function() { return connector.platform.oneOf(connector.YANDEX, connector.VK, connector.OK, connector.INSTANT, connector.TEST) } ; PlatformStorage.prototype.initialize = function() { this.isReady || this.isLoading || !connector.platform.isConnected() || this.load().then(function(a) { if (this.isReady = a) clearInterval(this.initializeInterval), this.bus.trigger("ready") } .bind(this)) } ; PlatformStorage.prototype.load = function() { if (this.isLoading) return this.loadingPromise; this.isLoading = !0; return connector.platform.isConnected() ? this.loadingPromise = new Promise(function(a) { connector.platform.getPlugin().loadData().then(function(b) { this.data = b || {}; this.isLoading = !1; a(!0) } .bind(this)).catch(function(b) { this.isLoading = !1; console.log("[connector] Error retrieving platform data", b); this.bus.trigger("error:load", ERRORS.STORAGE.LOAD.UNKNOWN); a(!1) } .bind(this)) } .bind(this)) : (this.isLoading = !1, this.bus.trigger("error:load", ERRORS.NOT_CONNECTED), Promise.resolve(!1)) } ; PlatformStorage.prototype.set = function(a, b) { var c = connector.platform.getPlugin(); if (!this.isReady) return this.bus.trigger("error:set", ERRORS.STORAGE.NOT_READY), Promise.resolve(!1); void 0 === b && (b = null); this.data[a] = b; return new Promise(function(d) { c.setData(a, b).then(function() { d(!0) }).catch(function(e) { console.log("[connector] Error setting data", e); this.bus.trigger("error:set", ERRORS.STORAGE.SET.UNKNOWN); d(!1) } .bind(this)) } .bind(this)) } ; PlatformStorage.prototype.get = function(a) { if (this.isReady) return this.data[a]; this.bus.trigger("error:get", ERRORS.STORAGE.NOT_READY) } ; PlatformStorage.prototype.getKeys = function() { if (this.isReady) return Object.keys(this.data); this.bus.trigger("error:getKeys", ERRORS.STORAGE.NOT_READY) } ; var CommonInterface = function() { var a = new ConnectorEventEmitter , b = void 0; return { _refreshPlugin: function() { var c = this._detectPlugin(); !c || b && b.constructor === c || (this._installPlugin(new c), this.connect()) }, _installPlugin: function(c) { this._removePlugin(); b = c; console.log("[connector] create plugin", b.pluginType, b.pluginName); b.onCreated(); b.bus.setProxy(a); a.trigger("pluginChanged") }, _removePlugin: function() { b && (console.log("[connector] remove plugin", b.pluginType, b.pluginName), b.disconnect(), b.onRemoved(), b.bus.setProxy(void 0), b = void 0) }, getPlugin: function() { return b }, getName: function() { if (b) return b.pluginName }, on: function(c, d) { return a.on(c, d) }, once: function(c, d) { return a.once(c, d) }, oneOf: function(c) { return b && b.oneOf(Array.isArray(c) ? c : Array.prototype.slice.call(arguments)) }, getStatus: function() { return b ? b.status || connector.STATUS_DISCONNECTED : connector.STATUS_DISABLED }, connect: function() { b && b.connect() }, disconnect: function() { b && b.disconnect() }, isConnected: function() { return b ? b.isConnected() : !1 }, whenConnected: function(c) { if (b && b.isConnected()) c(); else var d = a.on("changeStatus", function(e) { e === connector.STATUS_CONNECTED && (d.clear(), c()) }) } } }; var PlatformInterface = function() { return Object.assign({ get isPaused() { return this.getPlugin().isPaused() }, get isAudioEnabled() { return this.getPlugin().isAudioEnabled() }, get hasAudioControls() { return this.getPlugin().hasAudioControls() } }, CommonInterface(), { _detectPlugin: PlatformDetector, getUserID: function() { return this.getPlugin().getUserID() }, setUserID: function(a) { this.getPlugin().setUserID(a) }, withTmpID: function() { var a = connector.platform.getUserID(); return a ? a.startsWith("__") : !1 }, withDeviceID: function() { var a = connector.platform.getUserID() , b = connector.info.deviceID; return b ? a === b : !1 }, getAccessToken: function() { return connector.platform.withDeviceID() ? this.getPlugin().getAccessToken() : connector.social.getPlugin().getAccessToken() }, pause: function() { this.getPlugin().pause() }, resume: function() { this.getPlugin().resume() }, callNative: function(a, b, c) { this.getPlugin().callNative(a, b, c) }, subscribeNative: function(a, b) { this.getPlugin().nativeEventListeners[a] = b }, unsubscribeNative: function(a) { delete this.getPlugin().nativeEventListeners[a] }, isTester: function() { return this.getPlugin().isTester() }, openUrl: function(a) { this.getPlugin().openUrl(a) }, locationReload: function() { this.getPlugin().locationReload() }, listSuggestedLanguages: function() { return this.getPlugin().listSuggestedLanguages() }, parsePayload: function(a) { this.getPlugin().parsePayload(a) }, calcPromo: function(a) { this.parsePayload(function(b) { (b = b && b.promo) ? a(b) : this.parseOtherWays(a) } .bind(this)) }, parseOtherWays: function(a) { this.getPlugin().parseOtherWays(a) }, hasCloseApplication: function() { return this.getPlugin().closeApplication }, closeApplication: function() { this.getPlugin().closeApplication && this.getPlugin().closeApplication() }, reportLoadingProgress: function(a) { this.getPlugin().reportLoadingProgress && this.getPlugin().reportLoadingProgress(a) }, startGame: function() { return new Promise(function(a) { this.startGameCallback(a) } .bind(this)) }, startGameCallback: function(a) { this.getPlugin().startGame ? this.getPlugin().startGame(a) : a() }, getSafePadding: function() { return this.getPlugin().getSafePadding() }, getFrameSize: function() { return this.getPlugin().getFrameSize() }, getLocalStoragePrefix: function() { return this.getPlugin().getLocalStoragePrefix() }, canReview: function() { return this.getPlugin().canReview() }, requestReview: function() { return new Promise(function(a) { this.requestReviewCallback(function(b) { a(b === connector.CODE_SUCCEED) }) } .bind(this)) }, requestReviewCallback: function(a) { this.getPlugin().requestReview(a) }, canCreateShortcut: function() { return this.getPlugin().canCreateShortcut() }, createShortcut: function() { return new Promise(function(a) { this.createShortcutCallback(function(b) { a(b === connector.CODE_SUCCEED) }) } .bind(this)) }, createShortcutCallback: function(a) { this.getPlugin().createShortcut(a) }, notifyGameReady: function() { this.getPlugin().notifyGameReady && !this.getPlugin().notifyGameReadyDone && (this.getPlugin().notifyGameReadyDone = !0, connector.platform.whenConnected(function() { this.getPlugin().notifyGameReady() } .bind(this))) }, gameplayStart: function() { var a = this.getPlugin(); a.gameplayStart && a.gameplayStart() }, gameplayStop: function() { var a = this.getPlugin(); a.gameplayStop && a.gameplayStop() }, switchGame: function(a, b, c) { this.getPlugin().switchGame(a, b, c) }, getGameUrl: function(a) { return Platform.getGameUrl(a) }, getRateUrl: function() { return Platform.getRateUrl() }, getExternalUrl: function(a) { return Platform.getExternalUrl(a) } }) }; var SocialInterface = function() { return Object.assign({ get isSupportsNativeShare() { return this.getPlugin().isSupportsNativeShare() }, get isSupportsNativeInvite() { return this.getPlugin().isSupportsNativeInvite() || connector._socialManager.isInviteViaPlatform() }, get isSupportsNativeRequest() { return this.getPlugin().isSupportsNativeRequest() }, get isNeedsLoginForInvite() { return !connector._socialManager.isInviteViaPlatform() }, get isSupportsNativeCommunityJoin() { return this.getPlugin().isSupportsNativeCommunityJoin() }, get canJoinCommunity() { return connector.platform.oneOf(connector.OK, connector.INSTANT, connector.VK, connector.MM, connector.MOBAGE, connector.SP_MOBAGE, connector.DRAUGIEM, connector.DRAUGIEM, connector.FOTOSTRANA, connector.FACEBOOK) } }, CommonInterface(), { _detectPlugin: SocialDetector, needWindowForLogin: !1, isLoggedIn: function(a) { return this.getPlugin().isLoggedIn(a) }, login: function(a) { return new Promise(function(b) { connector.social.loginCallback(b, a) } ) }, loginCallback: function(a, b) { this.getPlugin().login(a, b) }, logout: function() { this.getPlugin().logout() }, hasLeaderBoard: function() { return this.getPlugin().hasLeaderBoard() }, showLeaderBoard: function(a, b) { var c = this.getPlugin(); c && c.isConnected() ? c.showLeaderBoard(a, b) : b(connector.CODE_FAILED) }, joinCommunity: function() { return new Promise(function(a) { this.joinCommunityCallback(a) } .bind(this)) }, joinCommunityCallback: function(a) { connector._socialManager.joinCommunity(a) }, joinCommunityNativeCallback: function(a) { connector._socialManager.joinCommunity(a, !0) }, share: function(a) { return new Promise(function(b) { this.shareCallback(a, b) } .bind(this)) }, shareCallback: function(a, b) { connector._socialManager.share(a, b) }, invite: function(a) { return new Promise(function(b) { this.inviteCallback(a, b) } .bind(this)) }, inviteCallback: function(a, b) { connector._socialManager.invite(a, b) }, request: function(a) { return new Promise(function(b) { this.requestCallback(a, b) } .bind(this)) }, requestCallback: function(a, b) { connector._socialManager.request(a, b) }, askFriendsPermission: function(a) { var b = this.getPlugin(); b.askFriendsPermission && b.isConnected() ? b.askFriendsPermission(a) : a(connector.CODE_FAILED) }, listFriends: function(a) { this.getPlugin().listFriends(a) }, listInvitableFriends: function(a) { this.getPlugin().listInvitableFriends(a) }, aboutUser: function(a, b) { this.getPlugin().aboutUser(a, b) }, sendActivity: function(a, b) { var c = this.getPlugin(); c.sendActivity && c.isConnected() ? c.sendActivity(a, b) : b(connector.CODE_FAILED) }, markAchievement: function(a) { var b = this.getPlugin(); b.markAchievement && b.isConnected() && b.markAchievement(a) }, invalidateAccessToken: function() { var a = this.getPlugin(); a.invalidateAccessToken && a.invalidateAccessToken() }, listAvailable: function() { return this.getPlugin().listAvailable() } }) }; var PaymentsInterface = function() { return Object.assign({ get products() { return connector.payments.getPlugin().listProducts() }, get isAvailable() { return connector.payments.getStatus() !== connector.STATUS_DISABLED }, get isLoginRequired() { return connector._paymentsManager.isLoginRequired() }, get isEmailRequired() { return connector.payments.oneOf(connector.YOOKASSA) }, get isSubscriptionsAvailable() { return connector._paymentsManager.isSubscriptionsAvailable() } }, CommonInterface(), { _detectPlugin: PaymentsDetector, purchase: function(a) { return new Promise(function(b) { connector.payments.purchaseCallback(a, b) } ) }, purchaseCallback: function(a, b) { connector._paymentsManager.purchase(a, b) }, consume: function(a) { return new Promise(function(b) { connector.payments.consumeCallback(a, b) } ) }, consumeCallback: function(a, b) { connector._paymentsManager.consume(a, b) }, stopCurrentPurchase: function() { connector._paymentsManager.stopPurchasePlayer() }, getProduct: function(a) { return this.getPlugin().getProduct(a) }, getPurchaseState: function() { return this.getPlugin().getPurchaseState() }, loadProductsThrottled: function() { connector.payments.isConnected() && connector._paymentsManager.tryLoadProductsThrottled() }, getTextPrice: function(a) { return this.getPlugin().getTextPrice(a) }, convertPrice: function(a) { return this.getPlugin().convertPrice(a) }, getExchangeRate: function() { return this.getPlugin().getExchangeRate() }, restoreSubscriptions: function(a) { var b = this.getPlugin(); b.restoreSubscriptions ? b.restoreSubscriptions(a) : a() }, isVirtualCurrency: function() { return this.getPlugin().isVirtualCurrency() }, getSubscriptionStatus: function(a, b) { this.getPlugin().getSubscriptionStatus(a, b) }, notifyActive: function() { this.getPlugin().notifyActive() } }) }; var AdsInterface = function() { var a = { rewarded: {} }; a[connector.INSTANT] = 2.12; a[connector.OK] = 50 / connector.EXCHANGE_RATES.RUB; a[connector.GDCOM] = 1.7 / connector.EXCHANGE_RATES.EUR; a[connector.PLINGA] = .85 / connector.EXCHANGE_RATES.EUR; a[connector.VK] = 36 / connector.EXCHANGE_RATES.RUB; a[connector.YANDEX] = .66; a[connector.YANDEX_WEB_ADS] = 38 / connector.EXCHANGE_RATES.RUB; a[connector.YANDEX_APP_ADS] = 1.4; a[connector.GOOGLE_ADS] = 2.96 / connector.EXCHANGE_RATES.SGD; a[connector.MSSTART] = 2; a[connector.SAMSUNG] = 1.46; a[connector.CRAZY] = 1; a[connector.WECHAT] = 50 / connector.EXCHANGE_RATES.CNY; a[connector.TEST] = 1; a.rewarded[connector.INSTANT] = 2.04; a.rewarded[connector.GOOGLE_ADS] = 6.15 / connector.EXCHANGE_RATES.SGD; a.rewarded[connector.CRAZY] = 1; a.rewarded[connector.VK] = 36 / connector.EXCHANGE_RATES.RUB; a.rewarded[connector.MSSTART] = 2; a.rewarded[connector.SAMSUNG] = 2.13; a.rewarded[connector.GDCOM] = .4 / connector.EXCHANGE_RATES.EUR; a.rewarded[connector.WECHAT] = 50 / connector.EXCHANGE_RATES.CNY; a.rewarded[connector.TEST] = 1; a.rewarded[connector.PLINGA] = .85 / connector.EXCHANGE_RATES.EUR; a.rewarded[connector.OK] = 50 / connector.EXCHANGE_RATES.RUB; a.rewarded[connector.YANDEX] = .37; a.rewarded[connector.YANDEX_APP_ADS] = 1.4; a.rewarded[connector.YANDEX_WEB_ADS] = 38 / connector.EXCHANGE_RATES.RUB; return Object.assign({ get isRewardedSupported() { return this.getPlugin().isRewardedSupported() }, get isRewardedAvailable() { return connector._adsManager.getRewardedStatus() === connector.CODE_SUCCEED }, get isRewardedPlaying() { return this.getPlugin().isPlaying(AdsPlugin.REWARDED) }, get isInterstitialSupported() { return this.getPlugin().isInterstitialSupported() }, get isInterstitialAvailable() { return connector._adsManager.getInterstitialStatus() === connector.CODE_SUCCEED }, get isInterstitialPlaying() { return this.getPlugin().isPlaying(AdsPlugin.INTERSTITIAL) }, get isStickySupported() { return this.getPlugin().isStickySupported() }, get isStickyAvailable() { return connector._adsManager.getStickyStatus() === connector.CODE_SUCCEED }, get isStickyPlaying() { return connector._adsManager.isStickyPlaying() }, get isAdBlockEnabled() { return connector._adsManager.isAdBlockEnabled } }, CommonInterface(), { _detectPlugin: AdsDetector, checkAdBlock: function() { return new Promise(function(b) { this.checkAdBlockCallback(b) } .bind(this)) }, checkAdBlockCallback: function(b) { connector._adsManager.checkAdBlock(b) }, showRewardedVideo: function() { return new Promise(function(b) { this.showRewardedVideoCallback(b) } .bind(this)) }, showRewardedVideoCallback: function(b) { connector._adsManager.showRewarded(function(c) { b(c === connector.CODE_SUCCEED) }) }, showInterstitial: function() { return new Promise(function(b) { this.showInterstitialCallback(b) } .bind(this)) }, showInterstitialCallback: function(b) { connector._adsManager.showInterstitial(function(c) { b(c === connector.CODE_SUCCEED) }) }, askPermission: function(b) { connector._adsManager.askPermission(b) }, finishAd: function(b, c) { var d = this.getPlugin(); d && d.finishAd(b, c) }, showSticky: function() { return new Promise(function(b) { this.showStickyCallback(b) } .bind(this)) }, showStickyCallback: function(b) { connector._adsManager.enableSticky(function() { b && b() }) }, refreshSticky: function() { return new Promise(function(b) { this.refreshStickyCallback(b) } .bind(this)) }, refreshStickyCallback: function(b) { connector._adsManager.refreshSticky(function() { b && b() }) }, closeSticky: function() { return new Promise(function(b) { this.closeStickyCallback(b) } .bind(this)) }, closeStickyCallback: function(b) { connector._adsManager.disableSticky(function() { b && b() }) }, eCPM: a }) }; var StorageInterface = function() { return { get ready() { return new Promise(function(a) { connector._platformStorage.whenReady(a) } ) }, on: function(a, b) { return connector._platformStorage.bus.on(a, b) }, once: function(a, b) { return connector._platformStorage.bus.once(a, b) }, get isSupported() { return connector._platformStorage.isSupported() }, set: function(a, b) { return connector._platformStorage.set(a, b) }, get: function(a) { return connector._platformStorage.get(a) }, getKeys: function() { return connector._platformStorage.getKeys() }, load: function() { return connector._platformStorage.load() } } }; var Info = { nativePlatforms: ["microsoft", "gpg", "mygames", "macos", "wechat"], nativeMobilePlatforms: ["android", "amazon", "ios", "pliega", "rustore"], bus: new ConnectorEventEmitter, initialize: function() { connector.info.source = this._detectSource(); connector.info.isMobile = this._detectMobile(); connector.info.isNative = this._detectNative() }, _detectLanguage: function() { //多语言设置,强制设置成英文 return 'en'; // 始终返回英语 // var a = window.navigator.language || window.navigator.browserLanguage; // return a ? (a = a.split("-")[0], // "du" === a ? connector.LANGUAGE_DUTCH : a) : connector.LANGUAGE_ENGLISH }, _detectMobile: function() { if (Info.nativeMobilePlatforms.includes(connector.info.source)) return !0; var a = window.navigator.userAgent.toLowerCase(); return /mobile|android|iphone|ipad/.test(a) }, _detectNative: function() { return Info.nativePlatforms.includes(connector.info.source) || Info.nativeMobilePlatforms.includes(connector.info.source) }, _detectOS: function() { var a = window.navigator , b = a.userAgent.toLowerCase() , c = !1 , d = !1 , e = /android (\d+(?:\.\d+)+)/i.exec(b) || /android (\d+(?:\.\d+)+)/i.exec(a.platform); e && (c = !0); (e = /(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(b)) ? d = !0 : /(iPhone|iPad|iPod)/.exec(a.platform) && (d = !0); b = connector.OS_UNKNOWN; -1 !== a.appVersion.indexOf("Win") ? b = connector.OS_WINDOWS : d ? b = connector.OS_IOS : -1 !== a.appVersion.indexOf("Mac") ? b = connector.OS_OSX : -1 !== a.appVersion.indexOf("X11") && -1 === a.appVersion.indexOf("Linux") ? b = connector.OS_UNIX : c ? b = connector.OS_ANDROID : -1 !== a.appVersion.indexOf("Linux") && (b = connector.OS_LINUX); return b }, _detectSource: function() { var a = function(c) { return -1 !== window.location.href.indexOf(c) }; if ("msstart" === connector.config.source && !a("msstart_sdk_init")) return "pwa"; if (connector.config.debugMode && "plinga" === connector.config.source) return "plng"; if (connector.config.source) return connector.config.source; if (window.location.href.includes("apps.fbsbx.com")) return "instant"; if (window.location.href.includes("coolmathgames.com")) return "coolmath"; var b = (new URLSearchParams(window.location.search)).get("source"); if ("android amazon ios macos plng pliega rustore gdcom mygames kongregate msstart microsoft crazy facebook xiaomi cleverapps wortal samsung youtube gamesnack".split(" ").includes(b)) return b; if (a("msstart_sdk_init")) return "msstart"; if (a("dr_auth_code")) return "draugiem"; if (a("logged_user_id")) return "ok"; if (a("api.vk.")) return "vk"; b = connector.config.yandex && connector.config.yandex.appId; return a("yandex") || a("playhop.com") || b && a("app-id=" + b) ? "yandex" : a("fotostrana.ru") ? "fotostrana" : a("source=spmobage") ? "sp_mbga" : a("mbga-platform.jp") ? "mbga" : a("source=xsolla") ? "cleverapps" : connector.config.mm && a("app_id=" + connector.config.mm.appId) ? "mm" : a("telegram=true") ? "ton" : connector.config.testPlatform ? "test" : connector.config.facebook && connector.config.facebook.appId && connector.utils.isIFrame() ? "facebook" : "cleverapps" } }; var InfoInterface = function() { return { on: function(a, b) { Info.bus.on(a, b) }, source: "", isMobile: !1, isNative: !1, os: Info._detectOS(), isInApp: !1, language: Info._detectLanguage(), deviceName: "", deviceVersion: "", deviceID: "", changeLanguage: function(a) { connector.info.language = a } } }; connector.OS_UNKNOWN = "Unknown"; connector.OS_WINDOWS = "Windows"; connector.OS_IOS = "iOS"; connector.OS_OSX = "OS X"; connector.OS_UNIX = "Unix"; connector.OS_ANDROID = "Android"; connector.OS_LINUX = "Linux"; connector.LANGUAGE_ENGLISH = "en"; connector.LANGUAGE_CHINESE = "zh"; connector.LANGUAGE_FRENCH = "fr"; connector.LANGUAGE_ITALIAN = "it"; connector.LANGUAGE_GERMAN = "de"; connector.LANGUAGE_SPANISH = "es"; connector.LANGUAGE_DUTCH = "nl"; connector.LANGUAGE_RUSSIAN = "ru"; connector.LANGUAGE_KOREAN = "ko"; connector.LANGUAGE_JAPANESE = "ja"; connector.LANGUAGE_HUNGARIAN = "hu"; connector.LANGUAGE_PORTUGUESE = "pt"; connector.LANGUAGE_ARABIC = "ar"; connector.LANGUAGE_NORWEGIAN = "no"; connector.LANGUAGE_POLISH = "pl"; connector.LANGUAGE_LATVIAN = "lv"; connector.LANGUAGE_TURKISH = "tr"; var PlayerInterface = function() { return { on: function(a, b) { return connector._playerManager.bus.on(a, b) }, once: function(a, b) { return connector._playerManager.bus.once(a, b) }, get ready() { return new Promise(function(a) { connector._playerManager.whenReady(a) } ) }, whenReady: function(a) { connector._playerManager.whenReady(a) }, get name() { return connector._playerManager.name }, get firstName() { return connector._playerManager.firstName }, get lastName() { return connector._playerManager.lastName }, get id() { return connector.platform.getUserID() }, get avatar() { return connector._playerManager.avatar } } }; var AdsManager = function(a) { this.manualPermissions = a.manualPermissions; this.isAdBlockEnabled = this._isStickyEnabled = this._isStickyPlaying = !1; connector.platform.on("pause", this._updateRefreshInterval.bind(this)); connector.platform.on("resume", this._updateRefreshInterval.bind(this)); connector.platform.on("pause", this._updateCacheInterval.bind(this)); connector.platform.on("resume", this._updateCacheInterval.bind(this)); connector.ads.on("changeStatus", function() { connector.ads.isConnected() && (this.checkCacheQueue(), this.checkAdBlock()); this._updateCacheInterval(); this._isStickyEnabled && this._refreshStickyInner() } .bind(this)); connector._countryManager.on("changed", function() { this.whenIdle(function() { connector.ads._refreshPlugin() }) } .bind(this)); connector.ads.on("pluginChanged", function() { this._isStickyPlaying = !1 } .bind(this)) }; AdsManager.prototype.getAdStatus = function(a) { if (a === AdsPlugin.REWARDED) return this.getRewardedStatus(); if (a === AdsPlugin.INTERSTITIAL) return this.getInterstitialStatus(); if (a === AdsPlugin.STICKY) return this.getStickyStatus() } ; AdsManager.prototype.getRewardedStatus = function() { var a = connector.ads.getPlugin(); return a.isConnected() ? a.isRewardedSupported() ? a.isAdCached(AdsPlugin.REWARDED) ? a.isRewardedConfigured() ? connector.CODE_SUCCEED : ERRORS.SHOW_REWARDED.NOT_CONFIGURED : ERRORS.SHOW_REWARDED.NO_ADS : ERRORS.SHOW_REWARDED.NOT_SUPPORTED : ERRORS.NOT_CONNECTED } ; AdsManager.prototype.getInterstitialStatus = function() { var a = connector.ads.getPlugin(); return a.isConnected() ? a.isInterstitialSupported() ? a.isAdCached(AdsPlugin.INTERSTITIAL) ? a.isInterstitialConfigured() ? connector.CODE_SUCCEED : ERRORS.SHOW_INTERSTITIAL.NOT_CONFIGURED : ERRORS.SHOW_INTERSTITIAL.NO_ADS : ERRORS.SHOW_INTERSTITIAL.NOT_SUPPORTED : ERRORS.NOT_CONNECTED } ; AdsManager.prototype.getStickyStatus = function() { var a = connector.ads.getPlugin(); return a.isConnected() ? a.isStickySupported() ? a.isStickyConfigured() ? a.isStickyAvailable() ? connector.CODE_SUCCEED : ERRORS.SHOW_STICKY.NO_STICKY : ERRORS.SHOW_STICKY.NOT_CONFIGURED : ERRORS.SHOW_STICKY.NOT_SUPPORTED : ERRORS.NOT_CONNECTED } ; AdsManager.prototype.showRewarded = function(a) { this.playAd(AdsPlugin.REWARDED, function(b) { b && b !== ERRORS.SHOW_REWARDED.CLOSED_BY_USER && connector.ads.getPlugin().bus.trigger("error:showRewarded", b); a(b) }) } ; AdsManager.prototype.showInterstitial = function(a) { this.playAd(AdsPlugin.INTERSTITIAL, function(b) { b && b !== ERRORS.SHOW_INTERSTITIAL.CLOSED_BY_USER && connector.ads.getPlugin().bus.trigger("error:showInterstitial", b); a(b) }) } ; AdsManager.prototype.isStickyPlaying = function() { return this._isStickyPlaying } ; AdsManager.prototype.enableSticky = function(a) { this._isStickyEnabled ? a() : (this._isStickyEnabled = !0, this._updateRefreshInterval(), this.showSticky(a)) } ; AdsManager.prototype.disableSticky = function(a) { this._isStickyEnabled ? (this._isStickyEnabled = !1, this._updateRefreshInterval(), this.closeSticky(a)) : a() } ; AdsManager.prototype.showSticky = function(a) { var b = connector.ads.getPlugin() , c = function(e) { b.bus.trigger("error:showSticky", e); a(e) } , d = this.getAdStatus(AdsPlugin.STICKY); d ? c(d) : b.showSticky(function(e, f) { e ? c(e) : (this._isStickyPlaying = !0, b.bus.trigger("sticky:start", f), a(e)) } .bind(this)) } ; AdsManager.prototype._refreshStickyInner = function(a) { if (this._refreshingSticky) a && a(connector.CODE_FAILED); else { this._refreshingSticky = !0; var b = connector.ads.getPlugin() , c = function(d) { this._refreshingSticky = !1; this._isStickyEnabled ? (d && b.bus.trigger("error:refreshSticky", d), b.bus.trigger("sticky:refresh"), a && a(d)) : (a && a(d), this.closeSticky()) } .bind(this); this._isStickyPlaying && !connector.ads.isStickyAvailable ? this.closeSticky(c) : !this._isStickyPlaying && connector.ads.isStickyAvailable ? this.showSticky(c) : b.refreshSticky ? b.refreshSticky(function(d) { d && this.closeSticky(); c(connector.CODE_SUCCEED) } .bind(this)) : c(connector.CODE_SUCCEED) } } ; AdsManager.prototype._updateRefreshInterval = function() { !this._isStickyEnabled || connector.platform.isPaused ? void 0 !== this._refreshInterval && (clearInterval(this._refreshInterval), this._refreshInterval = void 0) : void 0 === this._refreshInterval && (this._refreshInterval = setInterval(this._refreshStickyInner.bind(this), AdsManager.REFRESH_STICKY_INTERVAL)) } ; AdsManager.prototype._updateCacheInterval = function() { !connector.ads.isConnected() || connector.platform.isPaused ? void 0 !== this.cacheInterval && (clearInterval(this.cacheInterval), this.cacheInterval = void 0) : void 0 === this.cacheInterval && (this.cacheInterval = setInterval(this.checkCacheQueue.bind(this), AdsPlugin.CHECK_CACHE_INTERVAL)) } ; AdsManager.prototype.refreshSticky = function(a) { this._refreshStickyInner(a) } ; AdsManager.prototype.closeSticky = function(a) { var b = connector.ads.getPlugin(); this._isStickyPlaying ? b.closeSticky(function(c) { c ? b.bus.trigger("error:closeSticky", c) : (this._isStickyPlaying = !1, b.bus.trigger("sticky:close")); a && a(c) } .bind(this)) : a && a(connector.CODE_SUCCEED) } ; AdsManager.prototype.onStickyRestored = function(a) { this._isStickyPlaying = !0; connector.ads.getPlugin().bus.trigger("sticky:start", a) } ; AdsManager.prototype.onStickyClosedByUser = function() { this._isStickyPlaying = !1; connector.ads.getPlugin().bus.trigger("sticky:close") } ; AdsManager.prototype.isAdSupported = function(a) { if (a === AdsPlugin.REWARDED) return connector.ads.isRewardedSupported; if (a === AdsPlugin.INTERSTITIAL) return connector.ads.isInterstitialSupported; if (a === AdsPlugin.STICKY) return connector.ads.isStickySupported } ; AdsManager.prototype.checkAdBlock = function(a) { var b = connector.ads.getPlugin() , c = function(e) { this.isAdBlockEnabled = e; a && a(e) } .bind(this); if (connector.info.isNative || connector.info.isInApp) c(!1); else if (b.checkAdBlock) b.isConnected() ? b.checkAdBlock(c) : c(!1); else { var d = document.createElement("div"); d.innerHTML = " "; d.className = "adsbox advertisement pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links"; d.id = "text_ad"; d.style.padding = "1px 0 0 0"; document.body.appendChild(d); setTimeout(function() { c(0 === d.offsetHeight); d.parentElement && d.parentElement.removeChild(d) }, 10) } } ; AdsManager.prototype.whenIdle = function(a) { var b = connector.ads.getPlugin(); if (b) if (b.isIdle()) a(); else var c = b.bus.on("changeVideoState", function() { b.isIdle() && (a(), c.clear()) }); else a() } ; AdsManager.prototype.checkCacheQueue = function() { if (connector.ads.isConnected()) { var a = connector.ads.getPlugin(); a.cantLoadInParallel ? AdsPlugin.TYPES.slice().reverse().reduce(function(b, c) { return function() { a.cacheAd(c, b) } }, function() {})() : AdsPlugin.TYPES.forEach(function(b) { a.cacheAd(b) }) } } ; AdsManager.prototype.askPermission = function(a) { connector.ads.getPlugin().askPermission(function() { connector.ads.connect(); a && a() }) } ; AdsManager.prototype.playAd = function(a, b) { b = b || function() {} ; var c = this.getAdStatus(a); if (c) b(c); else { var d = connector.ads.getPlugin(); d.bus.trigger(a + ":loading", d.pluginName); d.cacheAd(a, function(e) { d.bus.trigger(a + ":loaded", e === connector.CODE_SUCCEED, d.pluginName); e !== connector.CODE_SUCCEED ? a === AdsPlugin.REWARDED ? b(ERRORS.SHOW_REWARDED.NO_ADS) : b(ERRORS.SHOW_INTERSTITIAL.NO_ADS) : (d.playAd(a, function(f) { AdsPlugin.TYPES.forEach(function(g) { d.cacheAd(g) }); b(f) }), d.cacheAd(a)) }) } } ; AdsManager.REFRESH_STICKY_INTERVAL = connector.utils.parseInterval("60 seconds"); var PaymentsManager = function(a) { this.pending = []; this.consumed = []; this.load(); this.productsConfig = a; this.restoreThrottled = connector.utils.timeredThrottle(1E4, this.restore.bind(this)); this.tryLoadProductsThrottled = connector.utils.timeredThrottle(1E4, this.tryLoadProducts.bind(this)); connector.platform.on("pause", this._updateRefreshInterval.bind(this)); connector.platform.on("resume", this._updateRefreshInterval.bind(this)); this._updateRefreshInterval(); connector.payments.on("changeStatus", function(b) { b === connector.STATUS_CONNECTED && this.tryLoadProducts() } .bind(this)); connector._countryManager.on("changed", function() { this.whenIdle(function() { connector.payments._refreshPlugin() }) } .bind(this)) }; PaymentsManager.prototype._updateRefreshInterval = function() { connector.platform.isPaused ? (this._tryLoadProductsInterval && (clearInterval(this._tryLoadProductsInterval), this._tryLoadProductsInterval = void 0), this._restoreInterval && (clearInterval(this._restoreInterval), this._restoreInterval = void 0)) : (this._tryLoadProductsInterval || (this._tryLoadProductsInterval = setInterval(this.tryLoadProductsThrottled.bind(this), connector.utils.parseInterval("2 minutes"))), this._restoreInterval || (this._restoreInterval = setInterval(this.restoreThrottled.bind(this), connector.utils.parseInterval(connector.config.debugMode ? "1 minute" : "5 minutes")))) } ; PaymentsManager.prototype.whenIdle = function(a) { var b = connector.payments.getPlugin(); if (b) if (b.isIdle()) a(); else b.bus.once("paymentClosed", a); else a() } ; PaymentsManager.prototype.stop = function() { this.stopLoadProductsPlayer(); this.stopRestorePlayer(); this.stopPurchasePlayer() } ; PaymentsManager.prototype.stopRestorePlayer = function() { this.restorePlayer && (this.restorePlayer.stop(), delete this.restorePlayer) } ; PaymentsManager.prototype.restore = function() { if (connector.payments.isConnected() && connector.payments.getPlugin().isRestoreAvailable() && !this.isPurchaseRunning() && !this.isRestoreRunning()) { var a; (this.restorePlayer = new ConnectorActionPlayer({ actionTimeout: connector.utils.parseInterval("1 minute"), actions: [function(b, c) { connector.payments.getPlugin().restore(function(d, e) { d === connector.CODE_SUCCEED ? (e.restore = !0, a = e, console.log("[connector] Restore purchase:", e), b()) : c() }) } , function(b, c) { this.isConsumed(a.paymentId) ? (this.consume(a), c()) : connector.payments.getPlugin().validate(a, function(d) { d === connector.CODE_SUCCEED ? b() : (this.consume(a), c()) } .bind(this)) } .bind(this), function(b) { var c = this.findPendingPurchaseContext(a.productId); c = Object.assign({}, c, a); connector.payments.getPlugin().bus.trigger("restore", c); b() } .bind(this)] })).play() } } ; PaymentsManager.prototype.load = function() { var a = connector.dataLoader.load(SimpleDataLoader.TYPES.PAYMENTS); a && (this.pending = (a.pending || []).slice(), this.consumed = (a.consumed || []).slice()) } ; PaymentsManager.prototype.save = function() { connector.dataLoader.save(SimpleDataLoader.TYPES.PAYMENTS, { pending: this.pending.slice(-PaymentsManager.PENDING_STORAGE_LIMIT), consumed: this.consumed.slice(-PaymentsManager.CONSUMED_STORAGE_LIMIT) }) } ; PaymentsManager.prototype.savePendingPurchaseContext = function(a, b) { this.pending.push({ productId: a, context: b }); this.save() } ; PaymentsManager.prototype.indexOfPendingPurchaseContext = function(a) { for (var b = this.pending.length - 1; 0 <= b; --b) if (this.pending[b].productId === a) return b } ; PaymentsManager.prototype.removePendingPurchaseContext = function(a) { a = this.indexOfPendingPurchaseContext(a); -1 !== a && (this.pending.splice(a, 1), this.save()) } ; PaymentsManager.prototype.findPendingPurchaseContext = function(a) { a = this.indexOfPendingPurchaseContext(a); if (-1 !== a) return this.pending[a] } ; PaymentsManager.prototype.isConsumed = function(a) { return a && this.consumed.includes(a) } ; PaymentsManager.prototype.consume = function(a, b) { b = b || function() {} ; this._consumeInner(a, function(c) { var d = connector.payments.getPlugin() , e = connector.payments.getProduct(a.productId); e = { purchase: a, product: e }; c ? (d.bus.trigger("error:consume", c), b()) : (d.bus.trigger("consume", e), b(e)) }); a.restore && this.restoreThrottled() } ; PaymentsManager.prototype._consumeInner = function(a, b) { a.state = a.restore ? 4 : 2; delete a.restore; b = connector.utils.once(b); a.paymentId && !this.consumed.includes(a.paymentId) && (this.removePendingPurchaseContext(a.productId), this.consumed.push(a.paymentId), this.save()); var c = connector.payments.getProduct(a.productId); "nonConsumable" === c.type && connector.payments.oneOf(connector.SAMSUNG) ? b(ERRORS.CONSUME.UNKNOWN) : connector.payments.getPlugin().consume(a, b); "subscription" === c.type || connector.payments.getPlugin()instanceof RestPayments || (b = "/payments/add/" + connector.info.source + "/" + encodeURIComponent(connector.platform.getUserID()), connector.payments.oneOf(connector.IAP) && delete a.payload.receipt, ConnectorRestClient.post(b, { purchase: a, version: 2 }, function() {}, function(d) { connector.payments.getPlugin().bus.trigger("stream:error", "Error adding payments " + d.status + " " + d.errorMessage + " " + JSON.stringify(a)) })) } ; PaymentsManager.prototype.getLocalizedProduct = function(a) { if (a = connector.payments.getProduct(a)) return a = connector.utils.clone(a, !0), a.title = void 0 !== a.title[connector.info.language] ? a.title[connector.info.language] : a.title.en, a.description = void 0 !== a.description[connector.info.language] ? a.description[connector.info.language] : a.description.en, a } ; PaymentsManager.prototype.isLoginRequired = function() { return connector.payments.oneOf(connector.XSOLLA) && connector.platform.oneOf(connector.CRAZY) ? !0 : !connector.payments.oneOf(connector.MICROSOFT, connector.PLINGA, connector.IAP, connector.RUSTORE, connector.YANDEX, connector.TEST, connector.YOOKASSA, connector.XSOLLA) } ; PaymentsManager.prototype.purchase = function(a, b) { this._purchaseInner(a, function(c, d) { var e = connector.payments.getPlugin(); c ? e.bus.trigger("error:purchase", c, a) : e.bus.trigger("purchase", d); b(d) }) } ; PaymentsManager.prototype._purchaseInner = function(a, b) { a = a || {}; b = connector.utils.once(b); var c = this.getLocalizedProduct(a.id || a.tag); if (c && c.productId) { var d; if (this.isPurchaseRunning()) b(ERRORS.PURCHASE.ALREADY_OPEN); else if (connector.payments.isConnected()) if (connector.payments.isLoginRequired && !connector.social.isLoggedIn({ strict: !0 })) b(ERRORS.PURCHASE.LOGIN_REQUIRED); else if (connector.payments.isEmailRequired && !a.email) b(ERRORS.PURCHASE.EMAIL_REQUIRED); else { var e = this.purchasePlayer = new ConnectorActionPlayer([function(f, g) { console.log("PaymentsManager purchase start", c.productId, c.itemId); this.savePendingPurchaseContext(c.productId, a.context); connector.payments.getPlugin().setPurchaseState(PaymentsManager.STATE_PURCHASE); connector.payments.getPlugin().purchase(c, connector.utils.once(function(h, k) { d = k; console.log("PaymentsManager purchase result", c.productId, c.itemId, h); console.log("PaymentsManager purchase", JSON.stringify(d)); connector.config.debugMode && connector.config.testRestore && (h = connector.CODE_FAILED); h === connector.CODE_CANCELLED && this.removePendingPurchaseContext(c.productId); h !== connector.CODE_SUCCEED || e.isRunning() ? h !== connector.CODE_SUCCEED ? g(h) : this.isConsumed(d.paymentId) ? (this.consume(d), g()) : f() : setTimeout(function() { this.restoreThrottled() } .bind(this), 15E3) } .bind(this)), { email: a.email }) } .bind(this), function(f, g) { connector.payments.getPlugin().setPurchaseState(PaymentsManager.STATE_VALIDATE); console.log("PaymentsManager validate start", c.productId, c.itemId); connector.payments.getPlugin().validate(d, function(h) { console.log("PaymentsManager validate result", c.productId, c.itemId, h); h !== connector.CODE_SUCCEED ? (this.consume(d), g(h)) : f() } .bind(this)) } .bind(this)]); e.onComplete(function() { connector.payments.getPlugin().setPurchaseState(void 0) }); e.onSuccess(function() { b(connector.CODE_SUCCEED, { purchase: d, product: c }) }); e.onFailure(function(f) { f = f || ERRORS.PURCHASE.UNKNOWN; b(f) }); e.play() } else b(ERRORS.NOT_CONNECTED) } else b(ERRORS.PURCHASE.PRODUCT_NOT_FOUND) } ; PaymentsManager.prototype.isPurchaseRunning = function() { return this.purchasePlayer && this.purchasePlayer.isRunning() } ; PaymentsManager.prototype.isRestoreRunning = function() { return this.restorePlayer && this.restorePlayer.isRunning() } ; PaymentsManager.prototype.isSubscriptionsAvailable = function() { if (connector.platform.oneOf(connector.ANDROID) && connector.payments.oneOf(connector.YOOKASSA)) return !1; var a = connector.payments.getPlugin(); return a.isSubscriptionsAvailable ? a.isSubscriptionsAvailable() : connector.platform.oneOf(connector.OK, connector.ANDROID, connector.IOS, connector.MACOS, connector.TEST) } ; PaymentsManager.prototype.stopPurchasePlayer = function() { this.purchasePlayer && (this.purchasePlayer.stop(), delete this.purchasePlayer) } ; PaymentsManager.prototype.stopLoadProductsPlayer = function() { this.loadProductsPlayer && (this.loadProductsPlayer.stop(), delete this.loadProductsPlayer) } ; PaymentsManager.prototype.tryLoadProducts = function() { !connector.payments.isConnected() || this.loadProductsPlayer && this.loadProductsPlayer.isRunning() || (this.loadProductsPlayer = new ConnectorActionPlayer({ actionTimeout: connector.utils.parseInterval("15 seconds"), actions: [function(a, b) { connector.payments.getPlugin().loadProducts(function(c) { c === connector.CODE_SUCCEED ? (this.restore(), a()) : b() } .bind(this)) } .bind(this), function(a, b) { connector.payments.getPlugin().loadSubscriptions(function(c) { c === connector.CODE_SUCCEED ? a() : b() }) } , function(a, b) { connector.payments.getPlugin().loadSubscriptionsTokens(function(c) { c === connector.CODE_SUCCEED ? a() : b() }) } ] }), this.loadProductsPlayer.play()) } ; PaymentsManager.STATE_PURCHASE = "purchase"; PaymentsManager.STATE_VALIDATE = "validate"; PaymentsManager.PENDING_STORAGE_LIMIT = 30; PaymentsManager.CONSUMED_STORAGE_LIMIT = 30; connector.config = {}; connector.sdk = new SdkManager; connector.player = PlayerInterface(); connector.info = InfoInterface(); connector.platform = PlatformInterface(); connector.social = SocialInterface(); connector.payments = PaymentsInterface(); connector.ads = AdsInterface(); connector.storage = StorageInterface(); connector._playerManager = new PlayerManager; connector._platformStorage = new PlatformStorage; connector.initialize = function(a, b) { this.config = a.config; if (this.config.name !== this.config.projectId) throw 1; if (!this.config.payApiURL) throw 2; document.body ? connector._initialize(a, b) : document.addEventListener("DOMContentLoaded", function() { connector._initialize(a, b) }, !1) } ; connector.calcBaseUrl = function() { return this.config.payApiURL.substring(0, this.config.payApiURL.lastIndexOf("/") + 1) } ; connector._initialize = function(a, b) { this.dataLoader = new SimpleDataLoader; Info.initialize(); var c = new (connector.platform._detectPlugin()); connector.platform._installPlugin(c); c.initialize(function() { SimpleDataLoader.INIT_TYPES(a.migrateLocalStorage); c.loadUserId(); this._countryManager = new CountryManager; this._paymentsManager = new PaymentsManager(a.products); this._adsManager = new AdsManager({ manualPermissions: a.manualPermissions }); this._socialManager = new SocialManager; this._platformStorage.start(); var d = connector.social._detectPlugin(); d && connector.social._installPlugin(new d); (d = connector.payments._detectPlugin()) && connector.payments._installPlugin(new d); (d = connector.ads._detectPlugin()) && connector.ads._installPlugin(new d); b(); connector.platform.connect(); connector.social.connect(); connector.payments.connect(); connector.ads.connect() } .bind(this)) } ; var BasePlugin = function(a, b, c) { c = c || {}; this.bus = new ConnectorEventEmitter; this.pluginType = a; this.pluginName = b; this.sdk = c.sdk; this.status = void 0 }; BasePlugin.prototype.onCreated = function() {} ; BasePlugin.prototype.onRemoved = function() {} ; BasePlugin.prototype.canConnect = function() { return !0 } ; BasePlugin.prototype.connect = function() { if (!this.connecting && !this.isConnected() && this.canConnect()) { this.connecting = !0; console.log("[connector] connecting", this.pluginType, this.pluginName); var a = function(b, c) { this.connecting = !1; b = b || connector.STATUS_DISCONNECTED; this.setStatus(b, c); this.onConnected() } .bind(this); this.sdk ? (this.sdkEventHandler = connector.sdk.on(this.sdk, this.onSdkEvent.bind(this)), connector.sdk.loadSdk(this.sdk, function(b) { b === connector.CODE_SUCCEED ? this._connect(connector.utils.waitNoMore(BasePlugin.CONNECT_TIMEOUT, a)) : a(connector.STATUS_DISCONNECTED) } .bind(this))) : this._connect(connector.utils.waitNoMore(BasePlugin.CONNECT_TIMEOUT, a)) } } ; BasePlugin.prototype._connect = function(a) { a(connector.STATUS_CONNECTED) } ; BasePlugin.prototype.onConnected = function() {} ; BasePlugin.prototype.disconnect = function() { this.setStatus(connector.STATUS_DISCONNECTED) } ; BasePlugin.prototype.setStatus = function(a, b) { this.status !== a && (console.log("[connector] setStatus", this.pluginType, this.pluginName, a), this.status = a, this.status === connector.STATUS_DISCONNECTED && this.sdkEventHandler && (this.sdkEventHandler.clear(), this.sdkEventHandler = void 0), this.bus.trigger("changeStatus", this.status, b)) } ; BasePlugin.prototype.isConnected = function() { return this.status === connector.STATUS_CONNECTED } ; BasePlugin.prototype.whenConnected = function(a) { if (this.isConnected()) a(); else var b = this.bus.on("changeStatus", function(c) { c === connector.STATUS_CONNECTED && (b.clear(), a()) }) } ; BasePlugin.prototype.onSdkEvent = function() {} ; BasePlugin.prototype.oneOf = function(a) { a = Array.isArray(a) ? a : Array.prototype.slice.call(arguments); if (a.some(function(b) { return !b || "string" !== typeof b })) throw "Invalid plugin name"; return a.includes(this.pluginName) } ; BasePlugin.CONNECT_TIMEOUT = connector.utils.parseInterval("10 seconds"); var Social = function(a, b) { BasePlugin.call(this, "social", a, b) }; Social.prototype = Object.create(BasePlugin.prototype); Social.prototype.constructor = Social; Social.prototype.isLoggedIn = function() { return !1 } ; Social.prototype._getUserID = function() {} ; Social.prototype.getAccessToken = function() {} ; Social.prototype.isSupportsNativeShare = function() { return !1 } ; Social.prototype.isSupportsNativeInvite = function() { return !1 } ; Social.prototype.isSupportsNativeRequest = function() { return !1 } ; Social.prototype.isSupportsNativeCommunityJoin = function() { return !1 } ; Social.prototype.canJoinCommunity = function(a) { a(!1) } ; Social.prototype.onConnected = function() { if (this.isLoggedIn()) this.onLogin(); else { var a = connector.info.deviceID; a && connector.platform.oneOf(connector.MICROSOFT, connector.RUSTORE) && connector.platform.setUserID(a) } } ; Social.prototype.onLogin = function() { var a = connector.platform.getUserID() , b = this._getUserID(); console.log("Social.onLogin", a, b); connector.platform.setUserID(b); this.deleteAllRequests(); connector._playerManager.refresh(); this.bus.trigger("login", { oldId: a, newId: b }) } ; Social.prototype.login = function(a, b) { console.log("Social.login"); this._login(function() { this.isLoggedIn() ? (console.log("Social.login success"), this.onLogin(), a(!0)) : (console.log("Social.login fail"), a(!1)) } .bind(this), b) } ; Social.prototype._login = function(a) { a() } ; Social.prototype.logout = function() {} ; Social.prototype.invite = function(a, b) { b(connector.CODE_FAILED) } ; Social.prototype.request = function(a, b) { b(connector.CODE_FAILED) } ; Social.prototype.share = function(a, b) { b(connector.CODE_FAILED) } ; Social.prototype.listFriends = function(a) { connector.social.isConnected() ? this._listFriends(a) : a(connector.CODE_FAILED) } ; Social.prototype._listFriends = function(a) { a(connector.CODE_FAILED) } ; Social.prototype.listInvitableFriends = function(a) { connector.social.isConnected() ? this._listInvitableFriends(a) : a(connector.CODE_FAILED) } ; Social.prototype._listInvitableFriends = function(a) { a(connector.CODE_FAILED) } ; Social.prototype.hasLeaderBoard = function() { return !1 } ; Social.prototype._aboutMe = function(a) { this.aboutUser("me", a) } ; Social.prototype.aboutUser = function(a, b) { connector.social.isConnected() ? this._aboutUser(a, b) : b(connector.CODE_FAILED) } ; Social.prototype._aboutUser = function(a, b) { b(connector.CODE_FAILED) } ; Social.prototype.deleteAllRequests = function() {} ; Social.prepareId = function(a) { return "" + a } ; Social.prototype.listAvailable = function() { return [this.pluginName] } ; Social.MAX_INVITE_RANDOM_FRIENDS = 10; var SocialManager = function() {}; SocialManager.prototype.share = function(a, b) { var c = connector.social.getPlugin(); a = this.formatShareData(a); var d = function(e) { e = e === connector.CODE_SUCCEED; c.bus.trigger("share", e); b(e) }; connector.social.isConnected() ? connector.social.isSupportsNativeShare ? c.share(a, function(e) { d(e) }) : d(connector.CODE_FAILED) : d(connector.CODE_FAILED) } ; SocialManager.prototype.invite = function(a, b) { var c = connector.social.getPlugin(); a = this.formatShareData(a); var d = function(e) { e = e === connector.CODE_SUCCEED; c.bus.trigger("invite", e); b(e) }; connector.social.isConnected() ? this.isInviteViaPlatform() ? connector.platform.getPlugin().nativeInviteFriends(a, d) : connector.social.isLoggedIn() ? c.invite(a, d) : d(connector.CODE_FAILED) : d(connector.CODE_FAILED) } ; SocialManager.prototype.joinCommunity = function(a, b) { var c = connector.social.getPlugin() , d = function(e) { e = e === connector.CODE_SUCCEED; c.bus.trigger("joinCommunity", e); a && a(e) }; connector.social.isSupportsNativeCommunityJoin ? connector.social.isConnected() ? c.canJoinCommunity(function(e) { e ? c.joinCommunity(d) : b ? d(connector.CODE_FAILED) : (this.openCommunityUrl(), d(connector.CODE_SUCCEED)) } .bind(this)) : d(connector.CODE_FAILED) : b ? d(connector.CODE_FAILED) : (this.openCommunityUrl(), d(connector.CODE_SUCCEED)) } ; SocialManager.prototype.openCommunityUrl = function() { connector.platform.openUrl(Platform.getGroupUrl()) } ; SocialManager.prototype.request = function(a, b) { var c = connector.social.getPlugin() , d = function(e) { var f = e === connector.CODE_SUCCEED; e && c.bus.trigger("error:request", e); c.bus.trigger("request", f); b(f) }; connector.social.isConnected() ? connector.social.isSupportsNativeRequest ? c.request(a, function(e) { d(e) }) : d(connector.CODE_FAILED) : d(connector.CODE_FAILED) } ; SocialManager.prototype.formatShareData = function(a) { a || (a = {}); a.title || (a.title = document.title); return a } ; SocialManager.prototype.isInviteViaPlatform = function() { return connector.platform.oneOf(connector.MACOS, connector.IOS, connector.ANDROID, connector.AMAZON) } ; var Platform = function(a, b) { BasePlugin.call(this, "platform", a, b); this.paused = !1; this.callbacks = {}; this.nativeEventListeners = {} }; Platform.prototype = Object.create(BasePlugin.prototype); Platform.prototype.constructor = Platform; Platform.prototype.initialize = function(a) { this._pageVisibilitySubscribe(); this._initialize(a) } ; Platform.prototype._pageVisibilitySubscribe = function() { document.hidden && this.pause(); "undefined" !== typeof document.hidden && ["visibilitychange", "webkitvisibilitychange"].forEach(function(a) { document.addEventListener(a, function() { document.hidden ? this.pause() : this.resume() } .bind(this), !1) } .bind(this)); window.addEventListener("pagehide", function() { this.pause() } .bind(this), !1); window.addEventListener("pageshow", function() { this.resume() } .bind(this), !1) } ; Platform.prototype._initialize = function(a) { a() } ; Platform.getGroupUrl = function() { switch (connector.info.source) { case "ok": return connector.info.isMobile ? "https://m.ok.ru/group/" + connector.config.ok.groupId : "https://ok.ru/group/" + connector.config.ok.groupId; case "vk": return connector.info.isMobile ? "https://m.vk.com/" + connector.config.vk.groupId : "https://vk.com/" + connector.config.vk.groupId; case "mm": return connector.info.isMobile ? "https://m.my.mail.ru/community/" + connector.config.mm.groupId : "https://my.mail.ru/community/" + connector.config.mm.groupId; case "mbga": return "http://yahoo-mbga.jp/group/" + connector.config.mbga.groupId; case "sp_mbga": return "http://sp.mbga.jp/_grp_view?g=" + connector.config.mbga.groupId; case "draugiem": return "https://www.draugiem.lv/" + connector.config.draugiem.groupId; case "fotostrana": return "https://fotostrana.ru/public/" + connector.config.fotostrana.groupId; case "discord": return connector.config.discord.groupUrl; default: return connector.config.instant.groupId ? "https://www.facebook.com/" + connector.config.instant.groupId : "https://www.facebook.com/" + connector.config.facebook.groupId } } ; Platform.getGameUrl = function(a) { return connector.utils.guessPlatformURL({ source: a }) } ; Platform.getRateUrl = function() { switch (connector.info.source) { case "test": return connector.utils.guessPlatformURL({ source: "android" }); case "android": return "market://details?id=" + connector.config.android.package; case "amazon": return "amzn://apps/android?p=" + connector.config.amazon.package; case "macos": case "ios": return "itms-apps://itunes.apple.com/app/id" + connector.config.ios.id } } ; Platform.getExternalUrl = function(a) { "/" === a[0] && (a = a.substr(1)); return connector.platform.oneOf(connector.INSTANT, connector.TEST) ? a : connector.config.deployment + "/" + a } ; Platform.prototype.openUrl = function(a) { setTimeout(window.open.bind(window, a, "_blank"), 0) } ; Platform.prototype.nativeInviteFriends = function(a, b) { this.callNative("MessagesPlugin.inviteFriends", { title: a.title, message: a.text, link: connector.utils.guessPlatformURL() }, b) } ; Platform.prototype.loadUserId = function() { (this._userID = connector.dataLoader.load(SimpleDataLoader.TYPES.USER_ID)) || this.setUserID(this.generateTmpId()) } ; Platform.prototype.setUserID = function(a) { if (this._userID !== a) { console.log("Platform.setUserID", this._userID, a); var b = this._userID; this._userID = a; connector.dataLoader.save(SimpleDataLoader.TYPES.USER_ID, this._userID); this.bus.trigger("userIdChanged", { oldId: b, newId: a }) } } ; Platform.prototype.getUserID = function() { return this._userID } ; Platform.prototype.generateTmpId = function() { return "__" + Math.floor(1E15 * Math.random()) } ; Platform.prototype.canReview = function() { return !1 } ; Platform.prototype.getLocalStoragePrefix = function() { return "" } ; Platform.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_ENGLISH] } ; Platform.prototype.hasAudioControls = function() { return !1 } ; Platform.prototype.isAudioEnabled = function() {} ; Platform.prototype.requestReview = function(a) { this.isConnected() ? this._requestReview(a) : a(connector.CODE_FAILED) } ; Platform.prototype._requestReview = function(a) { a(connector.CODE_FAILED) } ; Platform.prototype.canCreateShortcut = function() { return this.isConnected() ? this._canCreateShortcut() : !1 } ; Platform.prototype._canCreateShortcut = function() { return !1 } ; Platform.prototype.createShortcut = function(a) { a && a(connector.CODE_FAILED) } ; Platform.prototype.getAccessToken = function() {} ; Platform.DecodeWebViewData = function(a) { if (a) try { return decodeURIComponent(a) } catch (b) {} return a } ; Platform.prototype.parsePayload = function(a) { connector.info.isNative ? a() : a(connector.utils.getRequestParameters()) } ; Platform.prototype.parseOtherWays = function(a) { a() } ; Platform.prototype.nativeEvent = function(a, b) { this.oneOf(connector.RUSTORE, connector.AMAZON, connector.ANDROID, connector.GPG, connector.PLIEGA, connector.IOS, connector.MACOS, connector.MICROSOFT) && (b = (b = Platform.DecodeWebViewData(b)) && JSON.parse(b)); console.log("Platform.nativeEvent " + a + ": " + JSON.stringify(b)); var c = a.split(".")[0]; a = a.split(".")[1]; if (this.nativeEventListeners[c]) this.nativeEventListeners[c](a, b) } ; Platform.prototype.callNative = function(a, b, c) { c || "function" !== typeof b || (c = b, b = void 0); this.callbacks[a] && (console.log("Platform.callNative - second call to method " + a), this.callCallback(a, connector.CODE_FAILED)); var d = b || {}; d._hasOptions = !!b; d._hasCallback = !!c; this.callbacks[a] = c; this._callNative(a, d) } ; Platform.prototype._callNative = function() {} ; Platform.prototype.callCallback = function(a, b, c) { this.oneOf(connector.RUSTORE, connector.AMAZON, connector.ANDROID, connector.GPG, connector.PLIEGA, connector.IOS, connector.MACOS, connector.MICROSOFT) && (c = (c = Platform.DecodeWebViewData(c)) ? JSON.parse(c) : {}); console.log("Platform.callCallback " + a + " - " + b + " - " + JSON.stringify(c)); var d = this.callbacks[a]; d && (delete this.callbacks[a], d(b, c)) } ; Platform.prototype.isTester = function() { var a = connector.config.testers && connector.config.testers[connector.info.source]; if (!a) return !1; var b = a.ids; a = a.deviceIds; var c = this.getUserID() , d = connector.info.deviceID; return c && b && b.includes(c) || d && a && a.includes(d) } ; Platform.prototype.locationReload = function() { window.location.reload() } ; Platform.prototype.isPaused = function() { return this.paused } ; Platform.prototype.pause = function() { this.paused || (this.paused = !0, this.bus.trigger("pause")) } ; Platform.prototype.resume = function() { this.paused && (this.paused = !1, this.bus.trigger("resume")) } ; Platform.prototype.switchGame = function(a) { connector.platform.openUrl(a) } ; Platform.prototype.getSafePadding = function() { this.safeAreaDiv || (this.safeAreaDiv = document.createElement("div"), this.safeAreaDiv.style.position = "absolute", this.safeAreaDiv.style.top = "env(safe-area-inset-top)", this.safeAreaDiv.style.bottom = "env(safe-area-inset-bottom)", this.safeAreaDiv.style.left = "env(safe-area-inset-left)", this.safeAreaDiv.style.right = "env(safe-area-inset-right)", document.body.appendChild(this.safeAreaDiv)); var a = function(b) { return "undefined" !== typeof window.getComputedStyle ? parseInt(window.getComputedStyle(this.safeAreaDiv).getPropertyValue(b)) || 0 : "undefined" !== typeof this.safeAreaDiv.currentStyle ? parseInt(this.safeAreaDiv.currentStyle[b]) || 0 : 0 } .bind(this); return { top: a("top"), bottom: a("bottom"), left: a("left"), right: a("right") } } ; Platform.prototype.getFrameSize = function() { return cc.size(window.innerWidth, window.innerHeight) } ; var AdsPlugin = function(a, b) { b = b || {}; BasePlugin.call(this, "ads", a, b); this.cantLoadInParallel = b.cantLoadInParallel; this.cantLoadAndPlayInParallel = b.cantLoadAndPlayInParallel; this.customImpressionEvent = b.customImpressionEvent; this.expirationPeriod = b.expirationPeriod; this.cached = {}; this.cachedTime = {}; this.cachedErrorTime = {}; this.playCallbacks = {}; this.loaderState = {}; this.videoState = {}; this.finishTime = {}; this.permissionAsked = !1; AdsPlugin.TYPES.forEach(function(c) { this.loaderState[c] = AdsPlugin.LOADER_STATE.IDLE; this.videoState[c] = AdsPlugin.VIDEO_STATE.IDLE } .bind(this)) }; AdsPlugin.prototype = Object.create(BasePlugin.prototype); AdsPlugin.prototype.constructor = AdsPlugin; AdsPlugin.prototype.canConnect = function() { return this.permissionAsked } ; AdsPlugin.prototype.askPermission = function(a) { this.permissionAsked ? a() : this._askPermission(function() { this.permissionAsked = !0; a() } .bind(this)) } ; AdsPlugin.prototype._askPermission = function(a) { a() } ; AdsPlugin.prototype.onCreated = function() { connector._adsManager.manualPermissions || connector._adsManager.askPermission() } ; AdsPlugin.prototype.setLoaderState = function(a, b) { console.log(this.pluginName, "setLoaderState", a, b); this.loaderState[a] = b; this.bus.trigger(a + ":refresh") } ; AdsPlugin.prototype.setVideoState = function(a, b) { console.log(this.pluginName, "setVideoState", a, b); this.videoState[a] = b; this.bus.trigger("changeVideoState", a, b) } ; AdsPlugin.prototype.whichIsLoading = function() { for (var a in this.loaderState) if (this.isAdLoading(a)) return a } ; AdsPlugin.prototype.whichIsPlaying = function() { for (var a in this.videoState) if (this.videoState[a] === AdsPlugin.VIDEO_STATE.PLAYING) return a } ; AdsPlugin.prototype.isPlaying = function(a) { return this.videoState[a] === AdsPlugin.VIDEO_STATE.PLAYING } ; AdsPlugin.prototype._connect = function(a) { a(connector.STATUS_CONNECTED) } ; AdsPlugin.prototype.isStickyAvailable = function() { return !0 } ; AdsPlugin.prototype.isRewardedSupported = function() { return !0 } ; AdsPlugin.prototype.isInterstitialSupported = function() { return !0 } ; AdsPlugin.prototype.isStickySupported = function() { return !1 } ; AdsPlugin.prototype.isRewardedConfigured = function() { return !0 } ; AdsPlugin.prototype.isInterstitialConfigured = function() { return !0 } ; AdsPlugin.prototype.isStickyConfigured = function() { return !0 } ; AdsPlugin.prototype.isAdLoading = function(a) { return this.loaderState[a] === AdsPlugin.LOADER_STATE.LOADING } ; AdsPlugin.prototype.isAdCached = function(a) { return this.loaderState[a] === AdsPlugin.LOADER_STATE.READY } ; AdsPlugin.prototype.isAdRunning = function(a) { return this.videoState[a] === AdsPlugin.VIDEO_STATE.PLAYING } ; AdsPlugin.prototype.isIdle = function() { return AdsPlugin.TYPES.every(function(a) { return !this.isAdRunning(a) }, this) } ; AdsPlugin.prototype.canCache = function(a) { if (!this.isConnected() || !connector._adsManager.isAdSupported(a) || this.cantLoadInParallel && this.whichIsLoading()) return !1; var b = this.finishTime[a] || 0; return this.cantLoadAndPlayInParallel && (this.isAdRunning(a) || b + AdsPlugin.LOAD_AFTER_PLAY_TIME > Date.now()) || (this.cachedErrorTime[a] || 0) + AdsPlugin.LOAD_AFTER_ERROR_TIME > Date.now() ? !1 : !0 } ; AdsPlugin.prototype.cacheAd = function(a, b) { b = b || function() {} ; this.canCache(a) ? this.isAdCached(a) && !this.isAdExpired(a) ? b(connector.CODE_SUCCEED) : this.cacheAdInner(a, b) : b(connector.CODE_FAILED) } ; AdsPlugin.prototype.cacheAdInner = function(a, b) { this.setLoaderState(a, AdsPlugin.LOADER_STATE.LOADING); this.bus.trigger(a + ":caching", this.pluginName); this._cacheAd(a, connector.utils.waitNoMore(AdsPlugin.TRY_LOADING_TIMEOUT, function(c, d) { this.bus.trigger(a + ":cached", c, this.pluginName); c === connector.CODE_SUCCEED ? (this.cached[a] = d, this.cachedTime[a] = Date.now(), this.setLoaderState(a, AdsPlugin.LOADER_STATE.READY)) : (this.cachedErrorTime[a] = Date.now(), this.setLoaderState(a, AdsPlugin.LOADER_STATE.IDLE)); b(c) } .bind(this))) } ; AdsPlugin.prototype._cacheAd = function(a, b) { b(connector.CODE_SUCCEED, !0) } ; AdsPlugin.prototype.isAdExpired = function() { return !1 } ; AdsPlugin.prototype.consumeCachedAd = function(a) { var b = this.cached[a]; this.cached[a] = void 0; this.cachedTime[a] = void 0; this.cachedErrorTime[a] = void 0; return b } ; AdsPlugin.prototype.whenCached = function(a, b) { if (this.isAdCached(a)) b(connector.CODE_SUCCEED); else if (this.isAdLoading(a)) this.bus.once(a + ":cached", b); else this.cacheAdInner(a, b) } ; AdsPlugin.prototype.playAd = function(a, b) { b = b || function() {} ; var c = this.cachedTime[a] + this.expirationPeriod <= Date.now() , d = this.consumeCachedAd(a); this.setLoaderState(a, AdsPlugin.LOADER_STATE.IDLE); this.setVideoState(a, AdsPlugin.VIDEO_STATE.PLAYING); this.bus.trigger(a + ":start", this.pluginName); c && this.bus.trigger(a + ":start:expired", this.pluginName); this.playCallbacks[a] = connector.utils.once(function(f) { this.playCallbacks[a] = void 0; this.finishTime[a] = Date.now(); this.setVideoState(a, AdsPlugin.VIDEO_STATE.IDLE); var g = f === connector.CODE_SUCCEED; this.bus.trigger(a + ":close", g, this.pluginName); a === AdsPlugin.REWARDED && g && this.bus.trigger("rewarded:reward", this.pluginName); c && this.bus.trigger(a + ":close:expired", this.pluginName); b(f) } .bind(this)); if (this._testNoCallback) delete this._testNoCallback; else { var e = connector.utils.once(function(f) { if (!this.customImpressionEvent && f === connector.CODE_SUCCEED) this.onImpressionEvent(a); if (this.playCallbacks[a]) this.playCallbacks[a](f) } .bind(this)); this._playAd(a, d, function(f) { if ([ERRORS.SHOW_REWARDED.AD_EXPIRED, ERRORS.SHOW_REWARDED.UNKNOWN, ERRORS.SHOW_REWARDED.NO_ADS, ERRORS.SHOW_INTERSTITIAL.UNKNOWN, ERRORS.SHOW_INTERSTITIAL.NO_ADS].includes(f)) { var g = (f + "").replace("error", "e").replace("rewarded", "r").replace("interstitial", "i"); console.log("[connector] Ad error, trying again", f); this.whenCached(a, function(h) { console.log("[connector] Ad cached after error result:", h === connector.CODE_SUCCEED); var k = (h + "").replace("ads_loading_", ""); this.bus.trigger("stream:logs", "ad_retry_c_" + g + "__" + k); h === connector.CODE_SUCCEED ? (h = this.consumeCachedAd(a), this.setLoaderState(a, AdsPlugin.LOADER_STATE.IDLE), this.setVideoState(a, AdsPlugin.VIDEO_STATE.PLAYING), this._playAd(a, h, function(l) { var m = (l + "").replace("error", "e").replace("rewarded", "r").replace("interstitial", "i"); this.bus.trigger("stream:logs", "ad_retry_p_" + g + "__" + m); e(l) } .bind(this))) : a === AdsPlugin.REWARDED ? e(ERRORS.SHOW_REWARDED.NO_ADS) : e(ERRORS.SHOW_INTERSTITIAL.NO_ADS) } .bind(this)) } else e(f) } .bind(this)) } } ; AdsPlugin.prototype._playAd = function(a, b, c) { c(connector.CODE_SUCCEED) } ; AdsPlugin.prototype.finishAd = function(a, b) { if (this.playCallbacks[a]) this.playCallbacks[a](b) } ; AdsPlugin.prototype.onImpressionEvent = function(a, b) { void 0 === b && (b = this.getECPM(a) / 1E3); b && this.bus.trigger(a + ":impression", b, this.pluginName) } ; AdsPlugin.prototype.getECPM = function(a) { if (connector.config.debugMode && (!connector.ads.eCPM[this.pluginName] || !connector.ads.eCPM.rewarded[this.pluginName])) throw "No eCPM for " + this.pluginName; return a === AdsPlugin.REWARDED ? connector.ads.eCPM.rewarded[this.pluginName] || 1 : connector.ads.eCPM[this.pluginName] || 1 } ; AdsPlugin.LOADER_STATE = { IDLE: "idle", LOADING: "loading", READY: "ready" }; AdsPlugin.VIDEO_STATE = { IDLE: "idle", PLAYING: "playing" }; AdsPlugin.REWARDED = "rewarded"; AdsPlugin.INTERSTITIAL = "interstitial"; AdsPlugin.STICKY = "sticky"; AdsPlugin.TYPES = [AdsPlugin.INTERSTITIAL, AdsPlugin.REWARDED]; AdsPlugin.ERROR_LOADING_UNKNOWN = "ads_loading_unknown"; AdsPlugin.ERROR_LOADING_FAILED = "ads_loading_failed"; AdsPlugin.ERROR_LOADING_NO_ADS = "ads_loading_no_ads"; AdsPlugin.ERROR_LOADING_ADBLOCK = "ads_loading_adblock"; AdsPlugin.ERROR_LOADING_ALREADY_LOADING = "ads_loading_already_loading"; AdsPlugin.TRY_LOADING_TIMEOUT = connector.utils.parseInterval("10 seconds"); AdsPlugin.CHECK_CACHE_INTERVAL = connector.utils.parseInterval("30 seconds"); AdsPlugin.LOAD_AFTER_PLAY_TIME = connector.utils.parseInterval("15 seconds"); AdsPlugin.LOAD_AFTER_ERROR_TIME = connector.utils.parseInterval("2 minutes"); var Payments = function(a, b) { BasePlugin.call(this, "payments", a, b); this.currency = this.getDefaultCurrency(); this.products = {}; this.productsById = {}; this.loadedIds = {}; this.productsLoaded = !1; this.bus.on("changeStatus", function(c) { c !== connector.STATUS_CONNECTED && (this.productsLoaded = !1) } .bind(this)); this.createProducts() }; Payments.prototype = Object.create(BasePlugin.prototype); Payments.prototype.constructor = Payments; Payments.prototype.getDefaultCurrency = function() { return "USD" } ; Payments.prototype.createProducts = function() { for (var a in connector._paymentsManager.productsConfig) { var b = this.createProduct(a, connector._paymentsManager.productsConfig[a]); b && (this.products[b.itemId] = b, this.productsById[b.productId] = b) } } ; Payments.prototype.createProduct = function(a, b) { var c = this.getProductId(b); if (null !== c) { void 0 === c && (c = a); var d = b.price , e = this.convertPrice(d) , f = this.getTextPrice(e); a = { itemId: a, type: b.type || "consumable", title: b.title, description: b.description, image: b.image, productId: c + "", price: e, currency: this.currency, priceUSD: d, textPrice: f }; "subscription" === a.type && (a.trial = b.trial, a.period = b.period); b.currencyImage && (a.currencyImage = b.currencyImage); return a } } ; Payments.prototype.getProduct = function(a) { return this.products[a] || this.productsById[a] } ; Payments.prototype.listProducts = function() { return Object.values(this.products) } ; Payments.prototype.listProductIdsOfType = function(a) { a = Array.isArray(a) ? a : [a]; return this.listProducts().filter(function(b) { return a.includes(b.type) }).map(function(b) { return b.productId }) } ; Payments.prototype.isVirtualCurrency = function() { return void 0 !== connector.VIRTUAL_EXCHANGE_RATES[this.currency] } ; Payments.prototype.getExchangeRate = function() { if (this.isVirtualCurrency()) var a = connector.VIRTUAL_EXCHANGE_RATES[this.currency]; else a = connector.EXCHANGE_RATES[this.currency], connector.EXCHANGE_RATES[this.pluginName] && connector.EXCHANGE_RATES[this.pluginName][this.currency] && (a = connector.EXCHANGE_RATES[this.pluginName][this.currency]); return a } ; Payments.prototype.convertPrice = function(a) { var b = this.getExchangeRate(); return 1 === b ? a : Math.max(Math.floor(a * b + .01), 1) } ; Payments.prototype.getPriceToBePaid = function(a) { a = a.price; if (connector.config.debugMode || connector.platform.isTester()) a = 1; return a } ; Payments.prototype.getTextPrice = function(a) { var b = Payments.CURRENCY_SIGNS[this.currency] || this.currency; return ["USD", "EUR", "GBP"].includes(this.currency) ? b + a : a + " " + b } ; Payments.prototype.getProductId = function() {} ; Payments.prototype.setCurrency = function(a) { if ((connector.EXCHANGE_RATES[a] || connector.VIRTUAL_EXCHANGE_RATES[a]) && a !== this.currency) { this.currency = a; for (var b in this.products) { var c = this.products[b]; c.price = this.convertPrice(c.priceUSD); c.currency = a; c.textPrice = this.getTextPrice(c.price) } } } ; Payments.prototype.onRemoved = function() { connector._paymentsManager.stop() } ; Payments.prototype.setPurchaseState = function(a) { this.purchaseState !== a && (this.purchaseState = a, void 0 === this.purchaseState && this.bus.trigger("paymentClosed")) } ; Payments.prototype.isIdle = function() { return void 0 === this.purchaseState } ; Payments.prototype.getPurchaseState = function() { return this.purchaseState } ; Payments.prototype.restore = function(a) { a(connector.CODE_FAILED) } ; Payments.prototype.consume = function(a, b) { b(connector.CODE_SUCCEED) } ; Payments.prototype.purchase = function(a, b) { b(connector.CODE_FAILED) } ; Payments.prototype.validate = function(a, b) { b(connector.CODE_SUCCEED, a) } ; Payments.prototype.createPurchase = function(a, b, c) { b = { userId: String(connector.platform.getUserID()).replace("sb.mbga.jp:", "").replace("mbga.jp:", "").replace("FS_", ""), productId: b.productId, source: connector.info.source, method: this.pluginName, price: this.getPriceToBePaid(b), currency: b.currency || "USD", type: b.type, payload: c || {} }; a && (b.paymentId = String(a)); return b } ; Payments.prototype.getSubscriptionStatus = function(a, b) { var c = connector.info.source; ["android", "ios", "macos"].includes(c) && 0 === Object.keys(a.tokens).length || connector.platform.withTmpID() && ["facebook", "ok"].includes(c) || (a = { source: c, tokens: a.tokens }, ConnectorRestClient.post("/subscriptions/get/" + encodeURIComponent(connector.platform.getUserID()), a, b)) } ; Payments.prototype.loadProducts = function(a) { this.productsLoaded ? a(connector.CODE_SUCCEED) : this._loadProducts(function(b, c) { b === connector.CODE_SUCCEED && (0 < c.length && (this.productsLoaded = !0), this.verifyLoadedProducts(c), this.bus.trigger("productsLoaded")); a(b) } .bind(this)) } ; Payments.prototype._loadProducts = function(a) { var b = this.listProductIdsOfType(["consumable", "nonConsumable"]); a(connector.CODE_SUCCEED, b) } ; Payments.prototype.loadSubscriptions = function(a) { this.subscriptionsLoaded ? a(connector.CODE_SUCCEED) : 0 === this.listProductIdsOfType("subscription").length ? (this.subscriptionsLoaded = !0, a(connector.CODE_SUCCEED)) : this._loadSubscriptions(function(b, c) { b === connector.CODE_SUCCEED && (0 < c.length && (this.subscriptionsLoaded = !0), this.verifyLoadedSubscriptions(c)); a(b) } .bind(this)) } ; Payments.prototype._loadSubscriptions = function(a) { var b = this.listProductIdsOfType("subscription"); a(connector.CODE_SUCCEED, b) } ; Payments.prototype.loadSubscriptionsTokens = function(a) { this.subscriptionsTokensLoaded ? a(connector.CODE_SUCCEED) : 0 === this.listProductIdsOfType("subscription").length ? (this.subscriptionsTokensLoaded = !0, a(connector.CODE_SUCCEED)) : this._loadSubscriptionsTokens(function(b) { b === connector.CODE_SUCCEED && (this.subscriptionsTokensLoaded = !0); a(b) } .bind(this)) } ; Payments.prototype._loadSubscriptionsTokens = function(a) { a(connector.CODE_SUCCEED) } ; Payments.prototype.verifyLoadedSubscriptions = function(a) { a = this._getMissingProducts("subscription", a); 0 < a.length && this.bus.trigger("error:unknownSubscriptions", a) } ; Payments.prototype.verifyLoadedProducts = function(a) { a = this._getMissingProducts(["consumable", "nonConsumable"], a); 0 < a.length && this.bus.trigger("error:unknownProducts", a) } ; Payments.prototype._getMissingProducts = function(a, b) { a = this.listProductIdsOfType(a); return connector.utils.substract(a, b) } ; Payments.prototype.isRestoreAvailable = function() { return connector.payments.isConnected() } ; Payments.prototype.notifyActive = function() {} ; Payments.CURRENCY_SIGNS = { USD: "$", EUR: "\u20ac", GBP: "\u00a3", RUB: "\u20bd", CNY: "\uffe5", MLK: "\u043c\u043b\u043a", FM: "\u0424\u041c" }; Payments.ERROR_INVALID_EMAIL = "INVALID_EMAIL"; var RestPayments = function(a, b) { Payments.call(this, a, b) }; RestPayments.prototype = Object.create(Payments.prototype); RestPayments.prototype.constructor = RestPayments; RestPayments.prototype.purchase = function(a, b) { var c = this.createPurchase(void 0, a); this.startPurchasePinger(c, b); this.purchaseOpen(a, b) } ; RestPayments.prototype.purchaseOpen = function(a, b) { b(connector.CODE_FAILED) } ; RestPayments.prototype.restore = function(a) { var b = "/payments/restore/" + connector.info.source + "/" + encodeURIComponent(connector.platform.getUserID()); ConnectorRestClient.post(b, { version: 3, method: this.pluginName }, function(c) { this.getProduct(c && c.productId) ? a(connector.CODE_SUCCEED, c) : a(connector.CODE_FAILED) } .bind(this), function() { a(connector.CODE_FAILED) }) } ; RestPayments.prototype.validate = function(a, b) { this.startPurchasePinger(a, b, { timeout: connector.utils.parseInterval("3 minutes") }) } ; RestPayments.prototype.consume = function(a, b) { this.startPurchasePinger(a, function(c) { c ? b(ERRORS.CONSUME.UNKNOWN) : b(connector.CODE_SUCCEED) }, { method: "consume", attempts: 5 }) } ; RestPayments.prototype.stopPurchasePinger = function() { this.purchasePinger && (this.purchasePinger.stop(), delete this.purchasePinger) } ; RestPayments.prototype.startPurchasePinger = function(a, b, c) { this.stopPurchasePinger(); b = connector.utils.once(b); c = c || {}; var d = "/payments/" + (c.method || "validate") + "/" + connector.info.source + "/" + encodeURIComponent(connector.platform.getUserID()) , e = { purchase: a, version: 5 }; this.purchasePinger = new Pinger(Object.assign({}, c, { action: function(f) { ConnectorRestClient.send("POST", d, e, function(g) { var h = g.data; "ok" === g.code ? f(connector.CODE_SUCCEED, h) : f(connector.CODE_PENDING) }) }, callback: function(f, g) { f === connector.CODE_SUCCEED && (!(g = g && g.paymentId) || a.paymentId && !RestPayments.IsTmpPaymentId(a.paymentId) || (a.paymentId = g)); b(f, a) } })); this.purchasePinger.start() } ; RestPayments.prototype.notifyActive = function() { this.notifyActiveListener && (console.log("Payments notifyActive"), this.notifyActiveListener(), delete this.notifyActiveListener) } ; RestPayments.IsTmpPaymentId = function(a) { return (a + "").startsWith("tmp") } ; RestPayments.prototype.setNotifyActiveListener = function(a) { this.notifyActiveListener = a } ; RestPayments.prototype.setPurchaseState = function(a) { this.purchaseState !== a && (this.purchaseState = a, this.stopPurchaseActions(), void 0 === this.purchaseState && this.bus.trigger("paymentClosed")) } ; RestPayments.prototype.stopPurchaseActions = function() { this.stopPurchasePinger(); delete this.notifyActiveListener } ; NoSocial = function() { Social.call(this, connector.NONE) } ; NoSocial.prototype = Object.create(Social.prototype); NoSocial.prototype.constructor = NoSocial; NoSocial.prototype._connect = function(a) { a(connector.STATUS_CONNECTED) } ; var NoAdsPlugin = function() { AdsPlugin.call(this, connector.NONE) }; NoAdsPlugin.prototype = Object.create(AdsPlugin.prototype); NoAdsPlugin.prototype.constructor = NoAdsPlugin; NoAdsPlugin.prototype._connect = function(a) { a(connector.STATUS_DISABLED) } ; NoAdsPlugin.prototype.isRewardedSupported = function() { return !1 } ; NoAdsPlugin.prototype.isInterstitialSupported = function() { return !1 } ; NoAdsPlugin.prototype.isStickySupported = function() { return !1 } ; var NoPayments = function() { Payments.call(this, connector.NONE) }; NoPayments.prototype = Object.create(Payments.prototype); NoPayments.prototype.constructor = NoPayments; NoPayments.isAppropriate = function() { return connector.platform.oneOf(connector.PLIEGA, connector.GPG, connector.TON, connector.GDCOM, connector.COOLMATHGAMES, connector.XIAOMI, connector.YOUTUBE, connector.GAMESNACK) || connector.platform.oneOf(connector.MOBAGE, connector.SP_MOBAGE) && ["mbga.jp:63100202", "sb.mbga.jp:63100202"].includes(connector.platform.getUserID()) } ; NoPayments.prototype._connect = function(a) { a(connector.STATUS_DISABLED) } ; var Pinger = function(a) { this.interval = a.interval || Pinger.INTERVAL; this.finishTime = Date.now() + (a.timeout || Pinger.TIMEOUT); this.maxAttempts = a.attempts || 1E6; this.backoff = a.backoff || Pinger.BACKOFF; this.callback = a.callback || function() {} ; this.action = a.action; this.attempt = 0 }; Pinger.prototype.ping = function() { Date.now() > this.finishTime || this.attempt > this.maxAttempts ? (this.callback(connector.CODE_FAILED), this.stop()) : (this.player = new ConnectorActionPlayer([function(a) { a = connector.utils.waitNoMore(1E4, a); this.action(function(b) { [connector.CODE_SUCCEED, connector.CODE_FAILED, connector.CODE_CANCELLED].includes(b) ? (this.callback.apply(this, arguments), this.stop()) : a() } .bind(this)) } .bind(this), function(a) { var b = Math.min(this.interval * Math.pow(this.backoff, this.attempt), Pinger.MAX_INTERVAL); this.timeout = setTimeout(this.ping.bind(this), Math.round(b)); this.attempt++; a() } .bind(this)]), this.player.play()) } ; Pinger.prototype.start = function() { this.ping() } ; Pinger.prototype.stop = function() { this.timeout && (clearTimeout(this.timeout), delete this.timeout); this.player && (this.player.stop(), delete this.player) } ; Pinger.BACKOFF = 1.4; Pinger.INTERVAL = connector.utils.parseInterval("2 seconds"); Pinger.MAX_INTERVAL = connector.utils.parseInterval("1 minute"); Pinger.TIMEOUT = connector.utils.parseInterval("30 minutes"); var BaseFbSocial = function(a, b) { Social.call(this, a, b) }; BaseFbSocial.prototype = Object.create(Social.prototype); BaseFbSocial.prototype.constructor = BaseFbSocial; BaseFbSocial.prototype.pagingLoading = function(a, b, c, d, e) { e || (e = []); d || (d = ""); c || (c = 0); c >= BaseFbSocial.MAX_PAGE ? b(connector.CODE_SUCCEED, e) : this.api(a + "&limit=100" + d, function(f, g) { f === connector.CODE_SUCCEED ? (g.data && (e = e.concat(g.data)), g.paging && g.paging.cursors && g.paging.next && g.paging.cursors.after ? this.pagingLoading(a, b, c + 1, "&after=" + g.paging.cursors.after, e) : b(connector.CODE_SUCCEED, e)) : e.length ? b(connector.CODE_SUCCEED, e) : b(f, e) } .bind(this)) } ; BaseFbSocial.prototype.getShareDialogLink = function(a) { var b = connector.config.payApiURL + "/share"; return b += "?name=" + encodeURIComponent(a.name) + "&description=" + encodeURIComponent(a.text) + "&picture=" + encodeURIComponent(a.image) } ; BaseFbSocial.prototype._listFriends = function(a) { this.pagingLoading("/me/friends?fields=first_name,id,picture.type(large)", a) } ; BaseFbSocial.prototype._aboutMe = function(a) { this.aboutUser("me", a) } ; BaseFbSocial.prototype._aboutUser = function(a, b) { var c = "currency,first_name,name,picture.type(large)"; "me" === a && (c += ",email"); this.api("/" + a + "/?fields=" + c, function(d, e) { d === connector.CODE_SUCCEED ? b(connector.CODE_SUCCEED, BaseFbSocial.formatUserData(e)) : (console.log("Error: " + d), console.log(e), b(connector.CODE_FAILED), 0 <= BaseFbSocial.USERS_BLACK_LIST_ERROR_CODES.indexOf(d) && ConnectorRestClient.post("/users/blacklist/add/" + a, { code: d, data: e }, function() { console.log("Success add to black list:" + a) }, function() { console.log("Failure add to black list:" + a) })) }) } ; BaseFbSocial.prototype.deleteAllRequests = function() { this.api("me/apprequests", function(a, b) { if (a === connector.CODE_SUCCEED) { if (b.data) for (a = 0; a < b.data.length; a++) console.log("START DELETE REQUEST", b.data[a].id), this.api(b.data[a].id, "delete", function(c, d) { console.log("DELETE REQUEST", c, d) }) } else console.log("Error: " + a), console.log(b) } .bind(this)) } ; BaseFbSocial.prototype.api = function() {} ; BaseFbSocial.formatUserData = function(a) { return { id: a.id, name: a.name, firstName: a.first_name, avatar: a.picture && a.picture.data && a.picture.data.url, currency: a.currency && a.currency.user_currency } } ; BaseFbSocial.MAX_PAGE = 20; BaseFbSocial.USERS_BLACK_LIST_ERROR_CODES = [100]; BaseFbSocial.PERMISSIONS = "public_profile,gaming_profile,gaming_user_picture"; var StartFacebook = function() { cc.game.config.plugin = cc.game.config.plugin || {}; cc.game.config.plugin.facebook = connector.config.plugin.facebook; plugin.extend("facebook", { name: "", version: "", _userInfo: null, _isLoggedIn: void 0, HttpMethod: { GET: "get", POST: "post", DELETE: "delete" }, CODE_SUCCEED: 0, AppEvent: { ACTIVATED_APP: FB.AppEvents.EventNames.ACTIVATED_APP, COMPLETED_REGISTRATION: FB.AppEvents.EventNames.COMPLETED_REGISTRATION, VIEWED_CONTENT: FB.AppEvents.EventNames.VIEWED_CONTENT, SEARCHED: FB.AppEvents.EventNames.SEARCHED, RATED: FB.AppEvents.EventNames.RATED, COMPLETED_TUTORIAL: FB.AppEvents.EventNames.COMPLETED_TUTORIAL, ADDED_TO_CART: FB.AppEvents.EventNames.ADDED_TO_CART, ADDED_TO_WISHLIST: FB.AppEvents.EventNames.ADDED_TO_WISHLIST, INITIATED_CHECKOUT: FB.AppEvents.EventNames.INITIATED_CHECKOUT, ADDED_PAYMENT_INFO: FB.AppEvents.EventNames.ADDED_PAYMENT_INFO, PURCHASED: FB.AppEvents.EventNames.PURCHASED, ACHIEVED_LEVEL: FB.AppEvents.EventNames.ACHIEVED_LEVEL, UNLOCKED_ACHIEVEMENT: FB.AppEvents.EventNames.UNLOCKED_ACHIEVEMENT, SPENT_CREDITS: FB.AppEvents.EventNames.SPENT_CREDITS }, AppEventParam: { CURRENCY: FB.AppEvents.ParameterNames.CURRENCY, REGISTRATION_METHOD: FB.AppEvents.ParameterNames.REGISTRATION_METHOD, CONTENT_TYPE: FB.AppEvents.ParameterNames.CONTENT_TYPE, CONTENT_ID: FB.AppEvents.ParameterNames.CONTENT_ID, SEARCH_STRING: FB.AppEvents.ParameterNames.SEARCH_STRING, SUCCESS: FB.AppEvents.ParameterNames.SUCCESS, MAX_RATING_VALUE: FB.AppEvents.ParameterNames.MAX_RATING_VALUE, PAYMENT_INFO_AVAILABLE: FB.AppEvents.ParameterNames.PAYMENT_INFO_AVAILABLE, NUM_ITEMS: FB.AppEvents.ParameterNames.NUM_ITEMS, LEVEL: FB.AppEvents.ParameterNames.LEVEL, DESCRIPTION: FB.AppEvents.ParameterNames.DESCRIPTION }, AppEventParamValue: { VALUE_YES: "1", VALUE_NO: "0" }, _checkLoginStatus: function(a) { var b = this; FB.getLoginStatus(function(c) { c && "connected" === c.status ? (b._isLoggedIn = !0, b._userInfo = c.authResponse) : (b._isLoggedIn = !1, b._userInfo = {}) }) }, ctor: function(a) { this.name = "facebook"; this.version = "1.0"; this._userInfo = {}; this._isLoggedIn = void 0; FB && (FB.init(a), this._checkLoginStatus(!0), plugin.FacebookAgent = this) }, getInstance: function() { return this }, login: function(a, b) { a = { scope: a, return_scopes: !0 }; FB.login(function(c) { if (c.authResponse) { this._isLoggedIn = !0; this._userInfo = c.authResponse; var d = c.authResponse.grantedScopes.split(","); "function" === typeof b && b(0, { accessToken: c.authResponse.accessToken, permissions: d }) } else this._isLoggedIn = !1, this._userInfo = {}, "function" === typeof b && b(c.error_code || 1, { error_message: c.error_message || "Unknown error" }) } .bind(this), a) }, isLoggedIn: function() { return this._isLoggedIn }, logout: function(a) { var b = this; FB.logout(function(c) { c.authResponse ? (b._isLoggedIn = !1, b._userInfo = {}, "function" === typeof a && a(0, { isLoggedIn: !1 })) : "function" === typeof a && a(c.error_code || 1, { error_message: c.error_message || "Unknown error" }) }) }, _requestPermissions: function(a, b) { a = a.join(","); var c = this; FB.login(function(d) { if (d.authResponse) { var e = d.authResponse.grantedScopes.split(","); c._isLoggedIn = !0; c._userInfo = d.authResponse; "function" === typeof b && b(0, { permissions: e }) } else c._isLoggedIn = !1, c._userInfo = {}, "function" === typeof b && b(d.error_code || 1, { error_message: d.error_message || "Unknown error" }) }, { scope: a, return_scopes: !0 }) }, getAccessToken: function() { return this._userInfo ? this._userInfo.accessToken : null }, getUserID: function() { return this._userInfo ? this._userInfo.userID : null }, _share: function(a, b) { FB.ui({ method: "share", caption: a.caption, href: a.link }, function(c) { c ? c.post_id ? "function" === typeof b && b(0, { didComplete: !0, post_id: c.post_id }) : "function" === typeof b && b(c.error_code || 1, { error_message: c.error_message || "Unknown error" }) : "function" === typeof b && b(1, { error_message: "Unknown error" }) }) }, dialog: function(a, b) { if (a) if (this.canPresentDialog(a)) { a.name = a.name || a.site; delete a.site; a.href = a.href || a.link || a.siteUrl; delete a.siteUrl; delete a.link; a.picture = a.picture || a.image || a.photo || a.imageUrl || a.imagePath; delete a.imageUrl; delete a.imagePath; delete a.photo; delete a.image; a.caption = a.title || a.caption; delete a.title; a.description = a.text || a.description; delete a.text; var c = a.dialog; delete a.dialog; if ("shareLink" === c || "feedDialog" == c) a.method = "share"; else if ("messageLink" == c) a.method = "send", a.link = a.href; else if ("shareOpenGraph" == c && (a.method = "share_open_graph", a.url)) { c = {}; a.preview_property_name ? c[a.preview_property_name] = a.url : c.object = a.url; for (var d in a) "method" != d && "action_type" != d && "action_properties" != d && (a[d] && (c[d] = a[d]), delete a[d]); a.action_properties = JSON.stringify(c) } FB.ui(a, function(e) { e && "function" === typeof b ? e.post_id || e.success ? b(0, { didComplete: !0, post_id: e.post_id || "" }) : e.error_code ? b(e.error_code, { error_message: e.error_message || "Unknown error" }) : b(0, e) : void 0 == e && "function" === typeof b && b(1, { error_message: "Unknown error" }) }) } else "function" === typeof b && b(1, { error_message: "The requested dialog: " + a.dialog + " can not be presented on Web" }); else "function" === typeof b && b(1, { error_message: "No info parameter provided" }) }, canPresentDialog: function(a) { return a && a.dialog && ("shareLink" === a.dialog || "feedDialog" === a.dialog || "shareOpenGraph" === a.dialog || "messageLink" === a.dialog) ? !0 : !1 }, api: function(a, b, c, d) { "function" === typeof c && (d = c, c = {}); FB.api(a, b, c, function(e) { e.error ? "function" === typeof d && d(e.error.code, { error_message: e.error.message || "Unknown error" }) : "function" === typeof d && d(0, e) }) }, _getPermissionList: function(a) { FB.api("/me/permissions", function(b) { if (b.data) { for (var c = [], d = 0; d < b.data.length; d++) "granted" == b.data[d].status && c.push(b.data[d].permission); "function" == typeof a && a(0, { permissions: c }) } else b.error || (b.error = {}), "function" == typeof a && a(b.error.code || 1, { error_message: b.error.message || "Unknown error" }) }) }, destroyInstance: function() {}, canvas: { pay: function(a, b) { var c = { method: "pay", action: "purchaseitem", product: a.product }; "subscription" === a.type && (c.action = "create_subscription"); -1 !== ["cancel_subscription", "reactivate_subscription", "change_subscription"].indexOf(a.action) && (c.action = a.action, c.subscription_id = a.subscription_id); FB.ui(c, function(d) { d ? d.error_code ? b(d.error_code || 1, { error_message: d.error_message || d.error_msg || "Unknown error" }) : b(0, d) : ("create_subscription" !== c.action && setTimeout(function() { throw "no response in FB.ui callback " + c.action + " " + c.product + " " + c.subscription_id; }, 0), b(1, { error_message: "Unknown error" })) }) } }, appRequest: function(a, b) { a ? (a.method = "apprequests", FB.ui(a, function(c) { c ? c.error_code ? "function" === typeof b && b(c.error_code, { error_message: c.error_message || "Unknown error" }) : "function" === typeof b && b(0, c) : "function" === typeof b && b(1, { error_message: "Unknown error" }) })) : "function" === typeof b && b(1, { error_message: "No info parameter provided" }) }, logEvent: function(a, b, c) { void 0 != a && (void 0 === b && void 0 === c ? FB.AppEvents.logEvent(a, null, null) : "number" === typeof b && void 0 === c ? FB.AppEvents.logEvent(a, b) : "object" === typeof b && void 0 === c ? FB.AppEvents.logEvent(a, null, b) : FB.AppEvents.logEvent(a, b, c)) }, activateApp: function() { FB.AppEvents.activateApp() }, logPurchase: function(a, b, c) { FB.AppEvents.logPurchase(a, b, c) } }) }; var VKSocial = function() { Social.MAX_INVITE_RANDOM_FRIENDS = 1; Social.call(this, connector.VK, { sdk: SdkManager.SDK_VK }); connector.config.debugMode && !connector.platform.isTester() && (document.body.innerHTML = "\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e") }; VKSocial.prototype = Object.create(Social.prototype); VKSocial.prototype.constructor = VKSocial; VKSocial.prototype.isSupportsNativeShare = function() { return !0 } ; VKSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; VKSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; VKSocial.prototype.sendActivity = function(a, b) { var c = { user_id: connector.platform.getUserID(), v: VKPlatform.API_VERSION }; c.activity_id = a.activityId; a.value && (c.value = a.value); ConnectorRestClient.get("/vkappevents", {}, function() { b(connector.CODE_SUCCEED) }, function() { b(connector.CODE_FAILED) }, { queryParams: c }) } ; VKSocial.prototype.markAchievement = function(a) { void 0 !== a.vkId && this.sendActivity({ activityId: a.vkId }, function() {}) } ; VKSocial.prototype.isLoggedIn = function() { return !0 } ; VKSocial.prototype._getUserID = function() { return connector.utils.getRequestParameters().viewer_id } ; VKSocial.prototype.getAccessToken = function() { return "VK_" + connector.utils.getRequestParameters().auth_key } ; VKSocial.prototype._login = function(a) { a() } ; VKSocial.prototype.invite = function(a, b) { connector.platform.callNative("VKWebAppShowInviteBox", {}, b) } ; VKSocial.prototype.requestToOne = function(a, b, c) { connector.platform.callNative("VKWebAppShowRequestBox", { uid: parseInt(a), message: b.text, requestKey: "key" }, c) } ; VKSocial.prototype.request = function(a, b) { var c = a.to; Array.isArray(c) || (c = [c]); var d = [] , e = function(f) { f === c.length ? b(d.length > Math.floor(c.length / 2) ? connector.CODE_SUCCEED : connector.CODE_CANCELLED, d) : this.requestToOne(c[f], a, function(g) { g === connector.CODE_SUCCEED && d.push(c[f]); e(f + 1) }) } .bind(this); e(0) } ; VKSocial.prototype.share = function(a, b) { connector.platform.callNative("VKWebAppShowWallPostBox", { message: a.text + "\n" + connector.platform.getGameUrl(), attachments: a.image + ",https://vk.com/app" + connector.config.vk.appId }, b) } ; VKSocial.prototype.hasLeaderBoard = function() { return connector.info.isMobile } ; VKSocial.prototype.showLeaderBoard = function(a, b) { connector.platform.callNative("VKWebAppShowLeaderBoardBox", { user_result: a.userResult }, b) } ; VKSocial.prototype.askFriendsPermission = function(a) { connector.platform.getPlugin().askPermissions("friends", a) } ; VKSocial.prototype.listFriendsByApp = function(a, b) { var c = function(d, e) { if (d !== connector.CODE_SUCCEED) b(connector.CODE_FAILED, []); else if (e && e.response && e.response.map) { var f = e.response.map(VKSocial.prepareId); connector.platform.callNative("friends.get", { count: 1E3, fields: "photo_200" }, function(g, h) { g !== connector.CODE_SUCCEED ? b(connector.CODE_FAILED, []) : b(connector.CODE_SUCCEED, this.prepareFriendsData(h.response && h.response.items, f, a)) } .bind(this)) } else b(connector.CODE_FAILED, []) } .bind(this); connector.platform.callNative("friends.getAppUsers", {}, c) } ; VKSocial.prototype.prepareFriendsData = function(a, b, c) { return (a || []).filter(function(d) { return void 0 === d.deactivated }).map(VKSocial.formatUserData).filter(function(d) { return c === (-1 !== b.indexOf(d.id)) }) } ; VKSocial.prototype._listFriends = function(a) { this.listFriendsByApp(!0, a) } ; VKSocial.prototype._listInvitableFriends = function(a) { this.listFriendsByApp(!1, a) } ; VKSocial.prototype._aboutMe = function(a) { connector.platform.callNative("VKWebAppGetUserInfo", {}, function(b, c) { b === connector.CODE_SUCCEED ? a(connector.CODE_SUCCEED, VKSocial.formatUserData(c)) : a(connector.CODE_FAILED) }) } ; VKSocial.prepareId = function(a) { return "" + a } ; VKSocial.formatUserData = function(a) { return { id: VKSocial.prepareId(a.id), name: a.first_name + " " + a.last_name, firstName: a.first_name, lastName: a.last_name, avatar: a.photo_200 && -1 === a.photo_200.indexOf("camera_200.png") ? a.photo_200 : void 0 } } ; VKSocial.DEFAULT_HEIGHT = 720; VKSocial.DEFAULT_WIDTH = 800; VKSocial.MIN_HEIGHT = 480; VKSocial.SCREEN_HEIGHT_RESERVED = 230; var OKSocial = function() { Social.call(this, connector.OK, { sdk: SdkManager.SDK_OK }) }; OKSocial.prototype = Object.create(Social.prototype); OKSocial.prototype.constructor = OKSocial; OKSocial.prototype.isSupportsNativeShare = function() { return !0 } ; OKSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; OKSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; OKSocial.prototype.isSupportsNativeCommunityJoin = function() { return !0 } ; OKSocial.prototype.isLoggedIn = function() { return connector.social.isConnected() } ; OKSocial.prototype._getUserID = function() { if (connector.social.isConnected()) return FAPI.Util.getRequestParameters().logged_user_id } ; OKSocial.prototype.getAccessToken = function() { if (connector.social.isConnected()) return "OK_" + FAPI.Util.getRequestParameters().session_key + "_" + FAPI.Util.getRequestParameters().auth_sig } ; OKSocial.prototype._login = function(a) { a() } ; OKSocial.prototype.invite = function(a, b) { connector.platform.getPlugin().listeners.showInvite = function(c, d) { c !== OKSocial.CODE_SUCCEED ? b(connector.CODE_CANCELLED, d) : b(connector.CODE_SUCCEED) } ; FAPI.UI.showInvite(a.text) } ; OKSocial.prototype.request = function(a, b) { "object" === typeof a.to && (a.to = a.to.join(";")); connector.platform.getPlugin().listeners.showNotification = function(c, d) { "error" === c && "noUsers" === d ? b(connector.CODE_SUCCEED, []) : c !== OKSocial.CODE_SUCCEED ? b(connector.CODE_CANCELLED, d) : (d = d.split(","), b(connector.CODE_SUCCEED, d)) } ; FAPI.UI.showNotification(a.text, "", a.to) } ; OKSocial.prototype.share = function(a, b) { a = [{ type: "app", text: a.text, images: [{ url: a.image, title: a.title }], actions: [{ text: a.title, mark: a.title }] }]; connector.platform.getPlugin().listeners.postMediatopic = function(c, d) { c !== OKSocial.CODE_SUCCEED ? b(connector.CODE_CANCELLED, d) : b(connector.CODE_SUCCEED) } ; FAPI.UI.postMediatopic({ media: a }, !0) } ; OKSocial.prototype.loadFriendsPerPage = function(a, b) { a = a.slice(0, 1E3); for (var c = [], d = 0; d < a.length; d += 100) c.push(a.slice(d, d + 100)); if (0 === c.length) b(connector.CODE_SUCCEED, []); else { var e = c.length , f = [] , g = function(h, k) { h === connector.CODE_SUCCEED && (f = f.concat(k)); e--; 0 === e && b(connector.CODE_SUCCEED, f) }; c.forEach(function(h) { this.aboutUser(h, g) } .bind(this)) } } ; OKSocial.prototype._listFriends = function(a) { FAPI.Client.call({ method: "friends.getAppUsers" }, function(b, c, d) { b !== OKSocial.CODE_SUCCEED ? (console.log("list friends error: " + d), a(connector.CODE_CANCELLED)) : this.loadFriendsPerPage(c.uids, a) } .bind(this)) } ; OKSocial.prototype._listInvitableFriends = function(a) { FAPI.Client.call({ method: "friends.get", sort_type: "PRESENT" }, function(b, c, d) { b !== OKSocial.CODE_SUCCEED ? (console.log("list ivitable friends error: " + d), a(connector.CODE_CANCELLED)) : FAPI.Client.call({ method: "friends.getAppUsers" }, function(e, f, g) { e !== OKSocial.CODE_SUCCEED ? (console.log("list friends error: " + g), a(connector.CODE_CANCELLED)) : this.loadFriendsPerPage(connector.utils.substract(c, f.uids), a) } .bind(this)) } .bind(this)) } ; OKSocial.formatUserData = function(a) { -1 !== a.pic128x128.indexOf("stub_128x128.gif") && (a.pic128x128 = ""); -1 !== a.pic128x128.indexOf("stub/user") && (a.pic128x128 = ""); return { id: a.uid, name: a.first_name + " " + a.last_name, firstName: a.first_name, lastName: a.last_name, avatar: a.pic128x128 } } ; OKSocial.prototype._aboutUser = function(a, b) { var c = !Array.isArray(a); c || (a = a.join(",")); FAPI.Client.call({ uids: a, fields: "first_name,last_name,uid,pic128x128", method: "users.getInfo" }, function(d, e) { d !== OKSocial.CODE_SUCCEED ? b(connector.CODE_FAILED) : (d = e.map(function(f) { return OKSocial.formatUserData(f) }), c ? b(connector.CODE_SUCCEED, d[0]) : b(connector.CODE_SUCCEED, d)) }) } ; OKSocial.prototype._aboutMe = function(a) { this.aboutUser(connector.platform.getUserID(), a) } ; OKSocial.prototype.canJoinCommunity = function(a) { this.isInGroup(function(b) { b ? this.isMessagesAllowed(function(c) { a(!c) }) : a(!0) } .bind(this)) } ; OKSocial.prototype.joinCommunity = function(a) { connector.platform.getPlugin().listeners.joinGroup = function(b) { a("ok" === b ? connector.CODE_SUCCEED : connector.CODE_FAILED) } ; FAPI.UI.joinGroup(connector.config.ok.groupId, !0) } ; OKSocial.prototype.isMessagesAllowed = function(a) { FAPI.Client.call({ method: "group.isMessagesAllowed", gid: connector.config.ok.groupId }, function(b, c) { "ok" !== b ? a(!1) : a(c.allowed) }) } ; OKSocial.prototype.isInGroup = function(a) { FAPI.Client.call({ method: "group.getUserGroupsV2" }, function(b, c) { b = "ok" === b && c && c.groups || []; c = !1; for (var d = 0; d < b.length; d++) if (b[d].groupId === connector.config.ok.groupId) { c = !0; break } a(c) }) } ; OKSocial.CODE_SUCCEED = "ok"; var MyMailRuSocial = function() { Social.call(this, connector.MM, { sdk: SdkManager.SDK_MYMAILRU }) }; MyMailRuSocial.prototype = Object.create(Social.prototype); MyMailRuSocial.prototype.constructor = MyMailRuSocial; MyMailRuSocial.prototype.isSupportsNativeShare = function() { return connector.info.os !== connector.OS_IOS } ; MyMailRuSocial.prototype.isSupportsNativeInvite = function() { return connector.info.os !== connector.OS_IOS } ; MyMailRuSocial.prototype.isSupportsNativeRequest = function() { return connector.info.os !== connector.OS_IOS } ; MyMailRuSocial.prototype._connect = function(a) { connector.info.os !== connector.OS_IOS && (this.listeners = { friendsInvitation: function() {}, friendsRequest: function() {}, streamPublish: function() {} }, mailru.events.listen(mailru.app.events.friendsInvitation, function(b) { this.listeners.friendsInvitation(b) } .bind(this)), mailru.events.listen(mailru.app.events.friendsRequest, function(b) { this.listeners.friendsRequest(b) } .bind(this)), mailru.events.listen(mailru.common.events.streamPublish, function(b) { this.listeners.streamPublish(b) } .bind(this))); a(connector.STATUS_CONNECTED) } ; MyMailRuSocial.prototype.isLoggedIn = function() { return !0 } ; MyMailRuSocial.prototype._getUserID = function() { return connector.utils.getRequestParameters().vid } ; MyMailRuSocial.prototype.getAccessToken = function() { var a = [] , b = connector.utils.getRequestParameters(); for (c in b) "sig" !== c && a.push(c); a.sort(); var c = ""; for (var d = 0; d < a.length; d++) c += a[d] + "=" + b[a[d]]; return "MM_" + b.sig + "_" + c } ; MyMailRuSocial.prototype._login = function(a) { a() } ; MyMailRuSocial.prototype.invite = function(a, b) { connector.info.os === connector.OS_IOS ? b(connector.CODE_FAILED) : (this.listeners.friendsInvitation = function(c) { "opened" !== c.status && b(c.data && c.data.length ? connector.CODE_SUCCEED : connector.CODE_CANCELLED) } , mailru.app.friends.invite({ text: a.text })) } ; MyMailRuSocial.prototype.request = function(a, b) { connector.info.os === connector.OS_IOS ? b(connector.CODE_FAILED) : (this.listeners.friendsRequest = function(c) { "opened" !== c.status && (c.data && c.data.length ? b(connector.CODE_SUCCEED, c.data) : b(connector.CODE_CANCELLED)) } , mailru.app.friends.request({ text: a.text, image_url: a.image, friends: a.to })) } ; MyMailRuSocial.prototype.share = function(a, b) { connector.info.os === connector.OS_IOS ? b(connector.CODE_FAILED) : (this.listeners.streamPublish = function(c) { "opened" !== c.status && ("publishSuccess" === c.status ? b(connector.CODE_SUCCEED) : (console.log(c.status), b(connector.CODE_CANCELLED))) } , mailru.common.stream.post({ title: a.title, text: a.text, img_url: a.image })) } ; MyMailRuSocial.prototype._listFriends = function(a) { mailru.common.friends.getAppUsers(function(b) { for (var c = [], d = 0; d < b.length; d++) c.push(MyMailRuSocial.formatUserData(b[d])); a(connector.CODE_SUCCEED, c) }, !0) } ; MyMailRuSocial.prototype._listInvitableFriends = function(a) { mailru.common.friends.getExtended(function(b) { for (var c = [], d = 0; d < b.length; d++) b[d].app_installed || c.push(MyMailRuSocial.formatUserData(b[d])); a(connector.CODE_SUCCEED, c) }) } ; MyMailRuSocial.formatUserData = function(a) { return { id: a.uid, name: a.first_name + " " + a.last_name, firstName: a.first_name, lastName: a.last_name, avatar: a.pic_128 } } ; MyMailRuSocial.prototype._aboutUser = function(a, b) { var c = !Array.isArray(a); mailru.common.users.getInfo(function(d) { d.error ? b(connector.CODE_FAILED) : (d && "function" === typeof d.map || this.bus.trigger("stream:error", "MailRU aboutUser response - " + JSON.stringify(d)), d = d.map(function(e) { return MyMailRuSocial.formatUserData(e) }), c ? b(connector.CODE_SUCCEED, d[0]) : b(connector.CODE_SUCCEED, d)) } .bind(this), a) } ; MyMailRuSocial.prototype._aboutMe = function(a) { this.aboutUser(connector.platform.getUserID(), a) } ; var MobageSocial = function(a, b) { Social.call(this, a || connector.MOBAGE, b) }; MobageSocial.prototype = Object.create(Social.prototype); MobageSocial.prototype.constructor = MobageSocial; MobageSocial.HEIGHT = 860; MobageSocial.prototype.isSupportsNativeShare = function() { return !0 } ; MobageSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; MobageSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; MobageSocial.prototype._connect = function(a) { gadgets.window.adjustHeight(MobageSocial.HEIGHT); var b = opensocial.newDataRequest(); b.add(b.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), "viewer"); b.send(function(c) { c.hadError() ? a(connector.STATUS_DISCONNECTED) : (c = c.get("viewer"), c.hadError() ? a(connector.STATUS_DISCONNECTED) : (c = c.getData(), "mbga.jp:-1" === c.getId() ? a(connector.STATUS_DISCONNECTED) : (this.user = MobageSocial.formatUserData(c), console.log(this.user), a(connector.STATUS_CONNECTED)))) } .bind(this)) } ; MobageSocial.prototype.isLoggedIn = function() { return !0 } ; MobageSocial.prototype._getUserID = function() { return this.user && this.user.id } ; MobageSocial.prototype.getAccessToken = function() { return "mbga" } ; MobageSocial.prototype._login = function(a) { a() } ; MobageSocial.prototype.sendActivity = function(a, b) { var c = {}; c[opensocial.Activity.Field.TITLE] = a.title; c[opensocial.Activity.Field.BODY] = a.body; a = opensocial.newActivity(c); opensocial.requestCreateActivity(a, opensocial.CreateActivityPriority.LOW, function(d) { d.hadError() ? b(connector.CODE_FAILED) : b(connector.CODE_SUCCEED) }) } ; MobageSocial.prototype.invite = function(a, b) { var c = {}; c[opensocial.Message.Field.TITLE] = a.title; a = opensocial.newMessage(a.text, c); opensocial.requestShareApp("VIEWER_FRIENDS", a, function(d) { d.hadError() ? b(connector.CODE_CANCELLED, d) : b(connector.CODE_SUCCEED) }) } ; MobageSocial.prototype.requestToOne = function(a, b, c) { var d = {}; d[opensocial.Message.Field.TITLE] = b.title; b = opensocial.newMessage(b.text, d); opensocial.requestSendMessage(a, b, function(e) { e.hadError() ? c(connector.CODE_CANCELLED) : (e = e.getData(), e.recipientIds && 0 < e.recipientIds.length ? c(connector.CODE_SUCCEED) : c(connector.CODE_CANCELLED)) }) } ; MobageSocial.prototype.request = function(a, b) { var c = a.to; Array.isArray(c) || (c = [c]); var d = [] , e = function(f) { f === c.length ? b(0 < d.length ? connector.CODE_SUCCEED : connector.CODE_CANCELLED, d) : this.requestToOne(c[f], a, function(g) { g === connector.CODE_SUCCEED && d.push(c[f]); setTimeout(function() { e(f + 1) }, 500) }) } .bind(this); e(0) } ; MobageSocial.prototype.share = function(a, b) { var c = opensocial.newMediaItem("image/jpg", a.image); c.setField(opensocial.MediaItem.Field.TYPE, opensocial.MediaItem.Type.IMAGE); var d = {}; d[mbga.Diary.Field.TITLE] = a.title; d[mbga.Diary.Field.CONTENT] = a.text; d[mbga.Diary.Field.MEDIA_ITEMS] = [c]; a = mbga.newCreateDiary(d); mbga.requestCreateDiary(a, function(e) { e.hadError() ? b(connector.CODE_FAILED, e) : (e = e.getData().getEntryURL(), console.log(e), b(e ? connector.CODE_SUCCEED : connector.CODE_CANCELLED)) }) } ; MobageSocial.prototype.listFriendsByApp = function(a, b) { var c = {}; c[opensocial.DataRequest.PeopleRequestFields.MAX] = 1E3; c[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [opensocial.Person.Field.HAS_APP]; var d = {}; d[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER; d[opensocial.IdSpec.Field.GROUP_ID] = opensocial.IdSpec.GroupId.FRIENDS; d = opensocial.newIdSpec(d); var e = opensocial.newDataRequest(); e.add(e.newFetchPeopleRequest(d, c), "friends"); e.send(function(f) { f.hadError() ? b(connector.CODE_FAILED) : (f = f.get("friends").getData().asArray(), f = f.filter(function(g) { return g.getField(opensocial.Person.Field.HAS_APP) === a }), b(connector.CODE_SUCCEED, f.map(MobageSocial.formatUserData))) }) } ; MobageSocial.prototype._listFriends = function(a) { this.listFriendsByApp(!0, a) } ; MobageSocial.prototype._listInvitableFriends = function(a) { this.listFriendsByApp(!1, a) } ; MobageSocial.formatUserData = function(a) { var b = "" , c = { id: a.getId(), name: a.getDisplayName() }; try { return b = MobageSocial.proxyAvatar(a.getField(opensocial.Person.Field.THUMBNAIL_URL)), c.avatar = b, c } catch (d) { if (d instanceof TypeError || d.message && -1 !== d.message.indexOf("of null")) throw a = d.message + " avatarUrl - " + b + " reqUserId - " + c.id + " reqUserName - " + c.name + " stack - " + JSON.stringify(d.stack), Error(a); throw d; } } ; MobageSocial.proxyAvatar = function(a) { var b = connector.platform.getExternalUrl("proxy"); a = a.match(/.*profile(.*)/); return b + a[1] } ; MobageSocial.prototype._aboutMe = function(a) { this.user ? a(connector.CODE_SUCCEED, this.user) : a(connector.CODE_FAILED) } ; MobageSocial.CODE_SUCCEED = "ok"; var SPMobageSocial = function() { MobageSocial.call(this, connector.SP_MOBAGE, { sdk: SdkManager.SDK_SPMOBAGE }); this.clientData = { clientId: SPMobageSocial.getClientId(), state: "mobage-connect_" + Math.random().toString(36).slice(-16), code: null, connected: !1 }; this.clientData.redirectUrl = SPMobageSocial.getRedirectUrl(); connector.social.mobagePlatformLogin = !1; connector.platform.on("pause", this._updateRefreshInterval.bind(this)); connector.platform.on("resume", this._updateRefreshInterval.bind(this)) }; SPMobageSocial.prototype = Object.create(MobageSocial.prototype); SPMobageSocial.prototype.constructor = SPMobageSocial; SPMobageSocial.prototype.isSupportsNativeShare = function() { return !1 } ; SPMobageSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; SPMobageSocial.prototype.isSupportsNativeRequest = function() { return !1 } ; SPMobageSocial.prototype.needTokenRefresh = function() { return this.clientData.token && this.clientData.token.expireTime ? this.clientData.token.expireTime <= Date.now() : !0 } ; SPMobageSocial.prototype.checkAccessToken = function(a) { a = a || function() {} ; var b = function(d) { ConnectorRestClient.get(d.path, {}, function(e) { this.clientData.token.accessToken = e.accessToken; this.clientData.token.refreshToken = e.refreshToken; this.clientData.token.expireTime = Date.now() + 1E3 * e.expiresIn; a() } .bind(this), function() {}, { queryParams: d }) } .bind(this) , c = { redirect_uri: this.clientData.redirectUrl }; this.clientData.token ? this.needTokenRefresh() ? (c.path = "/spmbgatoken/refresh", c.refresh_token = this.clientData.token.refreshToken, b(c)) : a() : (this.clientData.token = {}, c.path = "/spmbgatoken/get", c.code = this.clientData.code, b(c)) } ; SPMobageSocial.prototype._connect = function(a) { try { mobage.oauth.getConnectedStatus({ state: this.clientData.state }, function(b, c) { b ? (connector.social.mobagePlatformLogin = b.login, this.clientData.connected = b.connected, a(connector.STATUS_CONNECTED)) : (connector.social.mobagePlatformLogin = !0, this.clientData.connected = !0, this.clientData.code = c.response.code, this.getPlayerInfo(function(d) { a(d === connector.CODE_SUCCEED ? connector.STATUS_CONNECTED : connector.STATUS_DISCONNECTED) })) } .bind(this)) } catch (b) { console.log("Get connect status error", b), a(connector.STATUS_DISCONNECTED) } } ; SPMobageSocial.prototype.onConnected = function() { MobageSocial.prototype.onConnected.call(this); this._updateRefreshInterval() } ; SPMobageSocial.prototype._updateRefreshInterval = function() { !this.isConnected() || connector.platform.isPaused ? this._checkStatusInterval && (clearInterval(this._checkStatusInterval), this._checkStatusInterval = void 0) : this._checkStatusInterval || (this._checkStatusInterval = setInterval(this.periodicCheck.bind(this), connector.utils.parseInterval(SPMobageSocial.CHECK_STATUS_INTERVAL))) } ; SPMobageSocial.prototype.getPlayerInfo = function(a) { mobage.api.people.get({ userId: "@me", groupId: "@self", fields: ["id", "displayName", "thumbnailUrl"] }, function(b, c) { b ? (console.log("Failed requesting user info", b), a(connector.CODE_FAILED)) : (this.user = SPMobageSocial.formatUserData(c), a(connector.CODE_SUCCEED)) } .bind(this)) } ; SPMobageSocial.prototype._login = function(a, b) { var c = { state: this.clientData.state }; b && b.registration && (c.easyRegistration = !0, c.requestType = "window"); mobage.oauth.connect(c, function(d, e) { d ? (console.log("Authorization failed:", d), a()) : (connector.social.mobagePlatformLogin = !0, this.clientData.connected = !0, this.clientData.code = e.response.code, this.checkAccessToken(), this.getPlayerInfo(a)) } .bind(this)) } ; SPMobageSocial.prototype.periodicCheck = function() { if (connector.social.isConnected() && !this.checkInProcess) { this.checkInProcess = !0; try { mobage.oauth.getConnectedStatus({ state: this.clientData.state }, function(a, b) { this.checkInProcess = !1; b && (this.clientData.code = b.response.code, this.checkAccessToken()) } .bind(this)) } catch (a) { this.checkInProcess = !1, console.log("Get connect status error", a) } } } ; SPMobageSocial.prototype.isLoggedIn = function() { return !!this.user } ; SPMobageSocial.formatUserData = function(a) { return { id: a.id, name: a.displayName, avatar: SPMobageSocial.proxyAvatar(a.thumbnailUrl) } } ; SPMobageSocial.proxyAvatar = function(a) { var b = connector.config.deployment + "/proxy/sp"; a = a.match(/.*img_u(.*)/); return b + a[1] } ; SPMobageSocial.prototype.listFriendsByApp = function(a, b) { mobage.api.people.get({ userId: "@me", groupId: "@friends", fields: ["id", "displayName", "thumbnailUrl", "hasApp"] }, function(c, d) { c ? (console.log("Failed fetching friends", c), b(connector.CODE_FAILED)) : (c = d.entry, c = c.filter(function(e) { return e.hasApp === a }), b(connector.CODE_SUCCEED, c.map(SPMobageSocial.formatUserData))) }) } ; SPMobageSocial.prototype.invite = function(a, b) { mobage.ui.open("invitation", {}, function(c, d) { c ? b(connector.CODE_FAILED, c) : "mobage" === d.response.result.channel ? b(connector.CODE_SUCCEED) : b(connector.CODE_CANCELLED) }) } ; SPMobageSocial.prototype.request = function(a, b) { b(connector.CODE_SUCCEED) } ; SPMobageSocial.prototype.share = function(a, b) { b(connector.CODE_SUCCEED) } ; SPMobageSocial.prototype.sendActivity = function(a, b) { b(connector.CODE_FAILED) } ; SPMobageSocial.getClientId = function() { return connector.config.mbga.appId + "-4" } ; SPMobageSocial.getRedirectUrl = function() { return connector.config.deployment + "/publish/html5" + (connector.config.debugMode ? "-staging" : "") + "/index.html" } ; SPMobageSocial.CHECK_STATUS_INTERVAL = "10 minutes"; var XsollaSocial = function() { this.user = this.accessToken = void 0; Social.call(this, connector.XSOLLA) }; XsollaSocial.prototype = Object.create(Social.prototype); XsollaSocial.prototype.constructor = XsollaSocial; XsollaSocial.prototype._connect = function(a) { var b = document.createElement("div"); b.id = "xsollaLoginLayout"; b.style.width = "100%"; b.style.height = "100%"; b.style.left = "0px"; b.style.top = "0px"; b.style.position = "absolute"; b.style.backgroundColor = "#00000050"; b.style.zIndex = "1000000000"; b.style.visibility = "hidden"; document.body.appendChild(b); (this.accessToken = connector.dataLoader.load(SimpleDataLoader.TYPES.XSOLLA_ACCESS_TOKEN)) ? this.loadUser(function(c) { c === connector.CODE_SUCCEED ? a(connector.STATUS_CONNECTED) : (this.accessToken = void 0, connector.dataLoader.remove(SimpleDataLoader.TYPES.XSOLLA_ACCESS_TOKEN), a(connector.STATUS_DISCONNECTED)) } .bind(this)) : a(connector.STATUS_CONNECTED) } ; XsollaSocial.prototype.loadUser = function(a) { ConnectorRestClient.get("https://login.xsolla.com/api/users/me", {}, function(b) { this.user = b; a(connector.CODE_SUCCEED) } .bind(this), function() { a(connector.CODE_FAILED) }, { authorization: "Bearer " + this.accessToken }) } ; XsollaSocial.prototype._login = function(a) { var b = function() { window.removeEventListener("message", c, !1); document.getElementById("xsollaLoginLayout").style.visibility = "hidden"; clearInterval(l) }; var c = function(m) { m.origin === location.origin && (this.accessToken = m.data, connector.dataLoader.save(SimpleDataLoader.TYPES.XSOLLA_ACCESS_TOKEN, this.accessToken), b(), this.loadUser(a)) } .bind(this); var d = Math.max(800, .5 * screen.width) , e = Math.max(600, .6 * screen.height) , f = (screen.width - d) / 2 , g = (screen.height - e) / 2 , h = location.href; h = h.substr(0, h.lastIndexOf("/") + 1).replace("msstart/", "") + "xsolla-login.html"; var k = window.open(h, "popup", "toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no, width=" + d + ", height=" + e + ", top=" + g + ", left=" + f); if (k) { window.addEventListener("message", c, !1); document.getElementById("xsollaLoginLayout").style.visibility = "visible"; var l = setInterval(function() { k.closed && (b(), a()) }, 100) } else a() } ; XsollaSocial.prototype._getUserID = function() { return this.user ? this.user.id : void 0 } ; XsollaSocial.prototype.isLoggedIn = function() { return this.user } ; XsollaSocial.prototype.getAccessToken = function() { return "XS_" + (this.accessToken || 0) } ; XsollaSocial.prototype._aboutMe = function(a) { ConnectorRestClient.get("https://login.xsolla.com/api/users/me/social_providers", {}, function(b) { b && 0 < b.length ? (b = b[0], a(connector.CODE_SUCCEED, { id: connector.platform.getUserID(), name: b.full_name, firstName: b.nickname, avatar: b.picture })) : (console.log("Error: " + JSON.stringify(b)), a(connector.CODE_FAILED)) }, function() { console.log("Failed loading aboutMe"); a(connector.CODE_FAILED) }, { authorization: "Bearer " + this.accessToken }) } ; var FacebookCanvasSocial = function() { BaseFbSocial.call(this, connector.FACEBOOK, { sdk: SdkManager.SDK_FACEBOOK_CANVAS }) }; FacebookCanvasSocial.prototype = Object.create(BaseFbSocial.prototype); FacebookCanvasSocial.prototype.constructor = FacebookCanvasSocial; FacebookCanvasSocial.prototype.isSupportsNativeShare = function() { return !0 } ; FacebookCanvasSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; FacebookCanvasSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; FacebookCanvasSocial.prototype.isLoggedIn = function() { return connector.social.isConnected() && plugin.FacebookAgent.getInstance().isLoggedIn() } ; FacebookCanvasSocial.prototype._getUserID = function() { if (connector.social.isConnected()) return plugin.FacebookAgent.getInstance().getUserID() } ; FacebookCanvasSocial.prototype.getAccessToken = function() { if (connector.social.isConnected()) return plugin.FacebookAgent.getInstance().getAccessToken() } ; FacebookCanvasSocial.prototype._login = function(a) { plugin.FacebookAgent.getInstance().login(FacebookCanvasSocial.PERMISSIONS, function() { a() }) } ; FacebookCanvasSocial.prototype.invite = function(a, b) { this.request(a, b) } ; FacebookCanvasSocial.prototype.request = function(a, b) { connector.social.isConnected() ? (delete a.element, "object" === typeof a.to && (a.to = a.to.join(",")), plugin.FacebookAgent.getInstance().appRequest({ to: a.to, message: a.text, title: a.title, picture: a.image }, b)) : b && b(connector.CODE_FAILED) } ; FacebookCanvasSocial.prototype.share = function(a, b) { var c = this.getShareDialogLink(a); console.log("share link", c); a = { dialog: "feedDialog", link: c, caption: a.text }; plugin.FacebookAgent.getInstance().dialog(a, b) } ; FacebookCanvasSocial.prototype.api = function(a, b, c, d) { if (connector.social.isConnected()) if (c = c || {}, "function" === typeof c && (d = c, c = {}), this.isLoggedIn()) { void 0 === b ? (b = plugin.FacebookAgent.HttpMethod.GET, d = function() {} ) : "function" === typeof b && (d = b, b = plugin.FacebookAgent.HttpMethod.GET); try { plugin.FacebookAgent.getInstance().api(a, b, c, d) } catch (e) { console.log(e), d && d(connector.CODE_CANCELLED) } } else console.log("Not logged in!"), d && d(connector.CODE_CANCELLED); else d && d(connector.CODE_FAILED) } ; FacebookCanvasSocial.PERMISSIONS = "public_profile"; var MSStartSocial = function() { Social.call(this, connector.MSSTART, { sdk: SdkManager.SDK_MSSTART }) }; MSStartSocial.prototype = Object.create(Social.prototype); MSStartSocial.prototype.constructor = MSStartSocial; MSStartSocial.prototype.isSupportsNativeShare = function() { return !0 } ; MSStartSocial.prototype._connect = function(a) { $msstart.getSignedInUserAsync().then(function(b) { this.playerId = b.publisherPlayerId || b.playerId; console.log("MSStart getSignedInUserAsync", b); a(connector.STATUS_CONNECTED) } .bind(this)).catch(function(b) { console.log("MSStart getSignedInUserAsync error", b); a(connector.STATUS_CONNECTED) }) } ; MSStartSocial.prototype.isLoggedIn = function() { return !!this.playerId } ; MSStartSocial.prototype._getUserID = function() { return this.playerId } ; MSStartSocial.prototype._login = function(a) { $msstart.signInAsync().then(function(b) { this.playerId = b.publisherPlayerId || b.playerId; console.log("MSStart login", b); a() } .bind(this)).catch(function(b) { console.log("MSStart login error", b); a() }) } ; MSStartSocial.prototype.share = function(a, b) { console.log("MS Start share", a); $msstart.shareAsync({ title: a.title, text: a.text, image: a.image }).then(function() { console.log("MSStart share: success!"); b(connector.CODE_SUCCEED) }).catch(function(c) { console.log("MSStart share error", c); b(connector.CODE_FAILED) }) } ; MSStartSocial.prototype._aboutMe = function(a) { a(connector.CODE_SUCCEED, { name: "MSN Player " + (connector.platform.getUserID() + "").substring(0, 18) }) } ; MSStartSocial.prototype.getAccessToken = function() { return "msstart" } ; var PlingaSocial = function() { Social.call(this, connector.PLINGA, { sdk: SdkManager.SDK_PLINGA }) }; PlingaSocial.prototype = Object.create(Social.prototype); PlingaSocial.prototype.constructor = PlingaSocial; PlingaSocial.prototype.isSupportsNativeShare = function() { return !0 } ; PlingaSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; PlingaSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; PlingaSocial.prototype._login = function() { plingaRpc.invite() } ; PlingaSocial.prototype._aboutUser = function(a, b) { var c = !Array.isArray(a); plingaRpc.getUsers(c ? [a] : a, function(d) { d = d.map(PlingaSocial.formatUserData); b(connector.CODE_SUCCEED, c ? d[0] : d) }) } ; PlingaSocial.prototype._aboutMe = function(a) { var b = plingaRpc.getOwner(); a(connector.CODE_SUCCEED, PlingaSocial.formatUserData(b)) } ; PlingaSocial.prototype._listFriends = function(a) { var b = plingaRpc.getFriends().map(PlingaSocial.formatUserData); a(connector.CODE_SUCCEED, b) } ; PlingaSocial.formatUserData = function(a) { return { id: a.uid, name: a.firstname + " " + a.lastname, firstName: a.firstname, lastName: a.lastname, avatar: a.thumbnailurl } } ; PlingaSocial.prototype.invite = function(a, b) { plingaRpc.invite(a.text); b(connector.CODE_SUCCEED) } ; PlingaSocial.prototype.share = function(a, b) { plingaRpc.post({ target: connector.platform.getUserID(), title: a.title, body: a.text, linktext: a.linktext, pic: a.image }, function(c) { console.log("post callback", c); !1 === c.globalError_ ? b(connector.CODE_SUCCEED) : b(connector.CODE_FAILED) }); b(connector.CODE_SUCCEED) } ; PlingaSocial.prototype.sendMessage = function(a, b) { console.log(a); plingaRpc.sendMessage({ target: "userid of the receiver", title: "text, which is shown as title", body: "text of the post", pic: "link to a picture, which is shown in the post", linktext: "text to display for the link" }, b) } ; PlingaSocial.prototype.getAccessToken = function() { var a = connector.utils.getRequestParameters(); return "PLINGA_" + a.sessionid + "_" + a.sessionkey } ; PlingaSocial.prototype.isLoggedIn = function() { return connector.social.isConnected() && !0 !== plingaRpc.getOwner().guest } ; PlingaSocial.prototype._getUserID = function() { if (connector.social.isConnected()) return plingaRpc.getOwner().uid } ; var KongregateSocial = function() { Social.call(this, connector.KONGREGATE, { sdk: SdkManager.SDK_KONGREGATE }) }; KongregateSocial.prototype = Object.create(Social.prototype); KongregateSocial.prototype.constructor = KongregateSocial; KongregateSocial.prototype.isSupportsNativeShare = function() { return !0 } ; KongregateSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; KongregateSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; KongregateSocial.prototype._login = function() { kongregate.services.showRegistrationBox() } ; KongregateSocial.prototype._aboutMe = function(a) { a(connector.CODE_SUCCEED, { id: connector.platform.getUserID(), name: kongregate.services.getUsername() }) } ; KongregateSocial.prototype.invite = function(a, b) { kongregate.services.showInvitationBox({ content: a.text, filter: "not_played" }); b(connector.CODE_SUCCEED) } ; KongregateSocial.prototype.share = function(a, b) { kongregate.services.showFeedPostBox({ content: a.text, image_uri: a.image }, function(c) { console.log("post callback", c); c.success ? b(connector.CODE_SUCCEED) : b(connector.CODE_FAILED) }) } ; KongregateSocial.prototype.sendMessage = function(a, b) { console.log(a, b) } ; KongregateSocial.prototype.markAchievement = function(a) { void 0 !== a.kongId && kongregate.stats.submit(a.kongId, 1) } ; KongregateSocial.prototype.getAccessToken = function() { if (connector.social.isConnected()) return "KONGREGATE_" + kongregate.services.getGameAuthToken() } ; KongregateSocial.prototype.isLoggedIn = function() { return connector.social.isConnected() && !0 !== kongregate.services.isGuest() } ; KongregateSocial.prototype._getUserID = function() { if (connector.social.isConnected()) return "" + kongregate.services.getUserId() } ; var CrazySocial = function() { Social.call(this, connector.CRAZY, { sdk: SdkManager.SDK_CRAZY }) }; CrazySocial.prototype = Object.create(Social.prototype); CrazySocial.prototype.constructor = CrazySocial; CrazySocial.prototype._connect = function(a) { this.hasAuthListener || (CrazyGames.SDK.user.addAuthListener(function() { this.isConnected() && !this.loginRunning && this.loadUser(function() { if (this.isLoggedIn()) this.onLogin() } .bind(this)) } .bind(this)), this.hasAuthListener = !0); this.loadUser(function() { a(connector.STATUS_CONNECTED) }) } ; CrazySocial.prototype._login = function(a) { this.loginRunning = !0; var b = function() { this.loginRunning = !1; a() } .bind(this); CrazyGames.SDK.user.showAuthPrompt(function(c) { c ? (console.log("CrazySocial login error:", c), b()) : this.loadUser(b) } .bind(this)) } ; CrazySocial.prototype.loadUser = function(a) { this.isLoggedIn() ? a() : CrazyGames.SDK.user.getUserToken(function(b, c) { b ? (console.log("CrazyGames getUserToken error:", b), a(b)) : ConnectorRestClient.get("/crazy/decodetoken/" + c, {}, function(d) { this.accessToken = c; this.user = CrazySocial.formatUserData(d); a() } .bind(this), function(d) { a(d) }) } .bind(this)) } ; CrazySocial.formatUserData = function(a) { if (a.userId) return { id: "" + a.userId, name: a.username, firstName: a.username, avatar: a.profilePictureUrl } } ; CrazySocial.prototype._aboutMe = function(a) { this.user ? a(connector.CODE_SUCCEED, this.user) : a(connector.CODE_FAILED) } ; CrazySocial.prototype.markAchievement = function() { CrazyGames.SDK.game.happytime() } ; CrazySocial.prototype.getAccessToken = function() { return "CRAZY_" + this.accessToken } ; CrazySocial.prototype.isLoggedIn = function() { return !!this.user } ; CrazySocial.prototype._getUserID = function() { return this.user && this.user.id } ; var TonSocial = function() { Social.call(this, connector.TON) }; TonSocial.prototype = Object.create(Social.prototype); TonSocial.prototype.constructor = TonSocial; TonSocial.prototype._connect = function(a) { connector.platform.callNative("getUser", {}, function(b, c) { this.id = "" + c.value.id; a(b === connector.CODE_SUCCEED ? connector.STATUS_CONNECTED : connector.STATUS_DISCONNECTED) } .bind(this)) } ; TonSocial.prototype._getUserID = function() { return this.id } ; TonSocial.prototype._login = function(a) { a() } ; TonSocial.prototype.isLoggedIn = function() { return !0 } ; TonSocial.prototype.getAccessToken = function() { return "ton" } ; var FotoStranaSocial = function() { Social.call(this, connector.FOTOSTRANA, { sdk: SdkManager.SDK_FOTOSTRANA }) }; FotoStranaSocial.prototype = Object.create(Social.prototype); FotoStranaSocial.prototype.constructor = FotoStranaSocial; FotoStranaSocial.prototype.isSupportsNativeShare = function() { return !0 } ; FotoStranaSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; FotoStranaSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; FotoStranaSocial.prototype.isLoggedIn = function() { return !0 } ; FotoStranaSocial.prototype.fromSocialUserId = function(a) { return "FS_" + a } ; FotoStranaSocial.prototype.toSocialUserId = function(a) { return a.substr(3) } ; FotoStranaSocial.prototype._getUserID = function() { return this.fromSocialUserId(connector.utils.getRequestParameters().viewerId) } ; FotoStranaSocial.prototype.getAccessToken = function() { return "FS_" + connector.utils.getRequestParameters().authKey } ; FotoStranaSocial.prototype._login = function(a) { a() } ; FotoStranaSocial.prototype.invite = function(a, b) { FSClient.event("invite", function(c) { b(c.send ? connector.CODE_SUCCEED : connector.CODE_CANCELLED) }) } ; FotoStranaSocial.prototype.request = function(a, b) { "object" !== typeof a.to && (a.to = [a.to]); var c = []; a.to.forEach(function(d) { c.push(this.toSocialUserId(d)) } .bind(this)); FSClient.event("sendMessageAndInvite", function(d) { b(d.messSent || d.invSent ? connector.CODE_SUCCEED : connector.CODE_CANCELLED) }, { message: a.text, customIds: c.join(",") }) } ; FotoStranaSocial.prototype.share = function(a, b) { FSClient.event("postUserEventOnWall", function(c) { b("success" === c.result ? connector.CODE_SUCCEED : connector.CODE_CANCELLED) }, { title: a.title, text: a.text, imgUrl: a.image }) } ; FotoStranaSocial.prototype.loadUsersData = function(a, b) { a && a.length ? FSClient.api("User.getProfiles", { userIds: a.join(","), fields: "user_name, user_lastname, photo_small" }, function(c) { var d = []; if (c.response) { for (var e in c.response) d.push(this.formatUserData(c.response[e])); b(connector.CODE_SUCCEED, d) } else b(connector.CODE_FAILED, d) } .bind(this)) : b(connector.CODE_CANCELLED, []) } ; FotoStranaSocial.prototype._listFriends = function(a) { FSClient.api("User.getAppFriends", { appId: connector.config.fotostrana.appId, limit: 500 }, function(b) { this.loadUsersData(b.response, a) } .bind(this)) } ; FotoStranaSocial.prototype._listInvitableFriends = function(a) { FSClient.api("User.getFriends", { limit: 200 }, function(b) { if (b.response && b.response.length) { var c = b.response; FSClient.api("User.getAppFriends", { appId: connector.config.fotostrana.appId, limit: 500 }, function(d) { d.response && d.response.length && (c = connector.utils.substract(c, d.response)); this.loadUsersData(c, a) } .bind(this)) } else a(connector.CODE_FAILED) } .bind(this)) } ; FotoStranaSocial.prototype.formatUserData = function(a) { return { id: this.fromSocialUserId(a.user_id), name: a.user_name + " " + a.user_lastname, firstName: a.user_name, lastName: a.user_lastname, avatar: a.photo_small } } ; FotoStranaSocial.prototype._aboutMe = function(a) { this.loadUsersData([this.toSocialUserId(connector.platform.getUserID())], function(b, c) { b === connector.CODE_SUCCEED && c.length ? a(connector.CODE_SUCCEED, c[0]) : a(connector.CODE_FAILED) }) } ; var DraugiemSocial = function() { Social.call(this, connector.DRAUGIEM, { sdk: SdkManager.SDK_DRAUGIEM }) }; DraugiemSocial.prototype = Object.create(Social.prototype); DraugiemSocial.prototype.constructor = DraugiemSocial; DraugiemSocial.prototype.isSupportsNativeShare = function() { return !0 } ; DraugiemSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; DraugiemSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; DraugiemSocial.prototype._connect = function(a) { var b = function(e) { this.accessToken = e; connector.utils.setUrlHash({ saved_token: e }); connector.platform.callNative("userdata", function(f, g) { this.user = DraugiemSocial.formatUserData(Object.values(g.users)[0]); a(f === connector.CODE_SUCCEED ? connector.STATUS_CONNECTED : connector.STATUS_DISCONNECTED) } .bind(this)) } .bind(this) , c = connector.utils.getRequestParameters().dr_auth_code , d = connector.dataLoader.load(SimpleDataLoader.TYPES.DRAUGIEM_AUTH_DATA); d && d.code === c ? b(d.token) : connector.platform.callNative("authorize", { code: c }, function(e, f) { if (f && !f.error && f.apikey) this.accessToken = f.apikey, this.user = DraugiemSocial.formatUserData(f.users[f.uid]), connector.dataLoader.save(SimpleDataLoader.TYPES.DRAUGIEM_AUTH_DATA, { code: c, token: this.accessToken }), connector.utils.setUrlHash({ saved_token: this.accessToken }), a(connector.STATUS_CONNECTED); else { if (f && f.error && 106 === f.error.code) { var g = connector.utils.getRequestParameters(window.location.hash).saved_token; if (g) { b(g); return } } g = JSON.stringify({ arguments: arguments, auth_code: c }); this.bus.trigger("stream:error", { group: "DRAUGIEM_AUTH_ERROR", message: "draugiem authorize empty result " + g }); this.user = DraugiemSocial.formatUserData({ uid: "1" }); a(connector.STATUS_DISCONNECTED) } } .bind(this)) } ; DraugiemSocial.prototype.isLoggedIn = function() { return !0 } ; DraugiemSocial.prototype._getUserID = function() { return this.user && this.user.id } ; DraugiemSocial.prototype.getAccessToken = function() { return "DRG_" + this.accessToken } ; DraugiemSocial.prototype._login = function(a) { a() } ; DraugiemSocial.prototype.sendActivity = function(a, b) { connector.platform.callNative("add_activity", { prefix: a.title, text: a.body, link: a.link }, function(c, d) { d && "OK" === d.status ? b(connector.CODE_SUCCEED) : b(connector.CODE_FAILED) }) } ; DraugiemSocial.prototype.invite = function(a, b) { draugiemSendInvite(a.text, "", function(c) { c ? b(connector.CODE_SUCCEED) : b(connector.CODE_CANCELLED) }) } ; DraugiemSocial.prototype.requestToOne = function(a, b, c) { var d = b.text + "\n" + connector.platform.getGameUrl(); draugiemSendMessage(a, b.title, d, function(e) { e ? c(connector.CODE_SUCCEED) : c(connector.CODE_FAILED) }) } ; DraugiemSocial.prototype.request = function(a, b) { var c = a.to; Array.isArray(c) || (c = [c]); var d = [] , e = function(f) { f === c.length ? b(0 < d.length ? connector.CODE_SUCCEED : connector.CODE_CANCELLED, d) : this.requestToOne(c[f], a, function(g) { g === connector.CODE_SUCCEED && d.push(c[f]); setTimeout(function() { e(f + 1) }, 500) }) } .bind(this); e(0) } ; DraugiemSocial.prototype.share = function(a, b) { draugiemSay(a.title, connector.platform.getGameUrl(), a.subTitle, a.text, function(c) { c ? b(connector.CODE_SUCCEED) : b(connector.CODE_FAILED) }) } ; DraugiemSocial.prototype.listFriendsByApp = function() {} ; DraugiemSocial.prototype._listFriends = function(a) { connector.platform.callNative("app_friends", function(b, c) { b === connector.CODE_SUCCEED ? (b = [], 0 < c.total && (b = Object.values(c.users).map(DraugiemSocial.formatUserData)), a(connector.CODE_SUCCEED, b)) : a(connector.CODE_FAILED) }) } ; DraugiemSocial.formatUserData = function(a) { return { id: "" + a.uid, name: a.surname + " " + a.name, firstName: a.name, lastName: a.surname, avatar: a.img } } ; DraugiemSocial.prototype._aboutMe = function(a) { a(connector.CODE_SUCCEED, this.user) } ; var YandexSocial = function() { Social.call(this, connector.YANDEX, { sdk: SdkManager.SDK_YANDEX }) }; YandexSocial.prototype = Object.create(Social.prototype); YandexSocial.prototype.constructor = YandexSocial; YandexSocial.prototype._connect = function(a) { this.initPlayer(function(b) { a(b === connector.CODE_SUCCEED ? connector.STATUS_CONNECTED : connector.STATUS_DISCONNECTED) }) } ; YandexSocial.prototype.initPlayer = function(a) { ysdk.getPlayer({ signed: !0 }).then(function(b) { this.playerMode = b.getMode(); this.payingStatus = b.getPayingStatus(); this.accessToken = b.signature; "lite" === this.playerMode ? delete this.user : (this.user = YandexSocial.formatUserData(b), ysdk.notifications.allow()); a(connector.CODE_SUCCEED) } .bind(this)).catch(function() { a(connector.CODE_FAILED) }) } ; YandexSocial.prototype._login = function(a) { ysdk.auth.openAuthDialog().then(function() { this.initPlayer(a) } .bind(this)).catch(a) } ; YandexSocial.prototype.isLoggedIn = function() { return void 0 !== this.user } ; YandexSocial.prototype._getUserID = function() { return this.user ? this.user.id : void 0 } ; YandexSocial.prototype.getAccessToken = function() { return "YA_" + (this.accessToken || 0) } ; YandexSocial.prototype._aboutMe = function(a) { this.user ? a(connector.CODE_SUCCEED, this.user) : a(connector.CODE_FAILED) } ; YandexSocial.formatUserData = function(a) { return { id: a.getUniqueID(), name: a.getName(), avatar: a.getPhoto("small") } } ; var DiscordSocial = function() { Social.call(this, connector.DISCORD, { sdk: SdkManager.SDK_DISCORD }) }; DiscordSocial.prototype = Object.create(Social.prototype); DiscordSocial.prototype.constructor = DiscordSocial; DiscordSocial.prototype._connect = function(a) { this.authorize(function() { a(connector.STATUS_CONNECTED) }) } ; DiscordSocial.prototype._login = function(a) { this.authorize(a) } ; DiscordSocial.prototype.authorize = function(a) { discordSdk.commands.authorize({ client_id: connector.config.discord.appId, response_type: "code", state: "", prompt: "none", scope: ["identify", "guilds", "applications.commands"] }).then(function(b) { ConnectorRestClient.post("/discord/token", { code: b.code }, function(c) { discordSdk.commands.authenticate({ access_token: c.access_token }).then(function(d) { d && d.user && d.user.id ? (this.accessToken = c.access_token, this.user = DiscordSocial.formatUserData(d.user)) : console.log("[connector] discord authentication rejected"); a() } .bind(this)).catch(function(d) { console.log("[connector] discord authentication failed", d); a() }) } .bind(this), function(c) { console.log("[connector] can't load discord access token", c.status, c.errorMessage); a() }) } .bind(this)).catch(function(b) { console.log("[connector] discord authorization failed", b); a() }) } ; DiscordSocial.prototype.getAccessToken = function() { return "DISCORD_" + this.accessToken } ; DiscordSocial.prototype.isLoggedIn = function() { return !!this.user && !!this.accessToken } ; DiscordSocial.prototype._getUserID = function() { return this.user && this.user.id } ; DiscordSocial.prototype._aboutMe = function(a) { this.user ? a(connector.CODE_SUCCEED, this.user) : a(connector.CODE_FAILED) } ; DiscordSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; DiscordSocial.prototype.invite = function(a, b) { discordSdk.commands.openInviteDialog().then(function() { b(connector.CODE_SUCCEED) }).catch(function() { b(connector.CODE_FAILED) }) } ; DiscordSocial.formatUserData = function(a) { var b = "" + a.id , c = a.avatar , d = a.global_name; d || (d = a.username + "#" + a.discriminator); c = c ? "https://cdn.discordapp.com/avatars/" + b + "/" + c + ".png?size=256" : "https://cdn.discordapp.com/embed/avatars/" + parseInt(b.slice(-7)) % 6 + ".png"; return { id: b, name: d, avatar: c } } ; var TestSocial = function() { Social.call(this, connector.TEST) }; TestSocial.prototype = Object.create(Social.prototype); TestSocial.prototype.constructor = TestSocial; TestSocial.prototype.isSupportsNativeShare = function() { return !0 } ; TestSocial.prototype.isSupportsNativeInvite = function() { return !0 } ; TestSocial.prototype.isSupportsNativeRequest = function() { return !0 } ; TestSocial.prototype.updateSession = function(a) { var b = "undefined" !== typeof DateShift ? new DateShift.Date : new Date; b.setMonth(b.getMonth() + 3); this.id = a; this.token = "123"; this.expires = b.getTime(); document.cookie = "tsid=" + this.id + "; path=/; expires=" + b.toUTCString() } ; TestSocial.prototype.removeSession = function() { this.expires = this.token = this.id = void 0; document.cookie = "tsid=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;" } ; TestSocial.prototype.loadSession = function() { var a = document.cookie && document.cookie.match(/tsid=([^;]+)/); a && this.updateSession(a[1]) } ; TestSocial.prototype._connect = function(a) { this.token = this.expires = this.id = void 0; setTimeout(function() { this.loadSession(); a(connector.STATUS_CONNECTED) } .bind(this), 1E3) } ; TestSocial.prototype._loadTestImage = function(a, b) { var c = new Image; document.body.appendChild(c); c.style.zIndex = "10"; c.style.margin = "auto auto"; var d = function() { document.body.removeChild(c) }; c.onload = function() { setTimeout(function() { b(d) }, 100) } ; c.src = a } ; TestSocial.prototype.share = function(a, b) { this._loadTestImage(a.image, function(c) { confirm("Do you to post " + JSON.stringify(a) + "?") ? (c(), b(connector.CODE_SUCCEED)) : (c(), b(connector.CODE_FAILED)) }) } ; TestSocial.prototype.isExpired = function() { var a = "undefined" !== typeof DateShift ? new DateShift.Date : Date.now(); return !this.expires || this.expires < a } ; TestSocial.prototype.isLoggedIn = function() { return !!this.id } ; TestSocial.prototype._getUserID = function() { return this.id } ; TestSocial.prototype.getAccessToken = function() { return this.isExpired() ? void 0 : this.token } ; TestSocial.prototype._login = function(a) { new FakeLoginWindow(TestSocial.USERS,function(b) { b ? this.updateSession(b) : this.removeSession(); a() } .bind(this)) } ; TestSocial.prototype.logout = function() { this.removeSession() } ; TestSocial.prototype.invite = function(a, b) { this._loadTestImage(a.image, function(c) { confirm("Invite " + JSON.stringify(a)) ? (c(), b(connector.CODE_SUCCEED)) : (c(), b(connector.CODE_FAILED)) }) } ; TestSocial.prototype.request = function(a, b) { delete a.element; b = b || function() {} ; this._loadTestImage(a.image, function(c) { confirm("Do you to post " + JSON.stringify(a) + "?") ? (c(), b(connector.CODE_SUCCEED)) : (c(), b(connector.CODE_FAILED)) }) } ; TestSocial.prototype._listFriends = function(a) { setTimeout(function() { a(connector.CODE_SUCCEED, Object.values(TestSocial.USERS)) }, 500) } ; TestSocial.prototype._listInvitableFriends = function(a) { setTimeout(function() { a(connector.CODE_SUCCEED, Object.values(TestSocial.INVITABLE_USERS)) }, 500) } ; TestSocial.prototype._aboutMe = function(a) { setTimeout(function() { a(connector.CODE_SUCCEED, { name: "FakeFB User", avatar: "https://graph.facebook.com/100001828353521/picture?height=200&width=200", id: connector.platform.getUserID() }) }, 500) } ; TestSocial.isAppropriate = function() { return connector.platform.oneOf(connector.TEST) } ; TestSocial.USERS = { alpha: { name: "Alpha", avatar: "https://graph.facebook.com/41803173/picture?height=200&width=200" }, beta: { name: "Beta", avatar: "https://graph.facebook.com/692982514/picture?height=200&width=200" }, gamma: { name: "Gamma", avatar: "https://graph.facebook.com/100028444590540/picture?height=200&width=200" } }; Object.keys(TestSocial.USERS).forEach(function(a) { TestSocial.USERS[a].id = a }); TestSocial.INVITABLE_USERS = { invitable_1: { name: "Invitable1", avatar: "https://graph.facebook.com/100001008129789/picture?height=200&width=200" }, invitable_2: { name: "Invitable2", avatar: "https://graph.facebook.com/100011706990070/picture?height=200&width=200" }, invitable_3: { name: "Invitable3", avatar: "https://graph.facebook.com/100001575006940/picture?height=200&width=200" }, invitable_4: { name: "Invitable4", avatar: "https://graph.facebook.com/100000318466656/picture?height=200&width=200" } }; Object.keys(TestSocial.INVITABLE_USERS).forEach(function(a) { TestSocial.INVITABLE_USERS[a].id = a }); var Draugiem = function() { Platform.call(this, connector.DRAUGIEM, { sdk: SdkManager.SDK_DRAUGIEM }) }; Draugiem.prototype = Object.create(Platform.prototype); Draugiem.prototype.constructor = Draugiem; Draugiem.prototype.getLocalStoragePrefix = function() { return "_draugiem" } ; Draugiem.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_LATVIAN, connector.LANGUAGE_RUSSIAN] } ; Draugiem.prototype.callNative = function(a, b, c) { c || "function" !== typeof b || (c = b, b = {}); b = Object.assign({ action: a, apikey: connector.social.getPlugin() && connector.social.getPlugin().accessToken }, b); console.log("[connector] callNative", a); ConnectorRestClient.post("/draugiem", b, function(d) { d.error ? (console.log("[connector] callNative error", a, d), c(connector.CODE_FAILED, d)) : (console.log("[connector] callNative success", a, d), c(connector.CODE_SUCCEED, d)) }) } ; var FotoStrana = function() { Platform.call(this, connector.FOTOSTRANA, { sdk: SdkManager.SDK_FOTOSTRANA }) }; FotoStrana.prototype = Object.create(Platform.prototype); FotoStrana.prototype.constructor = FotoStrana; FotoStrana.prototype.getLocalStoragePrefix = function() { return "_FS" } ; FotoStrana.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_RUSSIAN] } ; var Mobage = function() { Platform.call(this, connector.MOBAGE) }; Mobage.prototype = Object.create(Platform.prototype); Mobage.prototype.constructor = Mobage; Mobage.prototype.getLocalStoragePrefix = function() { return "_mbga" } ; Mobage.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_JAPANESE] } ; var MyMailRu = function() { Platform.call(this, connector.MM, { sdk: SdkManager.SDK_MYMAILRU }); "app_mobile" === connector.utils.getRequestParameters().view && (connector.info.isMobile = !0, connector.info.isInApp = !0) }; MyMailRu.prototype = Object.create(Platform.prototype); MyMailRu.prototype.constructor = MyMailRu; MyMailRu.prototype._connect = function(a) { this.withHeader() ? (window.outerHeight && mailru.app.utils.setHeight(window.outerHeight - 250), setTimeout(function() { a(connector.STATUS_CONNECTED) }, 300)) : a(connector.STATUS_CONNECTED) } ; MyMailRu.prototype.getLocalStoragePrefix = function() { return "_MM" } ; MyMailRu.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_RUSSIAN] } ; MyMailRu.prototype.parsePayload = function(a) { connector.platform.whenConnected(function() { mailru.events.listen(mailru.app.events.readHash, function(b) { b = b || {}; b = Object.assign(connector.utils.getRequestParameters(), b); if (document.referrer) { var c = new URL(document.referrer); b = Object.assign(connector.utils.getRequestParameters(c.search), b) } a(b) }); mailru.app.utils.hash.read() }) } ; MyMailRu.prototype.withHeader = function() { return !connector.info.isMobile } ; var OKPlatform = function() { this.listeners = {}; Platform.call(this, connector.OK, { sdk: SdkManager.SDK_OK }); var a = connector.utils.getRequestParameters(); ["androidweb", "iosweb", "mobweb", "android", "ios"].includes(a.mob_platform) && (connector.info.isMobile = !0); ["android", "ios"].includes(a.mob_platform) && (connector.info.isInApp = !0); "android" === a.mob_platform && (connector.info.os = connector.OS_ANDROID); "ios" === a.mob_platform && (connector.info.os = connector.OS_IOS) }; OKPlatform.prototype = Object.create(Platform.prototype); OKPlatform.prototype.constructor = OKPlatform; OKPlatform.prototype.getLocalStoragePrefix = function() { return "_OK" } ; OKPlatform.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_RUSSIAN] } ; OKPlatform.prototype._connect = function(a) { this.listeners = {}; connector.info.isInApp && connector.info.os === connector.OS_ANDROID && this.initPushNotifications(); a(connector.STATUS_CONNECTED) } ; OKPlatform.prototype._loadDataKeys = function() { return new Promise(function(a, b) { FAPI.Client.call({ method: "storage.getKeys", scope: "CUSTOM", count: 1E3 }, function(c, d, e) { "ok" === c ? a(d.keys) : b(e) }) } ) } ; OKPlatform.prototype.loadData = function() { return this._loadDataKeys().then(function(a) { return new Promise(function(b, c) { 0 === a.length ? b({}) : FAPI.Client.call({ method: "storage.get", scope: "CUSTOM", keys: a }, function(d, e, f) { if ("ok" === d) { d = {}; for (var g in e.data) d[g] = JSON.parse(e.data[g]); b(d) } else c(f) }) } ) }) } ; OKPlatform.prototype.setData = function(a, b) { return new Promise(function(c, d) { FAPI.Client.call({ method: "storage.set", key: a, value: JSON.stringify(b) }, function(e, f, g) { "ok" === e ? c(!0) : d(g) }) } ) } ; OKPlatform.prototype.parsePayload = function(a) { var b = connector.utils.getRequestParameters(); if (b.custom_args) { var c = ""; try { c = decodeURIComponent(b.custom_args), Object.assign(b, connector.utils.getRequestParameters("?" + c)) } catch (d) { this.bus.trigger("stream:error", "calcChannel decodeURIComponent error, params.custom_args - " + b.custom_args) } } a(b) } ; OKPlatform.prototype.parseOtherWays = function(a) { this.parsePayload(function(b) { b = "rb_17 promo_shop recommended_apps game_campaign_portlet game_campaign vitrine_video eventcard eventpush".split(" ").includes(b.refplace) ? b.refplace : void 0; a(b) }) } ; OKPlatform.prototype.onSdkEvent = function(a, b, c) { if (this.listeners[a]) { var d = this.listeners[a]; this.listeners[a] = void 0; d.call(this, b, c) } } ; OKPlatform.prototype.openUrl = function(a) { var b = document.createElement("a"); b.setAttribute("target", "_blank"); b.setAttribute("href", a); b.click() } ; OKPlatform.prototype.initPushNotifications = function() { this.listeners.getPushNotificationsStatus = function(a, b) { "ok" === a && (b = JSON.parse(b), "true" === b.isGlobalEnabled && "true" === b.isSubscriptionEnabled ? this.bus.trigger("pushPermission", !0) : FAPI.UI.suggestToEnablePushNotifications()) } .bind(this); this.listeners.suggestToEnablePushNotifications = function(a) { this.bus.trigger("pushPermission", "ok" === a) } .bind(this); FAPI.UI.getPushNotificationsStatus() } ; OKPlatform.prototype._canCreateShortcut = function() { return connector.info.isInApp && connector.info.os === connector.OS_ANDROID && !connector.dataLoader.load(SimpleDataLoader.TYPES.SHORTCUT_CREATED) } ; OKPlatform.prototype.createShortcut = function(a) { this.listeners.requestDesktopIcon = connector.utils.once(function(b) { b = "ok" === b ? connector.CODE_SUCCEED : connector.CODE_FAILED; a && a(b); b === connector.CODE_SUCCEED && connector.dataLoader.save(SimpleDataLoader.TYPES.SHORTCUT_CREATED, 1) }); FAPI.invokeUIMethod("requestDesktopIcon") } ; OKPlatform.prototype.canReview = function() { return !0 } ; OKPlatform.prototype._requestReview = function(a) { this.listeners.showRatingDialog = connector.utils.once(function(b, c) { console.log("showRatingDialog", b, c); a("ok" === b ? connector.CODE_SUCCEED : connector.CODE_FAILED) }); FAPI.UI.showRatingDialog() } ; var MSStart = function() { Platform.call(this, connector.MSSTART, { sdk: SdkManager.SDK_MSSTART }); this.needsCountry = !0 }; MSStart.prototype = Object.create(Platform.prototype); MSStart.prototype.constructor = MSStart; MSStart.prototype.getLocalStoragePrefix = function() { return "_msstart" } ; MSStart.prototype.parsePayload = function(a) { connector.platform.whenConnected(function() { a({ channel: ($msstart.switchGamePayload || {}).channel }) }) } ; MSStart.prototype.switchGame = function(a, b, c) { $msstart.switchGameAsync({ id: a, payloadData: b }).then(function() {}).catch(function(d) { c("SWITCH_GAME_DISMISSED" === d.code ? ERRORS.SWITCH_GAME.CANCEL : ERRORS.SWITCH_GAME.UNKNOWN) }) } ; var PWA = function() { Platform.call(this, connector.PWA) }; PWA.prototype = Object.create(Platform.prototype); PWA.prototype.constructor = PWA; PWA.prototype.getLocalStoragePrefix = function() { return "_pwa" } ; var Plinga = function() { Platform.call(this, connector.PLINGA, { sdk: SdkManager.SDK_PLINGA }) }; Plinga.prototype = Object.create(Platform.prototype); Plinga.prototype.constructor = Plinga; Plinga.prototype._connect = function(a) { plingaRpc_pauseGame = this.pause.bind(this); plingaRpc_resumeGame = this.resume.bind(this); plingaRpc.setAllowFullscreen(); a(connector.STATUS_CONNECTED) } ; Plinga.prototype.getLocalStoragePrefix = function() { return "_plinga" } ; var Ton = function() { Platform.call(this, connector.TON); this.initCallback = void 0; window.addEventListener("message", function(a) { if (a = (a = a.data) && a.playdeck) "play" === a.method ? this.initCallback && (this.initCallback(connector.STATUS_CONNECTED), this.initCallback = void 0) : this.callCallback(a.method, 0, a) } .bind(this)) }; Ton.prototype = Object.create(Platform.prototype); Ton.prototype.constructor = Ton; Ton.prototype.reportLoadingProgress = function(a) { this.callNative("loading", { value: a }) } ; Ton.prototype._connect = function(a) { this.initCallback = a } ; Ton.prototype._callNative = function(a, b) { a = Object.assign({ method: a }, b); window.parent[Ton.POST_MESSAGE]({ playdeck: a }, "*") } ; Ton.POST_MESSAGE = "postMessage"; var Kongregate = function() { Platform.call(this, connector.KONGREGATE, { sdk: SdkManager.SDK_KONGREGATE }) }; Kongregate.prototype = Object.create(Platform.prototype); Kongregate.prototype.constructor = Kongregate; Kongregate.prototype.getLocalStoragePrefix = function() { return "_kongregate" } ; Kongregate.prototype.callNative = function(a, b, c) { console.log("[connector] callNative", a); ConnectorRestClient.get("https://api.kongregate.com/api/" + a, b, function(d) { d.error ? (console.log("[connector] callNative error", a, d), c(connector.CODE_FAILED, d)) : (console.log("[connector] callNative success", a, d), c(connector.CODE_SUCCEED, d)) }) } ; var Crazy = function() { Platform.call(this, connector.CRAZY, { sdk: SdkManager.SDK_CRAZY }); connector.social.needWindowForLogin = !0 }; Crazy.prototype = Object.create(Platform.prototype); Crazy.prototype.constructor = Crazy; Crazy.prototype._connect = function(a) { CrazyGames.SDK.game.sdkGameLoadingStart(); CrazyGames.SDK.user.isUserAccountAvailable(function(b) { b ? a(connector.STATUS_DISCONNECTED) : a(connector.STATUS_CONNECTED) }) } ; Crazy.prototype.startGame = function(a) { connector.platform.whenConnected(function() { CrazyGames.SDK.game.sdkGameLoadingStop() }); a() } ; Crazy.prototype.gameplayStart = function() { connector.platform.whenConnected(function() { CrazyGames.SDK.game.gameplayStart() }) } ; Crazy.prototype.gameplayStop = function() { connector.platform.whenConnected(function() { CrazyGames.SDK.game.gameplayStop() }) } ; Crazy.prototype.getLocalStoragePrefix = function() { return "_crazy" } ; var SPMobage = function() { Platform.call(this, connector.SP_MOBAGE, { sdk: SdkManager.SDK_SPMOBAGE }); connector.info.isInApp = !0; connector.info.isMobile = !0; connector.platform.whenConnected(this.createHeaderAndFooter.bind(this)) }; SPMobage.prototype = Object.create(Platform.prototype); SPMobage.prototype.constructor = SPMobage; SPMobage.prototype.getLocalStoragePrefix = function() { return "_sp_mbga" } ; SPMobage.prototype.listSuggestedLanguages = function() { return [connector.LANGUAGE_JAPANESE] } ; SPMobage.prototype.createHeaderAndFooter = function() { var a = document.createElement("div"); a.style.position = "absolute"; a.style.zIndex = "2"; a.style.bottom = "0"; a.style.height = "27px"; a.style.width = "100%"; a.style.background = "#e3e3e3"; a.style.display = "table"; a.innerHTML = "