Advertisement
Guest User

bad.js

a guest
Mar 28th, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Kongregate = Kongregate || {};
  2. Kongregate.Utils = Kongregate.Utils || {};
  3. Kongregate.Utils.catchErrors = function(a, c) {
  4.     return function() {
  5.         try {
  6.             return a.apply(c, arguments)
  7.         } catch (b) {
  8.             Kongregate.Log.error("catchErrors caught unhandled exception", b)
  9.         }
  10.     }
  11. };
  12. (function() {
  13.     function a(a, b, e) {
  14.         Kongregate.Log[a] = function() {
  15.             try {
  16.                 "undefined" !== typeof active_user && void 0 === Kongregate.Log.debugLevel && (Kongregate.Log.debugLevel = active_user.debugLevel()), Kongregate.Log.debugLevel >= b && (console[e] ? Function.prototype.apply.call(console[e], console, arguments) : console.log(arguments))
  17.             } catch (a) {}
  18.         }
  19.     }
  20.     Kongregate.Log = {};
  21.     a("spam", 5, "log");
  22.     a("debug", 4, "log");
  23.     a("info", 3, "info");
  24.     a("warn", 2, "warn");
  25.     a("error", 1, "error")
  26. })();
  27. KonduitEvent = {
  28.     INIT: "init",
  29.     CONNECT: "connect",
  30.     CONNECTED: "connected",
  31.     DISCONNECT: "disconnect",
  32.     LOGIN: "login",
  33.     SWITCH_USER: "switch_user",
  34.     JOIN_ROOM: "join_room",
  35.     LEAVE_ROOM: "leave_room",
  36.     USER_JOIN: "user_join",
  37.     USER_DEPARTURE: "user_departure",
  38.     USER_CHANGED: "user_changed",
  39.     ROOM_MESSAGE: "room_message",
  40.     SYSTEM_MESSAGE: "system_message",
  41.     PRIVATE_MESSAGE: "private_message",
  42.     ADMIN_MESSAGE: "admin_message",
  43.     MESSAGE_ERROR: "message_error",
  44.     SET_PRESENCE: "set_presence",
  45.     GUEST_COUNT: "guest_count",
  46.     ROOM_NOT_FOUND: "room_not_found",
  47.     ROOM_FULL: "room_full",
  48.     REQUEST_CHAT_ROOM: "request_chat_room",
  49.     CREATE_PRIVATE_ROOM: "create_private_room",
  50.     DESTROY_PRIVATE_ROOM: "destroy_private_room",
  51.     PRIVATE_ROOM_INVITATION: "private_room_invitation",
  52.     PRIVATE_ROOM_KICK: "private_room_kick",
  53.     PRIVATE_ROOM_INVITATION_SENT: "private_room_invitation_sent",
  54.     JOIN_GUILD_ROOM: "join_guild_room",
  55.     SILENCED: "silenced",
  56.     PARTICIPATE: "participate",
  57.     AMNESTY: "amnesty",
  58.     API_INITIALIZED: "api_initialized",
  59.     ADD_STATISTICS: "add_statistics",
  60.     STATISTIC_UPDATED: "statistic_updated",
  61.     STATISTIC_SUBMISSION: "statistic_submission",
  62.     STATISTICS_FLUSH: "statistics_flush",
  63.     SET_ACCOMPLISHMENT_PROGRESS: "set_accomplishment_progress",
  64.     NEW_HIGH_SCORE: "new_high_score",
  65.     DISPLAY_SHOUT_BOX: "display_shout_box",
  66.     DISPLAY_INVITATION_BOX: "display_invitation_box",
  67.     SEND_PRIVATE_MESSAGE: "send_private_message",
  68.     DISPLAY_FEED_POST_BOX: "display_feed_post_box",
  69.     DISPLAY_SIGN_IN_LIGHTBOX: "display_sign_in_lightbox",
  70.     DISPLAY_REGISTRATION_LIGHTBOX: "display_registration_lightbox",
  71.     RESIZE_GAME: "resize_game",
  72.     HANDLE_ITEM_CHECKOUT_REQUEST: "handle_item_checkout_request",
  73.     KONDUIT_MESSAGE: "konduit_message",
  74.     ANALYTICS_PAYLOAD: "analytics_payload",
  75.     OP_EXTERNAL_MESSAGE: "ext.msg",
  76.     OP_CONNECTED: "connected",
  77.     OP_HELLO: "hello",
  78.     OP_USER_INFO: "user.info",
  79.     OP_SIGN_IN: "sign_in",
  80.     PARAM_USER: "user",
  81.     PARAM_USER_ID: "user_id",
  82.     PARAM_GAME_AUTH_TOKEN: "auth_token",
  83.     PURCHASE_RESULT: "purchase_result",
  84.     CUSTOM_TAB_MESSAGE: "custom_tab_message",
  85.     CUSTOM_TAB_SHOW: "custom_tab_show",
  86.     CUSTOM_TAB_CLOSE: "custom_tab_close",
  87.     CUSTOM_TAB_SHOWN: "custom_tab_shown",
  88.     CUSTOM_TAB_CLEAR_MESSAGES: "custom_tab_clear_messages",
  89.     OP_CHAT_TAB: "chat.tab",
  90.     OP_CHAT_CLEAR_DIALOG: "chat.dlg.clear",
  91.     OP_CHAT_DISPLAY: "chat.disp",
  92.     OP_CHAT_MSG: "chat.msg",
  93.     OP_CHAT_CANVAS_ELEMENT: "chat.elm",
  94.     OP_CHAT_PRIVATE_MESSAGE: "chat.privateMessage",
  95.     OP_CHAT_RESIZE_GAME: "chat.resizeGame",
  96.     OP_CHAT_DISPLAY_INVITATION_BOX: "chat.invite",
  97.     OP_CHAT_DISPLAY_FEED_POST_BOX: "chat.feedpost",
  98.     OP_CHAT_DISPLAY_REGISTRATION: "chat.registration",
  99.     OP_CHAT_DISPLAY_SHOUT_BOX: "chat.shoutbox",
  100.     PARAM_SHOUT_MESSAGE: "shout_message",
  101.     PARAM_CANVAS_SIZE: "chat.canvas.size",
  102.     PARAM_RESIZE_GAME_WIDTH: "chat.resizeGame.width",
  103.     PARAM_RESIZE_GAME_HEIGHT: "chat.resizeGame.height",
  104.     PARAM_INVITATION_MESSAGE: "invitation_message",
  105.     PARAM_FRIEND_FILTER: "filter",
  106.     PARAM_IMAGE_URI: "image_uri",
  107.     PARAM_KV_PARAMS: "kv_params",
  108.     PARAM_NAME: "name",
  109.     PARAM_DESCRIPTION: "desc",
  110.     PARAM_DATA: "data",
  111.     OP_SHOUT_CALLBACK: "ext.shout_callback",
  112.     PARAM_MESSAGE_TYPE: "ext.message_type",
  113.     PARAM_MESSAGE_RECIPIENTS: "ext.message_recipients",
  114.     PARAM_ERROR: "error",
  115.     PARAM_SUCCESS: "success",
  116.     PARAM_REQUEST_ID: "req.id",
  117.     OP_STATS_SUBMIT: "stat.submit",
  118.     ITEM_LIST: "mtx.item_list",
  119.     ITEM_CHECKOUT: "mtx.checkout",
  120.     PURCHASE_KREDS: "mtx.kred_purchase",
  121.     ITEM_INSTANCES: "mtx.item_instances",
  122.     USE_ITEM_INSTANCE: "mtx.use_item_instance",
  123.     PARAM_PURCHASE_METHOD: "purchase_method",
  124.     PARAM_ITEM_TAGS: "item_tags",
  125.     PARAM_ITEMS: "items",
  126.     PARAM_ORDER_INFO: "order_info",
  127.     PARAM_ID: "id",
  128.     ADS_INITIALIZE: "ads.initialize",
  129.     ADS_AVAILABLE: "ads.available",
  130.     ADS_UNAVAILABLE: "ads.unavailable",
  131.     ADS_SHOW_INCENTIVIZED: "ads.show_incentivized",
  132.     AD_OPENED: "ads.ad_opened",
  133.     AD_COMPLETED: "ads.ad_completed",
  134.     AD_ABANDONED: "ads.ad_abandoned",
  135.     PROCESSING_SAVE_SHARED_CONTENT: "processing_save_shared_content",
  136.     SAVE_SHARED_CONTENT: "save_shared_content",
  137.     SAVE_SHARED_CONTENT_COMPLETE: "shared_content_save_complete",
  138.     LOAD_SHARED_CONTENT: "load_shared_content",
  139.     BROWSE_SHARED_CONTENT: "browse_shared_content",
  140.     OP_SAVE_SHARED_CONTENT: "save_shared_content",
  141.     OP_BROWSE_SHARED_CONTENT: "browse_shared_content",
  142.     OP_LOAD_SHARED_CONTENT: "load_shared_content",
  143.     OP_SHARED_CONTENT_SAVE_COMPLETE: "shared_content_save_complete",
  144.     PARAM_CONTENT_TYPE: "content_type",
  145.     PARAM_LABEL: "label",
  146.     PARAM_IMAGE: "image",
  147.     OP_IMAGE_AVATAR_SUBMIT: "avatar.submit",
  148.     OP_IMAGE_AVATAR_FINISHED: "avatar.finished",
  149.     IMAGE_AVATAR_SUBMIT: "image_avatar_submit",
  150.     IMAGE_AVATAR_COMPLETE: "image_avatar_complete",
  151.     OP_ANALYTICS_PAYLOAD: "analytics.payload",
  152.     HOLODECK_DATA: "holodeck_data",
  153.     PARAM_HOLODECK_TYPE: "holodeck_type",
  154.     FETCH_HISTORY: "fetch_history",
  155.     HISTORY_RECEIVED: "history_received",
  156.     FAYE_DISCONNECT: "faye_disconnect"
  157. };
  158. KonduitChatErrorMessage = {
  159.     MESSAGE_TOO_LONG: "error_msg_too_long",
  160.     RATE_LIMITED: "error_msg_rate_limit"
  161. };
  162. KonduitPresenceType = {
  163.     CHAT: "chat",
  164.     AWAY: "away"
  165. };
  166.  
  167. function FABridge(a, c) {
  168.     this.target = a;
  169.     this.remoteTypeCache = {};
  170.     this.remoteInstanceCache = {};
  171.     this.remoteFunctionCache = {};
  172.     this.localFunctionCache = {};
  173.     this.bridgeID = FABridge.nextBridgeID++;
  174.     this.name = c;
  175.     this.nextLocalFuncID = 0;
  176.     FABridge.instances[this.name] = this;
  177.     FABridge.idMap[this.bridgeID] = this;
  178.     return this
  179. }
  180. FABridge.TYPE_ASINSTANCE = 1;
  181. FABridge.TYPE_ASFUNCTION = 2;
  182. FABridge.TYPE_JSFUNCTION = 3;
  183. FABridge.TYPE_ANONYMOUS = 4;
  184. FABridge.initCallbacks = {};
  185. FABridge.userTypes = {};
  186. FABridge.addToUserTypes = function() {
  187.     for (var a = 0; a < arguments.length; a++) FABridge.userTypes[arguments[a]] = {
  188.         typeName: arguments[a],
  189.         enriched: !1
  190.     }
  191. };
  192. FABridge.argsToArray = function(a) {
  193.     for (var c = [], b = 0; b < a.length; b++) c[b] = a[b];
  194.     return c
  195. };
  196. FABridge.isArray = function(a) {
  197.     return !!a && (a instanceof Array || "[object Array]" === Object.prototype.toString.call(a))
  198. };
  199. FABridge.isASProxy = function(a) {
  200.     return !!a && (a instanceof ASProxy || !!a.bridgeName && !!a.typeName && "ASProxy" === a.className)
  201. };
  202.  
  203. function instanceFactory(a) {
  204.     this.fb_instance_id = a;
  205.     return this
  206. }
  207.  
  208. function FABridge__invokeJSFunction(a) {
  209.     var c = a[0];
  210.     a = a.concat();
  211.     a.shift();
  212.     return FABridge.extractBridgeFromID(c).invokeLocalFunction(c, a)
  213. }
  214. FABridge.addInitializationCallback = function(a, c) {
  215.     var b = FABridge.instances[a];
  216.     void 0 != b ? c.call(b) : (b = FABridge.initCallbacks[a], null == b && (FABridge.initCallbacks[a] = b = []), b.push(c))
  217. };
  218.  
  219. function FABridge__bridgeInitialized(a) {
  220.     var c = document.getElementsByTagName("object"),
  221.         b = c.length,
  222.         e = [];
  223.     if (0 < b)
  224.         for (var d = 0; d < b; d++) "undefined" != typeof c[d].SetVariable && (e[e.length] = c[d]);
  225.     b = document.getElementsByTagName("embed");
  226.     d = b.length;
  227.     c = [];
  228.     if (0 < d)
  229.         for (var k = 0; k < d; k++) "undefined" != typeof b[k].SetVariable && (c[c.length] = b[k]);
  230.     k = e.length;
  231.     b = c.length;
  232.     d = "bridgeName=" + a;
  233.     if (1 == k && !b || 1 == k && 1 == b) FABridge.attachBridge(e[0], a);
  234.     else if (1 == b && !k) FABridge.attachBridge(c[0], a);
  235.     else {
  236.         var g = !1;
  237.         if (1 < k)
  238.             for (var f = 0; f <
  239.                 k; f++) {
  240.                 for (var n = e[f].childNodes, v = 0; v < n.length; v++) {
  241.                     var l = n[v];
  242.                     if (1 == l.nodeType && "param" == l.tagName.toLowerCase() && "flashvars" == l.name.toLowerCase() && 0 <= l.value.indexOf(d)) {
  243.                         FABridge.attachBridge(e[f], a);
  244.                         g = !0;
  245.                         break
  246.                     }
  247.                 }
  248.                 if (g) break
  249.             }
  250.         if (!g && 1 < b)
  251.             for (e = 0; e < b; e++)
  252.                 if (0 <= c[e].attributes.getNamedItem("flashVars").nodeValue.indexOf(d)) {
  253.                     FABridge.attachBridge(c[e], a);
  254.                     break
  255.                 }
  256.     }
  257.     return !0
  258. }
  259. FABridge.nextBridgeID = 0;
  260. FABridge.instances = {};
  261. FABridge.idMap = {};
  262. FABridge.refCount = 0;
  263. FABridge.extractBridgeFromID = function(a) {
  264.     return FABridge.idMap[a >> 16]
  265. };
  266. FABridge.attachBridge = function(a, c) {
  267.     var b = new FABridge(a, c);
  268.     FABridge[c] = b;
  269.     var e = FABridge.initCallbacks[c];
  270.     if (null != e) {
  271.         for (var d = 0; d < e.length; d++) e[d].call(b);
  272.         delete FABridge.initCallbacks[c]
  273.     }
  274. };
  275. FABridge.blockedMethods = {
  276.     toString: !0,
  277.     get: !0,
  278.     set: !0,
  279.     call: !0
  280. };
  281. FABridge.prototype = {
  282.     root: function() {
  283.         return this.deserialize(this.target.getRoot())
  284.     },
  285.     releaseASObjects: function() {
  286.         return this.target.releaseASObjects()
  287.     },
  288.     releaseNamedASObject: function(a) {
  289.         return "object" != typeof a ? !1 : this.target.releaseNamedASObject(a.fb_instance_id)
  290.     },
  291.     create: function(a) {
  292.         return this.deserialize(this.target.create(a))
  293.     },
  294.     makeID: function(a) {
  295.         return (this.bridgeID << 16) + a
  296.     },
  297.     getPropertyFromAS: function(a, c) {
  298.         if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
  299.         FABridge.refCount++;
  300.         retVal = this.target.getPropFromAS(a, c);
  301.         retVal = this.handleError(retVal);
  302.         FABridge.refCount--;
  303.         return retVal
  304.     },
  305.     setPropertyInAS: function(a, c, b) {
  306.         if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
  307.         FABridge.refCount++;
  308.         retVal = this.target.setPropInAS(a, c, this.serialize(b));
  309.         retVal = this.handleError(retVal);
  310.         FABridge.refCount--;
  311.         return retVal
  312.     },
  313.     callASFunction: function(a,
  314.         c) {
  315.         if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
  316.         FABridge.refCount++;
  317.         retVal = this.target.invokeASFunction(a, this.serialize(c));
  318.         retVal = this.handleError(retVal);
  319.         FABridge.refCount--;
  320.         return retVal
  321.     },
  322.     callASMethod: function(a, c, b) {
  323.         if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
  324.         FABridge.refCount++;
  325.         b = this.encodeJSON(this.serialize(b));
  326.         retVal = this.target.invokeASMethod(a, c, b);
  327.         retVal = this.handleError(retVal);
  328.         FABridge.refCount--;
  329.         return retVal
  330.     },
  331.     invokeLocalFunction: function(a, c) {
  332.         var b, e = this.localFunctionCache[a];
  333.         void 0 != e && (b = this.serialize(e.apply(null, this.deserialize(c))));
  334.         return b
  335.     },
  336.     getTypeFromName: function(a) {
  337.         return this.remoteTypeCache[a]
  338.     },
  339.     createProxy: function(a, c) {
  340.         var b = this.getTypeFromName(c);
  341.         instanceFactory.prototype = b;
  342.         b = new instanceFactory(a);
  343.         return this.remoteInstanceCache[a] =
  344.             b
  345.     },
  346.     getProxy: function(a) {
  347.         return this.remoteInstanceCache[a]
  348.     },
  349.     addTypeDataToCache: function(a) {
  350.         newType = new ASProxy(this, a.name);
  351.         for (var c = a.accessors, b = 0; b < c.length; b++) this.addPropertyToType(newType, c[b]);
  352.         a = a.methods;
  353.         for (b = 0; b < a.length; b++) void 0 == FABridge.blockedMethods[a[b]] && this.addMethodToType(newType, a[b]);
  354.         return this.remoteTypeCache[newType.typeName] = newType
  355.     },
  356.     addPropertyToType: function(a, c) {
  357.         var b = c.charAt(0),
  358.             e;
  359.         "a" <= b && "z" >= b ? (e = "get" + b.toUpperCase() + c.substr(1), b = "set" + b.toUpperCase() + c.substr(1)) :
  360.             (e = "get" + c, b = "set" + c);
  361.         a[b] = function(a) {
  362.             this.bridge.setPropertyInAS(this.fb_instance_id, c, a)
  363.         };
  364.         a[e] = function() {
  365.             return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, c))
  366.         }
  367.     },
  368.     addMethodToType: function(a, c) {
  369.         a[c] = function() {
  370.             return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id, c, FABridge.argsToArray(arguments)))
  371.         }
  372.     },
  373.     getFunctionProxy: function(a) {
  374.         var c = this;
  375.         null == this.remoteFunctionCache[a] && (this.remoteFunctionCache[a] = function() {
  376.             c.callASFunction(a, FABridge.argsToArray(arguments))
  377.         });
  378.         return this.remoteFunctionCache[a]
  379.     },
  380.     getFunctionID: function(a) {
  381.         void 0 == a.__bridge_id__ && (a.__bridge_id__ = this.makeID(this.nextLocalFuncID++), this.localFunctionCache[a.__bridge_id__] = a);
  382.         return a.__bridge_id__
  383.     },
  384.     serialize: function(a) {
  385.         var c = {},
  386.             b = typeof a;
  387.         if ("number" == b || "string" == b || "boolean" == b || null == b || "undefined" == b) c = a;
  388.         else if (FABridge.isArray(a)) {
  389.             c = [];
  390.             for (b = 0; b < a.length; b++) c[b] = this.serialize(a[b])
  391.         } else "function" == b ? (c.type = FABridge.TYPE_JSFUNCTION, c.value = this.getFunctionID(a)) : FABridge.isASProxy(a) ?
  392.             (c.type = FABridge.TYPE_ASINSTANCE, c.value = a.fb_instance_id) : (c.type = FABridge.TYPE_ANONYMOUS, c.value = a);
  393.         return c
  394.     },
  395.     deserialize: function(a) {
  396.         var c, b = typeof a;
  397.         if ("number" == b || "string" == b || "boolean" == b || null == a || void 0 == a) c = this.handleError(a);
  398.         else if (FABridge.isArray(a)) {
  399.             c = [];
  400.             for (b = 0; b < a.length; b++) c[b] = this.deserialize(a[b])
  401.         } else if ("object" == b) {
  402.             for (b = 0; b < a.newTypes.length; b++) this.addTypeDataToCache(a.newTypes[b]);
  403.             for (var e in a.newRefs) this.createProxy(e, a.newRefs[e]);
  404.             a.type == FABridge.TYPE_PRIMITIVE ?
  405.                 c = a.value : a.type == FABridge.TYPE_ASFUNCTION ? c = this.getFunctionProxy(a.value) : a.type == FABridge.TYPE_ASINSTANCE ? c = this.getProxy(a.value) : a.type == FABridge.TYPE_ANONYMOUS && (c = a.value)
  406.         }
  407.         return c
  408.     },
  409.     encodeJSON: function(a) {
  410.         var c, b, e, d = "";
  411.         switch (typeof a) {
  412.             case "object":
  413.                 if (a) {
  414.                     if (FABridge.isArray(a)) {
  415.                         for (b = 0; b < a.length; ++b) c = this.encodeJSON(a[b]), d && (d += ","), d += c;
  416.                         return "[" + d + "]"
  417.                     }
  418.                     if ("undefined" != typeof a.toString) {
  419.                         for (b in a) c = a[b], "undefined" != typeof c && "function" != typeof c && (c = this.encodeJSON(c), d && (d += ","), d +=
  420.                             this.encodeJSON(b) + ":" + c);
  421.                         return "{" + d + "}"
  422.                     }
  423.                 }
  424.                 return "null";
  425.             case "number":
  426.                 return isFinite(a) ? "" + a : "null";
  427.             case "string":
  428.                 e = a.length;
  429.                 d = '"';
  430.                 for (b = 0; b < e; b += 1)
  431.                     if (c = a.charAt(b), " " <= c) {
  432.                         if ("\\" == c || '"' == c) d += "\\";
  433.                         d += c
  434.                     } else switch (c) {
  435.                         case "\b":
  436.                             d += "\\b";
  437.                             break;
  438.                         case "\f":
  439.                             d += "\\f";
  440.                             break;
  441.                         case "\n":
  442.                             d += "\\n";
  443.                             break;
  444.                         case "\r":
  445.                             d += "\\r";
  446.                             break;
  447.                         case "\t":
  448.                             d += "\\t";
  449.                             break;
  450.                         default:
  451.                             c = c.charCodeAt(), d += "\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16)
  452.                     }
  453.                 return d + '"';
  454.             case "boolean":
  455.                 return "" + a;
  456.             default:
  457.                 return "null"
  458.         }
  459.     },
  460.     addRef: function(a) {
  461.         this.target.incRef(a.fb_instance_id)
  462.     },
  463.     release: function(a) {
  464.         this.target.releaseRef(a.fb_instance_id)
  465.     },
  466.     handleError: function(a) {
  467.         if ("string" == typeof a && 0 == a.indexOf("__FLASHERROR")) throw a = a.split("||"), 0 < FABridge.refCount && FABridge.refCount--, Error(a[1]);
  468.         return a
  469.     }
  470. };
  471. ASProxy = function(a, c) {
  472.     this.bridge = a;
  473.     this.typeName = c;
  474.     this.className = "ASProxy";
  475.     return this
  476. };
  477. ASProxy.prototype = {
  478.     get: function(a) {
  479.         return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, a))
  480.     },
  481.     set: function(a, c) {
  482.         this.bridge.setPropertyInAS(this.fb_instance_id, a, c)
  483.     },
  484.     call: function(a, c) {
  485.         this.bridge.callASMethod(this.fb_instance_id, a, c)
  486.     },
  487.     addRef: function() {
  488.         this.bridge.addRef(this)
  489.     },
  490.     release: function() {
  491.         this.bridge.release(this)
  492.     }
  493. };
  494. (function() {
  495.     var a;
  496.     Kongregate.MessageConnection = function(a) {
  497.         this.initialize(a)
  498.     };
  499.     Kongregate.MessageConnection.MESSAGE_EVENT = "kongregate:api:message";
  500.     Kongregate.MessageConnection.prototype = {
  501.         initialize: function(c) {
  502.             a = c.channel_id;
  503.             this._window = c.window || window;
  504.             this._targetOrigin = c.target_origin;
  505.             this._targetWindows = c.target_window ? [c.target_window] : [];
  506.             this._retryConnection = c.retry_connection || !1;
  507.             this._messageListeners = [];
  508.             this._supportsObjects = this.detectObjectSupport();
  509.             this._client = "string" === typeof this._targetOrigin;
  510.             this._connected = this._handleMessages = !1
  511.         },
  512.         addMessageListener: function(a) {
  513.             this._messageListeners.push(a)
  514.         },
  515.         isSupported: function() {
  516.             return !this.supportsObjects() && "undefined" === typeof this._window.JSON ? !1 : "undefined" !== typeof(this._targetWindows[0] || window).postMessage
  517.         },
  518.         connected: function() {
  519.             return this._connected
  520.         },
  521.         isClient: function() {
  522.             return this._client
  523.         },
  524.         supportsObjects: function() {
  525.             return this._supportsObjects
  526.         },
  527.         logPrefix: function() {
  528.             return this._client ? "[Game]" : "[Konduit]"
  529.         },
  530.         detectObjectSupport: function() {
  531.             var a =
  532.                 document.createElement("iframe"),
  533.                 b = !0;
  534.             a.src = "about:blank";
  535.             document.body.appendChild(a);
  536.             try {
  537.                 a.contentWindow.postMessage({
  538.                     toString: function() {
  539.                         b = !1;
  540.                         return ""
  541.                     }
  542.                 }, "*")
  543.             } catch (e) {}
  544.             document.body.removeChild(a);
  545.             return b
  546.         },
  547.         listen: function() {
  548.             if (this.isSupported() && !this._listening) {
  549.                 this._listening = !0;
  550.                 var a = this,
  551.                     b = function(b) {
  552.                         a.onMessageReceived.call(a, b)
  553.                     };
  554.                 this._window.addEventListener ? this._window.addEventListener("message", b, !1) : this._window.attachEvent && this._window.attachEvent("onmessage", b)
  555.             }
  556.         },
  557.         parseMessage: function(a) {
  558.             var b;
  559.             try {
  560.                 if ("string" === typeof a && "{" === a[0] ? b = JSON.parse(a) : "object" === typeof a && (b = a), b && b.kongregate_type === Kongregate.MessageConnection.MESSAGE_EVENT) return {
  561.                     opcode: b.opcode,
  562.                     params: b.params
  563.                 }
  564.             } catch (e) {
  565.                 Kongregate.Log.warn(this.logPrefix(), "Error parsing message", a, e)
  566.             }
  567.             return null
  568.         },
  569.         onMessageReceived: function(a) {
  570.             var b = a.origin || a.originalEvent.origin;
  571.             this._targetOrigin && b !== this._targetOrigin ? Kongregate.Log.debug(this.logPrefix(), "Ignoring message from " + b) : (b = this.parseMessage(a.data)) && this.processMessage(b,
  572.                 a)
  573.         },
  574.         processMessage: function(a, b) {
  575.             Kongregate.Log.debug(this.logPrefix(), "Message received:", a);
  576.             switch (a.opcode) {
  577.                 case KonduitEvent.CONNECT:
  578.                     this.onClientConnected(a.params, b.source);
  579.                     break;
  580.                 case KonduitEvent.CONNECTED:
  581.                     this.onConnectedToServer()
  582.             }
  583.             for (var e = 0; e < this._messageListeners.length; e++) this._messageListeners[e](a.opcode, a.params)
  584.         },
  585.         sendMessage: function(a, b) {
  586.             this.removeMissingWindows();
  587.             if (!this.connected() && a !== KonduitEvent.CONNECT && a !== KonduitEvent.CONNECTED) Kongregate.Log.debug(this.logPrefix(),
  588.                 "Not sending " + a + ", not connected");
  589.             else {
  590.                 var e = {
  591.                     kongregate_type: Kongregate.MessageConnection.MESSAGE_EVENT,
  592.                     opcode: a,
  593.                     params: "string" === typeof b ? JSON.parse(b) : b
  594.                 };
  595.                 this.supportsObjects() || (e = JSON.stringify(e));
  596.                 for (var d = this._targetOrigin || "*", k = 0; k < this._targetWindows.length; k++) this._targetWindows[k].postMessage(e, d)
  597.             }
  598.         },
  599.         connect: function() {
  600.             this.connected() || (this.listen(), Kongregate.Log.debug("Attempting to connect to Kongregate API"), this.sendMessage(KonduitEvent.CONNECT, {
  601.                     chnl: a
  602.                 }), this._retryConnection &&
  603.                 this.retryConnection())
  604.         },
  605.         retryConnection: function() {
  606.             var a = this;
  607.             setTimeout(function() {
  608.                 a.connect()
  609.             }, 5E3)
  610.         },
  611.         onClientConnected: function(c, b) {
  612.             c.chnl !== a ? Kongregate.Log.warn(this.logPrefix(), "Channel ID mismatch, ignoring connect") : (Kongregate.Log.debug(this.logPrefix(), "API connection established!"), this.acceptClientConnection(b))
  613.         },
  614.         onConnectedToServer: function() {
  615.             this.connected() || (Kongregate.Log.debug(this.logPrefix(), "API connection established!"), this._connected = !0)
  616.         },
  617.         acceptClientConnection: function(a) {
  618.             for (var b =
  619.                     this._targetWindows, e = 0; e < this._targetWindows.length; e++)
  620.                 if (this._targetWindows[e] === a) {
  621.                     Kongregate.Log.debug("Not adding duplicate connection");
  622.                     return
  623.                 }
  624.             this._targetWindows = [a];
  625.             this.sendMessage(KonduitEvent.CONNECTED, {});
  626.             this._targetWindows = b;
  627.             this._targetWindows.push(a);
  628.             this.removeMissingWindows()
  629.         },
  630.         removeMissingWindows: function(a) {
  631.             if (!this._client) {
  632.                 for (i = this._targetWindows.length - 1; 0 <= i; i--) this._targetWindows[i].top || this._targetWindows.splice(i, 1);
  633.                 this._connected = 0 < this._targetWindows.length
  634.             }
  635.         }
  636.     }
  637. })();
  638. (function() {
  639.     Kongregate.AnalyticsServices = function(a) {
  640.         this.initialize(a)
  641.     };
  642.     Kongregate.AnalyticsServices.prototype = {
  643.         initialize: function(a) {
  644.             var b = this;
  645.             this._heartbeatInterval = a.heartbeat_interval || 15E3;
  646.             this._services = a.services;
  647.             this._legacyAnalytics = a.legacy_analytics;
  648.             this._swrveClient = a.swrve_client;
  649.             this._mtx = a.mtx;
  650.             this._kongVars = a.kongregate_variables;
  651.             this._staticVars = {};
  652.             this._persistentStore = {};
  653.             this._heartbeatCount = 0;
  654.             this._enablePersistence = a.enable_persistence;
  655.             this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,
  656.                 function(a) {
  657.                     b._onIncomingMessage(a.opcode, a.params)
  658.                 });
  659.             a.start && this._setup()
  660.         },
  661.         addEvent: function(a, b) {
  662.             this._enabled && (!this._autoAnalyticsDisabled() && 0 <= ja.indexOf(a) ? Kongregate.Log.warn("Ignoring analytics event: " + a + " since it is a kong-automatic event.") : this._addEventInternal(a, this._objectify(b)))
  663.         },
  664.         addFilterType: function(a) {
  665.             if (this._enabled && a) {
  666.                 var b = /^[a-zA-Z0-9_]+$/;
  667.                 !a || !b.test(a) ? Kongregate.Log.warn("Invalid filterType: " + a + ", must be alpha_numeric") : (b = (b = this._savedData[s]) ? b.split(",") : [], 0 > b.indexOf(a) && (b.push(a), b.sort(), this._savedData[s] = b.join(","), this._flushPersistentStore(), Kongregate.Log.info("Filter type added: " + a)))
  668.             }
  669.         },
  670.         setCommonPropsCallback: function(a) {
  671.             this._enabled && (this._commonPropsCallback = a, this.updateCommonProperties())
  672.         },
  673.         setCommonProperties: function(a) {
  674.             a = this._objectify(a);
  675.             this.setCommonPropsCallback(function() {
  676.                 return a
  677.             })
  678.         },
  679.         updateCommonProperties: function() {
  680.             try {
  681.                 "function" === typeof this._commonPropsCallback && (this._commonProperties = this._objectify(this._commonPropsCallback()),
  682.                     this._savedData[ka] = this._commonProperties, this._commonProperties[S] && !this._savedData[x] && (this._savedData[x] = this._commonProperties[S]))
  683.             } catch (a) {
  684.                 Kongregate.Log.error("Error updating common properties: " + a)
  685.             }
  686.         },
  687.         getAutoLongProperty: function(a) {
  688.             return this.getAutoIntProperty(a)
  689.         },
  690.         getAutoLongLongProperty: function(a) {
  691.             return this.getAutoLongProperty(a)
  692.         },
  693.         getAutoStringProperty: function(a) {
  694.             if (!this._enabled) return null;
  695.             var b = this._getKongAutomaticVariables();
  696.             if ("string" === typeof b[a]) return b[a];
  697.             Kongregate.Log.warn("Property is not a string: " +
  698.                 a);
  699.             return null
  700.         },
  701.         getAutoBoolProperty: function(a) {
  702.             return !this._enabled ? !1 : !!this._getKongAutomaticVariables()[a]
  703.         },
  704.         getAutoDoubleProperty: function(a) {
  705.             if (!this._enabled) return NaN;
  706.             var b = this._getKongAutomaticVariables();
  707.             return Number(b[a])
  708.         },
  709.         getAutoIntProperty: function(a) {
  710.             return !this._enabled ? NaN : Math.floor(this.getAutoDoubleProperty(a))
  711.         },
  712.         getAutoUTCProperty: function(a) {
  713.             return this.getAutoStringProperty(a)
  714.         },
  715.         getAutoPropertiesJSON: function() {
  716.             if (!this._enabled) return "{}";
  717.             this._buildKongAutomaticVariables();
  718.             return "function" === typeof JSON.stringify ? JSON.stringify(this._automaticVars) : "{}"
  719.         },
  720.         startPurchase: function(a, b) {
  721.             if (!this._autoAnalyticsDisabled()) {
  722.                 var c = this._getProductId(a);
  723.                 c ? (this._priceUSD = this._getUSDPrice(c, b), this._iapID && Kongregate.Log.warn("startPurchase: invoked before active transaction finished. iap_ids may mismatch."), Kongregate.Log.debug("IAP FLOW STEP: startPurchase(): " + c), this._iapID = this._uuid(), this._productId = c, this._addIAPEvent(null, this._objectify(b), I)) : Kongregate.Log.warn("startPurchase: Can't start purchase with null productId, param was: " +
  724.                     a)
  725.             }
  726.         },
  727.         finishPurchase: function(a, b, c) {
  728.             this._autoAnalyticsDisabled() || (Kongregate.Log.debug("IAP FLOW STEP: finishPurchase(): " + this._productId + ", transactionId: " + b + ", resultCode: " + a), la === a ? (this._numPurchases++, this._totalSpentUSD += this._priceUSD, this._addIAPEvent(b, this._objectify(c), J)) : this._addIAPFailEvent(b, this._objectify(c)))
  729.         },
  730.         setAutomaticVariablesListener: function(a) {
  731.             this._enabled && (this._automaticVarsListener = a, this._getKongAutomaticVariables())
  732.         },
  733.         start: function() {},
  734.         _setup: function() {
  735.             if (!this._savedData) {
  736.                 Kongregate.Log.debug("Initializing Analytics API");
  737.                 var b = this._services.isKongregate();
  738.                 this._mode = b ? this._kongVars.kongregate_analytics_mode : null;
  739.                 if (this._enabled = null !== this._mode) {
  740.                     this._enablePersistence && this._hasLocalStorage() && this._loadPersistentStore();
  741.                     this._clientVersion = b ? this._kongVars.kongregate_game_version : "1";
  742.                     this._pendingEvents = this._persistentStore.pending_events || [];
  743.                     this._persistentStore.event_queues = this._persistentStore.event_queues || {
  744.                         swrve: []
  745.                     };
  746.                     this._eventQueue = this._persistentStore.event_queues.swrve;
  747.                     this._savedData = this._persistentStore.saved_data =
  748.                         this._persistentStore.saved_data || {};
  749.                     this._items = this._persistentStore.items || [];
  750.                     this._savedData.common_properties || (this._savedData.common_properties = {});
  751.                     this._commonProperties = this._savedData.common_properties;
  752.                     this._bundleId = this._savedData[g];
  753.                     this._autoAnalyticsDisabled() ? Kongregate.Log.debug("Auto analytics disabled") : this._autoAnalyticsExcludesServer() ? Kongregate.Log.debug("Game has a server, only tracking a subset of analytics automatically") : Kongregate.Log.debug("Automatic analytics enabled");
  754.                     b && this._requestItems();
  755.                     var b = this._getDate(),
  756.                         c = !this._savedData[t];
  757.                     this._setInitialSavedData(t, this._toW3CDTF(b));
  758.                     this._setInitialSavedData(E, a);
  759.                     this._setInitialSavedData(y, this._clientVersion);
  760.                     this._setInitialSavedData(B, this._timeZoneOffset());
  761.                     c && (Kongregate.Log.debug("Analytics: First play"), this._installEvent());
  762.                     this._startSession();
  763.                     this._buildKongStaticVars()
  764.                 } else Kongregate.Log.debug("Analytics API not enabled")
  765.             }
  766.         },
  767.         _enqueueEvent: function(a, b) {
  768.             if (!this._initialized) {
  769.                 if (!this._autoAnalyticsDisabled() ||
  770.                     !b[K]) Kongregate.Log.debug("Queueing pending event: " + a), this._pendingEvents.push({
  771.                     name: a,
  772.                     event: b
  773.                 });
  774.                 return !0
  775.             }
  776.             return !1
  777.         },
  778.         _addEventInternal: function(a, b, c) {
  779.             var h = 0 === a.indexOf("swrve.");
  780.             !h && !b[T] && (b = this._merge(this._buildEventSpecificVariables(), b));
  781.             if (!this._enqueueEvent(a, b) && this._enabled) {
  782.                 U === a && this._refreshPlayerInfoFields(b);
  783.                 var m = this._getKongAutomaticVariables(),
  784.                     e = {};
  785.                 h ? e = b : (this._merge(e, this._objectify(this._commonProperties)), b[K] ? (this._merge(e, m), this._merge(e, b)) : (this._merge(e, b), this._merge(e,
  786.                     m)));
  787.                 Kongregate.SwrveClient.SWRVE_SESSION_START_IDENTIFIER === a && (c = !0);
  788.                 Kongregate.Log.debug("Adding event: " + a + ", flush=" + c);
  789.                 this._eventQueue.push({
  790.                     name: a,
  791.                     event: e
  792.                 });
  793.                 this._flushQueue();
  794.                 c && this._flushPersistentStore()
  795.             }
  796.         },
  797.         _flushQueue: function() {
  798.             if (this._swrveClient) {
  799.                 var a = this;
  800.                 this._eventQueue.length && !this._submitLock && (Kongregate.Log.debug("Flushing swrve event queue"), this._submitLock = !0, this._swrveClient.sendEvents(this._eventQueue, function(b) {
  801.                     a._submitLock = !1;
  802.                     a._flushPersistentStore();
  803.                     a._flushQueueDelayed(b.success ?
  804.                         1E3 : 1E4)
  805.                 }))
  806.             }
  807.         },
  808.         _flushQueueDelayed: function(a) {
  809.             var b = this;
  810.             setTimeout(function() {
  811.                 b._flushQueue()
  812.             }, a)
  813.         },
  814.         _persistentStoreName: function() {
  815.             return Kongregate.AnalyticsServices.persistentStoreName(this._kongVars.kongregate_game_id)
  816.         },
  817.         _getLegacyPersistentStore: function() {
  818.             if (this._legacyAnalytics) try {
  819.                 var a = this._legacyAnalytics.getPersistentDataJSON();
  820.                 if (a) return Kongregate.Log.debug("Importing legacy persistent store"), a
  821.             } catch (b) {
  822.                 Kongregate.Log.warn("Error importing persistent store: " + b)
  823.             }
  824.             return null
  825.         },
  826.         _loadPersistentStore: function() {
  827.             var a;
  828.             try {
  829.                 var b = localStorage.getItem(this._persistentStoreName()) || this._getLegacyPersistentStore(!0) || "{}";
  830.                 a = JSON.parse(b)
  831.             } catch (c) {
  832.                 Kongregate.Log.warn("Error loading persistent store: " + c)
  833.             }
  834.             this._persistentStore = a || {}
  835.         },
  836.         _flushPersistentStore: function() {
  837.             try {
  838.                 var a = JSON.stringify(this._persistentStore);
  839.                 localStorage.setItem(this._persistentStoreName(), a)
  840.             } catch (b) {
  841.                 Kongregate.Log.warn("Error flushing persistent store: " + b)
  842.             }
  843.         },
  844.         _destroyPersistentStore: function() {
  845.             localStorage.removeItem(this._persistentStoreName())
  846.         },
  847.         _buildEventSpecificVariables: function() {
  848.             var a = {};
  849.             a[T] = 0;
  850.             if (this._autoAnalyticsDisabled()) return a;
  851.             a[h] = this._uuid();
  852.             a[u] = this._toW3CDTF(this._getDate());
  853.             a[ma] = this._timeZoneOffset();
  854.             return a
  855.         },
  856.         _refreshPlayerInfoFields: function(a) {
  857.             a[L] = this._savedData[L];
  858.             a[M] = this._savedData[M];
  859.             for (var b = 0; b < V.length; b++) {
  860.                 var c = V[b];
  861.                 a[c] ? this._savedData[c] = a[c] : a[c] = this._savedData[c] ? this._savedData[c] : null
  862.             }
  863.         },
  864.         _addAutoEvent: function(a, b) {
  865.             this._autoAnalyticsDisabled() || (b = this._objectify(b), b[K] = !0, this._addEventInternal(a,
  866.                 b))
  867.         },
  868.         _addIAPEvent: function(a, b, c) {
  869.             var h = {};
  870.             this._merge(h, this._objectify(b));
  871.             h[N] = this._priceUSD;
  872.             h[na] = this._productId;
  873.             h[W] = this._iapID;
  874.             I != c && (h[X] = a || Y);
  875.             this._services.isKongregate() ? (h[O] = this._getKredPrice(this._productId), h[P] = "KRED") : (h[O] = b[O] || this._priceUSD, h[P] = b[P] || "USD");
  876.             J === c && (this._sendSwrveIAPEvent(this._productId, this._priceUSD, b), this._productId = this._iapID = null, this._priceUSD = 0);
  877.             this._addEventInternal(c, h)
  878.         },
  879.         _addIAPFailEvent: function(a, b) {
  880.             var c = {};
  881.             this._merge(c, this._objectify(b));
  882.             c[oa] = "SKErrorPaymentCancelled";
  883.             c[X] = a || Y;
  884.             c[W] = this._iapID;
  885.             this._productId = this._iapID = null;
  886.             this._priceUSD = 0;
  887.             this._addEventInternal(Z, c)
  888.         },
  889.         _sendSwrveUserEvent: function() {
  890.             if (!this._autoAnalyticsDisabled()) {
  891.                 for (var a = this._getKongAutomaticVariables(), b = {}, c = 0; c < aa.length; c++) {
  892.                     var h = aa[c];
  893.                     b["kong." + h] = a[h]
  894.                 }
  895.                 this._addAutoEvent(Kongregate.SwrveClient.SWRVE_USER_IDENTIFIER, b)
  896.             }
  897.         },
  898.         _sendSwrveIAPEvent: function(a, b, c) {
  899.             b = {
  900.                 product_id: a,
  901.                 quantity: 1,
  902.                 local_cost: b,
  903.                 local_currency: "USD",
  904.                 app_store: "unknown_store"
  905.             };
  906.             var h = {};
  907.             h[a] = {
  908.                 type: "item",
  909.                 amount: 1
  910.             };
  911.             c.soft_currency_change && (h.soft_currency_change = {
  912.                 type: "currency",
  913.                 amount: c.soft_currency_change
  914.             });
  915.             c.hard_currency_change && (h.hard_currency_change = {
  916.                 type: "currency",
  917.                 amount: c.hard_currency_change
  918.             });
  919.             c.type && (h[c.type] = {
  920.                 type: "item",
  921.                 amount: 1
  922.             });
  923.             b.rewards = h;
  924.             this.addEvent(Kongregate.SwrveClient.SWRVE_IAP_IDENTIFIER, b)
  925.         },
  926.         _onIncomingMessage: function(a, b) {
  927.             a === KonduitEvent.OP_ANALYTICS_PAYLOAD && this._processAnalyticsPayload(b.data.info, b.data.payload)
  928.         },
  929.         _setInitialSavedData: function(a,
  930.             b) {
  931.             this._savedData[a] || (this._savedData[a] = b)
  932.         },
  933.         _autoAnalyticsDisabled: function() {
  934.             return !this._enabled || this._mode === b
  935.         },
  936.         _autoAnalyticsAllEnabled: function() {
  937.             return this._enabled && this._mode === e
  938.         },
  939.         _autoAnalyticsExcludesServer: function() {
  940.             return this._enabled && this._mode === d
  941.         },
  942.         _getProductId: function(a) {
  943.             try {
  944.                 if ("string" === typeof a) return a;
  945.                 if (Number(parseFloat(a)) == a) return a.toString();
  946.                 if ("[object Array]" === Object.prototype.toString.call(a)) {
  947.                     if (0 < a.length) return this._getProductId(a[0])
  948.                 } else if ("string" ===
  949.                     typeof a.identifier) return a.identifier
  950.             } catch (b) {
  951.                 Kongregate.Log.error("Error calculating product ID:", b)
  952.             }
  953.             Kongregate.Log.warn("Couldn't get product ID from: " + a + ", type=" + typeof a);
  954.             return null
  955.         },
  956.         _getUSDPrice: function(a, b) {
  957.             if (this._services.isKongregate()) {
  958.                 var c = this._getKredPrice(a);
  959.                 if (0 !== c) return Math.floor(100 * c * this._kredExchangeRate) / 100
  960.             } else if (b && b[N]) return b[N];
  961.             if ((c = a.match(/^.*t([0-9][0-9])_.*$/)) && 2 === c.length)
  962.                 if (c = parseInt(c[1], 10), 0 < c && c <= ba.length) return ba[c - 1];
  963.             Kongregate.Log.warn("Couldn't calculate USD price for identifier: " +
  964.                 a);
  965.             return 0
  966.         },
  967.         _getKredPrice: function(a) {
  968.             for (var b = 0; b < this._items.length; b++) {
  969.                 var c = this._items[b];
  970.                 if (a === c.identifier) return c.price
  971.             }
  972.             Kongregate.Log.warn("Couldn't get kred price for identifier: " + a);
  973.             return 0
  974.         },
  975.         _requestItems: function(a) {
  976.             a = a || 0;
  977.             if (5 < a) Kongregate.Log.error("Giving up on retrieving item list");
  978.             else {
  979.                 var b = this;
  980.                 this._mtx.requestItemList(null, function(c) {
  981.                     c.success ? b._items = b._persistentStore.items = c.data : b._retryRequestItems(a + 1)
  982.                 })
  983.             }
  984.         },
  985.         _retryRequestItems: function(a) {
  986.             var b = this;
  987.             Kongregate.Log.warn("Retrying item list request, retry #" +
  988.                 a);
  989.             setTimeout(function() {
  990.                 b.requestItems(a)
  991.             }, 15E3 * a)
  992.         },
  993.         _processAnalyticsPayload: function(a, b) {
  994.             Kongregate.Log.info("Analytics payload received");
  995.             if (this._enabled)
  996.                 if (this._checkBrowserSupport(b)) {
  997.                     this._config = a;
  998.                     var c = this._config.swrve;
  999.                     this._svid = b.site_visitor_uid;
  1000.                     b.kger && (this._kredExchangeRate = b.kger);
  1001.                     this._updateKongStaticVars(b);
  1002.                     this._initialized || (this._initialized = !0, !this._swrveClient && (c && c.application_id && c.key) && (Kongregate.Log.debug("Swrve initialized"), this._swrveClient = new Kongregate.SwrveClient({
  1003.                         application_id: c.application_id,
  1004.                         api_key: c.key,
  1005.                         player_id: this._services.isKongregate() ? this._svid : this._savedData[Q],
  1006.                         client_version: this._clientVersion
  1007.                     })), this._swrveClient ? (this._submitLock = !1, this._startHeartbeatTimer(), this._flushPendingEvents(), this._sendSwrveUserEvent(), this.addEvent(U, {}), this._flushQueue()) : (Kongregate.Log.debug("Analytics not initialized, no services configured"), this._enabled = !1))
  1008.                 } else this._enabled = !1
  1009.         },
  1010.         _checkBrowserSupport: function(a) {
  1011.             try {
  1012.                 if ("safari" === a.browser.browser.toLowerCase()) Kongregate.Log.warn("Analytics disabled on Safari");
  1013.                 else {
  1014.                     if (window.XMLHttpRequest && "withCredentials" in new XMLHttpRequest) return !0;
  1015.                     Kongregate.Log.warn("Analytics disabled due to lack of XHR/CORS support")
  1016.                 }
  1017.             } catch (b) {
  1018.                 Kongregate.Log.warn("Error while checking browser support: " + b)
  1019.             }
  1020.             return !1
  1021.         },
  1022.         _hasLocalStorage: function() {
  1023.             try {
  1024.                 var a = "kong-" + this._getDate().getTime();
  1025.                 localStorage.setItem(a, a);
  1026.                 localStorage.removeItem(a);
  1027.                 return !0
  1028.             } catch (b) {
  1029.                 return !1
  1030.             }
  1031.         },
  1032.         _startHeartbeatTimer: function() {
  1033.             if (this._heartbeatInterval) {
  1034.                 var a = this;
  1035.                 setInterval(function() {
  1036.                         a._onHeartbeatInterval()
  1037.                     },
  1038.                     this._heartbeatInterval)
  1039.             }
  1040.         },
  1041.         _onHeartbeatInterval: function() {
  1042.             this._heartbeatCount += 1;
  1043.             this._session.active = this._getDate().getTime();
  1044.             4 == this._heartbeatCount && (this._heartbeatCount = 0, this.addEvent(pa, {}))
  1045.         },
  1046.         _flushPendingEvents: function() {
  1047.             if (0 < this._pendingEvents.length) {
  1048.                 Kongregate.Log.debug("Flushing " + this._pendingEvents.length + " pending event(s)");
  1049.                 for (var a = 0; a < this._pendingEvents.length; a++) {
  1050.                     var b = this._pendingEvents[a];
  1051.                     this._addEventInternal(b.name, b.event, !1)
  1052.                 }
  1053.                 this._pendingEvents.length = 0
  1054.             }
  1055.         },
  1056.         _buildKongStaticVars: function() {
  1057.             if (!this._autoAnalyticsDisabled()) {
  1058.                 var b =
  1059.                     this._services.isKongregate();
  1060.                 this._staticVars[g] = this._bundleId;
  1061.                 this._staticVars[ca] = this._services.getUsername();
  1062.                 this._staticVars[qa] = this._services.getUserId();
  1063.                 this._staticVars[ra] = b ? this._svid : "";
  1064.                 this._staticVars[z] = this._session.id;
  1065.                 this._staticVars[sa] = a;
  1066.                 this._staticVars[G] = this._numSessions();
  1067.                 this._staticVars[q] = this._clientVersion;
  1068.                 this._staticVars[r] = this._clientVersion;
  1069.                 this._staticVars[y] = this._savedData[y];
  1070.                 this._staticVars[x] = this._savedData[x] || null;
  1071.                 this._staticVars[ta] = "kongregate_web";
  1072.                 this._autoAnalyticsExcludesServer() || (this._staticVars[Q] = b ? this._svid : this._savedData[Q]);
  1073.                 this._staticVars[m] = "browser";
  1074.                 this._staticVars[ua] = null;
  1075.                 this._staticVars[t] = this._savedData[t];
  1076.                 this._staticVars[E] = this._savedData[E];
  1077.                 this._staticVars[B] = this._savedData[B];
  1078.                 this._staticVars[va] = this._kongVars.kongregate_language || (window.navigator.userLanguage || window.navigator.language).split("-")[0];
  1079.                 this._staticVars[da] = null;
  1080.                 this._staticVars[ea] = null;
  1081.                 this._staticVars[wa] = null;
  1082.                 this._staticVars[xa] = null;
  1083.                 this._staticVars[k] = !1;
  1084.                 this._staticVars[w] = "wifi";
  1085.                 this._staticVars[v] = null;
  1086.                 this._staticVars[H] = null;
  1087.                 this._staticVars[R] = null;
  1088.                 this._staticVars[ya] = !0;
  1089.                 this._staticVars[za] = "web"
  1090.             }
  1091.         },
  1092.         _buildKongAutomaticVariables: function() {
  1093.             if (this._autoAnalyticsDisabled()) this._automaticVars = {};
  1094.             else {
  1095.                 var a = {};
  1096.                 a[s] = this._savedData[s] || "";
  1097.                 a[Aa] = this._numPurchases;
  1098.                 a[A] = this._daysRetained();
  1099.                 this._autoAnalyticsExcludesServer() || (a[fa] = this._totalSpentUSD);
  1100.                 this._automaticVars = this._merge(a, this._staticVars)
  1101.             }
  1102.         },
  1103.         _updateKongStaticVars: function(a) {
  1104.             if (!this._autoAnalyticsDisabled()) {
  1105.                 this._bundleId =
  1106.                     "com.kongregate.web." + a.game_permalink;
  1107.                 this._services.isExternal() && (this._bundleId += ".external");
  1108.                 this._savedData[g] = this._bundleId;
  1109.                 this._buildKongStaticVars();
  1110.                 var b = this._parseOS(a.browser.os);
  1111.                 this._staticVars[l] = b.type;
  1112.                 this._staticVars[D] = b.version;
  1113.                 this._staticVars[Ba] = a.premium;
  1114.                 this._staticVars[p] = a.powerup_rewards_tier;
  1115.                 this._savedData[L] = a.pur_link_date || null;
  1116.                 this._savedData[M] = a.join_date || null;
  1117.                 this._staticVars[Ca] = Number(a.spent_on_kreds);
  1118.                 this._totalSpentUSD = a.spent_usd;
  1119.                 this._numPurchases = a.num_purchases;
  1120.                 this._staticVars[f] = a.browser.browser;
  1121.                 this._staticVars[n] = a.browser.version;
  1122.                 this._staticVars[Da] = a.ip_address;
  1123.                 this._staticVars[F] = a.ip_address;
  1124.                 b = this._getDate();
  1125.                 b = Math.abs(b.getTime() - this._parseW3CDTF(a.server_time, b).getTime()) / 1E3;
  1126.                 this._staticVars[Ea] = Math.floor(b);
  1127.                 this._savedData[Fa] = a.server_time;
  1128.                 this._staticVars[C] = a.country_code;
  1129.                 this._getKongAutomaticVariables()
  1130.             }
  1131.         },
  1132.         _getKongAutomaticVariables: function() {
  1133.             if (!this._enabled) return {};
  1134.             this.updateCommonProperties();
  1135.             this._buildKongAutomaticVariables();
  1136.             this._automaticVarsListener && this._automaticVarsListener(this._automaticVars);
  1137.             return this._automaticVars
  1138.         },
  1139.         _startSession: function() {
  1140.             var a = this._getDate(),
  1141.                 b = (this._previousSession = this._savedData.current_session) ? (a.getTime() - this._previousSession.active) / 1E3 : 0,
  1142.                 h = this._previousSession ? (a.getTime() - this._previousSession.start) / 1E3 : 0;
  1143.             b > c ? (Kongregate.Log.debug("Terminating previous session (" + this._previousSession.id + "), inactiveFor=" + b + ", length=" + h), b = {}, b[z] = this._previousSession.id, b[G] = this._numSessions(),
  1144.                 b[Ga] = this._toW3CDTF(this._previousSession.active), b[Ha] = h, b[Ia] = !1, this._addAutoEvent(ga, b)) : this._previousSession && (this._session = this._previousSession, Kongregate.Log.debug("Reopening previous session (" + this._previousSession.id + "), inactiveFor=" + b + ", length=" + h));
  1145.             this._session || (this._session = {
  1146.                 id: this._uuid(),
  1147.                 start: a.getTime(),
  1148.                 active: a.getTime()
  1149.             }, this._savedData.current_session = this._session, a = this._savedData[G] ? this._numSessions() + 1 : 1, this._savedData[G] = a, Kongregate.Log.debug("Created new session: " +
  1150.                 this._session.id));
  1151.             this._session != this._previousSession && (this.addEvent(Kongregate.SwrveClient.SWRVE_SESSION_START_IDENTIFIER, {}), a = {}, a[Ja] = !1, this._addAutoEvent(ha, a))
  1152.         },
  1153.         _installEvent: function() {
  1154.             if (this._autoAnalyticsAllEnabled()) {
  1155.                 var a = {};
  1156.                 a[Ka] = null;
  1157.                 a[La] = null;
  1158.                 a[Ma] = null;
  1159.                 a[Na] = null;
  1160.                 a[Oa] = null;
  1161.                 a[Pa] = null;
  1162.                 this._addAutoEvent(ia, a)
  1163.             } else Kongregate.Log.debug("Not firing installs event since analytics mode is not all")
  1164.         },
  1165.         _parseOS: function(a) {
  1166.             var b = "Unknown",
  1167.                 c = "Unknown";
  1168.             try {
  1169.                 var h = a.split(" ");
  1170.                 if (2 > h.length) throw Error("Not enough segments in OS string");
  1171.                 b = h.shift();
  1172.                 "OS" === b && (b = "MacOS", h.shift());
  1173.                 c = h.join(" ")
  1174.             } catch (m) {
  1175.                 Kongregate.Log.error("Error parsing OS version (" + a + "): " + m.toString())
  1176.             }
  1177.             return {
  1178.                 type: b,
  1179.                 version: c
  1180.             }
  1181.         },
  1182.         _numSessions: function() {
  1183.             return this._savedData[G] || 1
  1184.         },
  1185.         _timeZoneOffset: function() {
  1186.             return this._getDate().getTimezoneOffset() / -60
  1187.         },
  1188.         _daysRetained: function() {
  1189.             var a = this._getDate(),
  1190.                 b = this._timeZoneOffset(),
  1191.                 c = this._staticVars[t];
  1192.             c && (a = this._parseW3CDTF(c, null), null === a && (Kongregate.Log.warn("Failed to parse first play date: " + c + ", resetting"),
  1193.                 a = this._getDate(), this._savedData[t] = this._toW3CDTF(a), this._flushPersistentStore()));
  1194.             this._staticVars[B] && (b = this._staticVars[B]);
  1195.             return this._daysSince(a, b)
  1196.         },
  1197.         _dayOfEra: function(a, b) {
  1198.             return Math.floor((a + 3600 * b) / 86400)
  1199.         },
  1200.         _daysSince: function(a, b) {
  1201.             var c = Math.floor(this._getDate() / 1E3),
  1202.                 h = Math.floor(a.getTime() / 1E3);
  1203.             return this._dayOfEra(c, this._timeZoneOffset()) - this._dayOfEra(h, b)
  1204.         },
  1205.         _objectify: function(a) {
  1206.             if ("string" === typeof a) {
  1207.                 if (0 === a.length || "function" !== typeof JSON.parse) return {};
  1208.                 try {
  1209.                     return JSON.parse(a) || {}
  1210.                 } catch (b) {
  1211.                     return Kongregate.Log.warn("Failed to parse JSON: " + a + ", error: " + b), {}
  1212.                 }
  1213.             }
  1214.             return a
  1215.         },
  1216.         _toW3CDTF: function(a) {
  1217.             return Kongregate.Utils.toW3CDTF(a)
  1218.         },
  1219.         _parseW3CDTF: function(a, b) {
  1220.             return Kongregate.Utils.parseW3CDTF(a, b)
  1221.         },
  1222.         _uuid: function() {
  1223.             var a = this._getDate().getTime();
  1224.             window.performance && "function" === typeof window.performance.now && (a += performance.now());
  1225.             return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(b) {
  1226.                 var c = (a + 16 * Math.random()) % 16 | 0;
  1227.                 a = Math.floor(a / 16);
  1228.                 return ("x" == b ? c : c &
  1229.                     3 | 8).toString(16)
  1230.             })
  1231.         },
  1232.         _merge: function(a, b) {
  1233.             return Kongregate.Utils.merge(a, b)
  1234.         },
  1235.         _getDate: function() {
  1236.             return new Date
  1237.         }
  1238.     };
  1239.     var a = "2.0.0",
  1240.         c = 300,
  1241.         b = "none",
  1242.         e = "all",
  1243.         d = "cloud",
  1244.         k = "ad_tracking",
  1245.         g = "bundle_id",
  1246.         f = "browser",
  1247.         n = "browser_version",
  1248.         v = "carrier",
  1249.         l = "client_os_type",
  1250.         D = "client_os_version",
  1251.         q = "client_version",
  1252.         C = "country_code",
  1253.         w = "data_connection_type",
  1254.         A = "days_retained",
  1255.         r = "dev_client_version",
  1256.         h = "device_event_id",
  1257.         m = "device_type",
  1258.         u = "event_time",
  1259.         F = "external_ip_address",
  1260.         s = "filter_type",
  1261.         y = "first_client_version",
  1262.         B = "first_play_time_offset",
  1263.         t = "first_play_time",
  1264.         E = "first_sdk_version",
  1265.         x = "first_server_version",
  1266.         H = "gamecenter_id",
  1267.         R = "gamecenter_alias",
  1268.         p = "pur_tier",
  1269.         da = "idfa",
  1270.         ea = "idfv",
  1271.         xa = "imei",
  1272.         wa = "android_id",
  1273.         Da = "ip_address",
  1274.         ya = "is_valid",
  1275.         qa = "kong_user_id",
  1276.         ca = "kong_username",
  1277.         Ba = "kong_plus",
  1278.         va = "lang_code",
  1279.         Fa = "last_skew_refresh_time",
  1280.         Aa = "num_purchases",
  1281.         G = "num_sessions",
  1282.         ua = "mac_address",
  1283.         Q = "player_id",
  1284.         sa = "sdk_version",
  1285.         S = "server_version",
  1286.         z = "session_id",
  1287.         Ea = "time_skew",
  1288.         fa = "total_spent_in_usd",
  1289.         ma = "event_time_offset",
  1290.         ra = "site_visitor_id",
  1291.         Ca = "usd_spent_on_kreds",
  1292.         ta = "platform",
  1293.         za = "pkg_src",
  1294.         T = "retry_count",
  1295.         K = "auto_event",
  1296.         ha = "session_starts",
  1297.         Ja = "is_from_background",
  1298.         ga = "session_ends",
  1299.         Ha = "session_length_seconds",
  1300.         Ga = "session_end_time",
  1301.         Ia = "did_crash",
  1302.         ia = "installs",
  1303.         Ka = "stub_field",
  1304.         La = "utm_source",
  1305.         Ma = "utm_medium",
  1306.         Na = "utm_term",
  1307.         Oa = "utm_content",
  1308.         Pa = "utm_campaign",
  1309.         I = "iap_attempts",
  1310.         J = "iap_transactions",
  1311.         Z = "iap_fails",
  1312.         N = "usd_cost",
  1313.         na = "product_id",
  1314.         W = "iap_id",
  1315.         oa = "fail_reason",
  1316.         X = "receipt_id",
  1317.         P = "local_currency_type",
  1318.         O = "local_currency_cost",
  1319.         la = "SUCCESS",
  1320.         Y = "none",
  1321.         U = "player_info",
  1322.         M = "kong_join_date",
  1323.         L = "pur_link_date",
  1324.         ja = [ia, ha, ga, "foreground_visits", "background_visits", I, Z, J, "invalid_states"],
  1325.         V = ["twitter_id", "fb_user_id", "fb_username", "fb_email", "email"],
  1326.         aa = [fa, t, G, A, m, l, D, C, ca, z, da, ea, q],
  1327.         pa = "swrve.heartbeat",
  1328.         ba = [0.99, 1.99, 2.99, 3.99, 4.99, 5.99, 6.99, 7.99, 8.99, 9.99, 10.99, 11.99, 12.99, 13.99, 14.99, 15.99, 16.99, 17.99, 18.99, 19.99, 20.99, 21.99, 22.99, 23.99, 24.99, 25.99, 26.99, 27.99, 28.99, 29.99, 30.99, 31.99, 32.99, 33.99, 34.99, 35.99, 36.99, 37.99, 38.99, 39.99, 40.99, 41.99, 42.99, 43.99, 44.99, 45.99,
  1329.             46.99, 47.99, 48.99, 49.99, 54.99, 59.99, 64.99, 69.99, 74.99, 79.99, 84.99, 89.99, 94.99, 99.99, 109.99, 119.99, 124.99, 129.99, 139.99, 149.99, 159.99, 169.99, 174.99, 179.99, 189.99, 199.99, 209.99, 219.99, 229.99, 239.99, 249.99, 299.99, 349.99, 399.99, 449.99, 499.99, 599.99, 699.99, 799.99, 899.99, 999.99
  1330.         ],
  1331.         ka = "common_properties";
  1332.     Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME = u;
  1333.     Kongregate.AnalyticsServices.persistentStoreName = function(a) {
  1334.         return "kong-game-analytics-" + a
  1335.     }
  1336. })();
  1337. Kongregate.ApiServices = function(a) {
  1338.     this.initialize(a)
  1339. };
  1340. Kongregate.ApiServices.prototype = {
  1341.     initialize: function(a) {
  1342.         this._kongVars = a.kongregate_variables || {};
  1343.         this._messageConnection = a.message_connection;
  1344.         this._eventListeners = {};
  1345.         this._requestHandlers = {};
  1346.         this._messageQueue = [];
  1347.         this._requestId = 0;
  1348.         this._initializeKongVars(this._kongVars);
  1349.         this.initializeEventListeners()
  1350.     },
  1351.     initializeEventListeners: function() {
  1352.         var a = this;
  1353.         this._messageConnection.addMessageListener(function(c, b) {
  1354.             a._onIncomingMessage(c, b)
  1355.         })
  1356.     },
  1357.     _initializeKongVars: function(a) {
  1358.         a = a || {};
  1359.         this._kongregate = "true" ===
  1360.             String(a.kongregate);
  1361.         this._username = a.kongregate_username || "Guest";
  1362.         this._authToken = a.kongregate_game_auth_token;
  1363.         this._userId = parseInt(a.kongregate_user_id, 10) || 0;
  1364.         this._gameId = parseInt(a.kongregate_game_id, 10) || 0
  1365.     },
  1366.     addEventListener: function(a, c) {
  1367.         this._eventListeners[a] || (this._eventListeners[a] = []);
  1368.         this._eventListeners[a].push(c)
  1369.     },
  1370.     _dispatchEvent: function(a, c) {
  1371.         for (var b = this._eventListeners[a] || [], e = 0; e < b.length; e++) b[e](c || {})
  1372.     },
  1373.     connect: function() {},
  1374.     connectExternal: function() {
  1375.         Kongregate.Log.warn("The Kongregate externally hosted API is not available")
  1376.     },
  1377.     isExternal: function() {
  1378.         return !this.isKongregate()
  1379.     },
  1380.     isKongregate: function() {
  1381.         return this._kongregate
  1382.     },
  1383.     getUsername: function() {
  1384.         return this._username
  1385.     },
  1386.     getGameAuthToken: function() {
  1387.         return this._authToken
  1388.     },
  1389.     getUserId: function() {
  1390.         return this._userId
  1391.     },
  1392.     getUserID: function() {
  1393.         return this.getUserId()
  1394.     },
  1395.     getGameId: function() {
  1396.         return this._gameId
  1397.     },
  1398.     getGameID: function() {
  1399.         return this.getGameId()
  1400.     },
  1401.     isGuest: function() {
  1402.         return 0 === this.getUserId()
  1403.     },
  1404.     isConnected: function() {
  1405.         return this._messageConnection.connected() && !this._messageQueue
  1406.     },
  1407.     sendMessage: function(a) {
  1408.         this.isConnected() ? this._messageConnection.sendMessage(a.opcode, a.params) : (Kongregate.Log.debug("Queueing message " + a.opcode + " since API is not yet connected!"), this._messageQueue.push(a))
  1409.     },
  1410.     _flushMessageQueue: function() {
  1411.         if (this._messageQueue) {
  1412.             var a = this._messageQueue;
  1413.             this._messageQueue = null;
  1414.             Kongregate.Log.debug("Flushing message queue", a);
  1415.             for (var c = 0; c < a.length; c++) this.sendMessage(a[c])
  1416.         }
  1417.     },
  1418.     _onIncomingMessage: function(a, c) {
  1419.         switch (a) {
  1420.             case KonduitEvent.OP_CONNECTED:
  1421.                 this.sendMessage({
  1422.                     opcode: KonduitEvent.OP_HELLO,
  1423.                     params: {}
  1424.                 });
  1425.                 this._flushMessageQueue();
  1426.                 break;
  1427.             case KonduitEvent.OP_EXTERNAL_MESSAGE:
  1428.                 this._onIncomingMessage(c.opcode, c.data);
  1429.                 break;
  1430.             case KonduitEvent.OP_SHOUT_CALLBACK:
  1431.                 this._onShoutResponse(c);
  1432.                 break;
  1433.             case KonduitEvent.OP_USER_INFO:
  1434.                 this._onUserInfo(c)
  1435.         }
  1436.         this._dispatchEvent(KonduitEvent.KONDUIT_MESSAGE, {
  1437.             opcode: a,
  1438.             params: c
  1439.         })
  1440.     },
  1441.     _onShoutResponse: function(a) {
  1442.         this._completeRequest(a, {
  1443.             type: a[KonduitEvent.PARAM_MESSAGE_TYPE],
  1444.             recipients: a[KonduitEvent.PARAM_MESSAGE_RECIPIENTS],
  1445.             success: a.success,
  1446.             error: a.error
  1447.         })
  1448.     },
  1449.     _onUserInfo: function(a) {
  1450.         var c =
  1451.             a[KonduitEvent.PARAM_USER_ID];
  1452.         if (0 !== c) {
  1453.             var b = this.isGuest();
  1454.             this._username = a[KonduitEvent.PARAM_USER];
  1455.             this._authToken = a[KonduitEvent.PARAM_GAME_AUTH_TOKEN];
  1456.             this._userId = c;
  1457.             b && this._dispatchEvent(KonduitEvent.LOGIN)
  1458.         }
  1459.     },
  1460.     privateMessage: function(a, c) {
  1461.         if (this._ensureKongregate(c)) {
  1462.             var b = {
  1463.                 shout_message: ("string" === typeof a ? a : a.content) || ""
  1464.             };
  1465.             this._enqueueRequest(b, c);
  1466.             this.sendMessage({
  1467.                 opcode: KonduitEvent.OP_CHAT_PRIVATE_MESSAGE,
  1468.                 params: b
  1469.             })
  1470.         }
  1471.     },
  1472.     resizeGame: function(a, c) {
  1473.         if (this._ensureKongregate()) {
  1474.             var b = {};
  1475.             b[KonduitEvent.PARAM_RESIZE_GAME_WIDTH] =
  1476.                 a;
  1477.             b[KonduitEvent.PARAM_RESIZE_GAME_HEIGHT] = c;
  1478.             this.sendMessage({
  1479.                 opcode: KonduitEvent.OP_CHAT_RESIZE_GAME,
  1480.                 params: b
  1481.             })
  1482.         }
  1483.     },
  1484.     showInvitationBox: function(a, c) {
  1485.         if (this._ensureKongregate()) {
  1486.             var b = {};
  1487.             a = "string" === typeof a ? {
  1488.                 content: a
  1489.             } : a;
  1490.             b[KonduitEvent.PARAM_INVITATION_MESSAGE] = a.content || "";
  1491.             b[KonduitEvent.PARAM_FRIEND_FILTER] = a.filter || "";
  1492.             b[KonduitEvent.PARAM_KV_PARAMS] = a.kv_params || {};
  1493.             this._enqueueRequest(b, c);
  1494.             this.sendMessage({
  1495.                 opcode: KonduitEvent.OP_CHAT_DISPLAY_INVITATION_BOX,
  1496.                 params: b
  1497.             })
  1498.         }
  1499.     },
  1500.     showFeedPostBox: function(a,
  1501.         c) {
  1502.         if (this._ensureKongregate()) {
  1503.             var b = {};
  1504.             a = "string" === typeof a ? {
  1505.                 content: a
  1506.             } : a;
  1507.             b[KonduitEvent.PARAM_SHOUT_MESSAGE] = a.content || "";
  1508.             b[KonduitEvent.PARAM_KV_PARAMS] = a.kv_params || {};
  1509.             a.image_uri && (b[KonduitEvent.PARAM_IMAGE_URI] = a.image_uri);
  1510.             this._enqueueRequest(b, c);
  1511.             this.sendMessage({
  1512.                 opcode: KonduitEvent.OP_CHAT_DISPLAY_FEED_POST_BOX,
  1513.                 params: b
  1514.             })
  1515.         }
  1516.     },
  1517.     showSignInBox: function() {
  1518.         this.showRegistrationBox()
  1519.     },
  1520.     showRegistrationBox: function() {
  1521.         this._ensureKongregate() && this.isGuest() && this.sendMessage({
  1522.             opcode: KonduitEvent.OP_CHAT_DISPLAY_REGISTRATION,
  1523.             params: {}
  1524.         })
  1525.     },
  1526.     showShoutBox: function(a, c) {
  1527.         if (this._ensureKongregate()) {
  1528.             var b = {};
  1529.             b[KonduitEvent.PARAM_SHOUT_MESSAGE] = ("string" === typeof a ? a : a.content) || "";
  1530.             this._enqueueRequest(b, c);
  1531.             this.sendMessage({
  1532.                 opcode: KonduitEvent.OP_CHAT_DISPLAY_SHOUT_BOX,
  1533.                 params: b
  1534.             })
  1535.         }
  1536.     },
  1537.     _ensureKongregate: function(a) {
  1538.         return !this.isKongregate() ? (a && a({
  1539.             success: !1
  1540.         }), !1) : !0
  1541.     },
  1542.     _enqueueRequest: function(a, c) {
  1543.         var b = this._nextRequestId();
  1544.         a[KonduitEvent.PARAM_REQUEST_ID] = b;
  1545.         "function" === typeof c && (this._requestHandlers[b] = c)
  1546.     },
  1547.     _completeRequest: function(a,
  1548.         c) {
  1549.         var b = a[KonduitEvent.PARAM_REQUEST_ID],
  1550.             e = this._requestHandlers[b];
  1551.         "function" === typeof e && (e(c || a), delete this._requestHandlers[b])
  1552.     },
  1553.     _nextRequestId: function() {
  1554.         return this._requestId += 1
  1555.     }
  1556. };
  1557. Kongregate.ChatServices = function(a) {
  1558.     this.initialize(a)
  1559. };
  1560. Kongregate.ChatServices.DEFAULT_TAB = "Default";
  1561. Kongregate.ChatServices.prototype = {
  1562.     initialize: function(a) {
  1563.         var c = this;
  1564.         this._services = a.services;
  1565.         this._eventCallbacks = [];
  1566.         this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
  1567.             c._onIncomingMessage(a.opcode, a.params)
  1568.         })
  1569.     },
  1570.     showTab: function(a, c, b) {
  1571.         var e = {};
  1572.         e[KonduitEvent.PARAM_NAME] = a;
  1573.         e[KonduitEvent.PARAM_DESCRIPTION] = c;
  1574.         b && b.size && (e[KonduitEvent.PARAM_CANVAS_SIZE] = b.size);
  1575.         this._services.sendMessage({
  1576.             opcode: KonduitEvent.OP_CHAT_TAB,
  1577.             params: e
  1578.         })
  1579.     },
  1580.     closeTab: function() {
  1581.         this.showTab(Kongregate.ChatServices.DEFAULT_TAB)
  1582.     },
  1583.     displayMessage: function(a, c) {
  1584.         var b = {};
  1585.         b[KonduitEvent.PARAM_DATA] = a;
  1586.         b[KonduitEvent.PARAM_USER] = c;
  1587.         this._services.sendMessage({
  1588.             opcode: KonduitEvent.OP_CHAT_DISPLAY,
  1589.             params: b
  1590.         })
  1591.     },
  1592.     clearMessages: function() {
  1593.         this._services.sendMessage({
  1594.             opcode: KonduitEvent.OP_CHAT_CLEAR_DIALOG
  1595.         })
  1596.     },
  1597.     displayCanvasImage: function(a, c, b) {
  1598.         var e = {};
  1599.         e[KonduitEvent.PARAM_DATA] = {
  1600.             type: "image",
  1601.             name: a,
  1602.             url: c,
  1603.             position: b
  1604.         };
  1605.         this._services.sendMessage({
  1606.             opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
  1607.             params: e
  1608.         })
  1609.     },
  1610.     displayCanvasText: function(a, c, b, e) {
  1611.         var d = {};
  1612.         d[KonduitEvent.PARAM_DATA] = {
  1613.             type: "text",
  1614.             name: a,
  1615.             text: c,
  1616.             position: b,
  1617.             options: e
  1618.         };
  1619.         this._services.sendMessage({
  1620.             opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
  1621.             params: d
  1622.         })
  1623.     },
  1624.     drawCanvasObject: function(a, c) {
  1625.         var b = {};
  1626.         b[KonduitEvent.PARAM_DATA] = {
  1627.             type: "draw",
  1628.             name: a,
  1629.             commands: c
  1630.         };
  1631.         this._services.sendMessage({
  1632.             opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
  1633.             params: b
  1634.         })
  1635.     },
  1636.     removeCanvasObject: function(a) {
  1637.         var c = {};
  1638.         c[KonduitEvent.PARAM_DATA] = {
  1639.             type: "remove",
  1640.             name: a
  1641.         };
  1642.         this._services.sendMessage({
  1643.             opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
  1644.             params: c
  1645.         })
  1646.     },
  1647.     _onIncomingMessage: function(a, c) {
  1648.         switch (a) {
  1649.             case KonduitEvent.OP_CHAT_MSG:
  1650.                 this._handleChatEvent("message", c);
  1651.                 break;
  1652.             case KonduitEvent.OP_CHAT_ROOM_MESSAGE:
  1653.                 this._handleChatEvent("room.message", c);
  1654.                 break;
  1655.             case KonduitEvent.OP_CHAT_TAB:
  1656.                 this._handleChatEvent("tab_visible", c)
  1657.         }
  1658.     },
  1659.     addEventListener: function(a, c) {
  1660.         "function" !== typeof c ? Kongregate.Log.error("addEventListener requires a callback function") : (this._eventCallbacks[a] || (this._eventCallbacks[a] = []), this._eventCallbacks[a].push(c))
  1661.     },
  1662.     _handleChatEvent: function(a,
  1663.         c) {
  1664.         var b = this._eventCallbacks[a];
  1665.         if (b)
  1666.             for (var e = 0; e < b.length; e++) b[e](c)
  1667.     }
  1668. };
  1669. Kongregate.ImageServices = function(a) {
  1670.     this.initialize(a)
  1671. };
  1672. Kongregate.ImageServices.prototype = {
  1673.     initialize: function(a) {
  1674.         var c = this;
  1675.         this._services = a.services;
  1676.         this._submitting = !1;
  1677.         this._callback = null;
  1678.         this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
  1679.             c._onIncomingMessage(a.opcode, a.params)
  1680.         })
  1681.     },
  1682.     submitAvatar: function(a, c) {
  1683.         this._submitting ? (Kongregate.Log.warn("Another avatar submission is active, ignoring"), c && c({
  1684.             success: !1
  1685.         })) : (this._submitting = !0, this._callback = c, this._services.sendMessage({
  1686.             opcode: KonduitEvent.OP_IMAGE_AVATAR_SUBMIT,
  1687.             params: {
  1688.                 image: a
  1689.             }
  1690.         }))
  1691.     },
  1692.     _onIncomingMessage: function(a, c) {
  1693.         KonduitEvent.OP_IMAGE_AVATAR_FINISHED === a && (this._submitting = !1, this._callback && this._callback(c.success))
  1694.     }
  1695. };
  1696.  
  1697. function KongregateAPI() {
  1698.     this._initialize()
  1699. }
  1700. KongregateAPI.prototype = {
  1701.     unityElementId: null,
  1702.     _initialize: function() {
  1703.         this._flashVarsString = "";
  1704.         this._flashVarsObject = {};
  1705.         this._services = {};
  1706.         this._postMessageParams = void 0;
  1707.         this._loading = this._loaded = this._paramsReceived = !1;
  1708.         this._queuedMessages = [];
  1709.         this._swfTimeout = window.chrome ? 0 : 1250;
  1710.         this._loadCallbacks = [];
  1711.         var a = location.search.split("?")[1];
  1712.         if (a)
  1713.             for (var a = a.split("&"), c = 0; c < a.length; c++) {
  1714.                 var b = a[c].split("=");
  1715.                 b && 2 == b.length && this._processParam(b[0], b[1])
  1716.             }
  1717.         if (this._postMessageParams = !this.flashVarsObject().kongregate_ansible_path &&
  1718.             top != window) {
  1719.             var e = this;
  1720.             window.addEventListener("message", function(a) {
  1721.                 e._messageOriginIsKongregate(a) && (a = a.data, "params" == a.type && e._handleParamsMessage(a.data))
  1722.             });
  1723.             top.postMessage("kongregate_request_params", "*")
  1724.         } else this._paramsReceived = !0
  1725.     },
  1726.     flashVarsString: function() {
  1727.         return this._flashVarsString
  1728.     },
  1729.     flashVarsObject: function() {
  1730.         return this._flashVarsObject
  1731.     },
  1732.     getVariable: function(a) {
  1733.         return this._flashVarsObject[a]
  1734.     },
  1735.     loadAPI: function(a) {
  1736.         !this._postMessageParams || this._paramsReceived ? this._doLoadAPI(a) :
  1737.             this._loadCallbacks.push(a)
  1738.     },
  1739.     getAPI: function() {
  1740.         return this._services
  1741.     },
  1742.     embedFrame: function(a, c) {
  1743.         var b = document.getElementById(c ? c : "contentdiv"),
  1744.             e;
  1745.         e = "<iframe id='content' frameborder='0' style='position:relative;top:0px;left:0px;" + ("border:0px none;padding:0px;width:" + b.offsetWidth + "px;height:" + b.offsetHeight + "px;'");
  1746.         e += "src='" + a + "'></iframe>";
  1747.         b.innerHTML = e
  1748.     },
  1749.     _handleParamsMessage: function(a) {
  1750.         if (!this._paramsReceived) {
  1751.             for (var c in a) this._processParam(c, a[c]);
  1752.             this._paramsReceived = !0;
  1753.             0 < this._loadCallbacks.length &&
  1754.                 this._doLoadAPI()
  1755.         }
  1756.     },
  1757.     _fireLoadCallbacks: function() {
  1758.         var a = this._loadCallbacks.length;
  1759.         Kongregate.Log.debug("Kongregate API: Firing " + a + " load callback(s)");
  1760.         for (var c = 0; c < a; c++) {
  1761.             var b = this._loadCallbacks[c];
  1762.             "function" === typeof b && b()
  1763.         }
  1764.         this._loadCallbacks = []
  1765.     },
  1766.     _checkAlreadyLoaded: function() {
  1767.         this._loaded && this._fireLoadCallbacks();
  1768.         return this._loaded
  1769.     },
  1770.     _doLoadAPI: function(a) {
  1771.         this._loadCallbacks.push(a);
  1772.         if (!this._checkAlreadyLoaded() && !this._loading) {
  1773.             this._loading = !0;
  1774.             var c = this,
  1775.                 b = function() {
  1776.                     if (!c._checkAlreadyLoaded()) {
  1777.                         c._loaded = !0;
  1778.                         var a = c.messageConnection && c.messageConnection.isSupported(),
  1779.                             b = "services stats mtx chat sharedContent analytics images".split(" ");
  1780.                         try {
  1781.                             if (c._hasFlash)
  1782.                                 for (var k = FABridge.ansible.root(), g = 0; g < b.length; g++) {
  1783.                                     var f = b[g];
  1784.                                     c._services[f] = k.getServices(f)
  1785.                                 }
  1786.                         } catch (n) {
  1787.                             Kongregate.Log.info("Error creating Flash Ansible object, which is probably fine: " + n)
  1788.                         }
  1789.                         a && c._createJavascriptApi();
  1790.                         c._fireLoadCallbacks()
  1791.                     }
  1792.                 };
  1793.             kswfobject.addDomLoadEvent(function() {
  1794.                 c._createAnsible(b)
  1795.             })
  1796.         }
  1797.     },
  1798.     _processParam: function(a, c) {
  1799.         0 === a.indexOf("kongregate") &&
  1800.             (this._flashVarsObject[a] = c, this._flashVarsString += a + "=" + c + "&")
  1801.     },
  1802.     _messageOriginIsKongregate: function(a) {
  1803.         var c = this._flashVarsObject.kongregate_host;
  1804.         return c && a.origin == "http://" + c || a.origin == "https://" + c
  1805.     },
  1806.     _createJavascriptApi: function() {
  1807.         var a = this;
  1808.         this._services.services = new Kongregate.ApiServices({
  1809.             kongregate_variables: this.flashVarsObject(),
  1810.             message_connection: this.messageConnection
  1811.         });
  1812.         this._services.stats = new Kongregate.StatisticServices({
  1813.             services: this._services.services
  1814.         });
  1815.         this._services.sharedContent =
  1816.             new Kongregate.SharedContentServices({
  1817.                 services: this._services.services
  1818.             });
  1819.         this._services.images = new Kongregate.ImageServices({
  1820.             services: this._services.services
  1821.         });
  1822.         this._services.mtx = new Kongregate.MicrotransactionServices({
  1823.             services: this._services.services
  1824.         });
  1825.         this._services.chat = new Kongregate.ChatServices({
  1826.             services: this._services.services
  1827.         });
  1828.         this._services.analytics = new Kongregate.AnalyticsServices({
  1829.             services: this._services.services,
  1830.             legacy_analytics: this._services.analytics,
  1831.             mtx: this._services.mtx,
  1832.             kongregate_variables: this.flashVarsObject(),
  1833.             enable_persistence: !0,
  1834.             start: !0
  1835.         });
  1836.         setTimeout(function() {
  1837.             a.messageConnection.connect()
  1838.         }, 0)
  1839.     },
  1840.     _analyticsImportRequired: function() {
  1841.         var a = this.flashVarsObject(),
  1842.             c = a.kongregate_analytics_mode,
  1843.             a = Kongregate.AnalyticsServices.persistentStoreName(a.kongregate_game_id);
  1844.         if (!c || "none" === c || navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) return !1;
  1845.         try {
  1846.             return !localStorage.getItem(a)
  1847.         } catch (b) {
  1848.             return !1
  1849.         }
  1850.     },
  1851.     _onAnsibleEmbeded: function(a, c) {
  1852.         this._hasFlash = (this._ansibleSWF = a.ref) && a.success;
  1853.         Kongregate.Log.debug("Ansible embed callback, success: " +
  1854.             this._hasFlash);
  1855.         this._jsApiEnabled ? this._hasFlash ? this._analyticsImportRequired() ? (Kongregate.Log.debug("Analytics import required, attempting to wait for Flash"), this._waitForAnsible(c)) : (Kongregate.Log.debug("Flash not required for analytics import, calling ansible embed callback"), c()) : (Kongregate.Log.debug("Flash not detected, calling ansible embed callback"), c()) : Kongregate.Log.debug("JS API disabled, waiting for Flash indefinitely")
  1856.     },
  1857.     _ansibleReady: function() {
  1858.         return this._ansibleSWF && "undefined" !==
  1859.             typeof this._ansibleSWF.Play
  1860.     },
  1861.     _waitForAnsible: function(a) {
  1862.         var c = (new Date).getTime(),
  1863.             b = this,
  1864.             e = this._requestAnimationFrame(),
  1865.             d = function() {
  1866.                 b._ansibleSWF && "undefined" !== typeof b._ansibleSWF.Play ? Kongregate.Log.debug("Ansible SWF loading, no longer polling") : Math.abs((new Date).getTime() - c) >= b._swfTimeout ? (Kongregate.Log.debug("Ansible SWF did not start loading in time, giving up"), a()) : e(d)
  1867.             };
  1868.         d()
  1869.     },
  1870.     _requestAnimationFrame: function() {
  1871.         if (window.requestAnimationFrame) return window.requestAnimationFrame;
  1872.         for (var a = ["ms", "moz", "webkit", "o"], c = 0; c < a.length; c++) {
  1873.             var b = window[a[c] + "RequestAnimationFrame"];
  1874.             if (b) return b
  1875.         }
  1876.         return function(a) {
  1877.             setTimeout(a, 0)
  1878.         }
  1879.     },
  1880.     _createAnsible: function(a) {
  1881.         try {
  1882.             kongregateUnitySupport.hijackUnityErrorHandler()
  1883.         } catch (c) {}
  1884.         FABridge.addInitializationCallback("ansible", a);
  1885.         var b = this.flashVarsObject(),
  1886.             e = this;
  1887.         this._jsApiEnabled = "true" === String(b.kongregate_js_api);
  1888.         Kongregate.Log.debugLevel = b.kongregate_debug_level || 2;
  1889.         var d = document.createElement("div");
  1890.         d.id = "kongregate-ansible-container";
  1891.         d.style.position =
  1892.             "absolute";
  1893.         d.style.width = d.style.height = "1px";
  1894.         d.style.left = d.style.top = "-1000px";
  1895.         document.body.appendChild(d);
  1896.         var k = document.createElement("div");
  1897.         k.id = "kongregate-ansible";
  1898.         d.appendChild(k);
  1899.         d = {
  1900.             bridgeName: "ansible",
  1901.             json_encode: "true"
  1902.         };
  1903.         this._jsApiEnabled && (this.messageConnection = new Kongregate.MessageConnection({
  1904.             target_window: top,
  1905.             target_origin: decodeURIComponent(b.kongregate_host),
  1906.             channel_id: b.kongregate_channel_id,
  1907.             retry_connection: !0
  1908.         }), this.messageConnection.isSupported() && (d.message_connection_object =
  1909.             "kongregateAPI.messageConnection", this.messageConnection.addMessageListener(function(a, b) {
  1910.                 var c = e._ansibleSWF;
  1911.                 c && "function" === typeof c.handleMessageConnectionEvent && c.handleMessageConnectionEvent(JSON.stringify({
  1912.                     opcode: a,
  1913.                     params: b
  1914.                 }))
  1915.             })));
  1916.         for (var g in b) d[g] = this.flashVarsObject()[g];
  1917.         b = decodeURIComponent(this.getVariable("kongregate_ansible_path"));
  1918.         kswfobject.embedSWF(b, "kongregate-ansible", "1", "1", "9.0.0", null, d, {
  1919.             allowScriptaccess: "always"
  1920.         }, null, function(b) {
  1921.             e._onAnsibleEmbeded(b, a)
  1922.         })
  1923.     }
  1924. };
  1925. kongregateAPI = new KongregateAPI;
  1926. var kswfobject = function() {
  1927.     function a() {
  1928.         if (!E) {
  1929.             try {
  1930.                 var a = m.getElementsByTagName("body")[0].appendChild(m.createElement("span"));
  1931.                 a.parentNode.removeChild(a)
  1932.             } catch (b) {
  1933.                 return
  1934.             }
  1935.             E = !0;
  1936.             for (var a = s.length, c = 0; c < a; c++) s[c]()
  1937.         }
  1938.     }
  1939.  
  1940.     function c(a) {
  1941.         E ? a() : s[s.length] = a
  1942.     }
  1943.  
  1944.     function b(a) {
  1945.         if (typeof h.addEventListener != w) h.addEventListener("load", a, !1);
  1946.         else if (typeof m.addEventListener != w) m.addEventListener("load", a, !1);
  1947.         else if (typeof h.attachEvent != w) l(h, "onload", a);
  1948.         else if ("function" == typeof h.onload) {
  1949.             var b = h.onload;
  1950.             h.onload =
  1951.                 function() {
  1952.                     b();
  1953.                     a()
  1954.                 }
  1955.         } else h.onload = a
  1956.     }
  1957.  
  1958.     function e() {
  1959.         var a = window.onerror;
  1960.         window.onerror = function() {
  1961.             return !0
  1962.         };
  1963.         try {
  1964.             var b = m.getElementsByTagName("body")[0],
  1965.                 c = m.createElement(A);
  1966.             c.setAttribute("type", r);
  1967.             var h = b.appendChild(c);
  1968.             if (h) {
  1969.                 var e = 0;
  1970.                 (function() {
  1971.                     if (typeof h.GetVariable != w) {
  1972.                         var a = h.GetVariable("$version");
  1973.                         a && (a = a.split(" ")[1].split(","), p.pv = [parseInt(a[0], 10), parseInt(a[1], 10), parseInt(a[2], 10)])
  1974.                     } else if (10 > e) {
  1975.                         e++;
  1976.                         setTimeout(arguments.callee, 10);
  1977.                         return
  1978.                     }
  1979.                     b.removeChild(c);
  1980.                     h = null;
  1981.                     d()
  1982.                 })()
  1983.             } else d()
  1984.         } finally {
  1985.             window.onerror =
  1986.                 a
  1987.         }
  1988.     }
  1989.  
  1990.     function d() {
  1991.         var a = y.length;
  1992.         if (0 < a)
  1993.             for (var b = 0; b < a; b++) {
  1994.                 var c = y[b].id,
  1995.                     h = y[b].callbackFn,
  1996.                     m = {
  1997.                         success: !1,
  1998.                         id: c
  1999.                     };
  2000.                 if (0 < p.pv[0]) {
  2001.                     var e = v(c);
  2002.                     e && (D(y[b].swfVersion) && !(p.wk && 312 > p.wk) ? (C(c, !0), h && (m.success = !0, m.ref = k(c), h(m))) : (g(e), h && h(m)))
  2003.                 } else if (C(c, !0), h) {
  2004.                     if ((c = k(c)) && typeof c.SetVariable != w) m.success = !0, m.ref = c;
  2005.                     h(m)
  2006.                 }
  2007.             }
  2008.     }
  2009.  
  2010.     function k(a) {
  2011.         var b = null;
  2012.         if ((a = v(a)) && "OBJECT" == a.nodeName) typeof a.SetVariable != w ? b = a : (a = a.getElementsByTagName(A)[0]) && (b = a);
  2013.         return b
  2014.     }
  2015.  
  2016.     function g(a) {
  2017.         if (p.ie && p.win && 4 != a.readyState) {
  2018.             var b =
  2019.                 m.createElement("div");
  2020.             a.parentNode.insertBefore(b, a);
  2021.             b.parentNode.replaceChild(f(a), b);
  2022.             a.style.display = "none";
  2023.             (function() {
  2024.                 4 == a.readyState ? a.parentNode.removeChild(a) : setTimeout(arguments.callee, 10)
  2025.             })()
  2026.         } else a.parentNode.replaceChild(f(a), a)
  2027.     }
  2028.  
  2029.     function f(a) {
  2030.         var b = m.createElement("div");
  2031.         if (p.win && p.ie) b.innerHTML = a.innerHTML;
  2032.         else if (a = a.getElementsByTagName(A)[0])
  2033.             if (a = a.childNodes)
  2034.                 for (var c = a.length, h = 0; h < c; h++) !(1 == a[h].nodeType && "PARAM" == a[h].nodeName) && 8 != a[h].nodeType && b.appendChild(a[h].cloneNode(!0));
  2035.         return b
  2036.     }
  2037.  
  2038.     function n(a) {
  2039.         var b = v(a);
  2040.         b && "OBJECT" == b.nodeName && (p.ie && p.win ? (b.style.display = "none", function() {
  2041.             if (4 == b.readyState) {
  2042.                 var c = v(a);
  2043.                 if (c) {
  2044.                     for (var h in c) "function" == typeof c[h] && (c[h] = null);
  2045.                     c.parentNode.removeChild(c)
  2046.                 }
  2047.             } else setTimeout(arguments.callee, 10)
  2048.         }()) : b.parentNode.removeChild(b))
  2049.     }
  2050.  
  2051.     function v(a) {
  2052.         var b = null;
  2053.         try {
  2054.             b = m.getElementById(a)
  2055.         } catch (c) {}
  2056.         return b
  2057.     }
  2058.  
  2059.     function l(a, b, c) {
  2060.         a.attachEvent(b, c);
  2061.         t[t.length] = [a, b, c]
  2062.     }
  2063.  
  2064.     function D(a) {
  2065.         var b = p.pv;
  2066.         a = a.split(".");
  2067.         a[0] = parseInt(a[0], 10);
  2068.         a[1] = parseInt(a[1],
  2069.             10) || 0;
  2070.         a[2] = parseInt(a[2], 10) || 0;
  2071.         return b[0] > a[0] || b[0] == a[0] && b[1] > a[1] || b[0] == a[0] && b[1] == a[1] && b[2] >= a[2] ? !0 : !1
  2072.     }
  2073.  
  2074.     function q(a, b, c, h) {
  2075.         if (!p.ie || !p.mac) {
  2076.             var e = m.getElementsByTagName("head")[0];
  2077.             if (e) {
  2078.                 c = c && "string" == typeof c ? c : "screen";
  2079.                 h && (H = x = null);
  2080.                 if (!x || H != c) h = m.createElement("style"), h.setAttribute("type", "text/css"), h.setAttribute("media", c), x = e.appendChild(h), p.ie && (p.win && typeof m.styleSheets != w && 0 < m.styleSheets.length) && (x = m.styleSheets[m.styleSheets.length - 1]), H = c;
  2081.                 p.ie && p.win ? x && typeof x.addRule ==
  2082.                     A && x.addRule(a, b) : x && typeof m.createTextNode != w && x.appendChild(m.createTextNode(a + " {" + b + "}"))
  2083.             }
  2084.         }
  2085.     }
  2086.  
  2087.     function C(a, b) {
  2088.         if (R) {
  2089.             var c = b ? "visible" : "hidden";
  2090.             E && v(a) ? v(a).style.visibility = c : q("#" + a, "visibility:" + c)
  2091.         }
  2092.     }
  2093.     var w = "undefined",
  2094.         A = "object",
  2095.         r = "application/x-shockwave-flash",
  2096.         h = window,
  2097.         m = document,
  2098.         u = navigator,
  2099.         F = !1,
  2100.         s = [function() {
  2101.             F ? e() : d()
  2102.         }],
  2103.         y = [],
  2104.         B = [],
  2105.         t = [],
  2106.         E = !1,
  2107.         x, H, R = !0,
  2108.         p = function() {
  2109.             var a = typeof m.getElementById != w && typeof m.getElementsByTagName != w && typeof m.createElement != w,
  2110.                 b = u.userAgent.toLowerCase(),
  2111.                 c = u.platform.toLowerCase(),
  2112.                 e = c ? /win/.test(c) : /win/.test(b),
  2113.                 c = c ? /mac/.test(c) : /mac/.test(b),
  2114.                 b = /webkit/.test(b) ? parseFloat(b.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1,
  2115.                 d = !+"\v1",
  2116.                 s = [0, 0, 0],
  2117.                 f = null;
  2118.             if (typeof u.plugins != w && typeof u.plugins["Shockwave Flash"] == A) {
  2119.                 if ((f = u.plugins["Shockwave Flash"].description) && !(typeof u.mimeTypes != w && u.mimeTypes[r] && !u.mimeTypes[r].enabledPlugin)) F = !0, d = !1, f = f.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), s[0] = parseInt(f.replace(/^(.*)\..*$/, "$1"), 10), s[1] = parseInt(f.replace(/^.*\.(.*)\s.*$/, "$1"), 10),
  2120.                     s[2] = /[a-zA-Z]/.test(f) ? parseInt(f.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0
  2121.             } else if (typeof h.ActiveXObject != w) try {
  2122.                 var g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  2123.                 if (g && (f = g.GetVariable("$version"))) d = !0, f = f.split(" ")[1].split(","), s = [parseInt(f[0], 10), parseInt(f[1], 10), parseInt(f[2], 10)]
  2124.             } catch (k) {}
  2125.             return {
  2126.                 w3: a,
  2127.                 pv: s,
  2128.                 wk: b,
  2129.                 ie: d,
  2130.                 win: e,
  2131.                 mac: c
  2132.             }
  2133.         }();
  2134.     (function() {
  2135.         p.w3 && ((typeof m.readyState != w && "complete" == m.readyState || typeof m.readyState == w && (m.getElementsByTagName("body")[0] || m.body)) && a(), E || (typeof m.addEventListener !=
  2136.             w && m.addEventListener("DOMContentLoaded", a, !1), p.ie && p.win && (m.attachEvent("onreadystatechange", function() {
  2137.                 "complete" == m.readyState && (m.detachEvent("onreadystatechange", arguments.callee), a())
  2138.             }), h == top && function() {
  2139.                 if (!E) {
  2140.                     try {
  2141.                         m.documentElement.doScroll("left")
  2142.                     } catch (b) {
  2143.                         setTimeout(arguments.callee, 0);
  2144.                         return
  2145.                     }
  2146.                     a()
  2147.                 }
  2148.             }()), p.wk && function() {
  2149.                 E || (/loaded|complete/.test(m.readyState) ? a() : setTimeout(arguments.callee, 0))
  2150.             }(), b(a)))
  2151.     })();
  2152.     (function() {
  2153.         p.ie && p.win && window.attachEvent("onunload", function() {
  2154.             for (var a = t.length,
  2155.                     b = 0; b < a; b++) t[b][0].detachEvent(t[b][1], t[b][2]);
  2156.             a = B.length;
  2157.             for (b = 0; b < a; b++) n(B[b]);
  2158.             for (var c in p) p[c] = null;
  2159.             p = null;
  2160.             for (var h in kswfobject) kswfobject[h] = null;
  2161.             kswfobject = null
  2162.         })
  2163.     })();
  2164.     return {
  2165.         embedSWF: function(a, b, h, e, d, u, F, f, s, g) {
  2166.             var k = {
  2167.                 success: !1,
  2168.                 id: b
  2169.             };
  2170.             p.w3 && !(p.wk && 312 > p.wk) && a && b && h && e && d ? (C(b, !1), c(function() {
  2171.                 h += "";
  2172.                 e += "";
  2173.                 var c = {};
  2174.                 if (s && typeof s === A)
  2175.                     for (var u in s) c[u] = s[u];
  2176.                 c.data = a;
  2177.                 c.width = h;
  2178.                 c.height = e;
  2179.                 u = {};
  2180.                 if (f && typeof f === A)
  2181.                     for (var l in f) u[l] = f[l];
  2182.                 if (F && typeof F === A)
  2183.                     for (var y in F) u.flashvars =
  2184.                         typeof u.flashvars != w ? u.flashvars + ("&" + y + "=" + F[y]) : y + "=" + F[y];
  2185.                 if (D(d)) {
  2186.                     var q;
  2187.                     l = v(b);
  2188.                     if (!(p.wk && 312 > p.wk) && l)
  2189.                         if (typeof c.id == w && (c.id = b), p.ie && p.win) {
  2190.                             var n = "",
  2191.                                 z;
  2192.                             for (z in c) c[z] != Object.prototype[z] && ("data" == z.toLowerCase() ? u.movie = c[z] : "styleclass" == z.toLowerCase() ? n += ' class="' + c[z] + '"' : "classid" != z.toLowerCase() && (n += " " + z + '="' + c[z] + '"'));
  2193.                             z = "";
  2194.                             for (var t in u) u[t] != Object.prototype[t] && (z += '<param name="' + t + '" value="' + u[t] + '" />');
  2195.                             l.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
  2196.                                 n + ">" + z + "</object>";
  2197.                             B[B.length] = c.id;
  2198.                             q = v(c.id)
  2199.                         } else {
  2200.                             t = m.createElement(A);
  2201.                             t.setAttribute("type", r);
  2202.                             for (var x in c) c[x] != Object.prototype[x] && ("styleclass" == x.toLowerCase() ? t.setAttribute("class", c[x]) : "classid" != x.toLowerCase() && t.setAttribute(x, c[x]));
  2203.                             for (n in u) u[n] != Object.prototype[n] && "movie" != n.toLowerCase() && (z = t, x = n, q = u[n], y = m.createElement("param"), y.setAttribute("name", x), y.setAttribute("value", q), z.appendChild(y));
  2204.                             l.parentNode.replaceChild(t, l);
  2205.                             q = t
  2206.                         }
  2207.                     u = q;
  2208.                     c.id == b && C(b, !0);
  2209.                     k.success = !0;
  2210.                     k.ref =
  2211.                         u
  2212.                 } else C(b, !0);
  2213.                 g && g(k)
  2214.             })) : g && g(k)
  2215.         },
  2216.         ua: p,
  2217.         removeSWF: function(a) {
  2218.             p.w3 && n(a)
  2219.         },
  2220.         createCSS: function(a, b, c, h) {
  2221.             p.w3 && q(a, b, c, h)
  2222.         },
  2223.         addDomLoadEvent: c,
  2224.         addLoadEvent: b
  2225.     }
  2226. }();
  2227. ! function(a) {
  2228.     function c(a) {
  2229.         for (var b = 16; b--;) {
  2230.             var c = b << 2;
  2231.             n[b] = a.charCodeAt(c) + (a.charCodeAt(c + 1) << 8) + (a.charCodeAt(c + 2) << 16) + (a.charCodeAt(c + 3) << 24)
  2232.         }
  2233.     }
  2234.  
  2235.     function b(a, b, c, e, d, f, g) {
  2236.         b += a + e + g;
  2237.         return (b << d | b >>> f) + c << 0
  2238.     }
  2239.  
  2240.     function e(a) {
  2241.         k(0, 0, 0, 0, a);
  2242.         q[0] = r[0] + 1732584193 << 0;
  2243.         q[1] = r[1] - 271733879 << 0;
  2244.         q[2] = r[2] - 1732584194 << 0;
  2245.         q[3] = r[3] + 271733878 << 0
  2246.     }
  2247.  
  2248.     function d(a) {
  2249.         k(q[0], q[1], q[2], q[3], a);
  2250.         q[0] = r[0] + q[0] << 0;
  2251.         q[1] = r[1] + q[1] << 0;
  2252.         q[2] = r[2] + q[2] << 0;
  2253.         q[3] = r[3] + q[3] << 0
  2254.     }
  2255.  
  2256.     function k(a, c, e, d, f) {
  2257.         var g;
  2258.         C ? (a = b((e ^ d) & c ^ d, a, c, f[0], 7, 25, -680876936),
  2259.             d = b((c ^ e) & a ^ e, d, a, f[1], 12, 20, -389564586), e = b((a ^ c) & d ^ c, e, d, f[2], 17, 15, 606105819), c = b((d ^ a) & e ^ a, c, e, f[3], 22, 10, -1044525330)) : (a = f[0] - 680876937, a = (a << 7 | a >>> 25) - 271733879 << 0, d = f[1] - 117830708 + (2004318071 & a ^ -1732584194), d = (d << 12 | d >>> 20) + a << 0, e = f[2] - 1126478375 + ((a ^ -271733879) & d ^ -271733879), e = (e << 17 | e >>> 15) + d << 0, c = f[3] - 1316259209 + ((d ^ a) & e ^ a), c = (c << 22 | c >>> 10) + e << 0);
  2260.         a = b((e ^ d) & c ^ d, a, c, f[4], 7, 25, -176418897);
  2261.         d = b((c ^ e) & a ^ e, d, a, f[5], 12, 20, 1200080426);
  2262.         e = b((a ^ c) & d ^ c, e, d, f[6], 17, 15, -1473231341);
  2263.         c = b((d ^ a) & e ^ a, c, e,
  2264.             f[7], 22, 10, -45705983);
  2265.         a = b((e ^ d) & c ^ d, a, c, f[8], 7, 25, 1770035416);
  2266.         d = b((c ^ e) & a ^ e, d, a, f[9], 12, 20, -1958414417);
  2267.         e = b((a ^ c) & d ^ c, e, d, f[10], 17, 15, -42063);
  2268.         c = b((d ^ a) & e ^ a, c, e, f[11], 22, 10, -1990404162);
  2269.         a = b((e ^ d) & c ^ d, a, c, f[12], 7, 25, 1804603682);
  2270.         d = b((c ^ e) & a ^ e, d, a, f[13], 12, 20, -40341101);
  2271.         e = b((a ^ c) & d ^ c, e, d, f[14], 17, 15, -1502002290);
  2272.         c = b((d ^ a) & e ^ a, c, e, f[15], 22, 10, 1236535329);
  2273.         a = b((c ^ e) & d ^ e, a, c, f[1], 5, 27, -165796510);
  2274.         d = b((a ^ c) & e ^ c, d, a, f[6], 9, 23, -1069501632);
  2275.         e = b((d ^ a) & c ^ a, e, d, f[11], 14, 18, 643717713);
  2276.         c = b((e ^ d) & a ^ d, c, e, f[0], 20, 12, -373897302);
  2277.         a = b((c ^ e) & d ^ e, a, c, f[5], 5, 27, -701558691);
  2278.         d = b((a ^ c) & e ^ c, d, a, f[10], 9, 23, 38016083);
  2279.         e = b((d ^ a) & c ^ a, e, d, f[15], 14, 18, -660478335);
  2280.         c = b((e ^ d) & a ^ d, c, e, f[4], 20, 12, -405537848);
  2281.         a = b((c ^ e) & d ^ e, a, c, f[9], 5, 27, 568446438);
  2282.         d = b((a ^ c) & e ^ c, d, a, f[14], 9, 23, -1019803690);
  2283.         e = b((d ^ a) & c ^ a, e, d, f[3], 14, 18, -187363961);
  2284.         c = b((e ^ d) & a ^ d, c, e, f[8], 20, 12, 1163531501);
  2285.         a = b((c ^ e) & d ^ e, a, c, f[13], 5, 27, -1444681467);
  2286.         d = b((a ^ c) & e ^ c, d, a, f[2], 9, 23, -51403784);
  2287.         e = b((d ^ a) & c ^ a, e, d, f[7], 14, 18, 1735328473);
  2288.         c = b((e ^ d) & a ^ d, c, e, f[12], 20, 12, -1926607734);
  2289.         g = c ^ e;
  2290.         a = b(g ^ d, a, c, f[5], 4, 28, -378558);
  2291.         d = b(g ^ a, d, a, f[8], 11, 21, -2022574463);
  2292.         g = d ^ a;
  2293.         e = b(g ^ c, e, d, f[11], 16, 16, 1839030562);
  2294.         c = b(g ^ e, c, e, f[14], 23, 9, -35309556);
  2295.         g = c ^ e;
  2296.         a = b(g ^ d, a, c, f[1], 4, 28, -1530992060);
  2297.         d = b(g ^ a, d, a, f[4], 11, 21, 1272893353);
  2298.         g = d ^ a;
  2299.         e = b(g ^ c, e, d, f[7], 16, 16, -155497632);
  2300.         c = b(g ^ e, c, e, f[10], 23, 9, -1094730640);
  2301.         g = c ^ e;
  2302.         a = b(g ^ d, a, c, f[13], 4, 28, 681279174);
  2303.         d = b(g ^ a, d, a, f[0], 11, 21, -358537222);
  2304.         g = d ^ a;
  2305.         e = b(g ^ c, e, d, f[3], 16, 16, -722521979);
  2306.         c = b(g ^ e, c, e, f[6], 23, 9, 76029189);
  2307.         g = c ^ e;
  2308.         a = b(g ^ d, a, c, f[9], 4, 28, -640364487);
  2309.         d = b(g ^ a, d, a,
  2310.             f[12], 11, 21, -421815835);
  2311.         g = d ^ a;
  2312.         e = b(g ^ c, e, d, f[15], 16, 16, 530742520);
  2313.         c = b(g ^ e, c, e, f[2], 23, 9, -995338651);
  2314.         a = b(e ^ (c | ~d), a, c, f[0], 6, 26, -198630844);
  2315.         d = b(c ^ (a | ~e), d, a, f[7], 10, 22, 1126891415);
  2316.         e = b(a ^ (d | ~c), e, d, f[14], 15, 17, -1416354905);
  2317.         c = b(d ^ (e | ~a), c, e, f[5], 21, 11, -57434055);
  2318.         a = b(e ^ (c | ~d), a, c, f[12], 6, 26, 1700485571);
  2319.         d = b(c ^ (a | ~e), d, a, f[3], 10, 22, -1894986606);
  2320.         e = b(a ^ (d | ~c), e, d, f[10], 15, 17, -1051523);
  2321.         c = b(d ^ (e | ~a), c, e, f[1], 21, 11, -2054922799);
  2322.         a = b(e ^ (c | ~d), a, c, f[8], 6, 26, 1873313359);
  2323.         d = b(c ^ (a | ~e), d, a, f[15], 10, 22, -30611744);
  2324.         e =
  2325.             b(a ^ (d | ~c), e, d, f[6], 15, 17, -1560198380);
  2326.         c = b(d ^ (e | ~a), c, e, f[13], 21, 11, 1309151649);
  2327.         a = b(e ^ (c | ~d), a, c, f[4], 6, 26, -145523070);
  2328.         d = b(c ^ (a | ~e), d, a, f[11], 10, 22, -1120210379);
  2329.         e = b(a ^ (d | ~c), e, d, f[2], 15, 17, 718787259);
  2330.         c = b(d ^ (e | ~a), c, e, f[9], 21, 11, -343485551);
  2331.         r[0] = a;
  2332.         r[1] = c;
  2333.         r[2] = e;
  2334.         r[3] = d
  2335.     }
  2336.     var g = [],
  2337.         f = [],
  2338.         n = [],
  2339.         v = [],
  2340.         l = "0123456789abcdef".split(""),
  2341.         D = [],
  2342.         q = [],
  2343.         C = !1,
  2344.         w = 0,
  2345.         A = 0,
  2346.         r = [];
  2347.     if (a.Int32Array) f = new Int32Array(16), n = new Int32Array(16), v = new Int32Array(4), D = new Int32Array(4), q = new Int32Array(4), r = new Int32Array(4);
  2348.     else {
  2349.         for (a = 0; 16 >
  2350.             a; a++) f[a] = n[a] = 0;
  2351.         for (a = 0; 4 > a; a++) v[a] = D[a] = q[a] = r[a] = 0
  2352.     }
  2353.     v[0] = 128;
  2354.     v[1] = 32768;
  2355.     v[2] = 8388608;
  2356.     v[3] = -2147483648;
  2357.     D[0] = 0;
  2358.     D[1] = 8;
  2359.     D[2] = 16;
  2360.     D[3] = 24;
  2361.     Kongregate.Utils.md5 = function(a, b, k) {
  2362.         if (!b) {
  2363.             for (var r = b = "", s = 0, y = 0, B = 0, t = a.length; B < t; B++) r = a.charCodeAt(B), 128 > r ? y++ : (r = 2048 > r ? String.fromCharCode(r >> 6 | 192, r & 63 | 128) : String.fromCharCode(r >> 12 | 224, r >> 6 & 63 | 128, r & 63 | 128), y > s && (b += a.slice(s, y)), b += r, s = y = B + 1);
  2364.             y > s && (b += a.slice(s, t));
  2365.             a = b
  2366.         }
  2367.         a += "";
  2368.         C = !1;
  2369.         w = A = a.length;
  2370.         if (63 < A) {
  2371.             c(a.substring(0, 64));
  2372.             e(n);
  2373.             C = !0;
  2374.             for (b = 128; b <= A; b +=
  2375.                 64) c(a.substring(b - 64, b)), d(n);
  2376.             a = a.substring(b - 64);
  2377.             A = a.length
  2378.         }
  2379.         for (b = f[0] = f[1] = f[2] = f[3] = f[4] = f[5] = f[6] = f[7] = f[8] = f[9] = f[10] = f[11] = f[12] = f[13] = f[14] = f[15] = 0; b < A; b++) s = b & 3, f[b >> 2] = 0 === s ? a.charCodeAt(b) : f[b >> 2] | a.charCodeAt(b) << D[s];
  2380.         f[b >> 2] |= v[b & 3];
  2381.         55 < b ? (C ? d(f) : (e(f), C = !0), d([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, w << 3, 0])) : (f[14] = w << 3, C ? d(f) : e(f));
  2382.         a = q[0];
  2383.         g[1] = l[a & 15];
  2384.         g[0] = l[(a >>= 4) & 15];
  2385.         g[3] = l[(a >>= 4) & 15];
  2386.         g[2] = l[(a >>= 4) & 15];
  2387.         g[5] = l[(a >>= 4) & 15];
  2388.         g[4] = l[(a >>= 4) & 15];
  2389.         g[7] = l[(a >>= 4) & 15];
  2390.         g[6] = l[a >> 4 & 15];
  2391.         a = q[1];
  2392.         g[9] = l[a &
  2393.             15];
  2394.         g[8] = l[(a >>= 4) & 15];
  2395.         g[11] = l[(a >>= 4) & 15];
  2396.         g[10] = l[(a >>= 4) & 15];
  2397.         g[13] = l[(a >>= 4) & 15];
  2398.         g[12] = l[(a >>= 4) & 15];
  2399.         g[15] = l[(a >>= 4) & 15];
  2400.         g[14] = l[a >> 4 & 15];
  2401.         a = q[2];
  2402.         g[17] = l[a & 15];
  2403.         g[16] = l[(a >>= 4) & 15];
  2404.         g[19] = l[(a >>= 4) & 15];
  2405.         g[18] = l[(a >>= 4) & 15];
  2406.         g[21] = l[(a >>= 4) & 15];
  2407.         g[20] = l[(a >>= 4) & 15];
  2408.         g[23] = l[(a >>= 4) & 15];
  2409.         g[22] = l[a >> 4 & 15];
  2410.         a = q[3];
  2411.         g[25] = l[a & 15];
  2412.         g[24] = l[(a >>= 4) & 15];
  2413.         g[27] = l[(a >>= 4) & 15];
  2414.         g[26] = l[(a >>= 4) & 15];
  2415.         g[29] = l[(a >>= 4) & 15];
  2416.         g[28] = l[(a >>= 4) & 15];
  2417.         g[31] = l[(a >>= 4) & 15];
  2418.         g[30] = l[a >> 4 & 15];
  2419.         return k ? g : g.join("")
  2420.     }
  2421. }("undefined" === typeof global ?
  2422.     window : global);
  2423. Kongregate.MicrotransactionServices = function(a) {
  2424.     this.initialize(a)
  2425. };
  2426. Kongregate.MicrotransactionServices.prototype = {
  2427.     initialize: function(a) {
  2428.         var c = this;
  2429.         this._services = a.services;
  2430.         this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
  2431.             c._onIncomingMessage(a.opcode, a.params)
  2432.         });
  2433.         this._adCallbacks = []
  2434.     },
  2435.     requestItemList: function(a, c) {
  2436.         Kongregate.Log.info("MicrotransactionServices.requestItemList(" + a + ")");
  2437.         params = {};
  2438.         a && 0 < a.length && (params[KonduitEvent.PARAM_ITEM_TAGS] = a);
  2439.         this._services._enqueueRequest(params, c);
  2440.         this._services.sendMessage({
  2441.             opcode: KonduitEvent.ITEM_LIST,
  2442.             params: params
  2443.         })
  2444.     },
  2445.     requestUserItemList: function(a, c) {
  2446.         Kongregate.Log.info("MicrotransactionServices.requestUserItemList(" + a + ")");
  2447.         params = {};
  2448.         params[KonduitEvent.PARAM_USER] = a || this._services.getUsername();
  2449.         this._services._enqueueRequest(params, c);
  2450.         this._services.sendMessage({
  2451.             opcode: KonduitEvent.ITEM_INSTANCES,
  2452.             params: params
  2453.         })
  2454.     },
  2455.     purchaseItems: function(a, c) {
  2456.         Kongregate.Log.info("MicrotransactionServices.purchaseItems(" + a + ")");
  2457.         params = {};
  2458.         a && 0 < a.length ? (this._purchaseItemsCallback = c, params[KonduitEvent.PARAM_ITEMS] =
  2459.             a, this._services.sendMessage({
  2460.                 opcode: KonduitEvent.ITEM_CHECKOUT,
  2461.                 params: params
  2462.             })) : (Kongregate.Log.error("purchaseItems requires a non-empty item identifier array"), c && c({
  2463.             success: !1
  2464.         }))
  2465.     },
  2466.     purchaseItemsRemote: function(a, c) {
  2467.         Kongregate.Log.info("MicrotransactionServices.purchaseItemsRemote(" + a + ")");
  2468.         params = {};
  2469.         a && 0 < a.length ? (this._purchaseItemsCallback = c, params[KonduitEvent.PARAM_ORDER_INFO] = a, this._services.sendMessage({
  2470.             opcode: KonduitEvent.ITEM_CHECKOUT,
  2471.             params: params
  2472.         })) : (Kongregate.Log.error("purchaseItemsRemote requires an orderInformation string"),
  2473.             c && c({
  2474.                 success: !1
  2475.             }))
  2476.     },
  2477.     useItemInstance: function(a, c) {
  2478.         Kongregate.Log.info("MicrotransactionServices.useItemInstance(" + a + ")");
  2479.         params = {};
  2480.         a ? (params[KonduitEvent.PARAM_ID] = a, this._services._enqueueRequest(params, c), this._services.sendMessage({
  2481.             opcode: KonduitEvent.USE_ITEM_INSTANCE,
  2482.             params: params
  2483.         })) : (Kongregate.Log.error("useItemInstance requires an itemInstanceId"), c && c({
  2484.             success: !1
  2485.         }))
  2486.     },
  2487.     showKredPurchaseDialog: function(a) {
  2488.         params = {};
  2489.         params[KonduitEvent.PARAM_PURCHASE_METHOD] = a;
  2490.         this._services.sendMessage({
  2491.             opcode: KonduitEvent.PURCHASE_KREDS,
  2492.             params: params
  2493.         })
  2494.     },
  2495.     initializeIncentivizedAds: function() {
  2496.         this._services.sendMessage({
  2497.             opcode: KonduitEvent.ADS_INITIALIZE
  2498.         })
  2499.     },
  2500.     showIncentivizedAd: function() {
  2501.         this._services.sendMessage({
  2502.             opcode: KonduitEvent.ADS_SHOW_INCENTIVIZED
  2503.         })
  2504.     },
  2505.     addEventListener: function(a, c) {
  2506.         "function" !== typeof c ? Kongregate.Log.error("addEventListener requires a callback function") : (this._adCallbacks[a] || (this._adCallbacks[a] = []), this._adCallbacks[a].push(c))
  2507.     },
  2508.     _onIncomingMessage: function(a, c) {
  2509.         switch (a) {
  2510.             case KonduitEvent.ITEM_INSTANCES:
  2511.             case KonduitEvent.ITEM_LIST:
  2512.             case KonduitEvent.USE_ITEM_INSTANCE:
  2513.                 this._services._completeRequest(c);
  2514.                 break;
  2515.             case KonduitEvent.PURCHASE_RESULT:
  2516.                 this._onPurchaseResultResponse(c);
  2517.                 break;
  2518.             case KonduitEvent.ADS_AVAILABLE:
  2519.                 this._handleAdEvent("adsAvailable", c);
  2520.                 break;
  2521.             case KonduitEvent.ADS_UNAVAILABLE:
  2522.                 this._handleAdEvent("adsUnavailable", c);
  2523.                 break;
  2524.             case KonduitEvent.AD_OPENED:
  2525.                 this._handleAdEvent("adOpened", c);
  2526.                 break;
  2527.             case KonduitEvent.AD_COMPLETED:
  2528.                 this._handleAdEvent("adCompleted", c);
  2529.                 break;
  2530.             case KonduitEvent.AD_ABANDONED:
  2531.                 this._handleAdEvent("adAbandoned", c)
  2532.         }
  2533.     },
  2534.     _onPurchaseResultResponse: function(a) {
  2535.         this._purchaseItemsCallback &&
  2536.             (this._purchaseItemsCallback(a), this._purchaseItemsCallback = null)
  2537.     },
  2538.     _handleAdEvent: function(a, c) {
  2539.         var b = this._adCallbacks[a];
  2540.         if (b)
  2541.             for (var e = 0; e < b.length; e++) b[e](c)
  2542.     }
  2543. };
  2544. Kongregate.SharedContentServices = function(a) {
  2545.     this.initialize(a)
  2546. };
  2547. Kongregate.SharedContentServices.CONTENT_TYPE_LIMIT = 12;
  2548. Kongregate.SharedContentServices.prototype = {
  2549.     initialize: function(a) {
  2550.         var c = this;
  2551.         this._services = a.services;
  2552.         this._loadListeners = {};
  2553.         this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
  2554.             c._onIncomingMessage(a.opcode, a.params)
  2555.         })
  2556.     },
  2557.     browse: function(a, c, b) {
  2558.         var e = {};
  2559.         e[KonduitEvent.PARAM_CONTENT_TYPE] = a;
  2560.         b && (e[KonduitEvent.PARAM_LABEL] = b);
  2561.         c && (e[KonduitEvent.PARAM_SORT] = c);
  2562.         this._services.sendMessage({
  2563.             opcode: KonduitEvent.OP_BROWSE_SHARED_CONTENT,
  2564.             params: e
  2565.         })
  2566.     },
  2567.     save: function(a, c, b, e, d) {
  2568.         if (this._saving ||
  2569.             a.length > Kongregate.SharedContentServices.CONTENT_TYPE_LIMIT) b && b({
  2570.             success: !1
  2571.         });
  2572.         else {
  2573.             var k = {};
  2574.             k[KonduitEvent.PARAM_CONTENT_TYPE] = a;
  2575.             k[KonduitEvent.PARAM_LABEL] = d;
  2576.             k[KonduitEvent.PARAM_DATA] = c;
  2577.             k[KonduitEvent.PARAM_IMAGE] = e;
  2578.             this._services.sendMessage({
  2579.                 opcode: KonduitEvent.OP_SAVE_SHARED_CONTENT,
  2580.                 params: k
  2581.             });
  2582.             this._saving = !0;
  2583.             this._saveCallback = b
  2584.         }
  2585.     },
  2586.     addLoadListener: function(a, c) {
  2587.         this._loadListeners[a] || (this._loadListeners[a] = []);
  2588.         this._loadListeners[a].push(c)
  2589.     },
  2590.     _onIncomingMessage: function(a, c) {
  2591.         switch (a) {
  2592.             case KonduitEvent.OP_SHARED_CONTENT_SAVE_COMPLETE:
  2593.                 this._onSaveContentComplete(c);
  2594.                 break;
  2595.             case KonduitEvent.OP_LOAD_SHARED_CONTENT:
  2596.                 this._onLoadSharedContent(c)
  2597.         }
  2598.     },
  2599.     _onSaveContentComplete: function(a) {
  2600.         this._saving = !1;
  2601.         this._saveCallback && (this._saveCallback(a), this._saveCallback = null)
  2602.     },
  2603.     _onLoadSharedContent: function(a) {
  2604.         var c = a.contentType;
  2605.         a = {
  2606.             id: a.id,
  2607.             name: a.name,
  2608.             permalink: a.permalink,
  2609.             content: a.content,
  2610.             label: a.label
  2611.         };
  2612.         Kongregate.Log.info({
  2613.             loadContent: a
  2614.         });
  2615.         for (var c = this._loadListeners[c] || [], b = 0; b < c.length; b++) c[b](a)
  2616.     }
  2617. };
  2618. Kongregate.StatisticServices = function(a) {
  2619.     this.initialize(a)
  2620. };
  2621. Kongregate.StatisticServices.prototype = {
  2622.     initialize: function(a) {
  2623.         this._services = a.services
  2624.     },
  2625.     submit: function(a, c) {
  2626.         Kongregate.Log.info("StatServices.submit(" + a + "," + c + ")");
  2627.         !a || null === c || void 0 === c || isNaN(c) ? Kongregate.Log.warn("Invalid stat name or value:", a, c) : this._services.sendMessage({
  2628.             opcode: KonduitEvent.OP_STATS_SUBMIT,
  2629.             params: {
  2630.                 stats: [{
  2631.                     name: a,
  2632.                     value: c
  2633.                 }]
  2634.             }
  2635.         })
  2636.     },
  2637.     submitArray: function(a) {
  2638.         if (a && a.length)
  2639.             for (var c = 0; c < a.length; c++) this.submit(a[c].name, a[c].value)
  2640.     }
  2641. };
  2642. (function() {
  2643.     Kongregate.SwrveClient = function(a) {
  2644.         this.initialize(a)
  2645.     };
  2646.     var a = Kongregate.SwrveClient;
  2647.     Kongregate.SwrveClient.prototype = {
  2648.         initialize: function(a) {
  2649.             this._applicationId = a.application_id;
  2650.             this._apiKey = a.api_key;
  2651.             this._playerId = a.player_id;
  2652.             this._clientVersion = a.client_version
  2653.         },
  2654.         sendEvents: function(a, c) {
  2655.             var d = new XMLHttpRequest,
  2656.                 k = a.length,
  2657.                 g = this,
  2658.                 f = function(d) {
  2659.                     g._onError(a, k, d, c)
  2660.                 };
  2661.             d.open("POST", "//" + this._applicationId + ".api.swrve.com/1/batch");
  2662.             d.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  2663.             d.onerror = d.onabort = f;
  2664.             d.onload = function() {
  2665.                 g._onBatchResponse(d, a, k, c, f)
  2666.             };
  2667.             "undefined" !== typeof d.timeout && (d.timeout = 3E4, d.ontimeout = f);
  2668.             d.send(JSON.stringify(this._createPayload(a)))
  2669.         },
  2670.         _onBatchResponse: function(a, c, d, k, g) {
  2671.             var f = !1;
  2672.             if (200 === a.status) {
  2673.                 var n = a.responseText;
  2674.                 (f = 0 === n.length) || (f = 200 === JSON.parse(n).code)
  2675.             }
  2676.             f ? (Kongregate.Log.debug("SWRVE submission complete, " + d + " event(s)"), c.splice(0, d), k && k({
  2677.                 success: !0
  2678.             })) : (Kongregate.Log.error("Error while parsing swrve result: " + a.status + ", removing " +
  2679.                 d + " event(s)"), g(!0))
  2680.         },
  2681.         _onError: function(a, c, d, k) {
  2682.             for (var g = 0; g < c && g < a.length; g++) {
  2683.                 var f = a[g];
  2684.                 if (f) {
  2685.                     var n = (f.event.retry_count || 0) + (d ? this._maxRetries() + 1 : 1);
  2686.                     f.event.retry_count = n
  2687.                 }
  2688.             }
  2689.             this._pruneEvents(a);
  2690.             k && k({
  2691.                 success: !1
  2692.             })
  2693.         },
  2694.         _createPayload: function(b) {
  2695.             for (var c = {
  2696.                     app_version: this._clientVersion,
  2697.                     session_token: this._createSessionToken(),
  2698.                     user: this._playerId
  2699.                 }, d = [], k = 0; k < b.length; k++) {
  2700.                 var g = b[k],
  2701.                     f = g.name,
  2702.                     n = this._getTime(g),
  2703.                     g = Kongregate.Utils.merge({}, g.event);
  2704.                 this._removeTransientProperties(g);
  2705.                 a.SWRVE_SESSION_START_IDENTIFIER ===
  2706.                     f ? d.push({
  2707.                         type: "session_start",
  2708.                         time: n
  2709.                     }) : a.SWRVE_USER_IDENTIFIER === f ? d.push({
  2710.                         type: "user",
  2711.                         time: n,
  2712.                         attributes: g
  2713.                     }) : a.SWRVE_IAP_IDENTIFIER === f ? d.push(Kongregate.Utils.merge({
  2714.                         type: "iap",
  2715.                         time: n
  2716.                     }, g)) : 0 === f.indexOf("swrve.") ? (f = f.replace("swrve.", "Kongregate."), d.push({
  2717.                         type: "event",
  2718.                         name: f,
  2719.                         time: n,
  2720.                         payload: g
  2721.                     })) : (f = "Kongregate.RawData." + f, d.push({
  2722.                         type: "event",
  2723.                         name: f,
  2724.                         time: n,
  2725.                         payload: {
  2726.                             data: JSON.stringify(g)
  2727.                         }
  2728.                     }))
  2729.             }
  2730.             c.data = d;
  2731.             return c
  2732.         },
  2733.         _pruneEvents: function(a) {
  2734.             for (var c = a.length - 1; 0 <= c; c--) a[c].event && a[c].event.retry_count >
  2735.                 this._maxRetries() && (Kongregate.Log.debug("Event " + a[c].name + " is over max retry count, deleting it"), a.splice(c, 1));
  2736.             c = this._maxBacklogSize();
  2737.             a && a.length > c && a.splice(0, a.length - c)
  2738.         },
  2739.         _removeTransientProperties: function(a) {
  2740.             for (var e = 0; e < c.length; e++) {
  2741.                 var d = c[e];
  2742.                 void 0 !== a[d] && delete a[d]
  2743.             }
  2744.         },
  2745.         _createSessionToken: function() {
  2746.             var a = Math.floor(this._getDate().getTime() / 1E3);
  2747.             return this._applicationId + "=" + this._playerId + "=" + String(a) + "=" + Kongregate.Utils.md5(this._playerId + String(a) + this._apiKey)
  2748.         },
  2749.         _maxRetries: function() {
  2750.             return 2
  2751.         },
  2752.         _maxBacklogSize: function() {
  2753.             return 100
  2754.         },
  2755.         _getDate: function() {
  2756.             return new Date
  2757.         },
  2758.         _getTime: function(a) {
  2759.             var c = this._getDate();
  2760.             a.event && a.event[Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME] && (c = Kongregate.Utils.parseW3CDTF(a.event[Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME], this._getDate()));
  2761.             return Math.floor(c.getTime() / 1E3)
  2762.         }
  2763.     };
  2764.     a.SWRVE_EVENT_IDENTIFIER = "swrve.";
  2765.     a.SWRVE_BARE_EVENT_IDENTIFIER = a.SWRVE_EVENT_IDENTIFIER + "__bare_";
  2766.     a.SWRVE_SESSION_START_IDENTIFIER = a.SWRVE_BARE_EVENT_IDENTIFIER +
  2767.         "session_start";
  2768.     a.SWRVE_USER_IDENTIFIER = a.SWRVE_BARE_EVENT_IDENTIFIER + "user";
  2769.     a.SWRVE_IAP_IDENTIFIER = a.SWRVE_BARE_EVENT_IDENTIFIER + "iap";
  2770.     var c = ["auto_event", "retry_count"]
  2771. })();
  2772. (function() {
  2773.     Kongregate.Utils.merge = function(a, b) {
  2774.         if (!a || !b) return a;
  2775.         for (var e in b) b.hasOwnProperty(e) && (a[e] = b[e]);
  2776.         return a
  2777.     };
  2778.     Kongregate.Utils.toW3CDTF = function(a) {
  2779.         function b(a) {
  2780.             return 10 > a ? "0" + a : a
  2781.         }
  2782.         return !(a instanceof Date) ? "" : a.getUTCFullYear() + "-" + b(a.getUTCMonth() + 1) + "-" + b(a.getUTCDate()) + "T" + b(a.getUTCHours()) + ":" + b(a.getUTCMinutes()) + ":" + b(a.getUTCSeconds()) + "." + (a.getUTCMilliseconds() / 1E3).toFixed(3).slice(2, 5) + "-00:00"
  2783.     };
  2784.     Kongregate.Utils.parseW3CDTF = function(c, b) {
  2785.         var e;
  2786.         try {
  2787.             var d, k = 0,
  2788.                 g = [1, 4,
  2789.                     5, 6, 7, 10, 11
  2790.                 ];
  2791.             if (d = a.exec(c)) {
  2792.                 for (var f = 0, n; n = g[f]; ++f) d[n] = +d[n] || 0;
  2793.                 d[2] = (+d[2] || 1) - 1;
  2794.                 d[3] = +d[3] || 1;
  2795.                 "Z" !== d[8] && void 0 !== d[9] && (k = 60 * d[10] + d[11], "+" === d[9] && (k = 0 - k));
  2796.                 e = new Date(Date.UTC(d[1], d[2], d[3], d[4], d[5] + k, d[6], d[7]))
  2797.             }
  2798.             if (!e || "Invalid Date" === e.toString()) throw Error("This date does not conform to W3CDTF.");
  2799.         } catch (v) {
  2800.             return e = "Unable to parse the string [" + c + "] into a date. " + ("The internal error was: " + v.toString()), Kongregate.Log.error(e), b
  2801.         }
  2802.         return e
  2803.     };
  2804.     var a = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/
  2805. })();
  2806. "undefined" == typeof kongregateUnitySupport && (kongregateUnitySupport = function() {
  2807.     function a(a) {
  2808.         a = g.getElementById(a);
  2809.         if (!a) return null;
  2810.         var b;
  2811.         l.win && l.ie ? (a = a.getElementsByTagName("object")[0]) && "OBJECT" == a.nodeName && (b = a) : (a = a.getElementsByTagName("embed")[0]) && "EMBED" == a.nodeName && (b = a);
  2812.         return b && typeof b.GetPluginVersion == d ? null : b
  2813.     }
  2814.  
  2815.     function c() {
  2816.         if ("function" === typeof window.SendMessage) return window;
  2817.         var b = "kongregateUnityDiv";
  2818.         typeof kongregateAPI != d && kongregateAPI.unityElementId && (b = kongregateAPI.unityElementId);
  2819.         return a(b) || a("unityPlayer")
  2820.     }
  2821.  
  2822.     function b() {
  2823.         return [kongregate.services.getUserId(), kongregate.services.getUsername(), kongregate.services.getGameAuthToken()].join("|")
  2824.     }
  2825.     var e = [],
  2826.         d = "undefined",
  2827.         k = navigator,
  2828.         g = document,
  2829.         f = k.userAgent,
  2830.         k = k.platform,
  2831.         n = !1,
  2832.         v = /chrome/i.test(f);
  2833.     /msie/i.test(f) ? n = parseFloat(f.replace(/^.*msie ([0-9]+(\.[0-9]+)?).*$/i, "$1")) : /Trident/i.test(f) && (n = parseFloat(f.replace(/^.*rv:([0-9]+(\.[0-9]+)?).*$/i, "$1")));
  2834.     var l = {
  2835.         w3: typeof g.getElementById != d && typeof g.getElementsByTagName != d && typeof g.createElement !=
  2836.             d,
  2837.         win: k ? /win/i.test(k) : /win/i.test(f),
  2838.         mac: k ? /mac/i.test(k) : /mac/i.test(f),
  2839.         ie: n,
  2840.         ff: /firefox/i.test(f),
  2841.         op: /opera/i.test(f),
  2842.         ch: v,
  2843.         ch_v: /chrome/i.test(f) ? parseFloat(f.replace(/^.*chrome\/(\d+(\.\d+)?).*$/i, "$1")) : !1,
  2844.         sf: /safari/i.test(f) && !v,
  2845.         wk: /webkit/i.test(f) ? parseFloat(f.replace(/^.*webkit\/(\d+(\.\d+)?).*$/i, "$1")) : !1,
  2846.         x64: /win64/i.test(f) && /x64/i.test(f),
  2847.         moz: /mozilla/i.test(f) ? parseFloat(f.replace(/^.*mozilla\/([0-9]+(\.[0-9]+)?).*$/i, "$1")) : 0,
  2848.         mobile: /ipad/i.test(k) || /iphone/i.test(k) || /ipod/i.test(k) ||
  2849.             /android/i.test(f) || /windows phone/i.test(f)
  2850.     };
  2851.     l.clientBrand = l.ch ? "ch" : l.ff ? "ff" : l.sf ? "sf" : l.ie ? "ie" : l.op ? "op" : "??";
  2852.     l.clientPlatform = l.win ? "win" : l.mac ? "mac" : "???";
  2853.     return {
  2854.         onUnityEmbed: function(a) {
  2855.             $("unity_missing") && (a.success ? "missingUnityObject" == a.id ? ($("missingUnityObject").update(""), $("kongregateUnityDiv").update(""), top.location.replace(decodeURIComponent(kongregateAPI.getVariable("kongregate_game_url")))) : $("unity_missing").remove() : $("unity_missing").show())
  2856.         },
  2857.         initAPI: function(a, d) {
  2858.             e.push({
  2859.                 object: a ||
  2860.                     "KongregateAPI",
  2861.                 callback: d || "OnKongregateAPILoaded"
  2862.             });
  2863.             kongregateAPI.loadAPI(function() {
  2864.                 "undefined" === typeof kongregate && (kongregate = kongregateAPI.getAPI());
  2865.                 for (var a = 0; a < e.length; a++) {
  2866.                     var d = e[a];
  2867.                     c().SendMessage(d.object, d.callback, b())
  2868.                 }
  2869.                 e = []
  2870.             })
  2871.         },
  2872.         getUnityObject: function() {
  2873.             return c()
  2874.         },
  2875.         getUserInfoString: function() {
  2876.             return b()
  2877.         },
  2878.         hijackUnityErrorHandler: function() {
  2879.             if (!kongregateAPI.disableUnityErrorHandler) {
  2880.                 var a = window.Module;
  2881.                 if (a && a.TOTAL_MEMORY && a.codeUrl) {
  2882.                     var b = a.errorhandler;
  2883.                     a.errorhandler = function(a,
  2884.                         c, d) {
  2885.                         if (a.match(/Permission denied to access property/)) {
  2886.                             try {
  2887.                                 console.error("Caught error: " + a)
  2888.                             } catch (e) {}
  2889.                             return !0
  2890.                         }
  2891.                         return "function" === typeof b && b(a, c, d)
  2892.                     }
  2893.                 }
  2894.             }
  2895.         }
  2896.     }
  2897. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement