// Generated by Construct 2, the HTML5 game and app creator :: http://www.scirra.com
//////////////////////////////////////
// COCOONJS.JS                      //
//////////////////////////////////////

(function()
{
	// There should not be a CocoonJS object when this code is executed.
	// if (typeof window.CocoonJS !== 'undefined') throw("This is strange, a CocoonJS object already exists when trying to create it.");

    /**
    * The basic object for all the CocoonJS related specific APIs === extensions.
    * @namespace
    */
    CocoonJS = window.CocoonJS ? window.CocoonJS : {};

	CocoonJS.nativeExtensionObjectAvailable = typeof window.ext !== 'undefined';

	/**
	* This type represents a 2D size structure with horizontal and vertical values.
	* @namespace
	*/
	CocoonJS.Size = {
		/**
		* The horizontal size value.
		*/
		width : 0,

		/**
		* The vertical size value.
		*/
		height : 0
	};

	/**
	* This utility function allows to create an object oriented like hierarchy between two functions using their prototypes.
	* This function adds a "superclass" and a "__super" attributes to the subclass and it's functions to reference the super class.
	* @param {function} subc The subclass function.
	* @param {function} superc The superclass function.
	*/
	CocoonJS.extend = function(subc, superc) {
	    var subcp = subc.prototype;

	    // Class pattern.
	    var CocoonJSExtendHierarchyChainClass = function() {};
	    CocoonJSExtendHierarchyChainClass.prototype = superc.prototype;

	    subc.prototype = new CocoonJSExtendHierarchyChainClass();       // chain prototypes.
	    subc.superclass = superc.prototype;
	    subc.prototype.constructor = subc;

	    // Reset constructor. See Object Oriented Javascript for an in-depth explanation of this.
	    if (superc.prototype.constructor === Object.prototype.constructor) {
	        superc.prototype.constructor = superc;
	    }

	    // Check all the elements in the subclass prototype and add them to the chain object's prototype.
	    for (var method in subcp) {
	        if (subcp.hasOwnProperty(method)) {
	            subc.prototype[method] = subcp[method];

	            // // tenemos en super un metodo con igual nombre.
	            // if ( superc.prototype[method]) 
	            // {
	            //     subc.prototype[method]= (function(fn, fnsuper) 
	            //     {
	            //         return function() 
	            //         {
	            //             var prevMethod= this.__super;

	            //             this.__super= fnsuper;

	            //             var retValue= fn.apply(
	            //                     this,
	            //                     Array.prototype.slice.call(arguments) );

	            //             this.__super= prevMethod;

	            //             return retValue;
	            //         };
	            //     })(subc.prototype[method], superc.prototype[method]);
	            // }
	        }
	    }
	}

	/**
	* IMPORTANT: This function should only be used by Ludei.
	* This function allows a call to the native extension object function reusing the same arguments object.
	* Why is interesting to use this function instead of calling the native object's function directly?
	* As the CocoonJS object functions expicitly receive parameters, if they are not present and the native call is direcly mapped,
	* undefined arguments are passed to the native side. Some native functions do not check the parameters validation
	* correctly (just check the number of parameters passed).
	* Another solution instead of using this function call is to correctly check if the parameters are valid (not undefined) to make the
	* call, but it takes more work than using this approach.
	* @static
	* @param {string} nativeExtensionObjectName The name of the native extension object name. The object that is a member of the 'ext' object.
	* @param {string} nativeFunctionName The name of the function to be called inside the native extension object.
	* @param {object} arguments The arguments object of the CocoonJS extension object function. It contains all the arguments passed to the CocoonJS extension object function and these are the ones that will be passed to the native call too.
	* @param {boolean} [async] A flag to indicate if the makeCall (false or undefined) or the makeCallAsync function should be used to perform the native call.
	* @returns Whatever the native function call returns.
	*/
	CocoonJS.makeNativeExtensionObjectFunctionCall = function(nativeExtensionObjectName, nativeFunctionName, args, async) {
		if (CocoonJS.nativeExtensionObjectAvailable) {
			var argumentsArray = Array.prototype.slice.call(args);
			argumentsArray.unshift(nativeFunctionName);
			var nativeExtensionObject = ext[nativeExtensionObjectName];
			var makeCallFunction = async ? nativeExtensionObject.makeCallAsync : nativeExtensionObject.makeCall;
			var ret = makeCallFunction.apply(nativeExtensionObject, argumentsArray);
			var finalRet = ret;
			if (typeof ret === "string") {
				try	{
					finalRet = JSON.parse(ret);
				}
				catch(error) {
				}
			}
			return finalRet;
		}
	};

	/**
	* Returns an object retrieved from a path specified by a dot specified text path starting from a given base object.
	* It could be useful to find the reference of an object from a defined base object. For example the base object could be window and the
	* path could be "CocoonJS.App" or "document.body".
	* @param {Object} baseObject The object to start from to find the object using the given text path.
	* @param {string} objectPath The path in the form of a text using the dot notation. i.e. "document.body"
	* For example:
	* var body = getObjectFromPath(window, "document.body");
	*/
	CocoonJS.getObjectFromPath = function(baseObject, objectPath) {
    	var parts = objectPath.split('.');
    	var obj = baseObject;
        for (var i = 0, len = parts.length; i < len; ++i) 
        {
            obj[parts[i]] = obj[parts[i]] || undefined;
    		obj = obj[parts[i]];
    	}
    	return obj;
 	};

 	/**
 	* Returns the key for a value in a dictionary. It looks for an specific value inside a dictionary and returns the corresponding key.
 	* @param {Object} dictionary The dictionary to look for the value in and get the corresponding key.
 	* @param {Object} value The value to look for inside the dictionary and return it's corresponding key.
 	* @return The key that corresponds to the given value it is has been found or null.
 	*/
 	CocoonJS.getKeyForValueInDictionary = function(dictionary, value) {
        var finalKey = null;
        for (var key in dictionary) {
            if (dictionary[key] === value)            {
                finalKey = key;
                break;
            }
        }
        return finalKey;
 	}

 	/**
 	* Finds a string inside a given array of strings by looking for a given substring. It can also
 	* specify if the search must be performed taking care or not of the case sensitivity.
 	* @param {Array} stringArray The array of strings in which to to look for the string.
 	* @param {string} subString The substring to look for inside all the strings of the array.
 	* @param {boolean} caseSensitive A flag to indicate if the search must be performed taking case of the 
 	* case sensitiveness (true) or not (false).
 	* @return {string} The string that has been found or null if the substring is not inside any of the string of the array.
 	*/
 	CocoonJS.findStringInStringArrayThatIsIndexOf = function(stringArray, subString, caseSensitive) {
 		var foundString = null;
 		subString = caseSensitive ? subString : subString.toUpperCase();
 		for (var i = 0; foundString == null && i < stringArray.length; i++)	{
 			foundString = caseSensitive ? stringArray[i] : stringArray[i].toUpperCase();
 			foundString = foundString.indexOf(subString) >= 0 ? stringArray[i] : null; 
 		}
 		return foundString;
 	};

	/**
	* A class that represents objects to handle events. Event handlers have always the same structure:
	* Mainly they provide the addEventListener and removeEventListener functions.
	* Both functions receive a callback function that will be added or removed. All the added callback
	* functions will be called when the event takes place.
	* Additionally they also allow the addEventListenerOnce and notifyEventListeners functions.
	* @constructor
	* @param {string} nativeExtensionObjectName The name of the native extension object (inside the ext object) to be used.
	* @param {string} cocoonJSExtensionObjectName The name of the sugarized extension object.
	* @param {string} nativeEventName The name of the native event inside the ext object.
	* @param {number} [chainFunction] An optional function used to preprocess the listener callbacks. This function, if provided,
	* will be called before any of the other listeners.
	*/
	CocoonJS.EventHandler = function(nativeExtensionObjectName, cocoonJSExtensionObjectName, nativeEventName, chainFunction) {
		this.listeners = [];
		this.listenersOnce = [];
		this.chainFunction = chainFunction;

		/**
		* Adds a callback function so it can be called when the event takes place.
		* @param {function} listener The callback function to be added to the event handler object. See the referenced Listener function documentation for more detail in each event handler object's documentation.
		*/
		this.addEventListener = function(listener) {
			if (chainFunction) {
				var f = function() {
					chainFunction.call(this, arguments.callee.sourceListener, Array.prototype.slice.call(arguments)); 
				};
				listener.CocoonJSEventHandlerChainFunction = f;
				f.sourceListener = listener;
				listener = f;
			}

			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject && cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].addEventListener(nativeEventName, listener);
            }
            else {
                var indexOfListener = this.listeners.indexOf(listener);
                if (indexOfListener < 0) {
                	this.listeners.push(listener);
                }
            }
		};

        this.addEventListenerOnce = function(listener)
		{
			if (chainFunction) {
				var f = function() { chainFunction(arguments.callee.sourceListener,Array.prototype.slice.call(arguments)); };
				f.sourceListener = listener;
				listener = f;
			}

			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].addEventListenerOnce(nativeEventName, listener);
            }
            else
            {
                var indexOfListener = this.listeners.indexOf(listener);
                if (indexOfListener < 0)
                {
                	this.listenersOnce.push(listener);
                }
            }
		};

        /**
         * Removes a callback function that was added to the event handler so it won't be called when the event takes place.
         * @param {function} listener The callback function to be removed from the event handler object. See the referenced Listener function documentation for more detail in each event handler object's documentation.
         */
        this.removeEventListener = function (listener) {

        	if (chainFunction) {
        		listener = listener.CocoonJSEventHandlerChainFunction;
        		delete listener.CocoonJSEventHandlerChainFunction;
        	}

			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].removeEventListener(nativeEventName, listener);
            }
            else {
                var indexOfListener = this.listeners.indexOf(listener);
                if (indexOfListener >= 0) {
                    this.listeners.splice(indexOfListener, 1);
                }
            }
        };

		this.notifyEventListeners = function() {
			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject && cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].notifyEventListeners(nativeEventName);
            } else {

                var argumentsArray= Array.prototype.slice.call(arguments);
                var listeners =     Array.prototype.slice.call(this.listeners);
                var listenersOnce = Array.prototype.slice.call(this.listenersOnce);
                var _this = this;
                // Notify listeners after a while ;) === do not block this thread.
                setTimeout(function() {
                    for (var i = 0; i < listeners.length; i++) {
                        listeners[i].apply(_this, argumentsArray);
                    }
                    for (var i = 0; i < listenersOnce.length; i++) {
                        listenersOnce[i].apply(_this, argumentsArray);
                    }
                }, 0);

                _this.listenersOnce= [];
            }
		};
		return this;
	};

	/**
	* A simple timer class. Update it every loop iteration and get values from accumulated time to elapsed time in seconds or milliseconds.
	*/
	CocoonJS.Timer = function() {
		this.reset();
		return this;
	};

	CocoonJS.Timer.prototype = {
		currentTimeInMillis : 0,
		lastTimeInMillis : 0,
		elapsedTimeInMillis : 0,
		elapsedTimeInSeconds : 0,
		accumTimeInMillis : 0,

		/**
		Resets the timer to 0.
		*/
		reset : function() {
			this.currentTimeInMillis = this.lastTimeInMillis = new Date().getTime();
			this.accumTimeInMillis = this.elapsedTimeInMillis = this.elapsedTimeInSeconds = 0;
		},

		/**
		Updates the timer calculating the elapsed time between update calls.
		*/
		update : function() {
			this.currentTimeInMillis = new Date().getTime();
			this.elapsedTimeInMillis = this.currentTimeInMillis - this.lastTimeInMillis;
			this.elapsedTimeInSeconds = this.elapsedTimeInMillis / 1000.0;
			this.lastTimeInMillis = this.currentTimeInMillis;
			this.accumTimeInMillis += this.elapsedTimeInMillis;
		}
	};

	// CocoonJS.FindAllNativeBindingsInCocoonJSExtensionObject = function(cocoonJSExtensionObject, nativeFunctionBindingCallback, nativeEventBindingCallback)
	// {
	// 	for (var cocoonJSExtensionObjectAttributeName in cocoonJSExtensionObject)
	// 	{
	// 		var cocoonJSExtensionObjectAttribute = cocoonJSExtensionObject[cocoonJSExtensionObjectAttributeName];

	// 		// Function
	// 		if (typeof cocoonJSExtensionObjectAttribute === 'function' && typeof cocoonJSExtensionObjectAttribute.nativeFunctionName !== 'undefined')
	// 		{
	// 			var nativeFunctionName = cocoonJSExtensionObjectAttribute.nativeFunctionName;
	// 			nativeFunctionBindingCallback(cocoonJSExtensionObjectAttributeName, nativeFunctionName);
	// 		}
	// 		// Event object
	// 		else if (typeof cocoonJSExtensionObjectAttribute === 'object' && cocoonJSExtensionObjectAttribute !== null && typeof cocoonJSExtensionObjectAttribute.nativeEventName !== 'undefined')
	// 		{
	// 			var nativeEventName = cocoonJSExtensionObjectAttribute.nativeEventName;
	// 			nativeEventBindingCallback(cocoonJSExtensionObjectAttributeName, nativeEventName);
	// 		}
	// 	}
	// }

	/**
	This function looks for a CocoonJS extension object that is bound to the given native ext object name.
	@returns The CocoonJS extension object that corresponds to the give native extension object name or null if it cannot be found.
	*/
	// CocoonJS.GetCocoonJSExtensionObjectForNativeExtensionObjectName = function(nativeExtensionObjectName)
	// {
	// 	var cocoonJSExtensionObject = null;
	// 	// Look in the CocoonJS object and for every object that is a CocoonJS.Extension check if it's nativeExtensionObjectName matches to the one passed as argument. If so, create an object that will represent it's documentation for the native ext object.
	// 	for (var cocoonJSAttributeName in CocoonJS)
	// 	{
	// 		var cocoonJSAttribute = CocoonJS[cocoonJSAttributeName];
	// 		if (typeof cocoonJSAttribute === 'object' && cocoonJSAttribute instanceof CocoonJS.Extension && cocoonJSAttribute.nativeExtensionObjectName === nativeExtensionObjectName)
	// 		{
	// 			// We have found the CocoonJS object that represents the native ext extension object name. 
	// 			cocoonJSExtensionObject = cocoonJSAttribute;
	// 			break;
	// 		}
	// 	}
	// 	return cocoonJSExtensionObject;
	// };

	/**
	This function adds functions to a CocoonJS extension object in order to bind them to the native makeCall function calls of the ext object.

	@param extensionObject The reference to the CocoonJS extension object where to add the new functions bound to the ext object makeCall functions calls.

	@param nativeFunctionsConfiguration An array of objects with the following structure:

		{ nativeFunctionName : "" [, functionName : "", isAsync : true/false] }

		- nativeFunctionName: Specifies the name of the function inside the ext object makeCall function call that will be bound.
		- functionName: An optional attribute that allows to specify the name of the function to be added to the CocoonJS extension object. If is not present, the name of the function will be the same
		as the nativeFunctionName.
		- isAsync: An optional attribute that allows to specify if the call should be performed using makeCall (false or missing) or makeCallAsync (true).
		- alternativeFunction: An optional attribute that allows to specify an alternative function that will be called internally when this function is called. This attribute
		allows for adding new functionalities like for example adding methods 

	@returns The CocoonJS extension object.
	*/
	// CocoonJS.AddNativeFunctionBindingsToExtensionObject = function(extensionObject, nativeFunctionsConfiguration)
	// {
	// 	if (typeof extensionObject === 'undefined' || extensionObject === null) throw("The passed extension object be a valid object.");
	// 	if (typeof nativeFunctionsConfiguration === 'undefined' || nativeFunctionsConfiguration === null) throw("The passed native functions configuration array must be a valid object.");

	// 	for (var i = 0; i < nativeFunctionsConfiguration.length; i++)
	// 	{
	// 		if (typeof nativeFunctionsConfiguration[i].nativeFunctionName === 'undefined') throw("The 'nativeFunctionName' attribute in the native function configuration object at index '" + i + "' in the native function configuration array cannot be undefined.");
	// 		var nativeFunctionName = nativeFunctionsConfiguration[i].nativeFunctionName;
	// 		var functionName = typeof nativeFunctionsConfiguration[i].functionName !== 'undefined' ? nativeFunctionsConfiguration[i].functionName : nativeFunctionName;
	// 		var makeCallFunction = null;
	// 		makeCallFunction = typeof nativeFunctionsConfiguration[i].isAsync !== 'undefined' && nativeFunctionsConfiguration[i].isAsync ? extensionObject.nativeExtensionObject.makeCallAsync : extensionObject.nativeExtensionObject.makeCall;
	// 		// Add the new function to the CocoonJS extension object
	// 		extensionObject[functionName] = function()
	// 		{
	// 			// Convert the arguments object to an array
	// 			var arguments = Array.prototype.slice.call(arguments);
	// 			// Add the native function name as the first parameter
	// 			arguments.unshift(nativeFunctionName);
	// 			// Make the native ext object call
	// 			var result = makeCallFunction.apply(extensionObject.nativeExtensionObject, arguments);
	// 			return result;
	// 		}
	// 		// Add a property to the newly added function to store the name of the original function.
	// 		extensionObject[functionName].nativeFunctionName = nativeFunctionName;
	// 	}
	// 	return extensionObject;
	// };

	/**
	This function adds objects to a CocoonJS extension object to allow event listener handling (add and remove) bound to the native ext object event listener handling.

	@param extensionObject The reference to the CocoonJS extension object where to add the new objects bound to the ext object event listener handling.

	@param nativeEventsConfiguration An array of objects with the following structure:

		{ nativeEventName : "" [, eventObjectName : ""] }

		- nativeEventName: Specifies the event in the native ext object to be bound.
		- eventObjectName: An optional attribute that allows to specify the name of the object to be added to the CocoonJS extension object. If is not present, the name of the function will be the same
		as the nativeEventName.
		- alternativeAddEventListenerFunction:
		- alternativeRemoveEventListenerFunction:

	@returns The CocoonJS extension object.
	*/
	// CocoonJS.AddNativeEventBindingsToExtensionObject = function(extensionObject, nativeEventsConfiguration)
	// {
	// 	if (typeof extensionObject === 'undefined' || extensionObject === null) throw("The passed extension object be a valid object.");
	// 	if (typeof nativeEventsConfiguration === 'undefined' || nativeEventsConfiguration === null) throw("The passed native events configuration array must be a valid object.");

	// 	for (var i = 0; i < nativeEventsConfiguration.length; i++)
	// 	{
	// 		if (typeof nativeEventsConfiguration[i].nativeEventName === 'undefined') throw("The 'nativeEventName' attribute in the native event configuration object at index '" + i + "' in the native event configuration array cannot be undefined.");
	// 		var nativeEventName = nativeEventsConfiguration[i].nativeEventName;
	// 		var eventObjectName = typeof nativeEventsConfiguration[i].eventObjectName !== 'undefined' ? nativeEventsConfiguration[i].eventObjectName : nativeEventName;
	// 		// Anonymous function call so each variable in the loop is used in the event listener handling function bindings.
	// 		(function(nativeEventName, eventObjectName)
	// 		{
	//     		extensionObject[eventObjectName] =
	//     		{
	//     			// Store the native event name
	//     			nativeEventName : nativeEventName,
	//     			// Create the event listener management functions bound to the native counterparts
	//     			addEventListener : function(callback)
	// 	    		{
	// 	    			extensionObject.nativeExtensionObject.addEventListener(nativeEventName, callback);
	//     			},
	//     			removeEventListener : function(callback)
	//     			{
	// 	    			extensionObject.nativeExtensionObject.removeEventListener(nativeEventName, callback);
	//     			}
	//     			// ,
	//     			// removeAllEventListeners : function()
	//     			// {

	//     			// }
	//     		};
	// 		})(nativeEventName, eventObjectName);
	// 	}
	// 	return extensionObject;
	// };

	/**
	The function object constructor function all the CocoonJS extensions can use to instantiate the CocoonJS extension object and add all the functionality needed bound to the native ext object.

	@param nativeExtensionObject The reference to the ext object extension object.

	@param nativeFunctionsConfiguration See CocoonJS.AddNativeFunctionBindingsToExtensionObject function's documentation for more details.

	@param nativeEventsConfiguration See CocoonJS.AddNativeEventBindingsToExtensionObject function's documentation for more details.

	@returns The new CocoonJS extension object.
	*/
	// CocoonJS.Extension = function(nativeExtensionObjectName, nativeFunctionsConfiguration, nativeEventsConfiguration)
	// {
	// 	if (typeof nativeExtensionObjectName === 'undefined' || nativeExtensionObjectName === null) throw("The native extension object name cannot be null");

	// 	if (window.ext[nativeExtensionObjectName] === 'undefined') throw("The given native extension object name '" + nativeExtensionObjectName + "' is incorrect or the native extension object is undefined.");

	// 	var nativeExtensionObject = window.ext[nativeExtensionObjectName];

	// 	// Store a reference to the native extension object and to it's name
	// 	this.nativeExtensionObject = nativeExtensionObject;
	// 	this.nativeExtensionObjectName = nativeExtensionObjectName;

	// 	// If native function configuration is passed, use it to add some functions to the new extension object.
	// 	if (typeof nativeFunctionsConfiguration !== 'undefined')
	// 	{
	// 		CocoonJS.AddNativeFunctionBindingsToExtensionObject(this, nativeFunctionsConfiguration);
	// 	}

	// 	// If native event configuration is passed, use it to add some event objects to the new extension object.
	// 	if (typeof nativeEventsConfiguration !== 'undefined')
	// 	{
	// 		CocoonJS.AddNativeEventBindingsToExtensionObject(this, nativeEventsConfiguration);
	// 	}

	// 	return this;
	// };   

})();

//////////////////////////////////////
// COCOONJS_APP.JS                  //
//////////////////////////////////////

(function () {
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
     * This namespace represents all the basic functionalities available in the CocoonJS extension API.
     * @namespace
     */
    CocoonJS.App = CocoonJS.App ? CocoonJS.App : {};

    CocoonJS.App.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_APP !== 'undefined';

    /**
     * The predefined possible layouts for the FPS overlay.
     * @namespace
     */
    CocoonJS.App.FPSLayout = {
        TOP_LEFT:'top-left',
        TOP_RIGHT:'top-right',
        BOTTOM_LEFT:'bottom-left',
        BOTTOM_RIGHT:'bottom-right'
    };

    /**
     * Contains all the possible values to specify the input keyboard type to be used when introducing text.
     * @namespace
     */
    CocoonJS.App.KeyboardType = {
        /**
         * Represents a generic text input keyboard.
         */
        TEXT:"text",

        /**
         * Represents a number like input keyboard.
         */
        NUMBER:"num",

        /**
         * Represents a phone like input keyboard.
         */
        PHONE:"phone",

        /**
         * Represents an email like input keyboard.
         */
        EMAIL:"email",

        /**
         * Represents an URL like input keyboard.
         */
        URL:"url"
    };

    /**
     * The storage types to be used with file system related operations.
     * @namespace
     */
    CocoonJS.App.StorageType = {
        /**
         * Represents the application storage. The application storage is the place where all the resources that come with the application are stored.
         */
        APP_STORAGE:"APP_STORAGE",

        /**
         * Represents the internal storage. The internal storage is a different storage space that the application storage and only the data that the application has stored
         * in it will be in this storage. It is internal to the platform/device.
         */
        INTERNAL_STORAGE:"INTERNAL_STORAGE",

        /**
         * Represents an external storage. The external storage is similar to the internal storage in the sense that it only contains information that the application has written
         * in it but it represents an external storage device like a SD-CARD. If there is no exrernal storage, it will represent the same as the internal storage.
         */
        EXTERNAL_STORAGE:"EXTERNAL_STORAGE",

        /**
         * Represents the temporal storage. Same as the internal and external storage spaces in the sense that it only contains information that the application has written
         * in it but the main difference is that the information in this storage may dissapear without notice.
         */
        TEMPORARY_STORAGE:"TEMPORARY_STORAGE"
    };

    /**
     * The capture types to capture screenshots using CocoonJS native capabilities.
     * @namespace
     */
    CocoonJS.App.CaptureType = {
        /**
         Captures everything, both the CocoonJS GL hardware accelerated surface and the system views (like the WebView).
         */
        EVERYTHING:0,

        /**
         * Captures just the CocoonJS GL hardware accelerated surface.
         */
        JUST_COCOONJS_GL_SURFACE:1,

        /**
         * Captures just the sustem views (like the webview)
         */
        JUST_SYSTEM_VIEWS:2
    };

    /**
     * Makes a forward call of some javascript code to be executed in a different environment (i.e. from CocoonJS to the WebView and viceversa).
     * It waits until the code is executed and the result of it is returned === synchronous.
     * @function
     * @param {string} javaScriptCode Some JavaScript code in a string to be forwarded and executed in a different JavaScript environment (i.e. from CocoonJS to the WebView and viceversa).
     * @return {string} The result of the execution of the passed JavaScript code in the different JavaScript environment.
     */
    CocoonJS.App.forward = function (javaScriptCode) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "forward", arguments);
        }
        else if (!navigator.isCocoonJS) {
            if (window.name == 'CocoonJS_App_ForCocoonJS_WebViewIFrame') {
                return window.parent.eval(javaScriptCode);
            }
            else {
                //return window.parent.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
                return window.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
            }
        }
    };

    /**
     * Makes a forward call of some javascript code to be executed in a different environment (i.e. from CocoonJS to the WebView and viceversa).
     * It is asyncrhonous so it does not wait until the code is executed and the result of it is returned. Instead, it calls a callback function when the execution has finished to pass the result.
     * @function
     * @param {string} javaScriptCode Some JavaScript code in a string to be forwarded and executed in a different JavaScript environment (i.e. from CocoonJS to the WebView and viceversa).
     * @param {function} [returnCallback] A function callback that will be called when the passed JavaScript code is executed in a different thread to pass the result of the execution in the different JavaScript environment.
     */
    CocoonJS.App.forwardAsync = function (javaScriptCode, returnCallback) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            if (typeof returnCallback !== 'undefined') {
                return ext.IDTK_APP.makeCallAsync("forward", javaScriptCode, returnCallback);
            }
            else {
                return ext.IDTK_APP.makeCallAsync("forward", javaScriptCode);
            }
        }
        else if (!navigator.isCocoonJS) {
            if (window.name == 'CocoonJS_App_ForCocoonJS_WebViewIFrame') {
                return window.parent.eval(javaScriptCode);
            }
            else {
                return window.parent.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
                // window.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
            }
        }
    };

    /**
     * Pops up a text dialog so the user can introduce some text and the application can get it back. It is the first approach CocoonJS has taken to be able to introduce
     * text input in a easy way. The dialog execution events are passed to the application through the {@link CocoonJS.App.onTextDialogFinished} and the {@link CocoonJS.App.onTextDialogCancelled} event objects.
     * @function
     * @param {string} [title] Default value is "". The title to be displayed in the dialog.
     * @param {string} [message] Default value is "". The message to be displayed in the dialog, next to the text input field.
     * @param {string} [text] Default value is "". The initial text to be introduced in the text input field.
     * @param {CocoonJS.App.KeyboardType} [keyboardType] Default value is {@link CocoonJS.App.KeyboardType.TEXT}. The keyboard type to be used when the text has to be introduced.
     * @param {string} [cancelButtonText] Default value is "". The text to be displayed in the cancel button of the dialog.
     * @param {string} [okButtonText] Default value is "". The text to be displayed in the ok button of the dialog.
     * @see CocoonJS.App.onTextDialogFinished
     * @see CocoonJS.App.onTextDialogCancelled
     */
    CocoonJS.App.showTextDialog = function (title, message, text, keyboardType, cancelButtonText, okButtonText) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "showTextDialog", arguments, true);
        }
        else if (!navigator.isCocoonJS) {
            if (!message) {
                message = "";
            }
            if (!text) {
                text = "";
            }
            var result = prompt(message, text);
            var eventObject = result ? CocoonJS.App.onTextDialogFinished : CocoonJS.App.onTextDialogCancelled;
            eventObject.notifyEventListeners(result);
        }
    };

    /**
     * Pops up a message dialog so the user can decide between a yes or no like confirmation. The message box execution events are passed to the application through the {@link CocoonJS.App.onMessageBoxConfirmed} and the {@link CocoonJS.App.onMessageBoxDenied} event objects.
     * @function
     * @param {string} [title] Default value is "". The title to be displayed in the dialog.
     * @param {string} [message] Default value is "". The message to be displayed in the dialog, next to the text input field.
     * @param {string} [confirmButtonText] Default value is "Yes". The text to be displayed for the confirm button.
     * @param {string} [denyButtonText] Default value is "No". The text to be displayed for the deny button.
     * @see CocoonJS.App.onMessageBoxConfirmed
     * @see CocoonJS.App.onMessageBoxDenied
     */
    CocoonJS.App.showMessageBox = function (title, message, confirmButtonText, denyButtonText) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "showMessageBox", arguments, true);
        }
        else if (!navigator.isCocoonJS) {
            if (!message) {
                message = "";
            }
            var result = confirm(message);
            var eventObject = result ? CocoonJS.App.onMessageBoxConfirmed : CocoonJS.App.onMessageBoxDenied;
            eventObject.notifyEventListeners();
        }
    };

    /**
     * It allows to load a new JavaScript/HTML5 resource that can be loaded either locally (inside the platform/device storage) or using a remote URL.
     * @function
     * @param {string} path A path to a resource stored in the platform or in a URL to a remote resource.
     * @param {CocoonJS.App.StorageType} [storageType] If the path argument represents a locally stored resource, the developer can specify the storage where it is stored. If no value is passes, the {@link CocoonJS.App.StorageType.APP_STORAGE} value is used by default.
     */
    CocoonJS.App.load = function (path, storageType) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "loadPath", arguments);
        }
        else if (!navigator.isCocoonJS) {
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange = function (event) {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        // TODO: As window load event is not being called (WHY???), I have decided to call the listeners directly
                        // var callback= function(event){
                        //     window.removeEventListener("load", callback);
                        var jsCode;
                        // If there is no webview, it means we are in the webview, so notify the CocoonJS environment
                        if (!CocoonJS.App.EmulatedWebViewIFrame) {
                            jsCode = "window.CocoonJS && window.CocoonJS.App.onLoadInTheWebViewSucceed.notifyEventListeners('" + path + "');";
                        }
                        // If there is a webview, it means we are in CocoonJS, so notify the webview environment
                        else {
                            jsCode = "window.CocoonJS && window.CocoonJS.App.onLoadInCocoonJSSucceed.notifyEventListeners('" + path + "');";
                        }
                        CocoonJS.App.forwardAsync(jsCode);
                        // };
                        // window.addEventListener("load", callback);
                        window.location.href = path;
                    }
                    else if (xhr.status === 404) {
                        this.onreadystatechange = null;
                        var jsCode;
                        // If there is no webview, it means we are in the webview, so notify the CocoonJS environment
                        if (!CocoonJS.App.EmulatedWebViewIFrame) {
                            jsCode = "CocoonJS && CocoonJS.App.onLoadInTheWebViewFailed.notifyEventListeners('" + path + "');";
                        }
                        // If there is a webview, it means we are in CocoonJS, so notify the webview environment
                        else {
                            jsCode = "CocoonJS && CocoonJS.App.onLoadInCocoonJSFailed.notifyEventListeners('" + path + "');";
                        }
                        CocoonJS.App.forwardAsync(jsCode);
                    }
                }
            };
            xhr.open("GET", path, true);
            xhr.send();
        }
    };

    /**
     * Reloads the last loaded path in the current context.
     * @function
     */
    CocoonJS.App.reload = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "reload", arguments);
        }
        else if (!navigator.isCocoonJS) {
            if (window.name == 'CocoonJS_App_ForCocoonJS_WebViewIFrame') {
                return window.parent.location.reload();
            }
            else {
                return window.parent.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.location.reload();
            }
        }
    };

    /**
     * Opens a given URL using a system service that is able to open it. For example, open a HTTP URL using the system WebBrowser.+
     * @function
     * @param {string} url The URL to be opened by a system service.
     */
    CocoonJS.App.openURL = function (url) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "openURL", arguments, true);
        }
        else if (!navigator.isCocoonJS) {
            window.open(url, '_blank');
        }
    }

    /**
     * Forces the app to be finished.
     * @function
     */
    CocoonJS.App.forceToFinish = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "forceToFinish", arguments);
        }
        else if (!navigator.isCocoonJS) {
            window.close();
        }
    }

    /**
     * Enables or disables the auto lock to control if the screen keeps on after an inactivity period.
     * When the auto lock is enabled and the application has no user input for a short period, the system puts the device into a "sleepâ€ state where the screen dims or turns off.
     * When the auto lock is disabled the screen keeps on even when there is no user input for long times.
     * @param enabled A boolean value that controls whether to enable or disable the auto lock.
     */
    CocoonJS.App.setAutoLockEnabled = function (enabled) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "setAutoLockEnabled", arguments);
        }
    }

    /**
     * Creates a canvas element that is automatically resized to the screen size. When the app is being executed
     * inside CocoonJS. This canvas is optimized for rendering so it is higly recommended to use it if it fits
     * your app needs. If your app uses one canvas as the main canvas where all other canvases and images are displayed, Ludei recommends to
     * call this function in order to create this main canvas. A usual 2x performance gain is achieved by doing so
     * depending on the device and the graphics card driver.
     * @function
     * @return {object} The canvas object that should be used as the main canvas and that is resized to the screen resolution.
     */
    CocoonJS.App.createScreenCanvas = function () {
        var screenCanvas;
        if (navigator.isCocoonJS) {
            screenCanvas = document.createElement("screencanvas");
        }
        else if (!navigator.isCocoonJS) {
            screenCanvas = document.createElement("canvas");
            screenCanvas.width = window.innerWidth;
            screenCanvas.height = window.innerHeight;
        }
        return screenCanvas;
    };

    /**
     * Disables the touch events in the CocoonJS environment.
     * @function
     */
    CocoonJS.App.disableTouchInCocoonJS = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("disableTouchLayer", "CocoonJSView");
        }
    };

    /**
     * Enables the touch events in the CocoonJS environment.
     * @function
     */
    CocoonJS.App.enableTouchInCocoonJS = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("enableTouchLayer", "CocoonJSView");
        }
    };

    /**
     * Disables the touch events in the WebView environment.
     * @function
     */
    CocoonJS.App.disableTouchInTheWebView = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("disableTouchLayer", "WebView");
        }
    };

    /**
     * Enables the touch events in the WebView environment.
     * @function
     */
    CocoonJS.App.enableTouchInTheWebView = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("enableTouchLayer", "WebView");
        }
    };

    /**
     * Setups the update interval in seconds (1 second / X frames) to receive the accelerometer updates.
     * It defines the rate at which the devicemotion events are updated.
     * @function
     * @param {number} updateIntervalInSeconds The update interval in seconds to be set.
     */
    CocoonJS.App.setAccelerometerUpdateIntervalInSeconds = function (updateIntervalInSeconds) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("setAccelerometerUpdateIntervalInSeconds", updateIntervalInSeconds);
        }
    };

    /**
     * Returns the update interval in seconds that is currently set for accelerometer related events.
     * @function
     * @return {number} The update interval in seconds that is currently set for accelerometer related events.
     */
    CocoonJS.App.getAccelerometerUpdateIntervalInSeconds = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("getAccelerometerUpdateIntervalInSeconds");
        }
    };

    /**
     * Setups the update interval in seconds (1 second / X frames) to receive the gyroscope updates.
     * It defines the rate at which the devicemotion and deviceorientation events are updated.
     * @function
     * @param {number} updateIntervalInSeconds The update interval in seconds to be set.
     */
    CocoonJS.App.setGyroscopeUpdateIntervalInSeconds = function (updateIntervalInSeconds) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("setGyroscopeUpdateIntervalInSeconds", updateIntervalInSeconds);
        }
    };

    /**
     * Returns the update interval in seconds that is currently set for gyroscope related events.
     * @function
     * @return {number} The update interval in seconds that is currently set for gyroscope related events.
     */
    CocoonJS.App.getGyroscopeUpdateIntervalInSeconds = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("getGyroscopeUpdateIntervalInSeconds");
        }
    };


    /**
     * Setups a origin proxy for a given typeName. What this means is that after calling this function the environment that makes this call will suddenly
     * have a way of creating instances of the given typeName and those instances will act as a transparent proxy to counterpart instances in the destination environment.
     * Manipulating attributes, calling funcitions or handling events will all be performed in the destination environment but the developer will think they will be
     * happening in the origin environment.
     * IMPORTANT NOTE: These proxies only work with types that use attributes and function parameters and return types that are primitive like numbers, strings or arrays.
     * @param {string} typeName The name of the type to be proxified.
     * @param {array} [attributeNames] A list of the names of the attributes to be proxified.
     * @param {array} [functionNames] A list of the names of the functions to be proxified.
     * @param {array} [eventHandlerNames] A list of the names of the event handlers to be proxified (onXXXX like attributes that represent callbacks).
     * A valid typeName and at least one valid array for attribute, function or event handler names is mandatory.
     */
    CocoonJS.App.setupOriginProxyType = function (typeName, attributeNames, functionNames, eventHandlerNames) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            // Control the parameters.
            if (!typeName) throw "The given typeName must be valid.";
            if (!attributeNames && !functionNames && !eventHandlerNames) throw "There is no point on setting up a proxy for no attributes, functions nor eventHandlers.";
            attributeNames = attributeNames ? attributeNames : [];
            functionNames = functionNames ? functionNames : [];
            eventHandlerNames = eventHandlerNames ? eventHandlerNames : [];

            // The parent object will be the window. It could be another object but careful, the destination side should know about this.
            // TODO: Specify the parentObject as a parameter, obtain it's path from the window object and pass it to the destination environment so it knows about it.
            var parentObject = window;

            // Setup the destination side too.
            var jsCode = "CocoonJS.App.setupDestinationProxyType(" + JSON.stringify(typeName) + ", " + JSON.stringify(eventHandlerNames) + ");";
            CocoonJS.App.forward(jsCode);

            var originalType = parentObject[typeName];

            // Constructor. This will be the new proxified type in the origin environment. Instances of this type will be created by the developer without knowing that they are
            // internally calling to their counterparts in the destination environment.
            parentObject[typeName] = function () {
                var _this = this;

                // Each proxy object will have a origin object inside with all the necessary information to be a proxy to the destination.
                this._cocoonjs_proxy_object_data = {};
                // The id is obtained calling to the destination side to create an instance of the type.
                var jsCode = "CocoonJS.App.newDestinationProxyObject(" + JSON.stringify(typeName) + ");";
                this._cocoonjs_proxy_object_data.id = CocoonJS.App.forward(jsCode);
                // The eventHandlers dictionary contains objects of the type { eventHandlerName : string, eventHandler : function } to be able to make the callbacks when the 
                // webview makes the corresponding calls.
                this._cocoonjs_proxy_object_data.eventHandlers = {};
                // Also store the typename inside each instance.
                this._cocoonjs_proxy_object_data.typeName = typeName;
                // A dictionary to store the event handlers
                this._cocoonjs_proxy_object_data.eventListeners = {};

                // TODO: eventHandlers and eventListeners should be in the same list ;)

                // Store all the proxy instances in a list that belongs to the type itself.
                parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[this._cocoonjs_proxy_object_data.id] = this;

                // Create a setter and a getter for all the attribute names that have been specified. When the attributes are accessed (set or get) a call to the destination counterpart will be performed.
                for (var i = 0; i < attributeNames.length; i++) {
                    (function (attributeName) {
                        _this.__defineSetter__(attributeName, function (value) {
                            var jsCode = "CocoonJS.App.setDestinationProxyObjectAttribute(" + JSON.stringify(typeName) + ", " + _this._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(attributeName) + ", " + JSON.stringify(value) + ");";
                            return CocoonJS.App.forwardAsync(jsCode);
                        });
                        _this.__defineGetter__(attributeName, function () {
                            var jsCode = "CocoonJS.App.getDestinationProxyObjectAttribute(" + JSON.stringify(typeName) + ", " + _this._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(attributeName) + ");";
                            return CocoonJS.App.forwardAsync(jsCode);
                        });
                    })(attributeNames[i]);
                }

                // Create a function that performs a call to the destination environment counterpart for all the function names that have been specified.
                for (var i = 0; i < functionNames.length; i++) {
                    (function (functionName) {
                        _this[functionName] = function () {
                            // Get the arguments as an array and add the typeName, the proxy id and the functionName before all the other arguments before making the call to the destination counterpart.
                            var argumentsArray = Array.prototype.slice.call(arguments);
                            argumentsArray.unshift(functionName);
                            argumentsArray.unshift(this._cocoonjs_proxy_object_data.id);
                            argumentsArray.unshift(typeName);
                            // Use the array to create the correct function call.
                            var jsCode = "CocoonJS.App.callDestinationProxyObjectFunction(";
                            for (var i = 0; i < argumentsArray.length; i++) {
                                // The second argument (the id) should not be stringified
                                jsCode += (i !== 1 ? JSON.stringify(argumentsArray[i]) : argumentsArray[i]) + (i < argumentsArray.length - 1 ? ", " : "");
                            }
                            jsCode += ");";
                            // TODO: This next call should be synchronous but it seems that some customers are experiencing some crash issues. Making it async solves these crashes.
                            // Another possible solution could be to be able to specify which calls could be async and which sync in the proxification array.
                            var ret = CocoonJS.App.forwardAsync(jsCode);
                            return ret;
                        };
                    })(functionNames[i]);
                }

                // Create a setter and getter for all the event handler names that have been specified. When the event handlers are accessed, store them inside the corresponding position on the eventHandlers
                // array so they can be called when the destination environment makes the corresponding callback call.
                for (var i = 0; i < eventHandlerNames.length; i++) {
                    (function (eventHandlerName) {
                        _this.__defineSetter__(eventHandlerName, function (value) {
                            _this._cocoonjs_proxy_object_data.eventHandlers[eventHandlerName] = value;
                        });
                        _this.__defineGetter__(eventHandlerName, function () {
                            return _this._cocoonjs_proxy_object_data.eventHandlers[eventHandlerName];
                        });
                    })(eventHandlerNames[i]);
                }

                // Setup the add and remove event listeners in the proxy object
                _this.addEventListener = function (eventTypeName, eventCallback) {
                    var addEventCallback = true;
                    // Check for the eventListeners
                    var eventListeners = _this._cocoonjs_proxy_object_data.eventListeners[eventTypeName];
                    if (eventListeners) {
                        // As the eventListeners were already added, check that the same callback has not been added.
                        addEventCallback = eventListeners.indexOf(eventCallback) < 0;
                    }
                    else {
                        // There are no event listeners, so add the one and add the listeners array for the specific event type name
                        eventListeners = [];
                        _this._cocoonjs_proxy_object_data.eventListeners[eventTypeName] = eventListeners;

                        // Forward the call so the other end registers a event listener (only one is needed).
                        var jsCode = "CocoonJS.App.addDestinationProxyObjectEventListener(" + JSON.stringify(_this._cocoonjs_proxy_object_data.typeName) + ", " + _this._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(eventTypeName) + ");";
                        CocoonJS.App.forwardAsync(jsCode);
                    }
                    // Only if the alforithm above specify so, add the eventcallback and notify the destination environment to do the same
                    if (addEventCallback) {
                        eventListeners.push(eventCallback);
                    }
                };

                _this.removeEventListener = function (eventTypeName, eventCallback) {
                    // Check for the eventListeners
                    var eventListeners = _this._cocoonjs_proxy_object_data.eventListeners[eventTypeName];
                    if (eventListeners) {
                        var eventCallbackIndex = eventListeners.indexOf(eventCallback);
                        if (eventCallbackIndex >= 0) {
                            eventListeners.splice(eventCallbackIndex, 1);
                        }
                    }
                };

                // Return the proxy instance.
                return this;
            };

            // The type will contain a proxy data structure to store all the instances that are created so they are available when the destination environment calls back. 
            parentObject[typeName]._cocoonjs_proxy_type_data =
            {
                originalType:originalType,
                proxyObjects:[]
            };

            /**
             * Deletes a proxy instance from both the CocoonJS environment structures and also deleting it's webview environment counterpart.
             * This function should be manually called whenever a proxy instance won't be accessed anymore.
             * @param {object} object The proxy object to be deleted.
             */
            parentObject[typeName]._cocoonjs_proxy_type_data.deleteProxyObject = function (object) {
                var proxyObjectKey = CocoonJS.getKeyForValueInDictionary(this.proxyObjects, object);
                if (proxyObjectKey) {
                    var jsCode = "CocoonJS.App.deleteDestinationProxyObject(" + JSON.stringify(typeName) + ", " + object._cocoonjs_proxy_object_data.id + ");";
                    CocoonJS.App.forwardAsync(jsCode);
                    object._cocoonjs_proxy_object_data = null;
                    delete this.proxyObjects[proxyObjectKey];
                }
            };

            /**
             * Calls a event handler for the given proxy object id and eventHandlerName.
             * @param {number} id The id to be used to look for the proxy object for which to make the call to it's event handler.
             * @param {string} eventHandlerName The name of the handler to be called.
             * NOTE: Events are a complex thing in the HTML specification. This function just performs a call but at least provides a
             * structure to the event passing the target (the proxy object).
             * TODO: The destination should serialize the event object as far as it can so many parameters can be passed to the origin
             * side. Using JSON.stringify in the destination side and parse in origin side maybe? Still must add the target to the event structure though.
             */
            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventHandler = function (id, eventHandlerName) {
                var object = this.proxyObjects[id];
                var eventHandler = object._cocoonjs_proxy_object_data.eventHandlers[eventHandlerName];
                if (eventHandler) {
                    eventHandler({ target:object });
                }
            };

            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventListeners = function (id, eventTypeName) {
                var object = this.proxyObjects[id];
                var eventListeners = object._cocoonjs_proxy_object_data.eventListeners[eventTypeName].slice();
                for (var i = 0; i < eventListeners.length; i++) {
                    eventListeners[i]({ target:object });
                }
            };
        }
    };

    /**
     * Takes down the proxification of a type and restores it to it's original type. Do not worry if you pass a type name that is not proxified yet. The
     * function will handle it correctly for compativility reasons.
     * @param {string} typeName The name of the type to be deproxified (take down the proxification and restore the type to it's original state)
     */
    CocoonJS.App.takedownOriginProxyType = function (typeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            if (parentObject[typeName] && parentObject[typeName]._cocoonjs_proxy_type_data) {
                parentObject[typeName] = parentObject[typeName]._cocoonjs_proxy_type_data.originalType;
            }
        }
    };

    /**
     * Deletes everything related to a proxy object in both environments. Do not worry of you do not pass a proxified object to the
     * function. For compatibility reasons, you can still have calls to this function even when no poxification of a type has been done.
     * @param {object} object The proxified object to be deleted.
     */
    CocoonJS.App.deleteOriginProxyObject = function (object) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            if (object && object._cocoonjs_proxy_object_data) {
                parentObject[object._cocoonjs_proxy_object_data.typeName]._cocoonjs_proxy_type_data.deleteProxyObject(object);
            }
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the destination environment whenever it is needed to work with proxy objects.
     * It calls the origin proxy object when an event handler need to be updated/called from the destination environment.
     * @param {string} typeName The type name of the proxified type.
     * @param {number} id The id of the proxy object.
     * @param {string} eventHandlerName The name of the event handler to be called.
     */
    CocoonJS.App.callOriginProxyObjectEventHandler = function (typeName, id, eventHandlerName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventHandler(id, eventHandlerName);
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the destination environment whenever it is needed to work with proxy objects.
     * It calls the origin proxy object when all the event listeners related to a specific event need to be updated/called from the destination environment.
     * @param {string} typeName The type name of the proxified type.
     * @param {number} id The id of the proxy object.
     * @param {string} eventTypeName The name of the event type to call the listeners related to it.
     */
    CocoonJS.App.callOriginProxyObjectEventListeners = function (typeName, id, eventTypeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventListeners(id, eventTypeName);
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the origin environment whenever it is needed to work with proxy objects.
     * Setups all the structures that are needed to proxify a destination type to an origin type.
     * @param {string} typeName The name of the type to be proxified.
     * @param {array} eventHandlerNames An array with al the event handlers to be proxified. Needed in order to be able to create callbacks for all the event handlers
     * and call to the CocoonJS counterparts accordingly.
     */
    CocoonJS.App.setupDestinationProxyType = function (typeName, eventHandlerNames) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;

            // Add a cocoonjs structure to the destination proxified type to store some useful information like all the proxy instances that are created, plus the id counter 
            // and the names of all the event handlers and some utility functions.
            parentObject[typeName]._cocoonjs_proxy_type_data =
            {
                nextId:0,
                proxyObjects:{},
                eventHandlerNames:eventHandlerNames
            }
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the origin environment whenever it is needed to work with proxy objects.
     * Takes down the proxy type at the destination environment. Just removes the data structure related to proxies that was added to the type when proxification tool place.
     * @param {string} typeName The name of the type to take the proxification down.
     */
    CocoonJS.App.takedownDestinationProxyType = function (typeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            if (parent[typeName] && parentObject[typeName]._cocoonjs_proxy_type_data) {
                delete parentObject[typeName]._cocoonjs_proxy_type_data;
            }
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Creates a new destination object instance and generates a id to reference it from the original environment.
     * @param {string} typeName The name of the type to be proxified and to generate an instance.
     * @return The id to be used from the original environment to identify the corresponding destination object instance.
     */
    CocoonJS.App.newDestinationProxyObject = function (typeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;

            var proxyObject = new parentObject[typeName]();
            // Also store some additional information in the proxy object
            proxyObject._cocoonjs_proxy_object_data = {};
            // Like the type name, that could be useful late ;)
            proxyObject._cocoonjs_proxy_object_data.typeName = typeName;
            // Caculate the id for the object. It will be returned to the origin environment so this object can be referenced later
            var proxyObjectId = parentObject[typeName]._cocoonjs_proxy_type_data.nextId;
            // Store the created object in the structure defined in the setup of proxification with an id associated to it
            parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[proxyObjectId] = proxyObject;
            // Also store the id inside the proxy object itself
            proxyObject._cocoonjs_proxy_object_data.id = proxyObjectId;
            // Calculate a new id for the next object.
            parentObject[typeName]._cocoonjs_proxy_type_data.nextId++;

            // Setup all the event handlers.
            for (var i = 0; i < parentObject[typeName]._cocoonjs_proxy_type_data.eventHandlerNames.length; i++) {
                (function (eventHandlerName) {
                    proxyObject[eventHandlerName] = function (event) {
                        var proxyObject = this; // event.target;
                        // var eventHandlerName = CocoonJS.getKeyForValueInDictionary(proxyObject, this); // Avoid closures ;)
                        var jsCode = "CocoonJS.App.callOriginProxyObjectEventHandler(" + JSON.stringify(proxyObject._cocoonjs_proxy_object_data.typeName) + ", " + proxyObject._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(eventHandlerName) + ");";
                        CocoonJS.App.forwardAsync(jsCode);
                    };
                })(parentObject[typeName]._cocoonjs_proxy_type_data.eventHandlerNames[i]);
            }

            // Add the dictionary where the event listeners (callbacks) will be added.
            proxyObject._cocoonjs_proxy_object_data.eventListeners = {};

            return proxyObjectId;
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the origin environement whenever it is needed to work with proxy objects.
     * Calls a function of a destination object idetified by it's typeName and id.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     * @param {string} functionName The name of the function to be called.
     * @return Whatever the function call returns.
     */
    CocoonJS.App.callDestinationProxyObjectFunction = function (typeName, id, functionName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            var argumentsArray = Array.prototype.slice.call(arguments);
            argumentsArray.splice(0, 3);
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
            var result = proxyObject[functionName].apply(proxyObject, argumentsArray);
            return result;
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Sets a value to the corresponding attributeName of a proxy object represented by it's typeName and id.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     * @param {string} attributeName The name of the attribute to be set.
     * @param {unknown} attributeValue The value to be set to the attribute.
     */
    CocoonJS.App.setDestinationProxyObjectAttribute = function (typeName, id, attributeName, attributeValue) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
            proxyObject[attributeName] = attributeValue;
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Retrieves the value of the corresponding attributeName of a proxy object represented by it's typeName and id.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     * @param {string} attributeName The name of the attribute to be retrieved.
     */
    CocoonJS.App.getDestinationProxyObjectAttribute = function (typeName, id, attributeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
            return proxyObject[attributeName];
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Deletes a proxy object identifying it using it's typeName and id. Deleting a proxy object mainly means to remove the instance from the global structure
     * that hold all the instances.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     */
    CocoonJS.App.deleteDestinationProxyObject = function (typeName, id) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            delete parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     */
    CocoonJS.App.addDestinationProxyObjectEventListener = function (typeName, id, eventTypeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            // Look for the proxy object
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];

            var callback = function (event) {
                var proxyObject = this; // event.target;
                // var eventTypeName = CocoonJS.getKeyForValueInDictionary(proxyObject._cocoonjs_proxy_object_data.eventListeners, this); // Avoid closures ;)
                // TODO: Is there a way to retrieve the callbackId without a closure?
                var jsCode = "CocoonJS.App.callOriginProxyObjectEventListeners(" + JSON.stringify(proxyObject._cocoonjs_proxy_object_data.typeName) + ", " + proxyObject._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(eventTypeName) + ");";
                CocoonJS.App.forwardAsync(jsCode);
            };

            proxyObject._cocoonjs_proxy_object_data.eventListeners[eventTypeName] = callback;

            // Finally add the event listener callback to the proxy object
            proxyObject.addEventListener(eventTypeName, callback);
        }
    };

    // TODO: We could add a removeDestinationProxyObjectEventListener although it seems that is not completely necessary.

    /**
     * Proxifies the XMLHttpRequest type for the environment where this call is made. After calling this function, all the new objects
     * of XMLHttpRequest that are instantiated, will be proxified objects that will make calls to the counterparts in the other environment (CocoonJS <-> WebView viceversa).
     * IMPORTANT NOTE: Remember to take down the proxification once you are done or to delete proxy objects whenever they are not needed anymore or memory leaks may occur.
     */
    CocoonJS.App.proxifyXHR = function () {
        var ATTRIBUTE_NAMES =
            [
                "timeout",
                "withCredentials",
                "upload",
                "status",
                "statusText",
                "responseType",
                "response",
                "responseText",
                "responseXML",
                "readyState"
            ];
        var FUNCTION_NAMES =
            [
                "open",
                "setRequestHeader",
                "send",
                "abort",
                "getResponseHeader",
                "getAllResponseHeaders",
                "overrideMimeType"
            ];
        var EVENT_HANDLER_NAMES =
            [
                "onloadstart",
                "onprogress",
                "onabort",
                "onerror",
                "onload",
                "ontimeout",
                "onloadend",
                "onreadystatechange"
            ];
        CocoonJS.App.setupOriginProxyType("XMLHttpRequest", ATTRIBUTE_NAMES, FUNCTION_NAMES, EVENT_HANDLER_NAMES);
    };

    /**
     * Proxifies the Audio type for the environment where this call is made. After calling this function, all the new objects
     * of Audio that are instantiated, will be proxified objects that will make calls to the counterparts in the other environment (CocoonJS <-> WebView viceversa).
     * IMPORTANT NOTE: Remember to take down the proxification once you are done or to delete proxy objects whenever they are not needed anymore or memory leaks may occur.
     */
    CocoonJS.App.proxifyAudio = function () {
        var ATTRIBUTE_NAMES =
            [
                "src",
                "loop",
                "volume",
                "preload"
            ];
        var FUNCTION_NAMES =
            [
                "play",
                "pause",
                "load",
                "canPlayType"
            ];
        var EVENT_HANDLER_NAMES =
            [
                "onended",
                "oncanplay",
                "oncanplaythrough",
                "onerror"
            ];
        CocoonJS.App.setupOriginProxyType("Audio", ATTRIBUTE_NAMES, FUNCTION_NAMES, EVENT_HANDLER_NAMES);
    };

    /**
     * Captures a image of the screen synchronously and saves it to a file. Sync mode allows to capture the screen in the middle of a frame rendering.
     * @param {string} fileName Desired file name and format (png or jpg). If no value is passed, "capture.png" value is used by default
     * @param {CocoonJS.App.StorageType} storageType The developer can specify the storage where it is stored. If no value is passed, the {@link CocoonJS.App.StorageType.TMP_STORAGE} value is used by default.
     * @param {CocoonJS.App.CaptureType} captureType. Optional value to choose capture type. [0: captures everything, 1: only captures cocoonjs surface 2: only captures system views]. @see CocoonJS.App.CaptureType
     * @return The URL of the saved file.
     * @throws exception if the image fails to be stored or there is another error.
     * @see CocoonJS.App.onCaptureScreenSucceeded
     * @see CocoonJS.App.onCaptureScreenFailed
     */
    CocoonJS.App.captureScreen = function (fileName, storageType, captureType) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("captureScreen", fileName, storageType, captureType);
        }
    };

    /**
     * Captures a image of the screen asynchronously and saves it to a file.
     * Async mode captures a final frame as soon as possible.
     * @param {string} Desired file name and format (png or jpg). If no value is passed, "capture.png" value is used by default
     * @param {CocoonJS.App.StorageType} [storageType] The developer can specify the storage where it is stored. If no value is passed, the {@link CocoonJS.App.StorageType.TMP_STORAGE} value is used by default.
     * @param {CocoonJS.App.CaptureType} captureType. Optional value to choose capture type. [0: captures everything, 1: only captures cocoonjs surface, 2: only captures system views]. @see CocoonJS.App.CaptureType
     * @param {function} callback. Response callback, check the error property to monitor errors. Check the 'url' property to get the URL of the saved Image
     */
    CocoonJS.App.captureScreenAsync = function (fileName, storageType, captureType, callback) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCallAsync("captureScreen", fileName, storageType, captureType, callback);
        }
    };

    /**
     * Returns the device UUID
     * @return {string} The device UUID
     */
    CocoonJS.App.getDeviceId = function() {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("getDeviceId");
        }
    };

    /**
     * Structure that defines the getDeviceInfo returned information
     */
    CocoonJS.App.DeviceInfo = {

        /**
        * The operating system name (ios, android,...)
        * @type string
        */
        os: null,

        /**
        * The operating system version (4.2.2, 5.0,...)
        * @type string
        */
        version: null,

        /**
        * The operating system screen density in dpi
        * @type string
        */
        dpi: null,

        /**
        * The device manufacturer (apple, samsung, lg,...)
        * @type string
        */
        brand: null,

        /**
        * The device model (iPhone 4S, SAMSUNG-SGH-I997, SAMSUNG-SGH-I997R, etc)
        * @type string
        */
        model: null,

        /**
        * The phone IMEI
        * Android: The phone IMEI is returned or null if the device has not telepohny
        * iOS: null is returned as we cannot get the IMEI in iOS, no public API available for that yet.
        * @type string
        */
        imei: null,

        /**
        * The platform Id
        * Android: The ANDROID_ID is used.
        * iOS: The OpenUDID is used as there is no Android ANDROID_ID equivalent in iOS
        * @type string
        */
        platformId: null,

        /**
        * The Odin generated id https://code.google.com/p/odinmobile/
        * @type string
        */
        odin: null,

        /**
        * The OpenUDID generated Id https://github.com/ylechelle/OpenUDID
        * @type string
        */
        openudid: null
    };

    /**
     * Returns the device Info
     * @return {CocoonJS.App.DeviceInfo} The device Info
     */
    CocoonJS.App.getDeviceInfo = function() {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("getDeviceInfo");
        }
    };    

    /**
     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.App.onTextDialogFinished} event calls.
     * @name OnTextDialogFinishedListener
     * @function
     * @static
     * @memberOf CocoonJS.App
     * @param {string} text The text that was introduced in the text dialog when it was finished.
     */
    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by accepting it's content.
     * The callback function's documentation is represented by {@link CocoonJS.App.OnTextDialogFinishedListener}
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onTextDialogFinished = new CocoonJS.EventHandler("IDTK_APP", "App", "ontextdialogfinish");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by dismissing it's content.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onTextDialogCancelled = new CocoonJS.EventHandler("IDTK_APP", "App", "ontextdialogcancel");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by accepting it's content.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onMessageBoxConfirmed = new CocoonJS.EventHandler("IDTK_APP", "App", "onmessageboxconfirmed");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by dismissing it's content.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onMessageBoxDenied = new CocoonJS.EventHandler("IDTK_APP", "App", "onmessageboxdenied");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the application is suspended.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onSuspended = new CocoonJS.EventHandler("IDTK_APP", "App", "onsuspended");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the application is activated.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onActivated = new CocoonJS.EventHandler("IDTK_APP", "App", "onactivated");

})();

//////////////////////////////////////
// COCOONJS_APP_FORCOCOONJS.JS		//
//////////////////////////////////////

(function()
{
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before adding more functionalities to an extension.");
    if (typeof window.CocoonJS.App === 'undefined' || window.CocoonJS.App === null) throw("The CocoonJS.App object must exist and be valid before adding more functionalities to it.");

    /**
    * This namespace represents all the basic functionalities available in the CocoonJS extension API.
    * @namespace
    */
    CocoonJS.App = CocoonJS.App ? CocoonJS.App : {};

    if (!CocoonJS.App.nativeExtensionObjectAvailable)
    {
        (function createWebView() { 
            CocoonJS.App.EmulatedWebView = document.createElement('div'); 
            CocoonJS.App.EmulatedWebView.setAttribute('id', 'CocoonJS_App_ForCocoonJS_WebViewDiv'); 
            CocoonJS.App.EmulatedWebView.style.width = 0; 
            CocoonJS.App.EmulatedWebView.style.height = 0; 
            CocoonJS.App.EmulatedWebView.style.position = "absolute"; 
            CocoonJS.App.EmulatedWebView.style.left = 0; 
            CocoonJS.App.EmulatedWebView.style.top = 0;
            CocoonJS.App.EmulatedWebView.style.backgroundColor = 'transparent';
            CocoonJS.App.EmulatedWebView.style.border = "0px solid #000"; 
            CocoonJS.App.EmulatedWebViewIFrame = document.createElement("IFRAME"); 
            CocoonJS.App.EmulatedWebViewIFrame.setAttribute('id', 'CocoonJS_App_ForCocoonJS_WebViewIFrame');
            CocoonJS.App.EmulatedWebViewIFrame.setAttribute('name', 'CocoonJS_App_ForCocoonJS_WebViewIFrame');
            CocoonJS.App.EmulatedWebViewIFrame.style.width = 0; 
            CocoonJS.App.EmulatedWebViewIFrame.style.height = 0; 
            CocoonJS.App.EmulatedWebViewIFrame.frameBorder = 0;
            CocoonJS.App.EmulatedWebViewIFrame.allowtransparency = true;
            CocoonJS.App.EmulatedWebView.appendChild(CocoonJS.App.EmulatedWebViewIFrame);
            if(!document.body)
            document.body = document.createElement("body");
            document.body.appendChild(CocoonJS.App.EmulatedWebView);
        })(); 
    }

    /**
    * Pauses the CocoonJS JavaScript execution loop.
    * @function
    * @augments CocoonJS.App
    */
    CocoonJS.App.pause = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "pause", arguments);
        }
    };

    /**
    * Resumes the CocoonJS JavaScript execution loop.
    * @static
    * @function
    */
    CocoonJS.App.resume = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "resume", arguments);
        }
    };

    /**
    * Loads a resource in the WebView environment from the CocoonJS environment.
    * @function
    * @param {string} path The path to the resource. It can be a remote URL or a path to a local file.
    * @param {CocoonJS.App.StorageType} [storageType] An optional parameter to specify at which storage in the device the file path is stored. By default, APP_STORAGE is used.
    * @see CocoonJS.App.load
    * @see CocoonJS.App.onLoadInTheWebViewSucceed
    * @see CocoonJS.App.onLoadInTheWebViewFailed
    */
    CocoonJS.App.loadInTheWebView = function(path, storageType)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            // TODO: All this code should be changed to a simple call makeNativeExtensionObjectFunctionCall when the native argument control is improved.
            var javaScriptCodeToForward = "ext.IDTK_APP.makeCall('loadPath'";
            if (typeof path !== 'undefined')
            {
                javaScriptCodeToForward += ", '" + path + "'";
                if (typeof storageType !== 'undefined')
                {
                    javaScriptCodeToForward += ", '" + storageType + "'";
                }
            }
            javaScriptCodeToForward += ");";

            return CocoonJS.App.forwardAsync(javaScriptCodeToForward);
        }
        else if (!navigator.isCocoonJS)
        {
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange = function(event) {
                if (xhr.readyState === 4)
                {
                    if (xhr.status === 200)
                    {
                        var callback= function(event){
                            CocoonJS.App.onLoadInTheWebViewSucceed.notifyEventListeners(path);
                            CocoonJS.App.EmulatedWebViewIFrame.removeEventListener("load", callback);
                        };

                        CocoonJS.App.EmulatedWebViewIFrame.addEventListener(
                            "load", 
                            callback
                        );
                        CocoonJS.App.EmulatedWebViewIFrame.contentWindow.location.href= path;
                    }
                    else if (xhr.status === 404)
                    {
                        this.onreadystatechange = null;
                        CocoonJS.App.onLoadInTheWebViewFailed.notifyEventListeners(path);
                    }
                }
            };
            xhr.open("GET", path, true);
            xhr.send();
        }
    };

    /**
     * Reloads the last loaded path in the WebView context.
     * @function
     */
    CocoonJS.App.reloadWebView = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.App.forwardAsync("ext.IDTK_APP.makeCall('reload');");
        }
        else if (!navigator.isCocoonJS)
        {
            CocoonJS.App.EmulatedWebViewIFrame.contentWindow.location.reload();
        }
    };

    /**
    * Shows the webview.
    * @function
    * @param {int} x The top lef x coordinate of the rectangle where the webview will be shown.
    * @param {int} y The top lef y coordinate of the rectangle where the webview will be shown.
    * @param {width} y The width of the rectangle where the webview will be shown.
    * @param {height} y The height of the rectangle where the webview will be shown.
    */
    CocoonJS.App.showTheWebView = function(x, y, width, height)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            var javaScriptCodeToForward = "ext.IDTK_APP.makeCall('show'";
            if (typeof x !== 'undefined' && typeof y !== 'undefined' && typeof width !== 'undefined' && typeof height !== 'undefined')
            {
                javaScriptCodeToForward += ", " + x + ", " + y + ", " + width + ", " + height;
            }
            javaScriptCodeToForward += ");";

            return CocoonJS.App.forwardAsync(javaScriptCodeToForward);
        }
        else if (!navigator.isCocoonJS)
        {
            CocoonJS.App.EmulatedWebViewIFrame.style.width = (width ? width : window.innerWidth)+'px';
            CocoonJS.App.EmulatedWebViewIFrame.style.height = (height ? height : window.innerHeight)+'px';
            CocoonJS.App.EmulatedWebView.style.left = (x ? x : 0)+'px';
            CocoonJS.App.EmulatedWebView.style.top = (y ? y : 0)+'px';
            CocoonJS.App.EmulatedWebView.style.width = (width ? width : window.innerWidth)+'px';
            CocoonJS.App.EmulatedWebView.style.height = (height ? height : window.innerHeight)+'px';
            CocoonJS.App.EmulatedWebView.style.display = "block";
        }
    };

    /**
    * Hides the webview.
    * @function
    */
    CocoonJS.App.hideTheWebView = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            var javaScriptCodeToForward = "ext.IDTK_APP.makeCall('hide');";
            return CocoonJS.App.forwardAsync(javaScriptCodeToForward);
        }
        else if (!navigator.isCocoonJS)
        {
            CocoonJS.App.EmulatedWebView.style.display = "none";
        }
    };

    /**
    * Marks a audio file to be used as music by the system. CocoonJS, internally, differentiates among music files and sound files.
    * Music files are usually bigger in size and longer in duration that sound files. There can only be just one music file 
    * playing at a specific given time. The developer can mark as many files as he/she wants to be treated as music. When the corresponding
    * HTML5 audio object is used, the system will automatically know how to treat the audio resource as music or as sound.
    * Note that it is not mandatory to use this function. The system automatically tries to identify if a file is suitable to be treated as music
    * or as sound by checking file size and duration thresholds. It is recommended, though, that the developer specifies him/herself what he/she considers
    * to be music.
    * @function
    * @param {string} audioFilePath The same audio file path that will be used to create HTML5 audio objects.
    */
    CocoonJS.App.markAsMusic = function(audioFilePath)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
           return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "addForceMusic", arguments);
        }
    };

    /**
    * Activates or deactivates the antialas functionality from the CocoonJS rendering.
    * @function
    * @param {boolean} enable A flag that indicates if the antialas should be activated (true) or deactivated (false).
    */
    CocoonJS.App.setAntialias = function(enable)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
           return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "setDefaultAntialias", arguments);
        }
    };

    /**
    * Sets a callback function that will be called whenever the system tries to finish the app.
    * The developer can specify how the system will react to the finish of the app by returning a
    * boolean value in the callback function: true means, close the app, false means that the developer
    * will handle the app close.
    * A common example of this is the back button in Android devices. When the back button is pressed, this
    * callback will be called and the system will react depending on the developers choice finishing, or not,
    * the application.
    * @function
    * @param {function} appShouldFinishCallback A function object that will be called when the system
    * determines that the app should be finished. This function must return a true or a false value
    * depending on what the developer wants: true === finish the app, false === do not close the app.
    */
    CocoonJS.App.setAppShouldFinishCallback = function(appShouldFinishCallback)
    {
        if (navigator.isCocoonJS)
        {
            window.onidtkappfinish = appShouldFinishCallback;
        }
    }

    /**
    * Sets the texture reduction options. The texture reduction is a process that allows big images to be reduced/scaled down when they are loaded.
    * Although the quality of the images may decrease, it can be very useful in low end devices or those with limited amount of memory.
    * The function sets the threshold on image size (width or height) that will be used in order to know if an image should be reduced or not.
    * It also allows to specify a list of strings to identify in which images file paths should be applied (when they meet the size threshold requirement) 
    * The developer will still think that the image is of the original size. CocoonJS handles all of the internals to be able to show the image correctly.
    * IMPORTANT NOTE: This function should be called when the application is initialized before any image is set to be loaded for obvious reasons ;).
    * and in which sould be forbid (even if they meet the threshold requirement).
    * @function
    * @param {number} sizeThreshold This parameter specifies the minimun size (either width or height) that an image should have in order to be reduced.
    * @param {string or array} [applyTo] This parameter can either be a string or an array of strings. It's purpose is to specify one (the string) or more (the array) substring(s) 
    * that will be compared against the file path of an image to be loaded in order to know if the reduction should be applied or not. If the image meets the
    * threshold size requirement and it's file path contains this string (or strings), it will be reduced. This parameter can also be null.
    * @param {string or array} [forbidFor] This parameter can either be a string or an array of strings. It's purpose is to specify one (the string) or more (the array) substring(s) 
    * that will be compared against the file path of an image to be loaded in order to know if the reduction should be applied or not. If the image meets the
    * threshold size requirement and it's file path contains this string (or strings), it won't be reduced. This parameter should be used in order to mantain the 
    * quality of some images even they meet the size threshold requirement.
    */
    CocoonJS.App.setTextureReduction = function(sizeThreshold, applyTo, forbidFor)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "setDefaultTextureReducerThreshold", arguments);
        }
    };


    /**
    * Prints to the console the memory usage of the currently alive textures
    * @function
    */
    CocoonJS.App.logMemoryInfo = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "logMemoryInfo", arguments);
        }
    };

    /**
    * Enable CocoonJS Webview FPS overlay.
    * @function
    */
    CocoonJS.App.enableFPSInTheWebView = function(fpsLayout, textColor)
    {
        if (!CocoonJS.App.fpsInTheWebViewEnabled)
        {
            fpsLayout = fpsLayout ? fpsLayout : CocoonJS.App.FPSLayout.TOP_RIGHT;
            textColor = textColor ? textColor : "white";
            var jsCode = "" +
                "(function()" +
                "{" +
                    "var COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES = ['js/CocoonJSExtensions/CocoonJS.js', 'js/CocoonJSExtensions/CocoonJS_App.js', 'js/CocoonJSExtensions/CocoonJS_App_ForWebView.js'];" +
                    "var loadedScriptCounter = 0;" + 
                    "var loadedScriptFunction = function() " +
                    "{ " +
                        "loadedScriptCounter++;"+
                        "if (loadedScriptCounter >= COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES.length)"+
                        "{"+
                            "CocoonJS.App.enableFPS(" + JSON.stringify(fpsLayout) + ", " + JSON.stringify(textColor) + ");"+
                        "}"+
                    "};"+
                    "for (var i = 0; i < COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES.length; i++)"+
                    "{"+
                        "var s = document.createElement('script');"+
                        "s.onload = loadedScriptFunction;"+
                        "s.src = COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES[i];"+
                        "document.body.appendChild(s);"+
                    "}" +
                "})();";
            setTimeout(function()
            {
                CocoonJS.App.forward(jsCode);
            }, 3000);
            CocoonJS.App.fpsInTheWebViewEnabled = true;
        }
    };

    /**
    * Disable CocoonJS Webview FPS overlay.
    * @function
    */
    CocoonJS.App.disableFPSInTheWebView = function()
    {
        // TODO: Implement this function.
    };

    /**
     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.App.onLoadInTheWebViewSucceed} event calls.
     * @name OnLoadInTheWebViewSucceedListener
     * @function
     * @static
     * @memberOf CocoonJS.App
     * @param {string} pageURL The URL of the page that had been loaded in the webview.
     */
    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the WebView load has completed successfully.
    * The callback function's documentation is represented by {@link CocoonJS.App.OnLoadInTheWebViewSucceedListener}
    * @event
    * @static
    * @memberOf CocoonJS.App
    * @param {string} pageURL A string that represents the page URL loaded.
    */
    CocoonJS.App.onLoadInTheWebViewSucceed = new CocoonJS.EventHandler("IDTK_APP", "App", "forwardpageload");

    /**
     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.App.onLoadInTheWebViewFailed} event calls.
     * @name OnLoadInTheWebViewFailedListener
     * @function
     * @static
     * @memberOf CocoonJS.App
     * @param {string} pageURL The URL of the page that had been loaded in the webview.
     */
    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the WebView load fails.
    * The callback function's documentation is represented by {@link CocoonJS.App.OnLoadInTheWebViewFailedListener}
    * @event
    * @static
    * @memberOf CocoonJS.App
    */
    CocoonJS.App.onLoadInTheWebViewFailed = new CocoonJS.EventHandler("IDTK_APP", "App", "forwardpagefail");
    
})();

//////////////////////////////////////
// COCOONJS_AD.JS                   //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
    * This namespace represents the CocoonJS Advertisement extension API.
    * @namespace
    */
    CocoonJS.Ad = {};

    CocoonJS.Ad.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_SRV_AD !== 'undefined';

    /**
    * The predefined possible layouts for a banner ad.
    * @namespace 
    */
	CocoonJS.Ad.BannerLayout = 
	{
		/**
		* Specifies that the banner must be shown in the top of the screen and vertically centered.
		*/
	    TOP_CENTER      : "TOP_CENTER",

		/**
		* Specifies that the banner must be shown in the bottom of the screen and vertically centered.
		*/
	    BOTTOM_CENTER   : "BOTTOM_CENTER"
	};

	/**
    * A rectangle object that contains the banner dimensions
    * @namespace 
    * @constructor
    * @param {int} x The top lef x coordinate of the rectangle.
    * @param {int} y The top lef y coordinate of the rectangle.
    * @param {width} y The rectangle width.
    * @param {height} y The rectangle height.
    */
	CocoonJS.Ad.Rectangle = function(x, y, width, height) 
	{
		/**
		* The top lef x coordinate of the rectangle 
		* @field 
		* @type {int}
		*/
	    this.x = x;

		/**
		* The top lef y coordinate of the rectangle 
		* @field 
		* @type {int}
		*/
	    this.y = y;

	    /**
		* The rectangle width
		* @field 
		* @type {int}
		*/
	    this.width = width;

	    /**
		* The rectangle height
		* @field 
		* @type {int}
		*/
	    this.height = height;
	};

	CocoonJS.Ad.Banner = function(id)
	{
		if (typeof id !== 'number') throw "The given ad ID is not a number.";

		this.id = id;
		var me = this;

		/**
    	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is shown.
    	* The callback function does not receive any parameter.
    	* @static
    	* @event
    	*/
		this.onBannerShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannershow", function(sourceListener, args)
    	{
    		if (me.id === args[0]) 
    		{
    			sourceListener();
    		}
    	});

    	/**
    	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is hidden.
    	* The callback function does not receive any parameter.
    	* @static
    	* @event
    	*/
		this.onBannerHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerhide", function(sourceListener, args)
    	{
    		if (me.id === args[0]) 
    		{
    			sourceListener();
    		}
    	});

    	/**
    	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is ready (cached).
    	* The callback function does not receive any parameter.
    	* @param {number} width The banner width
    	* @param {number} height The banner height
    	* @static
    	* @event
    	*/
		this.onBannerReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerready", function(sourceListener, args)
    	{
    		if (me.id === args[0]) 
    		{
    			sourceListener(args[1], args[2]);
    		}
    	});
	};

	CocoonJS.Ad.Banner.prototype = {

		/**
		* Shows a banner ad if available.
		* @function
		*/
		showBanner : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showBanner", [this.id], true);
			}
		},

		/**
		* Hides the banner ad if it was being shown.
		* @function
		*/
		hideBanner : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "hideBanner", [this.id], true);
			}
		},

		/**
		* Refreshes the banner.
		* @function
		*/
		refreshBanner : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshBanner", [this.id], true);
			}
		},

		/**
		* Gets the rectangle representing the banner screen position.
		* @function
		* @return {CocoonJS.Ad.Rectangle} rectangle The rectangle representing the banner position and domensions.
		*/
		getRectangle : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "getRectangle", [this.id]);
			}
		},

		/**
		* Sets the rectangle where the banner ad is going to be shown.
		* @function
		* @param {CocoonJS.Ad.Rectangle} rect The rectangle representing the banner position and domensions.
		*/
		setRectangle : function(rect)
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setRectangle", [this.id, rect],true);
			}
		},

		/**
		* Sets the rectangle where the banner ad is going to be shown.
		* You can use this method if you want to have better control of the banner screen positioning.
		* @function
		* @param {CocoonJS.Ad.BannerLayout} bannerLayout The layout where the bannerwill be placed.
		*/
		setBannerLayout : function(bannerLayout)
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setBannerLayout", [this.id, bannerLayout],true);
			}
		}
	};

	CocoonJS.Ad.Fullscreen = function(id)
	{
		if (typeof id !== 'number') throw "The given ad ID is not a number.";

		this.id = id;
		var me = this;

		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is shown.
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    */
		this.onFullScreenShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenshow", function(sourceListener, args)
    	{
    		if (me.id === args[0]) {
    			sourceListener();
    		}
    	});

		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is hidden.
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    */
    	this.onFullScreenHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenhide", function(sourceListener, args)
    	{
    		if (me.id === args[0]) {
    			sourceListener();
    		}
    	});

    	/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is ready (cached).
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    */
    	this.onFullScreenReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenready", function(sourceListener, args)
    	{
    		if (me.id === args[0]) {
    			sourceListener();
    		}
    	});
	};

	CocoonJS.Ad.Fullscreen.prototype = {

		/**
		* Shows a full screen ad if available.
		* @function
		* @see CocoonJS.Ad.onFullScreenShown
		* @see CocoonJS.Ad.onFullScreenHidden
		*/
		showFullScreen : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showFullScreen", [this.id], true);
			}
		},

		/**
		* Refreshes the fullscreen.
		* @function
		*/
		refreshFullScreen : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshFullScreen", [this.id], true);
			}
		}
	};

	/**
	* Initialize the service with service level initialization parameters.
	* @function
	* @param {object} An object with the required initialization parameters for the service.
	*/
	CocoonJS.Ad.requestInitialization = function(parameters)
	{
        if (typeof parameters === "undefined") {
            parameters = {};
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "requestInitialization", arguments, true);
		}
	};

	/**
	* Creates a new banner ad.
	* @function
	* @param {object} An object containing the properties the ad will need for its initialization.
	*/
	CocoonJS.Ad.createBanner = function(parameters)
	{
		if (typeof parameters === "undefined") {
            parameters = {};
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			var adId = CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "createBanner", [parameters]);
			var banner = new CocoonJS.Ad.Banner(adId);

			return banner;
		}
	};

	/**
	* Releases a banner.
	* @function
	* @param {object} The banner ad object to be released.
	*/
	CocoonJS.Ad.releaseBanner = function(banner)
	{
		if (typeof banner === "undefined") {
            throw "The banner ad object to be released is undefined"
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "releaseBanner", [banner.id]);
		}
	};

	/**
	* Creates a new fullscreen ad.
	* @function
	* @param {object} An object containing the properties the ad will need for its initialization.
	*/
	CocoonJS.Ad.createFullscreen = function(parameters)
	{
		if (typeof parameters === "undefined") {
            parameters = {};
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			var adId = CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "createFullscreen", [parameters]);
			var fullscreen = new CocoonJS.Ad.Fullscreen(adId);

			return fullscreen;
		}
	};

	/**
	* Releases a fullscreen ad.
	* @function
	* @param {object} The fullscreen ad object to be released.
	*/
	CocoonJS.Ad.releaseFullscreen = function(fullscreen)
	{
		if (typeof fullscreen === "undefined") {
            throw "The fullscreen ad object to be released is undefined"
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "releaseFullscreen", [fullscreen.id]);
		}
	};

	/**
	* Shows a banner ad if available.
	* @function
	* @see CocoonJS.Ad.setBannerLayout
	* @see CocoonJS.Ad.onBannerShown
	*/
	CocoonJS.Ad.showBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showBanner", arguments, true);
		}
	};

	/**
	* Hides the banner ad if it was being shown.
	* @function
	*/
	CocoonJS.Ad.hideBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "hideBanner", arguments, true);
		}
	};

	/**
	* Refreshes the banner.
	* @function
	*/
	CocoonJS.Ad.refreshBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshBanner", arguments, true);
		}
	};

	/**
	* Shows a full screen ad if available.
	* @function
	* @see CocoonJS.Ad.onFullScreenShown
	* @see CocoonJS.Ad.onFullScreenHidden
	*/
	CocoonJS.Ad.showFullScreen = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showFullScreen", arguments, true);
		}
	};

	/**
	* Refreshes the fullscreen.
	* @function
	*/
	CocoonJS.Ad.refreshFullScreen = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshFullScreen", arguments, true);
		}
	};

	/**
	* Makes a request to preload a banner ad.
	* @function
	*/
	CocoonJS.Ad.preloadBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "preloadBanner", arguments, true);
		}
	};

	/**
	* Makes a request to preload a full screen ad.
	* @function
	*/
	CocoonJS.Ad.preloadFullScreen = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "preloadFullScreen", arguments, true);
		}
	};

	/**
	* Sets the rectangle where the banner ad is going to be shown.
	* @function
	* @param {CocoonJS.Ad.Rectangle} rect The rectangle representing the banner position and domensions.
	*/
	CocoonJS.Ad.setRectangle = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setRectangle", arguments, true);
		}
	};

	/**
	* Gets the rectangle representing the banner screen position.
	* @function
	* @return {CocoonJS.Ad.Rectangle} rectangle The rectangle representing the banner position and domensions.
	*/
	CocoonJS.Ad.getRectangle = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "getRectangle", arguments);
		}
	};

	/**
	* Sets the rectangle where the banner ad is going to be shown.
	* You can use this method if you want to have better control of the banner screen positioning.
	* @function
	* @param {CocoonJS.Ad.BannerLayout} bannerLayout The layout where the bannerwill be placed.
	*/
	CocoonJS.Ad.setBannerLayout = function(bannerLayout)
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setBannerLayout", arguments, true);
		}
	};

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is shown.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onBannerShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannershow");

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is hidden.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onBannerHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerhide"); 

	/**
	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is ready (cached).
	* The callback function does not receive any parameter.
	* @param {number} width The banner width
	* @param {number} height The banner height
	* @static
	* @event
	*/
	CocoonJS.Ad.onBannerReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerready"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is shown.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onFullScreenShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenshow"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is hidden.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onFullScreenHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenhide");

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is ready (cached).
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onFullScreenReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenready"); 

})();

//////////////////////////////////////
// COCOONJS_STORE.JS                //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
    * This namespace represents the CocoonJS In-App Purchase extension.
    * @namespace
    */
    CocoonJS.Store = {};

    CocoonJS.Store.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_SRV_STORE !== 'undefined';

	/**
	* The data structure that represents the information of a product in the store.
	* @namespace
	* @constructor
	* @param {string} The id of the product.
	* @param {string} The alias of the product.
	* @param {CocoonJS.Store.ProductType} The product type @see CocoonJS.Store.ProductType.
	* @param {string} The title of the product.
	* @param {string} The description of the product.
	* @param {string} The localized price of the product.
	* @param {string} The URL of the asset to be downloaded for this purchase.
	*/
	CocoonJS.Store.ProductInfo = function(productAlias, productId, productType, title, description, price, localizedPrice, downloadURL)
	{
		/**
		* The id of the product.
		* @field
		* @type string
		*/
		this.productId = productId;

		/**
		* The alias of the product.
		* @field
		* @type string
		*/
		this.productAlias = productAlias;

		/**
		* The product type @see CocoonJS.Store.ProductType
		* @field
		* @type CocoonJS.Store.ProductType
		*/
		this.productType = productType;

		/**
		* The title of the product.
		* @field
		* @type string
		*/
		this.title = title;

		/**
		* The description of the product.
		* @field
		* @type string
		*/
		this.description = description;

		/**
		* The price of the product.
		* @field
		* @type string
		*/
		this.price = price;

		/**
		* The localized price of the product.
		* @field
		* @type string
		*/
		this.localizedPrice = localizedPrice;

		/**
		* The URL of the asset to be downloaded for this purchase.
		* @field
		* @type string
		*/
		this.downloadURL = downloadURL;

		return this;
	};

	/**
    * The predefined possible states of a purchase.
    * @namespace 
    */
	CocoonJS.Store.ProductType = 
	{
		/**
		* A consumable product. See platform documentation for further information.
		*/
	    CONSUMABLE : 0,

		/**
		* A non-cunsumable product. . See platform documentation for further information.
		*/
	    NON_CONSUMABLE : 1,

	    /**
		* An auto-renewable subscription. See platform documentation for further information.
		*/
	    AUTO_RENEWABLE_SUBSCRIPTION : 2,

	    /**
		* A free subscription. See platform documentation for further information.
		*/
	    FREE_SUBSCRIPTION : 3,

	    /**
		* A non-renewable subscription. See platform documentation for further information.
		*/
	    NON_RENEWABLE_SUBSCRIPTION : 4
	};

	/**
    * The predefined possible store types.
    * @namespace 
    */
	CocoonJS.Store.StoreType = 
	{
		/**
		* Apple AppStore
		*/
	    APP_STORE : 0,

	    /**
	    * Android Play Store
	    */
	    PLAY_STORE : 1,

		/**
		* Mock Store
		*/
		MOCK_STORE : 2,

		/**
	    * Amazon AppStore
	    */
	    CHROME_STORE : 3,

	    /**
	    * Amazon AppStore
	    */
	    AMAZON_STORE : 4,

	    /**
	    * Nook Store
	    */
	    NOOK_STORE : 5
	};

	/**
	* The data structure that represents the information of a purchase.
	* @namespace
	* @constructor
	* @param {string} The transaction id of a purchase.
	* @param {string} The time when the purchase was done in seconds since 1970.
	* @param {CocoonJS.Store.PurchaseState} The state of the purchase. @see CocoonJS.Store.PurchaseState
	* @param {string} The product id related to this purchase.
	* @param {number} The number of products of the productId kind purchased in this transaction.
	*/
	CocoonJS.Store.PurchaseInfo = function(transactionId, purchaseTime, purchaseState, productId, quantity)
	{
		/**
		* The transaction id of a purchase.
		* @field
		* @type string
		*/
		this.transactionId = transactionId;

		/**
		* The time when the purchase was done in seconds since 1970.
		* @field
		* @type string
		*/
		this.purchaseTime = purchaseTime;

		/**
		* The state of the purchase. @see CocoonJS.Store.PurchaseState
		* @field
		* @type CocoonJS.Store.PurchaseState
		*/
		this.purchaseState = purchaseState;

		/**
		* The product id related to this purchase.
		* @field
		* @type string
		*/
		this.productId = productId;

		/**
		* The number of products of the productId kind purchased in this transaction.
		* @field
		* @type number
		*/
		this.quantity = quantity;

		return this;
	};

	/**
    * The predefined possible states of a purchase.
    * @namespace 
    */
	CocoonJS.Store.PurchaseState = 
	{
		/**
		* The product has been successfully purchased. The transaction has ended successfully.
		*/
	    PURCHASED : 0,

		/**
		* The purchase has been canceled.
		*/
	    CANCELED : 1,

	    /**
		* The purchase has been refunded.
		*/
	    REFUNDED : 2,

	    /**
		* The purchase (subscriptions only) has expired and is no longer valid.
		*/
	    EXPIRED : 3
	};

	/**
	* Gets the name of the native store implementation. 
	* @return {CocoonJS.Store.StoreType} The store type
	* @function
	*/ 
	CocoonJS.Store.getStoreType = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "getStoreType", arguments);
		}
	};

	/**
	* Initialize the service with service level initialization parameters.
	* @function
	* @param {object} An object with the required initialization parameters for the service.
	*/
	CocoonJS.Store.requestInitialization = function(parameters)
	{
        if (typeof parameters === "undefined") 
        {
            parameters = {};
        }
        else
        {
        	if (parameters['managed'] !== undefined) parameters['remote'] = parameters['managed'];
        	if (parameters['sandbox'] !== undefined) parameters['debug'] = parameters['sandbox'];
        }

		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "requestInitialization", arguments, true);
		}
	};

	/**
	* Starts the Store Service. 
	* This will make the system to initialize the Store Service and probably Store callbacks will start to be received after calling this method so you should have set your event handler before calling this method so don't lose any callback.
	* @function
	*/ 
	CocoonJS.Store.start = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "start", arguments);
		}
	};

	/**
	* This method allows you to check is the  Store service is available in this platform. 
	* Not all iOS and Android devices will have the Store service available so you should check if it is before calling any other method.
	* @function
	* @return {boolean} True if the service is available and false otherwise.
	*/ 
	CocoonJS.Store.canPurchase = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "canPurchase", arguments);
		}
	};

	/**
	* Fetches the products from the CocoonJS Cloud Compiling service store configuration. 
	* The request is monitored using the {@link CocoonJS.Store.onProductsFetchStarted}, {@link CocoonJS.Store.onProductsFetchCompleted} and {@link CocoonJS.Store.onProductsFetchFailed} event handlers.
	* @deprecated You should now use fetchProductsFromStore. We don't support cloud products now.
	* @function
	* @see CocoonJS.Store.onProductsFetchStarted
	* @see CocoonJS.Store.onProductsFetchCompleted
	* @see CocoonJS.Store.onProductsFetchFailed
	*/ 
	CocoonJS.Store.fetchProductsFromServer = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "fetchProductsFromServer", arguments, true);
		}
	};

	/**
	* Fetches the products information from the Store. 
	* The request is monitored using the {@link CocoonJS.Store.onProductsFetchStarted}, {@link CocoonJS.Store.onProductsFetchCompleted} and {@link CocoonJS.Store.onProductsFetchFailed} event handlers.
	* @function
	* @param {array} productIds An array with the ids of the products to retrieve information from.
	* @see CocoonJS.Store.onProductsFetchStarted
	* @see CocoonJS.Store.onProductsFetchCompleted
	* @see CocoonJS.Store.onProductsFetchFailed
	*/ 
	CocoonJS.Store.fetchProductsFromStore = function(productIds)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "fetchProductsFromStore", arguments, true);
		}
	};

	/**
	* Finish a purchase transaction and removes the transaction from the transaction queue. 
	* This method must be called after a purchase finishes successfully and the  {@link CocoonJS.Store.onProductPurchaseCompleted} callback has been received. 
	* If the purchase includes some asset to download from an external server this method must be called after the asset has been successfully downloaded. 
	* If you do not finish the transaction because the asset has not been correctly downloaded the {@link CocoonJS.Store.onProductPurchaseStarted} method will be called again later on.
	* @function
	* @param {string} transactionId The transactionId of the purchase to finish.
	*/ 
	CocoonJS.Store.finishPurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "finishPurchase", arguments, true);
		}
	};

	/**
	* Consumes a purchase. This makes that product to be purchasable again. 
	* @function
	* @param {string} transactionId The transaction Id of the purchase to consume.
	* @param {string} productId The product Id of the product to be consumed.
	*/ 
	CocoonJS.Store.consumePurchase = function(transactionId, productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "consumePurchase", arguments, true);
		}
	};

	/**
	* Request a product purchase given it's product id. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} productId The id or alias of the product to be purchased.
	* @see CocoonJS.Store.onProductPurchaseStarted
	* @see CocoonJS.Store.onProductPurchaseCompleted
	* @see CocoonJS.Store.onProductPurchaseFailed
	*/ 
	CocoonJS.Store.purchaseProduct = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "purchaseFeature", arguments, true);
		}
	};

	/**
	* Request a product purchase given it's product id showing a modal progress dialog. 
	* The request is monitored using the {@link CocoonJS.Store.onProductPurchaseStarted}, {@link CocoonJS.Store.onProductPurchaseCompleted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} productId The id or alias of the product to be purchased.
	* @see CocoonJS.Store.onProductPurchaseStarted
	* @see CocoonJS.Store.onProductPurchaseCompleted
	* @see CocoonJS.Store.onProductPurchaseFailed
	*/ 
	CocoonJS.Store.puchaseProductModal = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "purchaseFeatureModal", arguments, true);
		}
	};

	/**
	* Request the purchase of a product given it's product id showing a dialog with a preview of the product (title and description). 
	* The request is monitored using the {@link CocoonJS.Store.onProductPurchaseStarted}, {@link CocoonJS.Store.onProductPurchaseCompleted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} productId The id or alias of the product to be purchased.
	* @see CocoonJS.Store.onProductPurchaseStarted
	* @see CocoonJS.Store.onProductPurchaseCompleted
	* @see CocoonJS.Store.onProductPurchaseFailed
	*/ 
	CocoonJS.Store.purchaseProductModalWithPreview = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "purchaseFeatureModalWithPreview", arguments, true);
		}
	};

	/**
	* Returns if a product has been already purchased or not. 
	* @function
	* @param {string} productId The product id or alias of the product to be checked.
	* @returns {boolean} A flag that indicates whether the product has been already purchased (true) or not (false).
	*/
	CocoonJS.Store.isProductPurchased = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "isFeaturePurchased", arguments);
		}
	};

	/**
	* Restores all the purchases from the platform's market. 
	* For each already purchased product {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onPurchaseProductCompleted} and {@link CocoonJS.Store.onPurchaseProductFailed} event handlers are called again
	* @function
	* @see CocoonJS.Store.onRestorePurchasesStarted
	* @see CocoonJS.Store.onRestorePurchasesCompleted
	* @see CocoonJS.Store.onRestorePurchasesFailed
	*/
	CocoonJS.Store.restorePurchases = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "restorePurchases", arguments, true);
		}
	};

	/**
	* Restores all the purchases from the platform's market showing a modal progress dialog. 
	* For each already purchased product {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onPurchaseProductCompleted} and {@link CocoonJS.Store.onPurchaseProductFailed} event handlers are called again
	* @function
	* @see CocoonJS.Store.onRestorePurchasesStarted
	* @see CocoonJS.Store.onRestorePurchasesCompleted
	* @see CocoonJS.Store.onRestorePurchasesFailed
	*/
	CocoonJS.Store.restorePurchasesModal = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "restorePurchasesModal", arguments, true);
		}
	};

	/**
	* Returns all the products available to be purchased.
	* @function
	* @returns {array} An array with  all the {@link CocoonJS.Store.ProductInfo} objects available for purchase.
	*/
	CocoonJS.Store.getProducts = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "getProducts", arguments);
		}
	};

	/**
	* Adds a product to the products local DB. 
	* @function
	* @param {CocoonJS.Store.ProductInfo} product The product to be added to the local products DB.
	*/
	CocoonJS.Store.addProduct = function(product)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "addProduct", arguments);
		}
	};

	/**
	* Removes a product from the products local DB given its productId. 
	* @function
	* @param {string} productId The product or alias of the product to be removed from the local products DB.
	*/
	CocoonJS.Store.removeProduct = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "removeProduct", arguments);
		}
	};

	/**
	* Returns all the locally stored purchases.
	* @function
	* @returns {array} An array with all the {@link CocoonJS.Store.PurchaseInfo} completed purchases.
	*/
	CocoonJS.Store.getPurchases = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "getPurchases", arguments);
		}
	};

	/**
	* Adds a purchase to the local purchases DB. 
	* @function
	* @param {CocoonJS.Store.StorePurchase} purchase The purchase to be added.
	*/ 
	CocoonJS.Store.addPurchase = function(purchase)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "addPurchase", arguments);
		}
	};

	/**
	* Removes a purchase from the local purchases DB given it's transaction id. 
	* @function
	* @param {string} transactionId The id of the transaction to be removed.
	*/ 
	CocoonJS.Store.removePurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "removePurchase", arguments);
		}
	};

	/**
	* (TESTING ONLY) Simulate a purchase cancel. 
	* This method is not allowed in production services and will only work in Mocks. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} transactionId The transactionId of the purchase to be canceled.
	*/
	CocoonJS.Store.cancelPurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "cancelPurchase", arguments);
		}
	};

	/**
	* (TESTING ONLY) Simulate a purchase refundment. 
	* This method is not allowed in production services and will only work in Mocks. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} transactionId The transactionId of the purchase to be refunded.
	*/
	CocoonJS.Store.refundPurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "refundPurchase", arguments);
		}
	};

	/**
	* (TESTING ONLY) Simulate a purchase expiration. 
	* This method is not allowed in production services and will only work in Mocks. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} transactionId The transactionId of the purchase to be expired.
	*/
	CocoonJS.Store.expirePurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "expirePurchase", arguments);
		}
	};

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the products fetch has started.
    * The callback function receives no parameters.
    * @static
    * @event
    */
	CocoonJS.Store.onProductsFetchStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductsFetchStarted");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the products fetch has completed.
    * The callback function receives a parameter with an the valid products array.
    * @static
    * @event
    * @param {array} validProducts An array of {@link CocoonJS.Store.ProductInfo} objects representing all the valid fetched products.
    */
	CocoonJS.Store.onProductsFetchCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductsFetchCompleted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the products fetch has failed.
    * The callback function receives an error message as a parameter.
    * @static
    * @event
    * @param {string} errorMessage The error message.
    */
	CocoonJS.Store.onProductsFetchFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductsFetchFailed"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the purchase of a product starts.
    * The callback function receives a parameters with the information of the purchased product @see CocoonJS.Store.ProductInfo.
    * @static
	* @event
    * @param {string} productId The product id of the product being purchased.
    */
	CocoonJS.Store.onProductPurchaseStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseStarted"); 

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a request for purchase verification has been received from the Store.
    * The callback function receives two parameters, one with the productId of the purchased product and another one with a JSON object containing the data to be verified.
    * In Andorid this JSON object will containt two keys: signedData and signature. You will need that information to verify the purchase against the backend server.
    * @static
    * @event
    * @param {string} productId The product id of the product to be verified.
    * @param {string} data The string with the data to be verified.
    */
	CocoonJS.Store.onProductPurchaseVerificationRequestReceived = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseVerificationRequestReceived");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the purchase of a product succeeds.
    * The callback function receives as parameter the information of the purchase {@see CocoonJS.Store.PurchaseInfo}.
    * @static
    * @event
    * @param {CocoonJS.Store.PurchaseInfo} purchaseInfo The purchase info.
    */
	CocoonJS.Store.onProductPurchaseCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseCompleted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the purchase of a product fails.
    * The callback function receives a parameters with the product id and an error message.
    * @static
    * @event
    * @param {string} productId The product id.
    * @param {string} msg The error message.
    */
	CocoonJS.Store.onProductPurchaseFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseFailed"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the restore purchases operation has started.
    * The callback function receives no parameters.
    * @static
    * @event
    */
	CocoonJS.Store.onRestorePurchasesStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onRestorePurchasesStarted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the restore purchases operation has completed.
    * The callback function receives no parameters.
    * @static
    * @event
    */
	CocoonJS.Store.onRestorePurchasesCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onRestorePurchasesCompleted"); 

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the restore purchases operation has failed.
    * The callback function receives an error message as a parameter.
    * @static
    * @event
    * @param {string} errorMessage The error message.
    */
	CocoonJS.Store.onRestorePurchasesFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onRestorePurchasesFailed");

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the consume purchase operation has started.
    * @static
    * @event
    * @param {string} transactionId The transaction id of the purchase being consumed.
    */
	CocoonJS.Store.onConsumePurchaseStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onConsumePurchaseStarted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the consume purchase operation has completed.
    * @static
    * @event
    * @param {string} transactionId The transaction id of the consumed purchase.
    */
	CocoonJS.Store.onConsumePurchaseCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onConsumePurchaseCompleted"); 

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the consume purchase operation has failed.
    * @static
    * @event
    * @param {string} transactionId The transaction id of the purchase that couldn't be consumed.
    * @param {string} errorMessage The error message.
    */
	CocoonJS.Store.onConsumePurchaseFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onConsumePurchaseFailed");

})();

//////////////////////////////////////
// COCOONJS_SOCIAL.JS               //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

	/**
	* This type represents the access to a native Social extension API. As there can be more than
	* one service of this type, more than one instance can be created.
	* @namespace
	* @constructor
	* @param {string} nativeExtensionName The name of the native ext object extension property name.
	* @param {string} extensionName The name of the CocoonJS object extension property name.
	*/
	CocoonJS.Social = function(nativeExtensionName, extensionName)
	{
		if (typeof nativeExtensionName !== 'string') throw "The given native extension name '" + nativeExtensionName + "' is not a string.";
		if (typeof extensionName !== 'string') throw "The given extension name '" + extensionName + "' is not a string.";

		this.nativeExtensionName = nativeExtensionName;
		this.extensionName = extensionName;
	    this.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext[nativeExtensionName] !== 'undefined';

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestInitializationSucceed} event calls.
	     * @name OnRequestInitializationSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {object} initializationData The data structure passed when requestInitialization was called.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestInitializationSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
	    this.onRequestInitializationSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestInitializationSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestInitializationFailed} event calls.
	     * @name OnRequestInitializationFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {object} initializationData The data structure passed when the requestInitialization function was called.
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestInitializationFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
	    this.onRequestInitializationFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestInitializationFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestLoginSucceed} event calls.
	     * @name OnRequestLoginSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {CocoonJS.Social.UserInfo} userInfo The structure that describes the information of the user that logged in.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user login request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestLoginSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestLoginSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestLoginSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestLoginFailed} event calls.
	     * @name OnRequestLoginFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user login request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestLoginFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestLoginFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestLoginFailed");

	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user logs out.
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onLogout = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLogout");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserInfoSucceed} event calls.
	     * @name OnRequestUserInfoSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {CocoonJS.Social.UserInfo} userInfo The structure that describes the information of the request user id.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnUserInfoRequestSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserInfoSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserInfoSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserInfoFailed} event calls.
	     * @name OnRequestUserInfoFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id used in the request.
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnUserInfoRequestFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserInfoFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserInfoFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserImageURLSucceed} event calls.
	     * @name OnRequestUserImageURLSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id used in the request.
	     * @param {string} imageURL The URL of the image of the requested user. 
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user image URL request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserImageURLSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserImageURLSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserImageURLSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserImageURLFailed} event calls.
	     * @name OnRequestUserImageURLFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id of the user the request was placed for.
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user image URL request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserImageURLFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserImageURLFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserImageURLFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserFriendsUserInfosSucceed} event calls.
	     * @name OnRequestUserFriendsUserInfosSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id of the user for whom the friend user infos where requested.
	     * @param {array} friendsInfo An array of {@link CocoonJS.Social.UserInfo} objects representing the information of the friends of the user.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's friends info is successfully retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserFriendsUserInfosSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserFriendsUserInfosSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserFriendsUserInfosSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserFriendsUserInfosFailed} event calls.
	     * @name OnRequestUserFriendsUserInfosFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param 
	     * @param {string} userID The id of the user fro whom the friends infos were requested.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's friends info fails to be retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserFriendsUserInfosFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserFriendsUserInfosFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserFriendsUserInfosFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestMessagePublicationSucceed} event calls.
	     * @name OnRequestMessagePublicationSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
 	     * @param {CocoonJS.Social.Message} message The message that has been published.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user message publication request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestMessagePublicationSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    * @param {CocoonJS.Social.Message} message The message that has been published.
	    */
		this.onRequestMessagePublicationSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestMessagePublicationSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestMessagePublicationFailed} event calls.
	     * @name OnRequestMessagePublicationFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {CocoonJS.Social.Message} message The message that was supposed to be published.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user message publication request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestMessagePublicationFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestMessagePublicationFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestMessagePublicationFailed");

		/**
        * @ignore
        */
        this.on= function(event, callback) {
            event= "on"+event[0].toUpperCase()+event.substr(1);
            var signal= this[event];
            if (signal) {
                signal.addEventListener(callback);
            } else {
                console.error("SocialGaming service: '"+this.extensionName+"' does not understand '"+event+' signal.');
            }

            return this;
        };

	    return this;
	};

	CocoonJS.Social.prototype = {
        userInfo : null,
        userInfoCocoonJS : null,

        /**
        * @ignore
        */
        getUserInfo : function() {
            return this.userInfo;
        },

        /**
        * Returns the information of the currently logged in user.
        * @return {@link CocoonJS.Social.UserInfo}
        */
        getLoggedInUserInfo : function() {
            if (this.nativeExtensionObjectAvailable) {
                return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "getLoggedInUserInfo", arguments);
            }
            else {
                return this.userInfoCocoonJS;
            }
        },

        /**
        * @ignore
        */
        setUserInfo : function( userInfo) {
            this.userInfo= userInfo;
        },

        /**
        * @ignore
        */
        setUserInfoCocoonJS : function( userInfoCocoonJS ) {
            this.userInfoCocoonJS = userInfoCocoonJS;
        },

		/**
        * Request initialization of the underlying social service.
        * @param {object} paramsObject A data structure to initialize the service. It will be dependable of the underlying service.
        * @see CocoonJS.Social.onRequestInitializationSucceed
        * @see CocoonJS.Social.onRequestInitializationFailed
        */
		requestInitialization : function(paramsObject) 
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestInitialization", arguments, true);
			}
		},

		/**
        * Returns a flag to indicate if the underlying service has been initialized or not.
        * @return {boolean} If the underlying service had been initialized using the requestInitialization function call.
        */
		isInitialized : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "isInitialized", arguments);
			}
			else
			{
				return false;
			}
		},

		/**
		* Request to log in the social gaming application.
		* @see CocoonJS.Social.onRequestLoginSucceed
		* @see CocoonJS.Socual.onRequestLoginFailed
		*/
		requestLogin : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestLogin", arguments, true);
			}
		},

		/**
		* Request to log out of the social gaming application.
		* @see CocoonJS.Social.onRequestLoginSucceed
		* @see CocoonJS.Social.onRequestLoginFailed
		* @see CocoonJS.Social.onLogout
		*/
		requestLogout : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestLogout", arguments, true);
			}
		},

		/**
		* Check if the user is logged in.
		* @return {boolean} true if the user is still logged in, false otherwise.
		*/
		isLoggedIn : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "isLoggedIn", arguments);
			}
			else
			{
				return false;
			}
		},

		/**
		* Returns all the granted permissions for the current session.
		* @return {Array} An array containin the user granted permissions.
		*/
		getPermissions : function() 
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "getPermissions", arguments);
			}
			else
			{
				return new Array();
			}
		},

		/**
		* Check if the user has granted the publish permission for the current session.
		* @return {boolean} true if the user has granted the publish permission for the current session, false otherwise.
		*/
		hasPublishPermission : function() 
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "hasPublishPermission", arguments);
			}
			else
			{
				return false;
			}
		},

		/**
		* Request to retrieve the current or a specific user's id. The request can be monitored using the {@link CocoonJS.Social.onUserInfoRequestSucceed} and {@link CocoonJS.Social.onUserInfoRequestFailed} event handlers.
		* @param {string} [userId] The id of the user to retireve the information from. If no userID is specified, the currently logged in user is assumed.
		* @see CocoonJS.Social.onRequestUserInfoSucceed
		* @see CocoonJS.Social.onRequestUserInfoFailed
		*/
		requestUserInfo : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserInfo", arguments, true);
			}
		},

		/**
		* Request to retrieve the Image of a user
		* @param {string} [userID] The id of the user to get the image for. If no userID is specified, the currently logged user is used.
		* @param {CocoonJS.Social.ImageSizeType} [imageSizeType] The size of the image. One of the possible values among the ones in the {@link CocoonJS.Social.ImageSizeType}. If no value is specified, SMALL is used.
		* @see CocoonJS.Social.onRequestUserImageURLSucceed;
		* @see CocoonJS.Social.onRequestUserImageURLFailed;
		*/
		requestUserImageURL : function( imageSizeType, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserImageURL", arguments, true);
			}
		},

		/**
		* Request for the information of all the friends of the currently logged user.
		* @param {string} [userID] The id of the user to get the friends infos for. If no userID is specified, the currently logged user is used.
		* @see CocoonJS.Social.onRequestUserFriendsUserInfosSucceed;
		* @see CocoonJS.Social.onRequestUserFriendsUserInfosFailed;
		*/
		requestUserFriendsUserInfos : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserFriendsUserInfos", arguments, true);
			}
		},

		/**
		* Request the publication of a message using a dialog.
		* @param {CocoonJS.Social.Message} message A object representing the information to be published.
		* @see CocoonJS.Social.onRequestMessagePublicationSucceed
		* @see CocoonJS.Social.onRequestMessagePublicationFailed
		*/
		requestMessagePublicationWithDialog : function(message)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestMessagePublicationWithDialog", arguments, true);
			}
		}
	};

	/**
	* This structure represents the possible images to be obtained for a user in the social gaming extension.
	* @namespace
	*/
	CocoonJS.Social.ImageSizeType = 
	{
		/**
		* Represent a thumbnail like image size.
		*/
	    THUMB : "thumb",

		/**
		* Represents the small image size.
		*/
	    SMALL : "small",

		/**
		* Represents the medium image size.
		*/
	    MEDIUM : "medium",

		/**
		* Represents the large image size.
		*/
	    LARGE : "large"
	};

	/**
	* The data structure that represents the information of a user inside the social gaming extension.
	* @namespace
	* @constructor
	* @param {string} userID The id of the user.
	* @param {string} userName The user name of the user.
	*/
	CocoonJS.Social.UserInfo = function(userID, userName)
	{
		/**
		* The id of the user.
		* @field
		* @type string
		*/
		this.userID = userID;

		/**
		* The user name of the user.
		* @field
		* @type string
		*/
		this.userName = userName;
	};

	/**
	* This type represents a message to be published.
	* @namespace
	* @constructor
	* @param {string} message The message to be published.
	* @param {string} mediaURL An URL to a media (image, video, ...)
	* @param {string} linkURL An URL to add to the message so the user can click on that link to get more information.
	* @param {string} linkText The text that will appear in the message link.
	* @param {string} linkCaption The text caption that will appear in the message link.
	*/
	CocoonJS.Social.Message = function(message, mediaURL, linkURL, linkText, linkCaption)
	{
		/**
		* The message to be published.
		* @field
		* @type string
		*/
		this.message = message;

		/**
		* An URL to a media (image, video, ...)
		* @field
		* @type string
		*/
		this.mediaURL = mediaURL;

		/**
		* An URL to add to the message so the user can click on that link to get more information.
		* @field
		* @type string
		*/
		this.linkURL = linkURL;

		/**
		* The text that will appear in the message link.
		* @field
		* @type string
		*/
		this.linkText = linkText;

		/**
		* The text caption that will appear in the message link.
		* @field
		* @type string
		*/
		this.linkCaption = linkCaption;

		return this;
	};

})();

//////////////////////////////////////
// COCOONJS_SOCIALGAMING.JS         //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    if (!CocoonJS.Social)
		throw("The CocoonJS.Social object must exist and be valid before creating any extension object.");

	/**
	* This type represents the access to a native Social Gamming extension API. As there can be more than
	* one service of this type, more than one instance can be created.
	* @namespace
	* @constructor
	* @param {string} nativeExtensionName The name of the native ext object extension property name.
	* @param {string} extensionName The name of the CocoonJS object extension property name.
	*/
	CocoonJS.SocialGaming = function(nativeExtensionName, extensionName)
	{
		CocoonJS.SocialGaming.superclass.constructor.call(this, nativeExtensionName, extensionName);

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAndFriendsScoresSucceed} event calls.
	     * @name OnRequestUserAndFriendsScoresSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {array} userAndFriendsScoreInfos An array of {@link CocoonJS.SocialGaming.UserScoreInfo} objects representing the information of the user's and friends' scores.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user and friends scores request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAndFriendsScoresSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAndFriendsScoresSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAndFriendsScoresSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAndFriendsScoresFailed} event calls.
	     * @name OnRequestUserAndFriendsScoresFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score and friends scores were requested.
	     * @param {string} leadeboardID The id of the leaderboard for whom the score and friends scores were requested.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user and his/her friends scores request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAndFriendsScoresFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAndFriendsScoresFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAndFriendsScoresFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserScoreSucceed} event calls.
	     * @name OnRequestUserScoreSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {CocoonJS.SocialGaming.UserScoreInfo} userScoreInfo The info of the user's score.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score information request suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserScoreSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserScoreSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserScoreSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserScoreFailed} event calls.
	     * @name OnRequestUserScoreFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score was requested.
	     * @param {string} leaderboardID The id of the leaderboard for whom the score was requested.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score information request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserScoreFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserScoreFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserScoreFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserScoreSucceed} event calls.
	     * @name OnSubmitUserScoreSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score has been submitted.
	     * @param {string} leaderboardID The id of the leaderboard for which the score has been submitted.
	     * @param {number} score The score that has been submitted.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score submit suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserScoreSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserScoreSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserScoreSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserScoreFailed} event calls.
	     * @name OnSubmitUserScoreFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score submition was requested.
	     * @param {string} leaderboadID The id of the leaderboard for which the score submition was requested.
	     * @param {number} score The score that was submitted and failed.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score submit fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserScoreFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserScoreFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserScoreFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAchievementsSucceed} event calls.
	     * @name OnRequestUserAchievementsSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements where requested.
	     * @param {array} achievementsInfos An array of {@link CocoonJS.SocialGaming.AchievementInfo} objects representing the information of the user's achievements.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievements info are successfully retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAchievementsSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAchievementsSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAchievementsSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAchievementsFailed} event calls.
	     * @name OnRequestUserAchievementsFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements were requested.
	   	 * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievmeents info fails to be retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAchievementsFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAchievementsFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAchievementsFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAllAchievementsSucceed} event calls.
	     * @name OnRequestAllAchievementsSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {array} achievementsInfos An array of {@link CocoonJS.SocialGaming.AchievementInfo} objects representing the information of all the achievements.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievements info are successfully retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAllAchievementsSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAllAchievementsSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAllAchievementsSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAllAchievementsFailed} event calls.
	     * @name OnRequestAllAchievementsFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	   	 * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievmeents info fails to be retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAllAchievementsFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAllAchievementsFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAllAchievementsFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAchievementInfoSucceed} event calls.
	     * @name OnRequestAchievementInfoSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {CocoonJS.SocialGaming.AchievementInfo} achievementInfo A {@link CocoonJS.SocialGaming.AchievementInfo} object representing the information of the achievement.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the request to retrieve the information of an achievement succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAchievementInfoSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAchievementInfoSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAchievementInfoSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAchievementInfoFailed} event calls.
	     * @name OnRequestAchievementInfoFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} achievementID The id of the achievement for which the information retrieval was requested.
	     * @param {string} errorMessage The error message.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the request to retrieve the information of an achievement fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAchievementInfoFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAchievementInfoFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAchievementInfoFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserAchievementSucceed} event calls.
	     * @name OnSubmitUserAchievementSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievement has been submitted.
	     * @param {string} achievementID The id of the achievement that has been submitted.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement submition succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserAchievementSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserAchievementSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserAchievementSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserAchievementFailed} event calls.
	     * @name OnSubmitUserAchievementFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievment was submitted.
	     * @param {string} achievementID The id of the achievement that was submitted.
	     * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement submition fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserAchievementFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserAchievementFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserAchievementFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onResetUserAchievementsSucceed} event calls.
	     * @name OnResetUserAchievementsSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements were reset.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnResetUserAchievementsSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onResetUserAchievementsSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onResetUserAchievementsSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onResetUserAchievementsFailed} event calls.
	     * @name OnResetUserAchievementsFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements where tried to be reset.
	     * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnResetUserAchievementsFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onResetUserAchievementsFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onResetUserAchievementsFailed");

	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the users closes the achievements view.
	    * The callback function does not receive any parameter.
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onAchievementsViewClosed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onAchievementsViewClosed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onAchievementsViewFailed} event calls.
	     * @name OnAchievementsViewFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} errorMessage The message that describes why the call failed.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the achievements view failed to show.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnAchievementsViewFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onAchievementsViewFailed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onAchievementsViewFailed");

		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when achievements view shows successfully.
	    * The callback function does not receive any parameter.
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onAchievementsViewSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onAchievementsViewSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onLeaderboardViewClosed} event calls.
	     * @name OnLeaderboardViewClosedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} leaderboardID The id of the leaderboard for which it's vew was requested to be shown.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnLeaderboardViewClosedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
   		this.onLeaderboardViewClosed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLeaderboardViewClosed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onLeaderboardViewFailed} event calls.
	     * @name OnLeaderboardViewFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} leaderboardID The id of the leaderboard for which it's vew was requested to be shown.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnLeaderboardViewFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
   		this.onLeaderboardViewFailed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLeaderboardViewFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onLeaderboardViewSucceed} event calls.
	     * @name OnLeaderboardViewSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} leaderboardID The id of the leaderboard for which it's vew was requested to be shown.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnLeaderboardViewSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
   		this.onLeaderboardViewSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLeaderboardViewSucceed");

		return this;
	};

	CocoonJS.SocialGaming.prototype = 
	{
        abstractToSocialGamingAchievementMap : null,
        abstractToSocialGamingAchievementMapInverse : null,

        /**
        * @ignore
        */
        setAbstractToSocialGamingAchievementMap : function( map ) {
            this.abstractToSocialGamingAchievementMap= map;

            // build a reciprocal map.
            this.abstractToSocialGamingAchievementMapInverse= {};
            for( var id in map ) {
                if ( map.hasOwnProperty(id) ) {
                    this.abstractToSocialGamingAchievementMapInverse[ map[id] ]= id;
                }
            }
            return this;
        },

        /**
        * @ignore
        */
        getAbstractToSocialGamingAchievementTranslation : function( achievementID ) {
            /**
             * If a translation map for abstract in-game achievements has been set, translate achievementID from
             * abstract to SocialGamingService.
             */
            if (this.abstractToSocialGamingAchievementMap) {
                var socialGamingAchievementID = this.abstractToSocialGamingAchievementMap[achievementID];
                if (socialGamingAchievementID) {
                    console.log("Abstract achieventID='" + achievementID + "' turned to '" + socialGamingAchievementID + "'");
                    achievementID = socialGamingAchievementID;
                } else {
                    console.log("Something may be wrong: abstract achievementID: '" + achievementID + "' w/o translation.")
                }
            }

            return achievementID;
        },

		/**
		* Request to retrieve the scores of all friends of a given user.
		* @param {string} [leaderboardID] The id of the leaderboard to request the scores for.
		* @param {string} [userID] The id of the user. If null or undefined is passed, the currently logged in user id is used.
		* @see CocoonJS.SocialGaming.onRequestUserAndFriendsScoresSucceed
		* @see CocoonJS.SocialGaming.onRequestUserAndFriendsScoresFailed
		*/
		requestUserAndFriendsScores : function(leaderboardID, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserAndFriendsScores", arguments, true);
			}
		},

		/**
		* Request to retrieve the score of a user.
		* @param {string} [leaderboardID] The id of the scores leaderboard to retireve the score from. If null or underfined is passed, the "leadeboard" id will be used.
		* @param {string} [userID] The id of the user to retireve the score from. If null or undefined is passed, the currently logged in user id is used.
		* @see CocoonJS.SocialGaming.onRequestUserScoreSucceed
		* @see CocoonJS.SocualGaming.onRequestUserScoreFailed
		*/
		requestUserScore : function(leaderboardID, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserScore", arguments, true);
			}
		},

		/**
		* Request to the server the score of a user.
		* @param {number} [score] the score to submit
		* @param {string} [leaderboardID] The id of the scores leaderboard to submit the score to. If null or underfined is passed, the "leadeboard" id will be used.
		* @param {string} [userID] The id of the user to submit the score for. If null or undefined is passed, the currently logged in user id is used.
		* @see CocoonJS.SocialGaming.onSubmitUserScoreSucceed
		* @see CocoonJS.SocualGaming.onSubmitUserScoreFailed
		*/
		submitUserScore : function(score, leaderboardID, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "submitUserScore", arguments, true);
			}
		},
		/**
		* Shows the leaderboard using a platform dependant view.
		* @param {string} [leaderboardID] The id of the scores leaderboard to show the view for. If null or underfined is passed, the "leadeboard" id will be used.
		* @see CocoonJS.SocialGaming.onLeaderboardViewClosed
		*/
		showLeaderboardView : function(leaderboardID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "showLeaderboardView", arguments, true);
			}
		},

		/**
		* Request to retrieve the user achievements. The request can be monitored using the {@link CocoonJS.SocialGaming.onRequestUserAchievementsSucceed} and {@link CocoonJS.Social.onRequestUserAchievementsFailed} event handlers.
		* @param {string} [userID] The id of the user to retireve the achievements from. if null/undefined/"" is specified, the currently logged in user is assumed.
		* @see CocoonJS.SocialGaming.onRequestUserAchievementsSucceed
		* @see CocoonJS.SocialGaming.onRequestUserAchievementsFailed
		*/
		requestUserAchievements : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserAchievements", arguments, true);
			}
		},

		/**
		* Request to retrieve all the achievements. The request can be monitored using the {@link CocoonJS.SocialGaming.onRequestAllAchievementsSucceed} and {@link CocoonJS.Social.onRequestAllAchievementsFailed} event handlers.
		* @see CocoonJS.SocialGaming.onRequestAllAchievementsSucceed
		* @see CocoonJS.SocialGaming.onRequestAllAchievementsFailed
		*/
		requestAllAchievements : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestAllAchievements", arguments, true);
			}
		},

		/**
		* Request to retrieve the information about an achievement. 
		* @param {string} achievementID The id of the achievement to get the information for.
		* @param {CocoonJS.Social.ImageSizeType} [imageSizeType] The size of the image. One of the possible values among the ones in the {@link CocoonJS.Social.ImageSizeType}
		*/
		requestAchievementInfo : function(achievementID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestAchievementInfo", arguments, true);
			}
		},

		/**
		* Submits an achievement to the server. If the process fails, the achievement is stored to submit it later.
		* @param {string} [achievementID] the achievement identifier
		* @param {number} [percentComplete] an optional number between 0 and 100 that indicates a completion percentage.
		* @see CocoonJS.SocialGaming.onSubmitAchievementSucceed
		* @see CocoonJS.SocualGaming.onSubmitAchievementFailed
		*/
        submitUserAchievement:function (achievementID, userID) {
            achievementID = this.getAbstractToSocialGamingAchievementTranslation(achievementID);

            if (this.nativeExtensionObjectAvailable) {
                return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "submitUserAchievement", arguments, true);
            }
        },

		/**
		* Shows the achievements using a platform dependant view.
		* @see CocoonJS.SocialGaming.onAchievementsViewClosed
		*/
		showUserAchievementsView : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "showUserAchievementsView", arguments, true);
			}
		},

		/**
		* Resets all the achievements of the current user
		* @param {string} [userID] The id of the user to reset the achievements for. If null/undefined/"", the logged in user is assumed.
		* @see CocoonJS.SocialGaming.onResetAchievementsSucceed
		* @see CocoonJS.SocualGaming.onResetAchievementsFailed
		*/
		resetUserAchievements : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "resetUserAchievements", arguments, true);
			}
		}
	};

	/**
    * @ignore
    */
	CocoonJS.extend(CocoonJS.SocialGaming, CocoonJS.Social);

	/**
	* The data structure that represents the information of the user score in the application.
	* @namespace
	* @constructor
	* @param {string} userID The user id.
	* @param {number} score The score of the user.
	* @param {string} userName The name of the user.
	* @param {string} imageURL The url of the user image.
	* @param {number} leaderboardID The id of the leaderboard the score belongs to.
	*/
	CocoonJS.SocialGaming.UserScoreInfo = function(userID, score, userName, imageURL, leaderboardID)
	{
		/**
		* The user id. 
		* @type string
		*/
		this.userID = userID;

		/**
		* The score of the user.
		* @type number
		*/
		this.score = score ? score : 0;

		/**
		* The name of the user.
		* @type string
		*/
        this.userName = userName;

		/**
		* The url of the user image.
		* @type string
		*/
        this.imageURL = imageURL;

        /**
		* The id of the leaderboard the score belongs to.
		* @type number
		*/
        this.leaderboardID = leaderboardID;
	};

	/**
	* The data structure that represents the information of an achievement in the application.
	* @namespace
	* @constructor
	* @param {string} achievementID The id of the achievement info.
	* @param {string} title The title of the achievement.
	* @param {string} description The description of the achievement.
	* @param {string} imageURL The url to the image representing the achievement.
	* @param {number} points The points value of the achievement
	*/
	CocoonJS.SocialGaming.AchievementInfo = function(achievementID, title, description, imageURL, points)
	{
		/**
		* The id of the achievement info.
		* @type string
		*/
		this.achievementID = achievementID;

		/**
		* The title of the achievement.
		* @type string
		*/
		this.title = title;

		/**
		* The description of the achievement.
		* @type string
		*/
		this.description = description;

		/**
		* The url to the image representing the achievement.
		* @type string
		*/
		this.imageURL = imageURL;

		/**
		* The points value of the achievement
		* @type number
		*/
		this.points = points ? points : 0;
	};

})();

/////////////////////////////////////////
// COCOONJS_SOCIALGAMING_GAMECENTER.JS //
/////////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");
    if (typeof window.CocoonJS.SocialGaming === 'undefined' || window.CocoonJS === null) throw("The CocoonJS.SocialGaming object must exist and be valid before creating a Game Center extension object.");

	/**
	* This instance represents the extension object to access GameCenter related native functionalities.
	* The data structure for initialization: None.
	* @see CocoonJS.Social
	*/
	CocoonJS.SocialGaming.GameCenter = new CocoonJS.SocialGaming("IDTK_SRV_SOCIAL_GAMECENTER", "SocialGaming.GameCenter");
})();

//////////////////////////////
// COCOONJS_GAMEPAD.JS 		//
//////////////////////////////

(function () {
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
     * This namespace represents the functionalities related to OUYA android gaming control.
     * @namespace
     */
    CocoonJS.Gamepad = {};

    CocoonJS.Gamepad.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.Gamepad !== 'undefined';

    CocoonJS.Gamepad.Indices = {
        BUTTON_0                : 0, 
        BUTTON_1                : 1,
        BUTTON_2                : 2,
        BUTTON_3                : 3,
        BUTTON_LEFT_BUMPER      : 4,
        BUTTON_RIGHT_BUMPER     : 5,
        
        BUTTON_LEFT_TRIGGER     : 6,
        BUTTON_RIGHT_TRIGGER    : 7,
        
        BUTTON_LEFT_JOYSTICK    : 10,
        BUTTON_RIGHT_JOYSTICK   : 11,
        BUTTON_DPAD_UP          : 12,
        BUTTON_DPAD_DOWN        : 13,
        BUTTON_DPAD_LEFT        : 14,
        BUTTON_DPAD_RIGHT       : 15,
        BUTTON_MENU             : 16,
        
        AXE_LEFT_JOYSTICK_X     : 0,
        AXE_LEFT_JOYSTICK_Y     : 1,
        AXE_RIGHT_JOYSTICK_X    : 2,
        AXE_RIGHT_JOYSTICK_Y    : 3
    };

    // If the extension is present and the navigator does not provide the gamepad API:
    // 1.- Add the getGamepads function to the navigator object.
    // 2.- Replace the window add and remove event listener functions to call to the extension for the gamepad related events.
    var systemSupportsGamepads = navigator["getGamepads"] || navigator["webkitGetGamepads"];
    if (CocoonJS.Gamepad.nativeExtensionObjectAvailable && !systemSupportsGamepads)
    {
        navigator.getGamepads = function()
        {
            return window.ext.Gamepad.makeCall("getGamepads");
        };

        CocoonJS.Gamepad.originalWindowAddEventListener = window.addEventListener;
        CocoonJS.Gamepad.originalWindowRemoveEventListener = window.removeEventListener;

        window.addEventListener = function(eventName, callback)
        {
            console.log("The new window.addEventListener has been called.");
            if (eventName === "gamepadconnected" || eventName === "gamepaddisconnected")
            {
                window.ext.Gamepad.addEventListener(eventName, callback);
            }
            else
            {
                var argumentsArray = Array.prototype.slice.call(arguments);
                CocoonJS.Gamepad.originalWindowAddEventListener.apply(window, argumentsArray);
            }
        };
        window.removeEventListener = function(eventName, callback)
        {
            console.log("The new window.removeEventListener has been called.");
            if (eventName === "gamepadconnected" || eventName === "gamepaddisconnected")
            {
                window.ext.Gamepad.removeEventListener(eventName, callback);
            }
            else
            {
                var argumentsArray = Array.prototype.slice.call(arguments);
                CocoonJS.Gamepad.originalWindowRemoveEventListener.apply(window, argumentsArray);
            }
        };
    } 
    else if (systemSupportsGamepads) 
    {
        if (!navigator.getGamepads)
        {
            console.log("navigator.getGamepads does not exist.");
            if (navigator.webkitGetGamepads)
            {
                console.log("navigator.webkitGamepads exists, adding navigator.getGamepads to point to it.");
                navigator.getGamepads = navigator.webkitGetGamepads;
            }
            else
            {
                console.log("navigator.webkitGetGamepads does not exist either.");
            }
        }
    }
})();

//////////////////////////////
// COCOONJS_NOTIFICATION.JS //
//////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
    * This namespace represents the CocoonJS Notification extension.
    * @namespace
    */
    CocoonJS.Notification = {};

    CocoonJS.Notification.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_SRV_NOTIFICATION !== 'undefined';

	/**
	* The data structure that represents the information of a local notification.
	* @namespace
	* @constructor
	* @param {string} message The notification message.
	* @param {boolean} soundEnabled A flag that indicates if the sound should be enabled for the notification.
	* @param {number} badgeNumber The number that will appear in the badge of the application icon in the home screen.
	* @param {object} userData The JSON data to attached to the notification.
	* @param {string} contentBody The body content to be showed in the expanded notification information.
	* @param {string} contentTitle The title to be showed in the expanded notification information.
	* @param {number} date Time in millisecs from 1970 when the notification will be fired.
	*/
	CocoonJS.Notification.LocalNotification = function(message, soundEnabled, badgeNumber, userData, contentBody, contentTitle, scheduleTime)
	{
		/**
		* The notification message.
		* @field
		* @type string
		*/
		this.message = message;

		/**
		* A flag that indicates if the sound should be enabled for the notification.
		* @field
		* @type boolean
		*/
		this.soundEnabled = soundEnabled;

		/**
		* (iOS only) The number that will appear in the badge of the application icon in the home screen.
		* @field
		* @type number
		*/
		this.badgeNumber = badgeNumber;

		/**
		* The JSON data to attached to the notification.
		* @field
		* @type object
		*/
		this.userData = userData;

		/**
		* (Android only) The body content to be showed in the expanded notification information.
		* @field
		* @type string
		*/
		if (contentBody !== undefined)
			this.contentBody = contentBody;
		else
			this.contentBody = "";

		/**
		* (Android only) The title to be showed in the expanded notification information.
		* @field
		* @type string
		*/
		if (contentTitle !== undefined)
			this.contentTitle = contentTitle;
		else
			this.contentTitle = "";

		/**
		* Time in millisecs from 1970 when the local notification will be fired
		* @field
		* @type number
		*/
		var currentTime = new Date().getTime();
		if (scheduleTime !== undefined){
			this.scheduleTime = scheduleTime;
		}else{
			this.scheduleTime = currentTime;
		}
	};

	/**
	* The data structure that represents the information of a push notification.
	* @namespace
	* @constructor
	* @param {string} message The notification message.
	* @param {boolean} soundEnabled A flag that indicates if the sound should be enabled for the notification.
	* @param {number} badgeNumber The number that will appear in the badge of the application icon in the home screen.
	* @param {object} userData The JSON data to attached to the notification.
	* @param {array} channels An array containing the channels names this notification will be delivered to.
	* @param {number} expirationTime A time in seconds from 1970 when the notification is no longer valid and will not be delivered in case it has not already been delivered.
	* @param {number} expirationTimeInterval An incremental ammount of time in from now when the notification is no longer valid and will not be delivered in case it has not already been delivered.
	*/
	CocoonJS.Notification.PushNotification = function(message, soundEnabled, badgeNumber, userData, channels, expirationTime, expirationTimeInterval)
	{
		/**
		* The notification message.
		* @field
		* @type string
		*/
		this.message = message;

		/**
		* A flag that indicates if the sound should be enabled for the notification.
		* @field
		* @type boolean
		*/
		this.soundEnabled = soundEnabled;

		/**
		* The number that will appear in the badge of the application icon in the home screen.
		* @field
		* @type number
		*/
		this.badgeNumber = badgeNumber;

		/**
		* The JSON data to attached to the notification.
		* @field
		* @type object
		*/
		this.userData = userData

		/**
		* An array containing the channels names this notification will be delivered to.
		* @field
		* @type array
		*/
		this.channels = channels;

		/**
		* A time in seconds from 1970 when the notification is no longer valid and will not be delivered in case it has not already been delivered.
		* @field
		* @type number
		*/
		if (expirationTime !== undefined)
			this.expirationTime = expirationTime;
		else
			this.expirationTime = 0;

		/**
		* An incremental ammount of time in from now when the notification is no longer valid and will not be delivered in case it has not already been delivered.
		* @field
		* @type number
		*/
		if (expirationTimeInterval !== undefined)
			this.expirationTimeInterval = expirationTimeInterval;
		else
			this.expirationTimeInterval = 0;
	};

	/**
	* Start processing received notifications. The user must call this method when the game is ready to process notifications. Notifications received before being prepared are stored and processed later.
	*/
	CocoonJS.Notification.start = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "start", arguments, true);
		}
	};


	/**
	* Register to be able to receive push notifications.
	* The registration process is controlled using the {@link CocoonJS.Notification.onRegisterForPushNotificationsSucceed} and {@link CocoonJS.Notification.onRegisterForPushNotificationsFailed} event handlers.
	* @function
	* @see {CocoonJS.Notification.onRegisterForPushNotificationsSucceed}
	* @see {CocoonJS.Notification.onRegisterForPushNotificationsFailed}
	*/
	CocoonJS.Notification.registerForPushNotifications = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "registerForPushNotifications", arguments, true);
		}
	};

	/**
	* Unregister from receiving push notifications.
	* The unregistration process is controlled using the {@link CocoonJS.Notification.onUnregisterForPushNotificationsSucceed} event handler.
	* @function
	* @see CocoonJS.Notification.onUnregisterForPushNotificationsSucceed
	*/
	CocoonJS.Notification.unregisterForPushNotifications = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "unregisterForPushNotifications", arguments, true);
		}
	};

	/**
	* Cancel the last sent local notification.
	* The last sent local notification will be remove from the notifications bar.
	* @function
	*/
	CocoonJS.Notification.cancelLastSentLocalNotificiation = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "cancelLocalNotification", arguments, true);
		}
	};

	/**
	* Cancel all sent local notifications.
	* All the notifications will ve removed from the notifications bar.
	* @function
	*/
	CocoonJS.Notification.cancelAllLocalNotifications = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "cancelAllLocalNotifications", arguments, true);
		}
	};

	/**
	* Send a local notification.
	* @function
	* @param {CocoonJS.Notification.LocalNotification} localNotification The local notification to be sent.
	*/
	CocoonJS.Notification.sendLocalNotification = function(localNotification)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "sendLocalNotification", arguments, true);
		}
	};

	/**
	* Subscribe to a channel in order to receive notifications targeted to that channel.
	* @function
	* @param {string} channel The channel id to subscribe to.
	*/
	CocoonJS.Notification.subscribeToChannel = function(channel)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "subscribe", arguments, true);
		}
	};

	/**
	* Unsubscribe from a channel in order to stop receiving notifications targeted to it.
	* @function
	* @param {string} channel The channel id to unsubscribe from.
	*/
	CocoonJS.Notification.unsubscribeFromChannel = function(channel)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "unsubscribe", arguments, true);
		}
	};

	/**
	* Send a push notification.
	* @function
	* @param {CocoonJS.Notification.PushNotification} pushNotification The push notification object to be sent.
	* @see CocoonJS.Notification.onPushNotificationDeliverySucceed
	* @see CocoonJS.Notification.onPushNotificationDeliveryFailed
	*/
	CocoonJS.Notification.sendPushNotification = function(pushNotification)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "sendPushNotification", arguments, true);
		}
	};

	/**
	* (iOS only) Set the badge number for this application.
	* This is useful if you want to modify the badge number set by a notification.
	* @function
	* @param {number} badgeNumber The number of the badge.
	*/
	CocoonJS.Notification.setBadgeNumber = function(badgeNumber)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "setBadgeNumber", arguments);
		}
	};

	/**
	* (iOS only) Returns the current badge number.
	* @function
	* @returns {number} The badge number.
	*/
	CocoonJS.Notification.getBadgeNumber = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "getBadgeNumber", arguments);
		}
	};

	/**
	* Returns the last received user data from a Local notification.
	* @function
	* @returns {object} The last received user data from a Local notification.
	*/
	CocoonJS.Notification.getLastReceivedLocalNotificationData = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "getLastReceivedLocalNotificationData", arguments);
		}
	};

	/**
	* Returns the last received user data from a Push notification.
	* @function
	* @returns {object} The last received user data from a Push notification.
	*/
	CocoonJS.Notification.getLastReceivedPushNotificationData = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "getLastReceivedPushNotificationData", arguments);
		}
	};

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the registration for push notification succeeds.
    * The callback function does not receive any parameter.
    * @static
    * @event
    * @param {string} token The token (apid or device token) received at registration time.
    * @memberOf CocoonJS.Notification
    */
	CocoonJS.Notification.onRegisterForPushNotificationsSucceed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationServiceRegistered");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the unregistration for push notifications succeeds.
    * The callback function does not receive any parameter.
    * @static
    * @event
    * @memberOf CocoonJS.Notification
    */
	CocoonJS.Notification.onUnregisterForPushNotificationsSucceed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationServiceUnregistered");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the registration for push notifications fails.
    * The callback function receives a parameter with error information.
    * @static
    * @event
    * @param {string} msg The error message.
    */
	CocoonJS.Notification.onRegisterForPushNotificationsFailed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationServiceFailedToRegister");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a push notification is received.
    * The callback function receives a parameter with the userData of the received notification.
    * @static
    * @event
    * @param {object} userData An object with the notification userData information.
    */
	CocoonJS.Notification.onPushNotificationReceived = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationReceived");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a local notification is received.
    * The callback function receives a parameter with the userData of the received notification.
    * @static
    * @event
    * @param {object} userData An object with the notification userData information.
    */
	CocoonJS.Notification.onLocalNotificationReceived = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "localNotificationReceived");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a notification is successfully delivered.
    * The callback function receives a parameter with the notificationId of the delivered notification.
    * @static
    * @event
    * @param {string} userData A string with the notification userData information.
    */
	CocoonJS.Notification.onPushNotificationDeliverySucceed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationSuccessfullyDelivered");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the delivery of push a notification fails.
    * The callback function receives a parameter with error information.
    * @static
    * @event
    * @param {string} msg The error message.
    */
	CocoonJS.Notification.onPushNotificationDeliveryFailed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationDeliveryError");

})();

/////////////////
// PATHFIND.JS //
/////////////////

// Pathfind.js
// Written by Ashley Gullen
// Copyright (c) 2013 Scirra Ltd.

// A* pathfinding javascript implementation

(function() {
	
	var PF_CLEAR = 0;
	var PF_OBSTACLE = 32767;
	
	function node()
	{
		this.parent = null;
		
		this.x = 0;
		this.y = 0;

		this.f = 0;
		this.g = 0;
		this.h = 0;
	};
	
	var nodeCache = [];			// for recycling nodes
	
	function allocNode()
	{
		var ret;
		
		if (nodeCache.length)
			ret = nodeCache.pop();
		else
			ret = new node();
			
		ret.parent = null;
		ret.x = 0;
		ret.y = 0;
		ret.f = 0;
		ret.g = 0;
		ret.h = 0;
		return ret;
	};
	
	function freeNode(n)
	{
		if (nodeCache.length < 64000)
			nodeCache.push(n);
	};
	
	function resultNode(x_, y_)
	{
		this.x = x_ || 0;
		this.y = y_ || 0;
	};
	
	var resultNodeCache = [];			// for recycling resultNodes
	
	function allocResultNode()
	{
		if (resultNodeCache.length)
			return resultNodeCache.pop();
		else
			return new resultNode(0, 0);
	};
	
	function freeResultNode(n)
	{
		if (resultNodeCache.length < 10000)
			resultNodeCache.push(n);
	};
	
	var workersSupported = (typeof Worker !== "undefined");
	var isInWebWorker = (typeof document === "undefined");		// no DOM in a worker
	var myInstance = null;										// single pathfinder instance for worker
	
	if (isInWebWorker)
	{
		self.addEventListener("message", function (e)
		{
			var d = e.data;
			
			if (!d)
				return;		// could be empty postMessage() to start worker
			
			if (d.cmd === "init")
			{
				if (!myInstance)
					myInstance = new pathfinder();
					
				myInstance.init(d.hcells, d.vcells, d.data, d.diagonals);
			}
			else if (d.cmd === "find")
			{
				// receive a pathfind job, process it them dispatch result
				myInstance.pathEnd.parent = null;
				myInstance.targetX = d.endX;
				myInstance.targetY = d.endY;
				
				if (myInstance.doLongFindPath(d.startX, d.startY))
				{
					self.postMessage({ cmd: "result", pathList: myInstance.pathList });
				}
				else
				{
					self.postMessage({ cmd: "result", pathList: null });
				}
			}
			else if (d.cmd === "setdiag")
			{
				// update diagonalsEnabled flag
				myInstance.diagonalsEnabled = d.diagonals;
			}
			
		}, false);
	}
	
	function pathfinder()
	{
		this.hcells = 0;
		this.vcells = 0;
		
		this.pathEnd = allocNode();
		
		this.cells = null;
		this.openList = [];
		this.closedList = [];
		this.closedCache = {};
		this.pathList = [];
		
		this.currentNode = null;
		this.targetX = 0;
		this.targetY = 0;
		this.diagonalsEnabled = true;
		
		this.worker = null;
		this.workerQueue = [];		// jobs awaiting completion from worker in order of requests made
		this.workerRecycle = [];
		
		var self = this;
		var i, len;
		
		if (workersSupported && !isInWebWorker)
		{
			// Create worker and receive results of pathfind jobs from it
			this.worker = new Worker("pathfind.js");
			
			this.worker.addEventListener("message", function (e) {
			
				if (!e || !e.data)
					return;
				
				if (e.data.cmd === "result")
				{
					if (e.data.pathList)
					{
						for (i = 0, len = self.pathList.length; i < len; i++)
							freeResultNode(self.pathList[i]);
						
						self.pathList = e.data.pathList;
						self.workerQueue[0].success();
					}
					else
						self.workerQueue[0].fail();
						
					self.workerRecycle.push(self.workerQueue.shift());
				}
			}, false);
			
			this.worker.addEventListener("error", function (e) {
				console.error(e);
			}, false);
			
			this.worker.postMessage(null);
		}
	};
	
	pathfinder.prototype.init = function (hcells_, vcells_, data_, diagonals_)
	{
		this.hcells = hcells_;
		this.vcells = vcells_;
		this.cells = data_;
		this.diagonalsEnabled = diagonals_;
		
		if (workersSupported && !isInWebWorker)
		{
			this.worker.postMessage({
				cmd: "init",
				hcells: hcells_,
				vcells: vcells_,
				diagonals: diagonals_,
				data: data_
			});
		}
	};
	
	pathfinder.prototype.isReady = function ()
	{
		return !!this.cells;
	};
	
	pathfinder.prototype.setDiagonals = function (d)
	{
		if (this.diagonalsEnabled === d)
			return;
		
		this.diagonalsEnabled = d;
		
		if (workersSupported && !isInWebWorker)
		{
			this.worker.postMessage({
				cmd: "setdiag",
				diagonals: d,
			});
		}
	};
	
	pathfinder.prototype.at = function (x_, y_)
	{
		if (x_ < 0 || y_ < 0 || x_ >= this.hcells || y_ >= this.vcells)
			return PF_OBSTACLE;
			
		return this.cells[x_][y_];
	};
	
	pathfinder.prototype.findPath = function (startX, startY, endX, endY, successCallback, failCallback)
	{
		if (!this.cells)
		{
			// not yet initialised
			failCallback();
			return;
		}
		
		startX = Math.floor(startX);
		startY = Math.floor(startY);
		endX = Math.floor(endX);
		endY = Math.floor(endY);
		
		this.targetX = endX;
		this.targetY = endY;
		this.pathEnd.parent = null;
		
		// Check the box made by the start and dest cells.
		// If the complete box is empty, allow a direct move to target.
		var minX = Math.min(startX, endX);
		var maxX = Math.max(startX, endX);
		var minY = Math.min(startY, endY);
		var maxY = Math.max(startY, endY);
		
		// Path goes out of bounds: no calculable path
		if (minX < 0 || minY < 0 || maxX >= this.hcells || maxY >= this.vcells)
		{
			failCallback();
			return;
		}
		
		var x, y, i, len, c, h, n;

		if (this.diagonalsEnabled)
		{
			var canMoveDirect = true;
			
			for (x = minX; x <= maxX; x++)
			{
				for (y = minY; y <= maxY; y++)
				{
					if (this.cells[x][y] !== 0)
					{
						canMoveDirect = false;
						
						// Break both loops
						x = maxX + 1;
						break;
					}
				}
			}

			// A "direct" path is available (box is empty)
			if (canMoveDirect)
			{
				for (i = 0, len = this.pathList.length; i < len; i++)
					freeResultNode(this.pathList[i]);
				this.pathList.length = 0;
			
				this.pathEnd.x = endX;
				this.pathEnd.y = endY;
				this.pathEnd.parent = null;
				n = allocResultNode();
				n.x = endX;
				n.y = endY;
				this.pathList.push(n);
				successCallback();
				return;
			}
		}
		
		if (workersSupported)
		{
			// recycle objects in the worker queue
			if (this.workerRecycle.length)
				h = this.workerRecycle.pop();
			else
				h = {};
			
			h.success = successCallback;
			h.fail = failCallback;
			
			// dispatch the heavy lifting to the worker thread
			this.workerQueue.push(h);

			this.worker.postMessage({
				cmd: "find",
				startX: startX,
				startY: startY,
				endX: endX,
				endY: endY
			});
		}
		else
		{
			// no web worker support, just run on main thread
			if (this.doLongFindPath(startX, startY))
				successCallback();
			else
				failCallback();
		}
	};
		
	pathfinder.prototype.doLongFindPath = function (startX, startY)
	{
		var i, len, c, n, p, lastDir = 8, curDir = -1, addNode;
		for (i = 0, len = this.openList.length; i < len; i++)
			freeNode(this.openList[i]);
		for (i = 0, len = this.closedList.length; i < len; i++)
			freeNode(this.closedList[i]);
		for (i = 0, len = this.pathList.length; i < len; i++)
			freeResultNode(this.pathList[i]);
		this.openList.length = 0;
		this.closedList.length = 0;
		this.closedCache = {};
		this.pathList.length = 0;

		// Add the start node to the open list
		var startNode = allocNode();
		startNode.x = startX;
		startNode.y = startY;

		this.openList.push(startNode);
		var obsLeft = false, obsTop = false, obsRight = false, obsBottom = false;
		var diagonals = this.diagonalsEnabled;
		
		// While there are nodes on the open list
		while (this.openList.length)
		{
			// Move the best F value to closed list
			c = this.openList.shift();
			this.closedList.unshift(c);
			this.closedCache[((c.x << 16) + c.y).toString()] = true;

			// Are we there yet?
			if (c.x === this.targetX && c.y === this.targetY)
			{
				this.pathEnd.parent = c.parent;
				this.pathEnd.x = c.x;
				this.pathEnd.y = c.y;
				
				// Link up the whole path to an indexable array
				p = this.pathEnd;
				
				while (p)
				{
					// filter redundant nodes in straight lines
					if (this.pathList.length === 0)
					{
						addNode = true;
						
						if (p.parent)
						{
							lastDir = this.nodeDirection(p, p.parent);
							curDir = lastDir;
						}
					}
					else if (!p.parent)
						addNode = false;
					else 
					{
						curDir = this.nodeDirection(p, p.parent);
						addNode = (curDir !== lastDir);
					}
					
					if (addNode)
					{
						n = allocResultNode();
						n.x = p.x;
						n.y = p.y;
						this.pathList.unshift(n);
						lastDir = curDir;
					}
					
					p = p.parent;
				}
				
				return true;
			}

			// Get current node
			this.currentNode = c;
			var x = c.x;
			var y = c.y;
			
			var obsLeft = (this.at(x - 1, y) === PF_OBSTACLE);
			var obsTop = (this.at(x, y - 1) === PF_OBSTACLE);
			var obsRight = (this.at(x + 1, y) === PF_OBSTACLE);
			var obsBottom = (this.at(x, y + 1) === PF_OBSTACLE);

			// Check adjacent 8 nodes.  No diagonals allowed if either cell being crossed is obstacle.
			if (!obsLeft)
				this.addCellToOpenList(x - 1, y, 10);

			if (diagonals && !obsLeft && !obsTop)
				this.addCellToOpenList(x - 1, y - 1, 14);

			if (!obsTop)
				this.addCellToOpenList(x, y - 1, 10);

			if (diagonals && !obsTop && !obsRight)
				this.addCellToOpenList(x + 1, y - 1, 14);

			if (!obsRight)
				this.addCellToOpenList(x + 1, y, 10);

			if (diagonals && !obsRight && !obsBottom)
				this.addCellToOpenList(x + 1, y + 1, 14);

			if (!obsBottom)
				this.addCellToOpenList(x, y + 1, 10);

			if (diagonals && !obsBottom && !obsLeft)
				this.addCellToOpenList(x - 1, y + 1, 14);
		}
		
		return false;
	};
	
	pathfinder.prototype.insertToOpenList = function (c)
	{
		var i, len;
		
		// Needs to go at end
		if (c.f >= this.openList[this.openList.length - 1].f)
		{
			this.openList.push(c);
		}
		else
		{
			for (i = 0, len = this.openList.length; i < len; i++)
			{
				if (c.f < this.openList[i].f)
				{
					this.openList.splice(i, 0, c);
					break;
				}
			}
		}
	};
	
	pathfinder.prototype.addCellToOpenList = function (x_, y_, g_)
	{
		// Ignore if cell on closed list
		if (this.closedCache.hasOwnProperty(((x_ << 16) + y_).toString()))
			return;
		
		var i, len, c;
		
		// Cell costs can be increased by changing the number in the map
		var curCellCost = this.at(x_, y_);

		// Is this cell already on the open list?
		for (i = 0, len = this.openList.length; i < len; i++)
		{
			c = this.openList[i];
			
			if (x_ === c.x && y_ === c.y)
			{
				// Is this a better path?
				if (this.currentNode.g + g_ + curCellCost < c.g)
				{
					// Update F, G and H and update parent
					c.parent = this.currentNode;
					c.g = this.currentNode.g + g_ + curCellCost;
					c.h = this.estimateH(c.x, c.y);
					c.f = c.g + c.h;

					// This node's F has changed:  Delete it then re-insert it in the right place

					if (this.openList.length === 1)
					{
						// no need to remove then re-insert same node, just leave it there
						return;
					}
					
					this.openList.splice(i, 1);
					this.insertToOpenList(c);
				}

				return;
			}
		}

		// Not on the open list; add it in the right place
		c = allocNode();
		c.x = x_;
		c.y = y_;
		c.h = this.estimateH(x_, y_);
		c.g = this.currentNode.g + g_ + curCellCost;
		c.f = c.h + c.g;
		c.parent = this.currentNode;

		// Insert this node sorted in the open list
		// The loop below won't add new largest F values
		if (!this.openList.length)
		{
			this.openList.push(c);
			return;
		}
		
		this.insertToOpenList(c);
	};
	
	function quickAbs(x)
	{
		return x < 0 ? -x : x;
	};
	
	pathfinder.prototype.estimateH = function (x_, y_)
	{
		var dx = quickAbs(x_ - this.targetX);
		var dy = quickAbs(y_ - this.targetY);

		return dx * 10 + dy * 10;
	};
	
	pathfinder.prototype.nodeDirection = function (a, b)
	{
		var ax = a.x;
		var ay = a.y;
		var bx = b.x;
		var by = b.y;

		if (ax === bx)
		{
			if (by > ay) return 6;
			if (by < ay) return 2;
			if (ay == by) return 8;
		}
		else if (ay === by)
		{
			if (bx > ax) return 4;
			if (by < ax) return 0;
		}
		else
		{
			if (bx < ax && by < ay) return 1;
			if (bx > ax && by < ay) return 3;
			if (bx < ax && by > ay) return 7;
			if (bx > ax && by > ay) return 5;
		}
		return 8;
	};
	
	if (!isInWebWorker)
	{
		window.PF_CLEAR = PF_CLEAR;
		window.PF_OBSTACLE = PF_OBSTACLE;
		window.Pathfinder = pathfinder;
		
		window.ResultNode = resultNode;
		window.allocResultNode = allocResultNode;
		window.freeResultNode = freeResultNode;
	}

})();
(function() {
'use strict';var cr={plugins_:{},behaviors:{}};"function"!==typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"===typeof"test".__proto__?function(a){return a.__proto__}:function(a){return a.constructor.prototype});
(function(){function a(a,b){this.x=a;this.y=b;cr.seal(this)}function b(a,b,c,d){this.set(a,b,c,d);cr.seal(this)}function c(){this.bly=this.blx=this.bry=this.brx=this.try_=this.trx=this.tly=this.tlx=0;cr.seal(this)}function d(){l?this.s=new Set:(this.items={},this.item_count=0);this.values_cache=[];this.cache_valid=!0;cr.seal(this)}function e(a){k[m++]=a}function f(){this.sum=this.t=this.y=this.c=0;cr.seal(this)}function g(a){this.pts_cache=[];this.set_pts(a);cr.seal(this)}cr.logexport=function(a){window.console&&
window.console.log&&window.console.log(a)};cr.seal=function(a){return a};cr.freeze=function(a){return a};cr.is_undefined=function(a){return"undefined"===typeof a};cr.is_number=function(a){return"number"===typeof a};cr.is_string=function(a){return"string"===typeof a};cr.isPOT=function(a){return 0<a&&0===(a-1&a)};cr.abs=function(a){return 0>a?-a:a};cr.max=function(a,b){return a>b?a:b};cr.min=function(a,b){return a<b?a:b};cr.PI=Math.PI;cr.round=function(a){return a+0.5|0};cr.floor=function(a){return a|
0};a.prototype.offset=function(a,b){this.x+=a;this.y+=b;return this};a.prototype.mul=function(a,b){this.x*=a;this.y*=b;return this};cr.vector2=a;cr.segments_intersect=function(a,b,c,d,e,g,f,h){if(cr.max(a,c)<cr.min(e,f)||cr.min(a,c)>cr.max(e,f)||cr.max(b,d)<cr.min(g,h)||cr.min(b,d)>cr.max(g,h))return!1;var k=e-a+f-c,m=g-b+h-d;a=c-a;b=d-b;e=f-e;g=h-g;h=cr.abs(b*e-g*a);a=a*m-b*k;return cr.abs(e*m-g*k)<=h&&cr.abs(a)<=h};b.prototype.set=function(a,b,c,d){this.left=a;this.top=b;this.right=c;this.bottom=
d};b.prototype.width=function(){return this.right-this.left};b.prototype.height=function(){return this.bottom-this.top};b.prototype.offset=function(a,b){this.left+=a;this.top+=b;this.right+=a;this.bottom+=b;return this};b.prototype.intersects_rect=function(a){return!(a.right<this.left||a.bottom<this.top||a.left>this.right||a.top>this.bottom)};b.prototype.contains_pt=function(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom};cr.rect=b;c.prototype.set_from_rect=function(a){this.tlx=
a.left;this.tly=a.top;this.trx=a.right;this.try_=a.top;this.brx=a.right;this.bry=a.bottom;this.blx=a.left;this.bly=a.bottom};c.prototype.set_from_rotated_rect=function(a,b){if(0===b)this.set_from_rect(a);else{var c=Math.sin(b),d=Math.cos(b),e=a.left*c,g=a.top*c,f=a.right*c,c=a.bottom*c,h=a.left*d,k=a.top*d,m=a.right*d,d=a.bottom*d;this.tlx=h-g;this.tly=k+e;this.trx=m-g;this.try_=k+f;this.brx=m-c;this.bry=d+f;this.blx=h-c;this.bly=d+e}};c.prototype.offset=function(a,b){this.tlx+=a;this.tly+=b;this.trx+=
a;this.try_+=b;this.brx+=a;this.bry+=b;this.blx+=a;this.bly+=b;return this};c.prototype.bounding_box=function(a){a.left=cr.min(cr.min(this.tlx,this.trx),cr.min(this.brx,this.blx));a.top=cr.min(cr.min(this.tly,this.try_),cr.min(this.bry,this.bly));a.right=cr.max(cr.max(this.tlx,this.trx),cr.max(this.brx,this.blx));a.bottom=cr.max(cr.max(this.tly,this.try_),cr.max(this.bry,this.bly))};c.prototype.contains_pt=function(a,b){var c=this.trx-this.tlx,d=this.try_-this.tly,e=this.brx-this.tlx,g=this.bry-this.tly,
f=a-this.tlx,h=b-this.tly,k=c*c+d*d,m=c*e+d*g,d=c*f+d*h,l=e*e+g*g,n=e*f+g*h,z=1/(k*l-m*m),c=(l*d-m*n)*z,k=(k*n-m*d)*z;if(0<=c&&0<k&&1>c+k)return!0;c=this.blx-this.tlx;d=this.bly-this.tly;k=c*c+d*d;m=c*e+d*g;d=c*f+d*h;z=1/(k*l-m*m);c=(l*d-m*n)*z;k=(k*n-m*d)*z;return 0<=c&&0<k&&1>c+k};c.prototype.at=function(a,b){switch(a){case 0:return b?this.tlx:this.tly;case 1:return b?this.trx:this.try_;case 2:return b?this.brx:this.bry;case 3:return b?this.blx:this.bly;case 4:return b?this.tlx:this.tly;default:return b?
this.tlx:this.tly}};c.prototype.midX=function(){return(this.tlx+this.trx+this.brx+this.blx)/4};c.prototype.midY=function(){return(this.tly+this.try_+this.bry+this.bly)/4};c.prototype.intersects_segment=function(a,b,c,d){if(this.contains_pt(a,b)||this.contains_pt(c,d))return!0;var e,g,f,h,k;for(k=0;4>k;k++)if(e=this.at(k,!0),g=this.at(k,!1),f=this.at(k+1,!0),h=this.at(k+1,!1),cr.segments_intersect(a,b,c,d,e,g,f,h))return!0;return!1};c.prototype.intersects_quad=function(a){var b=a.midX(),c=a.midY();
if(this.contains_pt(b,c))return!0;b=this.midX();c=this.midY();if(a.contains_pt(b,c))return!0;var d,e,g,f,h,k,m,l;for(m=0;4>m;m++)for(l=0;4>l;l++)if(b=this.at(m,!0),c=this.at(m,!1),d=this.at(m+1,!0),e=this.at(m+1,!1),g=a.at(l,!0),f=a.at(l,!1),h=a.at(l+1,!0),k=a.at(l+1,!1),cr.segments_intersect(b,c,d,e,g,f,h,k))return!0;return!1};cr.quad=c;cr.RGB=function(a,b,c){return Math.max(Math.min(a,255),0)|Math.max(Math.min(b,255),0)<<8|Math.max(Math.min(c,255),0)<<16};cr.GetRValue=function(a){return a&255};
cr.GetGValue=function(a){return(a&65280)>>8};cr.GetBValue=function(a){return(a&16711680)>>16};cr.shallowCopy=function(a,b,c){for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);return a};cr.arrayRemove=function(a,b){var c,d;b=cr.floor(b);if(!(0>b||b>=a.length))if(0===b)a.shift();else if(b===a.length-1)a.pop();else{c=b;for(d=a.length-1;c<d;c++)a[c]=a[c+1];a.length=d}};cr.shallowAssignArray=function(a,b){a.length=b.length;var c,d;c=0;for(d=b.length;c<d;c++)a[c]=b[c]};cr.arrayFindRemove=function(a,b){var c=
a.indexOf(b);-1!==c&&cr.arrayRemove(a,c)};cr.clamp=function(a,b,c){return a<b?b:a>c?c:a};cr.to_radians=function(a){return a/(180/cr.PI)};cr.to_degrees=function(a){return a*(180/cr.PI)};cr.clamp_angle_degrees=function(a){a%=360;0>a&&(a+=360);return a};cr.clamp_angle=function(a){a%=2*cr.PI;0>a&&(a+=2*cr.PI);return a};cr.to_clamped_degrees=function(a){return cr.clamp_angle_degrees(cr.to_degrees(a))};cr.to_clamped_radians=function(a){return cr.clamp_angle(cr.to_radians(a))};cr.angleTo=function(a,b,c,
d){return Math.atan2(d-b,c-a)};cr.angleDiff=function(a,b){if(a===b)return 0;var c=Math.sin(a),d=Math.cos(a),e=Math.sin(b),g=Math.cos(b),c=c*e+d*g;return 1<=c?0:-1>=c?cr.PI:Math.acos(c)};cr.angleRotate=function(a,b,c){var d=Math.sin(a),e=Math.cos(a),g=Math.sin(b),f=Math.cos(b);return Math.acos(d*g+e*f)>c?0<e*g-d*f?cr.clamp_angle(a+c):cr.clamp_angle(a-c):cr.clamp_angle(b)};cr.angleClockwise=function(a,b){var c=Math.sin(a),d=Math.cos(a),e=Math.sin(b),g=Math.cos(b);return 0>=d*e-c*g};cr.rotatePtAround=
function(a,b,c,d,e,g){if(0===c)return g?a:b;var f=Math.sin(c);c=Math.cos(c);a-=d;b-=e;var h=a*f;a=a*c-b*f;b=b*c+h;return g?a+d:b+e};cr.distanceTo=function(a,b,c,d){a=c-a;b=d-b;return Math.sqrt(a*a+b*b)};cr.xor=function(a,b){return!a!==!b};cr.lerp=function(a,b,c){return a+(b-a)*c};cr.hasAnyOwnProperty=function(a){for(var b in a)if(a.hasOwnProperty(b))return!0;return!1};cr.wipe=function(a){for(var b in a)a.hasOwnProperty(b)&&delete a[b]};var h=+new Date;cr.performance_now=function(){if("undefined"!==
typeof window.performance){var a=window.performance;if("undefined"!==typeof a.now)return a.now();if("undefined"!==typeof a.webkitNow)return a.webkitNow();if("undefined"!==typeof a.msNow)return a.msNow()}return Date.now()-h};var l="undefined"!==typeof Set&&"undefined"!==typeof Set.prototype.forEach;d.prototype.contains=function(a){return l?this.s.has(a):this.items.hasOwnProperty(a.toString())};d.prototype.add=function(a){if(l)this.s.has(a)||(this.s.add(a),this.cache_valid=!1);else{var b=a.toString();
this.items.hasOwnProperty(b)||(this.items[b]=a,this.item_count++,this.cache_valid=!1)}return this};d.prototype.remove=function(a){l?this.s.has(a)&&(this.s["delete"](a),this.cache_valid=!1):(a=a.toString(),this.items.hasOwnProperty(a)&&(delete this.items[a],this.item_count--,this.cache_valid=!1));return this};d.prototype.clear=function(){l?this.s.clear():(cr.wipe(this.items),this.item_count=0);this.values_cache.length=0;this.cache_valid=!0;return this};d.prototype.isEmpty=function(){return l?0===this.s.size:
0===this.item_count};d.prototype.count=function(){return l?this.s.size:this.item_count};var k=null,m=0;d.prototype.update_cache=function(){if(!this.cache_valid){if(l)this.values_cache.length=this.s.size,k=this.values_cache,m=0,this.s.forEach(e),k=null,m=0;else{this.values_cache.length=this.item_count;var a,b=0;for(a in this.items)this.items.hasOwnProperty(a)&&(this.values_cache[b++]=this.items[a])}this.cache_valid=!0}};d.prototype.values=function(){this.update_cache();return this.values_cache.slice(0)};
d.prototype.valuesRef=function(){this.update_cache();return this.values_cache};cr.ObjectSet=d;f.prototype.add=function(a){this.y=a-this.c;this.t=this.sum+this.y;this.c=this.t-this.sum-this.y;this.sum=this.t};f.prototype.reset=function(){this.sum=this.t=this.y=this.c=0};cr.KahanAdder=f;cr.regexp_escape=function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")};g.prototype.set_pts=function(a){this.pts_array=a;this.pts_count=a.length/2;this.pts_cache.length=a.length;this.cache_height=this.cache_width=
-1;this.cache_angle=0};g.prototype.is_empty=function(){return!this.pts_array.length};g.prototype.set_from_quad=function(a,b,c,d,e){this.pts_cache.length=8;this.pts_count=4;var g=this.pts_cache;g[0]=a.tlx-b;g[1]=a.tly-c;g[2]=a.trx-b;g[3]=a.try_-c;g[4]=a.brx-b;g[5]=a.bry-c;g[6]=a.blx-b;g[7]=a.bly-c;this.cache_width=d;this.cache_height=e};g.prototype.set_from_poly=function(a){this.pts_count=a.pts_count;cr.shallowAssignArray(this.pts_cache,a.pts_cache)};g.prototype.cache_poly=function(a,b,c){if(this.cache_width!==
a||this.cache_height!==b||this.cache_angle!==c){this.cache_width=a;this.cache_height=b;this.cache_angle=c;var d,e,g,f=0,h=1,k=this.pts_array,m=this.pts_cache;0!==c&&(f=Math.sin(c),h=Math.cos(c));c=0;for(d=this.pts_count;c<d;c++)e=k[2*c]*a,g=k[2*c+1]*b,m[2*c]=e*h-g*f,m[2*c+1]=g*h+e*f}};g.prototype.contains_pt=function(a,b){var c=this.pts_cache;if(a===c[0]&&b===c[1])return!0;var d,e,g,f=this.pts_count,h=c[0],k=h,m=c[1],l=m;for(d=1;d<f;d++)e=c[2*d],g=c[2*d+1],e<h&&(h=e),e>k&&(k=e),g<m&&(m=g),g>l&&(l=
g);e=h-110;var m=m-101,k=k+131,l=l+120,n,z,A=0,B=0;for(d=0;d<f;d++)g=c[2*d],h=c[2*d+1],n=c[2*((d+1)%f)],z=c[2*((d+1)%f)+1],cr.segments_intersect(e,m,a,b,g,h,n,z)&&A++,cr.segments_intersect(k,l,a,b,g,h,n,z)&&B++;return 1===A%2||1===B%2};g.prototype.intersects_poly=function(a,b,c){var d=a.pts_cache,e=this.pts_cache;if(this.contains_pt(d[0]+b,d[1]+c)||a.contains_pt(e[0]-b,e[1]-c))return!0;var g,f,h,k,m,l,n,z,A,B,t,y;g=0;for(f=this.pts_count;g<f;g++)for(m=e[2*g],l=e[2*g+1],n=e[2*((g+1)%f)],z=e[2*((g+
1)%f)+1],h=0,k=a.pts_count;h<k;h++)if(A=d[2*h]+b,B=d[2*h+1]+c,t=d[2*((h+1)%k)]+b,y=d[2*((h+1)%k)+1]+c,cr.segments_intersect(m,l,n,z,A,B,t,y))return!0;return!1};g.prototype.intersects_segment=function(a,b,c,d,e,g){var f=this.pts_cache;if(this.contains_pt(c-a,d-b))return!0;var h,k,m,l,n,z;h=0;for(k=this.pts_count;h<k;h++)if(m=f[2*h]+a,l=f[2*h+1]+b,n=f[2*((h+1)%k)]+a,z=f[2*((h+1)%k)+1]+b,cr.segments_intersect(c,d,e,g,m,l,n,z))return!0;return!1};cr.CollisionPoly=g;var n="lighter xor copy destination-over source-in destination-in source-out destination-out source-atop destination-atop".split(" ");
cr.effectToCompositeOp=function(a){return 0>=a||11<=a?"source-over":n[a-1]};cr.setGLBlend=function(a,b,c){if(c)switch(a.srcBlend=c.ONE,a.destBlend=c.ONE_MINUS_SRC_ALPHA,b){case 1:a.srcBlend=c.ONE;a.destBlend=c.ONE;break;case 3:a.srcBlend=c.ONE;a.destBlend=c.ZERO;break;case 4:a.srcBlend=c.ONE_MINUS_DST_ALPHA;a.destBlend=c.ONE;break;case 5:a.srcBlend=c.DST_ALPHA;a.destBlend=c.ZERO;break;case 6:a.srcBlend=c.ZERO;a.destBlend=c.SRC_ALPHA;break;case 7:a.srcBlend=c.ONE_MINUS_DST_ALPHA;a.destBlend=c.ZERO;
break;case 8:a.srcBlend=c.ZERO;a.destBlend=c.ONE_MINUS_SRC_ALPHA;break;case 9:a.srcBlend=c.DST_ALPHA;a.destBlend=c.ONE_MINUS_SRC_ALPHA;break;case 10:a.srcBlend=c.ONE_MINUS_DST_ALPHA,a.destBlend=c.SRC_ALPHA}};cr.round6dp=function(a){return Math.round(1E6*a)/1E6};cr.equals_nocase=function(a,b){return"string"!==typeof a||"string"!==typeof b||a.length!==b.length?!1:a===b?!0:a.toLowerCase()===b.toLowerCase()}})();
var MatrixArray="undefined"!==typeof Float32Array?Float32Array:Array,glMatrixArrayType=MatrixArray,vec3={},mat3={},mat4={},quat4={};vec3.create=function(a){var b=new MatrixArray(3);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2]);return b};vec3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];return b};vec3.add=function(a,b,c){if(!c||a===c)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a;c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];return c};
vec3.subtract=function(a,b,c){if(!c||a===c)return a[0]-=b[0],a[1]-=b[1],a[2]-=b[2],a;c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];return c};vec3.negate=function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];return b};vec3.scale=function(a,b,c){if(!c||a===c)return a[0]*=b,a[1]*=b,a[2]*=b,a;c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;return c};
vec3.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],f=Math.sqrt(c*c+d*d+e*e);if(f){if(1===f)return b[0]=c,b[1]=d,b[2]=e,b}else return b[0]=0,b[1]=0,b[2]=0,b;f=1/f;b[0]=c*f;b[1]=d*f;b[2]=e*f;return b};vec3.cross=function(a,b,c){c||(c=a);var d=a[0],e=a[1];a=a[2];var f=b[0],g=b[1];b=b[2];c[0]=e*b-a*g;c[1]=a*f-d*b;c[2]=d*g-e*f;return c};vec3.length=function(a){var b=a[0],c=a[1];a=a[2];return Math.sqrt(b*b+c*c+a*a)};vec3.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]};
vec3.direction=function(a,b,c){c||(c=a);var d=a[0]-b[0],e=a[1]-b[1];a=a[2]-b[2];b=Math.sqrt(d*d+e*e+a*a);if(!b)return c[0]=0,c[1]=0,c[2]=0,c;b=1/b;c[0]=d*b;c[1]=e*b;c[2]=a*b;return c};vec3.lerp=function(a,b,c,d){d||(d=a);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);d[2]=a[2]+c*(b[2]-a[2]);return d};vec3.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+"]"};
mat3.create=function(a){var b=new MatrixArray(9);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8]);return b};mat3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return b};mat3.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a};
mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];a[1]=a[3];a[2]=a[6];a[3]=c;a[5]=a[7];a[6]=d;a[7]=e;return a}b[0]=a[0];b[1]=a[3];b[2]=a[6];b[3]=a[1];b[4]=a[4];b[5]=a[7];b[6]=a[2];b[7]=a[5];b[8]=a[8];return b};mat3.toMat4=function(a,b){b||(b=mat4.create());b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=a[8];b[9]=a[7];b[8]=a[6];b[7]=0;b[6]=a[5];b[5]=a[4];b[4]=a[3];b[3]=0;b[2]=a[2];b[1]=a[1];b[0]=a[0];return b};
mat3.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+"]"};mat4.create=function(a){var b=new MatrixArray(16);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15]);return b};
mat4.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b};mat4.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};
mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],f=a[6],g=a[7],h=a[11];a[1]=a[4];a[2]=a[8];a[3]=a[12];a[4]=c;a[6]=a[9];a[7]=a[13];a[8]=d;a[9]=f;a[11]=a[14];a[12]=e;a[13]=g;a[14]=h;return a}b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};
mat4.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],q=a[11],p=a[12],r=a[13],s=a[14];a=a[15];return p*m*h*e-k*r*h*e-p*g*n*e+f*r*n*e+k*g*s*e-f*m*s*e-p*m*d*l+k*r*d*l+p*c*n*l-b*r*n*l-k*c*s*l+b*m*s*l+p*g*d*q-f*r*d*q-p*c*h*q+b*r*h*q+f*c*s*q-b*g*s*q-k*g*d*a+f*m*d*a+k*c*h*a-b*m*h*a-f*c*n*a+b*g*n*a};
mat4.inverse=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],k=a[7],m=a[8],n=a[9],q=a[10],p=a[11],r=a[12],s=a[13],w=a[14],x=a[15],C=c*h-d*g,F=c*l-e*g,I=c*k-f*g,D=d*l-e*h,v=d*k-f*h,u=e*k-f*l,z=m*s-n*r,A=m*w-q*r,B=m*x-p*r,t=n*w-q*s,y=n*x-p*s,K=q*x-p*w,E=1/(C*K-F*y+I*t+D*B-v*A+u*z);b[0]=(h*K-l*y+k*t)*E;b[1]=(-d*K+e*y-f*t)*E;b[2]=(s*u-w*v+x*D)*E;b[3]=(-n*u+q*v-p*D)*E;b[4]=(-g*K+l*B-k*A)*E;b[5]=(c*K-e*B+f*A)*E;b[6]=(-r*u+w*I-x*F)*E;b[7]=(m*u-q*I+p*F)*E;b[8]=(g*y-h*B+k*z)*E;
b[9]=(-c*y+d*B-f*z)*E;b[10]=(r*v-s*I+x*C)*E;b[11]=(-m*v+n*I-p*C)*E;b[12]=(-g*t+h*A-l*z)*E;b[13]=(c*t-d*A+e*z)*E;b[14]=(-r*D+s*F-w*C)*E;b[15]=(m*D-n*F+q*C)*E;return b};mat4.toRotationMat=function(a,b){b||(b=mat4.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};
mat4.toMat3=function(a,b){b||(b=mat3.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[4];b[4]=a[5];b[5]=a[6];b[6]=a[8];b[7]=a[9];b[8]=a[10];return b};mat4.toInverseMat3=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[4],g=a[5],h=a[6],l=a[8],k=a[9],m=a[10],n=m*g-h*k,q=-m*f+h*l,p=k*f-g*l,r=c*n+d*q+e*p;if(!r)return null;r=1/r;b||(b=mat3.create());b[0]=n*r;b[1]=(-m*d+e*k)*r;b[2]=(h*d-e*g)*r;b[3]=q*r;b[4]=(m*c-e*l)*r;b[5]=(-h*c+e*f)*r;b[6]=p*r;b[7]=(-k*c+d*l)*r;b[8]=(g*c-d*f)*r;return b};
mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],l=a[5],k=a[6],m=a[7],n=a[8],q=a[9],p=a[10],r=a[11],s=a[12],w=a[13],x=a[14];a=a[15];var C=b[0],F=b[1],I=b[2],D=b[3],v=b[4],u=b[5],z=b[6],A=b[7],B=b[8],t=b[9],y=b[10],K=b[11],E=b[12],N=b[13],H=b[14];b=b[15];c[0]=C*d+F*h+I*n+D*s;c[1]=C*e+F*l+I*q+D*w;c[2]=C*f+F*k+I*p+D*x;c[3]=C*g+F*m+I*r+D*a;c[4]=v*d+u*h+z*n+A*s;c[5]=v*e+u*l+z*q+A*w;c[6]=v*f+u*k+z*p+A*x;c[7]=v*g+u*m+z*r+A*a;c[8]=B*d+t*h+y*n+K*s;c[9]=B*e+t*l+y*q+K*w;c[10]=B*
f+t*k+y*p+K*x;c[11]=B*g+t*m+y*r+K*a;c[12]=E*d+N*h+H*n+b*s;c[13]=E*e+N*l+H*q+b*w;c[14]=E*f+N*k+H*p+b*x;c[15]=E*g+N*m+H*r+b*a;return c};mat4.multiplyVec3=function(a,b,c){c||(c=b);var d=b[0],e=b[1];b=b[2];c[0]=a[0]*d+a[4]*e+a[8]*b+a[12];c[1]=a[1]*d+a[5]*e+a[9]*b+a[13];c[2]=a[2]*d+a[6]*e+a[10]*b+a[14];return c};
mat4.multiplyVec4=function(a,b,c){c||(c=b);var d=b[0],e=b[1],f=b[2];b=b[3];c[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*b;c[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*b;c[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*b;c[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*b;return c};
mat4.translate=function(a,b,c){var d=b[0],e=b[1];b=b[2];var f,g,h,l,k,m,n,q,p,r,s,w;if(!c||a===c)return a[12]=a[0]*d+a[4]*e+a[8]*b+a[12],a[13]=a[1]*d+a[5]*e+a[9]*b+a[13],a[14]=a[2]*d+a[6]*e+a[10]*b+a[14],a[15]=a[3]*d+a[7]*e+a[11]*b+a[15],a;f=a[0];g=a[1];h=a[2];l=a[3];k=a[4];m=a[5];n=a[6];q=a[7];p=a[8];r=a[9];s=a[10];w=a[11];c[0]=f;c[1]=g;c[2]=h;c[3]=l;c[4]=k;c[5]=m;c[6]=n;c[7]=q;c[8]=p;c[9]=r;c[10]=s;c[11]=w;c[12]=f*d+k*e+p*b+a[12];c[13]=g*d+m*e+r*b+a[13];c[14]=h*d+n*e+s*b+a[14];c[15]=l*d+q*e+w*b+
a[15];return c};mat4.scale=function(a,b,c){var d=b[0],e=b[1];b=b[2];if(!c||a===c)return a[0]*=d,a[1]*=d,a[2]*=d,a[3]*=d,a[4]*=e,a[5]*=e,a[6]*=e,a[7]*=e,a[8]*=b,a[9]*=b,a[10]*=b,a[11]*=b,a;c[0]=a[0]*d;c[1]=a[1]*d;c[2]=a[2]*d;c[3]=a[3]*d;c[4]=a[4]*e;c[5]=a[5]*e;c[6]=a[6]*e;c[7]=a[7]*e;c[8]=a[8]*b;c[9]=a[9]*b;c[10]=a[10]*b;c[11]=a[11]*b;c[12]=a[12];c[13]=a[13];c[14]=a[14];c[15]=a[15];return c};
mat4.rotate=function(a,b,c,d){var e=c[0],f=c[1];c=c[2];var g=Math.sqrt(e*e+f*f+c*c),h,l,k,m,n,q,p,r,s,w,x,C,F,I,D,v,u,z,A,B;if(!g)return null;1!==g&&(g=1/g,e*=g,f*=g,c*=g);h=Math.sin(b);l=Math.cos(b);k=1-l;b=a[0];g=a[1];m=a[2];n=a[3];q=a[4];p=a[5];r=a[6];s=a[7];w=a[8];x=a[9];C=a[10];F=a[11];I=e*e*k+l;D=f*e*k+c*h;v=c*e*k-f*h;u=e*f*k-c*h;z=f*f*k+l;A=c*f*k+e*h;B=e*c*k+f*h;e=f*c*k-e*h;f=c*c*k+l;d?a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]):d=a;d[0]=b*I+q*D+w*v;d[1]=g*I+p*D+x*v;d[2]=m*I+r*
D+C*v;d[3]=n*I+s*D+F*v;d[4]=b*u+q*z+w*A;d[5]=g*u+p*z+x*A;d[6]=m*u+r*z+C*A;d[7]=n*u+s*z+F*A;d[8]=b*B+q*e+w*f;d[9]=g*B+p*e+x*f;d[10]=m*B+r*e+C*f;d[11]=n*B+s*e+F*f;return d};
mat4.rotateX=function(a,b,c){var d=Math.sin(b);b=Math.cos(b);var e=a[4],f=a[5],g=a[6],h=a[7],l=a[8],k=a[9],m=a[10],n=a[11];c?a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[4]=e*b+l*d;c[5]=f*b+k*d;c[6]=g*b+m*d;c[7]=h*b+n*d;c[8]=e*-d+l*b;c[9]=f*-d+k*b;c[10]=g*-d+m*b;c[11]=h*-d+n*b;return c};
mat4.rotateY=function(a,b,c){var d=Math.sin(b);b=Math.cos(b);var e=a[0],f=a[1],g=a[2],h=a[3],l=a[8],k=a[9],m=a[10],n=a[11];c?a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+l*-d;c[1]=f*b+k*-d;c[2]=g*b+m*-d;c[3]=h*b+n*-d;c[8]=e*d+l*b;c[9]=f*d+k*b;c[10]=g*d+m*b;c[11]=h*d+n*b;return c};
mat4.rotateZ=function(a,b,c){var d=Math.sin(b);b=Math.cos(b);var e=a[0],f=a[1],g=a[2],h=a[3],l=a[4],k=a[5],m=a[6],n=a[7];c?a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+l*d;c[1]=f*b+k*d;c[2]=g*b+m*d;c[3]=h*b+n*d;c[4]=e*-d+l*b;c[5]=f*-d+k*b;c[6]=g*-d+m*b;c[7]=h*-d+n*b;return c};
mat4.frustum=function(a,b,c,d,e,f,g){g||(g=mat4.create());var h=b-a,l=d-c,k=f-e;g[0]=2*e/h;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2*e/l;g[6]=0;g[7]=0;g[8]=(b+a)/h;g[9]=(d+c)/l;g[10]=-(f+e)/k;g[11]=-1;g[12]=0;g[13]=0;g[14]=-(2*f*e)/k;g[15]=0;return g};mat4.perspective=function(a,b,c,d,e){a=c*Math.tan(a*Math.PI/360);b*=a;return mat4.frustum(-b,b,-a,a,c,d,e)};
mat4.ortho=function(a,b,c,d,e,f,g){g||(g=mat4.create());var h=b-a,l=d-c,k=f-e;g[0]=2/h;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2/l;g[6]=0;g[7]=0;g[8]=0;g[9]=0;g[10]=-2/k;g[11]=0;g[12]=-(a+b)/h;g[13]=-(d+c)/l;g[14]=-(f+e)/k;g[15]=1;return g};
mat4.lookAt=function(a,b,c,d){d||(d=mat4.create());var e,f,g,h,l,k,m,n,q=a[0],p=a[1];a=a[2];f=c[0];g=c[1];e=c[2];c=b[1];k=b[2];if(q===b[0]&&p===c&&a===k)return mat4.identity(d);c=q-b[0];k=p-b[1];m=a-b[2];n=1/Math.sqrt(c*c+k*k+m*m);c*=n;k*=n;m*=n;b=g*m-e*k;e=e*c-f*m;f=f*k-g*c;(n=Math.sqrt(b*b+e*e+f*f))?(n=1/n,b*=n,e*=n,f*=n):f=e=b=0;g=k*f-m*e;h=m*b-c*f;l=c*e-k*b;(n=Math.sqrt(g*g+h*h+l*l))?(n=1/n,g*=n,h*=n,l*=n):l=h=g=0;d[0]=b;d[1]=g;d[2]=c;d[3]=0;d[4]=e;d[5]=h;d[6]=k;d[7]=0;d[8]=f;d[9]=l;d[10]=m;d[11]=
0;d[12]=-(b*q+e*p+f*a);d[13]=-(g*q+h*p+l*a);d[14]=-(c*q+k*p+m*a);d[15]=1;return d};mat4.fromRotationTranslation=function(a,b,c){c||(c=mat4.create());var d=a[0],e=a[1],f=a[2],g=a[3],h=d+d,l=e+e,k=f+f;a=d*h;var m=d*l,d=d*k,n=e*l,e=e*k,f=f*k,h=h*g,l=l*g,g=g*k;c[0]=1-(n+f);c[1]=m+g;c[2]=d-l;c[3]=0;c[4]=m-g;c[5]=1-(a+f);c[6]=e+h;c[7]=0;c[8]=d+l;c[9]=e-h;c[10]=1-(a+n);c[11]=0;c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c};
mat4.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+"]"};quat4.create=function(a){var b=new MatrixArray(4);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]);return b};quat4.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b};
quat4.calculateW=function(a,b){var c=a[0],d=a[1],e=a[2];if(!b||a===b)return a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a;b[0]=c;b[1]=d;b[2]=e;b[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e));return b};quat4.inverse=function(a,b){if(!b||a===b)return a[0]*=-1,a[1]*=-1,a[2]*=-1,a;b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b};quat4.length=function(a){var b=a[0],c=a[1],d=a[2];a=a[3];return Math.sqrt(b*b+c*c+d*d+a*a)};
quat4.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],f=a[3],g=Math.sqrt(c*c+d*d+e*e+f*f);if(0===g)return b[0]=0,b[1]=0,b[2]=0,b[3]=0,b;g=1/g;b[0]=c*g;b[1]=d*g;b[2]=e*g;b[3]=f*g;return b};quat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2];a=a[3];var g=b[0],h=b[1],l=b[2];b=b[3];c[0]=d*b+a*g+e*l-f*h;c[1]=e*b+a*h+f*g-d*l;c[2]=f*b+a*l+d*h-e*g;c[3]=a*b-d*g-e*h-f*l;return c};
quat4.multiplyVec3=function(a,b,c){c||(c=b);var d=b[0],e=b[1],f=b[2];b=a[0];var g=a[1],h=a[2];a=a[3];var l=a*d+g*f-h*e,k=a*e+h*d-b*f,m=a*f+b*e-g*d,d=-b*d-g*e-h*f;c[0]=l*a+d*-b+k*-h-m*-g;c[1]=k*a+d*-g+m*-b-l*-h;c[2]=m*a+d*-h+l*-g-k*-b;return c};quat4.toMat3=function(a,b){b||(b=mat3.create());var c=a[0],d=a[1],e=a[2],f=a[3],g=c+c,h=d+d,l=e+e,k=c*g,m=c*h,c=c*l,n=d*h,d=d*l,e=e*l,g=g*f,h=h*f,f=f*l;b[0]=1-(n+e);b[1]=m+f;b[2]=c-h;b[3]=m-f;b[4]=1-(k+e);b[5]=d+g;b[6]=c+h;b[7]=d-g;b[8]=1-(k+n);return b};
quat4.toMat4=function(a,b){b||(b=mat4.create());var c=a[0],d=a[1],e=a[2],f=a[3],g=c+c,h=d+d,l=e+e,k=c*g,m=c*h,c=c*l,n=d*h,d=d*l,e=e*l,g=g*f,h=h*f,f=f*l;b[0]=1-(n+e);b[1]=m+f;b[2]=c-h;b[3]=0;b[4]=m-f;b[5]=1-(k+e);b[6]=d+g;b[7]=0;b[8]=c+h;b[9]=d-g;b[10]=1-(k+n);b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};
quat4.slerp=function(a,b,c,d){d||(d=a);var e=a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3],f,g;if(1<=Math.abs(e))return d!==a&&(d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=a[3]),d;f=Math.acos(e);g=Math.sqrt(1-e*e);if(0.001>Math.abs(g))return d[0]=0.5*a[0]+0.5*b[0],d[1]=0.5*a[1]+0.5*b[1],d[2]=0.5*a[2]+0.5*b[2],d[3]=0.5*a[3]+0.5*b[3],d;e=Math.sin((1-c)*f)/g;c=Math.sin(c*f)/g;d[0]=a[0]*e+b[0]*c;d[1]=a[1]*e+b[1]*c;d[2]=a[2]*e+b[2]*c;d[3]=a[3]*e+b[3]*c;return d};
quat4.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"};
(function(){function a(a,b){this.height=this.width=0;this.cam=vec3.create([0,0,100]);this.look=vec3.create([0,0,0]);this.up=vec3.create([0,1,0]);this.worldScale=vec3.create([1,1,1]);this.matP=mat4.create();this.matMV=mat4.create();this.lastMV=mat4.create();this.currentMV=mat4.create();this.gl=a;this.initState()}function b(a,b,c){this.gl=a;this.shaderProgram=b;this.name=c;this.locAPos=a.getAttribLocation(b,"aPos");this.locATex=a.getAttribLocation(b,"aTex");this.locMatP=a.getUniformLocation(b,"matP");
this.locMatMV=a.getUniformLocation(b,"matMV");this.locOpacity=a.getUniformLocation(b,"opacity");this.locSamplerFront=a.getUniformLocation(b,"samplerFront");this.locSamplerBack=a.getUniformLocation(b,"samplerBack");this.locDestStart=a.getUniformLocation(b,"destStart");this.locDestEnd=a.getUniformLocation(b,"destEnd");this.locSeconds=a.getUniformLocation(b,"seconds");this.locPixelWidth=a.getUniformLocation(b,"pixelWidth");this.locPixelHeight=a.getUniformLocation(b,"pixelHeight");this.locLayerScale=
a.getUniformLocation(b,"layerScale");this.locOpacity&&a.uniform1f(this.locOpacity,1);this.locSamplerFront&&a.uniform1i(this.locSamplerFront,0);this.locSamplerBack&&a.uniform1i(this.locSamplerBack,1);this.locDestStart&&a.uniform2f(this.locDestStart,0,0);this.locDestEnd&&a.uniform2f(this.locDestEnd,1,1);this.hasCurrentMatMV=!1}function c(a,b){this.type=a;this.glwrap=b;this.gl=b.gl;this.indexCount=this.startIndex=this.opacityParam=0;this.mat4param=this.texParam=null;this.shaderParams=[];cr.seal(this)}
function d(a){--a;for(var b=1;32>b;b<<=1)a|=a>>b;return a+1}a.prototype.initState=function(){var a=this.gl,b;this.lastOpacity=1;this.lastTexture=null;this.currentOpacity=1;a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.BLEND);a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA);a.disable(a.CULL_FACE);a.disable(a.DEPTH_TEST);this.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE);this.lastSrcBlend=a.ONE;this.lastDestBlend=a.ONE_MINUS_SRC_ALPHA;this.pointBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,
this.pointBuffer);this.vertexBuffers=Array(4);this.texcoordBuffers=Array(4);for(b=0;4>b;b++)this.vertexBuffers[b]=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffers[b]),this.texcoordBuffers[b]=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this.texcoordBuffers[b]);this.curBuffer=0;this.indexBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);this.vertexData=new Float32Array(16E3);this.texcoordData=new Float32Array(16E3);this.pointData=new Float32Array(32E3);for(var c=
new Uint16Array(12E3),d=b=0;12E3>b;)c[b++]=d,c[b++]=d+1,c[b++]=d+2,c[b++]=d,c[b++]=d+2,c[b++]=d+3,d+=4;a.bufferData(a.ELEMENT_ARRAY_BUFFER,c,a.STATIC_DRAW);this.pointPtr=this.vertexPtr=0;this.shaderPrograms=[];b=this.createShaderProgram({src:"varying mediump vec2 vTex;\nuniform lowp float opacity;\nuniform lowp sampler2D samplerFront;\nvoid main(void) {\n\tgl_FragColor = texture2D(samplerFront, vTex);\n\tgl_FragColor *= opacity;\n}"},"attribute highp vec2 aPos;\nattribute mediump vec2 aTex;\nvarying mediump vec2 vTex;\nuniform highp mat4 matP;\nuniform highp mat4 matMV;\nvoid main(void) {\n\tgl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);\n\tvTex = aTex;\n}",
"<default>");this.shaderPrograms.push(b);b=this.createShaderProgram({src:"uniform mediump sampler2D samplerFront;\nvarying lowp float opacity;\nvoid main(void) {\n\tgl_FragColor = texture2D(samplerFront, gl_PointCoord);\n\tgl_FragColor *= opacity;\n}"},"attribute vec4 aPos;\nvarying float opacity;\nuniform mat4 matP;\nuniform mat4 matMV;\nvoid main(void) {\n\tgl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);\n\tgl_PointSize = aPos.z;\n\topacity = aPos.w;\n}","<point>");this.shaderPrograms.push(b);
for(var e in cr.shaders)cr.shaders.hasOwnProperty(e)&&this.shaderPrograms.push(this.createShaderProgram(cr.shaders[e],"attribute highp vec2 aPos;\nattribute mediump vec2 aTex;\nvarying mediump vec2 vTex;\nuniform highp mat4 matP;\nuniform highp mat4 matMV;\nvoid main(void) {\n\tgl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);\n\tvTex = aTex;\n}",e));a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,null);this.batch=[];this.batchPtr=0;this.hasPointBatchTop=this.hasQuadBatchTop=!1;
this.currentProgram=this.lastProgram=-1;this.currentShader=null;this.fbo=a.createFramebuffer();this.renderToTex=null;this.tmpVec3=vec3.create([0,0,0]);a=a.getParameter(a.ALIASED_POINT_SIZE_RANGE);this.minPointSize=a[0];this.maxPointSize=a[1];this.switchProgram(0);cr.seal(this)};a.prototype.createShaderProgram=function(a,c,d){var e=this.gl,f=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(f,a.src);e.compileShader(f);if(!e.getShaderParameter(f,e.COMPILE_STATUS))return e.deleteShader(f),null;var n=
e.createShader(e.VERTEX_SHADER);e.shaderSource(n,c);e.compileShader(n);if(!e.getShaderParameter(n,e.COMPILE_STATUS))return e.deleteShader(f),e.deleteShader(n),null;c=e.createProgram();e.attachShader(c,f);e.attachShader(c,n);e.linkProgram(c);if(!e.getProgramParameter(c,e.LINK_STATUS))return e.deleteShader(f),e.deleteShader(n),e.deleteProgram(c),null;e.useProgram(c);e.deleteShader(f);e.deleteShader(n);d=new b(e,c,d);d.extendBoxHorizontal=a.extendBoxHorizontal||0;d.extendBoxVertical=a.extendBoxVertical||
0;d.crossSampling=!!a.crossSampling;d.animated=!!a.animated;d.parameters=a.parameters||[];a=0;for(f=d.parameters.length;a<f;a++)d.parameters[a][1]=e.getUniformLocation(c,d.parameters[a][0]),e.uniform1f(d.parameters[a][1],0);cr.seal(d);return d};a.prototype.getShaderIndex=function(a){var b,c;b=0;for(c=this.shaderPrograms.length;b<c;b++)if(this.shaderPrograms[b].name===a)return b;return-1};a.prototype.project=function(a,b,c){var d=[0,0,this.width,this.height],e=this.matMV,f=this.matP,q=[0,0,0,0,0,0,
0,0];q[0]=e[0]*a+e[4]*b+e[12];q[1]=e[1]*a+e[5]*b+e[13];q[2]=e[2]*a+e[6]*b+e[14];q[3]=e[3]*a+e[7]*b+e[15];q[4]=f[0]*q[0]+f[4]*q[1]+f[8]*q[2]+f[12]*q[3];q[5]=f[1]*q[0]+f[5]*q[1]+f[9]*q[2]+f[13]*q[3];q[6]=f[2]*q[0]+f[6]*q[1]+f[10]*q[2]+f[14]*q[3];q[7]=-q[2];0!==q[7]&&(q[7]=1/q[7],q[4]*=q[7],q[5]*=q[7],q[6]*=q[7],c[0]=(0.5*q[4]+0.5)*d[2]+d[0],c[1]=(0.5*q[5]+0.5)*d[3]+d[1])};a.prototype.setSize=function(a,b,c){if(this.width!==a||this.height!==b||c){this.endBatch();this.width=a;this.height=b;this.gl.viewport(0,
0,a,b);mat4.perspective(45,a/b,1,1E3,this.matP);mat4.lookAt(this.cam,this.look,this.up,this.matMV);a=[0,0];b=[0,0];this.project(0,0,a);this.project(1,1,b);this.worldScale[0]=1/(b[0]-a[0]);this.worldScale[1]=-1/(b[1]-a[1]);a=0;for(b=this.shaderPrograms.length;a<b;a++)c=this.shaderPrograms[a],c.hasCurrentMatMV=!1,c.locMatP&&(this.gl.useProgram(c.shaderProgram),this.gl.uniformMatrix4fv(c.locMatP,!1,this.matP));this.gl.useProgram(this.shaderPrograms[this.lastProgram].shaderProgram);this.gl.bindTexture(this.gl.TEXTURE_2D,
null);this.lastTexture=null}};a.prototype.resetModelView=function(){mat4.lookAt(this.cam,this.look,this.up,this.matMV);mat4.scale(this.matMV,this.worldScale)};a.prototype.translate=function(a,b){if(0!==a||0!==b)this.tmpVec3[0]=a,this.tmpVec3[1]=b,this.tmpVec3[2]=0,mat4.translate(this.matMV,this.tmpVec3)};a.prototype.scale=function(a,b){if(1!==a||1!==b)this.tmpVec3[0]=a,this.tmpVec3[1]=b,this.tmpVec3[2]=1,mat4.scale(this.matMV,this.tmpVec3)};a.prototype.rotateZ=function(a){0!==a&&mat4.rotateZ(this.matMV,
a)};a.prototype.updateModelView=function(){for(var a=!1,b=0;16>b;b++)if(this.lastMV[b]!==this.matMV[b]){a=!0;break}a&&(a=this.pushBatch(),a.type=5,a.mat4param?mat4.set(this.matMV,a.mat4param):a.mat4param=mat4.create(this.matMV),mat4.set(this.matMV,this.lastMV),this.hasPointBatchTop=this.hasQuadBatchTop=!1)};c.prototype.doSetTexture=function(){this.gl.bindTexture(this.gl.TEXTURE_2D,this.texParam)};c.prototype.doSetOpacity=function(){var a=this.opacityParam,b=this.glwrap;b.currentOpacity=a;b=b.currentShader;
b.locOpacity&&this.gl.uniform1f(b.locOpacity,a)};c.prototype.doQuad=function(){this.gl.drawElements(this.gl.TRIANGLES,this.indexCount,this.gl.UNSIGNED_SHORT,2*this.startIndex)};c.prototype.doSetBlend=function(){this.gl.blendFunc(this.startIndex,this.indexCount)};c.prototype.doUpdateModelView=function(){var a,b,c,d=this.glwrap.shaderPrograms,e=this.glwrap.currentProgram;a=0;for(b=d.length;a<b;a++)c=d[a],a===e&&c.locMatMV?(this.gl.uniformMatrix4fv(c.locMatMV,!1,this.mat4param),c.hasCurrentMatMV=!0):
c.hasCurrentMatMV=!1;mat4.set(this.mat4param,this.glwrap.currentMV)};c.prototype.doRenderToTexture=function(){var a=this.gl,b=this.glwrap;this.texParam?(a.bindFramebuffer(a.FRAMEBUFFER,b.fbo),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.texParam,0)):(a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,null,0),a.bindFramebuffer(a.FRAMEBUFFER,null))};c.prototype.doClear=function(){var a=this.gl;0===this.startIndex?(a.clearColor(this.mat4param[0],this.mat4param[1],
this.mat4param[2],this.mat4param[3]),a.clear(a.COLOR_BUFFER_BIT)):(a.enable(a.SCISSOR_TEST),a.scissor(this.mat4param[0],this.mat4param[1],this.mat4param[2],this.mat4param[3]),a.clearColor(0,0,0,0),a.clear(this.gl.COLOR_BUFFER_BIT),a.disable(a.SCISSOR_TEST))};c.prototype.doPoints=function(){var a=this.gl,b=this.glwrap,c=b.shaderPrograms[1];a.useProgram(c.shaderProgram);!c.hasCurrentMatMV&&c.locMatMV&&(a.uniformMatrix4fv(c.locMatMV,!1,b.currentMV),c.hasCurrentMatMV=!0);a.enableVertexAttribArray(c.locAPos);
a.bindBuffer(a.ARRAY_BUFFER,b.pointBuffer);a.vertexAttribPointer(c.locAPos,4,a.FLOAT,!1,0,0);a.drawArrays(a.POINTS,this.startIndex/4,this.indexCount);c=b.currentShader;a.useProgram(c.shaderProgram);0<=c.locAPos&&(a.enableVertexAttribArray(c.locAPos),a.bindBuffer(a.ARRAY_BUFFER,b.vertexBuffers[b.curBuffer]),a.vertexAttribPointer(c.locAPos,2,a.FLOAT,!1,0,0));0<=c.locATex&&(a.enableVertexAttribArray(c.locATex),a.bindBuffer(a.ARRAY_BUFFER,b.texcoordBuffers[b.curBuffer]),a.vertexAttribPointer(c.locATex,
2,a.FLOAT,!1,0,0))};c.prototype.doSetProgram=function(){var a=this.gl,b=this.glwrap,c=b.shaderPrograms[this.startIndex];b.currentProgram=this.startIndex;b.currentShader=c;a.useProgram(c.shaderProgram);!c.hasCurrentMatMV&&c.locMatMV&&(a.uniformMatrix4fv(c.locMatMV,!1,b.currentMV),c.hasCurrentMatMV=!0);c.locOpacity&&a.uniform1f(c.locOpacity,b.currentOpacity);0<=c.locAPos&&(a.enableVertexAttribArray(c.locAPos),a.bindBuffer(a.ARRAY_BUFFER,b.vertexBuffers[b.curBuffer]),a.vertexAttribPointer(c.locAPos,
2,a.FLOAT,!1,0,0));0<=c.locATex&&(a.enableVertexAttribArray(c.locATex),a.bindBuffer(a.ARRAY_BUFFER,b.texcoordBuffers[b.curBuffer]),a.vertexAttribPointer(c.locATex,2,a.FLOAT,!1,0,0))};c.prototype.doSetProgramParameters=function(){var a,b,c=this.glwrap.currentShader,d=this.gl;c.locSamplerBack&&(d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,this.texParam),d.activeTexture(d.TEXTURE0));c.locPixelWidth&&d.uniform1f(c.locPixelWidth,this.mat4param[0]);c.locPixelHeight&&d.uniform1f(c.locPixelHeight,
this.mat4param[1]);c.locDestStart&&d.uniform2f(c.locDestStart,this.mat4param[2],this.mat4param[3]);c.locDestEnd&&d.uniform2f(c.locDestEnd,this.mat4param[4],this.mat4param[5]);c.locLayerScale&&d.uniform1f(c.locLayerScale,this.mat4param[6]);c.locSeconds&&d.uniform1f(c.locSeconds,cr.performance_now()/1E3);if(c.parameters.length)for(a=0,b=c.parameters.length;a<b;a++)d.uniform1f(c.parameters[a][1],this.shaderParams[a])};a.prototype.pushBatch=function(){this.batchPtr===this.batch.length&&this.batch.push(new c(0,
this));return this.batch[this.batchPtr++]};a.prototype.endBatch=function(){if(0!==this.batchPtr&&!this.gl.isContextLost()){var a=this.gl;0<this.pointPtr&&(a.bindBuffer(a.ARRAY_BUFFER,this.pointBuffer),a.bufferData(a.ARRAY_BUFFER,this.pointData.subarray(0,this.pointPtr),a.STREAM_DRAW),b&&0<=b.locAPos&&"<point>"===b.name&&a.vertexAttribPointer(b.locAPos,4,a.FLOAT,!1,0,0));if(0<this.vertexPtr){var b=this.currentShader;a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffers[this.curBuffer]);a.bufferData(a.ARRAY_BUFFER,
this.vertexData.subarray(0,this.vertexPtr),a.STREAM_DRAW);b&&0<=b.locAPos&&"<point>"!==b.name&&a.vertexAttribPointer(b.locAPos,2,a.FLOAT,!1,0,0);a.bindBuffer(a.ARRAY_BUFFER,this.texcoordBuffers[this.curBuffer]);a.bufferData(a.ARRAY_BUFFER,this.texcoordData.subarray(0,this.vertexPtr),a.STREAM_DRAW);b&&0<=b.locATex&&"<point>"!==b.name&&a.vertexAttribPointer(b.locATex,2,a.FLOAT,!1,0,0)}for(var c,a=0,b=this.batchPtr;a<b;a++)switch(c=this.batch[a],c.type){case 1:c.doQuad();break;case 2:c.doSetTexture();
break;case 3:c.doSetOpacity();break;case 4:c.doSetBlend();break;case 5:c.doUpdateModelView();break;case 6:c.doRenderToTexture();break;case 7:c.doClear();break;case 8:c.doPoints();break;case 9:c.doSetProgram();break;case 10:c.doSetProgramParameters()}this.pointPtr=this.vertexPtr=this.batchPtr=0;this.hasPointBatchTop=this.hasQuadBatchTop=!1;this.curBuffer++;4<=this.curBuffer&&(this.curBuffer=0)}};a.prototype.setOpacity=function(a){if(a!==this.lastOpacity){var b=this.pushBatch();b.type=3;this.lastOpacity=
b.opacityParam=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.setTexture=function(a){if(a!==this.lastTexture){var b=this.pushBatch();b.type=2;this.lastTexture=b.texParam=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.setBlend=function(a,b){if(a!==this.lastSrcBlend||b!==this.lastDestBlend){var c=this.pushBatch();c.type=4;c.startIndex=a;c.indexCount=b;this.lastSrcBlend=a;this.lastDestBlend=b;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.setAlphaBlend=function(){this.setBlend(this.gl.ONE,
this.gl.ONE_MINUS_SRC_ALPHA)};a.prototype.quad=function(a,b,c,d,e,f,q,p){15992<=this.vertexPtr&&this.endBatch();var r=this.vertexPtr,s=this.vertexData,w=this.texcoordData;if(this.hasQuadBatchTop)this.batch[this.batchPtr-1].indexCount+=6;else{var x=this.pushBatch();x.type=1;x.startIndex=3*(r/4);x.indexCount=6;this.hasQuadBatchTop=!0;this.hasPointBatchTop=!1}s[r]=a;w[r++]=0;s[r]=b;w[r++]=0;s[r]=c;w[r++]=1;s[r]=d;w[r++]=0;s[r]=e;w[r++]=1;s[r]=f;w[r++]=1;s[r]=q;w[r++]=0;s[r]=p;w[r++]=1;this.vertexPtr=
r};a.prototype.quadTex=function(a,b,c,d,e,f,q,p,r){15992<=this.vertexPtr&&this.endBatch();var s=this.vertexPtr,w=this.vertexData,x=this.texcoordData;if(this.hasQuadBatchTop)this.batch[this.batchPtr-1].indexCount+=6;else{var C=this.pushBatch();C.type=1;C.startIndex=3*(s/4);C.indexCount=6;this.hasQuadBatchTop=!0;this.hasPointBatchTop=!1}w[s]=a;x[s++]=r.left;w[s]=b;x[s++]=r.top;w[s]=c;x[s++]=r.right;w[s]=d;x[s++]=r.top;w[s]=e;x[s++]=r.right;w[s]=f;x[s++]=r.bottom;w[s]=q;x[s++]=r.left;w[s]=p;x[s++]=r.bottom;
this.vertexPtr=s};a.prototype.point=function(a,b,c,d){7996<=this.pointPtr&&this.endBatch();var e=this.pointPtr,f=this.pointData;if(this.hasPointBatchTop)this.batch[this.batchPtr-1].indexCount++;else{var q=this.pushBatch();q.type=8;q.startIndex=e;q.indexCount=1;this.hasPointBatchTop=!0;this.hasQuadBatchTop=!1}f[e++]=a;f[e++]=b;f[e++]=c;f[e++]=d;this.pointPtr=e};a.prototype.switchProgram=function(a){if(this.lastProgram!==a){if(!this.shaderPrograms[a]){if(0===this.lastProgram)return;a=0}var b=this.pushBatch();
b.type=9;this.lastProgram=b.startIndex=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.programUsesDest=function(a){a=this.shaderPrograms[a];return!(!a.locDestStart&&!a.locDestEnd)};a.prototype.programUsesCrossSampling=function(a){return this.shaderPrograms[a].crossSampling};a.prototype.programExtendsBox=function(a){a=this.shaderPrograms[a];return 0!==a.extendBoxHorizontal||0!==a.extendBoxVertical};a.prototype.getProgramBoxExtendHorizontal=function(a){return this.shaderPrograms[a].extendBoxHorizontal};
a.prototype.getProgramBoxExtendVertical=function(a){return this.shaderPrograms[a].extendBoxVertical};a.prototype.getProgramParameterType=function(a,b){return this.shaderPrograms[a].parameters[b][2]};a.prototype.programIsAnimated=function(a){return this.shaderPrograms[a].animated};a.prototype.setProgramParameters=function(a,b,c,d,e,f,q,p,r){var s=this.shaderPrograms[this.lastProgram];if(s.locPixelWidth||s.locPixelHeight||s.locSeconds||s.locSamplerBack||s.locDestStart||s.locDestEnd||s.locLayerScale||
r.length){s=this.pushBatch();s.type=10;s.mat4param?mat4.set(this.matMV,s.mat4param):s.mat4param=mat4.create();s.mat4param[0]=b;s.mat4param[1]=c;s.mat4param[2]=d;s.mat4param[3]=e;s.mat4param[4]=f;s.mat4param[5]=q;s.mat4param[6]=p;s.texParam=a;if(r.length)for(s.shaderParams.length=r.length,a=0,b=r.length;a<b;a++)s.shaderParams[a]=r[a];this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.clear=function(a,b,c,d){var e=this.pushBatch();e.type=7;e.startIndex=0;e.mat4param||(e.mat4param=mat4.create());
e.mat4param[0]=a;e.mat4param[1]=b;e.mat4param[2]=c;e.mat4param[3]=d;this.hasPointBatchTop=this.hasQuadBatchTop=!1};a.prototype.clearRect=function(a,b,c,d){var e=this.pushBatch();e.type=7;e.startIndex=1;e.mat4param||(e.mat4param=mat4.create());e.mat4param[0]=a;e.mat4param[1]=b;e.mat4param[2]=c;e.mat4param[3]=d;this.hasPointBatchTop=this.hasQuadBatchTop=!1};a.prototype.present=function(){this.endBatch();this.gl.flush()};var e=[],f={};a.prototype.loadTexture=function(a,b,c,k,m){b=!!b;c=!!c;var n=a.src+
","+b+","+c+(b?","+m:""),q=null;if("undefined"!==typeof a.src&&f.hasOwnProperty(n))return q=f[n],q.c2refcount++,q;this.endBatch();var p=this.gl,r=cr.isPOT(a.width)&&cr.isPOT(a.height),q=p.createTexture();p.bindTexture(p.TEXTURE_2D,q);p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);var s=p.RGBA,w=p.RGBA,x=p.UNSIGNED_BYTE;if(k)switch(k){case 1:w=s=p.RGB;break;case 2:x=p.UNSIGNED_SHORT_4_4_4_4;break;case 3:x=p.UNSIGNED_SHORT_5_5_5_1;break;case 4:w=s=p.RGB,x=p.UNSIGNED_SHORT_5_6_5}!r&&b?(k=document.createElement("canvas"),
k.width=d(a.width),k.height=d(a.height),k.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,k.width,k.height),p.texImage2D(p.TEXTURE_2D,0,s,w,x,k)):p.texImage2D(p.TEXTURE_2D,0,s,w,x,a);b?"repeat-x"===m?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.REPEAT),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE)):("repeat-y"===m?p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE):p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.REPEAT),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,
p.REPEAT)):(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE));c?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),r?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR_MIPMAP_LINEAR),p.generateMipmap(p.TEXTURE_2D)):p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR)):(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST));p.bindTexture(p.TEXTURE_2D,
null);this.lastTexture=null;q.c2width=a.width;q.c2height=a.height;q.c2refcount=1;q.c2texkey=n;e.push(q);return f[n]=q};a.prototype.createEmptyTexture=function(a,b,c,d){this.endBatch();var f=this.gl,n=f.createTexture();f.bindTexture(f.TEXTURE_2D,n);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,a,b,0,f.RGBA,d?f.UNSIGNED_SHORT_4_4_4_4:f.UNSIGNED_BYTE,null);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,
c?f.LINEAR:f.NEAREST);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,c?f.LINEAR:f.NEAREST);f.bindTexture(f.TEXTURE_2D,null);this.lastTexture=null;n.c2width=a;n.c2height=b;e.push(n);return n};a.prototype.videoToTexture=function(a,b,c){this.endBatch();var d=this.gl;d.bindTexture(d.TEXTURE_2D,b);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,c?d.UNSIGNED_SHORT_4_4_4_4:d.UNSIGNED_BYTE,a);d.bindTexture(d.TEXTURE_2D,null);this.lastTexture=null};a.prototype.deleteTexture=function(a){a&&("undefined"!==typeof a.c2refcount&&
1<a.c2refcount?a.c2refcount--:(this.endBatch(),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this.lastTexture=null,cr.arrayFindRemove(e,a),"undefined"!==typeof a.c2texkey&&delete f[a.c2texkey],this.gl.deleteTexture(a)))};a.prototype.estimateVRAM=function(){var a=8*this.width*this.height,b,c,d;b=0;for(c=e.length;b<c;b++)d=e[b],a+=4*d.c2width*d.c2height;return a};a.prototype.textureCount=function(){return e.length};a.prototype.setRenderingToTexture=function(a){if(a!==this.renderToTex){var b=this.pushBatch();
b.type=6;this.renderToTex=b.texParam=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};cr.GLWrap=a})();
(function(){function a(a){if(a&&(a.getContext||a.dc)&&!a.c2runtime){a.c2runtime=this;var b=this;this.isPhoneGap="undefined"!==typeof window.device&&("undefined"!==typeof window.device.cordova||"undefined"!==typeof window.device.phonegap);this.isDirectCanvas=!!a.dc;this.isAppMobi="undefined"!==typeof window.AppMobi||this.isDirectCanvas;if(this.isCocoonJs=!!window.c2cocoonjs)CocoonJS.App.onSuspended.addEventListener(function(){b.setSuspended(!0)}),CocoonJS.App.onActivated.addEventListener(function(){b.setSuspended(!1)});
this.isDomFree=this.isDirectCanvas||this.isCocoonJs;this.isTizen=/tizen/i.test(navigator.userAgent);this.isAndroid=/android/i.test(navigator.userAgent)&&!this.isTizen;this.isIE=/msie/i.test(navigator.userAgent)||/trident/i.test(navigator.userAgent);this.isiPhone=/iphone/i.test(navigator.userAgent)||/ipod/i.test(navigator.userAgent);this.isiPad=/ipad/i.test(navigator.userAgent);this.isiOS=this.isiPhone||this.isiPad;this.isChrome=/chrome/i.test(navigator.userAgent)||/chromium/i.test(navigator.userAgent);
this.isSafari=!this.isChrome&&/safari/i.test(navigator.userAgent);this.isWindows=/windows/i.test(navigator.userAgent);this.isNodeWebkit="undefined"!==typeof window.c2nodewebkit;this.isArcade="undefined"!==typeof window.is_scirra_arcade;this.isWindows8App=!("undefined"===typeof window.c2isWindows8||!window.c2isWindows8);this.isWindowsPhone8=!("undefined"===typeof window.c2isWindowsPhone8||!window.c2isWindowsPhone8);this.isBlackberry10=!("undefined"===typeof window.c2isBlackberry10||!window.c2isBlackberry10);
this.devicePixelRatio=1;this.isMobile=this.isPhoneGap||this.isAppMobi||this.isCocoonJs||this.isAndroid||this.isiOS||this.isWindowsPhone8||this.isBlackberry10||this.isTizen;this.isMobile||(this.isMobile=/(blackberry|bb10|playbook|palm|symbian|nokia|windows\s+ce|phone|mobile|tablet)/i.test(navigator.userAgent));"undefined"===typeof cr_is_preview||this.isNodeWebkit||"?nw"!==window.location.search&&!/nodewebkit/i.test(navigator.userAgent)||(this.isNodeWebkit=!0);this.isDebug="undefined"!==typeof cr_is_preview&&
-1<window.location.search.indexOf("debug");this.canvas=a;this.canvasdiv=document.getElementById("c2canvasdiv");this.ctx=this.glwrap=this.gl=null;this.canvas.oncontextmenu=function(a){a.preventDefault&&a.preventDefault();return!1};this.canvas.onselectstart=function(a){a.preventDefault&&a.preventDefault();return!1};this.isDirectCanvas&&(window.c2runtime=this);this.isNodeWebkit&&(window.ondragover=function(a){a.preventDefault();return!1},window.ondrop=function(a){a.preventDefault();return!1});this.width=
a.width;this.height=a.height;this.lastwidth=this.width;this.lastheight=this.height;this.redraw=!0;this.isSuspended=!1;Date.now||(Date.now=function(){return+new Date});this.plugins=[];this.types={};this.types_by_index=[];this.behaviors=[];this.layouts={};this.layouts_by_index=[];this.eventsheets={};this.eventsheets_by_index=[];this.wait_for_textures=[];this.triggers_to_postinit=[];this.all_global_vars=[];this.all_local_vars=[];this.deathRow=new cr.ObjectSet;this.isInClearDeathRow=!1;this.isInOnDestroy=
0;this.isRunningEvents=!1;this.createRow=[];this.isLoadingState=!1;this.lastSaveJson=this.loadFromJson=this.loadFromSlot=this.saveToSlot="";this.suspendDrawing=this.signalledContinuousPreview=!1;this.zeroDtCount=this.cpuutilisation=this.logictime=this.dt1=this.dt=0;this.timescale=1;this.kahanTime=new cr.KahanAdder;this.last_tick_time=0;this.measuring_dt=!0;this.objectcount=this.framecount=this.execcount=this.tickcount=this.last_fps_time=this.fps=0;this.changelayout=null;this.destroycallbacks=[];this.event_stack=
[];this.event_stack_index=-1;this.localvar_stack=[[]];this.trigger_depth=this.localvar_stack_index=0;this.pushEventStack(null);this.loop_stack=[];this.loop_stack_index=-1;this.next_puid=this.next_uid=0;this.layout_first_tick=!0;this.family_count=0;this.suspend_events=[];this.timeout_id=this.raf_id=0;this.isloading=!0;this.loadingprogress=0;this.isNodeFullscreen=!1;this.stackLocalCount=0;this.had_a_click=!1;this.objects_to_tick=new cr.ObjectSet;this.objects_to_tick2=new cr.ObjectSet;this.registered_collisions=
[];this.temp_poly=new cr.CollisionPoly([]);this.temp_poly2=new cr.CollisionPoly([]);this.allGroups=[];this.activeGroups={};this.cndsBySid={};this.actsBySid={};this.varsBySid={};this.blocksBySid={};this.layout_tex=this.layer_tex=this.layer_ctx=this.layer_canvas=this.running_layout=null;this.uses_background_blending=this.is_WebGL_context_lost=!1;this.fx_tex=[null,null];this.fullscreen_scaling=0;this.files_subfolder="";this.objectsByUid={};this.snapshotCanvas=this.loaderlogo=null;this.snapshotData="";
this.load();this.devicePixelRatio=(this.isRetina=!this.isDomFree&&this.useiOSRetina&&(this.isiOS||this.isTizen))?window.devicePixelRatio||1:1;this.ClearDeathRow();var c;"undefined"!==typeof jQuery&&0<this.fullscreen_mode&&this.setSize(jQuery(window).width(),jQuery(window).height());try{if(this.enableWebGL&&(this.isCocoonJs||!this.isDomFree)){c={depth:!1,antialias:!this.isMobile};var d=!0;if(this.isChrome&&this.isWindows){var e=document.createElement("canvas");"OES_texture_float,OES_standard_derivatives,WEBKIT_WEBGL_lose_context"===
(e.getContext("webgl",c)||e.getContext("experimental-webgl",c)).getSupportedExtensions().toString()&&(d=!1)}d&&(this.gl=a.getContext("webgl",c)||a.getContext("experimental-webgl",c))}}catch(f){}if(this.gl){this.isDomFree||(this.overlay_canvas=document.createElement("canvas"),jQuery(this.overlay_canvas).appendTo(this.canvas.parentNode),this.overlay_canvas.oncontextmenu=function(a){return!1},this.overlay_canvas.onselectstart=function(a){return!1},this.overlay_canvas.width=a.width,this.overlay_canvas.height=
a.height,this.positionOverlayCanvas(),this.overlay_ctx=this.overlay_canvas.getContext("2d"));this.glwrap=new cr.GLWrap(this.gl,this.isMobile);this.glwrap.setSize(a.width,a.height);this.ctx=null;this.canvas.addEventListener("webglcontextlost",function(a){a.preventDefault();b.onContextLost();window.cr_setSuspended(!0)},!1);this.canvas.addEventListener("webglcontextrestored",function(a){b.glwrap.initState();b.glwrap.setSize(b.glwrap.width,b.glwrap.height,!0);b.layer_tex=null;b.layout_tex=null;b.fx_tex[0]=
null;b.fx_tex[1]=null;b.onContextRestored();b.redraw=!0;window.cr_setSuspended(!1)},!1);var g,h,k,m,p;a=0;for(c=this.types_by_index.length;a<c;a++)for(g=this.types_by_index[a],d=0,e=g.effect_types.length;d<e;d++)k=g.effect_types[d],k.shaderindex=this.glwrap.getShaderIndex(k.id),this.uses_background_blending=this.uses_background_blending||this.glwrap.programUsesDest(k.shaderindex);a=0;for(c=this.layouts_by_index.length;a<c;a++){m=this.layouts_by_index[a];d=0;for(e=m.effect_types.length;d<e;d++)k=m.effect_types[d],
k.shaderindex=this.glwrap.getShaderIndex(k.id);d=0;for(e=m.layers.length;d<e;d++)for(p=m.layers[d],g=0,h=p.effect_types.length;g<h;g++)k=p.effect_types[g],k.shaderindex=this.glwrap.getShaderIndex(k.id),this.uses_background_blending=this.uses_background_blending||this.glwrap.programUsesDest(k.shaderindex)}}else{if(0<this.fullscreen_mode&&this.isDirectCanvas){this.canvas=null;document.oncontextmenu=function(a){return!1};document.onselectstart=function(a){return!1};this.ctx=AppMobi.canvas.getContext("2d");
try{this.ctx.samplingMode=this.linearSampling?"smooth":"sharp",this.ctx.globalScale=1,this.ctx.HTML5CompatibilityMode=!0,this.ctx.imageSmoothingEnabled=this.linearSampling}catch(l){}0!==this.width&&0!==this.height&&(this.ctx.width=this.width,this.ctx.height=this.height)}this.ctx||(this.isCocoonJs?(c={antialias:!!this.linearSampling},this.ctx=a.getContext("2d",c)):this.ctx=a.getContext("2d"),this.ctx.webkitImageSmoothingEnabled=this.linearSampling,this.ctx.mozImageSmoothingEnabled=this.linearSampling,
this.ctx.msImageSmoothingEnabled=this.linearSampling,this.ctx.imageSmoothingEnabled=this.linearSampling);this.overlay_ctx=this.overlay_canvas=null}this.tickFunc=function(){b.tick()};window==window.top||this.isDomFree||this.isWindows8App||(document.addEventListener("mousedown",function(){window.focus()},!0),document.addEventListener("touchstart",function(){window.focus()},!0));"undefined"!==typeof cr_is_preview&&(this.isCocoonJs&&console.log("[Construct 2] In preview-over-wifi via CocoonJS mode"),
-1<window.location.search.indexOf("continuous")&&(cr.logexport("Reloading for continuous preview"),this.loadFromSlot="__c2_continuouspreview",this.suspendDrawing=!0),this.pauseOnBlur&&!this.isMobile&&(jQuery(window).focus(function(){b.setSuspended(!1)}),jQuery(window).blur(function(){b.setSuspended(!0)})));this.go();this.extra={};cr.seal(this)}}function b(a){a.target.result.createObjectStore("saves",{keyPath:"slot"})}function c(a,c,d,e){var f=indexedDB.open("_C2SaveStates");f.onupgradeneeded=b;f.onerror=
e;f.onsuccess=function(b){b=b.target.result;b.onerror=e;b.transaction(["saves"],"readwrite").objectStore("saves").put({slot:a,data:c}).onsuccess=d}}function d(a,c,d){var e=indexedDB.open("_C2SaveStates");e.onupgradeneeded=b;e.onerror=d;e.onsuccess=function(b){b=b.target.result;b.onerror=d;var e=b.transaction(["saves"]).objectStore("saves").get(a);e.onsuccess=function(a){e.result?c(e.result.data):c(null)}}}function e(){cr.logexport("Reloading for continuous preview");window.c2cocoonjs?CocoonJS.App.reload():
-1<window.location.search.indexOf("continuous")?window.location.reload(!0):window.location+="?continuous"}function f(a){var b,c={};for(b in a)!a.hasOwnProperty(b)||a[b]instanceof cr.ObjectSet||"undefined"===typeof a[b].c2userdata&&(c[b]=a[b]);return c}a.prototype.setSize=function(a,b){var c=this.hideAddressBar&&this.isiPhone&&!navigator.standalone&&!this.isDomFree&&!this.isPhoneGap,d=0;c&&(this.isiPhone?d=60:this.isAndroid&&(d=56),b+=d);var e=0,f=0,g=0,h=0,k=0,k=this.fullscreen_mode,m=document.mozFullScreen||
document.webkitIsFullScreen||!!document.msFullscreenElement||document.fullScreen||this.isNodeFullscreen;m&&0<this.fullscreen_scaling&&(k=this.fullscreen_scaling);4<=k?(g=this.original_width/this.original_height,a/b>g?(g*=b,5===k?(k=g/this.original_width,1<k?k=Math.floor(k):1>k&&(k=1/Math.ceil(1/k)),g=this.original_width*k,h=this.original_height*k,e=(a-g)/2,f=(b-h)/2,a=g,b=h):(e=(a-g)/2,a=g)):(h=a/g,5===k?(k=h/this.original_height,1<k?k=Math.floor(k):1>k&&(k=1/Math.ceil(1/k)),g=this.original_width*
k,h=this.original_height*k,e=(a-g)/2,f=(b-h)/2,a=g):f=(b-h)/2,b=h),m&&!this.isNodeWebkit&&(f=e=0),e=Math.floor(e),f=Math.floor(f),a=Math.floor(a),b=Math.floor(b)):this.isNodeWebkit&&this.isNodeFullscreen&&0===this.fullscreen_mode_set&&(e=Math.floor((a-this.original_width)/2),f=Math.floor((b-this.original_height)/2),a=this.original_width,b=this.original_height);this.isRetina&&this.isiPad&&1<this.devicePixelRatio&&(1024<=a&&(a=1023),1024<=b&&(b=1023));m=this.devicePixelRatio;this.width=a*m;this.height=
b*m;this.redraw=!0;this.canvasdiv&&!this.isDomFree&&(jQuery(this.canvasdiv).css({width:a+"px",height:b+"px","margin-left":e,"margin-top":f}),"undefined"!==typeof cr_is_preview&&jQuery("#borderwrap").css({width:a+"px",height:b+"px"}));this.canvas&&(this.canvas.width=a*m,this.canvas.height=b*m,this.isRetina&&jQuery(this.canvas).css({width:a+"px",height:b+"px"}));this.overlay_canvas&&(this.overlay_canvas.width=a,this.overlay_canvas.height=b);this.glwrap&&this.glwrap.setSize(a,b);this.isDirectCanvas&&
this.ctx&&(this.ctx.width=a,this.ctx.height=b);this.ctx&&(this.ctx.webkitImageSmoothingEnabled=this.linearSampling,this.ctx.mozImageSmoothingEnabled=this.linearSampling,this.ctx.msImageSmoothingEnabled=this.linearSampling,this.ctx.imageSmoothingEnabled=this.linearSampling);c&&0<d&&window.setTimeout(function(){window.scrollTo(0,1)},100)};a.prototype.onContextLost=function(){this.is_WebGL_context_lost=!0;var a,b,c;a=0;for(b=this.types_by_index.length;a<b;a++)if(c=this.types_by_index[a],c.onLostWebGLContext)c.onLostWebGLContext()};
a.prototype.onContextRestored=function(){this.is_WebGL_context_lost=!1;var a,b,c;a=0;for(b=this.types_by_index.length;a<b;a++)if(c=this.types_by_index[a],c.onRestoreWebGLContext)c.onRestoreWebGLContext()};a.prototype.positionOverlayCanvas=function(){if(!this.isDomFree){var a=document.mozFullScreen||document.webkitIsFullScreen||document.fullScreen||document.msFullscreenElement||this.isNodeFullscreen?jQuery(this.canvas).offset():jQuery(this.canvas).position();a.position="absolute";jQuery(this.overlay_canvas).css(a)}};
var g=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||window.oCancelAnimationFrame;a.prototype.setSuspended=function(a){var b;if(a&&!this.isSuspended)for(cr.logexport("[Construct 2] Suspending"),this.isSuspended=!0,0!==this.raf_id&&g&&g(this.raf_id),0!==this.timeout_id&&clearTimeout(this.timeout_id),a=0,b=this.suspend_events.length;a<b;a++)this.suspend_events[a](!0);else if(!a&&this.isSuspended){cr.logexport("[Construct 2] Resuming");
this.isSuspended=!1;this.last_tick_time=cr.performance_now();this.last_fps_time=cr.performance_now();a=this.logictime=this.framecount=0;for(b=this.suspend_events.length;a<b;a++)this.suspend_events[a](!1);this.tick()}};a.prototype.addSuspendCallback=function(a){this.suspend_events.push(a)};a.prototype.load=function(){var a=cr.getProjectModel();this.name=a[0];this.first_layout=a[1];this.fullscreen_mode=a[11];this.fullscreen_mode_set=a[11];this.isDomFree&&(4<=a[11]||0===a[11])&&(cr.logexport("[Construct 2] Letterbox scale fullscreen modes are not supported on this platform - falling back to 'Scale outer'"),
this.fullscreen_mode_set=this.fullscreen_mode=3);this.uses_loader_layout=a[17];this.loaderstyle=a[18];0===this.loaderstyle&&(this.loaderlogo=new Image,this.loaderlogo.src="loading-logo.png");this.next_uid=a[20];this.system=new cr.system_object(this);var b,c,d,e,f,g,h,k,m;b=0;for(c=a[2].length;b<c;b++){h=a[2][b];cr.add_common_aces(h);m=new h[0](this);m.singleglobal=h[1];m.is_world=h[2];m.must_predraw=h[9];if(m.onCreate)m.onCreate();cr.seal(m);this.plugins.push(m)}a=cr.getProjectModel();b=0;for(c=a[3].length;b<
c;b++){h=a[3][b];f=h[1];m=null;d=0;for(e=this.plugins.length;d<e;d++)if(this.plugins[d]instanceof f){m=this.plugins[d];break}var p=new m.Type(m);p.name=h[0];p.is_family=h[2];p.instvar_sids=h[3].slice(0);p.vars_count=h[3].length;p.behs_count=h[4];p.fx_count=h[5];p.sid=h[11];p.is_family?(p.members=[],p.family_index=this.family_count++,p.families=null):(p.members=null,p.family_index=-1,p.families=[]);p.family_var_map=null;p.family_beh_map=null;p.family_fx_map=null;p.is_contained=!1;p.container=null;
h[6]?(p.texture_file=h[6][0],p.texture_filesize=h[6][1],p.texture_pixelformat=h[6][2]):(p.texture_file=null,p.texture_filesize=0,p.texture_pixelformat=0);p.animations=h[7]?h[7]:null;p.index=b;p.instances=[];p.deadCache=[];p.solstack=[new cr.selection(p)];p.cur_sol=0;p.default_instance=null;p.stale_iids=!0;p.updateIIDs=cr.type_updateIIDs;p.getFirstPicked=cr.type_getFirstPicked;p.getPairedInstance=cr.type_getPairedInstance;p.getCurrentSol=cr.type_getCurrentSol;p.pushCleanSol=cr.type_pushCleanSol;p.pushCopySol=
cr.type_pushCopySol;p.popSol=cr.type_popSol;p.getBehaviorByName=cr.type_getBehaviorByName;p.getBehaviorIndexByName=cr.type_getBehaviorIndexByName;p.getEffectIndexByName=cr.type_getEffectIndexByName;p.applySolToContainer=cr.type_applySolToContainer;p.extra={};p.toString=cr.type_toString;p.behaviors=[];d=0;for(e=h[8].length;d<e;d++){k=h[8][d];var l=k[1],n=null;f=0;for(g=this.behaviors.length;f<g;f++)if(this.behaviors[f]instanceof l){n=this.behaviors[f];break}if(!n){n=new l(this);n.my_instances=new cr.ObjectSet;
if(n.onCreate)n.onCreate();cr.seal(n);this.behaviors.push(n)}f=new n.Type(n,p);f.name=k[0];f.sid=k[2];f.onCreate();cr.seal(f);p.behaviors.push(f)}p.global=h[9];p.isOnLoaderLayout=h[10];p.effect_types=[];d=0;for(e=h[12].length;d<e;d++)p.effect_types.push({id:h[12][d][0],name:h[12][d][1],shaderindex:-1,active:!0,index:d});if(!this.uses_loader_layout||p.is_family||p.isOnLoaderLayout||!m.is_world)p.onCreate(),cr.seal(p);p.name&&(this.types[p.name]=p);this.types_by_index.push(p);m.singleglobal&&(d=new m.Instance(p),
d.uid=this.next_uid++,d.puid=this.next_puid++,d.iid=0,d.get_iid=cr.inst_get_iid,d.toString=cr.inst_toString,d.properties=h[13],d.onCreate(),cr.seal(d),p.instances.push(d),this.objectsByUid[d.uid.toString()]=d)}b=0;for(c=a[4].length;b<c;b++)for(f=a[4][b],g=this.types_by_index[f[0]],d=1,e=f.length;d<e;d++)h=this.types_by_index[f[d]],h.families.push(g),g.members.push(h);b=0;for(c=a[22].length;b<c;b++){f=a[22][b];g=[];d=0;for(e=f.length;d<e;d++)g.push(this.types_by_index[f[d]]);d=0;for(e=g.length;d<e;d++)g[d].is_contained=
!0,g[d].container=g}if(0<this.family_count)for(b=0,c=this.types_by_index.length;b<c;b++)if(h=this.types_by_index[b],!h.is_family&&h.families.length){h.family_var_map=Array(this.family_count);h.family_beh_map=Array(this.family_count);h.family_fx_map=Array(this.family_count);p=[];d=n=l=k=0;for(e=h.families.length;d<e;d++)for(m=h.families[d],h.family_var_map[m.family_index]=k,k+=m.vars_count,h.family_beh_map[m.family_index]=l,l+=m.behs_count,h.family_fx_map[m.family_index]=n,n+=m.fx_count,f=0,g=m.effect_types.length;f<
g;f++)p.push(cr.shallowCopy({},m.effect_types[f]));h.effect_types=p.concat(h.effect_types);d=0;for(e=h.effect_types.length;d<e;d++)h.effect_types[d].index=d}b=0;for(c=a[5].length;b<c;b++)h=a[5][b],d=new cr.layout(this,h),cr.seal(d),this.layouts[d.name]=d,this.layouts_by_index.push(d);b=0;for(c=a[6].length;b<c;b++)h=a[6][b],d=new cr.eventsheet(this,h),cr.seal(d),this.eventsheets[d.name]=d,this.eventsheets_by_index.push(d);b=0;for(c=this.eventsheets_by_index.length;b<c;b++)this.eventsheets_by_index[b].postInit();
b=0;for(c=this.triggers_to_postinit.length;b<c;b++)this.triggers_to_postinit[b].postInit();this.triggers_to_postinit.length=0;this.files_subfolder=a[7];this.pixel_rounding=a[8];this.original_width=a[9];this.original_height=a[10];this.aspect_scale=1;this.enableWebGL=a[12];this.linearSampling=a[13];this.clearBackground=a[14];this.versionstr=a[15];b=a[16];2===b&&(b=this.isiPhone?1:0);this.useiOSRetina=0!==b;this.hideAddressBar=a[19];this.pauseOnBlur=a[21];this.start_time=Date.now()};a.prototype.findWaitingTexture=
function(a){var b,c;b=0;for(c=this.wait_for_textures.length;b<c;b++)if(this.wait_for_textures[b].cr_src===a)return this.wait_for_textures[b];return null};a.prototype.areAllTexturesLoaded=function(){var a=0,b=0,c=!0,d,e;d=0;for(e=this.wait_for_textures.length;d<e;d++){var f=this.wait_for_textures[d].cr_filesize;if(!f||0>=f)f=5E4;a+=f;this.wait_for_textures[d].complete||this.wait_for_textures[d].loaded?b+=f:c=!1}this.progress=0==a?0:b/a;return c};a.prototype.go=function(){if(this.ctx||this.glwrap){var a=
this.ctx||this.overlay_ctx;this.overlay_canvas&&this.positionOverlayCanvas();this.progress=0;this.last_progress=-1;if(this.areAllTexturesLoaded())this.go_textures_done();else{var b=Date.now()-this.start_time,c=1;this.isTizen&&(c=this.devicePixelRatio);if(a){if(3!==this.loaderstyle&&500<=b&&this.last_progress!=this.progress){a.clearRect(0,0,this.width,this.height);var b=this.width/(2*c),c=this.height/(2*c),d=0===this.loaderstyle&&this.loaderlogo.complete,e=40,f=0,g=80;d&&(g=this.loaderlogo.width,e=
g/2,f=this.loaderlogo.height/2,a.drawImage(this.loaderlogo,cr.floor(b-e),cr.floor(c-f)));1>=this.loaderstyle?(c+=f+(d?12:0),b=cr.floor(b-e)+0.5,c=cr.floor(c)+0.5,a.fillStyle="DodgerBlue",a.fillRect(b,c,Math.floor(g*this.progress),6),a.strokeStyle="black",a.strokeRect(b,c,g,6),a.strokeStyle="white",a.strokeRect(b-1,c-1,g+2,8)):2===this.loaderstyle&&(a.font="12pt Arial",a.fillStyle="#999",a.textBaseLine="middle",d=Math.round(100*this.progress)+"%",e=a.measureText?a.measureText(d):null,a.fillText(d,
b-(e?e.width:0)/2,c))}this.last_progress=this.progress}setTimeout(function(a){return function(){a.go()}}(this),100)}}};a.prototype.go_textures_done=function(){this.overlay_canvas&&(this.canvas.parentNode.removeChild(this.overlay_canvas),this.overlay_canvas=this.overlay_ctx=null);this.start_time=Date.now();this.last_fps_time=cr.performance_now();var a,b,c;if(this.uses_loader_layout)for(a=0,b=this.types_by_index.length;a<b;a++)c=this.types_by_index[a],c.is_family||c.isOnLoaderLayout||!c.plugin.is_world||
(c.onCreate(),cr.seal(c));else this.isloading=!1;a=0;for(b=this.layouts_by_index.length;a<b;a++)this.layouts_by_index[a].createGlobalNonWorlds();2<=this.fullscreen_mode&&(a=this.original_width/this.original_height,b=this.width/this.height,this.aspect_scale=2!==this.fullscreen_mode&&b>a||2===this.fullscreen_mode&&b<a?this.height/this.original_height:this.width/this.original_width);this.first_layout?this.layouts[this.first_layout].startRunning():this.layouts_by_index[0].startRunning();this.uses_loader_layout||
(this.loadingprogress=1,this.trigger(cr.system_object.prototype.cnds.OnLoadFinished,null));this.tick();this.isDirectCanvas&&AppMobi.webview.execute("onGameReady();")};var h=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame;a.prototype.tick=function(){if(this.running_layout){var a=cr.performance_now();if(!this.isDomFree&&window!=window.top){var b=this.fullscreen_mode;(document.mozFullScreen||
document.webkitIsFullScreen||document.fullScreen||document.msFullscreenElement||this.isNodeFullscreen)&&0<this.fullscreen_scaling&&(b=this.fullscreen_scaling);if(0<b){var b=window.innerWidth,c=window.innerHeight;if(this.lastwidth!==b||this.lastheight!==c)this.lastwidth=b,this.lastheight=c,this.setSize(b,c)}}this.isloading&&(b=this.areAllTexturesLoaded(),this.loadingprogress=this.progress,b&&(this.isloading=!1,this.progress=1,this.trigger(cr.system_object.prototype.cnds.OnLoadFinished,null)));this.logic();
!this.redraw&&!this.isCocoonJs||this.is_WebGL_context_lost||this.suspendDrawing||(this.redraw=!1,this.glwrap?this.drawGL():this.draw(),this.snapshotCanvas&&(this.canvas&&this.canvas.toDataURL&&(this.snapshotData=this.canvas.toDataURL(this.snapshotCanvas[0],this.snapshotCanvas[1]),this.trigger(cr.system_object.prototype.cnds.OnCanvasSnapshot,null)),this.snapshotCanvas=null));this.hit_breakpoint||(this.tickcount++,this.execcount++,this.framecount++);this.logictime+=cr.performance_now()-a;this.isSuspended||
(h?this.raf_id=h(this.tickFunc,this.canvas):this.timeout_id=setTimeout(this.tickFunc,this.isMobile?1:16))}};a.prototype.logic=function(){var a,b,c,d,e,f,g,h,k;a=cr.performance_now();1E3<=a-this.last_fps_time&&(this.last_fps_time+=1E3,this.fps=this.framecount,this.framecount=0,this.cpuutilisation=this.logictime,this.logictime=0);this.measuring_dt&&(0!==this.last_tick_time&&(b=a-this.last_tick_time,0!==b||this.isDebug?(this.dt1=b/1E3,0.5<this.dt1?this.dt1=0:0.1<this.dt1&&(this.dt1=0.1)):(this.zeroDtCount++,
10<=this.zeroDtCout&&(this.measuring_dt=!1),this.dt1=1/60)),this.last_tick_time=a);this.dt=this.dt1*this.timescale;this.kahanTime.add(this.dt);a=document.mozFullScreen||document.webkitIsFullScreen||document.fullScreen||!!document.msFullscreenElement||this.isNodeFullscreen;2<=this.fullscreen_mode||a&&0<this.fullscreen_scaling?(b=this.original_width/this.original_height,c=this.width/this.height,d=this.fullscreen_mode,a&&0<this.fullscreen_scaling&&(d=this.fullscreen_scaling),this.aspect_scale=2!==d&&
c>b||2===d&&c<b?this.height/this.original_height:this.width/this.original_width,this.running_layout&&(this.running_layout.scrollToX(this.running_layout.scrollX),this.running_layout.scrollToY(this.running_layout.scrollY))):this.aspect_scale=1;this.ClearDeathRow();this.isInOnDestroy++;this.system.runWaits();this.isInOnDestroy--;this.ClearDeathRow();this.isInOnDestroy++;a=0;for(b=this.types_by_index.length;a<b;a++)if(g=this.types_by_index[a],!g.is_family&&(g.behaviors.length||g.families.length))for(c=
0,d=g.instances.length;c<d;c++)for(h=g.instances[c],e=0,f=h.behavior_insts.length;e<f;e++)h.behavior_insts[e].tick();a=0;for(b=this.types_by_index.length;a<b;a++)if(g=this.types_by_index[a],!g.is_family&&(g.behaviors.length||g.families.length))for(c=0,d=g.instances.length;c<d;c++)for(h=g.instances[c],e=0,f=h.behavior_insts.length;e<f;e++)k=h.behavior_insts[e],k.posttick&&k.posttick();c=this.objects_to_tick.valuesRef();a=0;for(b=c.length;a<b;a++)c[a].tick();this.isInOnDestroy--;this.handleSaveLoad();
for(a=0;this.changelayout&&10>a++;)this.doChangeLayout(this.changelayout);a=0;for(b=this.eventsheets_by_index.length;a<b;a++)this.eventsheets_by_index[a].hasRun=!1;this.running_layout.event_sheet&&this.running_layout.event_sheet.run();this.registered_collisions.length=0;this.layout_first_tick=!1;this.isInOnDestroy++;a=0;for(b=this.types_by_index.length;a<b;a++)if(g=this.types_by_index[a],!g.is_family&&(g.behaviors.length||g.families.length))for(c=0,d=g.instances.length;c<d;c++)for(h=g.instances[c],
e=0,f=h.behavior_insts.length;e<f;e++)k=h.behavior_insts[e],k.tick2&&k.tick2();c=this.objects_to_tick2.valuesRef();a=0;for(b=c.length;a<b;a++)c[a].tick2();this.isInOnDestroy--};a.prototype.doChangeLayout=function(a){var b=this.running_layout;this.running_layout.stopRunning();var c,d,e,f,g,h,k;if(this.glwrap)for(c=0,d=this.types_by_index.length;c<d;c++)g=this.types_by_index[c],g.is_family||!g.unloadTextures||g.global&&0!==g.instances.length||-1!==a.initial_types.indexOf(g)||g.unloadTextures();b==a&&
(this.system.waits.length=0);a.startRunning();c=0;for(d=this.types_by_index.length;c<d;c++)if(g=this.types_by_index[c],g.global||g.plugin.singleglobal)for(a=0,b=g.instances.length;a<b;a++){h=g.instances[a];if(h.onLayoutChange)h.onLayoutChange();if(h.behavior_insts)for(e=0,f=h.behavior_insts.length;e<f;e++)if(k=h.behavior_insts[e],k.onLayoutChange)k.onLayoutChange()}this.layout_first_tick=this.redraw=!0;this.ClearDeathRow()};a.prototype.tickMe=function(a){this.objects_to_tick.add(a)};a.prototype.untickMe=
function(a){this.objects_to_tick.remove(a)};a.prototype.tick2Me=function(a){this.objects_to_tick2.add(a)};a.prototype.untick2Me=function(a){this.objects_to_tick2.remove(a)};a.prototype.getDt=function(a){return a&&-1!==a.my_timescale?this.dt1*a.my_timescale:this.dt};a.prototype.draw=function(){this.running_layout.draw(this.ctx);this.isDirectCanvas&&this.ctx.present()};a.prototype.drawGL=function(){this.running_layout.drawGL(this.glwrap);this.glwrap.present()};a.prototype.addDestroyCallback=function(a){a&&
this.destroycallbacks.push(a)};a.prototype.removeDestroyCallback=function(a){cr.arrayFindRemove(this.destroycallbacks,a)};a.prototype.getObjectByUID=function(a){return this.objectsByUid[a.toString()]};a.prototype.DestroyInstance=function(a){var b,c;if(!this.deathRow.contains(a)){this.deathRow.add(a);if(a.is_contained)for(b=0,c=a.siblings.length;b<c;b++)this.DestroyInstance(a.siblings[b]);this.isInClearDeathRow&&this.deathRow.values_cache.push(a);this.isInOnDestroy++;this.trigger(Object.getPrototypeOf(a.type.plugin).cnds.OnDestroyed,
a);this.isInOnDestroy--}};a.prototype.ClearDeathRow=function(){var a,b,c,d,e,f,g,h,k,m;this.isInClearDeathRow=!0;d=0;for(f=this.createRow.length;d<f;d++)for(a=this.createRow[d],b=a.type,b.instances.push(a),e=0,g=b.families.length;e<g;e++)b.families[e].instances.push(a),b.families[e].stale_iids=!0;this.createRow.length=0;f=this.deathRow.valuesRef();for(d=0;d<f.length;d++){a=f[d];b=a.type;c=b.instances;e=0;for(g=this.destroycallbacks.length;e<g;e++)this.destroycallbacks[e](a);cr.arrayFindRemove(c,a);
a.layer&&(cr.arrayRemove(a.layer.instances,a.get_zindex()),a.layer.zindices_stale=!0);e=0;for(g=b.families.length;e<g;e++)cr.arrayFindRemove(b.families[e].instances,a),b.families[e].stale_iids=!0;if(a.behavior_insts)for(e=0,g=a.behavior_insts.length;e<g;e++){c=a.behavior_insts[e];if(c.onDestroy)c.onDestroy();c.behavior.my_instances.remove(a)}this.objects_to_tick.remove(a);this.objects_to_tick2.remove(a);e=0;for(g=this.system.waits.length;e<g;e++)if(k=this.system.waits[e],k.sols.hasOwnProperty(b.index)&&
cr.arrayFindRemove(k.sols[b.index].insts,a),!b.is_family)for(c=0,h=b.families.length;c<h;c++)m=b.families[c],k.sols.hasOwnProperty(m.index)&&cr.arrayFindRemove(k.sols[m.index].insts,a);if(a.onDestroy)a.onDestroy();this.objectsByUid.hasOwnProperty(a.uid.toString())&&delete this.objectsByUid[a.uid.toString()];this.objectcount--;64>b.deadCache.length&&b.deadCache.push(a);b.stale_iids=!0}this.deathRow.isEmpty()||(this.redraw=!0);this.deathRow.clear();this.isInClearDeathRow=!1};a.prototype.createInstance=
function(a,b,c,d){if(a.is_family){var e=cr.floor(Math.random()*a.members.length);return this.createInstance(a.members[e],b,c,d)}return a.default_instance?this.createInstanceFromInit(a.default_instance,b,!1,c,d,!1):null};var l=[];a.prototype.createInstanceFromInit=function(a,b,c,d,e,f){var g,h,k,m;if(!a)return null;var p=this.types_by_index[a[1]],n=p.plugin.is_world;if(this.isloading&&n&&!p.isOnLoaderLayout||n&&!this.glwrap&&11===a[0][11])return null;var q=b;n||(b=null);var t;p.deadCache.length?(t=
p.deadCache.pop(),t.recycled=!0,p.plugin.Instance.call(t,p)):(t=new p.plugin.Instance(p),t.recycled=!1);t.uid=c&&!f?a[2]:this.next_uid++;this.objectsByUid[t.uid.toString()]=t;t.puid=this.next_puid++;t.iid=p.instances.length;g=0;for(h=this.createRow.length;g<h;++g)this.createRow[g].type===p&&t.iid++;t.get_iid=cr.inst_get_iid;k=a[3];if(t.recycled)cr.wipe(t.extra);else{t.extra={};if("undefined"!==typeof cr_is_preview)for(t.instance_var_names=[],t.instance_var_names.length=k.length,g=0,h=k.length;g<h;g++)t.instance_var_names[g]=
k[g][1];t.instance_vars=[];t.instance_vars.length=k.length}g=0;for(h=k.length;g<h;g++)t.instance_vars[g]=k[g][0];if(n){var y=a[0];t.x=cr.is_undefined(d)?y[0]:d;t.y=cr.is_undefined(e)?y[1]:e;t.z=y[2];t.width=y[3];t.height=y[4];t.depth=y[5];t.angle=y[6];t.opacity=y[7];t.hotspotX=y[8];t.hotspotY=y[9];t.blend_mode=y[10];g=y[11];!this.glwrap&&p.effect_types.length&&(t.blend_mode=g);t.compositeOp=cr.effectToCompositeOp(t.blend_mode);this.gl&&cr.setGLBlend(t,t.blend_mode,this.gl);if(t.recycled){g=0;for(h=
y[12].length;g<h;g++)for(k=0,m=y[12][g].length;k<m;k++)t.effect_params[g][k]=y[12][g][k];t.bbox.set(0,0,0,0);t.bquad.set_from_rect(t.bbox);t.bbox_changed_callbacks.length=0}else{t.effect_params=y[12].slice(0);g=0;for(h=t.effect_params.length;g<h;g++)t.effect_params[g]=y[12][g].slice(0);t.active_effect_types=[];t.active_effect_flags=[];t.active_effect_flags.length=p.effect_types.length;t.bbox=new cr.rect(0,0,0,0);t.bquad=new cr.quad;t.bbox_changed_callbacks=[];t.set_bbox_changed=cr.set_bbox_changed;
t.add_bbox_changed_callback=cr.add_bbox_changed_callback;t.contains_pt=cr.inst_contains_pt;t.update_bbox=cr.update_bbox;t.get_zindex=cr.inst_get_zindex}g=0;for(h=p.effect_types.length;g<h;g++)t.active_effect_flags[g]=!0;t.updateActiveEffects=cr.inst_updateActiveEffects;t.updateActiveEffects();t.uses_shaders=!!t.active_effect_types.length;t.bbox_changed=!0;t.visible=!0;t.my_timescale=-1;t.layer=b;t.zindex=b.instances.length;"undefined"===typeof t.collision_poly&&(t.collision_poly=null);this.redraw=
t.collisionsEnabled=!0}t.toString=cr.inst_toString;var K;g=l.length=0;for(h=p.families.length;g<h;g++)l.push.apply(l,p.families[g].behaviors);l.push.apply(l,p.behaviors);if(t.recycled)for(g=0,h=l.length;g<h;g++){var E=l[g];K=t.behavior_insts[g];K.recycled=!0;E.behavior.Instance.call(K,E,t);y=a[4][g];k=0;for(m=y.length;k<m;k++)K.properties[k]=y[k];K.onCreate();E.behavior.my_instances.add(t)}else for(t.behavior_insts=[],g=0,h=l.length;g<h;g++)E=l[g],K=new E.behavior.Instance(E,t),K.recycled=!1,K.properties=
a[4][g].slice(0),K.onCreate(),cr.seal(K),t.behavior_insts.push(K),E.behavior.my_instances.add(t);y=a[5];if(t.recycled)for(g=0,h=y.length;g<h;g++)t.properties[g]=y[g];else t.properties=y.slice(0);this.createRow.push(t);b&&b.instances.push(t);this.objectcount++;if(p.is_contained){if(t.is_contained=!0,t.recycled?t.siblings.length=0:t.siblings=[],!c&&!f){g=0;for(h=p.container.length;g<h;g++)if(p.container[g]!==p){if(!p.container[g].default_instance)return null;t.siblings.push(this.createInstanceFromInit(p.container[g].default_instance,
q,!1,n?t.x:d,n?t.y:e,!0))}g=0;for(h=t.siblings.length;g<h;g++)for(t.siblings[g].siblings.push(t),k=0;k<h;k++)g!==k&&t.siblings[g].siblings.push(t.siblings[k])}}else t.is_contained=!1,t.siblings=null;t.onCreate();t.recycled||cr.seal(t);g=0;for(h=t.behavior_insts.length;g<h;g++)t.behavior_insts[g].postCreate&&t.behavior_insts[g].postCreate();return t};a.prototype.getLayerByName=function(a){var b,c;b=0;for(c=this.running_layout.layers.length;b<c;b++){var d=this.running_layout.layers[b];if(cr.equals_nocase(d.name,
a))return d}return null};a.prototype.getLayerByNumber=function(a){a=cr.floor(a);0>a&&(a=0);a>=this.running_layout.layers.length&&(a=this.running_layout.layers.length-1);return this.running_layout.layers[a]};a.prototype.getLayer=function(a){return cr.is_number(a)?this.getLayerByNumber(a):this.getLayerByName(a.toString())};a.prototype.clearSol=function(a){var b,c;b=0;for(c=a.length;b<c;b++)a[b].getCurrentSol().select_all=!0};a.prototype.pushCleanSol=function(a){var b,c;b=0;for(c=a.length;b<c;b++)a[b].pushCleanSol()};
a.prototype.pushCopySol=function(a){var b,c;b=0;for(c=a.length;b<c;b++)a[b].pushCopySol()};a.prototype.popSol=function(a){var b,c;b=0;for(c=a.length;b<c;b++)a[b].popSol()};a.prototype.testAndSelectCanvasPointOverlap=function(a,b,c,d){var e=a.getCurrentSol(),f,g,h,k,p,m;if(e.select_all)for(d||(e.select_all=!1,e.instances.length=0),f=0,k=a.instances.length;f<k;f++){if(h=a.instances[f],h.update_bbox(),p=h.layer.canvasToLayer(b,c,!0),m=h.layer.canvasToLayer(b,c,!1),h.contains_pt(p,m)){if(d)return!1;e.instances.push(h)}}else{f=
g=0;for(k=e.instances.length;f<k;f++)if(h=e.instances[f],h.update_bbox(),p=h.layer.canvasToLayer(b,c,!0),m=h.layer.canvasToLayer(b,c,!1),h.contains_pt(p,m)){if(d)return!1;e.instances[g]=e.instances[f];g++}d||(e.instances.length=g)}a.applySolToContainer();return d?!0:e.hasObjects()};a.prototype.testOverlap=function(a,b){if(!(a&&b&&a!==b&&a.collisionsEnabled&&b.collisionsEnabled))return!1;a.update_bbox();b.update_bbox();var c=a.layer,d=b.layer,e,f,g,h,k,p;if(c===d||c.parallaxX===d.parallaxX&&d.parallaxY===
d.parallaxY&&c.scale===d.scale&&c.angle===d.angle&&c.zoomRate===d.zoomRate){if(!a.bbox.intersects_rect(b.bbox)||!a.bquad.intersects_quad(b.bquad))return!1;k=a.collision_poly&&!a.collision_poly.is_empty();e=b.collision_poly&&!b.collision_poly.is_empty();if(!k&&!e)return!0;k?(a.collision_poly.cache_poly(a.width,a.height,a.angle),k=a.collision_poly):(this.temp_poly.set_from_quad(a.bquad,a.x,a.y,a.width,a.height),k=this.temp_poly);e?(b.collision_poly.cache_poly(b.width,b.height,b.angle),p=b.collision_poly):
(this.temp_poly.set_from_quad(b.bquad,b.x,b.y,b.width,b.height),p=this.temp_poly);return k.intersects_poly(p,b.x-a.x,b.y-a.y)}k=a.collision_poly&&!a.collision_poly.is_empty();e=b.collision_poly&&!b.collision_poly.is_empty();k?(a.collision_poly.cache_poly(a.width,a.height,a.angle),this.temp_poly.set_from_poly(a.collision_poly)):this.temp_poly.set_from_quad(a.bquad,a.x,a.y,a.width,a.height);k=this.temp_poly;e?(b.collision_poly.cache_poly(b.width,b.height,b.angle),this.temp_poly2.set_from_poly(b.collision_poly)):
this.temp_poly2.set_from_quad(b.bquad,b.x,b.y,b.width,b.height);p=this.temp_poly2;e=0;for(f=k.pts_count;e<f;e++)g=k.pts_cache[2*e],h=k.pts_cache[2*e+1],k.pts_cache[2*e]=c.layerToCanvas(g+a.x,h+a.y,!0),k.pts_cache[2*e+1]=c.layerToCanvas(g+a.x,h+a.y,!1);e=0;for(f=p.pts_count;e<f;e++)g=p.pts_cache[2*e],h=p.pts_cache[2*e+1],p.pts_cache[2*e]=d.layerToCanvas(g+b.x,h+b.y,!0),p.pts_cache[2*e+1]=d.layerToCanvas(g+b.x,h+b.y,!1);return k.intersects_poly(p,0,0)};var k=new cr.quad,m=new cr.rect(0,0,0,0);a.prototype.testRectOverlap=
function(a,b){if(!b||!b.collisionsEnabled)return!1;b.update_bbox();if(!b.bbox.intersects_rect(a))return!1;k.set_from_rect(a);if(!b.bquad.intersects_quad(k))return!1;if(!b.collision_poly||b.collision_poly.is_empty())return!0;b.collision_poly.cache_poly(b.width,b.height,b.angle);k.offset(-a.left,-a.top);this.temp_poly.set_from_quad(k,0,0,1,1);return b.collision_poly.intersects_poly(this.temp_poly,a.left-b.x,a.top-b.y)};a.prototype.testSegmentOverlap=function(a,b,c,d,e){if(!e||!e.collisionsEnabled)return!1;
e.update_bbox();m.set(cr.min(a,c),cr.min(b,d),cr.max(a,c),cr.max(b,d));if(!e.bbox.intersects_rect(m)||!e.bquad.intersects_segment(a,b,c,d))return!1;if(!e.collision_poly||e.collision_poly.is_empty())return!0;e.collision_poly.cache_poly(e.width,e.height,e.angle);return e.collision_poly.intersects_segment(e.x,e.y,a,b,c,d)};a.prototype.typeHasBehavior=function(a,b){if(!b)return!1;var c,d,e,f,g;c=0;for(d=a.behaviors.length;c<d;c++)if(a.behaviors[c].behavior instanceof b)return!0;if(!a.is_family)for(c=
0,d=a.families.length;c<d;c++)for(g=a.families[c],e=0,f=g.behaviors.length;e<f;e++)if(g.behaviors[e].behavior instanceof b)return!0;return!1};a.prototype.typeHasNoSaveBehavior=function(a){return this.typeHasBehavior(a,cr.behaviors.NoSave)};a.prototype.typeHasPersistBehavior=function(a){return this.typeHasBehavior(a,cr.behaviors.Persist)};a.prototype.getSolidBehavior=function(){if(!cr.behaviors.solid)return null;var a,b;a=0;for(b=this.behaviors.length;a<b;a++)if(this.behaviors[a]instanceof cr.behaviors.solid)return this.behaviors[a];
return null};a.prototype.testOverlapSolid=function(a){var b=this.getSolidBehavior();if(!b)return null;var c,d,e=b.my_instances.valuesRef(),b=0;for(c=e.length;b<c;++b)if(d=e[b],d.extra.solidEnabled&&this.testOverlap(a,d))return d;return null};a.prototype.testRectOverlapSolid=function(a){var b=this.getSolidBehavior();if(!b)return null;var c,d,e=b.my_instances.valuesRef(),b=0;for(c=e.length;b<c;++b)if(d=e[b],d.extra.solidEnabled&&this.testRectOverlap(a,d))return d;return null};var n=[];a.prototype.testOverlapJumpThru=
function(a,b){var c=null,d,e;if(!cr.behaviors.jumpthru)return null;d=0;for(e=this.behaviors.length;d<e;d++)if(this.behaviors[d]instanceof cr.behaviors.jumpthru){c=this.behaviors[d];break}if(!c)return null;var f=null;b&&(f=n,f.length=0);var g=c.my_instances.valuesRef();d=0;for(e=g.length;d<e;++d)if(c=g[d],c.extra.jumpthruEnabled&&this.testOverlap(a,c))if(b)f.push(c);else return c;return f};a.prototype.pushOutSolid=function(a,b,c,d,e,f){d=d||50;var g=a.x,h=a.y,k,p=null,m=null;for(k=0;k<d;k++)if(a.x=
g+b*k,a.y=h+c*k,a.set_bbox_changed(),!this.testOverlap(a,p)&&((p=this.testOverlapSolid(a))&&(m=p),!p&&(e&&(p=f?this.testOverlap(a,f)?f:null:this.testOverlapJumpThru(a))&&(m=p),!p)))return m&&this.pushInFractional(a,b,c,m,16),!0;a.x=g;a.y=h;a.set_bbox_changed();return!1};a.prototype.pushOut=function(a,b,c,d,e){d=d||50;var f=a.x,g=a.y,h;for(h=0;h<d;h++)if(a.x=f+b*h,a.y=g+c*h,a.set_bbox_changed(),!this.testOverlap(a,e))return!0;a.x=f;a.y=g;a.set_bbox_changed();return!1};a.prototype.pushInFractional=
function(a,b,c,d,e){var f=2,g,h=!1;g=!1;for(var k=a.x,p=a.y;f<=e;)g=1/f,f*=2,a.x+=b*g*(h?1:-1),a.y+=c*g*(h?1:-1),a.set_bbox_changed(),this.testOverlap(a,d)?g=h=!0:(g=h=!1,k=a.x,p=a.y);g&&(a.x=k,a.y=p,a.set_bbox_changed())};a.prototype.pushOutSolidNearest=function(a,b){var c=cr.is_undefined(b)?100:b,d=0,e=a.x,f=a.y,g=0,h=0,k=0,p=this.testOverlapSolid(a);if(!p)return!0;for(;d<=c;){switch(g){case 0:h=0;k=-1;d++;break;case 1:h=1;k=-1;break;case 2:h=1;k=0;break;case 3:k=h=1;break;case 4:h=0;k=1;break;
case 5:h=-1;k=1;break;case 6:h=-1;k=0;break;case 7:k=h=-1}g=(g+1)%8;a.x=cr.floor(e+h*d);a.y=cr.floor(f+k*d);a.set_bbox_changed();if(!this.testOverlap(a,p)&&(p=this.testOverlapSolid(a),!p))return!0}a.x=e;a.y=f;a.set_bbox_changed();return!1};a.prototype.registerCollision=function(a,b){a.collisionsEnabled&&b.collisionsEnabled&&this.registered_collisions.push([a,b])};a.prototype.checkRegisteredCollision=function(a,b){var c,d,e;c=0;for(d=this.registered_collisions.length;c<d;c++)if(e=this.registered_collisions[c],
e[0]==a&&e[1]==b||e[0]==b&&e[1]==a)return!0;return!1};a.prototype.calculateSolidBounceAngle=function(a,b,c,d){var e=a.x,f=a.y,g=cr.max(10,cr.distanceTo(b,c,e,f)),h=cr.angleTo(b,c,e,f),k=d||this.testOverlapSolid(a);if(!k)return cr.clamp_angle(h+cr.PI);var p=k,m,l,n,q,y=cr.to_radians(5);for(m=1;36>m;m++)if(l=h-m*y,a.x=b+Math.cos(l)*g,a.y=c+Math.sin(l)*g,a.set_bbox_changed(),!this.testOverlap(a,p)&&(p=d?null:this.testOverlapSolid(a),!p)){n=l;break}36===m&&(n=cr.clamp_angle(h+cr.PI));p=k;for(m=1;36>m;m++)if(l=
h+m*y,a.x=b+Math.cos(l)*g,a.y=c+Math.sin(l)*g,a.set_bbox_changed(),!this.testOverlap(a,p)&&(p=d?null:this.testOverlapSolid(a),!p)){q=l;break}36===m&&(q=cr.clamp_angle(h+cr.PI));a.x=e;a.y=f;a.set_bbox_changed();if(q===n)return q;a=cr.angleDiff(q,n)/2;a=cr.angleClockwise(q,n)?cr.clamp_angle(n+a+cr.PI):cr.clamp_angle(q+a);n=Math.cos(h);h=Math.sin(h);q=Math.cos(a);a=Math.sin(a);b=n*q+h*a;return cr.angleTo(0,0,n-2*b*q,h-2*b*a)};var q=[],p=-1;a.prototype.trigger=function(a,b,c){if(!this.running_layout)return!1;
var d=this.running_layout.event_sheet;if(!d)return!1;p++;p===q.length?q.push(new cr.ObjectSet):q[p].clear();a=this.triggerOnSheet(a,b,d,c);p--;return a};a.prototype.triggerOnSheet=function(a,b,c,d){var e=q[p];if(e.contains(c))return!1;e.add(c);var e=c.includes.valuesRef(),f=!1,g,h,k;g=0;for(h=e.length;g<h;g++)e[g].isActive()&&(k=this.triggerOnSheet(a,b,e[g].include_sheet,d),f=f||k);if(b)for(k=this.triggerOnSheetForTypeName(a,b,b.type.name,c,d),f=f||k,g=0,h=b.type.families.length;g<h;g++)k=this.triggerOnSheetForTypeName(a,
b,b.type.families[g].name,c,d),f=f||k;else k=this.triggerOnSheetForTypeName(a,b,"system",c,d),f=f||k;return f};a.prototype.triggerOnSheetForTypeName=function(a,b,c,d,e){var f,g=!1,h=!1,h="undefined"!==typeof e,k=(h?d.fasttriggers:d.triggers)[c];if(!k)return g;var p=null;d=0;for(f=k.length;d<f;d++)if(k[d].method==a){p=k[d].evs;break}if(!p)return g;a=h?p[e]:p;if(!a)return null;d=0;for(f=a.length;d<f;d++)e=a[d][0],h=a[d][1],h=this.executeSingleTrigger(b,c,e,h),g=g||h;return g};a.prototype.executeSingleTrigger=
function(a,b,c,d){var e,f,g=!1;this.trigger_depth++;var h=this.getCurrentEventStack().current_event;h&&this.pushCleanSol(h.solModifiersIncludingParents);var k=1<this.trigger_depth;this.pushCleanSol(c.solModifiersIncludingParents);k&&this.pushLocalVarStack();var m=this.pushEventStack(c);m.current_event=c;a&&(e=this.types[b].getCurrentSol(),e.select_all=!1,e.instances.length=1,e.instances[0]=a,this.types[b].applySolToContainer());a=!0;if(c.parent){b=m.temp_parents_arr;for(e=c.parent;e;)b.push(e),e=
e.parent;b.reverse();e=0;for(f=b.length;e<f;e++)if(!b[e].run_pretrigger()){a=!1;break}}a&&(this.execcount++,c.orblock?c.run_orblocktrigger(d):c.run(),g=g||m.last_event_true);this.popEventStack();k&&this.popLocalVarStack();this.popSol(c.solModifiersIncludingParents);h&&this.popSol(h.solModifiersIncludingParents);0!==this.isInOnDestroy||0!==p||this.isRunningEvents||this.deathRow.isEmpty()&&!this.createRow.length||this.ClearDeathRow();this.trigger_depth--;return g};a.prototype.getCurrentCondition=function(){var a=
this.getCurrentEventStack();return a.current_event.conditions[a.cndindex]};a.prototype.getCurrentAction=function(){var a=this.getCurrentEventStack();return a.current_event.actions[a.actindex]};a.prototype.pushLocalVarStack=function(){this.localvar_stack_index++;this.localvar_stack_index>=this.localvar_stack.length&&this.localvar_stack.push([])};a.prototype.popLocalVarStack=function(){this.localvar_stack_index--};a.prototype.getCurrentLocalVarStack=function(){return this.localvar_stack[this.localvar_stack_index]};
a.prototype.pushEventStack=function(a){this.event_stack_index++;this.event_stack_index>=this.event_stack.length&&this.event_stack.push(new cr.eventStackFrame);var b=this.getCurrentEventStack();b.reset(a);return b};a.prototype.popEventStack=function(){this.event_stack_index--};a.prototype.getCurrentEventStack=function(){return this.event_stack[this.event_stack_index]};a.prototype.pushLoopStack=function(a){this.loop_stack_index++;this.loop_stack_index>=this.loop_stack.length&&this.loop_stack.push(cr.seal({name:a,
index:0,stopped:!1}));var b=this.getCurrentLoop();b.name=a;b.index=0;b.stopped=!1;return b};a.prototype.popLoopStack=function(){this.loop_stack_index--};a.prototype.getCurrentLoop=function(){return this.loop_stack[this.loop_stack_index]};a.prototype.getEventVariableByName=function(a,b){for(var c,d,e,f,g,h;b;){c=0;for(d=b.subevents.length;c<d;c++)if(h=b.subevents[c],h instanceof cr.eventvariable&&cr.equals_nocase(a,h.name))return h;b=b.parent}c=0;for(d=this.eventsheets_by_index.length;c<d;c++)for(g=
this.eventsheets_by_index[c],e=0,f=g.events.length;e<f;e++)if(h=g.events[e],h instanceof cr.eventvariable&&cr.equals_nocase(a,h.name))return h;return null};a.prototype.getLayoutBySid=function(a){var b,c;b=0;for(c=this.layouts_by_index.length;b<c;b++)if(this.layouts_by_index[b].sid===a)return this.layouts_by_index[b];return null};a.prototype.getObjectTypeBySid=function(a){var b,c;b=0;for(c=this.types_by_index.length;b<c;b++)if(this.types_by_index[b].sid===a)return this.types_by_index[b];return null};
a.prototype.getGroupBySid=function(a){var b,c;b=0;for(c=this.allGroups.length;b<c;b++)if(this.allGroups[b].sid===a)return this.allGroups[b];return null};a.prototype.signalContinuousPreview=function(){this.signalledContinuousPreview=!0};a.prototype.handleSaveLoad=function(){var a=this,b=this.saveToSlot,f=this.lastSaveJson,g=this.loadFromSlot,h=!1;this.signalledContinuousPreview&&(h=!0,b="__c2_continuouspreview",this.signalledContinuousPreview=!1);if(b.length){this.ClearDeathRow();f=this.saveToJSONString();
if(window.indexedDB&&!this.isCocoonJs)c(b,f,function(){cr.logexport("Saved state to IndexedDB storage ("+f.length+" bytes)");a.lastSaveJson=f;a.trigger(cr.system_object.prototype.cnds.OnSaveComplete,null);a.lastSaveJson="";h&&e()},function(c){try{localStorage.setItem("__c2save_"+b,f),cr.logexport("Saved state to WebStorage ("+f.length+" bytes)"),a.lastSaveJson=f,a.trigger(cr.system_object.prototype.cnds.OnSaveComplete,null),a.lastSaveJson="",h&&e()}catch(d){cr.logexport("Failed to save game state: "+
c+"; "+d)}});else try{localStorage.setItem("__c2save_"+b,f),cr.logexport("Saved state to WebStorage ("+f.length+" bytes)"),a.lastSaveJson=f,this.trigger(cr.system_object.prototype.cnds.OnSaveComplete,null),a.lastSaveJson="",h&&e()}catch(k){cr.logexport("Error saving to WebStorage: "+k)}this.loadFromJson=this.loadFromSlot=this.saveToSlot=""}g.length&&(window.indexedDB&&!this.isCocoonJs?d(g,function(b){b?(a.loadFromJson=b,cr.logexport("Loaded state from IndexedDB storage ("+a.loadFromJson.length+" bytes)")):
(a.loadFromJson=localStorage.getItem("__c2save_"+g)||"",cr.logexport("Loaded state from WebStorage ("+a.loadFromJson.length+" bytes)"));a.suspendDrawing=!1;a.loadFromJson.length||a.trigger(cr.system_object.prototype.cnds.OnLoadFailed,null)},function(b){a.loadFromJson=localStorage.getItem("__c2save_"+g)||"";cr.logexport("Loaded state from WebStorage ("+a.loadFromJson.length+" bytes)");a.suspendDrawing=!1;a.loadFromJson.length||a.trigger(cr.system_object.prototype.cnds.OnLoadFailed,null)}):(this.loadFromJson=
localStorage.getItem("__c2save_"+g)||"",cr.logexport("Loaded state from WebStorage ("+this.loadFromJson.length+" bytes)"),this.suspendDrawing=!1,a.loadFromJson.length||a.trigger(cr.system_object.prototype.cnds.OnLoadFailed,null)),this.saveToSlot=this.loadFromSlot="");this.loadFromJson.length&&(this.ClearDeathRow(),this.loadFromJSONString(this.loadFromJson),this.lastSaveJson=this.loadFromJson,this.trigger(cr.system_object.prototype.cnds.OnLoadComplete,null),this.loadFromJson=this.lastSaveJson="")};
a.prototype.saveToJSONString=function(){var a,b,c,d,e,g,h,k={c2save:!0,version:1,rt:{time:this.kahanTime.sum,timescale:this.timescale,tickcount:this.tickcount,execcount:this.execcount,next_uid:this.next_uid,running_layout:this.running_layout.sid,start_time_offset:Date.now()-this.start_time},types:{},layouts:{},events:{groups:{},cnds:{},acts:{},vars:{}}};a=0;for(b=this.types_by_index.length;a<b;a++)if(e=this.types_by_index[a],!e.is_family&&!this.typeHasNoSaveBehavior(e)){g={instances:[]};cr.hasAnyOwnProperty(e.extra)&&
(g.ex=f(e.extra));c=0;for(d=e.instances.length;c<d;c++)g.instances.push(this.saveInstanceToJSON(e.instances[c]));k.types[e.sid.toString()]=g}a=0;for(b=this.layouts_by_index.length;a<b;a++)c=this.layouts_by_index[a],k.layouts[c.sid.toString()]=c.saveToJSON();d=k.events.groups;a=0;for(b=this.allGroups.length;a<b;a++)c=this.allGroups[a],d[c.sid.toString()]=!!this.activeGroups[c.group_name];b=k.events.cnds;for(h in this.cndsBySid)this.cndsBySid.hasOwnProperty(h)&&(a=this.cndsBySid[h],cr.hasAnyOwnProperty(a.extra)&&
(b[h]={ex:f(a.extra)}));b=k.events.acts;for(h in this.actsBySid)this.actsBySid.hasOwnProperty(h)&&(a=this.actsBySid[h],cr.hasAnyOwnProperty(a.extra)&&(b[h]={ex:a.extra}));b=k.events.vars;for(h in this.varsBySid)this.varsBySid.hasOwnProperty(h)&&(a=this.varsBySid[h],a.is_constant||a.parent&&!a.is_static||(b[h]=a.data));k.system=this.system.saveToJSON();return JSON.stringify(k)};a.prototype.refreshUidMap=function(){var a,b,c,d,e,f;this.objectsByUid={};a=0;for(b=this.types_by_index.length;a<b;a++)if(c=
this.types_by_index[a],!c.is_family)for(d=0,e=c.instances.length;d<e;d++)f=c.instances[d],this.objectsByUid[f.uid.toString()]=f};a.prototype.loadFromJSONString=function(a){a=JSON.parse(a);if(a.c2save&&!(1<a.version)){var b=a.rt;this.kahanTime.reset();this.kahanTime.sum=b.time;this.timescale=b.timescale;this.tickcount=b.tickcount;this.execcount=b.execcount;this.start_time=Date.now()-b.start_time_offset;var c=b.running_layout;if(c!==this.running_layout.sid)if(c=this.getLayoutBySid(c))this.doChangeLayout(c);
else return;this.isLoadingState=!0;var d,e,f,g,h,k,p;k=a.types;for(e in k)if(k.hasOwnProperty(e)&&(g=this.getObjectTypeBySid(parseInt(e,10)))&&!g.is_family&&!this.typeHasNoSaveBehavior(g)){k[e].ex?g.extra=k[e].ex:cr.wipe(g.extra);h=g.instances;f=k[e].instances;c=0;for(d=cr.min(h.length,f.length);c<d;c++)this.loadInstanceFromJSON(h[c],f[c]);c=f.length;for(d=h.length;c<d;c++)this.DestroyInstance(h[c]);c=h.length;for(d=f.length;c<d;c++){h=null;if(g.plugin.is_world&&(h=this.running_layout.getLayerBySid(f[c].w.l),
!h))continue;h=this.createInstanceFromInit(g.default_instance,h,!1,0,0,!0);this.loadInstanceFromJSON(h,f[c])}g.stale_iids=!0}this.ClearDeathRow();this.refreshUidMap();d=a.layouts;for(e in d)d.hasOwnProperty(e)&&(c=this.getLayoutBySid(parseInt(e,10)))&&c.loadFromJSON(d[e]);d=a.events.groups;for(e in d)d.hasOwnProperty(e)&&(c=this.getGroupBySid(parseInt(e,10)))&&(this.activeGroups[c.group_name]=d[e]);c=a.events.cnds;for(e in c)c.hasOwnProperty(e)&&this.cndsBySid.hasOwnProperty(e)&&(this.cndsBySid[e].extra=
c[e].ex);c=a.events.acts;for(e in c)c.hasOwnProperty(e)&&this.actsBySid.hasOwnProperty(e)&&(this.actsBySid[e].extra=c[e].ex);c=a.events.vars;for(e in c)c.hasOwnProperty(e)&&this.varsBySid.hasOwnProperty(e)&&(this.varsBySid[e].data=c[e]);this.next_uid=b.next_uid;this.isLoadingState=!1;this.system.loadFromJSON(a.system);c=0;for(d=this.types_by_index.length;c<d;c++)if(g=this.types_by_index[c],!g.is_family)for(e=0,a=g.instances.length;e<a;e++){h=g.instances[e];if(g.is_contained)for(k=h.get_iid(),b=h.siblings.length=
0,f=g.container.length;b<f;b++)p=g.container[b],g!==p&&h.siblings.push(p.instances[k]);h.afterLoad&&h.afterLoad();if(h.behavior_insts)for(b=0,f=h.behavior_insts.length;b<f;b++)k=h.behavior_insts[b],k.afterLoad&&k.afterLoad()}this.redraw=!0}};a.prototype.saveInstanceToJSON=function(a){var b,c,d,e,g;e=a.type;d=e.plugin;var h={uid:a.uid};cr.hasAnyOwnProperty(a.extra)&&(h.ex=f(a.extra));if(a.instance_vars&&a.instance_vars.length)for(h.ivs={},b=0,c=a.instance_vars.length;b<c;b++)h.ivs[a.type.instvar_sids[b].toString()]=
a.instance_vars[b];if(d.is_world){d={x:a.x,y:a.y,w:a.width,h:a.height,l:a.layer.sid,zi:a.get_zindex()};0!==a.angle&&(d.a=a.angle);1!==a.opacity&&(d.o=a.opacity);0.5!==a.hotspotX&&(d.hX=a.hotspotX);0.5!==a.hotspotY&&(d.hY=a.hotspotY);0!==a.blend_mode&&(d.bm=a.blend_mode);a.visible||(d.v=a.visible);a.collisionsEnabled||(d.ce=a.collisionsEnabled);-1!==a.my_timescale&&(d.mts=a.my_timescale);if(e.effect_types.length)for(d.fx=[],b=0,c=e.effect_types.length;b<c;b++)g=e.effect_types[b],d.fx.push({name:g.name,
active:a.active_effect_flags[g.index],params:a.effect_params[g.index]});h.w=d}if(a.behavior_insts&&a.behavior_insts.length)for(h.behs={},b=0,c=a.behavior_insts.length;b<c;b++)e=a.behavior_insts[b],e.saveToJSON&&(h.behs[e.type.sid.toString()]=e.saveToJSON());a.saveToJSON&&(h.data=a.saveToJSON());return h};a.prototype.getInstanceVarIndexBySid=function(a,b){var c,d;c=0;for(d=a.instvar_sids.length;c<d;c++)if(a.instvar_sids[c]===b)return c;return-1};a.prototype.getBehaviorIndexBySid=function(a,b){var c,
d;c=0;for(d=a.behavior_insts.length;c<d;c++)if(a.behavior_insts[c].type.sid===b)return c;return-1};a.prototype.loadInstanceFromJSON=function(a,b){var c,d,e,f,g,h;h=a.type;e=h.plugin;a.uid=b.uid;b.ex?a.extra=b.ex:cr.wipe(a.extra);if(d=b.ivs)for(c in d)d.hasOwnProperty(c)&&(f=this.getInstanceVarIndexBySid(h,parseInt(c,10)),0>f||f>=a.instance_vars.length||(a.instance_vars[f]=d[c]));if(e.is_world){f=b.w;a.layer.sid!==f.l&&(d=a.layer,a.layer=this.running_layout.getLayerBySid(f.l),a.layer?(a.layer.instances.push(a),
a.layer.zindices_stale=!0,cr.arrayFindRemove(d.instances,a),d.zindices_stale=!0):(a.layer=d,this.DestroyInstance(a)));a.x=f.x;a.y=f.y;a.width=f.w;a.height=f.h;a.zindex=f.zi;a.angle=f.hasOwnProperty("a")?f.a:0;a.opacity=f.hasOwnProperty("o")?f.o:1;a.hotspotX=f.hasOwnProperty("hX")?f.hX:0.5;a.hotspotY=f.hasOwnProperty("hY")?f.hY:0.5;a.visible=f.hasOwnProperty("v")?f.v:!0;a.collisionsEnabled=f.hasOwnProperty("ce")?f.ce:!0;a.my_timescale=f.hasOwnProperty("mts")?f.mts:-1;a.blend_mode=f.hasOwnProperty("bm")?
f.bm:0;a.compositeOp=cr.effectToCompositeOp(a.blend_mode);this.gl&&cr.setGLBlend(a,a.blend_mode,this.gl);a.set_bbox_changed();if(f.hasOwnProperty("fx"))for(d=0,e=f.fx.length;d<e;d++)g=h.getEffectIndexByName(f.fx[d].name),0>g||(a.active_effect_flags[g]=f.fx[d].active,a.effect_params[g]=f.fx[d].params);a.updateActiveEffects()}if(h=b.behs)for(c in h)h.hasOwnProperty(c)&&(f=this.getBehaviorIndexBySid(a,parseInt(c,10)),0>f||a.behavior_insts[f].loadFromJSON(h[c]));b.data&&a.loadFromJSON(b.data)};cr.runtime=
a;cr.createRuntime=function(b){return new a(document.getElementById(b))};cr.createDCRuntime=function(b,c){return new a({dc:!0,width:b,height:c})};window.cr_createRuntime=cr.createRuntime;window.cr_createDCRuntime=cr.createDCRuntime;window.createCocoonJSRuntime=function(){window.c2cocoonjs=!0;var b=document.createElement("screencanvas")||document.createElement("canvas");document.body.appendChild(b);b=new a(b);window.c2runtime=b;window.addEventListener("orientationchange",function(){window.c2runtime.setSize(window.innerWidth,
window.innerHeight)});window.c2runtime.setSize(window.innerWidth,window.innerHeight);return b}})();window.cr_getC2Runtime=function(){var a=document.getElementById("c2canvas");return a?a.c2runtime:window.c2runtime?window.c2runtime:null};window.cr_sizeCanvas=function(a,b){if(0!==a&&0!==b){var c=window.cr_getC2Runtime();c&&c.setSize(a,b)}};window.cr_setSuspended=function(a){var b=window.cr_getC2Runtime();b&&b.setSuspended(a)};
(function(){function a(a,b){this.runtime=a;this.event_sheet=null;this.scrollX=this.runtime.original_width/2;this.scrollY=this.runtime.original_height/2;this.scale=1;this.angle=0;this.first_visit=!0;this.name=b[0];this.width=b[1];this.height=b[2];this.unbounded_scrolling=b[3];this.sheetname=b[4];this.sid=b[5];var c=b[6],d,l;this.layers=[];this.initial_types=[];d=0;for(l=c.length;d<l;d++){var k=new cr.layer(this,c[d]);k.number=d;cr.seal(k);this.layers.push(k)}c=b[7];this.initial_nonworld=[];d=0;for(l=
c.length;d<l;d++){var k=c[d],m=this.runtime.types_by_index[k[1]];m.default_instance||(m.default_instance=k);this.initial_nonworld.push(k);-1===this.initial_types.indexOf(m)&&this.initial_types.push(m)}this.effect_types=[];this.active_effect_types=[];this.effect_params=[];d=0;for(l=b[8].length;d<l;d++)this.effect_types.push({id:b[8][d][0],name:b[8][d][1],shaderindex:-1,active:!0,index:d}),this.effect_params.push(b[8][d][2].slice(0));this.updateActiveEffects();this.rcTex=new cr.rect(0,0,1,1);this.rcTex2=
new cr.rect(0,0,1,1);this.persist_data={}}function b(a,b){this.layout=a;this.runtime=a.runtime;this.instances=[];this.scale=1;this.angle=0;this.disableAngle=!1;this.tmprect=new cr.rect(0,0,0,0);this.tmpquad=new cr.quad;this.viewBottom=this.viewTop=this.viewRight=this.viewLeft=0;this.zindices_stale=!1;this.name=b[0];this.index=b[1];this.sid=b[2];this.visible=b[3];this.background_color=b[4];this.transparent=b[5];this.parallaxX=b[6];this.parallaxY=b[7];this.opacity=b[8];this.forceOwnTexture=b[9];this.zoomRate=
b[10];this.blend_mode=b[11];this.effect_fallback=b[12];this.compositeOp="source-over";this.destBlend=this.srcBlend=0;this.render_offscreen=!1;var c=b[13],d,l;this.initial_instances=[];d=0;for(l=c.length;d<l;d++){var k=c[d],m=this.runtime.types_by_index[k[1]];m.default_instance||(m.default_instance=k);this.initial_instances.push(k);-1===this.layout.initial_types.indexOf(m)&&this.layout.initial_types.push(m)}this.effect_types=[];this.active_effect_types=[];this.effect_params=[];d=0;for(l=b[14].length;d<
l;d++)this.effect_types.push({id:b[14][d][0],name:b[14][d][1],shaderindex:-1,active:!0,index:d}),this.effect_params.push(b[14][d][2].slice(0));this.updateActiveEffects();this.rcTex=new cr.rect(0,0,1,1);this.rcTex2=new cr.rect(0,0,1,1)}function c(a,b){return a.zindex-b.zindex}a.prototype.saveObjectToPersist=function(a){var b=a.type.sid.toString();this.persist_data.hasOwnProperty(b)||(this.persist_data[b]=[]);this.persist_data[b].push(this.runtime.saveInstanceToJSON(a))};a.prototype.hasOpaqueBottomLayer=
function(){var a=this.layers[0];return!a.transparent&&1===a.opacity&&!a.forceOwnTexture&&a.visible};a.prototype.updateActiveEffects=function(){this.active_effect_types.length=0;var a,b,c;a=0;for(b=this.effect_types.length;a<b;a++)c=this.effect_types[a],c.active&&this.active_effect_types.push(c)};a.prototype.getEffectByName=function(a){var b,c,d;b=0;for(c=this.effect_types.length;b<c;b++)if(d=this.effect_types[b],d.name===a)return d;return null};var d=[];a.prototype.startRunning=function(){this.sheetname&&
(this.event_sheet=this.runtime.eventsheets[this.sheetname]);this.runtime.running_layout=this;this.scrollX=this.runtime.original_width/2;this.scrollY=this.runtime.original_height/2;var a,b,g,h,l,k,m;a=0;for(g=this.runtime.types_by_index.length;a<g;a++)if(b=this.runtime.types_by_index[a],!b.is_family)for(l=b.instances,b=0,h=l.length;b<h;b++)if(k=l[b],k.layer){var n=k.layer.number;n>=this.layers.length&&(n=this.layers.length-1);k.layer=this.layers[n];k.layer.instances.push(k);k.layer.zindices_stale=
!0}d.length=0;this.boundScrolling();a=0;for(g=this.layers.length;a<g;a++)k=this.layers[a],k.createInitialInstances(),k.disableAngle=!0,b=k.canvasToLayer(0,0,!0),h=k.canvasToLayer(0,0,!1),k.disableAngle=!1,this.runtime.pixel_rounding&&(b=b+0.5|0,h=h+0.5|0),k.rotateViewport(b,h,null);l=!1;if(!this.first_visit){for(m in this.persist_data)if(this.persist_data.hasOwnProperty(m)&&(b=this.runtime.getObjectTypeBySid(parseInt(m,10)))&&!b.is_family&&this.runtime.typeHasPersistBehavior(b)){h=this.persist_data[m];
a=0;for(g=h.length;a<g;a++){k=null;if(b.plugin.is_world&&(k=this.getLayerBySid(h[a].w.l),!k))continue;k=this.runtime.createInstanceFromInit(b.default_instance,k,!1,0,0,!0);this.runtime.loadInstanceFromJSON(k,h[a]);l=!0;d.push(k)}h.length=0}a=0;for(g=this.layers.length;a<g;a++)this.layers[a].instances.sort(c),this.layers[a].zindices_stale=!0}l&&(this.runtime.ClearDeathRow(),this.runtime.refreshUidMap());for(a=0;a<d.length;a++)if(k=d[a],k.type.is_contained)for(g=k.get_iid(),b=0,h=k.type.container.length;b<
h;b++)m=k.type.container[b],k.type!==m&&(m.instances.length>g?k.siblings.push(m.instances[g]):m.default_instance&&(l=this.runtime.createInstanceFromInit(m.default_instance,k.layer,!0,k.x,k.y,!0),this.runtime.ClearDeathRow(),m.updateIIDs(),k.siblings.push(l),d.push(l)));a=0;for(g=this.initial_nonworld.length;a<g;a++)this.runtime.createInstanceFromInit(this.initial_nonworld[a],null,!0);this.runtime.changelayout=null;this.runtime.ClearDeathRow();if(this.runtime.ctx&&!this.runtime.isDomFree)for(a=0,g=
this.runtime.types_by_index.length;a<g;a++)m=this.runtime.types_by_index[a],!m.is_family&&m.instances.length&&m.preloadCanvas2D&&m.preloadCanvas2D(this.runtime.ctx);a=0;for(g=d.length;a<g;a++)k=d[a],this.runtime.trigger(Object.getPrototypeOf(k.type.plugin).cnds.OnCreated,k);d.length=0;this.runtime.trigger(cr.system_object.prototype.cnds.OnLayoutStart,null);this.first_visit=!1};a.prototype.createGlobalNonWorlds=function(){var a,b,c,d,l;b=a=0;for(c=this.initial_nonworld.length;a<c;a++)d=this.initial_nonworld[a],
l=this.runtime.types_by_index[d[1]],l.global?this.runtime.createInstanceFromInit(d,null,!0):(this.initial_nonworld[b]=d,b++);this.initial_nonworld.length=b};a.prototype.stopRunning=function(){this.runtime.trigger(cr.system_object.prototype.cnds.OnLayoutEnd,null);this.runtime.system.waits.length=0;var a,b,c,d,l,k;a=0;for(b=this.layers.length;a<b;a++){l=this.layers[a].instances;c=0;for(d=l.length;c<d;c++)k=l[c],k.type.global||(this.runtime.typeHasPersistBehavior(k.type)&&this.saveObjectToPersist(k),
this.runtime.DestroyInstance(k));this.runtime.ClearDeathRow();l.length=0;this.layers[a].zindices_stale=!0}a=0;for(b=this.runtime.types_by_index.length;a<b;a++)if(l=this.runtime.types_by_index[a],!(l.global||l.plugin.is_world||l.plugin.singleglobal||l.is_family)){c=0;for(d=l.instances.length;c<d;c++)this.runtime.DestroyInstance(l.instances[c]);this.runtime.ClearDeathRow()}};a.prototype.draw=function(a){a.globalAlpha=1;a.globalCompositeOperation="source-over";this.runtime.clearBackground&&!this.hasOpaqueBottomLayer()&&
a.clearRect(0,0,this.runtime.width,this.runtime.height);var b,c,d;b=0;for(c=this.layers.length;b<c;b++)d=this.layers[b],d.visible&&0<d.opacity&&11!==d.blend_mode&&d.draw(a)};a.prototype.drawGL=function(a){var b=0<this.active_effect_types.length||this.runtime.uses_background_blending;if(b){this.runtime.layout_tex||(this.runtime.layout_tex=a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling));if(this.runtime.layout_tex.c2width!==this.runtime.width||this.runtime.layout_tex.c2height!==
this.runtime.height)a.deleteTexture(this.runtime.layout_tex),this.runtime.layout_tex=a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling);a.setRenderingToTexture(this.runtime.layout_tex)}this.runtime.clearBackground&&!this.hasOpaqueBottomLayer()&&a.clear(0,0,0,0);var c,d;c=0;for(d=this.layers.length;c<d;c++)this.layers[c].visible&&0<this.layers[c].opacity&&this.layers[c].drawGL(a);b&&(1>=this.active_effect_types.length?(1===this.active_effect_types.length?(b=this.active_effect_types[0].index,
a.switchProgram(this.active_effect_types[0].shaderindex),a.setProgramParameters(null,1/this.runtime.width,1/this.runtime.height,0,0,1,1,this.scale,this.effect_params[b]),a.programIsAnimated(this.active_effect_types[0].shaderindex)&&(this.runtime.redraw=!0)):a.switchProgram(0),a.setRenderingToTexture(null),a.setOpacity(1),a.setTexture(this.runtime.layout_tex),a.setAlphaBlend(),a.resetModelView(),a.updateModelView(),b=this.runtime.width/2,c=this.runtime.height/2,a.quad(-b,c,b,c,b,-c,-b,-c),a.setTexture(null)):
this.renderEffectChain(a,null,null,null))};a.prototype.getRenderTarget=function(){return 0<this.active_effect_types.length||this.runtime.uses_background_blending?this.runtime.layout_tex:null};a.prototype.getMinLayerScale=function(){var a=this.layers[0].getScale(),b,c,d;b=1;for(c=this.layers.length;b<c;b++)d=this.layers[b],(0!==d.parallaxX||0!==d.parallaxY)&&d.getScale()<a&&(a=d.getScale());return a};a.prototype.scrollToX=function(a){if(!this.unbounded_scrolling){var b=this.runtime.width*(1/this.getMinLayerScale())/
2;a>this.width-b&&(a=this.width-b);a<b&&(a=b)}this.scrollX!==a&&(this.scrollX=a,this.runtime.redraw=!0)};a.prototype.scrollToY=function(a){if(!this.unbounded_scrolling){var b=this.runtime.height*(1/this.getMinLayerScale())/2;a>this.height-b&&(a=this.height-b);a<b&&(a=b)}this.scrollY!==a&&(this.scrollY=a,this.runtime.redraw=!0)};a.prototype.boundScrolling=function(){this.scrollToX(this.scrollX);this.scrollToY(this.scrollY)};a.prototype.renderEffectChain=function(a,b,c,d){var l=c?c.active_effect_types:
b?b.active_effect_types:this.active_effect_types,k=c?c.layer.getScale():b?b.getScale():1,m=this.runtime.fx_tex,n,q,p,r,s=0,w=1,x,C=this.runtime.width,F=this.runtime.height,I=C/2,D=F/2,v=b?b.rcTex:this.rcTex,u=b?b.rcTex2:this.rcTex2,z=0,A=0,B=0,t=0,y=C,K=C,E=F,N=F,H=p=0,S=c?c.layer.getAngle():0;if(c){n=0;for(q=l.length;n<q;n++)p+=a.getProgramBoxExtendHorizontal(l[n].shaderindex),H+=a.getProgramBoxExtendVertical(l[n].shaderindex);r=c.bbox;z=b.layerToCanvas(r.left,r.top,!0);B=b.layerToCanvas(r.left,
r.top,!1);y=b.layerToCanvas(r.right,r.bottom,!0);E=b.layerToCanvas(r.right,r.bottom,!1);0!==S&&(n=b.layerToCanvas(r.right,r.top,!0),q=b.layerToCanvas(r.right,r.top,!1),A=b.layerToCanvas(r.left,r.bottom,!0),t=b.layerToCanvas(r.left,r.bottom,!1),r=Math.min(z,y,n,A),y=Math.max(z,y,n,A),z=r,r=Math.min(B,E,q,t),E=Math.max(B,E,q,t),B=r);z-=p;B-=H;y+=p;E+=H;u.left=z/C;u.top=1-B/F;u.right=y/C;u.bottom=1-E/F;A=z=Math.floor(z);t=B=Math.floor(B);K=y=Math.ceil(y);N=E=Math.ceil(E);A-=p;t-=H;K+=p;N+=H;0>z&&(z=
0);0>B&&(B=0);y>C&&(y=C);E>F&&(E=F);0>A&&(A=0);0>t&&(t=0);K>C&&(K=C);N>F&&(N=F);v.left=z/C;v.top=1-B/F;v.right=y/C;v.bottom=1-E/F}else v.left=u.left=0,v.top=u.top=0,v.right=u.right=1,v.bottom=u.bottom=1;H=c&&((c.angle||S)&&a.programUsesDest(l[0].shaderindex)||0!==p||0!==H||1!==c.opacity||c.type.plugin.must_predraw)||b&&!c&&1!==b.opacity;a.setAlphaBlend();if(H){m[s]||(m[s]=a.createEmptyTexture(C,F,this.runtime.linearSampling));if(m[s].c2width!==C||m[s].c2height!==F)a.deleteTexture(m[s]),m[s]=a.createEmptyTexture(C,
F,this.runtime.linearSampling);a.switchProgram(0);a.setRenderingToTexture(m[s]);x=N-t;a.clearRect(A,F-t-x,K-A,x);c?c.drawGL(a):(a.setTexture(this.runtime.layer_tex),a.setOpacity(b.opacity),a.resetModelView(),a.translate(-I,-D),a.updateModelView(),a.quadTex(z,E,y,E,y,B,z,B,v));u.left=u.top=0;u.right=u.bottom=1;c&&(r=v.top,v.top=v.bottom,v.bottom=r);s=1;w=0}a.setOpacity(1);p=l.length-1;var S=a.programUsesCrossSampling(l[p].shaderindex),T=0;n=0;for(q=l.length;n<q;n++){m[s]||(m[s]=a.createEmptyTexture(C,
F,this.runtime.linearSampling));if(m[s].c2width!==C||m[s].c2height!==F)a.deleteTexture(m[s]),m[s]=a.createEmptyTexture(C,F,this.runtime.linearSampling);a.switchProgram(l[n].shaderindex);T=l[n].index;a.programIsAnimated(l[n].shaderindex)&&(this.runtime.redraw=!0);0!=n||H?(a.setProgramParameters(d,1/C,1/F,u.left,u.top,u.right,u.bottom,k,c?c.effect_params[T]:b?b.effect_params[T]:this.effect_params[T]),n!==p||S?(a.setRenderingToTexture(m[s]),x=N-t,r=F-t-x,a.clearRect(A,r,K-A,x)):(c?a.setBlend(c.srcBlend,
c.destBlend):b&&a.setBlend(b.srcBlend,b.destBlend),a.setRenderingToTexture(d)),a.setTexture(m[w]),a.resetModelView(),a.translate(-I,-D),a.updateModelView(),a.quadTex(z,E,y,E,y,B,z,B,v),n!==p||S||a.setTexture(null)):(a.setRenderingToTexture(m[s]),x=N-t,r=F-t-x,a.clearRect(A,r,K-A,x),c?(a.setProgramParameters(d,1/c.width,1/c.height,u.left,u.top,u.right,u.bottom,k,c.effect_params[T]),c.drawGL(a)):(a.setProgramParameters(d,1/C,1/F,0,0,1,1,k,b?b.effect_params[T]:this.effect_params[T]),a.setTexture(b?this.runtime.layer_tex:
this.runtime.layout_tex),a.resetModelView(),a.translate(-I,-D),a.updateModelView(),a.quadTex(z,E,y,E,y,B,z,B,v)),u.left=u.top=0,u.right=u.bottom=1,c&&!S&&(r=E,E=B,B=r));s=0===s?1:0;w=0===s?1:0}S&&(a.switchProgram(0),c?a.setBlend(c.srcBlend,c.destBlend):b&&a.setBlend(b.srcBlend,b.destBlend),a.setRenderingToTexture(d),a.setTexture(m[w]),a.resetModelView(),a.translate(-I,-D),a.updateModelView(),c&&1===l.length&&!H?a.quadTex(z,B,y,B,y,E,z,E,v):a.quadTex(z,E,y,E,y,B,z,B,v),a.setTexture(null))};a.prototype.getLayerBySid=
function(a){var b,c;b=0;for(c=this.layers.length;b<c;b++)if(this.layers[b].sid===a)return this.layers[b];return null};a.prototype.saveToJSON=function(){var a,b,c,d={sx:this.scrollX,sy:this.scrollY,s:this.scale,a:this.angle,w:this.width,h:this.height,fv:this.first_visit,persist:this.persist_data,fx:[],layers:{}};a=0;for(b=this.effect_types.length;a<b;a++)c=this.effect_types[a],d.fx.push({name:c.name,active:c.active,params:this.effect_params[c.index]});a=0;for(b=this.layers.length;a<b;a++)c=this.layers[a],
d.layers[c.sid.toString()]=c.saveToJSON();return d};a.prototype.loadFromJSON=function(a){var b,c,d,l;this.scrollX=a.sx;this.scrollY=a.sy;this.scale=a.s;this.angle=a.a;this.width=a.w;this.height=a.h;this.persist_data=a.persist;"undefined"!==typeof a.fv&&(this.first_visit=a.fv);var k=a.fx;b=0;for(c=k.length;b<c;b++)if(d=this.getEffectByName(k[b].name))d.active=k[b].active,this.effect_params[d.index]=k[b].params;this.updateActiveEffects();b=a.layers;for(l in b)b.hasOwnProperty(l)&&(a=this.getLayerBySid(parseInt(l,
10)))&&a.loadFromJSON(b[l])};cr.layout=a;b.prototype.updateActiveEffects=function(){this.active_effect_types.length=0;var a,b,c;a=0;for(b=this.effect_types.length;a<b;a++)c=this.effect_types[a],c.active&&this.active_effect_types.push(c)};b.prototype.getEffectByName=function(a){var b,c,d;b=0;for(c=this.effect_types.length;b<c;b++)if(d=this.effect_types[b],d.name===a)return d;return null};b.prototype.createInitialInstances=function(){var a,b,c,h,l,k;b=a=0;for(c=this.initial_instances.length;a<c;a++){h=
this.initial_instances[a];l=this.runtime.types_by_index[h[1]];k=this.runtime.typeHasPersistBehavior(l);l=!0;if(!k||this.layout.first_visit)h=this.runtime.createInstanceFromInit(h,this,!0),d.push(h),h.type.global&&(l=!1);l&&(this.initial_instances[b]=this.initial_instances[a],b++)}this.initial_instances.length=b;this.runtime.ClearDeathRow();!this.runtime.glwrap&&this.effect_types.length&&(this.blend_mode=this.effect_fallback);this.compositeOp=cr.effectToCompositeOp(this.blend_mode);this.runtime.gl&&
cr.setGLBlend(this,this.blend_mode,this.runtime.gl)};b.prototype.updateZIndices=function(){if(this.zindices_stale){var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].zindex=a;this.zindices_stale=!1}};b.prototype.getScale=function(){return this.getNormalScale()*this.runtime.aspect_scale};b.prototype.getNormalScale=function(){return(this.scale*this.layout.scale-1)*this.zoomRate+1};b.prototype.getAngle=function(){return this.disableAngle?0:cr.clamp_angle(this.layout.angle+this.angle)};
b.prototype.draw=function(a){this.render_offscreen=this.forceOwnTexture||1!==this.opacity||0!==this.blend_mode;var b=this.runtime.canvas,c=a;a.globalAlpha=1;a.globalCompositeOperation="source-over";this.render_offscreen&&(this.runtime.layer_canvas||(this.runtime.layer_canvas=document.createElement("canvas"),b=this.runtime.layer_canvas,b.width=this.runtime.width,b.height=this.runtime.height,this.runtime.layer_ctx=b.getContext("2d")),b=this.runtime.layer_canvas,c=this.runtime.layer_ctx,b.width!==this.runtime.width&&
(b.width=this.runtime.width),b.height!==this.runtime.height&&(b.height=this.runtime.height),this.transparent&&c.clearRect(0,0,this.runtime.width,this.runtime.height));this.transparent||(c.fillStyle="rgb("+this.background_color[0]+","+this.background_color[1]+","+this.background_color[2]+")",c.fillRect(0,0,this.runtime.width,this.runtime.height));c.save();this.disableAngle=!0;var d=this.canvasToLayer(0,0,!0),l=this.canvasToLayer(0,0,!1);this.disableAngle=!1;this.runtime.pixel_rounding&&(d=d+0.5|0,
l=l+0.5|0);this.rotateViewport(d,l,c);var k=this.getScale();c.scale(k,k);c.translate(-d,-l);for(var m,d=0,l=this.instances.length;d<l;d++)k=this.instances[d],k.visible&&0!==k.width&&0!==k.height&&(k.update_bbox(),m=k.bbox,m.right<this.viewLeft||m.bottom<this.viewTop||m.left>this.viewRight||m.top>this.viewBottom||(c.globalCompositeOperation=k.compositeOp,k.draw(c)));c.restore();this.render_offscreen&&(a.globalCompositeOperation=this.compositeOp,a.globalAlpha=this.opacity,a.drawImage(b,0,0))};b.prototype.rotateViewport=
function(a,b,c){var d=this.getScale();this.viewLeft=a;this.viewTop=b;this.viewRight=a+this.runtime.width*(1/d);this.viewBottom=b+this.runtime.height*(1/d);a=this.getAngle();0!==a&&(c&&(c.translate(this.runtime.width/2,this.runtime.height/2),c.rotate(-a),c.translate(this.runtime.width/-2,this.runtime.height/-2)),this.tmprect.set(this.viewLeft,this.viewTop,this.viewRight,this.viewBottom),this.tmprect.offset((this.viewLeft+this.viewRight)/-2,(this.viewTop+this.viewBottom)/-2),this.tmpquad.set_from_rotated_rect(this.tmprect,
a),this.tmpquad.bounding_box(this.tmprect),this.tmprect.offset((this.viewLeft+this.viewRight)/2,(this.viewTop+this.viewBottom)/2),this.viewLeft=this.tmprect.left,this.viewTop=this.tmprect.top,this.viewRight=this.tmprect.right,this.viewBottom=this.tmprect.bottom)};b.prototype.drawGL=function(a){var b=this.runtime.width,c=this.runtime.height,d=0,l=0;if(this.render_offscreen=this.forceOwnTexture||1!==this.opacity||0<this.active_effect_types.length||0!==this.blend_mode){this.runtime.layer_tex||(this.runtime.layer_tex=
a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling));if(this.runtime.layer_tex.c2width!==this.runtime.width||this.runtime.layer_tex.c2height!==this.runtime.height)a.deleteTexture(this.runtime.layer_tex),this.runtime.layer_tex=a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling);a.setRenderingToTexture(this.runtime.layer_tex);this.transparent&&a.clear(0,0,0,0)}this.transparent||a.clear(this.background_color[0]/255,this.background_color[1]/
255,this.background_color[2]/255,1);this.disableAngle=!0;var l=this.canvasToLayer(0,0,!0),k=this.canvasToLayer(0,0,!1);this.disableAngle=!1;this.runtime.pixel_rounding&&(l=l+0.5|0,k=k+0.5|0);this.rotateViewport(l,k,null);k=this.getScale();a.resetModelView();a.scale(k,k);a.rotateZ(-this.getAngle());a.translate((this.viewLeft+this.viewRight)/-2,(this.viewTop+this.viewBottom)/-2);a.updateModelView();var m,n,q;m=0;for(n=this.instances.length;m<n;m++)if(q=this.instances[m],q.visible&&0!==q.width&&0!==
q.height&&(q.update_bbox(),d=q.bbox,!(d.right<this.viewLeft||d.bottom<this.viewTop||d.left>this.viewRight||d.top>this.viewBottom)))if(q.uses_shaders)if(d=q.active_effect_types[0].shaderindex,l=q.active_effect_types[0].index,1!==q.active_effect_types.length||a.programUsesCrossSampling(d)||a.programExtendsBox(d)||(q.angle||q.layer.getAngle())&&a.programUsesDest(d)||1!==q.opacity||q.type.plugin.must_predraw)this.layout.renderEffectChain(a,this,q,this.render_offscreen?this.runtime.layer_tex:this.layout.getRenderTarget()),
a.resetModelView(),a.scale(k,k),a.rotateZ(-this.getAngle()),a.translate((this.viewLeft+this.viewRight)/-2,(this.viewTop+this.viewBottom)/-2),a.updateModelView();else{a.switchProgram(d);a.setBlend(q.srcBlend,q.destBlend);a.programIsAnimated(d)&&(this.runtime.redraw=!0);var p=0,r=0,s=0,w=0;a.programUsesDest(d)&&(d=q.bbox,p=this.layerToCanvas(d.left,d.top,!0),r=this.layerToCanvas(d.left,d.top,!1),s=this.layerToCanvas(d.right,d.bottom,!0),d=this.layerToCanvas(d.right,d.bottom,!1),p/=b,r=1-r/c,s/=b,w=
1-d/c);a.setProgramParameters(this.render_offscreen?this.runtime.layer_tex:this.layout.getRenderTarget(),1/q.width,1/q.height,p,r,s,w,this.getScale(),q.effect_params[l]);q.drawGL(a)}else a.switchProgram(0),a.setBlend(q.srcBlend,q.destBlend),q.drawGL(a);this.render_offscreen&&(d=this.active_effect_types.length?this.active_effect_types[0].shaderindex:0,l=this.active_effect_types.length?this.active_effect_types[0].index:0,0===this.active_effect_types.length||1===this.active_effect_types.length&&!a.programUsesCrossSampling(d)&&
1===this.opacity?(1===this.active_effect_types.length?(a.switchProgram(d),a.setProgramParameters(this.layout.getRenderTarget(),1/this.runtime.width,1/this.runtime.height,0,0,1,1,this.getScale(),this.effect_params[l]),a.programIsAnimated(d)&&(this.runtime.redraw=!0)):a.switchProgram(0),a.setRenderingToTexture(this.layout.getRenderTarget()),a.setOpacity(this.opacity),a.setTexture(this.runtime.layer_tex),a.setBlend(this.srcBlend,this.destBlend),a.resetModelView(),a.updateModelView(),b=this.runtime.width/
2,c=this.runtime.height/2,a.quad(-b,c,b,c,b,-c,-b,-c),a.setTexture(null)):this.layout.renderEffectChain(a,this,null,this.layout.getRenderTarget()))};b.prototype.canvasToLayer=function(a,b,c){var d=this.runtime.devicePixelRatio;this.runtime.isRetina&&0<this.runtime.fullscreen_mode&&(a*=d,b*=d);var d=this.runtime.original_width/2,l=this.runtime.original_height/2,d=(this.layout.scrollX-d)*this.parallaxX+d,l=(this.layout.scrollY-l)*this.parallaxY+l,k=1/this.getScale(),d=d-this.runtime.width*k/2,l=l-this.runtime.height*
k/2,d=d+a*k,l=l+b*k;b=this.getAngle();0!==b&&(d-=this.layout.scrollX,l-=this.layout.scrollY,a=Math.cos(b),b=Math.sin(b),k=d*a-l*b,l=l*a+d*b,d=k+this.layout.scrollX,l+=this.layout.scrollY);return c?d:l};b.prototype.layerToCanvas=function(a,b,c){var d=this.getAngle();if(0!==d){a-=this.layout.scrollX;b-=this.layout.scrollY;var l=Math.cos(-d),d=Math.sin(-d),k=a*l-b*d;b=b*l+a*d;a=k+this.layout.scrollX;b+=this.layout.scrollY}l=this.runtime.original_width/2;d=this.runtime.original_height/2;l=(this.layout.scrollX-
l)*this.parallaxX+l;d=(this.layout.scrollY-d)*this.parallaxY+d;k=1/this.getScale();l-=this.runtime.width*k/2;d-=this.runtime.height*k/2;l=(a-l)/k;d=(b-d)/k;a=this.runtime.devicePixelRatio;this.runtime.isRetina&&0<this.runtime.fullscreen_mode&&(l/=a,d/=a);return c?l:d};b.prototype.rotatePt=function(a,b,c){if(0===this.getAngle())return c?a:b;var d=this.layerToCanvas(a,b,!0);b=this.layerToCanvas(a,b,!1);this.disableAngle=!0;a=this.canvasToLayer(d,b,!0);d=this.canvasToLayer(d,b,!0);this.disableAngle=
!1;return c?a:d};b.prototype.saveToJSON=function(){var a,b,c,d={s:this.scale,a:this.angle,vl:this.viewLeft,vt:this.viewTop,vr:this.viewRight,vb:this.viewBottom,v:this.visible,bc:this.background_color,t:this.transparent,px:this.parallaxX,py:this.parallaxY,o:this.opacity,zr:this.zoomRate,fx:[],instances:[]};a=0;for(b=this.effect_types.length;a<b;a++)c=this.effect_types[a],d.fx.push({name:c.name,active:c.active,params:this.effect_params[c.index]});return d};b.prototype.loadFromJSON=function(a){var b,
d;this.scale=a.s;this.angle=a.a;this.viewLeft=a.vl;this.viewTop=a.vt;this.viewRight=a.vr;this.viewBottom=a.vb;this.visible=a.v;this.background_color=a.bc;this.transparent=a.t;this.parallaxX=a.px;this.parallaxY=a.py;this.opacity=a.o;this.zoomRate=a.zr;var h=a.fx;a=0;for(b=h.length;a<b;a++)if(d=this.getEffectByName(h[a].name))d.active=h[a].active,this.effect_params[d.index]=h[a].params;this.updateActiveEffects();this.instances.sort(c);this.zindices_stale=!0};cr.layer=b})();
(function(){function a(a,b){var c,d=a.length;switch(d){case 0:return!0;case 1:return a[0]===b[0];case 2:return a[0]===b[0]&&a[1]===b[1];default:for(c=0;c<d;c++)if(a[c]!==b[c])return!1;return!0}}function b(a,b){return a.index-b.index}function c(c){var d,e,f,g;2===c.length?c[0].index>c[1].index&&(d=c[0],c[0]=c[1],c[1]=d):2<c.length&&c.sort(b);c.length>=p.length&&(p.length=c.length+1);p[c.length]||(p[c.length]=[]);g=p[c.length];d=0;for(e=g.length;d<e;d++)if(f=g[d],a(c,f))return f;g.push(c);return c}
function d(a,b){this.runtime=a;this.triggers={};this.fasttriggers={};this.hasRun=!1;this.includes=new cr.ObjectSet;this.name=b[0];var c=b[1];this.events=[];var d,e;d=0;for(e=c.length;d<e;d++)this.init_event(c[d],null,this.events)}function e(a){this.type=a;this.instances=[];this.else_instances=[];this.select_all=!0}function f(a,b,c){this.sheet=a;this.parent=b;this.runtime=a.runtime;this.solModifiers=[];this.solModifiersIncludingParents=[];this.has_else_block=this.toplevelgroup=this.toplevelevent=this.initially_activated=
this.group=this.solWriterAfterCnds=!1;this.conditions=[];this.actions=[];this.subevents=[];c[1]?(this.group_name=c[1][1].toLowerCase(),this.group=!0,this.initially_activated=!!c[1][0],this.runtime.allGroups.push(this),this.runtime.activeGroups[this.group_name.toLowerCase()]=this.initially_activated):(this.group_name="",this.initially_activated=this.group=!1);this.orblock=c[2];this.sid=c[4];this.group||(this.runtime.blocksBySid[this.sid.toString()]=this);var d=c[5];a=0;for(b=d.length;a<b;a++){var e=
new cr.condition(this,d[a]);e.index=a;cr.seal(e);this.conditions.push(e);this.addSolModifier(e.type)}d=c[6];a=0;for(b=d.length;a<b;a++)e=new cr.action(this,d[a]),e.index=a,cr.seal(e),this.actions.push(e);if(8===c.length)for(c=c[7],a=0,b=c.length;a<b;a++)this.sheet.init_event(c[a],this,this.subevents);this.is_else_block=!1;this.conditions.length&&(this.is_else_block=null==this.conditions[0].type&&this.conditions[0].func==cr.system_object.prototype.cnds.Else)}function g(a,b){var c,d,e;if(a&&(-1===b.indexOf(a)&&
b.push(a),a.is_contained))for(c=0,d=a.container.length;c<d;c++)e=a.container[c],a!==e&&-1===b.indexOf(e)&&b.push(e)}function h(a,b){this.block=a;this.sheet=a.sheet;this.runtime=a.runtime;this.parameters=[];this.results=[];this.extra={};this.index=-1;this.func=b[1];this.trigger=0<b[3];this.fasttrigger=2===b[3];this.looping=b[4];this.inverted=b[5];this.isstatic=b[6];this.sid=b[7];this.runtime.cndsBySid[this.sid.toString()]=this;-1===b[0]?(this.type=null,this.run=this.run_system,this.behaviortype=null,
this.beh_index=-1):(this.type=this.runtime.types_by_index[b[0]],this.run=this.isstatic?this.run_static:this.run_object,b[2]?(this.behaviortype=this.type.getBehaviorByName(b[2]),this.beh_index=this.type.getBehaviorIndexByName(b[2])):(this.behaviortype=null,this.beh_index=-1),this.block.parent&&this.block.parent.setSolWriterAfterCnds());this.fasttrigger&&(this.run=this.run_true);if(10===b.length){var c,d,e=b[9];c=0;for(d=e.length;c<d;c++){var f=new cr.parameter(this,e[c]);cr.seal(f);this.parameters.push(f)}this.results.length=
e.length}}function l(a,b){this.block=a;this.sheet=a.sheet;this.runtime=a.runtime;this.parameters=[];this.results=[];this.extra={};this.index=-1;this.func=b[1];-1===b[0]?(this.type=null,this.run=this.run_system,this.behaviortype=null,this.beh_index=-1):(this.type=this.runtime.types_by_index[b[0]],this.run=this.run_object,b[2]?(this.behaviortype=this.type.getBehaviorByName(b[2]),this.beh_index=this.type.getBehaviorIndexByName(b[2])):(this.behaviortype=null,this.beh_index=-1));this.sid=b[3];this.runtime.actsBySid[this.sid.toString()]=
this;if(6===b.length){var c,d,e=b[5];c=0;for(d=e.length;c<d;c++){var f=new cr.parameter(this,e[c]);cr.seal(f);this.parameters.push(f)}this.results.length=e.length}}function k(a,b){this.owner=a;this.block=a.block;this.sheet=a.sheet;this.runtime=a.runtime;this.type=b[0];this.expression=null;this.combosel=this.solindex=0;this.layout=null;this.key=0;this.object=null;this.index=0;this.variadicret=this.subparams=this.fileinfo=this.eventvar=this.varname=null;var c,d,e;switch(b[0]){case 0:case 7:this.expression=
new cr.expNode(this,b[1]);this.solindex=0;this.get=this.get_exp;break;case 1:this.expression=new cr.expNode(this,b[1]);this.solindex=0;this.get=this.get_exp_str;break;case 5:this.expression=new cr.expNode(this,b[1]);this.solindex=0;this.get=this.get_layer;break;case 3:case 8:this.combosel=b[1];this.get=this.get_combosel;break;case 6:this.layout=this.runtime.layouts[b[1]];this.get=this.get_layout;break;case 9:this.key=b[1];this.get=this.get_key;break;case 4:this.object=this.runtime.types_by_index[b[1]];
this.get=this.get_object;this.block.addSolModifier(this.object);this.owner instanceof cr.action?this.block.setSolWriterAfterCnds():this.block.parent&&this.block.parent.setSolWriterAfterCnds();break;case 10:this.index=b[1];this.get=a.type.is_family?this.get_familyvar:this.get_instvar;break;case 11:this.varname=b[1];this.eventvar=null;this.get=this.get_eventvar;break;case 2:case 12:this.fileinfo=b[1];this.get=this.get_audiofile;break;case 13:for(this.get=this.get_variadic,this.subparams=[],this.variadicret=
[],c=1,d=b.length;c<d;c++)e=new cr.parameter(this.owner,b[c]),cr.seal(e),this.subparams.push(e),this.variadicret.push(0)}}function m(a,b,c){this.sheet=a;this.parent=b;this.runtime=a.runtime;this.solModifiers=[];this.name=c[1];this.vartype=c[2];this.initial=c[3];this.is_static=!!c[4];this.is_constant=!!c[5];this.sid=c[6];this.runtime.varsBySid[this.sid.toString()]=this;this.data=this.initial;this.parent?(this.localIndex=this.is_static||this.is_constant?-1:this.runtime.stackLocalCount++,this.runtime.all_local_vars.push(this)):
(this.localIndex=-1,this.runtime.all_global_vars.push(this))}function n(a,b,c){this.sheet=a;this.parent=b;this.runtime=a.runtime;this.solModifiers=[];this.include_sheet=null;this.include_sheet_name=c[1]}function q(){this.temp_parents_arr=[];this.reset(null);cr.seal(this)}var p=[];d.prototype.toString=function(){return this.name};d.prototype.init_event=function(a,b,c){switch(a[0]){case 0:a=new cr.eventblock(this,b,a);cr.seal(a);if(a.orblock)for(c.push(a),c=0,b=a.conditions.length;c<b;c++)a.conditions[c].trigger&&
this.init_trigger(a,c);else a.is_trigger()?this.init_trigger(a,0):c.push(a);break;case 1:a=new cr.eventvariable(this,b,a);cr.seal(a);c.push(a);break;case 2:a=new cr.eventinclude(this,b,a),cr.seal(a),c.push(a)}};d.prototype.postInit=function(){var a,b;a=0;for(b=this.events.length;a<b;a++)this.events[a].postInit(a<b-1&&this.events[a+1].is_else_block)};d.prototype.run=function(a){this.runtime.resuming_breakpoint||(this.hasRun=!0,a||(this.runtime.isRunningEvents=!0));var b,c;b=0;for(c=this.events.length;b<
c;b++){var d=this.events[b];d.run();this.runtime.clearSol(d.solModifiers);this.runtime.deathRow.isEmpty()&&!this.runtime.createRow.length||this.runtime.ClearDeathRow()}a||(this.runtime.isRunningEvents=!1)};d.prototype.init_trigger=function(a,b){a.orblock||this.runtime.triggers_to_postinit.push(a);var c,d,e=a.conditions[b],f;f=e.type?e.type.name:"system";var g=(c=e.fasttrigger)?this.fasttriggers:this.triggers;g[f]||(g[f]=[]);f=g[f];g=e.func;if(c){if(e.parameters.length&&(e=e.parameters[0],1===e.type&&
2===e.expression.type)){e=e.expression.value.toLowerCase();c=0;for(d=f.length;c<d;c++)if(f[c].method==g){c=f[c].evs;c[e]?c[e].push([a,b]):c[e]=[[a,b]];return}c={};c[e]=[[a,b]];f.push({method:g,evs:c})}}else{c=0;for(d=f.length;c<d;c++)if(f[c].method==g){f[c].evs.push([a,b]);return}f.push({method:g,evs:[[a,b]]})}};cr.eventsheet=d;e.prototype.hasObjects=function(){return this.select_all?this.type.instances.length:this.instances.length};e.prototype.getObjects=function(){return this.select_all?this.type.instances:
this.instances};e.prototype.pick_one=function(a){a&&(a.runtime.getCurrentEventStack().current_event.orblock?(this.select_all&&(this.instances.length=0,cr.shallowAssignArray(this.else_instances,a.type.instances),this.select_all=!1),a=this.else_instances.indexOf(a),-1!==a&&(this.instances.push(this.else_instances[a]),this.else_instances.splice(a,1))):(this.select_all=!1,this.instances.length=1,this.instances[0]=a))};cr.selection=e;f.prototype.postInit=function(a){var b,d=this.parent;if(this.group)for(this.toplevelgroup=
!0;d;){if(!d.group){this.toplevelgroup=!1;break}d=d.parent}this.toplevelevent=!this.is_trigger()&&(!this.parent||this.parent.group&&this.parent.toplevelgroup);this.has_else_block=!!a;this.solModifiersIncludingParents=this.solModifiers.slice(0);for(d=this.parent;d;){a=0;for(b=d.solModifiers.length;a<b;a++)this.addParentSolModifier(d.solModifiers[a]);d=d.parent}this.solModifiers=c(this.solModifiers);this.solModifiersIncludingParents=c(this.solModifiersIncludingParents);a=0;for(b=this.conditions.length;a<
b;a++)this.conditions[a].postInit();a=0;for(b=this.actions.length;a<b;a++)this.actions[a].postInit();a=0;for(b=this.subevents.length;a<b;a++)this.subevents[a].postInit(a<b-1&&this.subevents[a+1].is_else_block)};f.prototype.addSolModifier=function(a){g(a,this.solModifiers)};f.prototype.addParentSolModifier=function(a){g(a,this.solModifiersIncludingParents)};f.prototype.setSolWriterAfterCnds=function(){this.solWriterAfterCnds=!0;this.parent&&this.parent.setSolWriterAfterCnds()};f.prototype.is_trigger=
function(){return this.conditions.length?this.conditions[0].trigger:!1};f.prototype.run=function(){var a,b=!1,c,d=this.runtime.getCurrentEventStack();d.current_event=this;this.is_else_block||(d.else_branch_ran=!1);if(this.orblock){0===this.conditions.length&&(b=!0);d.cndindex=0;for(a=this.conditions.length;d.cndindex<a;d.cndindex++)this.conditions[d.cndindex].trigger||(c=this.conditions[d.cndindex].run())&&(b=!0);(d.last_event_true=b)&&this.run_actions_and_subevents()}else{d.cndindex=0;for(a=this.conditions.length;d.cndindex<
a;d.cndindex++)if(c=this.conditions[d.cndindex].run(),!c){d.last_event_true=!1;!this.toplevelevent||this.runtime.deathRow.isEmpty()&&!this.runtime.createRow.length||this.runtime.ClearDeathRow();return}d.last_event_true=!0;this.run_actions_and_subevents()}this.end_run(d)};f.prototype.end_run=function(a){a.last_event_true&&this.has_else_block&&(a.else_branch_ran=!0);!this.toplevelevent||this.runtime.deathRow.isEmpty()&&!this.runtime.createRow.length||this.runtime.ClearDeathRow()};f.prototype.run_orblocktrigger=
function(a){this.runtime.getCurrentEventStack().current_event=this;this.conditions[a].run()&&this.run_actions_and_subevents()};f.prototype.run_actions_and_subevents=function(){var a=this.runtime.getCurrentEventStack(),b;a.actindex=0;for(b=this.actions.length;a.actindex<b;a.actindex++)if(this.actions[a.actindex].run())return;this.run_subevents()};f.prototype.resume_actions_and_subevents=function(){var a=this.runtime.getCurrentEventStack(),b;for(b=this.actions.length;a.actindex<b;a.actindex++)if(this.actions[a.actindex].run())return;
this.run_subevents()};f.prototype.run_subevents=function(){if(this.subevents.length){var a,b,c,d,e=this.subevents.length-1;this.runtime.pushEventStack(this);if(this.solWriterAfterCnds)for(a=0,b=this.subevents.length;a<b;a++)c=this.subevents[a],(d=!this.toplevelgroup||!this.group&&a<e)&&this.runtime.pushCopySol(c.solModifiers),c.run(),d?this.runtime.popSol(c.solModifiers):this.runtime.clearSol(c.solModifiers);else for(a=0,b=this.subevents.length;a<b;a++)this.subevents[a].run();this.runtime.popEventStack()}};
f.prototype.run_pretrigger=function(){var a=this.runtime.getCurrentEventStack();a.current_event=this;var b=!1,c;a.cndindex=0;for(c=this.conditions.length;a.cndindex<c;a.cndindex++)if(this.conditions[a.cndindex].run())b=!0;else if(!this.orblock)return!1;return this.orblock?b:!0};f.prototype.retrigger=function(){this.runtime.execcount++;var a=this.runtime.getCurrentEventStack().cndindex,b=this.runtime.pushEventStack(this);if(!this.orblock)for(b.cndindex=a+1,a=this.conditions.length;b.cndindex<a;b.cndindex++)if(!this.conditions[b.cndindex].run())return this.runtime.popEventStack(),
!1;this.run_actions_and_subevents();this.runtime.popEventStack();return!0};f.prototype.isFirstConditionOfType=function(a){var b=a.index;if(0===b)return!0;for(--b;0<=b;--b)if(this.conditions[b].type===a.type)return!1;return!0};cr.eventblock=f;h.prototype.postInit=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.parameters[a].postInit()};h.prototype.run_true=function(){return!0};h.prototype.run_system=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.results[a]=this.parameters[a].get();
return cr.xor(this.func.apply(this.runtime.system,this.results),this.inverted)};h.prototype.run_static=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.results[a]=this.parameters[a].get(a);a=this.func.apply(this.behaviortype?this.behaviortype:this.type,this.results);this.type.applySolToContainer();return a};h.prototype.run_object=function(){var a,b,c,d,e,f,g,k=this.type.getCurrentSol(),h=this.block.orblock&&!this.trigger,p=0,m=this.type.is_contained;if(k.select_all){k.instances.length=
0;a=k.else_instances.length=0;for(c=this.type.instances.length;a<c;a++){f=this.type.instances[a];b=0;for(d=this.parameters.length;b<d;b++)this.results[b]=this.parameters[b].get(a);-1<this.beh_index?(this.type.is_family&&(p=f.type.family_beh_map[this.type.family_index]),b=this.func.apply(f.behavior_insts[this.beh_index+p],this.results)):b=this.func.apply(f,this.results);(e=cr.xor(b,this.inverted))?k.instances.push(f):h&&k.else_instances.push(f)}this.type.finish&&this.type.finish(!0);k.select_all=!1;
this.type.applySolToContainer();return k.hasObjects()}var l=0,n=(e=h&&!this.block.isFirstConditionOfType(this))?k.else_instances:k.instances,r=!1;a=0;for(c=n.length;a<c;a++){f=n[a];b=0;for(d=this.parameters.length;b<d;b++)this.results[b]=this.parameters[b].get(a);-1<this.beh_index?(this.type.is_family&&(p=f.type.family_beh_map[this.type.family_index]),b=this.func.apply(f.behavior_insts[this.beh_index+p],this.results)):b=this.func.apply(f,this.results);if(cr.xor(b,this.inverted))if(r=!0,e){if(k.instances.push(f),
m)for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().instances.push(g)}else{n[l]=f;if(m)for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().instances[l]=g;l++}else if(e){n[l]=f;if(m)for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().else_instances[l]=g;l++}else if(h&&(k.else_instances.push(f),m))for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().else_instances.push(g)}n.length=l;if(m)for(a=0,c=this.type.container.length;a<
c;a++)f=this.type.container[a].getCurrentSol(),e?f.else_instances.length=l:f.instances.length=l;p=r;if(e&&!r)for(a=0,c=k.instances.length;a<c;a++){f=k.instances[a];b=0;for(d=this.parameters.length;b<d;b++)this.results[b]=this.parameters[b].get(a);b=-1<this.beh_index?this.func.apply(f.behavior_insts[this.beh_index],this.results):this.func.apply(f,this.results);if(cr.xor(b,this.inverted)){r=!0;break}}this.type.finish&&this.type.finish(p||h);return h?r:k.hasObjects()};cr.condition=h;l.prototype.postInit=
function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.parameters[a].postInit()};l.prototype.run_system=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.results[a]=this.parameters[a].get();return this.func.apply(this.runtime.system,this.results)};l.prototype.run_object=function(){var a=this.type.getCurrentSol().getObjects(),b,c,d,e,f;b=0;for(d=a.length;b<d;b++){f=a[b];c=0;for(e=this.parameters.length;c<e;c++)this.results[c]=this.parameters[c].get(b);-1<this.beh_index?(c=
0,this.type.is_family&&(c=f.type.family_beh_map[this.type.family_index]),this.func.apply(f.behavior_insts[this.beh_index+c],this.results)):this.func.apply(f,this.results)}return!1};cr.action=l;var r=[],s=-1;k.prototype.postInit=function(){var a,b;if(11===this.type)this.eventvar=this.runtime.getEventVariableByName(this.varname,this.block.parent);else if(13===this.type)for(a=0,b=this.subparams.length;a<b;a++)this.subparams[a].postInit();this.expression&&this.expression.postInit()};k.prototype.pushTempValue=
function(){s++;r.length===s&&r.push(new cr.expvalue);return r[s]};k.prototype.popTempValue=function(){s--};k.prototype.get_exp=function(a){this.solindex=a||0;a=this.pushTempValue();this.expression.get(a);this.popTempValue();return a.data};k.prototype.get_exp_str=function(a){this.solindex=a||0;a=this.pushTempValue();this.expression.get(a);this.popTempValue();return cr.is_string(a.data)?a.data:""};k.prototype.get_object=function(){return this.object};k.prototype.get_combosel=function(){return this.combosel};
k.prototype.get_layer=function(a){this.solindex=a||0;a=this.pushTempValue();this.expression.get(a);this.popTempValue();return a.is_number()?this.runtime.getLayerByNumber(a.data):this.runtime.getLayerByName(a.data)};k.prototype.get_layout=function(){return this.layout};k.prototype.get_key=function(){return this.key};k.prototype.get_instvar=function(){return this.index};k.prototype.get_familyvar=function(a){var b=this.owner.type,c=null,c=b.getCurrentSol(),d=c.getObjects(),c=d.length?d[a%d.length].type:
c.else_instances[a%c.else_instances.length].type;return this.index+c.family_var_map[b.family_index]};k.prototype.get_eventvar=function(){return this.eventvar};k.prototype.get_audiofile=function(){return this.fileinfo};k.prototype.get_variadic=function(){var a,b;a=0;for(b=this.subparams.length;a<b;a++)this.variadicret[a]=this.subparams[a].get();return this.variadicret};cr.parameter=k;m.prototype.postInit=function(){this.solModifiers=c(this.solModifiers)};m.prototype.setValue=function(a){var b=this.runtime.getCurrentLocalVarStack();
this.parent&&!this.is_static&&b?(this.localIndex>=b.length&&(b.length=this.localIndex+1),b[this.localIndex]=a):this.data=a};m.prototype.getValue=function(){var a=this.runtime.getCurrentLocalVarStack();return!this.parent||this.is_static||!a||this.is_constant?this.data:this.localIndex>=a.length||"undefined"===typeof a[this.localIndex]?this.initial:a[this.localIndex]};m.prototype.run=function(){!this.parent||this.is_static||this.is_constant||this.setValue(this.initial)};cr.eventvariable=m;n.prototype.toString=
function(){return"include:"+this.include_sheet.toString()};n.prototype.postInit=function(){this.include_sheet=this.runtime.eventsheets[this.include_sheet_name];this.sheet.includes.add(this);this.solModifiers=c(this.solModifiers)};n.prototype.run=function(){this.parent&&this.runtime.pushCleanSol(this.runtime.types_by_index);this.include_sheet.hasRun||this.include_sheet.run(!0);this.parent&&this.runtime.popSol(this.runtime.types_by_index)};n.prototype.isActive=function(){for(var a=this.parent;a;){if(a.group&&
!this.runtime.activeGroups[a.group_name.toLowerCase()])return!1;a=a.parent}return!0};cr.eventinclude=n;q.prototype.reset=function(a){this.current_event=a;this.actindex=this.cndindex=0;this.temp_parents_arr.length=0;this.any_true_state=this.else_branch_ran=this.last_event_true=!1};q.prototype.isModifierAfterCnds=function(){return this.current_event.solWriterAfterCnds?!0:this.cndindex<this.current_event.conditions.length-1?!!this.current_event.solModifiers.length:!1};cr.eventStackFrame=q})();
(function(){function a(a,b){this.owner=a;this.runtime=a.runtime;this.type=b[0];this.get=[this.eval_int,this.eval_float,this.eval_string,this.eval_unaryminus,this.eval_add,this.eval_subtract,this.eval_multiply,this.eval_divide,this.eval_mod,this.eval_power,this.eval_and,this.eval_or,this.eval_equal,this.eval_notequal,this.eval_less,this.eval_lessequal,this.eval_greater,this.eval_greaterequal,this.eval_conditional,this.eval_system_exp,this.eval_object_behavior_exp,this.eval_instvar_exp,this.eval_object_behavior_exp,
this.eval_eventvar_exp][this.type];var e=null;this.object_type=this.parameters=this.results=this.func=this.third=this.second=this.first=this.value=null;this.beh_index=-1;this.instance_expr=null;this.varindex=-1;this.eventvar=this.varname=this.behavior_type=null;this.return_string=!1;switch(this.type){case 0:case 1:case 2:this.value=b[1];break;case 3:this.first=new cr.expNode(a,b[1]);break;case 18:this.first=new cr.expNode(a,b[1]);this.second=new cr.expNode(a,b[2]);this.third=new cr.expNode(a,b[3]);
break;case 19:this.func=b[1];this.results=[];this.parameters=[];3===b.length?(e=b[2],this.results.length=e.length+1):this.results.length=1;break;case 20:this.object_type=this.runtime.types_by_index[b[1]];this.beh_index=-1;this.func=b[2];this.return_string=b[3];this.instance_expr=b[4]?new cr.expNode(a,b[4]):null;this.results=[];this.parameters=[];6===b.length?(e=b[5],this.results.length=e.length+1):this.results.length=1;break;case 21:this.object_type=this.runtime.types_by_index[b[1]];this.return_string=
b[2];this.instance_expr=b[3]?new cr.expNode(a,b[3]):null;this.varindex=b[4];break;case 22:this.object_type=this.runtime.types_by_index[b[1]];this.behavior_type=this.object_type.getBehaviorByName(b[2]);this.beh_index=this.object_type.getBehaviorIndexByName(b[2]);this.func=b[3];this.return_string=b[4];this.instance_expr=b[5]?new cr.expNode(a,b[5]):null;this.results=[];this.parameters=[];7===b.length?(e=b[6],this.results.length=e.length+1):this.results.length=1;break;case 23:this.varname=b[1],this.eventvar=
null}4<=this.type&&17>=this.type&&(this.first=new cr.expNode(a,b[1]),this.second=new cr.expNode(a,b[2]));if(e){var f,g;f=0;for(g=e.length;f<g;f++)this.parameters.push(new cr.expNode(a,e[f]))}cr.seal(this)}function b(a,b){this.type=a||cr.exptype.Integer;this.data=b||0;this.object_class=null;this.type==cr.exptype.Integer&&(this.data=Math.floor(this.data));cr.seal(this)}a.prototype.postInit=function(){23===this.type&&(this.eventvar=this.owner.runtime.getEventVariableByName(this.varname,this.owner.block.parent));
this.first&&this.first.postInit();this.second&&this.second.postInit();this.third&&this.third.postInit();this.instance_expr&&this.instance_expr.postInit();if(this.parameters){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.parameters[a].postInit()}};a.prototype.eval_system_exp=function(a){this.results[0]=a;a=this.owner.pushTempValue();var b,e;b=0;for(e=this.parameters.length;b<e;b++)this.parameters[b].get(a),this.results[b+1]=a.data;this.owner.popTempValue();this.func.apply(this.runtime.system,
this.results)};a.prototype.eval_object_behavior_exp=function(a){var b=this.object_type.getCurrentSol(),e=b.getObjects();if(!e.length)if(b.else_instances.length)e=b.else_instances;else{this.return_string?a.set_string(""):a.set_int(0);return}this.results[0]=a;a.object_class=this.object_type;a=this.owner.pushTempValue();var f,b=0;for(f=this.parameters.length;b<f;b++)this.parameters[b].get(a),this.results[b+1]=a.data;b=this.owner.solindex;this.instance_expr&&(this.instance_expr.get(a),a.is_number()&&
(b=a.data,e=this.object_type.instances));this.owner.popTempValue();b%=e.length;0>b&&(b+=e.length);e=e[b];-1<this.beh_index?(a=0,this.object_type.is_family&&(a=e.type.family_beh_map[this.object_type.family_index]),this.func.apply(e.behavior_insts[this.beh_index+a],this.results)):this.func.apply(e,this.results)};a.prototype.eval_instvar_exp=function(a){var b=this.object_type.getCurrentSol(),e=b.getObjects();if(!e.length)if(b.else_instances.length)e=b.else_instances;else{this.return_string?a.set_string(""):
a.set_int(0);return}b=this.owner.solindex;if(this.instance_expr){var f=this.owner.pushTempValue();this.instance_expr.get(f);if(f.is_number()){b=f.data;e=this.object_type.instances;b%=e.length;0>b&&(b+=e.length);e=e[b].instance_vars[this.varindex];cr.is_string(e)?a.set_string(e):a.set_float(e);this.owner.popTempValue();return}this.owner.popTempValue()}b%=e.length;0>b&&(b+=e.length);e=e[b];b=0;this.object_type.is_family&&(b=e.type.family_var_map[this.object_type.family_index]);e=e.instance_vars[this.varindex+
b];cr.is_string(e)?a.set_string(e):a.set_float(e)};a.prototype.eval_int=function(a){a.type=cr.exptype.Integer;a.data=this.value};a.prototype.eval_float=function(a){a.type=cr.exptype.Float;a.data=this.value};a.prototype.eval_string=function(a){a.type=cr.exptype.String;a.data=this.value};a.prototype.eval_unaryminus=function(a){this.first.get(a);a.is_number()&&(a.data=-a.data)};a.prototype.eval_add=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&
(a.data+=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_subtract=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data-=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_multiply=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data*=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_divide=
function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data/=b.data,a.make_float());this.owner.popTempValue()};a.prototype.eval_mod=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data%=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_power=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&
(a.data=Math.pow(a.data,b.data),b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_and=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()?b.is_string()?a.set_string(a.data.toString()+b.data):a.data&&b.data?a.set_int(1):a.set_int(0):a.is_string()&&(b.is_string()?a.data+=b.data:a.data+=(Math.round(1E10*b.data)/1E10).toString());this.owner.popTempValue()};a.prototype.eval_or=function(a){this.first.get(a);var b=this.owner.pushTempValue();
this.second.get(b);a.is_number()&&b.is_number()&&(a.data||b.data?a.set_int(1):a.set_int(0));this.owner.popTempValue()};a.prototype.eval_conditional=function(a){this.first.get(a);a.data?this.second.get(a):this.third.get(a)};a.prototype.eval_equal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data===b.data?1:0);this.owner.popTempValue()};a.prototype.eval_notequal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data!==
b.data?1:0);this.owner.popTempValue()};a.prototype.eval_less=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data<b.data?1:0);this.owner.popTempValue()};a.prototype.eval_lessequal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data<=b.data?1:0);this.owner.popTempValue()};a.prototype.eval_greater=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data>b.data?1:0);
this.owner.popTempValue()};a.prototype.eval_greaterequal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data>=b.data?1:0);this.owner.popTempValue()};a.prototype.eval_eventvar_exp=function(a){var b=this.eventvar.getValue();cr.is_number(b)?a.set_float(b):a.set_string(b)};cr.expNode=a;b.prototype.is_int=function(){return this.type===cr.exptype.Integer};b.prototype.is_float=function(){return this.type===cr.exptype.Float};b.prototype.is_number=function(){return this.type===
cr.exptype.Integer||this.type===cr.exptype.Float};b.prototype.is_string=function(){return this.type===cr.exptype.String};b.prototype.make_int=function(){this.is_int()||(this.is_float()?this.data=Math.floor(this.data):this.is_string()&&(this.data=parseInt(this.data,10)),this.type=cr.exptype.Integer)};b.prototype.make_float=function(){this.is_float()||(this.is_string()&&(this.data=parseFloat(this.data)),this.type=cr.exptype.Float)};b.prototype.make_string=function(){this.is_string()||(this.data=this.data.toString(),
this.type=cr.exptype.String)};b.prototype.set_int=function(a){this.type=cr.exptype.Integer;this.data=Math.floor(a)};b.prototype.set_float=function(a){this.type=cr.exptype.Float;this.data=a};b.prototype.set_string=function(a){this.type=cr.exptype.String;this.data=a};b.prototype.set_any=function(a){cr.is_number(a)?(this.type=cr.exptype.Float,this.data=a):cr.is_string(a)?(this.type=cr.exptype.String,this.data=a.toString()):(this.type=cr.exptype.Integer,this.data=0)};cr.expvalue=b;cr.exptype={Integer:0,
Float:1,String:2}})();cr.system_object=function(a){this.runtime=a;this.waits=[]};
cr.system_object.prototype.saveToJSON=function(){var a={},b,c,d,e,f,g,h,l;a.waits=[];var k=a.waits,m;b=0;for(c=this.waits.length;b<c;b++){g=this.waits[b];m={t:g.time,ev:g.ev.sid,sm:[],sols:{}};g.ev.actions[g.actindex]&&(m.act=g.ev.actions[g.actindex].sid);d=0;for(e=g.solModifiers.length;d<e;d++)m.sm.push(g.solModifiers[d].sid);for(f in g.sols)if(g.sols.hasOwnProperty(f)){h=this.runtime.types_by_index[parseInt(f,10)];l={sa:g.sols[f].sa,insts:[]};d=0;for(e=g.sols[f].insts.length;d<e;d++)l.insts.push(g.sols[f].insts[d].uid);
m.sols[h.sid.toString()]=l}k.push(m)}return a};
cr.system_object.prototype.loadFromJSON=function(a){a=a.waits;var b,c,d,e,f,g,h,l,k,m,n;b=this.waits.length=0;for(c=a.length;b<c;b++)if(g=a[b],l=this.runtime.blocksBySid[g.ev.toString()]){k=-1;d=0;for(e=l.actions.length;d<e;d++)if(l.actions[d].sid===g.act){k=d;break}if(-1!==k){h={sols:{},solModifiers:[],deleteme:!1};h.time=g.t;h.ev=l;h.actindex=k;d=0;for(e=g.sm.length;d<e;d++)(l=this.runtime.getObjectTypeBySid(g.sm[d]))&&h.solModifiers.push(l);for(f in g.sols)if(g.sols.hasOwnProperty(f)&&(l=this.runtime.getObjectTypeBySid(parseInt(f,
10)))){k=g.sols[f];m={sa:k.sa,insts:[]};d=0;for(e=k.insts.length;d<e;d++)(n=this.runtime.getObjectByUID(k.insts[d]))&&m.insts.push(n);h.sols[l.index.toString()]=m}this.waits.push(h)}}};
(function(){function a(){}function b(a,b){var c=a.extra.c2_foreachordered_val,d=b.extra.c2_foreachordered_val;if(cr.is_number(c)&&cr.is_number(d))return c-d;c=""+c;d=""+d;return c<d?-1:c>d?1:0}function c(a,b){k&&a===m&&b===n||(k=RegExp(a,b),m=a,n=b);k.lastIndex=0;return k}function d(){}function e(){}function f(a,b,d){if(a!==w||b!==x||d!==C){var e=c(b,d);s=a.match(e);w=a;x=b;C=d}}var g=cr.system_object.prototype;a.prototype.EveryTick=function(){return!0};a.prototype.OnLayoutStart=function(){return!0};
a.prototype.OnLayoutEnd=function(){return!0};a.prototype.Compare=function(a,b,c){return cr.do_cmp(a,b,c)};a.prototype.CompareTime=function(a,b){var c=this.runtime.kahanTime.sum;if(0===a){var d=this.runtime.getCurrentCondition();return!d.extra.CompareTime_executed&&c>=b?d.extra.CompareTime_executed=!0:!1}return cr.do_cmp(c,a,b)};a.prototype.LayerVisible=function(a){return a?a.visible:!1};a.prototype.LayerCmpOpacity=function(a,b,c){return a?cr.do_cmp(100*a.opacity,b,c):!1};a.prototype.Repeat=function(a){var b=
this.runtime.getCurrentEventStack(),c=b.current_event,d=b.isModifierAfterCnds(),b=this.runtime.pushLoopStack();if(d)for(d=0;d<a&&!b.stopped;d++)this.runtime.pushCopySol(c.solModifiers),b.index=d,c.retrigger(),this.runtime.popSol(c.solModifiers);else for(d=0;d<a&&!b.stopped;d++)b.index=d,c.retrigger();this.runtime.popLoopStack();return!1};a.prototype.While=function(a){var b=this.runtime.getCurrentEventStack();a=b.current_event;var c=b.isModifierAfterCnds(),b=this.runtime.pushLoopStack();if(c)for(c=
0;!b.stopped;c++)this.runtime.pushCopySol(a.solModifiers),b.index=c,a.retrigger()||(b.stopped=!0),this.runtime.popSol(a.solModifiers);else for(c=0;!b.stopped;c++)b.index=c,a.retrigger()||(b.stopped=!0);this.runtime.popLoopStack();return!1};a.prototype.For=function(a,b,c){var d=this.runtime.getCurrentEventStack(),e=d.current_event,d=d.isModifierAfterCnds();a=this.runtime.pushLoopStack(a);if(c<b)if(d)for(;b>=c&&!a.stopped;--b)this.runtime.pushCopySol(e.solModifiers),a.index=b,e.retrigger(),this.runtime.popSol(e.solModifiers);
else for(;b>=c&&!a.stopped;--b)a.index=b,e.retrigger();else if(d)for(;b<=c&&!a.stopped;++b)this.runtime.pushCopySol(e.solModifiers),a.index=b,e.retrigger(),this.runtime.popSol(e.solModifiers);else for(;b<=c&&!a.stopped;++b)a.index=b,e.retrigger();this.runtime.popLoopStack();return!1};var h=[],l=-1;a.prototype.ForEach=function(a){var b=a.getCurrentSol();l++;h.length===l&&h.push([]);var c=h[l];cr.shallowAssignArray(c,b.getObjects());var d=this.runtime.getCurrentEventStack(),e=d.current_event,f=d.isModifierAfterCnds(),
d=this.runtime.pushLoopStack(),g,k,p,m,n,r,s=a.is_contained;if(f)for(f=0,g=c.length;f<g&&!d.stopped;f++){this.runtime.pushCopySol(e.solModifiers);m=c[f];b=a.getCurrentSol();b.select_all=!1;b.instances.length=1;b.instances[0]=m;if(s)for(k=0,p=m.siblings.length;k<p;k++)n=m.siblings[k],r=n.type.getCurrentSol(),r.select_all=!1,r.instances.length=1,r.instances[0]=n;d.index=f;e.retrigger();this.runtime.popSol(e.solModifiers)}else for(b.select_all=!1,b.instances.length=1,f=0,g=c.length;f<g&&!d.stopped;f++){m=
c[f];b.instances[0]=m;if(s)for(k=0,p=m.siblings.length;k<p;k++)n=m.siblings[k],r=n.type.getCurrentSol(),r.select_all=!1,r.instances.length=1,r.instances[0]=n;d.index=f;e.retrigger()}c.length=0;this.runtime.popLoopStack();l--;return!1};a.prototype.ForEachOrdered=function(a,c,d){c=a.getCurrentSol();l++;h.length===l&&h.push([]);var e=h[l];cr.shallowAssignArray(e,c.getObjects());var f=this.runtime.getCurrentEventStack(),g=f.current_event,k=this.runtime.getCurrentCondition(),p=f.isModifierAfterCnds(),
f=this.runtime.pushLoopStack(),m,n,r,s,w;m=0;for(n=e.length;m<n;m++)e[m].extra.c2_foreachordered_val=k.parameters[1].get(m);e.sort(b);1===d&&e.reverse();d=a.is_contained;if(p)for(m=0,n=e.length;m<n&&!f.stopped;m++){this.runtime.pushCopySol(g.solModifiers);r=e[m];c=a.getCurrentSol();c.select_all=!1;c.instances.length=1;c.instances[0]=r;if(d)for(k=0,p=r.siblings.length;k<p;k++)s=r.siblings[k],w=s.type.getCurrentSol(),w.select_all=!1,w.instances.length=1,w.instances[0]=s;f.index=m;g.retrigger();this.runtime.popSol(g.solModifiers)}else for(c.select_all=
!1,c.instances.length=1,m=0,n=e.length;m<n&&!f.stopped;m++){r=e[m];c.instances[0]=r;if(d)for(k=0,p=r.siblings.length;k<p;k++)s=r.siblings[k],w=s.type.getCurrentSol(),w.select_all=!1,w.instances.length=1,w.instances[0]=s;f.index=m;g.retrigger()}e.length=0;this.runtime.popLoopStack();l--;return!1};a.prototype.PickByComparison=function(a,b,c,d){var e,f,g,k;if(a){l++;h.length===l&&h.push([]);var p=h[l],m=a.getCurrentSol();cr.shallowAssignArray(p,m.getObjects());m.select_all&&(m.else_instances.length=
0);var n=this.runtime.getCurrentCondition();g=e=0;for(f=p.length;e<f;e++)k=p[e],p[g]=k,b=n.parameters[1].get(e),d=n.parameters[3].get(e),cr.do_cmp(b,c,d)?g++:m.else_instances.push(k);p.length=g;m.select_all=!1;cr.shallowAssignArray(m.instances,p);p.length=0;l--;a.applySolToContainer();return!!m.instances.length}};a.prototype.PickByEvaluate=function(a,b){var c,d,e,f;if(a){l++;h.length===l&&h.push([]);var g=h[l],k=a.getCurrentSol();cr.shallowAssignArray(g,k.getObjects());k.select_all&&(k.else_instances.length=
0);var p=this.runtime.getCurrentCondition();e=c=0;for(d=g.length;c<d;c++)f=g[c],g[e]=f,(b=p.parameters[1].get(c))?e++:k.else_instances.push(f);g.length=e;k.select_all=!1;cr.shallowAssignArray(k.instances,g);g.length=0;l--;a.applySolToContainer();return!!k.instances.length}};a.prototype.TriggerOnce=function(){var a=this.runtime.getCurrentCondition().extra;"undefined"===typeof a.TriggerOnce_lastTick&&(a.TriggerOnce_lastTick=-1);var b=a.TriggerOnce_lastTick,c=this.runtime.tickcount;a.TriggerOnce_lastTick=
c;return this.runtime.layout_first_tick||b!==c-1};a.prototype.Every=function(a){var b=this.runtime.getCurrentCondition(),c=b.extra.Every_lastTime||0,d=this.runtime.kahanTime.sum;"undefined"===typeof b.extra.Every_seconds&&(b.extra.Every_seconds=a);var e=b.extra.Every_seconds;return d>=c+e?(b.extra.Every_lastTime=c+e,d>=b.extra.Every_lastTime+e&&(b.extra.Every_lastTime=d),b.extra.Every_seconds=a,!0):!1};a.prototype.PickNth=function(a,b){if(!a)return!1;var c=a.getCurrentSol(),d=c.getObjects();b=cr.floor(b);
if(0>b||b>=d.length)return!1;c.pick_one(d[b]);a.applySolToContainer();return!0};a.prototype.PickRandom=function(a){if(!a)return!1;var b=a.getCurrentSol(),c=b.getObjects(),d=cr.floor(Math.random()*c.length);if(d>=c.length)return!1;b.pick_one(c[d]);a.applySolToContainer();return!0};a.prototype.CompareVar=function(a,b,c){return cr.do_cmp(a.getValue(),b,c)};a.prototype.IsGroupActive=function(a){return this.runtime.activeGroups[a.toLowerCase()]};a.prototype.IsPreview=function(){return"undefined"!==typeof cr_is_preview};
a.prototype.PickAll=function(a){if(!a||!a.instances.length)return!1;a.getCurrentSol().select_all=!0;a.applySolToContainer();return!0};a.prototype.IsMobile=function(){return this.runtime.isMobile};a.prototype.CompareBetween=function(a,b,c){return a>=b&&a<=c};a.prototype.Else=function(){var a=this.runtime.getCurrentEventStack();return a.else_branch_ran?!1:!a.last_event_true};a.prototype.OnLoadFinished=function(){return!0};a.prototype.OnCanvasSnapshot=function(){return!0};a.prototype.EffectsSupported=
function(){return!!this.runtime.glwrap};a.prototype.OnSaveComplete=function(){return!0};a.prototype.OnLoadComplete=function(){return!0};a.prototype.OnLoadFailed=function(){return!0};a.prototype.ObjectUIDExists=function(a){return!!this.runtime.getObjectByUID(a)};a.prototype.IsOnPlatform=function(a){var b=this.runtime;switch(a){case 0:return!b.isDomFree&&!b.isNodeWebkit&&!b.isPhoneGap&&!b.isWindows8App&&!b.isWindowsPhone8&&!b.isBlackberry10;case 1:return b.isiOS;case 2:return b.isAndroid;case 3:return b.isWindows8App;
case 4:return b.isWindowsPhone8;case 5:return b.isBlackberry10;case 6:return b.isTizen;case 7:return b.isNodeWebkit;case 8:return b.isCocoonJs;case 9:return b.isPhoneGap;case 10:return b.isArcade;case 11:return b.isNodeWebkit;default:return!1}};var k=null,m="",n="";a.prototype.RegexTest=function(a,b,d){return c(b,d).test(a)};var q=[];a.prototype.PickOverlappingPoint=function(a,b,c){if(!a)return!1;var d=a.getCurrentSol(),e=d.getObjects(),f=this.runtime.getCurrentEventStack().current_event.orblock,
g=this.runtime.getCurrentCondition(),k,h;d.select_all?(cr.shallowAssignArray(q,e),d.else_instances.length=0,d.select_all=!1,d.instances.length=0):f?(cr.shallowAssignArray(q,d.else_instances),d.else_instances.length=0):(cr.shallowAssignArray(q,e),d.instances.length=0);e=0;for(f=q.length;e<f;++e)k=q[e],(h=cr.xor(k.contains_pt(b,c),g.inverted))?d.instances.push(k):d.else_instances.push(k);a.applySolToContainer();return cr.xor(!!d.instances.length,g.inverted)};g.cnds=new a;d.prototype.GoToLayout=function(a){this.runtime.isloading||
this.runtime.changelayout||(this.runtime.changelayout=a)};d.prototype.CreateObject=function(a,b,c,d){if(b&&a&&(b=this.runtime.createInstance(a,b,c,d))){this.runtime.isInOnDestroy++;var e;this.runtime.trigger(Object.getPrototypeOf(a.plugin).cnds.OnCreated,b);if(b.is_contained)for(c=0,d=b.siblings.length;c<d;c++)e=b.siblings[c],this.runtime.trigger(Object.getPrototypeOf(e.type.plugin).cnds.OnCreated,e);this.runtime.isInOnDestroy--;a=a.getCurrentSol();a.select_all=!1;a.instances.length=1;a.instances[0]=
b;if(b.is_contained)for(c=0,d=b.siblings.length;c<d;c++)e=b.siblings[c],a=e.type.getCurrentSol(),a.select_all=!1,a.instances.length=1,a.instances[0]=e}};d.prototype.SetLayerVisible=function(a,b){a&&a.visible!==b&&(a.visible=b,this.runtime.redraw=!0)};d.prototype.SetLayerOpacity=function(a,b){a&&(b=cr.clamp(b/100,0,1),a.opacity!==b&&(a.opacity=b,this.runtime.redraw=!0))};d.prototype.SetLayerScaleRate=function(a,b){a&&a.zoomRate!==b&&(a.zoomRate=b,this.runtime.redraw=!0)};d.prototype.SetLayoutScale=
function(a){this.runtime.running_layout&&this.runtime.running_layout.scale!==a&&(this.runtime.running_layout.scale=a,this.runtime.running_layout.boundScrolling(),this.runtime.redraw=!0)};d.prototype.ScrollX=function(a){this.runtime.running_layout.scrollToX(a)};d.prototype.ScrollY=function(a){this.runtime.running_layout.scrollToY(a)};d.prototype.Scroll=function(a,b){this.runtime.running_layout.scrollToX(a);this.runtime.running_layout.scrollToY(b)};d.prototype.ScrollToObject=function(a){if(a=a.getFirstPicked())this.runtime.running_layout.scrollToX(a.x),
this.runtime.running_layout.scrollToY(a.y)};d.prototype.SetVar=function(a,b){0===a.vartype?cr.is_number(b)?a.setValue(b):a.setValue(parseFloat(b)):1===a.vartype&&a.setValue(b.toString())};d.prototype.AddVar=function(a,b){0===a.vartype?cr.is_number(b)?a.setValue(a.getValue()+b):a.setValue(a.getValue()+parseFloat(b)):1===a.vartype&&a.setValue(a.getValue()+b.toString())};d.prototype.SubVar=function(a,b){0===a.vartype&&(cr.is_number(b)?a.setValue(a.getValue()-b):a.setValue(a.getValue()-parseFloat(b)))};
d.prototype.SetGroupActive=function(a,b){var c=this.runtime.activeGroups,d=a.toLowerCase();switch(b){case 0:c[d]=!1;break;case 1:c[d]=!0;break;case 2:c[d]=!c[d]}};d.prototype.SetTimescale=function(a){0>a&&(a=0);this.runtime.timescale=a};d.prototype.SetObjectTimescale=function(a,b){var c=b;0>c&&(c=0);if(a){var d=a.getCurrentSol().getObjects(),e,f;e=0;for(f=d.length;e<f;e++)d[e].my_timescale=c}};d.prototype.RestoreObjectTimescale=function(a){if(!a)return!1;a=a.getCurrentSol().getObjects();var b,c;b=
0;for(c=a.length;b<c;b++)a[b].my_timescale=-1};var p=[],r=[];d.prototype.Wait=function(a){if(!(0>a)){var b,c,d,e=this.runtime.getCurrentEventStack(),f;f=p.length?p.pop():{sols:{},solModifiers:[]};f.deleteme=!1;f.time=this.runtime.kahanTime.sum+a;f.ev=e.current_event;f.actindex=e.actindex+1;a=0;for(b=this.runtime.types_by_index.length;a<b;a++)d=this.runtime.types_by_index[a],c=d.getCurrentSol(),c.select_all&&-1===e.current_event.solModifiers.indexOf(d)||(f.solModifiers.push(d),d=void 0,d=r.length?
r.pop():{insts:[]},d.sa=!1,d.sa=c.select_all,cr.shallowAssignArray(d.insts,c.instances),f.sols[a.toString()]=d);this.waits.push(f);return!0}};d.prototype.SetLayerScale=function(a,b){a&&a.scale!==b&&(a.scale=b,this.runtime.redraw=!0)};d.prototype.ResetGlobals=function(){var a,b,c;a=0;for(b=this.runtime.all_global_vars.length;a<b;a++)c=this.runtime.all_global_vars[a],c.data=c.initial};d.prototype.SetLayoutAngle=function(a){a=cr.to_radians(a);a=cr.clamp_angle(a);this.runtime.running_layout&&this.runtime.running_layout.angle!==
a&&(this.runtime.running_layout.angle=a,this.runtime.redraw=!0)};d.prototype.SetLayerAngle=function(a,b){a&&(b=cr.to_radians(b),b=cr.clamp_angle(b),a.angle!==b&&(a.angle=b,this.runtime.redraw=!0))};d.prototype.SetLayerParallax=function(a,b,c){!a||a.parallaxX===b/100&&a.parallaxY===c/100||(a.parallaxX=b/100,a.parallaxY=c/100,this.runtime.redraw=!0)};d.prototype.SetLayerBackground=function(a,b){if(a){var c=cr.GetRValue(b),d=cr.GetGValue(b),e=cr.GetBValue(b);if(a.background_color[0]!==c||a.background_color[1]!==
d||a.background_color[2]!==e)a.background_color[0]=c,a.background_color[1]=d,a.background_color[2]=e,this.runtime.redraw=!0}};d.prototype.SetLayerTransparent=function(a,b){a&&!!b!==!!a.transparent&&(a.transparent=!!b,this.runtime.redraw=!0)};d.prototype.StopLoop=function(){0>this.runtime.loop_stack_index||(this.runtime.getCurrentLoop().stopped=!0)};d.prototype.GoToLayoutByName=function(a){if(!this.runtime.isloading&&!this.runtime.changelayout)for(var b in this.runtime.layouts)if(this.runtime.layouts.hasOwnProperty(b)&&
cr.equals_nocase(b,a)){this.runtime.changelayout=this.runtime.layouts[b];break}};d.prototype.RestartLayout=function(a){if(!this.runtime.isloading&&!this.runtime.changelayout&&this.runtime.running_layout){this.runtime.changelayout=this.runtime.running_layout;var b,c;a=0;for(b=this.runtime.allGroups.length;a<b;a++)c=this.runtime.allGroups[a],this.runtime.activeGroups[c.group_name.toLowerCase()]=c.initially_activated}};d.prototype.SnapshotCanvas=function(a,b){this.runtime.snapshotCanvas=[0===a?"image/png":
"image/jpeg",b/100];this.runtime.redraw=!0};d.prototype.SetCanvasSize=function(a,b){0>=a||0>=b||this.runtime.setSize(a,b)};d.prototype.SetLayoutEffectEnabled=function(a,b){if(this.runtime.running_layout&&this.runtime.glwrap){var c=this.runtime.running_layout.getEffectByName(b);if(c){var d=1===a;c.active!=d&&(c.active=d,this.runtime.running_layout.updateActiveEffects(),this.runtime.redraw=!0)}}};d.prototype.SetLayerEffectEnabled=function(a,b,c){a&&this.runtime.glwrap&&(c=a.getEffectByName(c))&&(b=
1===b,c.active!=b&&(c.active=b,a.updateActiveEffects(),this.runtime.redraw=!0))};d.prototype.SetLayoutEffectParam=function(a,b,c){if(this.runtime.running_layout&&this.runtime.glwrap&&(a=this.runtime.running_layout.getEffectByName(a))){var d=this.runtime.running_layout.effect_params[a.index];b=Math.floor(b);0>b||b>=d.length||(1===this.runtime.glwrap.getProgramParameterType(a.shaderindex,b)&&(c/=100),d[b]!==c&&(d[b]=c,a.active&&(this.runtime.redraw=!0)))}};d.prototype.SetLayerEffectParam=function(a,
b,c,d){a&&this.runtime.glwrap&&(b=a.getEffectByName(b))&&(a=a.effect_params[b.index],c=Math.floor(c),0>c||c>=a.length||(1===this.runtime.glwrap.getProgramParameterType(b.shaderindex,c)&&(d/=100),a[c]!==d&&(a[c]=d,b.active&&(this.runtime.redraw=!0))))};d.prototype.SaveState=function(a){this.runtime.saveToSlot=a};d.prototype.LoadState=function(a){this.runtime.loadFromSlot=a};d.prototype.LoadStateJSON=function(a){this.runtime.loadFromJson=a};g.acts=new d;e.prototype["int"]=function(a,b){cr.is_string(b)?
(a.set_int(parseInt(b,10)),isNaN(a.data)&&(a.data=0)):a.set_int(b)};e.prototype["float"]=function(a,b){cr.is_string(b)?(a.set_float(parseFloat(b)),isNaN(a.data)&&(a.data=0)):a.set_float(b)};e.prototype.str=function(a,b){cr.is_string(b)?a.set_string(b):a.set_string(b.toString())};e.prototype.len=function(a,b){a.set_int(b.length||0)};e.prototype.random=function(a,b,c){void 0===c?a.set_float(Math.random()*b):a.set_float(Math.random()*(c-b)+b)};e.prototype.sqrt=function(a,b){a.set_float(Math.sqrt(b))};
e.prototype.abs=function(a,b){a.set_float(Math.abs(b))};e.prototype.round=function(a,b){a.set_int(Math.round(b))};e.prototype.floor=function(a,b){a.set_int(Math.floor(b))};e.prototype.ceil=function(a,b){a.set_int(Math.ceil(b))};e.prototype.sin=function(a,b){a.set_float(Math.sin(cr.to_radians(b)))};e.prototype.cos=function(a,b){a.set_float(Math.cos(cr.to_radians(b)))};e.prototype.tan=function(a,b){a.set_float(Math.tan(cr.to_radians(b)))};e.prototype.asin=function(a,b){a.set_float(cr.to_degrees(Math.asin(b)))};
e.prototype.acos=function(a,b){a.set_float(cr.to_degrees(Math.acos(b)))};e.prototype.atan=function(a,b){a.set_float(cr.to_degrees(Math.atan(b)))};e.prototype.exp=function(a,b){a.set_float(Math.exp(b))};e.prototype.ln=function(a,b){a.set_float(Math.log(b))};e.prototype.log10=function(a,b){a.set_float(Math.log(b)/Math.LN10)};e.prototype.max=function(a){var b=arguments[1],c,d;c=2;for(d=arguments.length;c<d;c++)b<arguments[c]&&(b=arguments[c]);a.set_float(b)};e.prototype.min=function(a){var b=arguments[1],
c,d;c=2;for(d=arguments.length;c<d;c++)b>arguments[c]&&(b=arguments[c]);a.set_float(b)};e.prototype.dt=function(a){a.set_float(this.runtime.dt)};e.prototype.timescale=function(a){a.set_float(this.runtime.timescale)};e.prototype.wallclocktime=function(a){a.set_float((Date.now()-this.runtime.start_time)/1E3)};e.prototype.time=function(a){a.set_float(this.runtime.kahanTime.sum)};e.prototype.tickcount=function(a){a.set_int(this.runtime.tickcount)};e.prototype.objectcount=function(a){a.set_int(this.runtime.objectcount)};
e.prototype.fps=function(a){a.set_int(this.runtime.fps)};e.prototype.loopindex=function(a,b){var c,d,e;if(this.runtime.loop_stack.length)if(b){d=0;for(e=this.runtime.loop_stack.length;d<e;d++)if(c=this.runtime.loop_stack[d],c.name===b){a.set_int(c.index);return}a.set_int(0)}else c=this.runtime.getCurrentLoop(),a.set_int(c?c.index:-1);else a.set_int(0)};e.prototype.distance=function(a,b,c,d,e){a.set_float(cr.distanceTo(b,c,d,e))};e.prototype.angle=function(a,b,c,d,e){a.set_float(cr.to_degrees(cr.angleTo(b,
c,d,e)))};e.prototype.scrollx=function(a){a.set_float(this.runtime.running_layout.scrollX)};e.prototype.scrolly=function(a){a.set_float(this.runtime.running_layout.scrollY)};e.prototype.newline=function(a){a.set_string("\n")};e.prototype.lerp=function(a,b,c,d){a.set_float(cr.lerp(b,c,d))};e.prototype.windowwidth=function(a){a.set_int(this.runtime.width)};e.prototype.windowheight=function(a){a.set_int(this.runtime.height)};e.prototype.uppercase=function(a,b){a.set_string(cr.is_string(b)?b.toUpperCase():
"")};e.prototype.lowercase=function(a,b){a.set_string(cr.is_string(b)?b.toLowerCase():"")};e.prototype.clamp=function(a,b,c,d){b<c?a.set_float(c):b>d?a.set_float(d):a.set_float(b)};e.prototype.layerscale=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(c.scale):a.set_float(0)};e.prototype.layeropacity=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(100*c.opacity):a.set_float(0)};e.prototype.layerscalerate=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(c.zoomRate):
a.set_float(0)};e.prototype.layerparallaxx=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(100*c.parallaxX):a.set_float(0)};e.prototype.layerparallaxy=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(100*c.parallaxY):a.set_float(0)};e.prototype.layoutscale=function(a){this.runtime.running_layout?a.set_float(this.runtime.running_layout.scale):a.set_float(0)};e.prototype.layoutangle=function(a){a.set_float(cr.to_degrees(this.runtime.running_layout.angle))};e.prototype.layerangle=
function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(cr.to_degrees(c.angle)):a.set_float(0)};e.prototype.layoutwidth=function(a){a.set_int(this.runtime.running_layout.width)};e.prototype.layoutheight=function(a){a.set_int(this.runtime.running_layout.height)};e.prototype.find=function(a,b,c){cr.is_string(b)&&cr.is_string(c)?a.set_int(b.search(RegExp(cr.regexp_escape(c),"i"))):a.set_int(-1)};e.prototype.left=function(a,b,c){a.set_string(cr.is_string(b)?b.substr(0,c):"")};e.prototype.right=function(a,
b,c){a.set_string(cr.is_string(b)?b.substr(b.length-c):"")};e.prototype.mid=function(a,b,c,d){a.set_string(cr.is_string(b)?b.substr(c,d):"")};e.prototype.tokenat=function(a,b,c,d){cr.is_string(b)&&cr.is_string(d)?(b=b.split(d),c=cr.floor(c),0>c||c>=b.length?a.set_string(""):a.set_string(b[c])):a.set_string("")};e.prototype.tokencount=function(a,b,c){cr.is_string(b)&&b.length?a.set_int(b.split(c).length):a.set_int(0)};e.prototype.replace=function(a,b,c,d){cr.is_string(b)&&cr.is_string(c)&&cr.is_string(d)?
a.set_string(b.replace(RegExp(cr.regexp_escape(c),"gi"),d)):a.set_string(cr.is_string(b)?b:"")};e.prototype.trim=function(a,b){a.set_string(cr.is_string(b)?b.trim():"")};e.prototype.pi=function(a){a.set_float(cr.PI)};e.prototype.layoutname=function(a){this.runtime.running_layout?a.set_string(this.runtime.running_layout.name):a.set_string("")};e.prototype.renderer=function(a){a.set_string(this.runtime.gl?"webgl":"canvas2d")};e.prototype.anglediff=function(a,b,c){a.set_float(cr.to_degrees(cr.angleDiff(cr.to_radians(b),
cr.to_radians(c))))};e.prototype.choose=function(a){var b=cr.floor(Math.random()*(arguments.length-1));a.set_any(arguments[b+1])};e.prototype.rgb=function(a,b,c,d){a.set_int(cr.RGB(b,c,d))};e.prototype.projectversion=function(a){a.set_string(this.runtime.versionstr)};e.prototype.anglelerp=function(a,b,c,d){b=cr.to_radians(b);c=cr.to_radians(c);var e=cr.angleDiff(b,c);cr.angleClockwise(c,b)?a.set_float(cr.to_clamped_degrees(b+e*d)):a.set_float(cr.to_clamped_degrees(b-e*d))};e.prototype.anglerotate=
function(a,b,c,d){b=cr.to_radians(b);c=cr.to_radians(c);d=cr.to_radians(d);a.set_float(cr.to_clamped_degrees(cr.angleRotate(b,c,d)))};e.prototype.zeropad=function(a,b,c){var d=0>b?"-":"";0>b&&(b=-b);c-=b.toString().length;for(var e=0;e<c;e++)d+="0";a.set_string(d+b.toString())};e.prototype.cpuutilisation=function(a){a.set_float(this.runtime.cpuutilisation/1E3)};e.prototype.viewportleft=function(a,b){var c=this.runtime.getLayer(b);a.set_float(c?c.viewLeft:0)};e.prototype.viewporttop=function(a,b){var c=
this.runtime.getLayer(b);a.set_float(c?c.viewTop:0)};e.prototype.viewportright=function(a,b){var c=this.runtime.getLayer(b);a.set_float(c?c.viewRight:0)};e.prototype.viewportbottom=function(a,b){var c=this.runtime.getLayer(b);a.set_float(c?c.viewBottom:0)};e.prototype.loadingprogress=function(a){a.set_float(this.runtime.loadingprogress)};e.prototype.unlerp=function(a,b,c,d){a.set_float((d-b)/(c-b))};e.prototype.canvassnapshot=function(a){a.set_string(this.runtime.snapshotData)};e.prototype.urlencode=
function(a,b){a.set_string(encodeURIComponent(b))};e.prototype.urldecode=function(a,b){a.set_string(decodeURIComponent(b))};e.prototype.canvastolayerx=function(a,b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.canvasToLayer(c,d,!0):0)};e.prototype.canvastolayery=function(a,b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.canvasToLayer(c,d,!1):0)};e.prototype.layertocanvasx=function(a,b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.layerToCanvas(c,d,!0):0)};e.prototype.layertocanvasy=function(a,
b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.layerToCanvas(c,d,!1):0)};e.prototype.savestatejson=function(a){a.set_string(this.runtime.lastSaveJson)};e.prototype.imagememoryusage=function(a){this.runtime.glwrap?a.set_float(Math.round(100*this.runtime.glwrap.estimateVRAM()/1048576)/100):a.set_float(0)};e.prototype.regexsearch=function(a,b,d,e){d=c(d,e);a.set_int(b?b.search(d):-1)};e.prototype.regexreplace=function(a,b,d,e,f){d=c(d,e);a.set_string(b?b.replace(d,f):"")};var s=[],w="",x="",C="";
e.prototype.regexmatchcount=function(a,b,d,e){c(d,e);f(b,d,e);a.set_int(s?s.length:0)};e.prototype.regexmatchat=function(a,b,d,e,g){g=Math.floor(g);c(d,e);f(b,d,e);!s||0>g||g>=s.length?a.set_string(""):a.set_string(s[g])};e.prototype.infinity=function(a){a.set_float(Infinity)};g.exps=new e;g.runWaits=function(){var a,b,c,d,e,f,g=this.runtime.getCurrentEventStack();a=0;for(c=this.waits.length;a<c;a++)if(d=this.waits[a],!(d.time>this.runtime.kahanTime.sum)){g.current_event=d.ev;g.actindex=d.actindex;
g.cndindex=0;for(b in d.sols)d.sols.hasOwnProperty(b)&&(e=this.runtime.types_by_index[parseInt(b,10)].getCurrentSol(),f=d.sols[b],e.select_all=f.sa,cr.shallowAssignArray(e.instances,f.insts),e=f,e.insts.length=0,r.push(e));d.ev.resume_actions_and_subevents();this.runtime.clearSol(d.solModifiers);d.deleteme=!0}b=a=0;for(c=this.waits.length;a<c;a++)d=this.waits[a],this.waits[b]=d,d.deleteme?(cr.wipe(d.sols),d.solModifiers.length=0,p.push(d)):b++;this.waits.length=b}})();
cr.add_common_aces=function(a){var b=a[0].prototype,c=a[1],d=a[3],e=a[4],f=a[5],g=a[6],h=a[7];a=a[8];b.cnds||(b.cnds={});b.acts||(b.acts={});b.exps||(b.exps={});var l=b.cnds,k=b.acts,b=b.exps;d&&(l.CompareX=function(a,b){return cr.do_cmp(this.x,a,b)},l.CompareY=function(a,b){return cr.do_cmp(this.y,a,b)},l.IsOnScreen=function(){var a=this.layer;this.update_bbox();var b=this.bbox;return!(b.right<a.viewLeft||b.bottom<a.viewTop||b.left>a.viewRight||b.top>a.viewBottom)},l.IsOutsideLayout=function(){this.update_bbox();
var a=this.bbox,b=this.runtime.running_layout;return 0>a.right||0>a.bottom||a.left>b.width||a.top>b.height},l.PickDistance=function(a,b,c){var d=this.getCurrentSol(),e=d.getObjects();if(!e.length)return!1;var f=e[0],g=f,k=cr.distanceTo(f.x,f.y,b,c),h,l,I;h=1;for(l=e.length;h<l;h++)if(f=e[h],I=cr.distanceTo(f.x,f.y,b,c),0===a&&I<k||1===a&&I>k)k=I,g=f;d.pick_one(g);return!0},k.SetX=function(a){this.x!==a&&(this.x=a,this.set_bbox_changed())},k.SetY=function(a){this.y!==a&&(this.y=a,this.set_bbox_changed())},
k.SetPos=function(a,b){if(this.x!==a||this.y!==b)this.x=a,this.y=b,this.set_bbox_changed()},k.SetPosToObject=function(a,b){var c=a.getPairedInstance(this);if(c){var d;c.getImagePoint?(d=c.getImagePoint(b,!0),c=c.getImagePoint(b,!1)):(d=c.x,c=c.y);if(this.x!==d||this.y!==c)this.x=d,this.y=c,this.set_bbox_changed()}},k.MoveForward=function(a){0!==a&&(this.x+=Math.cos(this.angle)*a,this.y+=Math.sin(this.angle)*a,this.set_bbox_changed())},k.MoveAtAngle=function(a,b){0!==b&&(this.x+=Math.cos(cr.to_radians(a))*
b,this.y+=Math.sin(cr.to_radians(a))*b,this.set_bbox_changed())},b.X=function(a){a.set_float(this.x)},b.Y=function(a){a.set_float(this.y)},b.dt=function(a){a.set_float(this.runtime.getDt(this))});e&&(l.CompareWidth=function(a,b){return cr.do_cmp(this.width,a,b)},l.CompareHeight=function(a,b){return cr.do_cmp(this.height,a,b)},k.SetWidth=function(a){this.width!==a&&(this.width=a,this.set_bbox_changed())},k.SetHeight=function(a){this.height!==a&&(this.height=a,this.set_bbox_changed())},k.SetSize=function(a,
b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.set_bbox_changed()},b.Width=function(a){a.set_float(this.width)},b.Height=function(a){a.set_float(this.height)},b.BBoxLeft=function(a){this.update_bbox();a.set_float(this.bbox.left)},b.BBoxTop=function(a){this.update_bbox();a.set_float(this.bbox.top)},b.BBoxRight=function(a){this.update_bbox();a.set_float(this.bbox.right)},b.BBoxBottom=function(a){this.update_bbox();a.set_float(this.bbox.bottom)});f&&(l.AngleWithin=function(a,b){return cr.angleDiff(this.angle,
cr.to_radians(b))<=cr.to_radians(a)},l.IsClockwiseFrom=function(a){return cr.angleClockwise(this.angle,cr.to_radians(a))},l.IsBetweenAngles=function(a,b){var c=cr.to_clamped_radians(a),d=cr.to_clamped_radians(b),e=cr.clamp_angle(this.angle);return cr.angleClockwise(d,c)?cr.angleClockwise(e,c)&&!cr.angleClockwise(e,d):!(!cr.angleClockwise(e,c)&&cr.angleClockwise(e,d))},k.SetAngle=function(a){a=cr.to_radians(cr.clamp_angle_degrees(a));isNaN(a)||this.angle===a||(this.angle=a,this.set_bbox_changed())},
k.RotateClockwise=function(a){0===a||isNaN(a)||(this.angle+=cr.to_radians(a),this.angle=cr.clamp_angle(this.angle),this.set_bbox_changed())},k.RotateCounterclockwise=function(a){0===a||isNaN(a)||(this.angle-=cr.to_radians(a),this.angle=cr.clamp_angle(this.angle),this.set_bbox_changed())},k.RotateTowardAngle=function(a,b){var c=cr.angleRotate(this.angle,cr.to_radians(b),cr.to_radians(a));isNaN(c)||this.angle===c||(this.angle=c,this.set_bbox_changed())},k.RotateTowardPosition=function(a,b,c){b=Math.atan2(c-
this.y,b-this.x);a=cr.angleRotate(this.angle,b,cr.to_radians(a));isNaN(a)||this.angle===a||(this.angle=a,this.set_bbox_changed())},k.SetTowardPosition=function(a,b){var c=Math.atan2(b-this.y,a-this.x);isNaN(c)||this.angle===c||(this.angle=c,this.set_bbox_changed())},b.Angle=function(a){a.set_float(cr.to_clamped_degrees(this.angle))});c||(l.CompareInstanceVar=function(a,b,c){return cr.do_cmp(this.instance_vars[a],b,c)},l.IsBoolInstanceVarSet=function(a){return this.instance_vars[a]},l.PickInstVarHiLow=
function(a,b){var c=this.getCurrentSol(),d=c.getObjects();if(!d.length)return!1;var e=d[0],f=e,g=e.instance_vars[b],k,h,l;k=1;for(h=d.length;k<h;k++)if(e=d[k],l=e.instance_vars[b],0===a&&l<g||1===a&&l>g)g=l,f=e;c.pick_one(f);return!0},l.PickByUID=function(a){var b,c,d,e,f;if(this.runtime.getCurrentCondition().inverted){f=this.getCurrentSol();if(f.select_all)for(f.select_all=!1,f.instances.length=0,f.else_instances.length=0,d=this.instances,b=0,c=d.length;b<c;b++)e=d[b],e.uid===a?f.else_instances.push(e):
f.instances.push(e);else{d=b=0;for(c=f.instances.length;b<c;b++)e=f.instances[b],f.instances[d]=e,e.uid===a?f.else_instances.push(e):d++;f.instances.length=d}return!!f.instances.length}e=this.runtime.getObjectByUID(a);if(!e)return!1;f=this.getCurrentSol();if(!f.select_all&&-1===f.instances.indexOf(e))return!1;if(this.is_family)for(a=e.type.families,b=0,c=a.length;b<c;b++){if(a[b]===this)return f.pick_one(e),!0}else if(e.type===this)return f.pick_one(e),!0;return!1},l.OnCreated=function(){return!0},
l.OnDestroyed=function(){return!0},k.SetInstanceVar=function(a,b){var c=this.instance_vars;cr.is_number(c[a])?cr.is_number(b)?c[a]=b:c[a]=parseFloat(b):cr.is_string(c[a])&&(cr.is_string(b)?c[a]=b:c[a]=b.toString())},k.AddInstanceVar=function(a,b){var c=this.instance_vars;cr.is_number(c[a])?cr.is_number(b)?c[a]+=b:c[a]+=parseFloat(b):cr.is_string(c[a])&&(cr.is_string(b)?c[a]+=b:c[a]+=b.toString())},k.SubInstanceVar=function(a,b){var c=this.instance_vars;cr.is_number(c[a])&&(cr.is_number(b)?c[a]-=b:
c[a]-=parseFloat(b))},k.SetBoolInstanceVar=function(a,b){this.instance_vars[a]=b?1:0},k.ToggleBoolInstanceVar=function(a){this.instance_vars[a]=1-this.instance_vars[a]},k.Destroy=function(){this.runtime.DestroyInstance(this)},b.Count=function(a){var b=a.object_class.instances.length,c,d,e;c=0;for(d=this.runtime.createRow.length;c<d;c++)e=this.runtime.createRow[c],a.object_class.is_family?0<=e.type.families.indexOf(a.object_class)&&b++:e.type===a.object_class&&b++;a.set_int(b)},b.PickedCount=function(a){a.set_int(a.object_class.getCurrentSol().getObjects().length)},
b.UID=function(a){a.set_int(this.uid)},b.IID=function(a){a.set_int(this.get_iid())});g&&(l.IsVisible=function(){return this.visible},k.SetVisible=function(a){!a!==!this.visible&&(this.visible=a,this.runtime.redraw=!0)},l.CompareOpacity=function(a,b){return cr.do_cmp(cr.round6dp(100*this.opacity),a,b)},k.SetOpacity=function(a){a/=100;0>a?a=0:1<a&&(a=1);a!==this.opacity&&(this.opacity=a,this.runtime.redraw=!0)},b.Opacity=function(a){a.set_float(cr.round6dp(100*this.opacity))});h&&(l.IsOnLayer=function(a){return a?
this.layer===a:!1},l.PickTopBottom=function(a){var b=this.getCurrentSol(),c=b.getObjects();if(!c.length)return!1;var d=c[0],e=d,f,g;f=1;for(g=c.length;f<g;f++)if(d=c[f],0===a){if(d.layer.index>e.layer.index||d.layer.index===e.layer.index&&d.get_zindex()>e.get_zindex())e=d}else if(d.layer.index<e.layer.index||d.layer.index===e.layer.index&&d.get_zindex()<e.get_zindex())e=d;b.pick_one(e);return!0},k.MoveToTop=function(){var a=this.get_zindex();a!==this.layer.instances.length-1&&(cr.arrayRemove(this.layer.instances,
a),this.layer.instances.push(this),this.runtime.redraw=!0,this.layer.zindices_stale=!0)},k.MoveToBottom=function(){var a=this.get_zindex();0!==a&&(cr.arrayRemove(this.layer.instances,a),this.layer.instances.unshift(this),this.runtime.redraw=!0,this.layer.zindices_stale=!0)},k.MoveToLayer=function(a){a&&a!=this.layer&&(cr.arrayRemove(this.layer.instances,this.get_zindex()),this.layer.zindices_stale=!0,this.layer=a,this.zindex=a.instances.length,a.instances.push(this),this.runtime.redraw=!0)},k.ZMoveToObject=
function(a,b){var c=0===a;if(b){var d=b.getFirstPicked(this);if(d&&d.uid!==this.uid){this.layer.index!==d.layer.index&&(cr.arrayRemove(this.layer.instances,this.get_zindex()),this.layer.zindices_stale=!0,this.layer=d.layer,this.zindex=d.layer.instances.length,d.layer.instances.push(this));var e=this.get_zindex(),d=d.get_zindex();cr.arrayRemove(this.layer.instances,e);e<d&&d--;c&&d++;d===this.layer.instances.length?this.layer.instances.push(this):this.layer.instances.splice(d,0,this);this.layer.zindices_stale=
!0;this.runtime.redraw=!0}}},b.LayerNumber=function(a){a.set_int(this.layer.number)},b.LayerName=function(a){a.set_string(this.layer.name)},b.ZIndex=function(a){a.set_int(this.get_zindex())});a&&(k.SetEffectEnabled=function(a,b){if(this.runtime.glwrap){var c=this.type.getEffectIndexByName(b);if(!(0>c)){var d=1===a;this.active_effect_flags[c]!==d&&(this.active_effect_flags[c]=d,this.updateActiveEffects(),this.runtime.redraw=!0)}}},k.SetEffectParam=function(a,b,c){if(this.runtime.glwrap){var d=this.type.getEffectIndexByName(a);
0>d||(a=this.type.effect_types[d],d=this.effect_params[d],b=Math.floor(b),0>b||b>=d.length||(1===this.runtime.glwrap.getProgramParameterType(a.shaderindex,b)&&(c/=100),d[b]!==c&&(d[b]=c,a.active&&(this.runtime.redraw=!0))))}})};cr.set_bbox_changed=function(){this.bbox_changed=!0;this.runtime.redraw=!0;var a,b;a=0;for(b=this.bbox_changed_callbacks.length;a<b;a++)this.bbox_changed_callbacks[a](this)};cr.add_bbox_changed_callback=function(a){a&&this.bbox_changed_callbacks.push(a)};
cr.update_bbox=function(){if(this.bbox_changed){this.bbox.set(this.x,this.y,this.x+this.width,this.y+this.height);this.bbox.offset(-this.hotspotX*this.width,-this.hotspotY*this.height);this.angle?(this.bbox.offset(-this.x,-this.y),this.bquad.set_from_rotated_rect(this.bbox,this.angle),this.bquad.offset(this.x,this.y),this.bquad.bounding_box(this.bbox)):this.bquad.set_from_rect(this.bbox);var a=0;this.bbox.left>this.bbox.right&&(a=this.bbox.left,this.bbox.left=this.bbox.right,this.bbox.right=a);this.bbox.top>
this.bbox.bottom&&(a=this.bbox.top,this.bbox.top=this.bbox.bottom,this.bbox.bottom=a);this.bbox_changed=!1}};cr.inst_contains_pt=function(a,b){return this.bbox.contains_pt(a,b)&&this.bquad.contains_pt(a,b)?this.collision_poly&&!this.collision_poly.is_empty()?(this.collision_poly.cache_poly(this.width,this.height,this.angle),this.collision_poly.contains_pt(a-this.x,b-this.y)):!0:!1};cr.inst_get_iid=function(){this.type.updateIIDs();return this.iid};
cr.inst_get_zindex=function(){this.layer.updateZIndices();return this.zindex};cr.inst_updateActiveEffects=function(){this.active_effect_types.length=0;var a,b;a=0;for(b=this.active_effect_flags.length;a<b;a++)this.active_effect_flags[a]&&this.active_effect_types.push(this.type.effect_types[a]);this.uses_shaders=!!this.active_effect_types.length};cr.inst_toString=function(){return"Inst"+this.puid};
cr.type_getFirstPicked=function(a){if(a&&a.is_contained&&a.type!=this){var b,c,d;b=0;for(c=a.siblings.length;b<c;b++)if(d=a.siblings[b],d.type==this)return d}a=this.getCurrentSol().getObjects();return a.length?a[0]:null};cr.type_getPairedInstance=function(a){var b=this.getCurrentSol().getObjects();return b.length?b[a.get_iid()%b.length]:null};
cr.type_updateIIDs=function(){if(this.stale_iids&&!this.is_family){var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].iid=a;var c=a,d=this.runtime.createRow;a=0;for(b=d.length;a<b;++a)d[a].type===this&&(d[a].iid=c++);this.stale_iids=!1}};cr.type_getCurrentSol=function(){return this.solstack[this.cur_sol]};cr.type_pushCleanSol=function(){this.cur_sol++;this.cur_sol===this.solstack.length?this.solstack.push(new cr.selection(this)):this.solstack[this.cur_sol].select_all=!0};
cr.type_pushCopySol=function(){this.cur_sol++;this.cur_sol===this.solstack.length&&this.solstack.push(new cr.selection(this));var a=this.solstack[this.cur_sol],b=this.solstack[this.cur_sol-1];b.select_all?a.select_all=!0:(a.select_all=!1,cr.shallowAssignArray(a.instances,b.instances),cr.shallowAssignArray(a.else_instances,b.else_instances))};cr.type_popSol=function(){this.cur_sol--};
cr.type_getBehaviorByName=function(a){var b,c,d,e,f,g=0;if(!this.is_family)for(b=0,c=this.families.length;b<c;b++)for(f=this.families[b],d=0,e=f.behaviors.length;d<e;d++){if(a===f.behaviors[d].name)return this.extra.lastBehIndex=g,f.behaviors[d];g++}b=0;for(c=this.behaviors.length;b<c;b++){if(a===this.behaviors[b].name)return this.extra.lastBehIndex=g,this.behaviors[b];g++}return null};cr.type_getBehaviorIndexByName=function(a){return this.getBehaviorByName(a)?this.extra.lastBehIndex:-1};
cr.type_getEffectIndexByName=function(a){var b,c;b=0;for(c=this.effect_types.length;b<c;b++)if(this.effect_types[b].name===a)return b;return-1};
cr.type_applySolToContainer=function(){if(this.is_contained&&!this.is_family){var a,b,c,d,e,f,g;this.updateIIDs();f=this.getCurrentSol();var h=f.select_all,l=(a=this.runtime.getCurrentEventStack())&&a.current_event&&a.current_event.orblock;a=0;for(b=this.container.length;a<b;a++)if(e=this.container[a],e!==this&&(e.updateIIDs(),g=e.getCurrentSol(),g.select_all=h,!h)){g.instances.length=f.instances.length;c=0;for(d=f.instances.length;c<d;c++)g.instances[c]=e.instances[f.instances[c].iid];if(l)for(g.else_instances.length=
f.else_instances.length,c=0,d=f.else_instances.length;c<d;c++)g.else_instances[c]=e.instances[f.else_instances[c].iid]}}};cr.type_toString=function(){return"Type"+this.sid};cr.do_cmp=function(a,b,c){if("undefined"===typeof a||"undefined"===typeof c)return!1;switch(b){case 0:return a===c;case 1:return a!==c;case 2:return a<c;case 3:return a<=c;case 4:return a>c;case 5:return a>=c;default:return!1}};cr.shaders={};window.cr_cjs_accelerated_physics=!0;cr.plugins_.Audio=function(a){this.runtime=a};
(function(){function a(a){a=Math.pow(10,a/20);0>a&&(a=0);1<a&&(a=1);return a}function b(a){0>a&&(a=0);1<a&&(a=1);return 20*(Math.log(a)/Math.log(10))}function c(a){a=a.toLowerCase();return O.hasOwnProperty(a)&&O[a].length?O[a][0].getInputNode():J.destination}function d(){return J.createGain?J.createGain():J.createGainNode()}function e(a){return J.createDelay?J.createDelay(a):J.createDelayNode(a)}function f(a){a.start?a.start(0):a.noteOn(0)}function g(a,b,c){a.start?a.start(0,b):a.noteGrainOn(0,b,
c-b)}function h(a){try{a.stop?a.stop(0):a.noteOff(0)}catch(b){}}function l(a,b,c,d){if(a)if(a.cancelScheduledValues(0),0===d)a.value=b;else{var e=J.currentTime;d+=e;switch(c){case 0:a.setValueAtTime(b,d);break;case 1:a.setValueAtTime(a.value,e);a.linearRampToValueAtTime(b,d);break;case 2:a.setValueAtTime(a.value,e),a.exponentialRampToValueAtTime(b,d)}}}function k(a,b,c,e,f,g){this.type="filter";this.params=[a,b,c,e,f,g];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=g;this.dryNode=d();
this.dryNode.gain.value=1-g;this.filterNode=J.createBiquadFilter();this.filterNode.type="number"===typeof this.filterNode.type?a:ja[a];this.filterNode.frequency.value=b;this.filterNode.detune&&(this.filterNode.detune.value=c);this.filterNode.Q.value=e;this.filterNode.gain.value=f;this.inputNode.connect(this.filterNode);this.inputNode.connect(this.dryNode);this.filterNode.connect(this.wetNode)}function m(a,b,c){this.type="delay";this.params=[a,b,c];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=
c;this.dryNode=d();this.dryNode.gain.value=1-c;this.mainNode=d();this.delayNode=e(a);this.delayNode.delayTime.value=a;this.delayGainNode=d();this.delayGainNode.gain.value=b;this.inputNode.connect(this.mainNode);this.inputNode.connect(this.dryNode);this.mainNode.connect(this.wetNode);this.mainNode.connect(this.delayNode);this.delayNode.connect(this.delayGainNode);this.delayGainNode.connect(this.mainNode)}function n(a,b,c,e){this.type="convolve";this.params=[b,c,e];this.inputNode=d();this.wetNode=d();
this.wetNode.gain.value=c;this.dryNode=d();this.dryNode.gain.value=1-c;this.convolveNode=J.createConvolver();a&&(this.convolveNode.normalize=b,this.convolveNode.buffer=a);this.inputNode.connect(this.convolveNode);this.inputNode.connect(this.dryNode);this.convolveNode.connect(this.wetNode)}function q(a,b,c,g,k){this.type="flanger";this.params=[a,b,c,g,k];this.inputNode=d();this.dryNode=d();this.dryNode.gain.value=1-k/2;this.wetNode=d();this.wetNode.gain.value=k/2;this.feedbackNode=d();this.feedbackNode.gain.value=
g;this.delayNode=e(a+b);this.delayNode.delayTime.value=a;this.oscNode=J.createOscillator();this.oscNode.frequency.value=c;this.oscGainNode=d();this.oscGainNode.gain.value=b;this.inputNode.connect(this.delayNode);this.inputNode.connect(this.dryNode);this.delayNode.connect(this.wetNode);this.delayNode.connect(this.feedbackNode);this.feedbackNode.connect(this.delayNode);this.oscNode.connect(this.oscGainNode);this.oscGainNode.connect(this.delayNode.delayTime);f(this.oscNode)}function p(a,b,c,e,g,k){this.type=
"phaser";this.params=[a,b,c,e,g,k];this.inputNode=d();this.dryNode=d();this.dryNode.gain.value=1-k/2;this.wetNode=d();this.wetNode.gain.value=k/2;this.filterNode=J.createBiquadFilter();this.filterNode.type="number"===typeof this.filterNode.type?7:"allpass";this.filterNode.frequency.value=a;this.filterNode.detune&&(this.filterNode.detune.value=b);this.filterNode.Q.value=c;this.oscNode=J.createOscillator();this.oscNode.frequency.value=g;this.oscGainNode=d();this.oscGainNode.gain.value=e;this.inputNode.connect(this.filterNode);
this.inputNode.connect(this.dryNode);this.filterNode.connect(this.wetNode);this.oscNode.connect(this.oscGainNode);this.oscGainNode.connect(this.filterNode.frequency);f(this.oscNode)}function r(a){this.type="gain";this.params=[a];this.node=d();this.node.gain.value=a}function s(a,b){this.type="tremolo";this.params=[a,b];this.node=d();this.node.gain.value=1-b/2;this.oscNode=J.createOscillator();this.oscNode.frequency.value=a;this.oscGainNode=d();this.oscGainNode.gain.value=b/2;this.oscNode.connect(this.oscGainNode);
this.oscGainNode.connect(this.node.gain);f(this.oscNode)}function w(a,b){this.type="ringmod";this.params=[a,b];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=b;this.dryNode=d();this.dryNode.gain.value=1-b;this.ringNode=d();this.ringNode.gain.value=0;this.oscNode=J.createOscillator();this.oscNode.frequency.value=a;this.oscNode.connect(this.ringNode.gain);f(this.oscNode);this.inputNode.connect(this.ringNode);this.inputNode.connect(this.dryNode);this.ringNode.connect(this.wetNode)}function x(a,
b,c,e,f){this.type="distortion";this.params=[a,b,c,e,f];this.inputNode=d();this.preGain=d();this.postGain=d();this.setDrive(c,Math.pow(10,e/20));this.wetNode=d();this.wetNode.gain.value=f;this.dryNode=d();this.dryNode.gain.value=1-f;this.waveShaper=J.createWaveShaper();this.curve=new Float32Array(65536);this.generateColortouchCurve(a,b);this.waveShaper.curve=this.curve;this.inputNode.connect(this.preGain);this.inputNode.connect(this.dryNode);this.preGain.connect(this.waveShaper);this.waveShaper.connect(this.postGain);
this.postGain.connect(this.wetNode)}function C(a,b,c,d,e){this.type="compressor";this.params=[a,b,c,d,e];this.node=J.createDynamicsCompressor();this.node.threshold.value=a;this.node.knee.value=b;this.node.ratio.value=c;this.node.attack.value=d;this.node.release.value=e}function F(a,b){this.type="analyser";this.params=[a,b];this.node=J.createAnalyser();this.node.fftSize=a;this.node.smoothingTimeConstant=b;this.freqBins=new Float32Array(this.node.frequencyBinCount);this.signal=new Uint8Array(a);this.rms=
this.peak=0}function I(){this.obj=null;this.loadUid=0;this.speeds=[];this.moveAngle=this.lastY=this.lastX=0}function D(a,b){this.src=a;this.myapi=L;this.is_music=b;this.added_end_listener=!1;var c=this;this.mediaSourceNode=this.outNode=null;this.panWhenReady=[];this.seekWhenReady=0;this.pauseWhenReady=!1;L!==G||!b||N.isMobile||N.isNodeWebkit||(this.myapi=Q,this.outNode=d());this.audioData=this.bufferObject=null;var e;switch(this.myapi){case Q:this.bufferObject=new Audio;L===G&&J.createMediaElementSource&&
this.bufferObject.addEventListener("canplay",function(){c.mediaSourceNode=J.createMediaElementSource(c.bufferObject);c.mediaSourceNode.connect(c.outNode)});this.bufferObject.autoplay=!1;this.bufferObject.preload="auto";this.bufferObject.src=a;break;case G:e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType="arraybuffer";e.onload=function(){c.audioData=e.response;c.decodeAudioBuffer()};e.send();break;case V:this.bufferObject=!0;break;case aa:this.bufferObject=!0}}function v(a,b){var e=this;this.tag=
b;this.stopped=this.fresh=!0;this.src=a.src;this.buffer=a;this.myapi=L;this.is_music=a.is_music;this.playbackRate=1;this.pgended=!0;this.is_paused=this.resume_me=!1;this.resume_position=0;this.is_silent=this.is_muted=this.looping=!1;this.mutevol=this.volume=1;this.startTime=N.kahanTime.sum;this.pannerNode=this.gainNode=null;this.pannerEnabled=!1;this.objectTracker=null;this.panConeOuterGain=this.panConeOuter=this.panConeInner=this.panAngle=this.panY=this.panX=0;this.instanceObject=null;var f=!1;switch(this.myapi){case Q:this.is_music?
(this.instanceObject=a.bufferObject,f=!a.added_end_listener,a.added_end_listener=!0):(this.instanceObject=new Audio,this.instanceObject.autoplay=!1,this.instanceObject.src=a.bufferObject.src,f=!0);f&&this.instanceObject.addEventListener("ended",function(){S=e.tag;e.stopped=!0;N.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded,H)});break;case G:this.gainNode=d();this.gainNode.connect(c(b));this.buffer.myapi===G?a.bufferObject&&(this.instanceObject=J.createBufferSource(),this.instanceObject.buffer=
a.bufferObject,this.instanceObject.connect(this.gainNode)):(this.instanceObject=this.buffer.bufferObject,this.buffer.outNode.connect(this.gainNode));break;case V:this.instanceObject=new window.Media(T+this.src,null,null,function(a){a===window.Media.MEDIA_STOPPED&&(e.pgended=!0,e.stopped=!0,S=e.tag,N.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded,H))});break;case aa:this.instanceObject=!0}}function u(a){P.length=0;if(a.length){var b,c,d;b=0;for(c=M.length;b<c;b++)d=M[b],cr.equals_nocase(a,d.tag)&&
P.push(d)}else R&&!R.hasEnded()&&(P.length=1,P[0]=R)}function z(a){var b,c,d,e,f=J.destination;if(O.hasOwnProperty(a)&&(d=O[a],d.length))for(f=d[0].getInputNode(),b=0,c=d.length;b<c;b++)e=d[b],b+1===c?e.connectTo(J.destination):e.connectTo(d[b+1].getInputNode());u(a);b=0;for(c=P.length;b<c;b++)P[b].reconnect(f);ca&&ga===a&&(ca.disconnect(),ca.connect(f))}function A(a,b){O.hasOwnProperty(a)?O[a].push(b):O[a]=[b];z(a)}function B(){}function t(){}function y(){}function K(a,b){var c=null;O.hasOwnProperty(a)&&
(c=O[a]);return c&&0<=b&&b<c.length&&c[b].freqBins?c[b]:null}var E=cr.plugins_.Audio.prototype;E.Type=function(a){this.plugin=a;this.runtime=a.runtime};E.Type.prototype.onCreate=function(){};var N=null,H=null,S="",T="",Q=0,G=1,V=2,aa=3,L=Q,J=null,da=[],M=[],R=null,W=!1,fa=0,U=!1,X=1,Y=0,Z=0,ha=1,ia=1,ka=10,la=1E4,ma=1,ca=null,ga="",O={},ja="lowpass highpass bandpass lowshelf highshelf peaking notch allpass".split(" ");k.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);
this.dryNode.disconnect();this.dryNode.connect(a)};k.prototype.remove=function(){this.inputNode.disconnect();this.filterNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};k.prototype.getInputNode=function(){return this.inputNode};k.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&(b=0);1<b&&(b=1);this.params[4]=b;l(this.wetNode.gain,b,c,d);l(this.dryNode.gain,1-b,c,d);break;case 1:this.params[0]=b;l(this.filterNode.frequency,b,c,d);break;case 2:this.params[1]=
b;l(this.filterNode.detune,b,c,d);break;case 3:this.params[2]=b;l(this.filterNode.Q,b,c,d);break;case 4:this.params[3]=b,l(this.filterNode.gain,b,c,d)}};m.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};m.prototype.remove=function(){this.inputNode.disconnect();this.mainNode.disconnect();this.delayNode.disconnect();this.delayGainNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};m.prototype.getInputNode=
function(){return this.inputNode};m.prototype.setParam=function(b,c,d,e){switch(b){case 0:c/=100;0>c&&(c=0);1<c&&(c=1);this.params[2]=c;l(this.wetNode.gain,c,d,e);l(this.dryNode.gain,1-c,d,e);break;case 4:this.params[1]=a(c);l(this.delayGainNode.gain,a(c),d,e);break;case 5:this.params[0]=c,l(this.delayNode.delayTime,c,d,e)}};n.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};n.prototype.remove=function(){this.inputNode.disconnect();
this.convolveNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};n.prototype.getInputNode=function(){return this.inputNode};n.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100,0>b&&(b=0),1<b&&(b=1),this.params[1]=b,l(this.wetNode.gain,b,c,d),l(this.dryNode.gain,1-b,c,d)}};q.prototype.connectTo=function(a){this.dryNode.disconnect();this.dryNode.connect(a);this.wetNode.disconnect();this.wetNode.connect(a)};q.prototype.remove=function(){this.inputNode.disconnect();this.delayNode.disconnect();
this.oscNode.disconnect();this.oscGainNode.disconnect();this.dryNode.disconnect();this.wetNode.disconnect();this.feedbackNode.disconnect()};q.prototype.getInputNode=function(){return this.inputNode};q.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&(b=0);1<b&&(b=1);this.params[4]=b;l(this.wetNode.gain,b/2,c,d);l(this.dryNode.gain,1-b/2,c,d);break;case 6:this.params[1]=b/1E3;l(this.oscGainNode.gain,b/1E3,c,d);break;case 7:this.params[2]=b;l(this.oscNode.frequency,b,c,d);break;case 8:this.params[3]=
b/100,l(this.feedbackNode.gain,b/100,c,d)}};p.prototype.connectTo=function(a){this.dryNode.disconnect();this.dryNode.connect(a);this.wetNode.disconnect();this.wetNode.connect(a)};p.prototype.remove=function(){this.inputNode.disconnect();this.filterNode.disconnect();this.oscNode.disconnect();this.oscGainNode.disconnect();this.dryNode.disconnect();this.wetNode.disconnect()};p.prototype.getInputNode=function(){return this.inputNode};p.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&
(b=0);1<b&&(b=1);this.params[5]=b;l(this.wetNode.gain,b/2,c,d);l(this.dryNode.gain,1-b/2,c,d);break;case 1:this.params[0]=b;l(this.filterNode.frequency,b,c,d);break;case 2:this.params[1]=b;l(this.filterNode.detune,b,c,d);break;case 3:this.params[2]=b;l(this.filterNode.Q,b,c,d);break;case 6:this.params[3]=b;l(this.oscGainNode.gain,b,c,d);break;case 7:this.params[4]=b,l(this.oscNode.frequency,b,c,d)}};r.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};r.prototype.remove=
function(){this.node.disconnect()};r.prototype.getInputNode=function(){return this.node};r.prototype.setParam=function(b,c,d,e){switch(b){case 4:this.params[0]=a(c),l(this.node.gain,a(c),d,e)}};s.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};s.prototype.remove=function(){this.oscNode.disconnect();this.oscGainNode.disconnect();this.node.disconnect()};s.prototype.getInputNode=function(){return this.node};s.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>
b&&(b=0);1<b&&(b=1);this.params[1]=b;l(this.node.gain.value,1-b/2,c,d);l(this.oscGainNode.gain.value,b/2,c,d);break;case 7:this.params[0]=b,l(this.oscNode.frequency,b,c,d)}};w.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};w.prototype.remove=function(){this.oscNode.disconnect();this.ringNode.disconnect();this.inputNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};w.prototype.getInputNode=function(){return this.inputNode};
w.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&(b=0);1<b&&(b=1);this.params[1]=b;l(this.wetNode.gain,b,c,d);l(this.dryNode.gain,1-b,c,d);break;case 7:this.params[0]=b,l(this.oscNode.frequency,b,c,d)}};x.prototype.setDrive=function(a,b){0.01>a&&(a=0.01);this.preGain.gain.value=a;this.postGain.gain.value=Math.pow(1/a,0.6)*b};x.prototype.shape=function(a,b,c){var d=1.05*c*b-b;c=0>a?-1:1;a=0>a?-a:a;b=a<b?a:b+d*(1-Math.exp(-(1/d)*(a-b)));return b*c};x.prototype.generateColortouchCurve=
function(a,b){for(var c=Math.pow(10,a/20),d=Math.pow(10,b/20),e=0,f=0;32768>f;++f)e=f/32768,e=this.shape(e,c,d),this.curve[32768+f]=e,this.curve[32768-f-1]=-e};x.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};x.prototype.remove=function(){this.inputNode.disconnect();this.preGain.disconnect();this.waveShaper.disconnect();this.postGain.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};x.prototype.getInputNode=
function(){return this.inputNode};x.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100,0>b&&(b=0),1<b&&(b=1),this.params[4]=b,l(this.wetNode.gain,b,c,d),l(this.dryNode.gain,1-b,c,d)}};C.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};C.prototype.remove=function(){this.node.disconnect()};C.prototype.getInputNode=function(){return this.node};C.prototype.setParam=function(a,b,c,d){};F.prototype.tick=function(){this.node.getFloatFrequencyData(this.freqBins);this.node.getByteTimeDomainData(this.signal);
for(var a=this.node.fftSize,c=0,d=this.peak=0,e=0;c<a;c++)e=(this.signal[c]-128)/128,0>e&&(e=-e),this.peak<e&&(this.peak=e),d+=e*e;this.peak=b(this.peak);this.rms=b(Math.sqrt(d/a))};F.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};F.prototype.remove=function(){this.node.disconnect()};F.prototype.getInputNode=function(){return this.node};F.prototype.setParam=function(a,b,c,d){};I.prototype.setObject=function(a){if(this.obj=a)this.lastX=this.obj.x,this.lastY=this.obj.y;
this.speeds.length=0};I.prototype.hasObject=function(){return!!this.obj};I.prototype.tick=function(a){this.obj&&(this.moveAngle=cr.angleTo(this.lastX,this.lastY,this.obj.x,this.obj.y),a=cr.distanceTo(this.lastX,this.lastY,this.obj.x,this.obj.y)/a,4>this.speeds.length||this.speeds.shift(),this.speeds.push(a),this.lastX=this.obj.x,this.lastY=this.obj.y)};I.prototype.getSpeed=function(){if(!this.speeds.length)return 0;var a,b,c=0;a=0;for(b=this.speeds.length;a<b;a++)c+=this.speeds[a];return c/this.speeds.length};
I.prototype.getVelocityX=function(){return Math.cos(this.moveAngle)*this.getSpeed()};I.prototype.getVelocityY=function(){return Math.sin(this.moveAngle)*this.getSpeed()};var na=!1;D.prototype.decodeAudioBuffer=function(){if(!this.bufferObject&&this.audioData){var a=this;if(J.decodeAudioData)J.decodeAudioData(this.audioData,function(b){a.bufferObject=b;var c,d,e;if(cr.is_undefined(a.playTagWhenReady))cr.is_undefined(a.convolveWhenReady)||(c=a.convolveWhenReady.convolveNode,c.normalize=a.normalizeWhenReady,
c.buffer=b);else if(a.panWhenReady.length){c=0;for(d=a.panWhenReady.length;c<d;c++){b=a.panWhenReady[c];e=new v(a,b.thistag);e.setPannerEnabled(!0);if("undefined"!==typeof b.objUid&&(b.obj=N.getObjectByUID(b.objUid),!b.obj))continue;if(b.obj){var f=cr.rotatePtAround(b.obj.x,b.obj.y,-b.obj.layer.getAngle(),Y,Z,!0),g=cr.rotatePtAround(b.obj.x,b.obj.y,-b.obj.layer.getAngle(),Y,Z,!1);e.setPan(f,g,cr.to_degrees(b.obj.angle-b.obj.layer.getAngle()),b.ia,b.oa,b.og);e.setObject(b.obj)}else e.setPan(b.x,b.y,
b.a,b.ia,b.oa,b.og);e.play(a.loopWhenReady,a.volumeWhenReady,a.seekWhenReady);a.pauseWhenReady&&e.pause();M.push(e)}a.panWhenReady.length=0}else e=new v(a,a.playTagWhenReady),e.play(a.loopWhenReady,a.volumeWhenReady,a.seekWhenReady),a.pauseWhenReady&&e.pause(),M.push(e)});else if(this.bufferObject=J.createBuffer(this.audioData,!1),cr.is_undefined(this.playTagWhenReady))cr.is_undefined(this.convolveWhenReady)||(b=this.convolveWhenReady.convolveNode,b.normalize=this.normalizeWhenReady,b.buffer=this.bufferObject);
else{var b=new v(this,this.playTagWhenReady);b.play(this.loopWhenReady,this.volumeWhenReady,this.seekWhenReady);this.pauseWhenReady&&b.pause();M.push(b)}}};D.prototype.isLoaded=function(){switch(this.myapi){case Q:return 4===this.bufferObject.readyState;case G:return!!this.audioData;case V:return!0;case aa:return!0}return!1};v.prototype.hasEnded=function(){switch(this.myapi){case Q:return this.instanceObject.ended;case G:return this.buffer.myapi===G?!this.fresh&&!this.stopped&&this.instanceObject.loop||
this.is_paused?!1:N.kahanTime.sum-this.startTime>this.buffer.bufferObject.duration:this.instanceObject.ended;case V:return this.pgended;case aa:!0}return!0};v.prototype.canBeRecycled=function(){return this.fresh||this.stopped?!0:this.hasEnded()};v.prototype.setPannerEnabled=function(a){L===G&&(!this.pannerEnabled&&a?(this.pannerNode||(this.pannerNode=J.createPanner(),this.pannerNode.panningModel="number"===typeof this.pannerNode.panningModel?ha:["equalpower","HRTF","soundfield"][ha],this.pannerNode.distanceModel=
"number"===typeof this.pannerNode.distanceModel?ia:["linear","inverse","exponential"][ia],this.pannerNode.refDistance=ka,this.pannerNode.maxDistance=la,this.pannerNode.rolloffFactor=ma),this.gainNode.disconnect(),this.gainNode.connect(this.pannerNode),this.pannerNode.connect(c(this.tag)),this.pannerEnabled=!0):this.pannerEnabled&&!a&&(this.pannerNode.disconnect(),this.gainNode.disconnect(),this.gainNode.connect(c(this.tag)),this.pannerEnabled=!1))};v.prototype.setPan=function(a,b,c,d,e,f){this.pannerEnabled&&
L===G&&(this.pannerNode.setPosition(a,b,0),this.pannerNode.setOrientation(Math.cos(cr.to_radians(c)),Math.sin(cr.to_radians(c)),0),this.pannerNode.coneInnerAngle=d,this.pannerNode.coneOuterAngle=e,this.pannerNode.coneOuterGain=f,this.panX=a,this.panY=b,this.panAngle=c,this.panConeInner=d,this.panConeOuter=e,this.panConeOuterGain=f)};v.prototype.setObject=function(a){this.pannerEnabled&&L===G&&(this.objectTracker||(this.objectTracker=new I),this.objectTracker.setObject(a))};v.prototype.tick=function(a){if(this.pannerEnabled&&
L===G&&this.objectTracker&&this.objectTracker.hasObject()&&this.isPlaying()){this.objectTracker.tick(a);a=this.objectTracker.obj;var b=cr.rotatePtAround(a.x,a.y,-a.layer.getAngle(),Y,Z,!0),c=cr.rotatePtAround(a.x,a.y,-a.layer.getAngle(),Y,Z,!1);this.pannerNode.setPosition(b,c,0);b=0;"undefined"!==typeof this.objectTracker.obj.angle&&(b=a.angle-a.layer.getAngle(),this.pannerNode.setOrientation(Math.cos(b),Math.sin(b),0));this.pannerNode.setVelocity(this.objectTracker.getVelocityX(),this.objectTracker.getVelocityY(),
0)}};v.prototype.play=function(a,b,c){var d=this.instanceObject;this.looping=a;this.volume=b;c=c||0;switch(this.myapi){case Q:1!==d.playbackRate&&(d.playbackRate=1);d.volume!==b*X&&(d.volume=b*X);d.loop!==a&&(d.loop=a);d.muted&&(d.muted=!1);if(d.currentTime!==c)try{d.currentTime=c}catch(e){}this.instanceObject.play();break;case G:this.muted=!1;this.mutevol=1;if(this.buffer.myapi===G)this.fresh||(this.instanceObject=J.createBufferSource(),this.instanceObject.buffer=this.buffer.bufferObject,this.instanceObject.connect(this.gainNode)),
this.instanceObject.loop=a,this.gainNode.gain.value=b*X,0===c?f(this.instanceObject):g(this.instanceObject,c,this.getDuration());else{1!==d.playbackRate&&(d.playbackRate=1);d.loop!==a&&(d.loop=a);this.gainNode.gain.value=b*X;if(d.currentTime!==c)try{d.currentTime=c}catch(k){}d.play()}break;case V:(!this.fresh&&this.stopped||0!==c)&&d.seekTo(c);d.play();this.pgended=!1;break;case aa:N.isDirectCanvas?AppMobi.context.playSound(this.src):AppMobi.player.playSound(this.src)}this.playbackRate=1;this.startTime=
N.kahanTime.sum-c;this.is_paused=this.stopped=this.fresh=!1};v.prototype.stop=function(){switch(this.myapi){case Q:this.instanceObject.paused||this.instanceObject.pause();break;case G:this.buffer.myapi===G?h(this.instanceObject):this.instanceObject.paused||this.instanceObject.pause();break;case V:this.instanceObject.stop()}this.stopped=!0;this.is_paused=!1};v.prototype.pause=function(){if(!(this.fresh||this.stopped||this.hasEnded()||this.is_paused)){switch(this.myapi){case Q:this.instanceObject.paused||
this.instanceObject.pause();break;case G:this.buffer.myapi===G?(this.resume_position=this.getPlaybackTime(),this.looping&&(this.resume_position%=this.getDuration()),h(this.instanceObject)):this.instanceObject.paused||this.instanceObject.pause();break;case V:this.instanceObject.pause()}this.is_paused=!0}};v.prototype.resume=function(){if(!this.fresh&&!this.stopped&&!this.hasEnded()&&this.is_paused){switch(this.myapi){case Q:this.instanceObject.play();break;case G:this.buffer.myapi===G?(this.instanceObject=
J.createBufferSource(),this.instanceObject.buffer=this.buffer.bufferObject,this.instanceObject.connect(this.gainNode),this.instanceObject.loop=this.looping,this.gainNode.gain.value=X*this.volume*this.mutevol,this.startTime=N.kahanTime.sum-this.resume_position,g(this.instanceObject,this.resume_position,this.getDuration())):this.instanceObject.play();break;case V:this.instanceObject.play()}this.is_paused=!1}};v.prototype.seek=function(a){if(!(this.fresh||this.stopped||this.hasEnded()))switch(this.myapi){case Q:try{this.instanceObject.currentTime=
a}catch(b){}break;case G:if(this.buffer.myapi===G)this.is_paused?this.resume_position=a:(this.pause(),this.resume_position=a,this.resume());else try{this.instanceObject.currentTime=a}catch(c){}}};v.prototype.reconnect=function(a){this.myapi===G&&(this.pannerEnabled?(this.pannerNode.disconnect(),this.pannerNode.connect(a)):(this.gainNode.disconnect(),this.gainNode.connect(a)))};v.prototype.getDuration=function(){switch(this.myapi){case Q:if("undefined"!==typeof this.instanceObject.duration)return this.instanceObject.duration;
break;case G:return this.buffer.bufferObject.duration;case V:return this.instanceObject.getDuration()}return 0};v.prototype.getPlaybackTime=function(){var a=this.getDuration(),b=0;switch(this.myapi){case Q:"undefined"!==typeof this.instanceObject.currentTime&&(b=this.instanceObject.currentTime);break;case G:if(this.buffer.myapi===G){if(this.is_paused)return this.resume_position;b=N.kahanTime.sum-this.startTime}else"undefined"!==typeof this.instanceObject.currentTime&&(b=this.instanceObject.currentTime)}!this.looping&&
b>a&&(b=a);return b};v.prototype.isPlaying=function(){return!this.is_paused&&!this.fresh&&!this.stopped&&!this.hasEnded()};v.prototype.setVolume=function(a){this.volume=a;this.updateVolume()};v.prototype.updateVolume=function(){var a=this.volume*X;switch(this.myapi){case Q:this.instanceObject.volume&&this.instanceObject.volume!==a&&(this.instanceObject.volume=a);break;case G:this.gainNode.gain.value=a*this.mutevol}};v.prototype.getVolume=function(){return this.volume};v.prototype.doSetMuted=function(a){switch(this.myapi){case Q:this.instanceObject.muted!==
!!a&&(this.instanceObject.muted=!!a);break;case G:this.mutevol=a?0:1,this.gainNode.gain.value=X*this.volume*this.mutevol}};v.prototype.setMuted=function(a){this.is_muted=!!a;this.doSetMuted(this.is_muted||this.is_silent)};v.prototype.setSilent=function(a){this.is_silent=!!a;this.doSetMuted(this.is_muted||this.is_silent)};v.prototype.setLooping=function(a){this.looping=a;switch(this.myapi){case Q:this.instanceObject.loop!==!!a&&(this.instanceObject.loop=!!a);break;case G:this.instanceObject.loop!==
!!a&&(this.instanceObject.loop=!!a)}};v.prototype.setPlaybackRate=function(a){this.playbackRate=a;this.updatePlaybackRate()};v.prototype.updatePlaybackRate=function(){var a=this.playbackRate;if(1===fa&&!this.is_music||2===fa)a*=N.timescale;switch(this.myapi){case Q:this.instanceObject.playbackRate!==a&&(this.instanceObject.playbackRate=a);break;case G:this.buffer.myapi===G?this.instanceObject.playbackRate.value!==a&&(this.instanceObject.playbackRate.value=a):this.instanceObject.playbackRate!==a&&
(this.instanceObject.playbackRate=a)}};v.prototype.setSuspended=function(a){switch(this.myapi){case Q:a?this.isPlaying()?(this.instanceObject.pause(),this.resume_me=!0):this.resume_me=!1:this.resume_me&&this.instanceObject.play();break;case G:a?this.isPlaying()?(this.buffer.myapi===G?(this.resume_position=this.getPlaybackTime(),this.looping&&(this.resume_position%=this.getDuration()),h(this.instanceObject)):this.instanceObject.pause(),this.resume_me=!0):this.resume_me=!1:this.resume_me&&(this.buffer.myapi===
G?(this.instanceObject=J.createBufferSource(),this.instanceObject.buffer=this.buffer.bufferObject,this.instanceObject.connect(this.gainNode),this.instanceObject.loop=this.looping,this.gainNode.gain.value=X*this.volume*this.mutevol,this.startTime=N.kahanTime.sum-this.resume_position,g(this.instanceObject,this.resume_position,this.getDuration())):this.instanceObject.play());break;case V:a?this.isPlaying()?(this.instanceObject.pause(),this.resume_me=!0):this.resume_me=!1:this.resume_me&&this.instanceObject.play()}};
E.Instance=function(a){this.type=a;N=this.runtime=a.runtime;H=this;this.listenerTracker=null;this.listenerZ=-600;J=null;"undefined"!==typeof AudioContext?(L=G,J=new AudioContext):"undefined"!==typeof webkitAudioContext&&(L=G,J=new webkitAudioContext);this.runtime.isiOS&&L===G&&document.addEventListener("touchstart",function(){if(!na){var a=J.createBuffer(1,1,22050),b=J.createBufferSource();b.buffer=a;b.connect(J.destination);f(b);na=!0}},!0);L!==G&&(this.runtime.isPhoneGap?L=V:this.runtime.isAppMobi&&
(L=aa));L===V&&(T=location.href,a=T.lastIndexOf("/"),-1<a&&(T=T.substr(0,a+1)),T=T.replace("file://",""));if(this.runtime.isSafari&&this.runtime.isWindows&&"undefined"===typeof Audio)alert("It looks like you're using Safari for Windows without Quicktime.  Audio cannot be played until Quicktime is installed."),this.runtime.DestroyInstance(this);else{if(this.runtime.isDirectCanvas)W=this.runtime.isAndroid;else try{W=!!(new Audio).canPlayType('audio/ogg; codecs="vorbis"')}catch(b){W=!1}this.runtime.tickMe(this)}};
var ba=E.Instance.prototype;ba.onCreate=function(){fa=this.properties[0];this.saveload=this.properties[1];ha=this.properties[2];ia=this.properties[3];this.listenerZ=-this.properties[4];ka=this.properties[5];la=this.properties[6];ma=this.properties[7];this.listenerTracker=new I;L===G&&(J.listener.speedOfSound=this.properties[8],J.listener.dopplerFactor=this.properties[9],J.listener.setPosition(this.runtime.width/2,this.runtime.height/2,this.listenerZ),J.listener.setOrientation(0,0,1,0,-1,0),window.c2OnAudioMicStream=
function(a,b){ca&&ca.disconnect();ga=b.toLowerCase();ca=J.createMediaStreamSource(a);ca.connect(c(ga))});this.runtime.addSuspendCallback(function(a){H.onSuspend(a)});var a=this;this.runtime.addDestroyCallback(function(b){a.onInstanceDestroyed(b)})};ba.onInstanceDestroyed=function(a){var b,c,d;b=0;for(c=M.length;b<c;b++)d=M[b],d.objectTracker&&d.objectTracker.obj===a&&(d.objectTracker.obj=null,d.pannerEnabled&&d.isPlaying()&&d.looping&&d.stop());this.listenerTracker.obj===a&&(this.listenerTracker.obj=
null)};ba.saveToJSON=function(){var a={silent:U,masterVolume:X,listenerZ:this.listenerZ,listenerUid:this.listenerTracker.hasObject()?this.listenerTracker.obj.uid:-1,playing:[],effects:{}},b=a.playing,c,d,e,f,g,k;c=0;for(d=M.length;c<d;c++)e=M[c],!e.isPlaying()||3===this.saveload||e.is_music&&1===this.saveload||!e.is_music&&2===this.saveload||(f=e.getPlaybackTime(),e.looping&&(f%=e.getDuration()),f={tag:e.tag,buffersrc:e.buffer.src,is_music:e.is_music,playbackTime:f,volume:e.volume,looping:e.looping,
muted:e.is_muted,playbackRate:e.playbackRate,paused:e.is_paused,resume_position:e.resume_position},e.pannerEnabled&&(f.pan={},k=f.pan,e.objectTracker&&e.objectTracker.hasObject()?k.objUid=e.objectTracker.obj.uid:(k.x=e.panX,k.y=e.panY,k.a=e.panAngle),k.ia=e.panConeInner,k.oa=e.panConeOuter,k.og=e.panConeOuterGain),b.push(f));b=a.effects;for(g in O)if(O.hasOwnProperty(g)){e=[];c=0;for(d=O[g].length;c<d;c++)e.push({type:O[g][c].type,params:O[g][c].params});b[g]=e}return a};var ea=[];ba.loadFromJSON=
function(a){var b=a.silent;X=a.masterVolume;this.listenerZ=a.listenerZ;this.listenerTracker.setObject(null);var c=a.listenerUid;-1!==c&&(this.listenerTracker.loadUid=c,ea.push(this.listenerTracker));var c=a.playing,d,e,f,g,h,l,D,t,v,u,z;if(3!==this.saveload)for(d=0,e=M.length;d<e;d++)v=M[d],v.is_music&&1===this.saveload||(v.is_music||2!==this.saveload)&&v.stop();for(h in O)if(O.hasOwnProperty(h))for(d=0,e=O[h].length;d<e;d++)O[h][d].remove();cr.wipe(O);for(h in a.effects)if(a.effects.hasOwnProperty(h))for(l=
a.effects[h],d=0,e=l.length;d<e;d++)switch(f=l[d].type,u=l[d].params,f){case "filter":A(h,new k(u[0],u[1],u[2],u[3],u[4],u[5]));break;case "delay":A(h,new m(u[0],u[1],u[2]));break;case "convolve":f=u[2];v=this.getAudioBuffer(f,!1);v.bufferObject?f=new n(v.bufferObject,u[0],u[1],f):(f=new n(null,u[0],u[1],f),v.normalizeWhenReady=u[0],v.convolveWhenReady=f);A(h,f);break;case "flanger":A(h,new q(u[0],u[1],u[2],u[3],u[4]));break;case "phaser":A(h,new p(u[0],u[1],u[2],u[3],u[4],u[5]));break;case "gain":A(h,
new r(u[0]));break;case "tremolo":A(h,new s(u[0],u[1]));break;case "ringmod":A(h,new w(u[0],u[1]));break;case "distortion":A(h,new x(u[0],u[1],u[2],u[3],u[4]));break;case "compressor":A(h,new C(u[0],u[1],u[2],u[3],u[4]));break;case "analyser":A(h,new F(u[0],u[1]))}d=0;for(e=c.length;d<e;d++)3===this.saveload||(a=c[d],f=a.buffersrc,g=a.is_music,h=a.tag,l=a.playbackTime,D=a.looping,t=a.volume,z=(u=a.pan)&&u.hasOwnProperty("objUid")?u.objUid:-1,g&&1===this.saveload)||!g&&2===this.saveload||((v=this.getAudioInstance(f,
h,g,D,t))?(v.resume_position=a.resume_position,v.setPannerEnabled(!!u),v.play(D,t,l),v.updatePlaybackRate(),v.updateVolume(),v.doSetMuted(v.is_muted||v.is_silent),a.paused&&v.pause(),a.muted&&v.mute(),u&&(-1!==z?(v.objectTracker=v.objectTracker||new I,v.objectTracker.loadUid=z,ea.push(v.objectTracker)):v.setPan(u.x,u.y,u.a,u.ia,u.oa,u.og))):(v=this.getAudioBuffer(f,g),v.seekWhenReady=l,v.pauseWhenReady=a.paused,u&&(-1!==z?v.panWhenReady.push({objUid:z,ia:u.ia,oa:u.oa,og:u.og,thistag:h}):v.panWhenReady.push({x:u.x,
y:u.y,a:u.a,ia:u.ia,oa:u.oa,og:u.og,thistag:h}))));if(b&&!U){d=0;for(e=M.length;d<e;d++)M[d].setSilent(!0);U=!0}else if(!b&&U){d=0;for(e=M.length;d<e;d++)M[d].setSilent(!1);U=!1}};ba.afterLoad=function(){var a,b,c,d;a=0;for(b=ea.length;a<b;a++)c=ea[a],d=this.runtime.getObjectByUID(c.loadUid),c.setObject(d),c.loadUid=-1,d&&(Y=d.x,Z=d.y);ea.length=0};ba.onSuspend=function(a){var b,c;b=0;for(c=M.length;b<c;b++)M[b].setSuspended(a)};ba.tick=function(){var a=this.runtime.dt,b,c,d;b=0;for(c=M.length;b<
c;b++)d=M[b],d.tick(a),d.myapi===Q||d.myapi===aa||d.fresh||d.stopped||!d.hasEnded()||(d.stopped=!0,S=d.tag,N.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded,H)),0!==fa&&d.updatePlaybackRate();var e,f;for(e in O)if(O.hasOwnProperty(e))for(d=O[e],b=0,c=d.length;b<c;b++)f=d[b],f.tick&&f.tick();L===G&&this.listenerTracker.hasObject()&&(this.listenerTracker.tick(a),Y=this.listenerTracker.obj.x,Z=this.listenerTracker.obj.y,J.listener.setPosition(this.listenerTracker.obj.x,this.listenerTracker.obj.y,this.listenerZ),
J.listener.setVelocity(this.listenerTracker.getVelocityX(),this.listenerTracker.getVelocityY(),0))};ba.getAudioBuffer=function(a,b){var c,d,e,f=null,g,k,h,p;c=0;for(d=da.length;c<d;c++)if(e=da[c],e.src===a){f=e;break}f||(f=new D(a,b),da.push(f));if(f.is_music&&(N.isMobile||N.isNodeWebkit)){c=0;for(d=da.length;c<d;++c)if(e=da[c],e!==f&&e.is_music){e.bufferObject=null;k=g=0;for(h=M.length;g<h;++g)p=M[g],M[k]=p,p.buffer===e&&p.myapi===G?(p.gainNode.disconnect(),e.myapi===G&&p.instanceObject.disconnect()):
++k;M.length=k}f.decodeAudioBuffer()}return f};ba.getAudioInstance=function(a,b,c,d,e){var f,g,k;f=0;for(g=M.length;f<g;f++)if(k=M[f],k.src===a&&(k.canBeRecycled()||c))return k.tag=b,k;a=this.getAudioBuffer(a,c);if(!a.bufferObject)return"<preload>"!==b&&(a.playTagWhenReady=b,a.loopWhenReady=d,a.volumeWhenReady=e),null;k=new v(a,b);M.push(k);return k};var P=[];B.prototype.OnEnded=function(a){return cr.equals_nocase(S,a)};B.prototype.PreloadsComplete=function(){var a,b;a=0;for(b=da.length;a<b;a++)if(!da[a].isLoaded())return!1;
return!0};B.prototype.AdvancedAudioSupported=function(){return L===G};B.prototype.IsSilent=function(){return U};B.prototype.IsAnyPlaying=function(){var a,b;a=0;for(b=M.length;a<b;a++)if(M[a].isPlaying())return!0;return!1};B.prototype.IsTagPlaying=function(a){u(a);var b;a=0;for(b=P.length;a<b;a++)if(P[a].isPlaying())return!0;return!1};E.cnds=new B;t.prototype.Play=function(b,c,d,e){!U&&(d=a(d),R=this.getAudioInstance(this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a"),e,b[1],0!==c,d))&&(R.setPannerEnabled(!1),
R.play(0!==c,d))};t.prototype.PlayAtPosition=function(b,c,d,e,f,g,k,h,p,l){if(!U){d=a(d);var m=b[1];b=this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a");(R=this.getAudioInstance(b,l,m,0!==c,d))?(R.setPannerEnabled(!0),R.setPan(e,f,g,k,h,a(p)),R.play(0!==c,d)):this.getAudioBuffer(b,m).panWhenReady.push({x:e,y:f,a:g,ia:k,oa:h,og:a(p),thistag:l})}};t.prototype.PlayAtObject=function(b,c,d,e,f,g,k,h){if(!U&&e&&(e=e.getFirstPicked())){d=a(d);var p=b[1];b=this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a");
(R=this.getAudioInstance(b,h,p,0!==c,d))?(R.setPannerEnabled(!0),h=cr.rotatePtAround(e.x,e.y,-e.layer.getAngle(),Y,Z,!0),b=cr.rotatePtAround(e.x,e.y,-e.layer.getAngle(),Y,Z,!1),R.setPan(h,b,cr.to_degrees(e.angle-e.layer.getAngle()),f,g,a(k)),R.setObject(e),R.play(0!==c,d)):this.getAudioBuffer(b,p).panWhenReady.push({obj:e,ia:f,oa:g,og:a(k),thistag:h})}};t.prototype.PlayByName=function(b,c,d,e,f){!U&&(e=a(e),b=1===b,c=this.runtime.files_subfolder+c.toLowerCase()+(W?".ogg":".m4a"),R=this.getAudioInstance(c,
f,b,0!==d,e))&&(R.setPannerEnabled(!1),R.play(0!==d,e))};t.prototype.PlayAtPositionByName=function(b,c,d,e,f,g,k,h,p,l,m){U||(e=a(e),b=1===b,c=this.runtime.files_subfolder+c.toLowerCase()+(W?".ogg":".m4a"),(R=this.getAudioInstance(c,m,b,0!==d,e))?(R.setPannerEnabled(!0),R.setPan(f,g,k,h,p,a(l)),R.play(0!==d,e)):this.getAudioBuffer(c,b).panWhenReady.push({x:f,y:g,a:k,ia:h,oa:p,og:a(l),thistag:m}))};t.prototype.PlayAtObjectByName=function(b,c,d,e,f,g,k,h,p){!U&&f&&(f=f.getFirstPicked())&&(e=a(e),b=
1===b,c=this.runtime.files_subfolder+c.toLowerCase()+(W?".ogg":".m4a"),(R=this.getAudioInstance(c,p,b,0!==d,e))?(R.setPannerEnabled(!0),p=cr.rotatePtAround(f.x,f.y,-f.layer.getAngle(),Y,Z,!0),c=cr.rotatePtAround(f.x,f.y,-f.layer.getAngle(),Y,Z,!1),R.setPan(p,c,cr.to_degrees(f.angle-f.layer.getAngle()),g,k,a(h)),R.setObject(f),R.play(0!==d,e)):this.getAudioBuffer(c,b).panWhenReady.push({obj:f,ia:g,oa:k,og:a(h),thistag:p}))};t.prototype.SetLooping=function(a,b){u(a);var c,d;c=0;for(d=P.length;c<d;c++)P[c].setLooping(0===
b)};t.prototype.SetMuted=function(a,b){u(a);var c,d;c=0;for(d=P.length;c<d;c++)P[c].setMuted(0===b)};t.prototype.SetVolume=function(b,c){u(b);var d=a(c),e,f;e=0;for(f=P.length;e<f;e++)P[e].setVolume(d)};t.prototype.Preload=function(a){if(!U){var b=a[1];a=this.runtime.files_subfolder+a[0]+(W?".ogg":".m4a");L===aa?this.runtime.isDirectCanvas?AppMobi.context.loadSound(a):AppMobi.player.loadSound(a):L!==V&&this.getAudioInstance(a,"<preload>",b,!1)}};t.prototype.PreloadByName=function(a,b){if(!U){var c=
1===a,d=this.runtime.files_subfolder+b.toLowerCase()+(W?".ogg":".m4a");L===aa?this.runtime.isDirectCanvas?AppMobi.context.loadSound(d):AppMobi.player.loadSound(d):L!==V&&this.getAudioInstance(d,"<preload>",c,!1)}};t.prototype.SetPlaybackRate=function(a,b){u(a);0>b&&(b=0);var c,d;c=0;for(d=P.length;c<d;c++)P[c].setPlaybackRate(b)};t.prototype.Stop=function(a){u(a);var b;a=0;for(b=P.length;a<b;a++)P[a].stop()};t.prototype.StopAll=function(){var a,b;a=0;for(b=M.length;a<b;a++)M[a].stop()};t.prototype.SetPaused=
function(a,b){u(a);var c,d;c=0;for(d=P.length;c<d;c++)0===b?P[c].pause():P[c].resume()};t.prototype.Seek=function(a,b){u(a);var c,d;c=0;for(d=P.length;c<d;c++)P[c].seek(b)};t.prototype.SetSilent=function(a){var b;2===a&&(a=U?1:0);if(0===a&&!U){a=0;for(b=M.length;a<b;a++)M[a].setSilent(!0);U=!0}else if(1===a&&U){a=0;for(b=M.length;a<b;a++)M[a].setSilent(!1);U=!1}};t.prototype.SetMasterVolume=function(b){X=a(b);var c;b=0;for(c=M.length;b<c;b++)M[b].updateVolume()};t.prototype.AddFilterEffect=function(a,
b,c,d,e,f,g){L!==G||0>b||b>=ja.length||(a=a.toLowerCase(),g/=100,0>g&&(g=0),1<g&&(g=1),A(a,new k(b,c,d,e,f,g)))};t.prototype.AddDelayEffect=function(b,c,d,e){L===G&&(b=b.toLowerCase(),e/=100,0>e&&(e=0),1<e&&(e=1),A(b,new m(c,a(d),e)))};t.prototype.AddFlangerEffect=function(a,b,c,d,e,f){L===G&&(a=a.toLowerCase(),f/=100,0>f&&(f=0),1<f&&(f=1),A(a,new q(b/1E3,c/1E3,d,e/100,f)))};t.prototype.AddPhaserEffect=function(a,b,c,d,e,f,g){L===G&&(a=a.toLowerCase(),g/=100,0>g&&(g=0),1<g&&(g=1),A(a,new p(b,c,d,
e,f,g)))};t.prototype.AddConvolutionEffect=function(a,b,c,d){if(L===G){c=0===c;var e=this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a");b=this.getAudioBuffer(e,!1);a=a.toLowerCase();d/=100;0>d&&(d=0);1<d&&(d=1);b.bufferObject?d=new n(b.bufferObject,c,d,e):(d=new n(null,c,d,e),b.normalizeWhenReady=c,b.convolveWhenReady=d);A(a,d)}};t.prototype.AddGainEffect=function(b,c){L===G&&(b=b.toLowerCase(),A(b,new r(a(c))))};t.prototype.AddMuteEffect=function(a){L===G&&(a=a.toLowerCase(),A(a,new r(0)))};t.prototype.AddTremoloEffect=
function(a,b,c){L===G&&(a=a.toLowerCase(),c/=100,0>c&&(c=0),1<c&&(c=1),A(a,new s(b,c)))};t.prototype.AddRingModEffect=function(a,b,c){L===G&&(a=a.toLowerCase(),c/=100,0>c&&(c=0),1<c&&(c=1),A(a,new w(b,c)))};t.prototype.AddDistortionEffect=function(a,b,c,d,e,f){L===G&&(a=a.toLowerCase(),f/=100,0>f&&(f=0),1<f&&(f=1),A(a,new x(b,c,d,e,f)))};t.prototype.AddCompressorEffect=function(a,b,c,d,e,f){L===G&&(a=a.toLowerCase(),A(a,new C(b,c,d,e/1E3,f/1E3)))};t.prototype.AddAnalyserEffect=function(a,b,c){L===
G&&(a=a.toLowerCase(),A(a,new F(b,c)))};t.prototype.RemoveEffects=function(a){if(L===G){a=a.toLowerCase();var b,c,d;if(O.hasOwnProperty(a)&&(d=O[a],d.length)){b=0;for(c=d.length;b<c;b++)d[b].remove();d.length=0;z(a)}}};t.prototype.SetEffectParameter=function(a,b,c,d,e,f){L===G&&(a=a.toLowerCase(),b=Math.floor(b),O.hasOwnProperty(a)&&(a=O[a],0>b||b>=a.length||a[b].setParam(c,d,e,f)))};t.prototype.SetListenerObject=function(a){a&&L===G&&(a=a.getFirstPicked())&&(this.listenerTracker.setObject(a),Y=a.x,
Z=a.y)};t.prototype.SetListenerZ=function(a){this.listenerZ=a};E.acts=new t;y.prototype.Duration=function(a,b){u(b);P.length?a.set_float(P[0].getDuration()):a.set_float(0)};y.prototype.PlaybackTime=function(a,b){u(b);P.length?a.set_float(P[0].getPlaybackTime()):a.set_float(0)};y.prototype.Volume=function(a,c){u(c);if(P.length){var d=P[0].getVolume();a.set_float(b(d))}else a.set_float(0)};y.prototype.MasterVolume=function(a){a.set_float(X)};y.prototype.EffectCount=function(a,b){b=b.toLowerCase();var c=
null;O.hasOwnProperty(b)&&(c=O[b]);a.set_int(c?c.length:0)};y.prototype.AnalyserFreqBinCount=function(a,b,c){b=b.toLowerCase();c=Math.floor(c);b=K(b,c);a.set_int(b?b.node.frequencyBinCount:0)};y.prototype.AnalyserFreqBinAt=function(a,b,c,d){b=b.toLowerCase();c=Math.floor(c);d=Math.floor(d);(b=K(b,c))?0>d||d>=b.node.frequencyBinCount?a.set_float(0):a.set_float(b.freqBins[d]):a.set_float(0)};y.prototype.AnalyserPeakLevel=function(a,b,c){b=b.toLowerCase();c=Math.floor(c);(b=K(b,c))?a.set_float(b.peak):
a.set_float(0)};y.prototype.AnalyserRMSLevel=function(a,b,c){b=b.toLowerCase();c=Math.floor(c);(b=K(b,c))?a.set_float(b.rms):a.set_float(0)};E.exps=new y})();cr.plugins_.CJSAds=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(){}var d="",e=[],f=0,g=0,h=!1,l=!1,k=!1,m=cr.plugins_.CJSAds.prototype;m.Type=function(a){this.plugin=a;this.runtime=a.runtime};m.Type.prototype.onCreate=function(){};m.Instance=function(a){this.type=a;this.runtime=a.runtime};m.Instance.prototype.onCreate=function(){this.isShowingFullscreen=this.isShowingBanner=!1;this.triggerProduct="";this.socialService=null;this.socialServiceAvailable=!1;this.storeServiceAvailable=this.runtime.isCocoonJs&&"undefined"!==
typeof CocoonJS.Store.nativeExtensionObjectAvailable;this.storeManaged=1!==this.properties[1];this.storeSandboxed=0!==this.properties[2];this.onConsumePurchaseCompleted=this.onConsumePurchaseFailedTransactionId="";var a=this;this.runtime.isCocoonJs&&(CocoonJS.App.onTextDialogFinished.addEventListener(function(b){d=b;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnKeyboardOK,a)}),CocoonJS.App.onTextDialogCancelled.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnKeyboardCancelled,
a)}),CocoonJS.Ad.onBannerShown.addEventListener(function(){a.isShowingBanner=!0;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnBannerShown,a)}),CocoonJS.Ad.onBannerReady.addEventListener(function(){l=!0;h||(CocoonJS.Ad.setBannerLayout(g),CocoonJS.Ad.showBanner())}),CocoonJS.Ad.onFullScreenShown.addEventListener(function(){a.isShowingFullscreen=!0;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnFullscreenShown,a)}),CocoonJS.Ad.onFullScreenHidden.addEventListener(function(){a.isShowingFullscreen=
!1;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnFullscreenHidden,a)}),CocoonJS.Ad.onFullScreenReady.addEventListener(function(){k=!0;preloadFullScreen||CocoonJS.Ad.showFullScreen()}),this.storeServiceAvailable&&(CocoonJS.Store.onProductPurchaseCompleted.addEventListener(function(b){a.triggerProduct=b.productId;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnPurchaseComplete,a);CocoonJS.Store.addPurchase(b);CocoonJS.Store.consumePurchase(b.transactionId,b.productId);CocoonJS.Store.finishPurchase(b.transactionId)}),
CocoonJS.Store.onConsumePurchaseFailed.addEventListener(function(b,c){this.onConsumePurchaseFailedTransactionId=b;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.onConsumePurchaseFailed,a)}),CocoonJS.Store.onConsumePurchaseCompleted.addEventListener(function(b){this.onConsumePurchaseCompleted=b;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.onConsumePurchaseCompleted,a)}),CocoonJS.Store.onProductPurchaseFailed.addEventListener(function(b,c){a.triggerProduct=b;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnPurchaseFail,
a)}),CocoonJS.Store.onProductPurchaseStarted.addEventListener(function(b){a.triggerProduct=b.productId;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnPurchaseStart,a)}),CocoonJS.Store.onProductsFetchStarted.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.onProductsFetchStarted,a)}),CocoonJS.Store.onProductsFetchFailed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.onProductsFetchFailed,a)}),CocoonJS.Store.onProductsFetchCompleted.addEventListener(function(b){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.onProductsFetchCompleted,
a)}),CocoonJS.Store.requestInitialization({managed:this.storeManaged,sandbox:this.storeSandboxed}),CocoonJS.Store.start()),this.socialService=CocoonJS.SocialGaming.GameCenter,this.socialServiceAvailable=!!this.socialService.nativeExtensionObjectAvailable,this.socialService.onRequestLoginSucceed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCLoginSuccess,a)}),this.socialService.onRequestLoginFailed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCLoginFail,
a)}),this.socialService.onLogout.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCLogout,a)}),this.socialService.onRequestUserScoreSucceed.addEventListener(function(b){f=b.score||0;a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCScoreReceived,a)}),this.socialService.onRequestUserScoreFailed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCScoreUnavailable,a)}),this.socialService.onSubmitUserScoreSucceed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCScoreSubmitSuccess,
a)}),this.socialService.onSubmitUserScoreFailed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCScoreSubmitFail,a)}),this.socialService.onLeaderboardViewSucceed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCLeaderboardOpen,a)}),this.socialService.onLeaderboardViewClosed.addEventListener(function(){a.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.OnGCLeaderboardClose,a)}))};a.prototype.IsShowingBanner=function(){return this.isShowingBanner};
a.prototype.IsCocoonJS=function(){return this.runtime.isCocoonJs};a.prototype.OnBannerShown=function(){return!0};a.prototype.OnFullscreenShown=function(){return!0};a.prototype.OnFullscreenHidden=function(){return!0};a.prototype.IsShowingFullscreen=function(){return this.isShowingFullscreen};a.prototype.IsStoreAvailable=function(){return this.runtime.isCocoonJs?this.storeServiceAvailable&&CocoonJS.Store.canPurchase():!1};a.prototype.OnPurchaseStart=function(a){return this.triggerProduct===a};a.prototype.OnPurchaseComplete=
function(a){return this.triggerProduct===a};a.prototype.OnPurchaseFail=function(a){return this.triggerProduct===a};a.prototype.onProductsFetchStarted=function(){return!0};a.prototype.onConsumePurchaseFailed=function(){return!0};a.prototype.onProductsFetchCompleted=function(){return!0};a.prototype.onProductsFetchFailed=function(){return!0};a.prototype.IsProductPurchased=function(a){return this.runtime.isCocoonJs?CocoonJS.Store.isProductPurchased(a):!1};a.prototype.OnKeyboardCancelled=function(){return!0};
a.prototype.OnKeyboardOK=function(){return!0};a.prototype.IsGCAvailable=function(){return this.socialServiceAvailable};a.prototype.IsGCLoggedIn=function(){return this.socialServiceAvailable?this.socialService.isLoggedIn():!1};a.prototype.OnGCLoginSuccess=function(){return!0};a.prototype.OnGCLoginFail=function(){return!0};a.prototype.OnGCLogout=function(){return!0};a.prototype.OnGCScoreReceived=function(){return!0};a.prototype.OnGCScoreUnavailable=function(){return!0};a.prototype.OnGCScoreSubmitSuccess=
function(){return!0};a.prototype.OnGCScoreSubmitFail=function(){return!0};a.prototype.OnGCLeaderboardOpen=function(){return!0};a.prototype.OnGCLeaderboardClose=function(){return!0};m.cnds=new a;b.prototype.ShowBanner=function(a){this.runtime.isCocoonJs&&(g=0===a?CocoonJS.Ad.BannerLayout.TOP_CENTER:CocoonJS.Ad.BannerLayout.BOTTOM_CENTER,h=!1,l?(CocoonJS.Ad.setBannerLayout(g),CocoonJS.Ad.showBanner()):CocoonJS.Ad.preloadBanner())};b.prototype.ShowFullscreen=function(){this.runtime.isCocoonJs&&(k?CocoonJS.Ad.showFullScreen():
CocoonJS.Ad.preloadFullScreen())};b.prototype.HideBanner=function(){this.runtime.isCocoonJs&&(CocoonJS.Ad.hideBanner(),this.isShowingBanner=!1)};b.prototype.PreloadBanner=function(){this.runtime.isCocoonJs&&(h=!0,CocoonJS.Ad.preloadBanner())};b.prototype.PreloadFullscreen=function(){this.runtime.isCocoonJs&&CocoonJS.Ad.preloadFullScreen()};b.prototype.RefreshBanner=function(){this.runtime.isCocoonJs&&CocoonJS.Ad.refreshBanner()};b.prototype.RefreshFullscreen=function(){this.runtime.isCocoonJs&&CocoonJS.Ad.refreshFullScreen()};
b.prototype.Purchase=function(a){this.runtime.isCocoonJs&&CocoonJS.Store.purchaseProduct(a)};b.prototype.fetchProductsFromStore=function(a){this.runtime.isCocoonJs&&CocoonJS.Store.fetchProductsFromStore(a.split(","))};b.prototype.restorePurchases=function(){if(this.runtime.isCocoonJs)return CocoonJS.Store.restorePurchases()};b.prototype.PurchasePreview=function(a){this.runtime.isCocoonJs&&CocoonJS.Store.purchaseProductModalWithPreview(a)};b.prototype.RestorePurchases=function(){this.runtime.isCocoonJs&&
CocoonJS.Store.restorePurchases()};b.prototype.PromptKeyboard=function(a,b,c,d,e,f){this.runtime.isCocoonJs&&CocoonJS.App.showTextDialog(a,b,c,["text","num","phone","email","url"][d],e,f)};b.prototype.UpdateProductsList=function(){this.runtime.isCocoonJs&&CocoonJS.Store.canPurchase()&&(e=CocoonJS.Store.getProducts())};b.prototype.GCLogin=function(){this.socialServiceAvailable&&!this.socialService.isLoggedIn()&&this.socialService.requestLogin()};b.prototype.GCLogout=function(){this.socialServiceAvailable&&
this.socialService.isLoggedIn()&&this.socialService.requestLogout()};b.prototype.GCSubmitScore=function(a,b){this.socialServiceAvailable&&this.socialService.isLoggedIn()&&this.socialService.submitUserScore(a,b)};b.prototype.GCRequestScore=function(a){this.socialServiceAvailable&&this.socialService.isLoggedIn()&&this.socialService.requestUserScore(a)};b.prototype.GCOpenLeaderboard=function(a){this.socialServiceAvailable&&this.socialService.isLoggedIn()&&this.socialService.showLeaderboardView(a)};m.acts=
new b;c.prototype.InputText=function(a){a.set_string(d)};c.prototype.ProductCount=function(a){a.set_int(e.length)};c.prototype.ProductDescription=function(a,b){b=Math.floor(b);0>b||b>=e.length?a.set_string(""):a.set_string(e[b].description)};c.prototype.ProductLocalizedPrice=function(a,b){b=Math.floor(b);0>b||b>=e.length?a.set_string(""):a.set_string(e[b].localizedPrice)};c.prototype.ProductPrice=function(a,b){b=Math.floor(b);0>b||b>=e.length?a.set_string(""):a.set_string(e[b].price)};c.prototype.ProductAlias=
function(a,b){b=Math.floor(b);0>b||b>=e.length?a.set_string(""):a.set_string(e[b].productAlias)};c.prototype.ProductID=function(a,b){b=Math.floor(b);0>b||b>=e.length?a.set_string(""):a.set_string(e[b].productId)};c.prototype.ProductTitle=function(a,b){b=Math.floor(b);0>b||b>=e.length?a.set_string(""):a.set_string(e[b].title)};c.prototype.GameCenterScore=function(a){a.set_float(f)};m.exps=new c})();cr.plugins_.Keyboard=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(a){a=Math.floor(a);switch(a){case 8:return"backspace";case 9:return"tab";case 13:return"enter";case 16:return"shift";case 17:return"control";case 18:return"alt";case 19:return"pause";case 20:return"capslock";case 27:return"esc";case 33:return"pageup";case 34:return"pagedown";case 35:return"end";case 36:return"home";case 37:return"\u2190";case 38:return"\u2191";case 39:return"\u2192";case 40:return"\u2193";case 45:return"insert";case 46:return"del";
case 91:return"left window key";case 92:return"right window key";case 93:return"select";case 96:return"numpad 0";case 97:return"numpad 1";case 98:return"numpad 2";case 99:return"numpad 3";case 100:return"numpad 4";case 101:return"numpad 5";case 102:return"numpad 6";case 103:return"numpad 7";case 104:return"numpad 8";case 105:return"numpad 9";case 106:return"numpad *";case 107:return"numpad +";case 109:return"numpad -";case 110:return"numpad .";case 111:return"numpad /";case 112:return"F1";case 113:return"F2";
case 114:return"F3";case 115:return"F4";case 116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case 120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";case 144:return"numlock";case 145:return"scroll lock";case 186:return";";case 187:return"=";case 188:return",";case 189:return"-";case 190:return".";case 191:return"/";case 192:return"'";case 219:return"[";case 220:return"\\";case 221:return"]";case 222:return"#";case 223:return"`";default:return String.fromCharCode(a)}}
var d=cr.plugins_.Keyboard.prototype;d.Type=function(a){this.plugin=a;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a){this.type=a;this.runtime=a.runtime;this.keyMap=Array(256);this.usedKeys=Array(256);this.triggerKey=0};var e=d.Instance.prototype;e.onCreate=function(){var a=this;this.runtime.isDomFree||(jQuery(document).keydown(function(b){a.onKeyDown(b)}),jQuery(document).keyup(function(b){a.onKeyUp(b)}))};var f=[32,33,34,35,36,37,38,39,40,44];e.onKeyDown=function(a){var b=
!1;window!=window.top&&-1<f.indexOf(a.which)&&(a.preventDefault(),b=!0,a.stopPropagation());if(this.keyMap[a.which])this.usedKeys[a.which]&&!b&&a.preventDefault();else{this.keyMap[a.which]=!0;this.triggerKey=a.which;this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKey,this);var c=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKey,this),d=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCode,this);if(c||d)this.usedKeys[a.which]=!0,b||a.preventDefault()}};e.onKeyUp=
function(a){this.keyMap[a.which]=!1;this.triggerKey=a.which;this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKeyReleased,this);var b=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased,this),c=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCodeReleased,this);if(b||c||this.usedKeys[a.which])this.usedKeys[a.which]=!0,a.preventDefault()};e.saveToJSON=function(){return{triggerKey:this.triggerKey}};e.loadFromJSON=function(a){this.triggerKey=a.triggerKey};
a.prototype.IsKeyDown=function(a){return this.keyMap[a]};a.prototype.OnKey=function(a){return a===this.triggerKey};a.prototype.OnAnyKey=function(a){return!0};a.prototype.OnAnyKeyReleased=function(a){return!0};a.prototype.OnKeyReleased=function(a){return a===this.triggerKey};a.prototype.IsKeyCodeDown=function(a){a=Math.floor(a);return 0>a||a>=this.keyMap.length?!1:this.keyMap[a]};a.prototype.OnKeyCode=function(a){return a===this.triggerKey};a.prototype.OnKeyCodeReleased=function(a){return a===this.triggerKey};
d.cnds=new a;d.acts=new function(){};b.prototype.LastKeyCode=function(a){a.set_int(this.triggerKey)};b.prototype.StringFromKeyCode=function(a,b){a.set_string(c(b))};d.exps=new b})();cr.plugins_.Particles=function(a){this.runtime=a};
(function(){function a(a){this.owner=a;this.active=!1;this.angle=this.speed=this.y=this.x=0;this.opacity=1;this.age=this.gs=this.size=this.grow=0;cr.seal(this)}function b(){}function c(){}function d(){}var e=cr.plugins_.Particles.prototype;e.Type=function(a){this.plugin=a;this.runtime=a.runtime};var f=e.Type.prototype;f.onCreate=function(){this.is_family||(this.texture_img=new Image,this.texture_img.idtkLoadDisposed=!0,this.texture_img.src=this.texture_file,this.texture_img.cr_filesize=this.texture_filesize,
this.webGL_texture=null,this.runtime.wait_for_textures.push(this.texture_img))};f.onLostWebGLContext=function(){this.is_family||(this.webGL_texture=null)};f.onRestoreWebGLContext=function(){this.is_family||!this.instances.length||this.webGL_texture||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,!0,this.runtime.linearSampling,this.texture_pixelformat))};f.loadTextures=function(){this.is_family||this.webGL_texture||!this.runtime.glwrap||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,
!0,this.runtime.linearSampling,this.texture_pixelformat))};f.unloadTextures=function(){this.is_family||this.instances.length||!this.webGL_texture||(this.runtime.glwrap.deleteTexture(this.webGL_texture),this.webGL_texture=null)};f.preloadCanvas2D=function(a){a.drawImage(this.texture_img,0,0)};a.prototype.init=function(){var a=this.owner;this.x=a.x-a.xrandom/2+Math.random()*a.xrandom;this.y=a.y-a.yrandom/2+Math.random()*a.yrandom;this.speed=a.initspeed-a.speedrandom/2+Math.random()*a.speedrandom;this.angle=
a.angle-a.spraycone/2+Math.random()*a.spraycone;this.opacity=a.initopacity;this.size=a.initsize-a.sizerandom/2+Math.random()*a.sizerandom;this.grow=a.growrate-a.growrandom/2+Math.random()*a.growrandom;this.age=this.gs=0};a.prototype.tick=function(a){var b=this.owner;this.x+=Math.cos(this.angle)*this.speed*a;this.y+=Math.sin(this.angle)*this.speed*a;this.y+=this.gs*a;this.speed+=b.acc*a;this.size+=this.grow*a;this.gs+=b.g*a;this.age+=a;1>this.size?this.active=!1:(0!==b.lifeanglerandom&&(this.angle+=
Math.random()*b.lifeanglerandom*a-b.lifeanglerandom*a/2),0!==b.lifespeedrandom&&(this.speed+=Math.random()*b.lifespeedrandom*a-b.lifespeedrandom*a/2),0!==b.lifeopacityrandom&&(this.opacity+=Math.random()*b.lifeopacityrandom*a-b.lifeopacityrandom*a/2,0>this.opacity?this.opacity=0:1<this.opacity&&(this.opacity=1)),1>=b.destroymode&&this.age>=b.timeout&&(this.active=!1),2===b.destroymode&&0>=this.speed&&(this.active=!1))};a.prototype.draw=function(a){var b=this.owner.opacity*this.opacity;if(0!==b){0===
this.owner.destroymode&&(b*=1-this.age/this.owner.timeout);a.globalAlpha=b;var b=this.x-this.size/2,c=this.y-this.size/2;this.owner.runtime.pixel_rounding&&(b=b+0.5|0,c=c+0.5|0);a.drawImage(this.owner.type.texture_img,b,c,this.size,this.size)}};a.prototype.drawGL=function(a){var b=this.owner.opacity*this.opacity;0===this.owner.destroymode&&(b*=1-this.age/this.owner.timeout);var c=this.size,d=c*this.owner.particlescale,e=this.x-c/2,f=this.y-c/2;this.owner.runtime.pixel_rounding&&(e=e+0.5|0,f=f+0.5|
0);1>d||0===b||(d<a.minPointSize||d>a.maxPointSize?(a.setOpacity(b),a.quad(e,f,e+c,f,e+c,f+c,e,f+c)):a.point(this.x,this.y,d,b))};a.prototype.left=function(){return this.x-this.size/2};a.prototype.right=function(){return this.x+this.size/2};a.prototype.top=function(){return this.y-this.size/2};a.prototype.bottom=function(){return this.y+this.size/2};e.Instance=function(a){this.type=a;this.runtime=a.runtime};var f=e.Instance.prototype,g=[];f.onCreate=function(){var a=this.properties;this.rate=a[0];
this.spraycone=cr.to_radians(a[1]);this.spraytype=a[2];this.spraying=!0;this.initspeed=a[3];this.initsize=a[4];this.initopacity=a[5]/100;this.growrate=a[6];this.xrandom=a[7];this.yrandom=a[8];this.speedrandom=a[9];this.sizerandom=a[10];this.growrandom=a[11];this.acc=a[12];this.g=a[13];this.lifeanglerandom=a[14];this.lifespeedrandom=a[15];this.lifeopacityrandom=a[16];this.destroymode=a[17];this.timeout=a[18];this.particleCreateCounter=0;this.particlescale=1;this.particleBoxLeft=this.x;this.particleBoxTop=
this.y;this.particleBoxRight=this.x;this.particleBoxBottom=this.y;this.add_bbox_changed_callback(function(a){a.bbox.set(a.particleBoxLeft,a.particleBoxTop,a.particleBoxRight,a.particleBoxBottom);a.bquad.set_from_rect(a.bbox);a.bbox_changed=!1});this.recycled||(this.particles=[]);this.runtime.tickMe(this);this.type.loadTextures();if(1===this.spraytype)for(a=0;a<this.rate;a++)this.allocateParticle().opacity=0;this.first_tick=!0};f.saveToJSON=function(){var a={r:this.rate,sc:this.spraycone,st:this.spraytype,
s:this.spraying,isp:this.initspeed,isz:this.initsize,io:this.initopacity,gr:this.growrate,xr:this.xrandom,yr:this.yrandom,spr:this.speedrandom,szr:this.sizerandom,grnd:this.growrandom,acc:this.acc,g:this.g,lar:this.lifeanglerandom,lsr:this.lifespeedrandom,lor:this.lifeopacityrandom,dm:this.destroymode,to:this.timeout,pcc:this.particleCreateCounter,ft:this.first_tick,p:[]},b,c,d,e=a.p;b=0;for(c=this.particles.length;b<c;b++)d=this.particles[b],e.push([d.x,d.y,d.speed,d.angle,d.opacity,d.grow,d.size,
d.gs,d.age]);return a};f.loadFromJSON=function(a){this.rate=a.r;this.spraycone=a.sc;this.spraytype=a.st;this.spraying=a.s;this.initspeed=a.isp;this.initsize=a.isz;this.initopacity=a.io;this.growrate=a.gr;this.xrandom=a.xr;this.yrandom=a.yr;this.speedrandom=a.spr;this.sizerandom=a.szr;this.growrandom=a.grnd;this.acc=a.acc;this.g=a.g;this.lifeanglerandom=a.lar;this.lifespeedrandom=a.lsr;this.lifeopacityrandom=a.lor;this.destroymode=a.dm;this.timeout=a.to;this.particleCreateCounter=a.pcc;this.first_tick=
a.ft;g.push.apply(g,this.particles);this.particles.length=0;var b,c,d,e=a.p;a=0;for(b=e.length;a<b;a++)c=this.allocateParticle(),d=e[a],c.x=d[0],c.y=d[1],c.speed=d[2],c.angle=d[3],c.opacity=d[4],c.grow=d[5],c.size=d[6],c.gs=d[7],c.age=d[8]};f.onDestroy=function(){g.push.apply(g,this.particles);this.particles.length=0};f.allocateParticle=function(){var b;g.length?(b=g.pop(),b.owner=this):b=new a(this);this.particles.push(b);b.active=!0;return b};f.tick=function(){var a=this.runtime.getDt(this),b,c,
d,e;if(0===this.spraytype&&this.spraying)for(this.particleCreateCounter+=a*this.rate,c=cr.floor(this.particleCreateCounter),this.particleCreateCounter-=c,b=0;b<c;b++)d=this.allocateParticle(),d.init();this.particleBoxLeft=this.x;this.particleBoxTop=this.y;this.particleBoxRight=this.x;this.particleBoxBottom=this.y;e=b=0;for(c=this.particles.length;b<c;b++)d=this.particles[b],this.particles[e]=d,this.runtime.redraw=!0,1===this.spraytype&&this.first_tick&&d.init(),d.tick(a),d.active?(d.left()<this.particleBoxLeft&&
(this.particleBoxLeft=d.left()),d.right()>this.particleBoxRight&&(this.particleBoxRight=d.right()),d.top()<this.particleBoxTop&&(this.particleBoxTop=d.top()),d.bottom()>this.particleBoxBottom&&(this.particleBoxBottom=d.bottom()),e++):g.push(d);this.particles.length=e;this.set_bbox_changed();this.first_tick=!1;1===this.spraytype&&0===this.particles.length&&this.runtime.DestroyInstance(this)};f.draw=function(a){var b,c,d,e=this.layer;b=0;for(c=this.particles.length;b<c;b++)d=this.particles[b],d.right()>=
e.viewLeft&&d.bottom()>=e.viewTop&&d.left()<=e.viewRight&&d.top()<=e.viewBottom&&d.draw(a)};f.drawGL=function(a){this.particlescale=this.layer.getScale();a.setTexture(this.type.webGL_texture);var b,c,d,e=this.layer;b=0;for(c=this.particles.length;b<c;b++)d=this.particles[b],d.right()>=e.viewLeft&&d.bottom()>=e.viewTop&&d.left()<=e.viewRight&&d.top()<=e.viewBottom&&d.drawGL(a)};b.prototype.IsSpraying=function(){return this.spraying};e.cnds=new b;c.prototype.SetSpraying=function(a){this.spraying=0!==
a};c.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};c.prototype.SetRate=function(a){this.rate=a;var b;if(1===this.spraytype&&this.first_tick)if(a<this.particles.length)for(a=this.particles.length-a,b=0;b<a;b++)g.push(this.particles.pop());else if(a>this.particles.length)for(a-=this.particles.length,b=0;b<a;b++)this.allocateParticle().opacity=0};c.prototype.SetSprayCone=function(a){this.spraycone=cr.to_radians(a)};
c.prototype.SetInitSpeed=function(a){this.initspeed=a};c.prototype.SetInitSize=function(a){this.initsize=a};c.prototype.SetInitOpacity=function(a){this.initopacity=a/100};c.prototype.SetGrowRate=function(a){this.growrate=a};c.prototype.SetXRandomiser=function(a){this.xrandom=a};c.prototype.SetYRandomiser=function(a){this.yrandom=a};c.prototype.SetSpeedRandomiser=function(a){this.speedrandom=a};c.prototype.SetSizeRandomiser=function(a){this.sizerandom=a};c.prototype.SetGrowRateRandomiser=function(a){this.growrandom=
a};c.prototype.SetParticleAcc=function(a){this.acc=a};c.prototype.SetGravity=function(a){this.g=a};c.prototype.SetAngleRandomiser=function(a){this.lifeanglerandom=a};c.prototype.SetSpeedRandomiser=function(a){this.lifespeedrandom=a};c.prototype.SetOpacityRandomiser=function(a){this.lifeopacityrandom=a};c.prototype.SetTimeout=function(a){this.timeout=a};e.acts=new c;d.prototype.ParticleCount=function(a){a.set_int(this.particles.length)};d.prototype.Rate=function(a){a.set_float(this.rate)};d.prototype.SprayCone=
function(a){a.set_float(cr.to_degrees(this.spraycone))};d.prototype.InitSpeed=function(a){a.set_float(this.initspeed)};d.prototype.InitSize=function(a){a.set_float(this.initsize)};d.prototype.InitOpacity=function(a){a.set_float(100*this.initopacity)};d.prototype.InitGrowRate=function(a){a.set_float(this.growrate)};d.prototype.XRandom=function(a){a.set_float(this.xrandom)};d.prototype.YRandom=function(a){a.set_float(this.yrandom)};d.prototype.InitSpeedRandom=function(a){a.set_float(this.speedrandom)};
d.prototype.InitSizeRandom=function(a){a.set_float(this.sizerandom)};d.prototype.InitGrowRandom=function(a){a.set_float(this.growrandom)};d.prototype.ParticleAcceleration=function(a){a.set_float(this.acc)};d.prototype.Gravity=function(a){a.set_float(this.g)};d.prototype.ParticleAngleRandom=function(a){a.set_float(this.lifeanglerandom)};d.prototype.ParticleSpeedRandom=function(a){a.set_float(this.lifespeedrandom)};d.prototype.ParticleOpacityRandom=function(a){a.set_float(this.lifeopacityrandom)};d.prototype.Timeout=
function(a){a.set_float(this.timeout)};e.exps=new d})();cr.plugins_.Sprite=function(a){this.runtime=a};
(function(){function a(){if(0===this.datauri.length){var a=document.createElement("canvas");a.width=this.width;a.height=this.height;var b=a.getContext("2d");this.spritesheeted?b.drawImage(this.texture_img,this.offx,this.offy,this.width,this.height,0,0,this.width,this.height):b.drawImage(this.texture_img,0,0,this.width,this.height);this.datauri=a.toDataURL("image/png")}return this.datauri}function b(){}function c(a,b,c){var d;d=q.length?q.pop():[0,0];d[0]=b.uid;d[1]=c.uid;a.push(d)}function d(a,b,
c){b=b.uid;var d=c.uid,e=0,f,g;c=0;for(f=a.length;c<f;c++)g=a[c],g[0]===b&&g[1]===d||g[0]===d&&g[1]===b||(a[e][0]=a[c][0],a[e][1]=a[c][1],e++);for(c=e;c<f;c++)b=a[c],b[0]=0,b[1]=0,q.push(b);a.length=e}function e(a,b,c){b=b.uid;c=c.uid;var d,e,f;d=0;for(e=a.length;d<e;d++)if(f=a[d],f[0]===b&&f[1]===c||f[0]===c&&f[1]===b)return!0;return!1}function f(a,b,c){if(!a)return!1;var d=0!==b||0!==c,e,f,g=!1,k,h=this.runtime.getCurrentCondition(),l=h.type,h=h.inverted,m=a.getCurrentSol();k=this.runtime.getCurrentEventStack().current_event.orblock;
m=m.select_all?m.type.instances:k?m.else_instances:m.instances;p=a;s=l!==a&&!h;d&&(e=this.x,f=this.y,this.x+=b,this.y+=c,this.set_bbox_changed());b=0;for(c=m.length;b<c;b++)if(k=m[b],this.runtime.testOverlap(this,k)){g=!0;if(h)break;l!==a&&r.add(k)}d&&(this.x=e,this.y=f,this.set_bbox_changed());return g}function g(){}function h(){}var l=cr.plugins_.Sprite.prototype;l.Type=function(a){this.plugin=a;this.runtime=a.runtime};var k=l.Type.prototype;k.onCreate=function(){if(!this.is_family){var b,c,d,e,
f,g,k,h,p;this.all_frames=[];this.has_loaded_textures=!1;b=0;for(c=this.animations.length;b<c;b++){f=this.animations[b];k={};k.name=f[0];k.speed=f[1];k.loop=f[2];k.repeatcount=f[3];k.repeatto=f[4];k.pingpong=f[5];k.sid=f[6];k.frames=[];d=0;for(e=f[7].length;d<e;d++)g=f[7][d],h={},h.texture_file=g[0],h.texture_filesize=g[1],h.offx=g[2],h.offy=g[3],h.width=g[4],h.height=g[5],h.duration=g[6],h.hotspotX=g[7],h.hotspotY=g[8],h.image_points=g[9],h.poly_pts=g[10],h.pixelformat=g[11],h.spritesheeted=0!==
h.width,h.datauri="",h.getDataUri=a,p={left:0,top:0,right:1,bottom:1},h.sheetTex=p,h.webGL_texture=null,(p=this.runtime.findWaitingTexture(g[0]))?h.texture_img=p:(h.texture_img=new Image,h.texture_img.idtkLoadDisposed=!0,h.texture_img.src=g[0],h.texture_img.cr_src=g[0],h.texture_img.cr_filesize=g[1],h.texture_img.c2webGL_texture=null,this.runtime.wait_for_textures.push(h.texture_img)),cr.seal(h),k.frames.push(h),this.all_frames.push(h);cr.seal(k);this.animations[b]=k}}};k.updateAllCurrentTexture=
function(){var a,b,c;a=0;for(b=this.instances.length;a<b;a++)c=this.instances[a],c.curWebGLTexture=c.curFrame.webGL_texture};k.onLostWebGLContext=function(){if(!this.is_family){var a,b,c;a=0;for(b=this.all_frames.length;a<b;++a)c=this.all_frames[a],c.texture_img.c2webGL_texture=null,c.webGL_texture=null}};k.onRestoreWebGLContext=function(){if(!this.is_family&&this.instances.length){var a,b,c;a=0;for(b=this.all_frames.length;a<b;++a)c=this.all_frames[a],c.webGL_texture=this.runtime.glwrap.loadTexture(c.texture_img,
!1,this.runtime.linearSampling,c.pixelformat);this.updateAllCurrentTexture()}};k.loadTextures=function(){if(!this.is_family&&!this.has_loaded_textures&&this.runtime.glwrap){var a,b,c;a=0;for(b=this.all_frames.length;a<b;++a)c=this.all_frames[a],c.webGL_texture=this.runtime.glwrap.loadTexture(c.texture_img,!1,this.runtime.linearSampling,c.pixelformat);this.has_loaded_textures=!0}};k.unloadTextures=function(){if(!this.is_family&&!this.instances.length&&this.has_loaded_textures){var a,b,c;a=0;for(b=
this.all_frames.length;a<b;++a)c=this.all_frames[a],this.runtime.glwrap.deleteTexture(c.webGL_texture);this.has_loaded_textures=!1}};var m=[];k.preloadCanvas2D=function(a){var b,c,d;b=m.length=0;for(c=this.all_frames.length;b<c;++b)d=this.all_frames[b].texture_img,-1===m.indexOf(d)&&(a.drawImage(d,0,0),m.push(d))};l.Instance=function(a){this.type=a;this.runtime=a.runtime;a=this.type.animations[0].frames[0].poly_pts;this.recycled?this.collision_poly.set_pts(a):this.collision_poly=new cr.CollisionPoly(a)};
var n=l.Instance.prototype;n.onCreate=function(){this.visible=0===this.properties[0];this.inAnimTrigger=this.isTicking=!1;this.collisionsEnabled=0!==this.properties[3];1===this.type.animations.length&&1===this.type.animations[0].frames.length||0===this.type.animations[0].speed||(this.runtime.tickMe(this),this.isTicking=!0);this.cur_animation=this.getAnimationByName(this.properties[1])||this.type.animations[0];this.cur_frame=this.properties[2];0>this.cur_frame&&(this.cur_frame=0);this.cur_frame>=this.cur_animation.frames.length&&
(this.cur_frame=this.cur_animation.frames.length-1);var a=this.cur_animation.frames[this.cur_frame];this.collision_poly.set_pts(a.poly_pts);this.hotspotX=a.hotspotX;this.hotspotY=a.hotspotY;this.cur_anim_speed=this.cur_animation.speed;this.recycled?this.animTimer.reset():this.animTimer=new cr.KahanAdder;this.frameStart=this.getNowTime();this.animPlaying=!0;this.animRepeats=0;this.animForwards=!0;this.changeAnimName=this.animTriggerName="";this.changeAnimFrom=0;this.changeAnimFrame=-1;this.type.loadTextures();
var b,c,d,e,f,g,k,a=0;for(b=this.type.animations.length;a<b;a++)for(e=this.type.animations[a],c=0,d=e.frames.length;c<d;c++)f=e.frames[c],0===f.width&&(f.width=f.texture_img.width,f.height=f.texture_img.height),f.spritesheeted&&(k=f.texture_img,g=f.sheetTex,g.left=f.offx/k.width,g.top=f.offy/k.height,g.right=(f.offx+f.width)/k.width,g.bottom=(f.offy+f.height)/k.height,0===f.offx&&0===f.offy&&f.width===k.width&&f.height===k.height&&(f.spritesheeted=!1));this.curFrame=this.cur_animation.frames[this.cur_frame];
this.curWebGLTexture=this.curFrame.webGL_texture};n.saveToJSON=function(){var a={a:this.cur_animation.sid,f:this.cur_frame,cas:this.cur_anim_speed,fs:this.frameStart,ar:this.animRepeats,at:this.animTimer.sum};this.animPlaying||(a.ap=this.animPlaying);this.animForwards||(a.af=this.animForwards);return a};n.loadFromJSON=function(a){var b=this.getAnimationBySid(a.a);b&&(this.cur_animation=b);this.cur_frame=a.f;0>this.cur_frame&&(this.cur_frame=0);this.cur_frame>=this.cur_animation.frames.length&&(this.cur_frame=
this.cur_animation.frames.length-1);this.cur_anim_speed=a.cas;this.frameStart=a.fs;this.animRepeats=a.ar;this.animTimer.reset();this.animTimer.sum=a.at;this.animPlaying=a.hasOwnProperty("ap")?a.ap:!0;this.animForwards=a.hasOwnProperty("af")?a.af:!0;this.curFrame=this.cur_animation.frames[this.cur_frame];this.curWebGLTexture=this.curFrame.webGL_texture;this.collision_poly.set_pts(this.curFrame.poly_pts);this.hotspotX=this.curFrame.hotspotX;this.hotspotY=this.curFrame.hotspotY};n.animationFinish=function(a){this.cur_frame=
a?0:this.cur_animation.frames.length-1;this.animPlaying=!1;this.animTriggerName=this.cur_animation.name;this.inAnimTrigger=!0;this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnAnyAnimFinished,this);this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnAnimFinished,this);this.inAnimTrigger=!1;this.animRepeats=0};n.getNowTime=function(){return this.animTimer.sum};n.tick=function(){this.animTimer.add(this.runtime.getDt(this));this.changeAnimName.length&&this.doChangeAnim();0<=this.changeAnimFrame&&
this.doChangeAnimFrame();var a=this.getNowTime(),b=this.cur_animation,c=b.frames[this.cur_frame],d=c.duration/this.cur_anim_speed;this.animPlaying&&a>=this.frameStart+d&&(this.animForwards?this.cur_frame++:this.cur_frame--,this.frameStart+=d,this.cur_frame>=b.frames.length&&(b.pingpong?(this.animForwards=!1,this.cur_frame=b.frames.length-2):b.loop?this.cur_frame=b.repeatto:(this.animRepeats++,this.animRepeats>=b.repeatcount?this.animationFinish(!1):this.cur_frame=b.repeatto)),0>this.cur_frame&&(b.pingpong?
(this.cur_frame=1,this.animForwards=!0,b.loop||(this.animRepeats++,this.animRepeats>=b.repeatcount&&this.animationFinish(!0))):b.loop?this.cur_frame=b.repeatto:(this.animRepeats++,this.animRepeats>=b.repeatcount?this.animationFinish(!0):this.cur_frame=b.repeatto)),0>this.cur_frame?this.cur_frame=0:this.cur_frame>=b.frames.length&&(this.cur_frame=b.frames.length-1),a>this.frameStart+b.frames[this.cur_frame].duration/this.cur_anim_speed&&(this.frameStart=a),a=b.frames[this.cur_frame],this.OnFrameChanged(c,
a),this.runtime.redraw=!0)};n.getAnimationByName=function(a){var b,c,d;b=0;for(c=this.type.animations.length;b<c;b++)if(d=this.type.animations[b],cr.equals_nocase(d.name,a))return d;return null};n.getAnimationBySid=function(a){var b,c,d;b=0;for(c=this.type.animations.length;b<c;b++)if(d=this.type.animations[b],d.sid===a)return d;return null};n.doChangeAnim=function(){var a=this.cur_animation.frames[this.cur_frame],b=this.getAnimationByName(this.changeAnimName);this.changeAnimName="";!b||cr.equals_nocase(b.name,
this.cur_animation.name)&&this.animPlaying||(this.cur_animation=b,this.cur_anim_speed=b.speed,0>this.cur_frame&&(this.cur_frame=0),this.cur_frame>=this.cur_animation.frames.length&&(this.cur_frame=this.cur_animation.frames.length-1),1===this.changeAnimFrom&&(this.cur_frame=0),this.animPlaying=!0,this.frameStart=this.getNowTime(),this.animForwards=!0,this.OnFrameChanged(a,this.cur_animation.frames[this.cur_frame]),this.runtime.redraw=!0)};n.doChangeAnimFrame=function(){var a=this.cur_animation.frames[this.cur_frame],
b=this.cur_frame;this.cur_frame=cr.floor(this.changeAnimFrame);0>this.cur_frame&&(this.cur_frame=0);this.cur_frame>=this.cur_animation.frames.length&&(this.cur_frame=this.cur_animation.frames.length-1);b!==this.cur_frame&&(this.OnFrameChanged(a,this.cur_animation.frames[this.cur_frame]),this.frameStart=this.getNowTime(),this.runtime.redraw=!0);this.changeAnimFrame=-1};n.OnFrameChanged=function(a,b){var c=a.width,d=a.height,e=b.width,f=b.height;c!=e&&(this.width*=e/c);d!=f&&(this.height*=f/d);this.hotspotX=
b.hotspotX;this.hotspotY=b.hotspotY;this.collision_poly.set_pts(b.poly_pts);this.set_bbox_changed();this.curFrame=b;this.curWebGLTexture=b.webGL_texture;c=0;for(d=this.behavior_insts.length;c<d;c++)if(e=this.behavior_insts[c],e.onSpriteFrameChanged)e.onSpriteFrameChanged(a,b);this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnFrameChanged,this)};n.draw=function(a){a.globalAlpha=this.opacity;var b=this.curFrame,c=b.spritesheeted,d=b.texture_img,e=this.x,f=this.y,g=this.width,k=this.height;if(0===
this.angle&&0<=g&&0<=k)e-=this.hotspotX*g,f-=this.hotspotY*k,this.runtime.pixel_rounding&&(e=e+0.5|0,f=f+0.5|0),c?a.drawImage(d,b.offx,b.offy,b.width,b.height,e,f,g,k):a.drawImage(d,e,f,g,k);else{this.runtime.pixel_rounding&&(e=e+0.5|0,f=f+0.5|0);a.save();var h=0<g?1:-1,p=0<k?1:-1;a.translate(e,f);1===h&&1===p||a.scale(h,p);a.rotate(this.angle*h*p);e=0-this.hotspotX*cr.abs(g);f=0-this.hotspotY*cr.abs(k);c?a.drawImage(d,b.offx,b.offy,b.width,b.height,e,f,cr.abs(g),cr.abs(k)):a.drawImage(d,e,f,cr.abs(g),
cr.abs(k));a.restore()}};n.drawGL=function(a){a.setTexture(this.curWebGLTexture);a.setOpacity(this.opacity);var b=this.curFrame,c=this.bquad;if(this.runtime.pixel_rounding){var d=(this.x+0.5|0)-this.x,e=(this.y+0.5|0)-this.y;b.spritesheeted?a.quadTex(c.tlx+d,c.tly+e,c.trx+d,c.try_+e,c.brx+d,c.bry+e,c.blx+d,c.bly+e,b.sheetTex):a.quad(c.tlx+d,c.tly+e,c.trx+d,c.try_+e,c.brx+d,c.bry+e,c.blx+d,c.bly+e)}else b.spritesheeted?a.quadTex(c.tlx,c.tly,c.trx,c.try_,c.brx,c.bry,c.blx,c.bly,b.sheetTex):a.quad(c.tlx,
c.tly,c.trx,c.try_,c.brx,c.bry,c.blx,c.bly)};n.getImagePointIndexByName=function(a){var b=this.curFrame,c,d;c=0;for(d=b.image_points.length;c<d;c++)if(cr.equals_nocase(a,b.image_points[c][0]))return c;return-1};n.getImagePoint=function(a,b){var c=this.curFrame,d=c.image_points,e;e=cr.is_string(a)?this.getImagePointIndexByName(a):a-1;e=cr.floor(e);if(0>e||e>=d.length)return b?this.x:this.y;var f=(d[e][1]-c.hotspotX)*this.width,d=d[e][2],d=(d-c.hotspotY)*this.height,c=Math.cos(this.angle);e=Math.sin(this.angle);
var g=f*c-d*e,d=d*c+f*e,f=g+this.x,d=d+this.y;return b?f:d};var q=[];b.prototype.OnCollision=function(a){if(!a)return!1;var b=this.runtime,f=b.getCurrentCondition(),g=f.type;f.extra.collmemory||(f.extra.collmemory=[],b.addDestroyCallback(function(a){return function(b){var c=0,d,e,f=b.uid;b=0;for(d=a.length;b<d;b++)e=a[b],e[0]!==f&&e[1]!==f&&(a[c][0]=a[b][0],a[c][1]=a[b][1],c++);for(b=c;b<d;b++)e=a[b],e[0]=0,e[1]=0,q.push(e);a.length=c}}(f.extra.collmemory)));var k=g.getCurrentSol(),h=a.getCurrentSol(),
k=k.getObjects(),h=h.getObjects(),p,l,m,n,r,s,y=b.getCurrentEventStack().current_event;for(p=0;p<k.length;p++)for(l=k[p],m=0;m<h.length;m++)n=h[m],b.testOverlap(l,n)||b.checkRegisteredCollision(l,n)?e(f.extra.collmemory,l,n)||(c(f.extra.collmemory,l,n),b.pushCopySol(y.solModifiers),r=g.getCurrentSol(),s=a.getCurrentSol(),r.select_all=!1,s.select_all=!1,g===a?(r.instances.length=2,r.instances[0]=l,r.instances[1]=n,g.applySolToContainer()):(r.instances.length=1,s.instances.length=1,r.instances[0]=l,
s.instances[0]=n,g.applySolToContainer(),a.applySolToContainer()),y.retrigger(),b.popSol(y.solModifiers)):d(f.extra.collmemory,l,n);return!1};var p=null,r=new cr.ObjectSet,s=!1;k.finish=function(a){if(s){if(a){var b=this.runtime.getCurrentEventStack().current_event.orblock;a=p.getCurrentSol();var c=r.valuesRef(),d,e;if(a.select_all){a.select_all=!1;a.instances.length=c.length;d=0;for(e=c.length;d<e;d++)a.instances[d]=c[d];if(b)for(d=a.else_instances.length=0,e=p.instances.length;d<e;d++)b=p.instances[d],
r.contains(b)||a.else_instances.push(b)}else{var f=a.instances.length;a.instances.length=f+c.length;d=0;for(e=c.length;d<e;d++)a.instances[f+d]=c[d],b&&cr.arrayFindRemove(a.else_instances,c[d])}p.applySolToContainer()}r.clear();s=!1}};b.prototype.IsOverlapping=function(a){return f.call(this,a,0,0)};b.prototype.IsOverlappingOffset=function(a,b,c){return f.call(this,a,b,c)};b.prototype.IsAnimPlaying=function(a){return this.changeAnimName.length?cr.equals_nocase(this.changeAnimName,a):cr.equals_nocase(this.cur_animation.name,
a)};b.prototype.CompareFrame=function(a,b){return cr.do_cmp(this.cur_frame,a,b)};b.prototype.OnAnimFinished=function(a){return cr.equals_nocase(this.animTriggerName,a)};b.prototype.OnAnyAnimFinished=function(){return!0};b.prototype.OnFrameChanged=function(){return!0};b.prototype.IsMirrored=function(){return 0>this.width};b.prototype.IsFlipped=function(){return 0>this.height};b.prototype.OnURLLoaded=function(){return!0};b.prototype.IsCollisionEnabled=function(){return this.collisionsEnabled};l.cnds=
new b;g.prototype.Spawn=function(a,b,c){if(a&&b&&(b=this.runtime.createInstance(a,b,this.getImagePoint(c,!0),this.getImagePoint(c,!1)))){"undefined"!==typeof b.angle&&(b.angle=this.angle,b.set_bbox_changed());this.runtime.isInOnDestroy++;var d,e,f;this.runtime.trigger(Object.getPrototypeOf(a.plugin).cnds.OnCreated,b);if(b.is_contained)for(d=0,e=b.siblings.length;d<e;d++)f=b.siblings[d],this.runtime.trigger(Object.getPrototypeOf(f.type.plugin).cnds.OnCreated,f);this.runtime.isInOnDestroy--;d=this.runtime.getCurrentAction();
c=!1;if(cr.is_undefined(d.extra.Spawn_LastExec)||d.extra.Spawn_LastExec<this.runtime.execcount)c=!0,d.extra.Spawn_LastExec=this.runtime.execcount;if(a!=this.type&&(a=a.getCurrentSol(),a.select_all=!1,c?(a.instances.length=1,a.instances[0]=b):a.instances.push(b),b.is_contained))for(d=0,e=b.siblings.length;d<e;d++)f=b.siblings[d],a=f.type.getCurrentSol(),a.select_all=!1,c?(a.instances.length=1,a.instances[0]=f):a.instances.push(f)}};g.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);
cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};g.prototype.StopAnim=function(){this.animPlaying=!1};g.prototype.StartAnim=function(a){this.animPlaying=!0;this.frameStart=this.getNowTime();1===a&&0!==this.cur_frame&&(this.changeAnimFrame=0,this.inAnimTrigger||this.doChangeAnimFrame());this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0)};g.prototype.SetAnim=function(a,b){this.changeAnimName=a;this.changeAnimFrom=b;this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0);
this.inAnimTrigger||this.doChangeAnim()};g.prototype.SetAnimFrame=function(a){this.changeAnimFrame=a;this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0);this.inAnimTrigger||this.doChangeAnimFrame()};g.prototype.SetAnimSpeed=function(a){this.cur_anim_speed=cr.abs(a);this.animForwards=0<=a;this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0)};g.prototype.SetMirrored=function(a){a=cr.abs(this.width)*(0===a?-1:1);this.width!==a&&(this.width=a,this.set_bbox_changed())};g.prototype.SetFlipped=
function(a){a=cr.abs(this.height)*(0===a?-1:1);this.height!==a&&(this.height=a,this.set_bbox_changed())};g.prototype.SetScale=function(a){var b=this.curFrame,c=b.width*a*(0>this.width?-1:1);a=b.height*a*(0>this.height?-1:1);if(this.width!==c||this.height!==a)this.width=c,this.height=a,this.set_bbox_changed()};g.prototype.LoadURL=function(a,b){var c=new Image,d=this,e=this.curFrame;c.onload=function(){e.texture_img.src===c.src?d.runtime.glwrap&&d.curFrame===e&&(d.curWebGLTexture=e.webGL_texture):(e.texture_img=
c,e.offx=0,e.offy=0,e.width=c.width,e.height=c.height,e.spritesheeted=!1,e.datauri="",d.runtime.glwrap&&(e.webGL_texture&&d.runtime.glwrap.deleteTexture(e.webGL_texture),e.webGL_texture=d.runtime.glwrap.loadTexture(c,!1,d.runtime.linearSampling),d.curFrame===e&&(d.curWebGLTexture=e.webGL_texture),d.type.updateAllCurrentTexture()),0===b&&(d.width=c.width,d.height=c.height,d.set_bbox_changed()));d.runtime.redraw=!0;d.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnURLLoaded,d)};"data:"!==a.substr(0,
5)&&(c.crossOrigin="anonymous");c.src=a};g.prototype.SetCollisions=function(a){this.collisionsEnabled=0!==a};l.acts=new g;h.prototype.AnimationFrame=function(a){a.set_int(this.cur_frame)};h.prototype.AnimationFrameCount=function(a){a.set_int(this.cur_animation.frames.length)};h.prototype.AnimationName=function(a){a.set_string(this.cur_animation.name)};h.prototype.AnimationSpeed=function(a){a.set_float(this.cur_anim_speed)};h.prototype.ImagePointX=function(a,b){a.set_float(this.getImagePoint(b,!0))};
h.prototype.ImagePointY=function(a,b){a.set_float(this.getImagePoint(b,!1))};h.prototype.ImagePointCount=function(a){a.set_int(this.curFrame.image_points.length)};h.prototype.ImageWidth=function(a){a.set_float(this.curFrame.width)};h.prototype.ImageHeight=function(a){a.set_float(this.curFrame.height)};l.exps=new h})();cr.plugins_.Spritefont2=function(a){this.runtime=a};
(function(){function a(a,b,c){if(c){var d;c=0;for(d=b.length;c<d;c++)a.length<h&&a.push(b[c]);b.length=0}else for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(a.length<h&&a.push(b[d]),delete b[d])}function b(a,b,c){var d=a.lines;c=c.replace(/\s\s*$/,"");b>=d.length&&d.push(l.length?l.pop():{});b=d[b];b.text=c;b.width=a.measureWidth(c);a.textWidth=cr.max(a.textWidth,b.width)}function c(){}function d(){}function e(){}var f=cr.plugins_.Spritefont2.prototype;f.onCreate=function(){};f.Type=function(a){this.plugin=
a;this.runtime=a.runtime};var g=f.Type.prototype;g.onCreate=function(){this.is_family||(this.texture_img=new Image,this.texture_img.idtkLoadDisposed=!0,this.texture_img.src=this.texture_file,this.runtime.wait_for_textures.push(this.texture_img),this.webGL_texture=null)};g.onLostWebGLContext=function(){this.is_family||(this.webGL_texture=null)};g.onRestoreWebGLContext=function(){if(!this.is_family&&this.instances.length){this.webGL_texture||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,
!1,this.runtime.linearSampling,this.texture_pixelformat));var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].webGL_texture=this.webGL_texture}};g.unloadTextures=function(){this.is_family||this.instances.length||!this.webGL_texture||(this.runtime.glwrap.deleteTexture(this.webGL_texture),this.webGL_texture=null)};g.preloadCanvas2D=function(a){a.drawImage(this.texture_img,0,0)};f.Instance=function(a){this.type=a;this.runtime=a.runtime};g=f.Instance.prototype;g.onDestroy=function(){a(l,
this.lines,!0);a(k,this.clipList,!1);a(m,this.clipUV,!1);cr.wipe(this.characterWidthList)};g.onCreate=function(){this.texture_img=this.type.texture_img;this.characterWidth=this.properties[0];this.characterHeight=this.properties[1];this.characterSet=this.properties[2];this.text=this.properties[3];this.characterScale=this.properties[4];this.visible=0===this.properties[5];this.halign=this.properties[6]/2;this.valign=this.properties[7]/2;this.wrapbyword=0===this.properties[9];this.characterSpacing=this.properties[10];
this.lineHeight=this.properties[11];this.textHeight=this.textWidth=0;this.recycled?(this.lines.length=0,cr.wipe(this.clipList),cr.wipe(this.clipUV),cr.wipe(this.characterWidthList)):(this.lines=[],this.clipList={},this.clipUV={},this.characterWidthList={});this.text_changed=!0;this.lastwrapwidth=this.width;this.runtime.glwrap&&(this.type.webGL_texture||(this.type.webGL_texture=this.runtime.glwrap.loadTexture(this.type.texture_img,!1,this.runtime.linearSampling,this.type.texture_pixelformat)),this.webGL_texture=
this.type.webGL_texture);this.SplitSheet()};g.saveToJSON=function(){var a={t:this.text,csc:this.characterScale,csp:this.characterSpacing,lh:this.lineHeight,tw:this.textWidth,th:this.textHeight,lrt:this.last_render_tick,cw:{}},b;for(b in this.characterWidthList)a.cw[b]=this.characterWidthList[b];return a};g.loadFromJSON=function(a){this.text=a.t;this.characterScale=a.csc;this.characterSpacing=a.csp;this.lineHeight=a.lh;this.textWidth=a.tw;this.textHeight=a.th;this.last_render_tick=a.lrt;for(var b in a.cw)this.characterWidthList[b]=
a.cw[b];this.text_changed=!0;this.lastwrapwidth=this.width};var h=1E3,l=[],k=[],m=[];g.SplitSheet=function(){for(var a=this.texture_img,b=a.width,c=a.height,a=this.characterWidth,d=this.characterHeight,e=a/b,f=d/c,g=this.characterSet,b=Math.floor(b/a),c=Math.floor(c/d),h=0;h<g.length&&!(h>=b*c);h++){var l=h%b,n=Math.floor(h/b),q=g.charAt(h);if(this.runtime.glwrap){var z=this.clipUV,A=l*e,B=n*f,l=(l+1)*e,n=(n+1)*f;void 0===z[q]&&(z[q]=m.length?m.pop():new cr.rect);z[q].left=A;z[q].top=B;z[q].right=
l;z[q].bottom=n}else z=this.clipList,l*=a,n*=d,A=a,B=d,void 0===z[q]&&(z[q]=k.length?k.pop():{}),z[q].x=l,z[q].y=n,z[q].w=A,z[q].h=B}};var n=[];f.TokeniseWords=function(a){n.length=0;for(var b="",c,d=0;d<a.length;)if(c=a.charAt(d),"\n"===c)b.length&&(n.push(b),b=""),n.push("\n"),++d;else if(" "===c||"\t"===c||"-"===c){do b+=a.charAt(d),d++;while(d<a.length&&(" "===a.charAt(d)||"\t"===a.charAt(d)));n.push(b);b=""}else d<a.length&&(b+=c,d++);b.length&&n.push(b)};f.WordWrap=function(b){var c=b.text,
d=b.lines;if(c&&c.length){var e=b.width;if(2>=e)a(l,d,!0);else{var f=b.characterScale,g=b.characterSpacing;if(c.length*(b.characterWidth*f+g)-g<=e&&-1===c.indexOf("\n")&&(g=b.measureWidth(c),g<=e)){a(l,d,!0);d.push(l.length?l.pop():{});d[0].text=c;d[0].width=g;b.textWidth=g;b.textHeight=b.characterHeight*f+b.lineHeight;return}this.WrapText(b);b.textHeight=d.length*(b.characterHeight*f+b.lineHeight)}}else a(l,d,!0)};f.WrapText=function(a){var c=a.wrapbyword,d=a.text,e=a.lines,f=a.width;c&&(this.TokeniseWords(d),
d=n);var g="",k,m,q,v=0,u=!1;for(q=0;q<d.length;q++)"\n"===d[q]?(!0===u?u=!1:(b(a,v,g),v++),g=""):(u=!1,k=g,g+=d[q],m=a.measureWidth(g.replace(/\s\s*$/,"")),m>f&&(""===k?(b(a,v,g),g="",u=!0):(b(a,v,k),g=d[q]),v++,c||" "!==g||(g="")));g.replace(/\s\s*$/,"").length&&(b(a,v,g),v++);for(q=v;q<e.length;q++)l.length<h&&l.push(e[q]);e.length=v};g.measureWidth=function(a){for(var b=this.characterSpacing,c=a.length,d=0,e=0;e<c;e++)d+=this.getCharacterWidth(a.charAt(e))*this.characterScale+b;return d-(0<d?
b:0)};g.getCharacterWidth=function(a){var b=this.characterWidthList;return void 0!==b[a]?b[a]:this.characterWidth};g.rebuildText=function(){if(this.text_changed||this.width!==this.lastwrapwidth)this.textHeight=this.textWidth=0,this.type.plugin.WordWrap(this),this.text_changed=!1,this.lastwrapwidth=this.width};g.draw=function(a,b){var c=this.texture_img;if(""!==this.text&&null!=c&&(this.rebuildText(),!(this.height<this.characterHeight*this.characterScale+this.lineHeight))){a.globalAlpha=this.opacity;
var c=this.x,d=this.y;this.runtime.pixel_rounding&&(c=c+0.5|0,d=d+0.5|0);a.save();a.translate(c,d);a.rotate(this.angle);for(var c=this.halign,d=this.characterScale,e=this.characterHeight*d,f=this.lineHeight,g=this.characterSpacing,k=this.lines,h,l=this.valign*cr.max(0,this.height-this.textHeight),m=-(this.hotspotX*this.width),n=-(this.hotspotY*this.height),l=n+l,n=0;n<k.length;n++){var q=k[n].text;h=c*cr.max(0,this.width-k[n].width);h=m+h;for(var l=l+f,B=0;B<q.length;B++){var t=q.charAt(B),y=this.clipList[t];
if(h+this.getCharacterWidth(t)*d>this.width+1E-5)break;void 0!==y&&a.drawImage(this.texture_img,y.x,y.y,y.w,y.h,Math.round(h),Math.round(l),y.w*d,y.h*d);h+=this.getCharacterWidth(t)*d+g}l+=e;if(l+e+f>this.height)break}a.restore()}};var q=new cr.quad;g.drawGL=function(a){a.setTexture(this.webGL_texture);a.setOpacity(this.opacity);if(""!==this.text&&(this.rebuildText(),!(this.height<this.characterHeight*this.characterScale+this.lineHeight))){this.update_bbox();var b=this.bquad,c=0,d=0;this.runtime.pixel_rounding&&
(c=(this.x+0.5|0)-this.x,d=(this.y+0.5|0)-this.y);var e=this.angle,f=this.halign,g=this.valign,k=this.characterScale,h=this.characterHeight*k,l=this.lineHeight,m=this.characterSpacing,n=this.lines,A=this.textHeight,B,t;0!==e&&(B=Math.cos(e),t=Math.sin(e));for(var y,g=g*cr.max(0,this.height-A),c=b.tlx+c,b=b.tly+d,d=g,g=0;g<n.length;g++){A=n[g].text;y=f*cr.max(0,this.width-n[g].width);for(var d=d+l,K=0;K<A.length;K++){var E=A.charAt(K),N=this.clipUV[E];if(y+this.getCharacterWidth(E)*k>this.width+1E-5)break;
if(void 0!==N){var H=this.characterWidth*k,S=this.characterHeight*k;q.tlx=y;q.tly=d;q.trx=y+H;q.try_=d;q.blx=y;q.bly=d+S;q.brx=y+H;q.bry=d+S;if(0!==e){var H=q,S=B,T=t,Q=void 0,Q=H.tlx*S-H.tly*T;H.tly=H.tly*S+H.tlx*T;H.tlx=Q;Q=H.trx*S-H.try_*T;H.try_=H.try_*S+H.trx*T;H.trx=Q;Q=H.blx*S-H.bly*T;H.bly=H.bly*S+H.blx*T;H.blx=Q;Q=H.brx*S-H.bry*T;H.bry=H.bry*S+H.brx*T;H.brx=Q}q.offset(c,b);a.quadTex(q.tlx,q.tly,q.trx,q.try_,q.brx,q.bry,q.blx,q.bly,N)}y+=this.getCharacterWidth(E)*k+m}d+=h;if(d+h+l>this.height)break}}};
c.prototype.CompareText=function(a,b){return b?this.text==a:cr.equals_nocase(this.text,a)};f.cnds=new c;d.prototype.SetText=function(a){cr.is_number(a)&&1E9>a&&(a=Math.round(1E10*a)/1E10);a=a.toString();this.text!==a&&(this.text=a,this.text_changed=!0,this.runtime.redraw=!0)};d.prototype.AppendText=function(a){cr.is_number(a)&&(a=Math.round(1E10*a)/1E10);if(a=a.toString())this.text+=a,this.text_changed=!0,this.runtime.redraw=!0};d.prototype.SetScale=function(a){a!==this.characterScale&&(this.characterScale=
a,this.text_changed=!0,this.runtime.redraw=!0)};d.prototype.SetCharacterSpacing=function(a){a!==this.CharacterSpacing&&(this.characterSpacing=a,this.text_changed=!0,this.runtime.redraw=!0)};d.prototype.SetLineHeight=function(a){a!==this.lineHeight&&(this.lineHeight=a,this.text_changed=!0,this.runtime.redraw=!0)};g.SetCharWidth=function(a,b){var c=parseInt(b,10);this.characterWidthList[a]!==c&&(this.characterWidthList[a]=c,this.text_changed=!0,this.runtime.redraw=!0)};d.prototype.SetCharacterWidth=
function(a,b){if(""!==a)for(var c=0;c<a.length;c++)this.SetCharWidth(a.charAt(c),b)};d.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};f.acts=new d;e.prototype.CharacterWidth=function(a,b){a.set_int(this.getCharacterWidth(b))};e.prototype.CharacterHeight=function(a){a.set_int(this.characterHeight)};e.prototype.CharacterScale=function(a){a.set_float(this.characterScale)};e.prototype.CharacterSpacing=function(a){a.set_int(this.characterSpacing)};
e.prototype.LineHeight=function(a){a.set_int(this.lineHeight)};e.prototype.Text=function(a){a.set_string(this.text)};e.prototype.TextWidth=function(a){this.rebuildText();a.set_float(this.textWidth)};e.prototype.TextHeight=function(a){this.rebuildText();a.set_float(this.textHeight)};f.exps=new e})();cr.plugins_.Text=function(a){this.runtime=a};
(function(){function a(){return k.length?k.pop():{}}function b(a){var b,c;b=0;for(c=a.length;b<c;b++)k.push(a[b]);a.length=0}function c(){}function d(){}function e(){}var f=cr.plugins_.Text.prototype;f.onCreate=function(){f.acts.SetWidth=function(a){this.width!==a&&(this.width=a,this.text_changed=!0,this.set_bbox_changed())}};f.Type=function(a){this.plugin=a;this.runtime=a.runtime};var g=f.Type.prototype;g.onCreate=function(){};g.onLostWebGLContext=function(){if(!this.is_family){var a,b,c;a=0;for(b=
this.instances.length;a<b;a++)c=this.instances[a],c.mycanvas=null,c.myctx=null,c.mytex=null}};f.Instance=function(a){this.type=a;this.runtime=a.runtime;this.recycled?this.lines.length=0:this.lines=[];this.text_changed=!0};var g=f.Instance.prototype,h={};g.onCreate=function(){this.text=this.properties[0];this.visible=0===this.properties[1];this.font=this.properties[2];this.color=this.properties[3];this.halign=this.properties[4];this.valign=this.properties[5];this.wrapbyword=0===this.properties[7];
this.lastwrapwidth=this.lastwidth=this.width;this.lastheight=this.height;this.line_height_offset=this.properties[8];this.fontstyle=this.facename="";this.textHeight=this.textWidth=this.ptSize=0;this.parseFont();this.mytex=this.myctx=this.mycanvas=null;this.need_text_redraw=!1;this.last_render_tick=this.runtime.tickcount;this.recycled?this.rcTex.set(0,0,1,1):this.rcTex=new cr.rect(0,0,1,1);this.runtime.glwrap&&this.runtime.tickMe(this)};g.parseFont=function(){var a=this.font.split(" "),b;for(b=0;b<
a.length;b++)if("pt"===a[b].substr(a[b].length-2,2)){this.ptSize=parseInt(a[b].substr(0,a[b].length-2));this.pxHeight=Math.ceil(96*(this.ptSize/72))+4;0<b&&(this.fontstyle=a[b-1]);this.facename=a[b+1];for(b+=2;b<a.length;b++)this.facename+=" "+a[b];break}};g.saveToJSON=function(){return{t:this.text,f:this.font,c:this.color,ha:this.halign,va:this.valign,wr:this.wrapbyword,lho:this.line_height_offset,fn:this.facename,fs:this.fontstyle,ps:this.ptSize,pxh:this.pxHeight,tw:this.textWidth,th:this.textHeight,
lrt:this.last_render_tick}};g.loadFromJSON=function(a){this.text=a.t;this.font=a.f;this.color=a.c;this.halign=a.ha;this.valign=a.va;this.wrapbyword=a.wr;this.line_height_offset=a.lho;this.facename=a.fn;this.fontstyle=a.fs;this.ptSize=a.ps;this.pxHeight=a.pxh;this.textWidth=a.tw;this.textHeight=a.th;this.last_render_tick=a.lrt;this.text_changed=!0;this.lastwrapwidth=this.lastwidth=this.width;this.lastheight=this.height};g.tick=function(){if(this.runtime.glwrap&&this.mytex&&300<=this.runtime.tickcount-
this.last_render_tick){var a=this.layer;this.update_bbox();var b=this.bbox;if(b.right<a.viewLeft||b.bottom<a.viewTop||b.left>a.viewRight||b.top>a.viewBottom)this.runtime.glwrap.deleteTexture(this.mytex),this.mycanvas=this.myctx=this.mytex=null}};g.onDestroy=function(){this.mycanvas=this.myctx=null;this.runtime.glwrap&&this.mytex&&this.runtime.glwrap.deleteTexture(this.mytex);this.mytex=null};g.updateFont=function(){this.font=this.fontstyle+" "+this.ptSize.toString()+"pt "+this.facename;this.text_changed=
!0;this.runtime.redraw=!0};g.draw=function(a,b){a.font=this.font;a.textBaseline="top";a.fillStyle=this.color;a.globalAlpha=b?1:this.opacity;var c=1;b&&(c=this.layer.getScale(),a.save(),a.scale(c,c));if(this.text_changed||this.width!==this.lastwrapwidth)this.type.plugin.WordWrap(this.text,this.lines,a,this.width,this.wrapbyword),this.text_changed=!1,this.lastwrapwidth=this.width;this.update_bbox();var c=b?0:this.bquad.tlx,d=b?0:this.bquad.tly;this.runtime.pixel_rounding&&(c=c+0.5|0,d=d+0.5|0);0===
this.angle||b||(a.save(),a.translate(c,d),a.rotate(this.angle),d=c=0);var e=d+this.height,f=this.pxHeight,f=f+this.line_height_offset*this.runtime.devicePixelRatio,g,k;1===this.valign?d+=Math.max(this.height/2-this.lines.length*f/2,0):2===this.valign&&(d+=Math.max(this.height-this.lines.length*f-2,0));for(k=0;k<this.lines.length&&!(g=c,1===this.halign?g=c+(this.width-this.lines[k].width)/2:2===this.halign&&(g=c+(this.width-this.lines[k].width)),a.fillText(this.lines[k].text,g,d),d+=f,d>=e-f);k++);
(0!==this.angle||b)&&a.restore();this.last_render_tick=this.runtime.tickcount};g.drawGL=function(a){if(!(1>this.width||1>this.height)){var b=this.text_changed||this.need_text_redraw;this.need_text_redraw=!1;var c=this.layer.getScale(),d=this.layer.getAngle(),e=this.rcTex,f=c*this.width,g=c*this.height,k=Math.ceil(f),h=Math.ceil(g),l=this.runtime.width/2,I=this.runtime.height/2;this.myctx||(this.mycanvas=document.createElement("canvas"),this.mycanvas.width=k,this.mycanvas.height=h,this.lastwidth=k,
this.lastheight=h,b=!0,this.myctx=this.mycanvas.getContext("2d"));if(k!==this.lastwidth||h!==this.lastheight)this.mycanvas.width=k,this.mycanvas.height=h,this.mytex&&(a.deleteTexture(this.mytex),this.mytex=null),b=!0;b&&(this.myctx.clearRect(0,0,k,h),this.draw(this.myctx,!0),this.mytex||(this.mytex=a.createEmptyTexture(k,h,this.runtime.linearSampling,this.runtime.isMobile)),a.videoToTexture(this.mycanvas,this.mytex,this.runtime.isMobile));this.lastwidth=k;this.lastheight=h;a.setTexture(this.mytex);
a.setOpacity(this.opacity);a.resetModelView();a.translate(-l,-I);a.updateModelView();var D=this.bquad,b=this.layer.layerToCanvas(D.tlx,D.tly,!0),l=this.layer.layerToCanvas(D.tlx,D.tly,!1),I=this.layer.layerToCanvas(D.trx,D.try_,!0),v=this.layer.layerToCanvas(D.trx,D.try_,!1),u=this.layer.layerToCanvas(D.brx,D.bry,!0),z=this.layer.layerToCanvas(D.brx,D.bry,!1),A=this.layer.layerToCanvas(D.blx,D.bly,!0),D=this.layer.layerToCanvas(D.blx,D.bly,!1);if(this.runtime.pixel_rounding||0===this.angle&&0===d)var B=
(b+0.5|0)-b,t=(l+0.5|0)-l,b=b+B,l=l+t,I=I+B,v=v+t,u=u+B,z=z+t,A=A+B,D=D+t;0===this.angle&&0===d?(I=b+k,v=l,u=I,z=l+h,A=b,D=z,e.right=1,e.bottom=1):(e.right=f/k,e.bottom=g/h);a.quadTex(b,l,I,v,u,z,A,D,e);a.resetModelView();a.scale(c,c);a.rotateZ(-this.layer.getAngle());a.translate((this.layer.viewLeft+this.layer.viewRight)/-2,(this.layer.viewTop+this.layer.viewBottom)/-2);a.updateModelView();this.last_render_tick=this.runtime.tickcount}};var l=[];f.TokeniseWords=function(a){l.length=0;for(var b="",
c,d=0;d<a.length;)if(c=a.charAt(d),"\n"===c)b.length&&(l.push(b),b=""),l.push("\n"),++d;else if(" "===c||"\t"===c||"-"===c){do b+=a.charAt(d),d++;while(d<a.length&&(" "===a.charAt(d)||"\t"===a.charAt(d)));l.push(b);b=""}else d<a.length&&(b+=c,d++);b.length&&l.push(b)};var k=[];f.WordWrap=function(c,d,e,f,g){if(c&&c.length)if(2>=f)b(d);else{if(100>=c.length&&-1===c.indexOf("\n")){var k=e.measureText(c).width;if(k<=f){b(d);d.push(a());d[0].text=c;d[0].width=k;return}}this.WrapText(c,d,e,f,g)}else b(d)};
f.WrapText=function(b,c,d,e,f){f&&(this.TokeniseWords(b),b=l);var g="",h,x,C,F=0;for(C=0;C<b.length;C++)"\n"===b[C]?(F>=c.length&&c.push(a()),x=c[F],x.text=g,x.width=d.measureText(g).width,F++,g=""):(h=g,g+=b[C],x=d.measureText(g).width,x>=e&&(F>=c.length&&c.push(a()),x=c[F],x.text=h,x.width=d.measureText(h).width,F++,g=b[C],f||" "!==g||(g="")));g.length&&(F>=c.length&&c.push(a()),x=c[F],x.text=g,x.width=d.measureText(g).width,F++);for(C=F;C<c.length;C++)k.push(c[C]);c.length=F};c.prototype.CompareText=
function(a,b){return b?this.text==a:cr.equals_nocase(this.text,a)};f.cnds=new c;d.prototype.SetText=function(a){cr.is_number(a)&&1E9>a&&(a=Math.round(1E10*a)/1E10);a=a.toString();this.text!==a&&(this.text=a,this.text_changed=!0,this.runtime.redraw=!0)};d.prototype.AppendText=function(a){cr.is_number(a)&&(a=Math.round(1E10*a)/1E10);if(a=a.toString())this.text+=a,this.text_changed=!0,this.runtime.redraw=!0};d.prototype.SetFontFace=function(a,b){var c="";switch(b){case 1:c="bold";break;case 2:c="italic";
break;case 3:c="bold italic"}if(a!==this.facename||c!==this.fontstyle)this.facename=a,this.fontstyle=c,this.updateFont()};d.prototype.SetFontSize=function(a){this.ptSize!==a&&(this.ptSize=a,this.pxHeight=Math.ceil(96*(this.ptSize/72))+4,this.updateFont())};d.prototype.SetFontColor=function(a){a="rgb("+cr.GetRValue(a).toString()+","+cr.GetGValue(a).toString()+","+cr.GetBValue(a).toString()+")";a!==this.color&&(this.color=a,this.need_text_redraw=!0,this.runtime.redraw=!0)};d.prototype.SetWebFont=function(a,
b){if(this.runtime.isDomFree)cr.logexport("[Construct 2] Text plugin: 'Set web font' not supported on this platform - the action has been ignored");else{var c=this,d=function(){c.runtime.redraw=!0;c.text_changed=!0};if(h.hasOwnProperty(b)){var e="'"+a+"'";if(this.facename!==e)for(this.facename=e,this.updateFont(),e=1;10>e;e++)setTimeout(d,100*e),setTimeout(d,1E3*e)}else for(e=document.createElement("link"),e.href=b,e.rel="stylesheet",e.type="text/css",e.onload=d,document.getElementsByTagName("head")[0].appendChild(e),
h[b]=!0,this.facename="'"+a+"'",this.updateFont(),e=1;10>e;e++)setTimeout(d,100*e),setTimeout(d,1E3*e)}};d.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};f.acts=new d;e.prototype.Text=function(a){a.set_string(this.text)};e.prototype.FaceName=function(a){a.set_string(this.facename)};e.prototype.FaceSize=function(a){a.set_int(this.ptSize)};e.prototype.TextWidth=function(a){var b=0,c,d,e;c=0;for(d=this.lines.length;c<
d;c++)e=this.lines[c].width,b<e&&(b=e);a.set_int(b)};e.prototype.TextHeight=function(a){a.set_int(this.lines.length*(this.pxHeight+this.line_height_offset)-this.line_height_offset)};f.exps=new e})();cr.plugins_.TiledBg=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(){}var d=cr.plugins_.TiledBg.prototype;d.Type=function(a){this.plugin=a;this.runtime=a.runtime};var e=d.Type.prototype;e.onCreate=function(){this.is_family||(this.texture_img=new Image,this.texture_img.idtkLoadDisposed=!0,this.texture_img.src=this.texture_file,this.texture_img.cr_filesize=this.texture_filesize,this.runtime.wait_for_textures.push(this.texture_img),this.webGL_texture=this.pattern=null)};e.onLostWebGLContext=function(){this.is_family||
(this.webGL_texture=null)};e.onRestoreWebGLContext=function(){if(!this.is_family&&this.instances.length){this.webGL_texture||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,!0,this.runtime.linearSampling,this.texture_pixelformat));var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].webGL_texture=this.webGL_texture}};e.loadTextures=function(){this.is_family||this.webGL_texture||!this.runtime.glwrap||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,
!0,this.runtime.linearSampling,this.texture_pixelformat))};e.unloadTextures=function(){this.is_family||this.instances.length||!this.webGL_texture||(this.runtime.glwrap.deleteTexture(this.webGL_texture),this.webGL_texture=null)};e.preloadCanvas2D=function(a){a.drawImage(this.texture_img,0,0)};d.Instance=function(a){this.type=a;this.runtime=a.runtime};e=d.Instance.prototype;e.onCreate=function(){this.visible=0===this.properties[0];this.rcTex=new cr.rect(0,0,0,0);this.has_own_texture=!1;this.texture_img=
this.type.texture_img;this.runtime.glwrap?(this.type.loadTextures(),this.webGL_texture=this.type.webGL_texture):(this.type.pattern||(this.type.pattern=this.runtime.ctx.createPattern(this.type.texture_img,"repeat")),this.pattern=this.type.pattern)};e.afterLoad=function(){this.has_own_texture=!1;this.texture_img=this.type.texture_img};e.onDestroy=function(){this.runtime.glwrap&&this.has_own_texture&&this.webGL_texture&&(this.runtime.glwrap.deleteTexture(this.webGL_texture),this.webGL_texture=null)};
e.draw=function(a){a.globalAlpha=this.opacity;a.save();a.fillStyle=this.pattern;var b=this.x,c=this.y;this.runtime.pixel_rounding&&(b=b+0.5|0,c=c+0.5|0);var d=-(this.hotspotX*this.width),e=-(this.hotspotY*this.height),m=d%this.texture_img.width,n=e%this.texture_img.height;0>m&&(m+=this.texture_img.width);0>n&&(n+=this.texture_img.height);a.translate(b,c);a.rotate(this.angle);a.translate(m,n);a.fillRect(d-m,e-n,this.width,this.height);a.restore()};e.drawGL=function(a){a.setTexture(this.webGL_texture);
a.setOpacity(this.opacity);var b=this.rcTex;b.right=this.width/this.texture_img.width;b.bottom=this.height/this.texture_img.height;var c=this.bquad;if(this.runtime.pixel_rounding){var d=(this.x+0.5|0)-this.x,e=(this.y+0.5|0)-this.y;a.quadTex(c.tlx+d,c.tly+e,c.trx+d,c.try_+e,c.brx+d,c.bry+e,c.blx+d,c.bly+e,b)}else a.quadTex(c.tlx,c.tly,c.trx,c.try_,c.brx,c.bry,c.blx,c.bly,b)};a.prototype.OnURLLoaded=function(){return!0};d.cnds=new a;b.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);
cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};b.prototype.LoadURL=function(a){var b=new Image,c=this;b.onload=function(){c.texture_img=b;c.runtime.glwrap?(c.has_own_texture&&c.webGL_texture&&c.runtime.glwrap.deleteTexture(c.webGL_texture),c.webGL_texture=c.runtime.glwrap.loadTexture(b,!0,c.runtime.linearSampling)):c.pattern=c.runtime.ctx.createPattern(b,"repeat");c.has_own_texture=!0;c.runtime.redraw=!0;c.runtime.trigger(cr.plugins_.TiledBg.prototype.cnds.OnURLLoaded,c)};"data:"!==
a.substr(0,5)&&(b.crossOrigin="anonymous");b.src=a};d.acts=new b;c.prototype.ImageWidth=function(a){a.set_float(this.texture_img.width)};c.prototype.ImageHeight=function(a){a.set_float(this.texture_img.height)};d.exps=new c})();cr.plugins_.Touch=function(a){this.runtime=a};
(function(){function a(a){h=a.x;l=a.y;k=a.z}function b(a){m=a.x;n=a.y;q=a.z}function c(){}function d(){}var e=cr.plugins_.Touch.prototype;e.Type=function(a){this.plugin=a;this.runtime=a.runtime};e.Type.prototype.onCreate=function(){};e.Instance=function(a){this.type=a;this.runtime=a.runtime;this.touches=[];this.mouseDown=!1};var f=e.Instance.prototype,g={left:0,top:0};f.findTouch=function(a){var b,c;b=0;for(c=this.touches.length;b<c;b++)if(this.touches[b].id===a)return b;return-1};var h=0,l=0,k=0,
m=0,n=0,q=0;f.onCreate=function(){this.isWindows8=!("undefined"===typeof window.c2isWindows8||!window.c2isWindows8);this.trigger_id=this.trigger_index=this.curTouchY=this.curTouchX=this.acc_z=this.acc_y=this.acc_x=this.acc_g_z=this.acc_g_y=this.acc_g_x=this.orient_gamma=this.orient_beta=this.orient_alpha=0;this.useMouseInput=0!==this.properties[0];var c=0<this.runtime.fullscreen_mode?document:this.runtime.canvas,d=document;this.runtime.isDirectCanvas?d=c=window.Canvas:this.runtime.isCocoonJs&&(d=
c=window);var e=this;window.navigator.msPointerEnabled?(c.addEventListener("MSPointerDown",function(a){e.onPointerStart(a)},!1),c.addEventListener("MSPointerMove",function(a){e.onPointerMove(a)},!1),d.addEventListener("MSPointerUp",function(a){e.onPointerEnd(a)},!1),d.addEventListener("MSPointerCancel",function(a){e.onPointerEnd(a)},!1),this.runtime.canvas&&(this.runtime.canvas.addEventListener("MSGestureHold",function(a){a.preventDefault()},!1),document.addEventListener("MSGestureHold",function(a){a.preventDefault()},
!1))):(c.addEventListener("touchstart",function(a){e.onTouchStart(a)},!1),c.addEventListener("touchmove",function(a){e.onTouchMove(a)},!1),d.addEventListener("touchend",function(a){e.onTouchEnd(a)},!1),d.addEventListener("touchcancel",function(a){e.onTouchEnd(a)},!1));if(this.isWindows8){var f=function(a){a=a.reading;e.acc_x=a.accelerationX;e.acc_y=a.accelerationY;e.acc_z=a.accelerationZ},g=function(a){a=a.reading;e.orient_alpha=a.yawDegrees;e.orient_beta=a.pitchDegrees;e.orient_gamma=a.rollDegrees},
k=Windows.Devices.Sensors.Accelerometer.getDefault();k&&(k.reportInterval=Math.max(k.minimumReportInterval,16),k.addEventListener("readingchanged",f));var h=Windows.Devices.Sensors.Inclinometer.getDefault();h&&(h.reportInterval=Math.max(h.minimumReportInterval,16),h.addEventListener("readingchanged",g));document.addEventListener("visibilitychange",function(a){document.hidden||document.msHidden?(k&&k.removeEventListener("readingchanged",f),h&&h.removeEventListener("readingchanged",g)):(k&&k.addEventListener("readingchanged",
f),h&&h.addEventListener("readingchanged",g))},!1)}else window.addEventListener("deviceorientation",function(a){e.orient_alpha=a.alpha||0;e.orient_beta=a.beta||0;e.orient_gamma=a.gamma||0},!1),window.addEventListener("devicemotion",function(a){a.accelerationIncludingGravity&&(e.acc_g_x=a.accelerationIncludingGravity.x,e.acc_g_y=a.accelerationIncludingGravity.y,e.acc_g_z=a.accelerationIncludingGravity.z);a.acceleration&&(e.acc_x=a.acceleration.x,e.acc_y=a.acceleration.y,e.acc_z=a.acceleration.z)},
!1);this.useMouseInput&&!this.runtime.isDomFree&&(jQuery(document).mousemove(function(a){e.onMouseMove(a)}),jQuery(document).mousedown(function(a){e.onMouseDown(a)}),jQuery(document).mouseup(function(a){e.onMouseUp(a)}));this.runtime.isAppMobi&&!this.runtime.isDirectCanvas&&AppMobi.accelerometer.watchAcceleration(a,{frequency:40,adjustForRotation:!0});this.runtime.isPhoneGap&&navigator.accelerometer.watchAcceleration(b,null,{frequency:40});this.runtime.tick2Me(this)};f.onPointerMove=function(a){if(a.pointerType!==
a.MSPOINTER_TYPE_MOUSE){a.preventDefault&&a.preventDefault();var b=this.findTouch(a.pointerId),c=cr.performance_now();if(0<=b){var d=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset(),b=this.touches[b];2>c-b.time||(b.lasttime=b.time,b.lastx=b.x,b.lasty=b.y,b.time=c,b.x=a.pageX-d.left,b.y=a.pageY-d.top)}}};f.onPointerStart=function(a){if(a.pointerType!==a.MSPOINTER_TYPE_MOUSE){a.preventDefault&&a.preventDefault();var b=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset(),c=a.pageX-
b.left,b=a.pageY-b.top,d=cr.performance_now();this.trigger_index=this.touches.length;this.trigger_id=a.pointerId;this.touches.push({time:d,x:c,y:b,lasttime:d,lastx:c,lasty:b,id:a.pointerId,startindex:this.trigger_index});this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchStart,this);this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchStart,this);this.curTouchX=c;this.curTouchY=b;this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchObject,this)}};f.onPointerEnd=function(a){a.pointerType!==
a.MSPOINTER_TYPE_MOUSE&&(a.preventDefault&&a.preventDefault(),a=this.findTouch(a.pointerId),this.trigger_index=0<=a?this.touches[a].startindex:-1,this.trigger_id=0<=a?this.touches[a].id:-1,this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchEnd,this),this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchEnd,this),0<=a&&this.touches.splice(a,1))};f.onTouchMove=function(a){a.preventDefault&&a.preventDefault();var b=cr.performance_now(),c,d,e,f;c=0;for(d=a.changedTouches.length;c<
d;c++)if(e=a.changedTouches[c],f=this.findTouch(e.identifier),0<=f){var k=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset();f=this.touches[f];2>b-f.time||(f.lasttime=f.time,f.lastx=f.x,f.lasty=f.y,f.time=b,f.x=e.pageX-k.left,f.y=e.pageY-k.top)}};f.onTouchStart=function(a){a.preventDefault&&a.preventDefault();var b=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset(),c=cr.performance_now(),d,e,f,k;d=0;for(e=a.changedTouches.length;d<e;d++)if(f=a.changedTouches[d],k=this.findTouch(f.identifier),
-1===k){k=f.pageX-b.left;var h=f.pageY-b.top;this.trigger_index=this.touches.length;this.trigger_id=f.identifier;this.touches.push({time:c,x:k,y:h,lasttime:c,lastx:k,lasty:h,id:f.identifier,startindex:this.trigger_index});this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchStart,this);this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchStart,this);this.curTouchX=k;this.curTouchY=h;this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchObject,this)}};f.onTouchEnd=function(a){a.preventDefault&&
a.preventDefault();var b,c,d;b=0;for(c=a.changedTouches.length;b<c;b++)d=a.changedTouches[b],d=this.findTouch(d.identifier),0<=d&&(this.trigger_index=this.touches[d].startindex,this.trigger_id=this.touches[d].id,this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchEnd,this),this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchEnd,this),this.touches.splice(d,1))};f.getAlpha=function(){return this.runtime.isAppMobi&&0===this.orient_alpha&&0!==k?90*k:this.runtime.isPhoneGap&&0===this.orient_alpha&&
0!==q?90*q:this.orient_alpha};f.getBeta=function(){return this.runtime.isAppMobi&&0===this.orient_beta&&0!==l?-90*l:this.runtime.isPhoneGap&&0===this.orient_beta&&0!==n?-90*n:this.orient_beta};f.getGamma=function(){return this.runtime.isAppMobi&&0===this.orient_gamma&&0!==h?90*h:this.runtime.isPhoneGap&&0===this.orient_gamma&&0!==m?90*m:this.orient_gamma};f.onMouseDown=function(a){a.preventDefault&&this.runtime.had_a_click&&a.preventDefault();this.onTouchStart({changedTouches:[{pageX:a.pageX,pageY:a.pageY,
identifier:0}]});this.mouseDown=!0};f.onMouseMove=function(a){a.preventDefault&&this.runtime.had_a_click&&a.preventDefault();if(this.mouseDown)this.onTouchMove({changedTouches:[{pageX:a.pageX,pageY:a.pageY,identifier:0}]})};f.onMouseUp=function(a){a.preventDefault&&this.runtime.had_a_click&&a.preventDefault();this.runtime.had_a_click=!0;this.onTouchEnd({changedTouches:[{pageX:a.pageX,pageY:a.pageY,identifier:0}]});this.mouseDown=!1};f.tick2=function(){var a,b,c,d=cr.performance_now();a=0;for(b=this.touches.length;a<
b;a++)c=this.touches[a],c.time<=d-50&&(c.lasttime=d)};c.prototype.OnTouchStart=function(){return!0};c.prototype.OnTouchEnd=function(){return!0};c.prototype.IsInTouch=function(){return this.touches.length};c.prototype.OnTouchObject=function(a){return a?this.runtime.testAndSelectCanvasPointOverlap(a,this.curTouchX,this.curTouchY,!1):!1};c.prototype.IsTouchingObject=function(a){if(!a)return!1;a=a.getCurrentSol();var b=a.getObjects(),c,d,e=[],f,g,k,h;f=0;for(g=b.length;f<g;f++){var l=b[f];l.update_bbox();
k=0;for(h=this.touches.length;k<h;k++)if(d=this.touches[k],c=l.layer.canvasToLayer(d.x,d.y,!0),d=l.layer.canvasToLayer(d.x,d.y,!1),l.contains_pt(c,d)){e.push(l);break}}return e.length?(a.select_all=!1,a.instances=e,!0):!1};c.prototype.CompareTouchSpeed=function(a,b,c){a=Math.floor(a);if(0>a||a>=this.touches.length)return!1;var d=this.touches[a];a=cr.distanceTo(d.x,d.y,d.lastx,d.lasty);var d=(d.time-d.lasttime)/1E3,e=0;0<d&&(e=a/d);return cr.do_cmp(e,b,c)};c.prototype.OrientationSupported=function(){return"undefined"!==
typeof window.DeviceOrientationEvent};c.prototype.MotionSupported=function(){return"undefined"!==typeof window.DeviceMotionEvent};c.prototype.CompareOrientation=function(a,b,c){var d=0,d=0===a?this.getAlpha():1===a?this.getBeta():this.getGamma();return cr.do_cmp(d,b,c)};c.prototype.CompareAcceleration=function(a,b,c){var d=0;0===a?d=this.acc_g_x:1===a?d=this.acc_g_y:2===a?d=this.acc_g_z:3===a?d=this.acc_x:4===a?d=this.acc_y:5===a&&(d=this.acc_z);return cr.do_cmp(d,b,c)};c.prototype.OnNthTouchStart=
function(a){a=Math.floor(a);return a===this.trigger_index};c.prototype.OnNthTouchEnd=function(a){a=Math.floor(a);return a===this.trigger_index};c.prototype.HasNthTouch=function(a){a=Math.floor(a);return this.touches.length>=a+1};e.cnds=new c;d.prototype.TouchCount=function(a){a.set_int(this.touches.length)};d.prototype.X=function(a,b){if(this.touches.length){var c,d,e,f,g;cr.is_undefined(b)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxX,g=c.angle,c.scale=this.runtime.running_layout.scale,
c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=g):(c=cr.is_number(b)?this.runtime.getLayerByNumber(b):this.runtime.getLayerByName(b))?a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!0)):a.set_float(0)}else a.set_float(0)};d.prototype.XAt=function(a,b,c){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);else{var d,e,f,g;cr.is_undefined(c)?
(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxX,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!0)):a.set_float(0)}};d.prototype.XForID=function(a,
b,c){b=this.findTouch(b);if(0>b)a.set_float(0);else{b=this.touches[b];var d,e,f,g;cr.is_undefined(c)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxX,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(b.x,b.y,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(b.x,b.y,
!0)):a.set_float(0)}};d.prototype.Y=function(a,b){if(this.touches.length){var c,d,e,f,g;cr.is_undefined(b)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxY,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!1)),c.scale=d,c.zoomRate=e,c.parallaxY=f,c.angle=g):(c=cr.is_number(b)?this.runtime.getLayerByNumber(b):this.runtime.getLayerByName(b))?
a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!1)):a.set_float(0)}else a.set_float(0)};d.prototype.YAt=function(a,b,c){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);else{var d,e,f,g;cr.is_undefined(c)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxY,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!1)),c.scale=
d,c.zoomRate=e,c.parallaxY=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!1)):a.set_float(0)}};d.prototype.YForID=function(a,b,c){b=this.findTouch(b);if(0>b)a.set_float(0);else{b=this.touches[b];var d,e,f,g;cr.is_undefined(c)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxY,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=
this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(b.x,b.y,!1)),c.scale=d,c.zoomRate=e,c.parallaxY=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(b.x,b.y,!1)):a.set_float(0)}};d.prototype.AbsoluteX=function(a){this.touches.length?a.set_float(this.touches[0].x):a.set_float(0)};d.prototype.AbsoluteXAt=function(a,b){b=Math.floor(b);0>b||b>=this.touches.length?a.set_float(0):a.set_float(this.touches[b].x)};d.prototype.AbsoluteXForID=
function(a,b){var c=this.findTouch(b);0>c?a.set_float(0):a.set_float(this.touches[c].x)};d.prototype.AbsoluteY=function(a){this.touches.length?a.set_float(this.touches[0].y):a.set_float(0)};d.prototype.AbsoluteYAt=function(a,b){b=Math.floor(b);0>b||b>=this.touches.length?a.set_float(0):a.set_float(this.touches[b].y)};d.prototype.AbsoluteYForID=function(a,b){var c=this.findTouch(b);0>c?a.set_float(0):a.set_float(this.touches[c].y)};d.prototype.SpeedAt=function(a,b){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);
else{var c=this.touches[b],d=cr.distanceTo(c.x,c.y,c.lastx,c.lasty),c=(c.time-c.lasttime)/1E3;0===c?a.set_float(0):a.set_float(d/c)}};d.prototype.SpeedForID=function(a,b){var c=this.findTouch(b);if(0>c)a.set_float(0);else{var d=this.touches[c],c=cr.distanceTo(d.x,d.y,d.lastx,d.lasty),d=(d.time-d.lasttime)/1E3;0===d?a.set_float(0):a.set_float(c/d)}};d.prototype.AngleAt=function(a,b){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);else{var c=this.touches[b];a.set_float(cr.to_degrees(cr.angleTo(c.lastx,
c.lasty,c.x,c.y)))}};d.prototype.AngleForID=function(a,b){var c=this.findTouch(b);0>c?a.set_float(0):(c=this.touches[c],a.set_float(cr.to_degrees(cr.angleTo(c.lastx,c.lasty,c.x,c.y))))};d.prototype.Alpha=function(a){a.set_float(this.getAlpha())};d.prototype.Beta=function(a){a.set_float(this.getBeta())};d.prototype.Gamma=function(a){a.set_float(this.getGamma())};d.prototype.AccelerationXWithG=function(a){a.set_float(this.acc_g_x)};d.prototype.AccelerationYWithG=function(a){a.set_float(this.acc_g_y)};
d.prototype.AccelerationZWithG=function(a){a.set_float(this.acc_g_z)};d.prototype.AccelerationX=function(a){a.set_float(this.acc_x)};d.prototype.AccelerationY=function(a){a.set_float(this.acc_y)};d.prototype.AccelerationZ=function(a){a.set_float(this.acc_z)};d.prototype.TouchIndex=function(a){a.set_int(this.trigger_index)};d.prototype.TouchID=function(a){a.set_float(this.trigger_id)};e.exps=new d})();cr.behaviors.Fade=function(a){this.runtime=a};
(function(){function a(){}function b(){}var c=cr.behaviors.Fade.prototype;c.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};c.Type.prototype.onCreate=function(){};c.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var d=c.Instance.prototype;d.onCreate=function(){var a=1===this.properties[0];this.fadeInTime=this.properties[1];this.waitTime=this.properties[2];this.fadeOutTime=this.properties[3];this.destroy=this.properties[4];
this.stage=a?0:3;this.recycled?this.stageTime.reset():this.stageTime=new cr.KahanAdder;this.maxOpacity=this.inst.opacity?this.inst.opacity:1;a&&(0===this.fadeInTime?(this.stage=1,0===this.waitTime&&(this.stage=2)):(this.inst.opacity=0,this.runtime.redraw=!0))};d.saveToJSON=function(){return{fit:this.fadeInTime,wt:this.waitTime,fot:this.fadeOutTime,s:this.stage,st:this.stageTime.sum,mo:this.maxOpacity}};d.loadFromJSON=function(a){this.fadeInTime=a.fit;this.waitTime=a.wt;this.fadeOutTime=a.fot;this.stage=
a.s;this.stageTime.reset();this.stageTime.sum=a.st;this.maxOpacity=a.mo};d.tick=function(){this.stageTime.add(this.runtime.getDt(this.inst));0===this.stage&&(this.inst.opacity=this.stageTime.sum/this.fadeInTime*this.maxOpacity,this.runtime.redraw=!0,this.inst.opacity>=this.maxOpacity&&(this.inst.opacity=this.maxOpacity,this.stage=1,this.stageTime.reset()));1===this.stage&&this.stageTime.sum>=this.waitTime&&(this.stage=2,this.stageTime.reset());2===this.stage&&0!==this.fadeOutTime&&(this.inst.opacity=
this.maxOpacity-this.stageTime.sum/this.fadeOutTime*this.maxOpacity,this.runtime.redraw=!0,0>this.inst.opacity&&(this.inst.opacity=0,this.stage=3,this.stageTime.reset(),this.runtime.trigger(cr.behaviors.Fade.prototype.cnds.OnFadeOutEnd,this.inst),1===this.destroy&&this.runtime.DestroyInstance(this.inst)))};d.doStart=function(){this.stage=0;this.stageTime.reset();0===this.fadeInTime?(this.stage=1,0===this.waitTime&&(this.stage=2)):(this.inst.opacity=0,this.runtime.redraw=!0)};a.prototype.OnFadeOutEnd=
function(){return!0};c.cnds=new a;b.prototype.StartFade=function(){3===this.stage&&this.doStart()};b.prototype.RestartFade=function(){this.doStart()};c.acts=new b})();var Box2D={Dynamics:{}};Box2D.Dynamics.Joints={};Box2D.Common={};Box2D.Common.Math={};Box2D.Collision={};Box2D.Collision.Shapes={};function c2inherit(a,b){for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c])}
if(navigator.isCocoonJS&&"undefined"!==typeof window.cr_cjs_accelerated_physics)cr.logexport("Using CocoonJS native physics"),window.ext&&"undefined"!==typeof window.ext.IDTK_SRV_BOX2D?function(){var a=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.x=a;this.y=b};Box2D.Common.Math.b2Vec2=a;a._freeCache=[];a.Get=function(a,b){if(0<Box2D.Common.Math.b2Vec2._freeCache.length){var c=Box2D.Common.Math.b2Vec2._freeCache.pop();c.Set(a,b);return c}return new Box2D.Common.Math.b2Vec2(a,b)};a.Free=function(a){1E4>
Box2D.Common.Math.b2Vec2._freeCache.length&&Box2D.Common.Math.b2Vec2._freeCache.push(a)};a.prototype.SetZero=function(){this.y=this.x=0};a.prototype.Set=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.x=a;this.y=b};a.prototype.SetV=function(a){this.x=a.x;this.y=a.y};a.Make=function(b,c){void 0===b&&(b=0);void 0===c&&(c=0);return a.Get(b,c)};a.prototype.Copy=function(){return a.Get(this.x,this.y)};a.prototype.Add=function(a){this.x+=a.x;this.y+=a.y};a.prototype.Subtract=function(a){this.x-=
a.x;this.y-=a.y};a.prototype.Multiply=function(a){void 0===a&&(a=0);this.x*=a;this.y*=a};a.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y};a.prototype.Normalize=function(){var a=Math.sqrt(this.x*this.x+this.y*this.y);if(a<Number.MIN_VALUE)return 0;var b=1/a;this.x*=b;this.y*=b;return a};var b=function(){this.col1=a.Get(0,0);this.col2=a.Get(0,0);this.SetIdentity()};Box2D.Common.Math.b2Mat22=b;b.FromAngle=
function(a){void 0===a&&(a=0);var c=new b;c.Set(a);return c};b.FromVV=function(a,c){var d=new b;d.SetVV(a,c);return d};b.prototype.Set=function(a){void 0===a&&(a=0);var b=Math.cos(a);a=Math.sin(a);this.col1.x=b;this.col2.x=-a;this.col1.y=a;this.col2.y=b};b.prototype.SetVV=function(a,b){this.col1.SetV(a);this.col2.SetV(b)};b.prototype.Copy=function(){var a=new b;a.SetM(this);return a};b.prototype.SetM=function(a){this.col1.SetV(a.col1);this.col2.SetV(a.col2)};b.prototype.AddM=function(a){this.col1.x+=
a.col1.x;this.col1.y+=a.col1.y;this.col2.x+=a.col2.x;this.col2.y+=a.col2.y};b.prototype.SetIdentity=function(){this.col1.x=1;this.col2.x=0;this.col1.y=0;this.col2.y=1};b.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col1.y=0;this.col2.y=0};b.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)};b.prototype.GetInverse=function(a){var b=this.col1.x,c=this.col2.x,d=this.col1.y,e=this.col2.y,f=b*e-c*d;0!==f&&(f=1/f);a.col1.x=f*e;a.col2.x=-f*c;a.col1.y=-f*d;a.col2.y=
f*b;return a};b.prototype.Solve=function(a,b,c){void 0===b&&(b=0);void 0===c&&(c=0);var d=this.col1.x,e=this.col2.x,f=this.col1.y,g=this.col2.y,h=d*g-e*f;0!==h&&(h=1/h);a.x=h*(g*b-e*c);a.y=h*(d*c-f*b);return a};b.prototype.Abs=function(){this.col1.Abs();this.col2.Abs()};var c=function(c,d){this.position=a.Get(0,0);this.R=new b;void 0===c&&(c=null);void 0===d&&(d=null);c&&(this.position.SetV(c),this.R.SetM(d))};Box2D.Common.Math.b2Transform=c;c.prototype.Initialize=function(a,b){this.position.SetV(a);
this.R.SetM(b)};c.prototype.SetIdentity=function(){this.position.SetZero();this.R.SetIdentity()};c.prototype.Set=function(a){this.position.SetV(a.position);this.R.SetM(a.R)};c.prototype.SetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)};var d=function(){};Box2D.Common.Math.b2Math=d;d.IsValid=function(a){void 0===a&&(a=0);return isFinite(a)};d.Dot=function(a,b){return a.x*b.x+a.y*b.y};d.CrossVV=function(a,b){return a.x*b.y-a.y*b.x};d.CrossVF=function(b,c){void 0===c&&(c=0);return a.Get(c*
b.y,-c*b.x)};d.CrossFV=function(b,c){void 0===b&&(b=0);return a.Get(-b*c.y,b*c.x)};d.MulMV=function(b,c){return a.Get(b.col1.x*c.x+b.col2.x*c.y,b.col1.y*c.x+b.col2.y*c.y)};d.MulTMV=function(b,c){return a.Get(d.Dot(c,b.col1),d.Dot(c,b.col2))};d.MulX=function(a,b){var c=d.MulMV(a.R,b);c.x+=a.position.x;c.y+=a.position.y;return c};d.MulXT=function(a,b){var c=d.SubtractVV(b,a.position),e=c.x*a.R.col1.x+c.y*a.R.col1.y;c.y=c.x*a.R.col2.x+c.y*a.R.col2.y;c.x=e;return c};d.AddVV=function(b,c){return a.Get(b.x+
c.x,b.y+c.y)};d.SubtractVV=function(b,c){return a.Get(b.x-c.x,b.y-c.y)};d.Distance=function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)};d.DistanceSquared=function(a,b){var c=a.x-b.x,d=a.y-b.y;return c*c+d*d};d.MulFV=function(b,c){void 0===b&&(b=0);return a.Get(b*c.x,b*c.y)};d.AddMM=function(a,c){return b.FromVV(d.AddVV(a.col1,c.col1),d.AddVV(a.col2,c.col2))};d.MulMM=function(a,c){return b.FromVV(d.MulMV(a,c.col1),d.MulMV(a,c.col2))};d.MulTMM=function(c,e){var f=a.Get(d.Dot(c.col1,e.col1),
d.Dot(c.col2,e.col1)),g=a.Get(d.Dot(c.col1,e.col2),d.Dot(c.col2,e.col2));return b.FromVV(f,g)};d.Abs=function(a){void 0===a&&(a=0);return 0<a?a:-a};d.AbsV=function(b){return a.Get(d.Abs(b.x),d.Abs(b.y))};d.AbsM=function(a){return b.FromVV(d.AbsV(a.col1),d.AbsV(a.col2))};d.Min=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);return a<b?a:b};d.MinV=function(b,c){return a.Get(d.Min(b.x,c.x),d.Min(b.y,c.y))};d.Max=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);return a>b?a:b};d.MaxV=function(b,c){return a.Get(d.Max(b.x,
c.x),d.Max(b.y,c.y))};d.Clamp=function(a,b,c){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);return a<b?b:a>c?c:a};d.ClampV=function(a,b,c){return d.MaxV(b,d.MinV(a,c))};d.Swap=function(a,b){var c=a[0];a[0]=b[0];b[0]=c};d.Random=function(){return 2*Math.random()-1};d.RandomRange=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);var c=Math.random();return(b-a)*c+a};d.NextPowerOfTwo=function(a){void 0===a&&(a=0);a|=a>>1&2147483647;a|=a>>2&1073741823;a|=a>>4&268435455;a|=a>>8&16777215;return(a|
a>>16&65535)+1};d.IsPowerOfTwo=function(a){void 0===a&&(a=0);return 0<a&&0===(a&a-1)};d.b2Vec2_zero=new a(0,0);d.b2Mat22_identity=b.FromVV(new a(1,0),new a(0,1));d.b2Transform_identity=new c(d.b2Vec2_zero,d.b2Mat22_identity);var e=function(){this.e_aabbBit=4;this.e_centerOfMassBit=16;this.e_controllerBit=32;this.e_jointBit=2;this.e_pairBit=8;this.e_shapeBit=0};Box2D.Dynamics.b2DebugDraw=e;e.prototype.AppendFlags=function(){};e.prototype.ClearFlags=function(){};e.prototype.DrawCircle=function(){};
e.prototype.DrawPolygon=function(){};e.prototype.DrawSegment=function(){};e.prototype.DrawSolidCircle=function(){};e.prototype.DrawSolidPolygon=function(){};e.prototype.DrawTransform=function(){};e.prototype.GetAlpha=function(){};e.prototype.GetDrawScale=function(){};e.prototype.GetFillAlpha=function(){};e.prototype.GetFlags=function(){};e.prototype.GetLineThickness=function(){};e.prototype.GetSprite=function(){};e.prototype.GetXFormScale=function(){};e.prototype.SetAlpha=function(){};e.prototype.SetDrawScale=
function(){};e.prototype.SetFillAlpha=function(){};e.prototype.SetFlags=function(){};e.prototype.SetLineThickness=function(){};e.prototype.SetSprite=function(){};e.prototype.SetXFormScale=function(){};Box2D.Dynamics.b2BodyDef=function(){this.position=a.Get(0,0);this.linearVelocity=a.Get(0,0);this.userData=null;this.angle=0;this.linearVelocity.Set(0,0);this.angularDamping=this.linearDamping=this.angularVelocity=0;this.awake=this.allowSleep=!0;this.bullet=this.fixedRotation=!1;this.type=g.b2_staticBody;
this.active=!0;this.inertiaScale=1};var f=function(b,c,d,e){this.m_body=b;this.m_userData=c;this.m_fixtureID=d;this.m_shape={};this.m_shape.m_centroid=a.Get(0,0);this.m_isSensor=!1;this.m_density=e.density;this.m_friction=e.friction;this.m_restitution=e.restitution;this.m_isSensor=e.isSensor};Box2D.Dynamics.b2Fixture=f;f.prototype.GetBody=function(){return this.m_body};f.prototype.GetShape=function(){console.log("fixture.GetShape not yet supported in CocoonJS Box2D binding");return null};f.prototype.GetUserData=
function(){return this.m_userData};f.prototype.SetSensor=function(a){this.m_isSensor=a;window.ext.IDTK_SRV_BOX2D.makeCall("setSensor",this.m_body.m_world.m_worldID,this.m_fixtureID,this.m_isSensor)};f.prototype.IsSensor=function(){return this.m_isSensor};f.prototype.SetDensity=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setDensity",this.m_body.m_world.m_worldID,this.m_fixtureID,a);this.m_density=a};f.prototype.SetFriction=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setFriction",this.m_body.m_world.m_worldID,
this.m_fixtureID,a);this.m_friction=a};f.prototype.SetRestitution=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setRestitution",this.m_body.m_world.m_worldID,this.m_fixtureID,a);this.m_restitution=a};f.prototype.GetDensity=function(){return this.m_density};f.prototype.GetFriction=function(){return this.m_friction};f.prototype.GetRestitution=function(){return this.m_restitution};var g=function(a,d){var e=a.userData;a.userData=null;this.m_world=d;this.m_xf=new c(a.position,b.FromAngle(a.angle));this.m_fixtures=
[];this.m_active=a.active;a.type===g.b2_staticBody&&(a.density=0);this.m_bodyID=window.ext.IDTK_SRV_BOX2D.makeCall("createBody",d.m_worldID,a);this.m_userData=e;a.userData=e};Box2D.Dynamics.b2Body=g;g.prototype.CreateFixture=function(a){var b=a.userData;a.userData=null;var c=window.ext.IDTK_SRV_BOX2D.makeCall("createFixture",this.m_world.m_worldID,this.m_bodyID,a);a.userData=b;a=new f(this,b,c,a);this.m_world.m_fixturesList[c]=a;this.m_fixtures.push(a);return a};g.prototype.GetFixtureList=function(){return 0===
this.m_fixtures.length?null:this.m_fixtures[0]};g.prototype.DestroyFixture=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("deleteFixture",this.m_world.m_worldID,a.m_fixtureID);delete this.m_world.m_fixturesList[a.m_fixtureID]};g.prototype.SetPositionAndAngle=function(a,b){window.ext.IDTK_SRV_BOX2D.makeCall("setBodyTransform",this.m_world.m_worldID,this.m_bodyID,a.x,a.y,b);this.m_xf.R.Set(b);this.m_xf.position.SetV(a)};g.prototype.GetPosition=function(){return this.m_xf.position};g.prototype.SetPosition=
function(a){this.SetPositionAndAngle(a,this.GetAngle())};g.prototype.GetLinearVelocity=function(){var b=window.ext.IDTK_SRV_BOX2D.makeCall("getLinearVelocity",this.m_world.m_worldID,this.m_bodyID);return a.Get(b[0],b[1])};g.prototype.GetWorldCenter=function(){var b=window.ext.IDTK_SRV_BOX2D.makeCall("getWorldCenter",this.m_world.m_worldID,this.m_bodyID);return a.Get(b[0],b[1])};g.prototype.GetLocalCenter=function(){var b=window.ext.IDTK_SRV_BOX2D.makeCall("getLocalCenter",this.m_world.m_worldID,this.m_bodyID);
return a.Get(b[0],b[1])};g.prototype.GetLocalPoint=function(a){return d.MulXT(this.m_xf,a)};g.prototype.ApplyImpulse=function(a,b,c){window.ext.IDTK_SRV_BOX2D.makeCall("applyImpulse",this.m_world.m_worldID,this.m_bodyID,a.x,a.y,b.x,b.y,c)};g.prototype.IsAwake=function(){return window.ext.IDTK_SRV_BOX2D.makeCall("isAwake",this.m_world.m_worldID,this.m_bodyID)};g.prototype.GetAngularVelocity=function(){return window.ext.IDTK_SRV_BOX2D.makeCall("getAngularVelocity",this.m_world.m_worldID,this.m_bodyID)};
g.prototype.SetFixedRotation=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setFixedRotation",this.m_world.m_worldID,this.m_bodyID,a)};g.prototype.SetAwake=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setAwake",this.m_world.m_worldID,this.m_bodyID,a)};g.prototype.SetLinearVelocity=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setLinearVelocity",this.m_world.m_worldID,this.m_bodyID,a.x,a.y)};g.prototype.ApplyForceToCenter=function(a,b){window.ext.IDTK_SRV_BOX2D.makeCall("applyForceToCenter",
this.m_world.m_worldID,this.m_bodyID,a.x,a.y,b)};g.prototype.ApplyForce=function(a,b,c){window.ext.IDTK_SRV_BOX2D.makeCall("applyForce",this.m_world.m_worldID,this.m_bodyID,a.x,a.y,b.x,b.y,c)};g.prototype.ApplyTorque=function(a,b){window.ext.IDTK_SRV_BOX2D.makeCall("applyTorque",this.m_world.m_worldID,this.m_bodyID,a,b)};g.prototype.SetLinearDamping=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setLinearDamping",this.m_world.m_worldID,this.m_bodyID,a)};g.prototype.SetAngularVelocity=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setAngularVelocity",
this.m_world.m_worldID,this.m_bodyID,a)};g.prototype.SetType=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setType",this.m_world.m_worldID,this.m_bodyID,a)};g.prototype.SetActive=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setActive",this.m_world.m_worldID,this.m_bodyID,a);this.m_active=a};g.prototype.IsActive=function(){return this.m_active};g.prototype.GetAngle=function(){return this.m_xf.R.GetAngle()};g.prototype.SetAngle=function(a){void 0===a&&(a=0);this.SetPositionAndAngle(this.GetPosition(),
a)};g.prototype.GetContactList=function(){for(var a=window.ext.IDTK_SRV_BOX2D.makeCall("getObjectContacts",this.m_world.m_worldID,this.m_bodyID),b=[],c=0;c<a.length;c++)b.push(this.m_world.m_bodyList[a[c]]);return b};g.prototype.SetUserData=function(a){this.m_userData=a};g.prototype.GetUserData=function(){return this.m_userData};g.prototype.GetWorld=function(){return this.m_world};Box2D.Dynamics.b2Body.b2_staticBody=0;Box2D.Dynamics.b2Body.b2_kinematicBody=1;Box2D.Dynamics.b2Body.b2_dynamicBody=2;
var h=function(a,b,c){this.m_fixtureA=a;this.m_fixtureB=b;this.m_touching=c};Box2D.Dynamics.b2Contact=h;h.prototype.GetFixtureA=function(){return this.m_fixtureA};h.prototype.GetFixtureB=function(){return this.m_fixtureB};h.prototype.IsTouching=function(){return this.m_touching};e=function(){};Box2D.Dynamics.b2ContactListener=e;e.prototype.BeginContact=function(){};e.prototype.EndContact=function(){};e.prototype.PreSolve=function(){};e.prototype.PostSolve=function(){};Box2D.Dynamics.b2ContactListener.b2_defaultListener=
new e;Box2D.Dynamics.b2ContactFilter=function(){};e=function(a,b){this.m_bodyList=[];this.m_jointList=[];this.m_fixturesList=[];this.m_contactListener=null;this.m_jointsList=[];this.m_worldID=window.ext.IDTK_SRV_BOX2D.makeCall("createWorld",a.x,a.y,b)};Box2D.Dynamics.b2World=e;e.prototype.SetContactListener=function(a){this.m_contactListener=a};e.prototype.SetContactFilter=function(a){var b=this;window.ext.IDTK_SRV_BOX2D.makeCall("setContactFilter",this.m_worldID,function(c,d){return a.ShouldCollide(b.m_fixturesList[c],
b.m_fixturesList[d])})};e.prototype.CreateBody=function(a){a=new g(a,this);return this.m_bodyList[a.m_bodyID]=a};e.prototype.DestroyBody=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("deleteBody",this.m_worldID,a.m_bodyID);delete this.m_bodyList[a.m_bodyID];for(var b=0;b<a.m_fixtures.length;++b)delete this.m_fixturesList[a.m_fixtures[b].m_fixtureID]};e.prototype.CreateJoint=function(a){if(a.bodyA.m_bodyID!==a.bodyB.m_bodyID){var b=a.bodyA,c=a.bodyB;a.bodyA=b.m_bodyID;a.bodyB=c.m_bodyID;var d="createDistanceJoint";
a.type===l.e_revoluteJoint&&(d="createRevoluteJoint");var e=new l(a);e.m_jointID=window.ext.IDTK_SRV_BOX2D.makeCall(d,this.m_worldID,a);a.bodyA=b;a.bodyB=c;this.m_jointsList.push(e);return e}};e.prototype.DestroyJoint=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("destroyJoint",this.m_worldID,a.m_jointID)};e.prototype.GetJointList=function(){if(0===this.m_jointsList.length)return null;for(var a=0;a<this.m_jointsList.length-1;++a)this.m_jointsList[a].next=this.m_jointsList[a+1];this.m_jointsList[this.m_jointsList.length-
1].next=null;return this.m_jointsList[0]};e.prototype.SetContinuousPhysics=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setContinuous",this.m_worldID,a)};e.prototype.SetGravity=function(a){window.ext.IDTK_SRV_BOX2D.makeCall("setGravity",this.m_worldID,a.x,a.y)};e.prototype.Step=function(a,b,c){c=window.ext.IDTK_SRV_BOX2D.makeCall("step",this.m_worldID,a,b,c);b=c[0];for(a=1;a<=4*b;a+=4){var d=this.m_bodyList[c[a+0]];if(null===d)break;d.m_xf.position.Set(c[a+1],c[a+2]);d.m_xf.R.Set(c[a+3])}if(null!==
this.m_contactListener)for(c=window.ext.IDTK_SRV_BOX2D.makeCall("getLastContacts",this.m_worldID),b=c[0],a=1;a<=3*b;a+=3){var d=c[a+2],e=this.m_fixturesList[c[a+0]],f=this.m_fixturesList[c[a+1]];"undefined"===typeof e||"undefined"===typeof f?console.log("One of the fixtures in a contact DOESN'T EXIST!!"):this.m_contactListener.BeginContact(new h(e,f,d))}};e.prototype.ClearForces=function(){window.ext.IDTK_SRV_BOX2D.makeCall("clearForces",this.m_worldID)};e.prototype.SetDebugDraw=function(){};e.prototype.DrawDebugData=
function(){};Box2D.Collision.Shapes.b2CircleShape=function(a){this.radius=a;this.type="circle"};Box2D.Collision.Shapes.b2PolygonShape=function(){};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsBox=function(a,b){this.type="box";this.width=a;this.height=b};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsEdge=function(a,b){this.type="edge";this.p1x=a.x;this.p1y=a.y;this.p2x=b.x;this.p2y=b.y};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsArray=function(a,b){this.type="polygon";this.vertices=
[];for(var c=0;c<b;c++)this.vertices.push(a[c].x),this.vertices.push(a[c].y)};Box2D.Dynamics.b2FixtureDef=function(){this.userData=this.shape=null;this.friction=0.2;this.density=this.restitution=0;this.isSensor=!1;this.filter={categoryBits:1,maskBits:65535,groupIndex:0}};var l=function(a){this.bodyA=a.bodyA;this.bodyB=a.bodyB;this.userData=a.userData;this.type=a.type;this.next=null};Box2D.Dynamics.Joints.b2Joint=l;l.prototype.GetBodyA=function(){return this.bodyA};l.prototype.GetBodyB=function(){return this.bodyB};
l.prototype.GetUserData=function(){return this.userData};l.prototype.GetType=function(){return this.type};l.prototype.GetNext=function(){return this.next};l.e_distanceJoint=0;l.e_revoluteJoint=1;Box2D.Dynamics.Joints.b2DistanceJointDef=function(b,c,d,e){this.type=l.e_distanceJoint;this.localAnchorA=a.Get(0,0);this.localAnchorB=a.Get(0,0);this.userData=null;void 0!==b&&(this.bodyA=b);void 0!==c&&(this.bodyB=c);void 0!==d&&this.localAnchorA.SetV(d);void 0!==e&&this.localAnchorB.SetV(e);void 0!==d&&
void 0!==e&&(b=e.x-d.x,d=e.y-d.y,this.length=Math.sqrt(b*b+d*d));this.dampingRatio=this.frequencyHz=0};e=function(b,c,d,e){this.type=l.e_revoluteJoint;this.localAnchorA=new a;this.localAnchorB=new a;this.userData=null;void 0!==b&&(this.bodyA=b);void 0!==c&&(this.bodyB=c);void 0!==d&&this.localAnchorA.SetV(d);void 0!==e&&this.localAnchorB.SetV(e);this.motorSpeed=this.maxMotorTorque=this.upperAngle=this.lowerAngle=this.referenceAngle=0;this.enableMotor=this.enableLimit=!1};e.prototype.Initialize=function(a,
b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.Dynamics.Joints.b2RevoluteJointDef=e}():console.log("The CocoonJS binding for Box2D has been ignored because ext.IDTK_SRV_BOX2D is not available");else{Box2D.Collision.b2Collision={};Box2D.Collision.b2Distance={};Box2D.Common.b2Settings={};Box2D.Common.Math.b2Math={};Box2D.Consts={};Box2D.Dynamics.Contacts=
{};Box2D.Dynamics.Controllers={};Box2D.generateCallback=function(a,b){return function(){b.apply(a,arguments)}};Box2D.Consts.MIN_VALUE_SQUARED=Number.MIN_VALUE*Number.MIN_VALUE;Box2D.Common.b2Settings.b2MixFriction=function(a,b){return Math.sqrt(a*b)};Box2D.Common.b2Settings.b2MixRestitution=function(a,b){return a>b?a:b};Box2D.Common.b2Settings.VERSION="2.1alpha-illandril";Box2D.Common.b2Settings.USHRT_MAX=65535;Box2D.Common.b2Settings.b2_maxManifoldPoints=2;Box2D.Common.b2Settings.b2_aabbExtension=
0.1;Box2D.Common.b2Settings.b2_aabbMultiplier=2;Box2D.Common.b2Settings.b2_polygonRadius=2*Box2D.Common.b2Settings.b2_linearSlop;Box2D.Common.b2Settings.b2_linearSlop=0.005;Box2D.Common.b2Settings.b2_angularSlop=2/180*Math.PI;Box2D.Common.b2Settings.b2_toiSlop=8*Box2D.Common.b2Settings.b2_linearSlop;Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland=32;Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland=32;Box2D.Common.b2Settings.b2_velocityThreshold=1;Box2D.Common.b2Settings.b2_maxLinearCorrection=
0.2;Box2D.Common.b2Settings.b2_maxAngularCorrection=8/180*Math.PI;Box2D.Common.b2Settings.b2_maxTranslation=2;Box2D.Common.b2Settings.b2_maxTranslationSquared=Box2D.Common.b2Settings.b2_maxTranslation*Box2D.Common.b2Settings.b2_maxTranslation;Box2D.Common.b2Settings.b2_maxRotation=0.5*Math.PI;Box2D.Common.b2Settings.b2_maxRotationSquared=Box2D.Common.b2Settings.b2_maxRotation*Box2D.Common.b2Settings.b2_maxRotation;Box2D.Common.b2Settings.b2_contactBaumgarte=0.2;Box2D.Common.b2Settings.b2_timeToSleep=
0.5;Box2D.Common.b2Settings.b2_linearSleepTolerance=0.01;Box2D.Common.b2Settings.b2_linearSleepToleranceSquared=Box2D.Common.b2Settings.b2_linearSleepTolerance*Box2D.Common.b2Settings.b2_linearSleepTolerance;Box2D.Common.b2Settings.b2_angularSleepTolerance=2/180*Math.PI;Box2D.Common.b2Settings.b2_angularSleepToleranceSquared=Box2D.Common.b2Settings.b2_angularSleepTolerance*Box2D.Common.b2Settings.b2_angularSleepTolerance;Box2D.Common.b2Settings.MIN_VALUE_SQUARED=Number.MIN_VALUE*Number.MIN_VALUE;
Box2D.Common.Math.b2Math.Dot=function(a,b){return a.x*b.x+a.y*b.y};Box2D.Common.Math.b2Math.CrossVV=function(a,b){return a.x*b.y-a.y*b.x};Box2D.Common.Math.b2Math.CrossVF=function(a,b){return Box2D.Common.Math.b2Vec2.Get(b*a.y,-b*a.x)};Box2D.Common.Math.b2Math.CrossFV=function(a,b){return Box2D.Common.Math.b2Vec2.Get(-a*b.y,a*b.x)};Box2D.Common.Math.b2Math.MulMV=function(a,b){return Box2D.Common.Math.b2Vec2.Get(a.col1.x*b.x+a.col2.x*b.y,a.col1.y*b.x+a.col2.y*b.y)};Box2D.Common.Math.b2Math.MulTMV=
function(a,b){return Box2D.Common.Math.b2Vec2.Get(Box2D.Common.Math.b2Math.Dot(b,a.col1),Box2D.Common.Math.b2Math.Dot(b,a.col2))};Box2D.Common.Math.b2Math.MulX=function(a,b){var c=Box2D.Common.Math.b2Math.MulMV(a.R,b);c.x+=a.position.x;c.y+=a.position.y;return c};Box2D.Common.Math.b2Math.MulXT=function(a,b){var c=Box2D.Common.Math.b2Math.SubtractVV(b,a.position),d=c.x*a.R.col1.x+c.y*a.R.col1.y;c.y=c.x*a.R.col2.x+c.y*a.R.col2.y;c.x=d;return c};Box2D.Common.Math.b2Math.AddVV=function(a,b){return Box2D.Common.Math.b2Vec2.Get(a.x+
b.x,a.y+b.y)};Box2D.Common.Math.b2Math.SubtractVV=function(a,b){return Box2D.Common.Math.b2Vec2.Get(a.x-b.x,a.y-b.y)};Box2D.Common.Math.b2Math.Distance=function(a,b){return Math.sqrt(Box2D.Common.Math.b2Math.DistanceSquared(a,b))};Box2D.Common.Math.b2Math.DistanceSquared=function(a,b){var c=a.x-b.x,d=a.y-b.y;return c*c+d*d};Box2D.Common.Math.b2Math.MulFV=function(a,b){return Box2D.Common.Math.b2Vec2.Get(a*b.x,a*b.y)};Box2D.Common.Math.b2Math.AddMM=function(a,b){return Box2D.Common.Math.b2Mat22.FromVV(Box2D.Common.Math.b2Math.AddVV(a.col1,
b.col1),Box2D.Common.Math.b2Math.AddVV(a.col2,b.col2))};Box2D.Common.Math.b2Math.MulMM=function(a,b){return Box2D.Common.Math.b2Mat22.FromVV(Box2D.Common.Math.b2Math.MulMV(a,b.col1),Box2D.Common.Math.b2Math.MulMV(a,b.col2))};Box2D.Common.Math.b2Math.MulTMM=function(a,b){var c=Box2D.Common.Math.b2Vec2.Get(Box2D.Common.Math.b2Math.Dot(a.col1,b.col1),Box2D.Common.Math.b2Math.Dot(a.col2,b.col1)),d=Box2D.Common.Math.b2Vec2.Get(Box2D.Common.Math.b2Math.Dot(a.col1,b.col2),Box2D.Common.Math.b2Math.Dot(a.col2,
b.col2));return Box2D.Common.Math.b2Mat22.FromVV(c,d)};Box2D.Common.Math.b2Math.AbsV=function(a){return Box2D.Common.Math.b2Vec2.Get(Math.abs(a.x),Math.abs(a.y))};Box2D.Common.Math.b2Math.AbsM=function(a){return Box2D.Common.Math.b2Mat22.FromVV(Box2D.Common.Math.b2Math.AbsV(a.col1),Box2D.Common.Math.b2Math.AbsV(a.col2))};Box2D.Common.Math.b2Math.Clamp=function(a,b,c){return a<b?b:a>c?c:a};Box2D.Common.Math.b2Math.ClampV=function(a,b,c){var d=Box2D.Common.Math.b2Math.Clamp(a.x,b.x,c.x);a=Box2D.Common.Math.b2Math.Clamp(a.y,
b.y,c.y);return Box2D.Common.Math.b2Vec2.Get(d,a)};Box2D.Common.Math.b2Mat22=function(){this.col1=Box2D.Common.Math.b2Vec2.Get(0,0);this.col2=Box2D.Common.Math.b2Vec2.Get(0,0);this.SetIdentity()};Box2D.Common.Math.b2Mat22.FromAngle=function(a){var b=new Box2D.Common.Math.b2Mat22;b.Set(a);return b};Box2D.Common.Math.b2Mat22.FromVV=function(a,b){var c=new Box2D.Common.Math.b2Mat22;c.SetVV(a,b);return c};Box2D.Common.Math.b2Mat22.prototype.Set=function(a){var b=Math.cos(a);a=Math.sin(a);this.col1.Set(b,
a);this.col2.Set(-a,b)};Box2D.Common.Math.b2Mat22.prototype.SetVV=function(a,b){this.col1.SetV(a);this.col2.SetV(b)};Box2D.Common.Math.b2Mat22.prototype.Copy=function(){var a=new Box2D.Common.Math.b2Mat22;a.SetM(this);return a};Box2D.Common.Math.b2Mat22.prototype.SetM=function(a){this.col1.SetV(a.col1);this.col2.SetV(a.col2)};Box2D.Common.Math.b2Mat22.prototype.AddM=function(a){this.col1.Add(a.col1);this.col2.Add(a.col2)};Box2D.Common.Math.b2Mat22.prototype.SetIdentity=function(){this.col1.Set(1,
0);this.col2.Set(0,1)};Box2D.Common.Math.b2Mat22.prototype.SetZero=function(){this.col1.Set(0,0);this.col2.Set(0,0)};Box2D.Common.Math.b2Mat22.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)};Box2D.Common.Math.b2Mat22.prototype.GetInverse=function(a){var b=this.col1.x*this.col2.y-this.col2.x*this.col1.y;0!==b&&(b=1/b);a.col1.x=b*this.col2.y;a.col2.x=-b*this.col2.x;a.col1.y=-b*this.col1.y;a.col2.y=b*this.col1.x;return a};Box2D.Common.Math.b2Mat22.prototype.Solve=function(a,
b,c){var d=this.col1.x*this.col2.y-this.col2.x*this.col1.y;0!==d&&(d=1/d);a.x=d*(this.col2.y*b-this.col2.x*c);a.y=d*(this.col1.x*c-this.col1.y*b);return a};Box2D.Common.Math.b2Mat22.prototype.Abs=function(){this.col1.Abs();this.col2.Abs()};Box2D.Common.Math.b2Mat33=function(a,b,c){this.col1=new Box2D.Common.Math.b2Vec3(0,0,0);this.col2=new Box2D.Common.Math.b2Vec3(0,0,0);this.col3=new Box2D.Common.Math.b2Vec3(0,0,0);a&&this.col1.SetV(a);b&&this.col2.SetV(b);c&&this.col3.SetV(c)};Box2D.Common.Math.b2Mat33.prototype.SetVVV=
function(a,b,c){this.col1.SetV(a);this.col2.SetV(b);this.col3.SetV(c)};Box2D.Common.Math.b2Mat33.prototype.Copy=function(){return new Box2D.Common.Math.b2Mat33(this.col1,this.col2,this.col3)};Box2D.Common.Math.b2Mat33.prototype.SetM=function(a){this.col1.SetV(a.col1);this.col2.SetV(a.col2);this.col3.SetV(a.col3)};Box2D.Common.Math.b2Mat33.prototype.AddM=function(a){this.col1.x+=a.col1.x;this.col1.y+=a.col1.y;this.col1.z+=a.col1.z;this.col2.x+=a.col2.x;this.col2.y+=a.col2.y;this.col2.z+=a.col2.z;this.col3.x+=
a.col3.x;this.col3.y+=a.col3.y;this.col3.z+=a.col3.z};Box2D.Common.Math.b2Mat33.prototype.SetIdentity=function(){this.col1.Set(1,0,0);this.col2.Set(0,1,0);this.col3.Set(0,0,1)};Box2D.Common.Math.b2Mat33.prototype.SetZero=function(){this.col1.Set(0,0,0);this.col2.Set(0,0,0);this.col3.Set(0,0,0)};Box2D.Common.Math.b2Mat33.prototype.Solve22=function(a,b,c){var d=this.col1.x,e=this.col2.x,f=this.col1.y,g=this.col2.y,h=d*g-e*f;0!=h&&(h=1/h);a.x=h*(g*b-e*c);a.y=h*(d*c-f*b);return a};Box2D.Common.Math.b2Mat33.prototype.Solve33=
function(a,b,c,d){var e=this.col1.x,f=this.col1.y,g=this.col1.z,h=this.col2.x,l=this.col2.y,k=this.col2.z,m=this.col3.x,n=this.col3.y,q=this.col3.z,p=e*(l*q-k*n)+f*(k*m-h*q)+g*(h*n-l*m);0!=p&&(p=1/p);a.x=p*(b*(l*q-k*n)+c*(k*m-h*q)+d*(h*n-l*m));a.y=p*(e*(c*q-d*n)+f*(d*m-b*q)+g*(b*n-c*m));a.z=p*(e*(l*d-k*c)+f*(k*b-h*d)+g*(h*c-l*b));return a};Box2D.Common.Math.b2Sweep=function(){this.localCenter=Box2D.Common.Math.b2Vec2.Get(0,0);this.c0=Box2D.Common.Math.b2Vec2.Get(0,0);this.c=Box2D.Common.Math.b2Vec2.Get(0,
0)};Box2D.Common.Math.b2Sweep.prototype.Set=function(a){this.localCenter.SetV(a.localCenter);this.c0.SetV(a.c0);this.c.SetV(a.c);this.a0=a.a0;this.a=a.a;this.t0=a.t0};Box2D.Common.Math.b2Sweep.prototype.Copy=function(){var a=new Box2D.Common.Math.b2Sweep;a.localCenter.SetV(this.localCenter);a.c0.SetV(this.c0);a.c.SetV(this.c);a.a0=this.a0;a.a=this.a;a.t0=this.t0;return a};Box2D.Common.Math.b2Sweep.prototype.GetTransform=function(a,b){void 0===b&&(b=0);a.position.x=(1-b)*this.c0.x+b*this.c.x;a.position.y=
(1-b)*this.c0.y+b*this.c.y;a.R.Set((1-b)*this.a0+b*this.a);var c=a.R;a.position.x-=c.col1.x*this.localCenter.x+c.col2.x*this.localCenter.y;a.position.y-=c.col1.y*this.localCenter.x+c.col2.y*this.localCenter.y};Box2D.Common.Math.b2Sweep.prototype.Advance=function(a){void 0===a&&(a=0);if(this.t0<a&&1-this.t0>Number.MIN_VALUE){var b=(a-this.t0)/(1-this.t0);this.c0.x=(1-b)*this.c0.x+b*this.c.x;this.c0.y=(1-b)*this.c0.y+b*this.c.y;this.a0=(1-b)*this.a0+b*this.a;this.t0=a}};Box2D.Common.Math.b2Transform=
function(a,b){this.position=Box2D.Common.Math.b2Vec2.Get(0,0);this.R=new Box2D.Common.Math.b2Mat22;a&&this.position.SetV(a);b&&this.R.SetM(b)};Box2D.Common.Math.b2Transform.prototype.Initialize=function(a,b){this.position.SetV(a);this.R.SetM(b)};Box2D.Common.Math.b2Transform.prototype.SetIdentity=function(){this.position.SetZero();this.R.SetIdentity()};Box2D.Common.Math.b2Transform.prototype.Set=function(a){this.position.SetV(a.position);this.R.SetM(a.R)};Box2D.Common.Math.b2Transform.prototype.GetAngle=
function(){return Math.atan2(this.R.col1.y,this.R.col1.x)};Box2D.Common.Math.b2Vec2=function(a,b){this.x=a;this.y=b};Box2D.Common.Math.b2Vec2._freeCache=[];Box2D.Common.Math.b2Vec2.Get=function(a,b){if(0<Box2D.Common.Math.b2Vec2._freeCache.length){var c=Box2D.Common.Math.b2Vec2._freeCache.pop();c.Set(a,b);return c}return new Box2D.Common.Math.b2Vec2(a,b)};Box2D.Common.Math.b2Vec2.Free=function(a){Box2D.Common.Math.b2Vec2._freeCache.push(a)};Box2D.Common.Math.b2Vec2.prototype.SetZero=function(){this.y=
this.x=0};Box2D.Common.Math.b2Vec2.prototype.Set=function(a,b){this.x=a;this.y=b};Box2D.Common.Math.b2Vec2.prototype.SetV=function(a){this.x=a.x;this.y=a.y};Box2D.Common.Math.b2Vec2.prototype.GetNegative=function(){return Box2D.Common.Math.b2Vec2.Get(-this.x,-this.y)};Box2D.Common.Math.b2Vec2.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y};Box2D.Common.Math.b2Vec2.prototype.Copy=function(){return Box2D.Common.Math.b2Vec2.Get(this.x,this.y)};Box2D.Common.Math.b2Vec2.prototype.Add=
function(a){this.x+=a.x;this.y+=a.y};Box2D.Common.Math.b2Vec2.prototype.Subtract=function(a){this.x-=a.x;this.y-=a.y};Box2D.Common.Math.b2Vec2.prototype.Multiply=function(a){this.x*=a;this.y*=a};Box2D.Common.Math.b2Vec2.prototype.MulM=function(a){var b=this.x;this.x=a.col1.x*b+a.col2.x*this.y;this.y=a.col1.y*b+a.col2.y*this.y};Box2D.Common.Math.b2Vec2.prototype.MulTM=function(a){var b=this.x*a.col1.x+this.y*a.col1.y;this.y=this.x*a.col2.x+this.y*a.col2.y;this.x=b};Box2D.Common.Math.b2Vec2.prototype.CrossVF=
function(a){var b=this.x;this.x=a*this.y;this.y=-a*b};Box2D.Common.Math.b2Vec2.prototype.CrossFV=function(a){var b=this.x;this.x=-a*this.y;this.y=a*b};Box2D.Common.Math.b2Vec2.prototype.MinV=function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y)};Box2D.Common.Math.b2Vec2.prototype.MaxV=function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y)};Box2D.Common.Math.b2Vec2.prototype.Abs=function(){this.x=Math.abs(this.x);this.y=Math.abs(this.y)};Box2D.Common.Math.b2Vec2.prototype.Length=
function(){return Math.sqrt(this.LengthSquared())};Box2D.Common.Math.b2Vec2.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y};Box2D.Common.Math.b2Vec2.prototype.Normalize=function(){var a=this.Length();if(a<Number.MIN_VALUE)return 0;var b=1/a;this.x*=b;this.y*=b;return a};Box2D.Common.Math.b2Vec2.prototype.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)};Box2D.Common.Math.b2Vec3=function(a,b,c){this.x=a;this.y=b;this.z=c};Box2D.Common.Math.b2Vec3.prototype.SetZero=
function(){this.z=this.y=this.x=0};Box2D.Common.Math.b2Vec3.prototype.Set=function(a,b,c){this.x=a;this.y=b;this.z=c};Box2D.Common.Math.b2Vec3.prototype.SetV=function(a){this.x=a.x;this.y=a.y;this.z=a.z};Box2D.Common.Math.b2Vec3.prototype.GetNegative=function(){return new Box2D.Common.Math.b2Vec3(-this.x,-this.y,-this.z)};Box2D.Common.Math.b2Vec3.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y;this.z=-this.z};Box2D.Common.Math.b2Vec3.prototype.Copy=function(){return new Box2D.Common.Math.b2Vec3(this.x,
this.y,this.z)};Box2D.Common.Math.b2Vec3.prototype.Add=function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z};Box2D.Common.Math.b2Vec3.prototype.Subtract=function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z};Box2D.Common.Math.b2Vec3.prototype.Multiply=function(a){this.x*=a;this.y*=a;this.z*=a};Box2D.Collision.Shapes.b2Shape=function(){this.m_radius=Box2D.Common.b2Settings.b2_linearSlop};Box2D.Collision.Shapes.b2Shape.prototype.GetTypeName=function(){};Box2D.Collision.Shapes.b2Shape.prototype.Copy=function(){};
Box2D.Collision.Shapes.b2Shape.prototype.Set=function(a){this.m_radius=a.m_radius};Box2D.Collision.Shapes.b2Shape.prototype.TestPoint=function(){};Box2D.Collision.Shapes.b2Shape.prototype.RayCast=function(){};Box2D.Collision.Shapes.b2Shape.prototype.ComputeAABB=function(){};Box2D.Collision.Shapes.b2Shape.prototype.ComputeMass=function(){};Box2D.Collision.Shapes.b2Shape.prototype.ComputeSubmergedArea=function(){};Box2D.Collision.Shapes.b2Shape.prototype.SetDistanceProxy=function(){};Box2D.Collision.Shapes.b2Shape.TestOverlap=
function(a,b,c,d){var e=new Box2D.Collision.b2DistanceInput;e.proxyA=new Box2D.Collision.b2DistanceProxy;e.proxyA.Set(a);e.proxyB=new Box2D.Collision.b2DistanceProxy;e.proxyB.Set(c);e.transformA=b;e.transformB=d;e.useRadii=!0;a=new Box2D.Collision.b2SimplexCache;a.count=0;b=new Box2D.Collision.b2DistanceOutput;Box2D.Collision.b2Distance.Distance(b,a,e);return b.distance<10*Number.MIN_VALUE};Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide=-1;Box2D.Collision.Shapes.b2Shape.e_missCollide=0;Box2D.Collision.Shapes.b2Shape.e_hitCollide=
1;Box2D.Collision.Shapes.b2CircleShape=function(a){Box2D.Collision.Shapes.b2Shape.call(this);this.m_radius=a;this.m_radiusSquared=a*a;this.m_p=Box2D.Common.Math.b2Vec2.Get(0,0)};c2inherit(Box2D.Collision.Shapes.b2CircleShape,Box2D.Collision.Shapes.b2Shape);Box2D.Collision.Shapes.b2CircleShape.prototype.GetTypeName=function(){return Box2D.Collision.Shapes.b2CircleShape.NAME};Box2D.Collision.Shapes.b2CircleShape.prototype.Copy=function(){var a=new Box2D.Collision.Shapes.b2CircleShape(this.m_radius);
a.Set(this);return a};Box2D.Collision.Shapes.b2CircleShape.prototype.Set=function(a){Box2D.Collision.Shapes.b2Shape.prototype.Set.call(this,a);a instanceof Box2D.Collision.Shapes.b2CircleShape&&this.m_p.SetV(a.m_p)};Box2D.Collision.Shapes.b2CircleShape.prototype.TestPoint=function(a,b){var c=b.x-(a.position.x+(a.R.col1.x*this.m_p.x+a.R.col2.x*this.m_p.y)),d=b.y-(a.position.y+(a.R.col1.y*this.m_p.x+a.R.col2.y*this.m_p.y));return c*c+d*d<=this.m_radiusSquared};Box2D.Collision.Shapes.b2CircleShape.prototype.RayCast=
function(a,b,c){var d=c.R,e=b.p1.x-(c.position.x+(d.col1.x*this.m_p.x+d.col2.x*this.m_p.y));c=b.p1.y-(c.position.y+(d.col1.y*this.m_p.x+d.col2.y*this.m_p.y));var d=b.p2.x-b.p1.x,f=b.p2.y-b.p1.y,g=e*d+c*f,h=d*d+f*f,l=g*g-h*(e*e+c*c-this.m_radiusSquared);if(0>l||h<Number.MIN_VALUE)return!1;g=-(g+Math.sqrt(l));return 0<=g&&g<=b.maxFraction*h?(g/=h,a.fraction=g,a.normal.x=e+g*d,a.normal.y=c+g*f,a.normal.Normalize(),!0):!1};Box2D.Collision.Shapes.b2CircleShape.prototype.ComputeAABB=function(a,b){var c=
b.R,d=b.position.x+(c.col1.x*this.m_p.x+c.col2.x*this.m_p.y),c=b.position.y+(c.col1.y*this.m_p.x+c.col2.y*this.m_p.y);a.lowerBound_.Set(d-this.m_radius,c-this.m_radius);a.upperBound_.Set(d+this.m_radius,c+this.m_radius)};Box2D.Collision.Shapes.b2CircleShape.prototype.ComputeMass=function(a,b){a.mass=b*Math.PI*this.m_radiusSquared;a.center.SetV(this.m_p);a.I=a.mass*(0.5*this.m_radiusSquared+(this.m_p.x*this.m_p.x+this.m_p.y*this.m_p.y))};Box2D.Collision.Shapes.b2CircleShape.prototype.ComputeSubmergedArea=
function(a,b,c,d){c=Box2D.Common.Math.b2Math.MulX(c,this.m_p);var e=-(Box2D.Common.Math.b2Math.Dot(a,c)-b);if(e<-this.m_radius+Number.MIN_VALUE)return 0;if(e>this.m_radius)return d.SetV(c),Math.PI*this.m_radiusSquared;b=e*e;e=this.m_radiusSquared*(Math.asin(e/this.m_radius)+Math.PI/2)+e*Math.sqrt(this.m_radiusSquared-b);b=-2/3*Math.pow(this.m_radiusSquared-b,1.5)/e;d.x=c.x+a.x*b;d.y=c.y+a.y*b;return e};Box2D.Collision.Shapes.b2CircleShape.prototype.SetDistanceProxy=function(a){a.m_vertices=[this.m_p];
a.m_count=1;a.m_radius=this.m_radius};Box2D.Collision.Shapes.b2CircleShape.prototype.GetLocalPosition=function(){return this.m_p};Box2D.Collision.Shapes.b2CircleShape.prototype.SetLocalPosition=function(a){this.m_p.SetV(a)};Box2D.Collision.Shapes.b2CircleShape.prototype.GetRadius=function(){return this.m_radius};Box2D.Collision.Shapes.b2CircleShape.prototype.SetRadius=function(a){this.m_radius=a;this.m_radiusSquared=a*a};Box2D.Collision.Shapes.b2CircleShape.NAME="b2CircleShape";Box2D.Collision.Shapes.b2EdgeChainDef=
function(){this.vertexCount=0;this.isALoop=!0;this.vertices=[]};Box2D.Collision.Shapes.b2EdgeShape=function(a,b){Box2D.Collision.Shapes.b2Shape.call(this);this.m_nextEdge=this.m_prevEdge=null;this.m_v1=a;this.m_v2=b;this.m_direction=Box2D.Common.Math.b2Vec2.Get(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y);this.m_length=this.m_direction.Normalize();this.m_normal=Box2D.Common.Math.b2Vec2.Get(this.m_direction.y,-this.m_direction.x);this.m_coreV1=Box2D.Common.Math.b2Vec2.Get(-Box2D.Common.b2Settings.b2_toiSlop*
(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-Box2D.Common.b2Settings.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y);this.m_coreV2=Box2D.Common.Math.b2Vec2.Get(-Box2D.Common.b2Settings.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-Box2D.Common.b2Settings.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y);this.m_cornerDir1=this.m_normal;this.m_cornerDir2=Box2D.Common.Math.b2Vec2.Get(-this.m_normal.x,-this.m_normal.y);this.m_cornerConvex2=this.m_cornerConvex1=
!1};c2inherit(Box2D.Collision.Shapes.b2EdgeShape,Box2D.Collision.Shapes.b2Shape);Box2D.Collision.Shapes.b2EdgeShape.prototype.GetTypeName=function(){return Box2D.Collision.Shapes.b2EdgeShape.NAME};Box2D.Collision.Shapes.b2EdgeShape.prototype.TestPoint=function(a,b){return!1};Box2D.Collision.Shapes.b2EdgeShape.prototype.RayCast=function(a,b,c){var d=b.p2.x-b.p1.x,e=b.p2.y-b.p1.y,f=c.R,g=c.position.x+(f.col1.x*this.m_v1.x+f.col2.x*this.m_v1.y),h=c.position.y+(f.col1.y*this.m_v1.x+f.col2.y*this.m_v1.y),
l=c.position.y+(f.col1.y*this.m_v2.x+f.col2.y*this.m_v2.y)-h;c=-(c.position.x+(f.col1.x*this.m_v2.x+f.col2.x*this.m_v2.y)-g);var f=100*Number.MIN_VALUE,k=-(d*l+e*c);if(k>f){var g=b.p1.x-g,m=b.p1.y-h,h=g*l+m*c;if(0<=h&&h<=b.maxFraction*k&&(b=-d*m+e*g,-f*k<=b&&b<=k*(1+f)))return a.fraction=h/k,b=Math.sqrt(l*l+c*c),a.normal.x=l/b,a.normal.y=c/b,!0}return!1};Box2D.Collision.Shapes.b2EdgeShape.prototype.ComputeAABB=function(a,b){var c=b.R,d=b.position.x+(c.col1.x*this.m_v1.x+c.col2.x*this.m_v1.y),e=b.position.y+
(c.col1.y*this.m_v1.x+c.col2.y*this.m_v1.y),f=b.position.x+(c.col1.x*this.m_v2.x+c.col2.x*this.m_v2.y),c=b.position.y+(c.col1.y*this.m_v2.x+c.col2.y*this.m_v2.y);d<f?(a.lowerBound_.x=d,a.upperBound_.x=f):(a.lowerBound_.x=f,a.upperBound_.x=d);e<c?(a.lowerBound_.y=e,a.upperBound_.y=c):(a.lowerBound_.y=c,a.upperBound_.y=e)};Box2D.Collision.Shapes.b2EdgeShape.prototype.ComputeMass=function(a,b){a.mass=0;a.center.SetV(this.m_v1);a.I=0};Box2D.Collision.Shapes.b2EdgeShape.prototype.ComputeSubmergedArea=
function(a,b,c,d){void 0===b&&(b=0);var e=Box2D.Common.Math.b2Vec2.Get(a.x*b,a.y*b),f=Box2D.Common.Math.b2Math.MulX(c,this.m_v1);c=Box2D.Common.Math.b2Math.MulX(c,this.m_v2);var g=Box2D.Common.Math.b2Math.Dot(a,f)-b;a=Box2D.Common.Math.b2Math.Dot(a,c)-b;if(0<g){if(0<a)return 0;f.x=-a/(g-a)*f.x+g/(g-a)*c.x;f.y=-a/(g-a)*f.y+g/(g-a)*c.y}else 0<a&&(c.x=-a/(g-a)*f.x+g/(g-a)*c.x,c.y=-a/(g-a)*f.y+g/(g-a)*c.y);d.x=(e.x+f.x+c.x)/3;d.y=(e.y+f.y+c.y)/3;return 0.5*((f.x-e.x)*(c.y-e.y)-(f.y-e.y)*(c.x-e.x))};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetLength=
function(){return this.m_length};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetVertex1=function(){return this.m_v1};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetVertex2=function(){return this.m_v2};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetCoreVertex1=function(){return this.m_coreV1};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetCoreVertex2=function(){return this.m_coreV2};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetNormalVector=function(){return this.m_normal};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetDirectionVector=
function(){return this.m_direction};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetCorner1Vector=function(){return this.m_cornerDir1};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetCorner2Vector=function(){return this.m_cornerDir2};Box2D.Collision.Shapes.b2EdgeShape.prototype.Corner1IsConvex=function(){return this.m_cornerConvex1};Box2D.Collision.Shapes.b2EdgeShape.prototype.Corner2IsConvex=function(){return this.m_cornerConvex2};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetFirstVertex=function(a){var b=
a.R;return Box2D.Common.Math.b2Vec2.Get(a.position.x+(b.col1.x*this.m_coreV1.x+b.col2.x*this.m_coreV1.y),a.position.y+(b.col1.y*this.m_coreV1.x+b.col2.y*this.m_coreV1.y))};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetNextEdge=function(){return this.m_nextEdge};Box2D.Collision.Shapes.b2EdgeShape.prototype.GetPrevEdge=function(){return this.m_prevEdge};Box2D.Collision.Shapes.b2EdgeShape.prototype.Support=function(a,b,c){var d=a.R,e=a.position.x+(d.col1.x*this.m_coreV1.x+d.col2.x*this.m_coreV1.y),
f=a.position.y+(d.col1.y*this.m_coreV1.x+d.col2.y*this.m_coreV1.y),g=a.position.x+(d.col1.x*this.m_coreV2.x+d.col2.x*this.m_coreV2.y);a=a.position.y+(d.col1.y*this.m_coreV2.x+d.col2.y*this.m_coreV2.y);return e*b+f*c>g*b+a*c?Box2D.Common.Math.b2Vec2.Get(e,f):Box2D.Common.Math.b2Vec2.Get(g,a)};Box2D.Collision.Shapes.b2EdgeShape.prototype.SetPrevEdge=function(a,b,c,d){this.m_prevEdge=a;this.m_coreV1=b;this.m_cornerDir1=c;this.m_cornerConvex1=d};Box2D.Collision.Shapes.b2EdgeShape.prototype.SetNextEdge=
function(a,b,c,d){this.m_nextEdge=a;this.m_coreV2=b;this.m_cornerDir2=c;this.m_cornerConvex2=d};Box2D.Collision.Shapes.b2EdgeShape.NAME="b2EdgeShape";Box2D.Collision.Shapes.b2MassData=function(){this.mass=0;this.center=Box2D.Common.Math.b2Vec2.Get(0,0);this.I=0};Box2D.Collision.Shapes.b2PolygonShape=function(){Box2D.Collision.Shapes.b2Shape.call(this);this.m_centroid=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_vertices=[];this.m_normals=[]};c2inherit(Box2D.Collision.Shapes.b2PolygonShape,Box2D.Collision.Shapes.b2Shape);
Box2D.Collision.Shapes.b2PolygonShape.prototype.GetTypeName=function(){return Box2D.Collision.Shapes.b2PolygonShape.NAME};Box2D.Collision.Shapes.b2PolygonShape.prototype.Copy=function(){var a=new Box2D.Collision.Shapes.b2PolygonShape;a.Set(this);return a};Box2D.Collision.Shapes.b2PolygonShape.prototype.Set=function(a){Box2D.Collision.Shapes.b2Shape.prototype.Set.call(this,a);if(a instanceof Box2D.Collision.Shapes.b2PolygonShape){this.m_centroid.SetV(a.m_centroid);this.m_vertexCount=a.m_vertexCount;
this.Reserve(this.m_vertexCount);for(var b=0;b<this.m_vertexCount;b++)this.m_vertices[b].SetV(a.m_vertices[b]),this.m_normals[b].SetV(a.m_normals[b])}};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsArray=function(a){this.SetAsVector(a)};Box2D.Collision.Shapes.b2PolygonShape.AsArray=function(a){var b=new Box2D.Collision.Shapes.b2PolygonShape;b.SetAsArray(a);return b};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsVector=function(a){var b=a.length;this.m_vertexCount=b;this.Reserve(b);for(b=
b=0;b<this.m_vertexCount;b++)this.m_vertices[b].SetV(a[b]);for(b=0;b<this.m_vertexCount;++b)a=Box2D.Common.Math.b2Math.SubtractVV(this.m_vertices[b+1<this.m_vertexCount?b+1:0],this.m_vertices[b]),this.m_normals[b].SetV(Box2D.Common.Math.b2Math.CrossVF(a,1)),this.m_normals[b].Normalize();this.m_centroid=Box2D.Collision.Shapes.b2PolygonShape.ComputeCentroid(this.m_vertices,this.m_vertexCount)};Box2D.Collision.Shapes.b2PolygonShape.AsVector=function(a){var b=new Box2D.Collision.Shapes.b2PolygonShape;
b.SetAsVector(a);return b};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsBox=function(a,b){this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-a,-b);this.m_vertices[1].Set(a,-b);this.m_vertices[2].Set(a,b);this.m_vertices[3].Set(-a,b);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid.SetZero()};Box2D.Collision.Shapes.b2PolygonShape.AsBox=function(a,b){var c=new Box2D.Collision.Shapes.b2PolygonShape;c.SetAsBox(a,
b);return c};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsOrientedBox=function(a,b,c,d){this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-a,-b);this.m_vertices[1].Set(a,-b);this.m_vertices[2].Set(a,b);this.m_vertices[3].Set(-a,b);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid=c;a=new Box2D.Common.Math.b2Mat22;a.Set(d);c=new Box2D.Common.Math.b2Transform(c,a);for(d=0;d<this.m_vertexCount;++d)this.m_vertices[d]=
Box2D.Common.Math.b2Math.MulX(c,this.m_vertices[d]),this.m_normals[d]=Box2D.Common.Math.b2Math.MulMV(c.R,this.m_normals[d])};Box2D.Collision.Shapes.b2PolygonShape.AsOrientedBox=function(a,b,c,d){var e=new Box2D.Collision.Shapes.b2PolygonShape;e.SetAsOrientedBox(a,b,c,d);return e};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetAsEdge=function(a,b){this.m_vertexCount=2;this.Reserve(2);this.m_vertices[0].SetV(a);this.m_vertices[1].SetV(b);this.m_centroid.x=0.5*(a.x+b.x);this.m_centroid.y=0.5*(a.y+
b.y);this.m_normals[0]=Box2D.Common.Math.b2Math.CrossVF(Box2D.Common.Math.b2Math.SubtractVV(b,a),1);this.m_normals[0].Normalize();this.m_normals[1].x=-this.m_normals[0].x;this.m_normals[1].y=-this.m_normals[0].y};Box2D.Collision.Shapes.b2PolygonShape.AsEdge=function(a,b){var c=new Box2D.Collision.Shapes.b2PolygonShape;c.SetAsEdge(a,b);return c};Box2D.Collision.Shapes.b2PolygonShape.prototype.TestPoint=function(a,b){var c;c=a.R;for(var d=b.x-a.position.x,e=b.y-a.position.y,f=d*c.col1.x+e*c.col1.y,
g=d*c.col2.x+e*c.col2.y,h=0;h<this.m_vertexCount;++h)if(c=this.m_vertices[h],d=f-c.x,e=g-c.y,c=this.m_normals[h],0<c.x*d+c.y*e)return!1;return!0};Box2D.Collision.Shapes.b2PolygonShape.prototype.RayCast=function(a,b,c){var d=0,e=b.maxFraction,f=0,g=0,h,l,f=b.p1.x-c.position.x,g=b.p1.y-c.position.y;h=c.R;var k=f*h.col1.x+g*h.col1.y,m=f*h.col2.x+g*h.col2.y,f=b.p2.x-c.position.x,g=b.p2.y-c.position.y;h=c.R;b=f*h.col1.x+g*h.col1.y-k;h=f*h.col2.x+g*h.col2.y-m;for(var n=-1,q=0;q<this.m_vertexCount;++q){l=
this.m_vertices[q];f=l.x-k;g=l.y-m;l=this.m_normals[q];f=l.x*f+l.y*g;g=l.x*b+l.y*h;if(0==g){if(0>f)return!1}else 0>g&&f<d*g?(d=f/g,n=q):0<g&&f<e*g&&(e=f/g);if(e<d-Number.MIN_VALUE)return!1}return 0<=n?(a.fraction=d,h=c.R,l=this.m_normals[n],a.normal.x=h.col1.x*l.x+h.col2.x*l.y,a.normal.y=h.col1.y*l.x+h.col2.y*l.y,!0):!1};Box2D.Collision.Shapes.b2PolygonShape.prototype.ComputeAABB=function(a,b){for(var c=b.R,d=this.m_vertices[0],e=b.position.x+(c.col1.x*d.x+c.col2.x*d.y),f=b.position.y+(c.col1.y*d.x+
c.col2.y*d.y),g=e,h=f,l=1;l<this.m_vertexCount;++l)var d=this.m_vertices[l],k=b.position.x+(c.col1.x*d.x+c.col2.x*d.y),d=b.position.y+(c.col1.y*d.x+c.col2.y*d.y),e=e<k?e:k,f=f<d?f:d,g=g>k?g:k,h=h>d?h:d;a.lowerBound_.x=e-this.m_radius;a.lowerBound_.y=f-this.m_radius;a.upperBound_.x=g+this.m_radius;a.upperBound_.y=h+this.m_radius};Box2D.Collision.Shapes.b2PolygonShape.prototype.ComputeMass=function(a,b){if(2==this.m_vertexCount)a.center.x=0.5*(this.m_vertices[0].x+this.m_vertices[1].x),a.center.y=0.5*
(this.m_vertices[0].y+this.m_vertices[1].y),a.mass=0,a.I=0;else{for(var c=0,d=0,e=0,f=0,g=1/3,h=0;h<this.m_vertexCount;++h)var l=this.m_vertices[h],k=h+1<this.m_vertexCount?this.m_vertices[h+1]:this.m_vertices[0],m=l.x-0,n=l.y-0,q=k.x-0,p=k.y-0,r=m*p-n*q,s=0.5*r,e=e+s,c=c+s*g*(0+l.x+k.x),d=d+s*g*(0+l.y+k.y),l=m,f=f+r*(g*(0.25*(l*l+q*l+q*q)+(0*l+0*q))+0+(g*(0.25*(n*n+p*n+p*p)+(0*n+0*p))+0));a.mass=b*e;a.center.Set(c*(1/e),d*(1/e));a.I=b*f}};Box2D.Collision.Shapes.b2PolygonShape.prototype.ComputeSubmergedArea=
function(a,b,c,d){var e=Box2D.Common.Math.b2Math.MulTMV(c.R,a),f=b-Box2D.Common.Math.b2Math.Dot(a,c.position),g=[],h=0,l=-1;b=-1;var k=!1;for(a=a=0;a<this.m_vertexCount;++a){g[a]=Box2D.Common.Math.b2Math.Dot(e,this.m_vertices[a])-f;var m=g[a]<-Number.MIN_VALUE;0<a&&(m?k||(l=a-1,h++):k&&(b=a-1,h++));k=m}switch(h){case 0:return k?(a=new Box2D.Collision.Shapes.b2MassData,this.ComputeMass(a,1),d.SetV(Box2D.Common.Math.b2Math.MulX(c,a.center)),a.mass):0;case 1:-1==l?l=this.m_vertexCount-1:b=this.m_vertexCount-
1}a=(l+1)%this.m_vertexCount;e=(b+1)%this.m_vertexCount;f=(0-g[l])/(g[a]-g[l]);g=(0-g[b])/(g[e]-g[b]);l=Box2D.Common.Math.b2Vec2.Get(this.m_vertices[l].x*(1-f)+this.m_vertices[a].x*f,this.m_vertices[l].y*(1-f)+this.m_vertices[a].y*f);b=Box2D.Common.Math.b2Vec2.Get(this.m_vertices[b].x*(1-g)+this.m_vertices[e].x*g,this.m_vertices[b].y*(1-g)+this.m_vertices[e].y*g);g=0;f=Box2D.Common.Math.b2Vec2.Get(0,0);for(h=this.m_vertices[a];a!=e;)a=(a+1)%this.m_vertexCount,k=a==e?b:this.m_vertices[a],m=0.5*((h.x-
l.x)*(k.y-l.y)-(h.y-l.y)*(k.x-l.x)),g+=m,f.x+=m*(l.x+h.x+k.x)/3,f.y+=m*(l.y+h.y+k.y)/3,h=k;f.Multiply(1/g);d.SetV(Box2D.Common.Math.b2Math.MulX(c,f));return g};Box2D.Collision.Shapes.b2PolygonShape.prototype.SetDistanceProxy=function(a){a.m_vertices=this.m_vertices;a.m_count=this.m_vertexCount;a.m_radius=this.m_radius};Box2D.Collision.Shapes.b2PolygonShape.prototype.GetVertexCount=function(){return this.m_vertexCount};Box2D.Collision.Shapes.b2PolygonShape.prototype.GetVertices=function(){return this.m_vertices};
Box2D.Collision.Shapes.b2PolygonShape.prototype.GetNormals=function(){return this.m_normals};Box2D.Collision.Shapes.b2PolygonShape.prototype.GetSupport=function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_vertexCount;++d){var e=this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return b};Box2D.Collision.Shapes.b2PolygonShape.prototype.GetSupportVertex=function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_vertexCount;++d){var e=
this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return this.m_vertices[b]};Box2D.Collision.Shapes.b2PolygonShape.prototype.Reserve=function(a){this.m_vertices=[];this.m_normals=[];for(var b=this.m_vertices.length;b<a;b++)this.m_vertices[b]=Box2D.Common.Math.b2Vec2.Get(0,0),this.m_normals[b]=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.Shapes.b2PolygonShape.ComputeCentroid=function(a,b){for(var c=Box2D.Common.Math.b2Vec2.Get(0,0),d=0,e=1/3,f=0;f<b;++f){var g=a[f],h=f+1<b?a[f+
1]:a[0],l=0.5*((g.x-0)*(h.y-0)-(g.y-0)*(h.x-0)),d=d+l;c.x+=l*e*(0+g.x+h.x);c.y+=l*e*(0+g.y+h.y)}c.x*=1/d;c.y*=1/d;return c};Box2D.Collision.Shapes.b2PolygonShape.s_mat=new Box2D.Common.Math.b2Mat22;Box2D.Collision.Shapes.b2PolygonShape.NAME="b2PolygonShape";Box2D.Collision.b2ContactID=function(){this._incidentVertex=this._incidentEdge=this._referenceEdge=this._key=0};Box2D.Collision.b2ContactID.prototype.GetKey=function(){return this._key};Box2D.Collision.b2ContactID.prototype.SetKey=function(a){this._key=
a;this._referenceEdge=this._key&255;this._incidentEdge=(this._key&65280)>>8&255;this._incidentVertex=(this._key&16711680)>>16&255;this._flip=(this._key&4278190080)>>24&255};Box2D.Collision.b2ContactID.prototype.Set=function(a){this.SetKey(a._key)};Box2D.Collision.b2ContactID.prototype.SetReferenceEdge=function(a){this._referenceEdge=a;this._key=this._key&4294967040|this._referenceEdge&255};Box2D.Collision.b2ContactID.prototype.SetIncidentEdge=function(a){this._incidentEdge=a;this._key=this._key&4294902015|
this._incidentEdge<<8&65280};Box2D.Collision.b2ContactID.prototype.SetIncidentVertex=function(a){this._incidentVertex=a;this._key=this._key&4278255615|this._incidentVertex<<16&16711680};Box2D.Collision.b2ContactID.prototype.SetFlip=function(a){this._flip=a;this._key=this._key&16777215|this._flip<<24&4278190080};Box2D.Collision.b2ContactID.prototype.Copy=function(){var a=new Box2D.Collision.b2ContactID;a.Set(this);return a};Box2D.Collision.ClipVertex=function(){this.v=Box2D.Common.Math.b2Vec2.Get(0,
0);this.id=new Box2D.Collision.b2ContactID};Box2D.Collision.ClipVertex.prototype.Set=function(a){this.v.SetV(a.v);this.id.Set(a.id)};Box2D.Collision.IBroadPhase="Box2D.Collision.IBroadPhase";Box2D.Collision.b2AABB=function(){this.lowerBound_=Box2D.Common.Math.b2Vec2.Get(0,0);this.upperBound_=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2AABB._freeCache=[];Box2D.Collision.b2AABB.Get=function(){if(0<Box2D.Collision.b2AABB._freeCache.length){var a=Box2D.Collision.b2AABB._freeCache.pop();a.SetZero();
return a}return new Box2D.Collision.b2AABB};Box2D.Collision.b2AABB.Free=function(a){Box2D.Collision.b2AABB._freeCache.push(a)};Box2D.Collision.b2AABB.prototype.SetZero=function(){this.lowerBound_.Set(0,0);this.upperBound_.Set(0,0)};Box2D.Collision.b2AABB.prototype.IsValid=function(){return 0>this.upperBound_.x-this.lowerBound_.x||0>this.upperBound_.y-this.lowerBound_.y?!1:this.lowerBound_.IsValid()&&this.upperBound_.IsValid()};Box2D.Collision.b2AABB.prototype.GetCenter=function(){return Box2D.Common.Math.b2Vec2.Get((this.lowerBound_.x+
this.upperBound_.x)/2,(this.lowerBound_.y+this.upperBound_.y)/2)};Box2D.Collision.b2AABB.prototype.SetCenter=function(a){var b=this.GetCenter();this.lowerBound_.Subtract(b);this.upperBound_.Subtract(b);this.lowerBound_.Add(a);this.upperBound_.Add(a);Box2D.Common.Math.b2Vec2.Free(b)};Box2D.Collision.b2AABB.prototype.GetExtents=function(){return Box2D.Common.Math.b2Vec2.Get((this.upperBound_.x-this.lowerBound_.x)/2,(this.upperBound_.y-this.lowerBound_.y)/2)};Box2D.Collision.b2AABB.prototype.Contains=
function(a){var b;return b=(b=(b=(b=this.lowerBound_.x<=a.lowerBound_.x)&&this.lowerBound_.y<=a.lowerBound_.y)&&a.upperBound_.x<=this.upperBound_.x)&&a.upperBound_.y<=this.upperBound_.y};Box2D.Collision.b2AABB.prototype.RayCast=function(a,b){var c=-Number.MAX_VALUE,d=Number.MAX_VALUE,e=b.p2.x-b.p1.x;if(Math.abs(e)<Number.MIN_VALUE){if(b.p1.x<this.lowerBound_.x||this.upperBound_.x<b.p1.x)return!1}else{var f=1/e,e=(this.lowerBound_.x-b.p1.x)*f,f=(this.upperBound_.x-b.p1.x)*f,g=-1;e>f&&(g=e,e=f,f=g,
g=1);e>c&&(a.normal.x=g,a.normal.y=0,c=e);d=Math.min(d,f);if(c>d)return!1}e=b.p2.y-b.p1.y;if(Math.abs(e)<Number.MIN_VALUE){if(b.p1.y<this.lowerBound_.y||this.upperBound_.y<b.p1.y)return!1}else if(f=1/e,e=(this.lowerBound_.y-b.p1.y)*f,f*=this.upperBound_.y-b.p1.y,g=-1,e>f&&(g=e,e=f,f=g,g=1),e>c&&(a.normal.y=g,a.normal.x=0,c=e),d=Math.min(d,f),c>d)return!1;a.fraction=c;return!0};Box2D.Collision.b2AABB.prototype.TestOverlap=function(a){return 0<a.lowerBound_.x-this.upperBound_.x||0<a.lowerBound_.y-this.upperBound_.y||
0<this.lowerBound_.x-a.upperBound_.x||0<this.lowerBound_.y-a.upperBound_.y?!1:!0};Box2D.Collision.b2AABB.Combine=function(a,b){var c=Box2D.Collision.b2AABB.Get();c.Combine(a,b);return c};Box2D.Collision.b2AABB.prototype.Combine=function(a,b){this.lowerBound_.x=Math.min(a.lowerBound_.x,b.lowerBound_.x);this.lowerBound_.y=Math.min(a.lowerBound_.y,b.lowerBound_.y);this.upperBound_.x=Math.max(a.upperBound_.x,b.upperBound_.x);this.upperBound_.y=Math.max(a.upperBound_.y,b.upperBound_.y)};Box2D.Collision.b2Collision.ClipSegmentToLine=
function(a,b,c,d){var e=0,f=b[0].v,g=b[1].v,h=c.x*f.x+c.y*f.y-d;c=c.x*g.x+c.y*g.y-d;0>=h&&a[e++].Set(b[0]);0>=c&&a[e++].Set(b[1]);0>h*c&&(c=h/(h-c),d=a[e].v,d.x=f.x+c*(g.x-f.x),d.y=f.y+c*(g.y-f.y),a[e].id=0<h?b[0].id:b[1].id,e++);return e};Box2D.Collision.b2Collision.EdgeSeparation=function(a,b,c,d,e){for(var f=b.R.col1.x*a.m_normals[c].x+b.R.col2.x*a.m_normals[c].y,g=b.R.col1.y*a.m_normals[c].x+b.R.col2.y*a.m_normals[c].y,h=e.R.col1.x*f+e.R.col1.y*g,l=e.R.col2.x*f+e.R.col2.y*g,k=0,m=Number.MAX_VALUE,
n=0;n<d.m_vertexCount;n++){var q=d.m_vertices[n].x*h+d.m_vertices[n].y*l;q<m&&(m=q,k=n)}return(e.position.x+(e.R.col1.x*d.m_vertices[k].x+e.R.col2.x*d.m_vertices[k].y)-(b.position.x+(b.R.col1.x*a.m_vertices[c].x+b.R.col2.x*a.m_vertices[c].y)))*f+(e.position.y+(e.R.col1.y*d.m_vertices[k].x+e.R.col2.y*d.m_vertices[k].y)-(b.position.y+(b.R.col1.y*a.m_vertices[c].x+b.R.col2.y*a.m_vertices[c].y)))*g};Box2D.Collision.b2Collision.FindMaxSeparation=function(a,b,c,d){for(var e=d.position.x+(d.R.col1.x*c.m_centroid.x+
d.R.col2.x*c.m_centroid.y),f=d.position.y+(d.R.col1.y*c.m_centroid.x+d.R.col2.y*c.m_centroid.y),e=e-(b.position.x+(b.R.col1.x*a.m_centroid.x+b.R.col2.x*a.m_centroid.y)),f=f-(b.position.y+(b.R.col1.y*a.m_centroid.x+b.R.col2.y*a.m_centroid.y)),g=e*b.R.col1.x+f*b.R.col1.y,f=e*b.R.col2.x+f*b.R.col2.y,e=0,h=-Number.MAX_VALUE,l=0;l<a.m_vertexCount;++l){var k=a.m_normals[l].x*g+a.m_normals[l].y*f;k>h&&(h=k,e=l)}g=Box2D.Collision.b2Collision.EdgeSeparation(a,b,e,c,d);f=e-1;0>f&&(f=a.m_vertexCount-1);h=Box2D.Collision.b2Collision.EdgeSeparation(a,
b,f,c,d);l=e+1;l>=a.m_vertexCount&&(l=0);var k=Box2D.Collision.b2Collision.EdgeSeparation(a,b,l,c,d),m=0,n=0;if(h>g&&h>k)for(m=f,n=h;;)if(e=m-1,0>e&&(e=a.m_vertexCount-1),g=Box2D.Collision.b2Collision.EdgeSeparation(a,b,e,c,d),g>n)m=e,n=g;else break;else if(k>g)for(m=l,n=k;;)if(e=m+1,e>=a.m_vertexCount&&(e=0),g=Box2D.Collision.b2Collision.EdgeSeparation(a,b,e,c,d),g>n)m=e,n=g;else break;else m=e,n=g;return{bestEdge:m,separation:n}};Box2D.Collision.b2Collision.FindIncidentEdge=function(a,b,c,d,e,f){void 0===
d&&(d=0);var g=c.R.col1.x*b.m_normals[d].x+c.R.col2.x*b.m_normals[d].y;b=c.R.col1.y*b.m_normals[d].x+c.R.col2.y*b.m_normals[d].y;c=f.R.col1.x*g+f.R.col1.y*b;b=f.R.col2.x*g+f.R.col2.y*b;g=c;c=0;for(var h=Number.MAX_VALUE,l=0;l<e.m_vertexCount;l++){var k=g*e.m_normals[l].x+b*e.m_normals[l].y;k<h&&(h=k,c=l)}g=c+1;g>=e.m_vertexCount&&(g=0);a[0].v.x=f.position.x+(f.R.col1.x*e.m_vertices[c].x+f.R.col2.x*e.m_vertices[c].y);a[0].v.y=f.position.y+(f.R.col1.y*e.m_vertices[c].x+f.R.col2.y*e.m_vertices[c].y);
a[0].id.SetReferenceEdge(d);a[0].id.SetIncidentEdge(c);a[0].id.SetIncidentVertex(0);a[1].v.x=f.position.x+(f.R.col1.x*e.m_vertices[g].x+f.R.col2.x*e.m_vertices[g].y);a[1].v.y=f.position.y+(f.R.col1.y*e.m_vertices[g].x+f.R.col2.y*e.m_vertices[g].y);a[1].id.SetReferenceEdge(d);a[1].id.SetIncidentEdge(g);a[1].id.SetIncidentVertex(1)};Box2D.Collision.b2Collision.MakeClipPointVector=function(){return[new Box2D.Collision.ClipVertex,new Box2D.Collision.ClipVertex]};Box2D.Collision.b2Collision.CollidePolygons=
function(a,b,c,d,e){a.m_pointCount=0;var f=b.m_radius+d.m_radius,g=Box2D.Collision.b2Collision.FindMaxSeparation(b,c,d,e),h=g.bestEdge;if(!(g.separation>f)){var l=Box2D.Collision.b2Collision.FindMaxSeparation(d,e,b,c);if(!(l.separation>f)){var k=b,m=d,n=c,q=e,p=0;a.m_type=Box2D.Collision.b2Manifold.e_faceA;l.separation>0.98*g.separation+0.001&&(k=d,m=b,n=e,q=c,h=l.bestEdge,a.m_type=Box2D.Collision.b2Manifold.e_faceB,p=1);b=Box2D.Collision.b2Collision.s_incidentEdge;Box2D.Collision.b2Collision.FindIncidentEdge(b,
k,n,h,m,q);m=k.m_vertices[h];h=h+1<k.m_vertexCount?k.m_vertices[h+1]:k.m_vertices[0];Box2D.Collision.b2Collision.s_localTangent.Set(h.x-m.x,h.y-m.y);Box2D.Collision.b2Collision.s_localTangent.Normalize();Box2D.Collision.b2Collision.s_localNormal.x=Box2D.Collision.b2Collision.s_localTangent.y;Box2D.Collision.b2Collision.s_localNormal.y=-Box2D.Collision.b2Collision.s_localTangent.x;Box2D.Collision.b2Collision.s_planePoint.Set(0.5*(m.x+h.x),0.5*(m.y+h.y));Box2D.Collision.b2Collision.s_tangent.x=n.R.col1.x*
Box2D.Collision.b2Collision.s_localTangent.x+n.R.col2.x*Box2D.Collision.b2Collision.s_localTangent.y;Box2D.Collision.b2Collision.s_tangent.y=n.R.col1.y*Box2D.Collision.b2Collision.s_localTangent.x+n.R.col2.y*Box2D.Collision.b2Collision.s_localTangent.y;Box2D.Collision.b2Collision.s_tangent2.x=-Box2D.Collision.b2Collision.s_tangent.x;Box2D.Collision.b2Collision.s_tangent2.y=-Box2D.Collision.b2Collision.s_tangent.y;Box2D.Collision.b2Collision.s_normal.x=Box2D.Collision.b2Collision.s_tangent.y;Box2D.Collision.b2Collision.s_normal.y=
-Box2D.Collision.b2Collision.s_tangent.x;Box2D.Collision.b2Collision.s_v11.x=n.position.x+(n.R.col1.x*m.x+n.R.col2.x*m.y);Box2D.Collision.b2Collision.s_v11.y=n.position.y+(n.R.col1.y*m.x+n.R.col2.y*m.y);Box2D.Collision.b2Collision.s_v12.x=n.position.x+(n.R.col1.x*h.x+n.R.col2.x*h.y);Box2D.Collision.b2Collision.s_v12.y=n.position.y+(n.R.col1.y*h.x+n.R.col2.y*h.y);if(!(2>Box2D.Collision.b2Collision.ClipSegmentToLine(Box2D.Collision.b2Collision.s_clipPoints1,b,Box2D.Collision.b2Collision.s_tangent2,
-Box2D.Collision.b2Collision.s_tangent.x*Box2D.Collision.b2Collision.s_v11.x-Box2D.Collision.b2Collision.s_tangent.y*Box2D.Collision.b2Collision.s_v11.y+f)||2>Box2D.Collision.b2Collision.ClipSegmentToLine(Box2D.Collision.b2Collision.s_clipPoints2,Box2D.Collision.b2Collision.s_clipPoints1,Box2D.Collision.b2Collision.s_tangent,Box2D.Collision.b2Collision.s_tangent.x*Box2D.Collision.b2Collision.s_v12.x+Box2D.Collision.b2Collision.s_tangent.y*Box2D.Collision.b2Collision.s_v12.y+f))){a.m_localPlaneNormal.SetV(Box2D.Collision.b2Collision.s_localNormal);
a.m_localPoint.SetV(Box2D.Collision.b2Collision.s_planePoint);n=Box2D.Collision.b2Collision.s_normal.x*Box2D.Collision.b2Collision.s_v11.x+Box2D.Collision.b2Collision.s_normal.y*Box2D.Collision.b2Collision.s_v11.y;for(k=h=0;k<Box2D.Common.b2Settings.b2_maxManifoldPoints;++k)Box2D.Collision.b2Collision.s_normal.x*Box2D.Collision.b2Collision.s_clipPoints2[k].v.x+Box2D.Collision.b2Collision.s_normal.y*Box2D.Collision.b2Collision.s_clipPoints2[k].v.y-n<=f&&(m=Box2D.Collision.b2Collision.s_clipPoints2[k].v.x-
q.position.x,b=Box2D.Collision.b2Collision.s_clipPoints2[k].v.y-q.position.y,a.m_points[h].m_localPoint.x=m*q.R.col1.x+b*q.R.col1.y,a.m_points[h].m_localPoint.y=m*q.R.col2.x+b*q.R.col2.y,a.m_points[h].m_id.Set(Box2D.Collision.b2Collision.s_clipPoints2[k].id),a.m_points[h].m_id.SetFlip(p),h++);a.m_pointCount=h}}}};Box2D.Collision.b2Collision.CollideCircles=function(a,b,c,d,e){a.m_pointCount=0;var f=e.position.x+(e.R.col1.x*d.m_p.x+e.R.col2.x*d.m_p.y)-(c.position.x+(c.R.col1.x*b.m_p.x+c.R.col2.x*b.m_p.y));
c=e.position.y+(e.R.col1.y*d.m_p.x+e.R.col2.y*d.m_p.y)-(c.position.y+(c.R.col1.y*b.m_p.x+c.R.col2.y*b.m_p.y));e=b.m_radius+d.m_radius;f*f+c*c>e*e||(a.m_type=Box2D.Collision.b2Manifold.e_circles,a.m_localPoint.SetV(b.m_p),a.m_localPlaneNormal.SetZero(),a.m_pointCount=1,a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.SetKey(0))};Box2D.Collision.b2Collision.CollidePolygonAndCircle=function(a,b,c,d,e){a.m_pointCount=0;var f=e.position.x+(e.R.col1.x*d.m_p.x+e.R.col2.x*d.m_p.y)-c.position.x,g=
e.position.y+(e.R.col1.y*d.m_p.x+e.R.col2.y*d.m_p.y)-c.position.y;e=f*c.R.col1.x+g*c.R.col1.y;c=f*c.R.col2.x+g*c.R.col2.y;for(var f=0,g=-Number.MAX_VALUE,h=b.m_radius+d.m_radius,l=0;l<b.m_vertexCount;++l){var k=b.m_normals[l].x*(e-b.m_vertices[l].x)+b.m_normals[l].y*(c-b.m_vertices[l].y);if(k>h)return;k>g&&(g=k,f=l)}k=f+1;k>=b.m_vertexCount&&(k=0);var l=b.m_vertices[f],m=b.m_vertices[k];g<Number.MIN_VALUE?(a.m_pointCount=1,a.m_type=Box2D.Collision.b2Manifold.e_faceA,a.m_localPlaneNormal.SetV(b.m_normals[f]),
a.m_localPoint.x=0.5*(l.x+m.x),a.m_localPoint.y=0.5*(l.y+m.y),a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.SetKey(0)):0>=(e-l.x)*(m.x-l.x)+(c-l.y)*(m.y-l.y)?(e-l.x)*(e-l.x)+(c-l.y)*(c-l.y)>h*h||(a.m_pointCount=1,a.m_type=Box2D.Collision.b2Manifold.e_faceA,a.m_localPlaneNormal.x=e-l.x,a.m_localPlaneNormal.y=c-l.y,a.m_localPlaneNormal.Normalize(),a.m_localPoint.SetV(l),a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.SetKey(0)):0>=(e-m.x)*(l.x-m.x)+(c-m.y)*(l.y-m.y)?(e-m.x)*(e-
m.x)+(c-m.y)*(c-m.y)>h*h||(a.m_pointCount=1,a.m_type=Box2D.Collision.b2Manifold.e_faceA,a.m_localPlaneNormal.x=e-m.x,a.m_localPlaneNormal.y=c-m.y,a.m_localPlaneNormal.Normalize(),a.m_localPoint.SetV(m),a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.SetKey(0)):(k=0.5*(l.x+m.x),l=0.5*(l.y+m.y),g=(e-k)*b.m_normals[f].x+(c-l)*b.m_normals[f].y,g>h||(a.m_pointCount=1,a.m_type=Box2D.Collision.b2Manifold.e_faceA,a.m_localPlaneNormal.x=b.m_normals[f].x,a.m_localPlaneNormal.y=b.m_normals[f].y,a.m_localPlaneNormal.Normalize(),
a.m_localPoint.Set(k,l),a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.SetKey(0)))};Box2D.Collision.b2Collision.TestOverlap=function(a,b){return 0<b.lowerBound_.x-a.upperBound_.x||0<b.lowerBound_.y-a.upperBound_.y||0<a.lowerBound_.x-b.upperBound_.x||0<a.lowerBound_.y-b.upperBound_.y?!1:!0};Box2D.Collision.b2ContactPoint=function(){this.position=Box2D.Common.Math.b2Vec2.Get(0,0);this.velocity=Box2D.Common.Math.b2Vec2.Get(0,0);this.normal=Box2D.Common.Math.b2Vec2.Get(0,0);this.id=new Box2D.Collision.b2ContactID};
Box2D.Collision.b2Distance.Distance=function(a,b,c){var d=new Box2D.Collision.b2Simplex;d.ReadCache(b,c.proxyA,c.transformA,c.proxyB,c.transformB);for(var e=0;20>e;){for(var f=[],g=0;g<d.m_count;g++)f[g]={},f[g].indexA=d.m_vertices[g].indexA,f[g].indexB=d.m_vertices[g].indexB;2==d.m_count?d.Solve2():3==d.m_count&&d.Solve3();if(3==d.m_count)break;g=d.GetSearchDirection();if(g.LengthSquared()<Box2D.Common.b2Settings.MIN_VALUE_SQUARED)break;var h=g.GetNegative();d.m_vertices[d.m_count].indexA=c.proxyA.GetSupport(Box2D.Common.Math.b2Math.MulTMV(c.transformA.R,
h));d.m_vertices[d.m_count].wA=Box2D.Common.Math.b2Math.MulX(c.transformA,c.proxyA.GetVertex(d.m_vertices[d.m_count].indexA));d.m_vertices[d.m_count].indexB=c.proxyB.GetSupport(Box2D.Common.Math.b2Math.MulTMV(c.transformB.R,g));d.m_vertices[d.m_count].wB=Box2D.Common.Math.b2Math.MulX(c.transformB,c.proxyB.GetVertex(d.m_vertices[d.m_count].indexB));d.m_vertices[d.m_count].w=Box2D.Common.Math.b2Math.SubtractVV(d.m_vertices[d.m_count].wB,d.m_vertices[d.m_count].wA);Box2D.Common.Math.b2Vec2.Free(g);Box2D.Common.Math.b2Vec2.Free(h);
e++;h=!1;for(g=0;g<f.length;g++)if(d.m_vertices[d.m_count].indexA==f[g].indexA&&d.m_vertices[d.m_count].indexB==f[g].indexB){h=!0;break}if(h)break;d.m_count++}d.GetWitnessPoints(a.pointA,a.pointB);a.distance=Box2D.Common.Math.b2Math.SubtractVV(a.pointA,a.pointB).Length();d.WriteCache(b);c.useRadii&&(b=c.proxyA.m_radius,c=c.proxyB.m_radius,a.distance>b+c&&a.distance>Number.MIN_VALUE?(a.distance-=b+c,d=Box2D.Common.Math.b2Math.SubtractVV(a.pointB,a.pointA),d.Normalize(),a.pointA.x+=b*d.x,a.pointA.y+=
b*d.y,a.pointB.x-=c*d.x,a.pointB.y-=c*d.y,Box2D.Common.Math.b2Vec2.Free(d)):(c=Box2D.Common.Math.b2Vec2.Get(0,0),c.x=0.5*(a.pointA.x+a.pointB.x),c.y=0.5*(a.pointA.y+a.pointB.y),a.pointA.x=a.pointB.x=c.x,a.pointA.y=a.pointB.y=c.y,a.distance=0,Box2D.Common.Math.b2Vec2.Free(c)))};Box2D.Collision.b2DistanceInput=function(){};Box2D.Collision.b2DistanceOutput=function(){this.pointA=Box2D.Common.Math.b2Vec2.Get(0,0);this.pointB=Box2D.Common.Math.b2Vec2.Get(0,0);this.distance=0};Box2D.Collision.b2DistanceProxy=
function(){};Box2D.Collision.b2DistanceProxy.prototype.Set=function(a){a.SetDistanceProxy(this)};Box2D.Collision.b2DistanceProxy.prototype.GetSupport=function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_count;d++){var e=this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return b};Box2D.Collision.b2DistanceProxy.prototype.GetSupportVertex=function(a){return this.m_vertices[this.GetSupport(a)]};Box2D.Collision.b2DistanceProxy.prototype.GetVertexCount=
function(){return this.m_count};Box2D.Collision.b2DistanceProxy.prototype.GetVertex=function(a){void 0===a&&(a=0);return this.m_vertices[a]};Box2D.Collision.b2DynamicTree=function(){this.m_root=null;this.m_insertionCount=this.m_path=0};Box2D.Collision.b2DynamicTree.prototype.CreateProxy=function(a,b){var c=Box2D.Collision.b2DynamicTreeNode.Get(b),d=Box2D.Common.b2Settings.b2_aabbExtension,e=Box2D.Common.b2Settings.b2_aabbExtension;c.aabb.lowerBound_.x=a.lowerBound_.x-d;c.aabb.lowerBound_.y=a.lowerBound_.y-
e;c.aabb.upperBound_.x=a.upperBound_.x+d;c.aabb.upperBound_.y=a.upperBound_.y+e;this.InsertLeaf(c);return c};Box2D.Collision.b2DynamicTree.prototype.DestroyProxy=function(a){this.RemoveLeaf(a);a.Destroy()};Box2D.Collision.b2DynamicTree.prototype.MoveProxy=function(a,b,c){if(a.aabb.Contains(b))return!1;this.RemoveLeaf(a);var d=Box2D.Common.b2Settings.b2_aabbExtension+Box2D.Common.b2Settings.b2_aabbMultiplier*Math.abs(c.x);c=Box2D.Common.b2Settings.b2_aabbExtension+Box2D.Common.b2Settings.b2_aabbMultiplier*
Math.abs(c.y);a.aabb.lowerBound_.x=b.lowerBound_.x-d;a.aabb.lowerBound_.y=b.lowerBound_.y-c;a.aabb.upperBound_.x=b.upperBound_.x+d;a.aabb.upperBound_.y=b.upperBound_.y+c;this.InsertLeaf(a);return!0};Box2D.Collision.b2DynamicTree.prototype.Rebalance=function(a){if(null!==this.m_root)for(var b=0;b<a;b++){for(var c=this.m_root,d=0;!c.IsLeaf();)c=this.m_path>>d&1?c.child2:c.child1,d=d+1&31;this.m_path++;this.RemoveLeaf(c);this.InsertLeaf(c)}};Box2D.Collision.b2DynamicTree.prototype.GetFatAABB=function(a){return a.aabb};
Box2D.Collision.b2DynamicTree.prototype.Query=function(a,b){if(null!==this.m_root){var c=[];for(c.push(this.m_root);0<c.length;){var d=c.pop();if(d.aabb.TestOverlap(b))if(d.IsLeaf()){if(!a(d.fixture))break}else c.push(d.child1),c.push(d.child2)}}};Box2D.Collision.b2DynamicTree.prototype.RayCast=function(a,b){if(null!==this.m_root){var c=Box2D.Common.Math.b2Math.SubtractVV(b.p1,b.p2);c.Normalize();var c=Box2D.Common.Math.b2Math.CrossFV(1,c),d=Box2D.Common.Math.b2Math.AbsV(c),e=b.maxFraction,f=b.p1.x+
e*(b.p2.x-b.p1.x),e=b.p1.y+e*(b.p2.y-b.p1.y),g=Box2D.Collision.b2AABB.Get();g.lowerBound_.x=Math.min(b.p1.x,f);g.lowerBound_.y=Math.min(b.p1.y,e);g.upperBound_.x=Math.max(b.p1.x,f);g.upperBound_.y=Math.max(b.p1.y,e);var h=[];for(h.push(this.m_root);0<h.length;)if(f=h.pop(),f.aabb.TestOverlap(g)){var e=f.aabb.GetCenter(),l=f.aabb.GetExtents();if(!(0<Math.abs(c.x*(b.p1.x-e.x)+c.y*(b.p1.y-e.y))-d.x*l.x-d.y*l.y))if(f.IsLeaf()){new Box2D.Collision.b2RayCastInput(b.p1,b.p2,b.maxFraction);e=a(b,f.fixture);
if(0==e)break;0<e&&(f=b.p1.x+e*(b.p2.x-b.p1.x),e=b.p1.y+e*(b.p2.y-b.p1.y),g.lowerBound_.x=Math.min(b.p1.x,f),g.lowerBound_.y=Math.min(b.p1.y,e),g.upperBound_.x=Math.max(b.p1.x,f),g.upperBound_.y=Math.max(b.p1.y,e))}else h.push(f.child1),h.push(f.child2)}Box2D.Collision.b2AABB.Free(g)}};Box2D.Collision.b2DynamicTree.prototype.InsertLeaf=function(a){this.m_insertionCount++;if(null===this.m_root)this.m_root=a,this.m_root.parent=null;else{var b=this.GetBestSibling(a),c=b.parent,d=Box2D.Collision.b2DynamicTreeNode.Get();
d.parent=c;d.aabb.Combine(a.aabb,b.aabb);if(c)for(b.parent.child1==b?c.child1=d:c.child2=d,d.child1=b,d.child2=a,b.parent=d,a.parent=d;c&&!c.aabb.Contains(d.aabb);)c.aabb.Combine(c.child1.aabb,c.child2.aabb),d=c,c=c.parent;else d.child1=b,d.child2=a,b.parent=d,this.m_root=a.parent=d}};Box2D.Collision.b2DynamicTree.prototype.GetBestSibling=function(a){a=a.aabb.GetCenter();for(var b=this.m_root;!b.IsLeaf();)var c=b.child1,b=b.child2,d=Math.abs((c.aabb.lowerBound_.x+c.aabb.upperBound_.x)/2-a.x)+Math.abs((c.aabb.lowerBound_.y+
c.aabb.upperBound_.y)/2-a.y),e=Math.abs((b.aabb.lowerBound_.x+b.aabb.upperBound_.x)/2-a.x)+Math.abs((b.aabb.lowerBound_.y+b.aabb.upperBound_.y)/2-a.y),b=d<e?c:b;Box2D.Common.Math.b2Vec2.Free(a);return b};Box2D.Collision.b2DynamicTree.prototype.RemoveLeaf=function(a){if(a==this.m_root)this.m_root=null;else{var b=a.parent,c=b.parent;a=b.child1==a?b.child2:b.child1;if(c)for(c.child1==b?c.child1=a:c.child2=a,a.parent=c;c;){a=c.aabb;c.aabb.Combine(c.child1.aabb,c.child2.aabb);if(a.Contains(c.aabb))break;
c=c.parent}else this.m_root=a,a.parent=null;b.Destroy()}};Box2D.Collision.b2DynamicTreeBroadPhase=function(){this.m_tree=new Box2D.Collision.b2DynamicTree;this.m_moveBuffer=[]};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.CreateProxy=function(a,b){var c=this.m_tree.CreateProxy(a,b);this.BufferMove(c);return c};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.DestroyProxy=function(a){this.UnBufferMove(a);this.m_tree.DestroyProxy(a)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.MoveProxy=
function(a,b,c){this.m_tree.MoveProxy(a,b,c)&&this.BufferMove(a)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.TestOverlap=function(a,b){var c=this.m_tree.GetFatAABB(a),d=this.m_tree.GetFatAABB(b);return c.TestOverlap(d)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.GetFatAABB=function(a){return this.m_tree.GetFatAABB(a)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.GetProxyCount=function(){return this.m_tree.length};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.UpdatePairs=function(a){for(var b=
[];0<this.m_moveBuffer.length;){var c=this.m_moveBuffer.pop(),d=this.m_tree.GetFatAABB(c);this.m_tree.Query(function(a){a!=c.fixture&&b.push(new Box2D.Collision.b2DynamicTreePair(c.fixture,a));return!0},d)}for(d=0;d<b.length;){var e=b[d];a(e.fixtureA,e.fixtureB);for(d++;d<b.length;){var f=b[d];if(!(f.fixtureA==e.fixtureA&&f.fixtureB==e.fixtureB||f.fixtureA==e.fixtureB&&f.fixtureB==e.fixtureA))break;d++}}};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.Query=function(a,b){this.m_tree.Query(a,b)};
Box2D.Collision.b2DynamicTreeBroadPhase.prototype.RayCast=function(a,b){this.m_tree.RayCast(a,b)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.Rebalance=function(a){this.m_tree.Rebalance(a)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.BufferMove=function(a){this.m_moveBuffer.push(a)};Box2D.Collision.b2DynamicTreeBroadPhase.prototype.UnBufferMove=function(a){cr.arrayFindRemove(this.m_moveBuffer,a)};Box2D.Collision.b2DynamicTreeBroadPhase.__implements={};Box2D.Collision.b2DynamicTreeBroadPhase.__implements[Box2D.Collision.IBroadPhase]=
!0;Box2D.Collision.b2DynamicTreeNode=function(a){this.aabb=Box2D.Collision.b2AABB.Get();this.fixture=this.parent=this.child2=this.child1=null;"undefined"!=typeof a&&(this.fixture=a)};Box2D.Collision.b2DynamicTreeNode._freeCache=[];Box2D.Collision.b2DynamicTreeNode.Get=function(a){if(0<Box2D.Collision.b2DynamicTreeNode._freeCache.length){var b=Box2D.Collision.b2DynamicTreeNode._freeCache.pop();"undefined"!=typeof a&&(b.fixture=a);b.aabb.SetZero();return b}return new Box2D.Collision.b2DynamicTreeNode(a)};
Box2D.Collision.b2DynamicTreeNode.prototype.Destroy=function(){this.fixture=this.parent=this.child2=this.child1=null;Box2D.Collision.b2DynamicTreeNode._freeCache.push(this)};Box2D.Collision.b2DynamicTreeNode.prototype.IsLeaf=function(){return null===this.child1};Box2D.Collision.b2DynamicTreePair=function(a,b){this.fixtureA=a;this.fixtureB=b};Box2D.Collision.b2Manifold=function(){this.m_type=this.m_pointCount=0;this.m_points=[];for(var a=0;a<Box2D.Common.b2Settings.b2_maxManifoldPoints;a++)this.m_points[a]=
new Box2D.Collision.b2ManifoldPoint;this.m_localPlaneNormal=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localPoint=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2Manifold.prototype.Reset=function(){for(var a=0;a<Box2D.Common.b2Settings.b2_maxManifoldPoints;a++)this.m_points[a].Reset();this.m_localPlaneNormal.SetZero();this.m_localPoint.SetZero();this.m_pointCount=this.m_type=0};Box2D.Collision.b2Manifold.prototype.Set=function(a){this.m_pointCount=a.m_pointCount;for(var b=0;b<Box2D.Common.b2Settings.b2_maxManifoldPoints;b++)this.m_points[b].Set(a.m_points[b]);
this.m_localPlaneNormal.SetV(a.m_localPlaneNormal);this.m_localPoint.SetV(a.m_localPoint);this.m_type=a.m_type};Box2D.Collision.b2Manifold.prototype.Copy=function(){var a=new Box2D.Collision.b2Manifold;a.Set(this);return a};Box2D.Collision.b2Manifold.e_circles=1;Box2D.Collision.b2Manifold.e_faceA=2;Box2D.Collision.b2Manifold.e_faceB=4;Box2D.Collision.b2ManifoldPoint=function(){this.m_localPoint=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_id=new Box2D.Collision.b2ContactID;this.Reset()};Box2D.Collision.b2ManifoldPoint.prototype.Reset=
function(){this.m_localPoint.SetZero();this.m_tangentImpulse=this.m_normalImpulse=0;this.m_id.SetKey(0)};Box2D.Collision.b2ManifoldPoint.prototype.Set=function(a){this.m_localPoint.SetV(a.m_localPoint);this.m_normalImpulse=a.m_normalImpulse;this.m_tangentImpulse=a.m_tangentImpulse;this.m_id.Set(a.m_id)};Box2D.Collision.b2RayCastInput=function(a,b,c){this.p1=Box2D.Common.Math.b2Vec2.Get(0,0);this.p2=Box2D.Common.Math.b2Vec2.Get(0,0);void 0===c&&(c=1);a&&this.p1.SetV(a);b&&this.p2.SetV(b);this.maxFraction=
c};Box2D.Collision.b2RayCastOutput=function(){this.normal=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2Segment=function(){this.p1=Box2D.Common.Math.b2Vec2.Get(0,0);this.p2=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2Segment.prototype.TestSegment=function(a,b,c,d){void 0===d&&(d=0);var e=c.p1,f=c.p2.x-e.x,g=c.p2.y-e.y;c=this.p2.y-this.p1.y;var h=-(this.p2.x-this.p1.x),l=100*Number.MIN_VALUE,k=-(f*c+g*h);if(k>l){var m=e.x-this.p1.x,n=e.y-this.p1.y,e=m*c+n*h;if(0<=e&&e<=d*k&&(d=-f*n+
g*m,-l*k<=d&&d<=k*(1+l)))return e/=k,d=Math.sqrt(c*c+h*h),a[0]=e,b.Set(c/d,h/d),!0}return!1};Box2D.Collision.b2Segment.prototype.Extend=function(a){this.ExtendForward(a);this.ExtendBackward(a)};Box2D.Collision.b2Segment.prototype.ExtendForward=function(a){var b=this.p2.x-this.p1.x,c=this.p2.y-this.p1.y;a=Math.min(0<b?(a.upperBound_.x-this.p1.x)/b:0>b?(a.lowerBound_.x-this.p1.x)/b:Number.POSITIVE_INFINITY,0<c?(a.upperBound_.y-this.p1.y)/c:0>c?(a.lowerBound_.y-this.p1.y)/c:Number.POSITIVE_INFINITY);
this.p2.x=this.p1.x+b*a;this.p2.y=this.p1.y+c*a};Box2D.Collision.b2Segment.prototype.ExtendBackward=function(a){var b=-this.p2.x+this.p1.x,c=-this.p2.y+this.p1.y;a=Math.min(0<b?(a.upperBound_.x-this.p2.x)/b:0>b?(a.lowerBound_.x-this.p2.x)/b:Number.POSITIVE_INFINITY,0<c?(a.upperBound_.y-this.p2.y)/c:0>c?(a.lowerBound_.y-this.p2.y)/c:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+b*a;this.p1.y=this.p2.y+c*a};Box2D.Collision.b2SeparationFunction=function(){this.m_localPoint=Box2D.Common.Math.b2Vec2.Get(0,
0);this.m_axis=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2SeparationFunction.prototype.Initialize=function(a,b,c,d,e){this.m_proxyA=b;this.m_proxyB=d;var f,g,h,l=h=g=0,k=0;d=b=0;var m,n,l=0;1==a.count?(this.m_type=Box2D.Collision.b2SeparationFunction.e_points,f=this.m_proxyA.GetVertex(a.indexA[0]),a=this.m_proxyB.GetVertex(a.indexB[0]),n=f,m=c.R,g=c.position.x+(m.col1.x*n.x+m.col2.x*n.y),h=c.position.y+(m.col1.y*n.x+m.col2.y*n.y),n=a,m=e.R,l=e.position.x+(m.col1.x*n.x+m.col2.x*n.y),k=e.position.y+
(m.col1.y*n.x+m.col2.y*n.y),this.m_axis.x=l-g,this.m_axis.y=k-h,this.m_axis.Normalize()):(a.indexB[0]==a.indexB[1]?(this.m_type=Box2D.Collision.b2SeparationFunction.e_faceA,b=this.m_proxyA.GetVertex(a.indexA[0]),d=this.m_proxyA.GetVertex(a.indexA[1]),a=this.m_proxyB.GetVertex(a.indexB[0]),this.m_localPoint.x=0.5*(b.x+d.x),this.m_localPoint.y=0.5*(b.y+d.y),this.m_axis=Box2D.Common.Math.b2Math.CrossVF(Box2D.Common.Math.b2Math.SubtractVV(d,b),1),this.m_axis.Normalize(),n=this.m_axis,m=c.R,b=m.col1.x*
n.x+m.col2.x*n.y,d=m.col1.y*n.x+m.col2.y*n.y,n=this.m_localPoint,m=c.R,g=c.position.x+(m.col1.x*n.x+m.col2.x*n.y),h=c.position.y+(m.col1.y*n.x+m.col2.y*n.y),n=a,m=e.R,l=e.position.x+(m.col1.x*n.x+m.col2.x*n.y),k=e.position.y+(m.col1.y*n.x+m.col2.y*n.y),l=(l-g)*b+(k-h)*d):a.indexA[0]==a.indexA[0]?(this.m_type=Box2D.Collision.b2SeparationFunction.e_faceB,g=this.m_proxyB.GetVertex(a.indexB[0]),h=this.m_proxyB.GetVertex(a.indexB[1]),f=this.m_proxyA.GetVertex(a.indexA[0]),this.m_localPoint.x=0.5*(g.x+
h.x),this.m_localPoint.y=0.5*(g.y+h.y),this.m_axis=Box2D.Common.Math.b2Math.CrossVF(Box2D.Common.Math.b2Math.SubtractVV(h,g),1),this.m_axis.Normalize(),n=this.m_axis,m=e.R,b=m.col1.x*n.x+m.col2.x*n.y,d=m.col1.y*n.x+m.col2.y*n.y,n=this.m_localPoint,m=e.R,l=e.position.x+(m.col1.x*n.x+m.col2.x*n.y),k=e.position.y+(m.col1.y*n.x+m.col2.y*n.y),n=f,m=c.R,g=c.position.x+(m.col1.x*n.x+m.col2.x*n.y),h=c.position.y+(m.col1.y*n.x+m.col2.y*n.y),l=(g-l)*b+(h-k)*d):(b=this.m_proxyA.GetVertex(a.indexA[0]),d=this.m_proxyA.GetVertex(a.indexA[1]),
g=this.m_proxyB.GetVertex(a.indexB[0]),h=this.m_proxyB.GetVertex(a.indexB[1]),l=Box2D.Common.Math.b2Math.MulMV(c.R,Box2D.Common.Math.b2Math.SubtractVV(d,b)),k=Box2D.Common.Math.b2Math.MulMV(e.R,Box2D.Common.Math.b2Math.SubtractVV(h,g)),e=l.x*l.x+l.y*l.y,c=k.x*k.x+k.y*k.y,f=Box2D.Common.Math.b2Math.SubtractVV(k,l),a=l.x*f.x+l.y*f.y,f=k.x*f.x+k.y*f.y,k=l.x*k.x+l.y*k.y,m=e*c-k*k,l=0,0!=m&&(l=Box2D.Common.Math.b2Math.Clamp((k*f-a*c)/m,0,1)),0>(k*l+f)/c&&(l=Box2D.Common.Math.b2Math.Clamp((k-a)/e,0,1)),
f=Box2D.Common.Math.b2Vec2.Get(0,0),f.x=b.x+l*(d.x-b.x),f.y=b.y+l*(d.y-b.y),a=Box2D.Common.Math.b2Vec2.Get(0,0),a.x=g.x+l*(h.x-g.x),a.y=g.y+l*(h.y-g.y),0==l||1==l?(this.m_type=Box2D.Collision.b2SeparationFunction.e_faceB,this.m_axis=Box2D.Common.Math.b2Math.CrossVF(Box2D.Common.Math.b2Math.SubtractVV(h,g),1),this.m_axis.Normalize(),this.m_localPoint=a):(this.m_type=Box2D.Collision.b2SeparationFunction.e_faceA,this.m_axis=Box2D.Common.Math.b2Math.CrossVF(Box2D.Common.Math.b2Math.SubtractVV(d,b),1),
this.m_localPoint=f)),0>l&&this.m_axis.NegativeSelf())};Box2D.Collision.b2SeparationFunction.prototype.Evaluate=function(a,b){var c,d,e=0;switch(this.m_type){case Box2D.Collision.b2SeparationFunction.e_points:c=Box2D.Common.Math.b2Math.MulTMV(a.R,this.m_axis);d=Box2D.Common.Math.b2Math.MulTMV(b.R,this.m_axis.GetNegative());c=this.m_proxyA.GetSupportVertex(c);d=this.m_proxyB.GetSupportVertex(d);c=Box2D.Common.Math.b2Math.MulX(a,c);d=Box2D.Common.Math.b2Math.MulX(b,d);e=(d.x-c.x)*this.m_axis.x+(d.y-
c.y)*this.m_axis.y;break;case Box2D.Collision.b2SeparationFunction.e_faceA:e=Box2D.Common.Math.b2Math.MulMV(a.R,this.m_axis);c=Box2D.Common.Math.b2Math.MulX(a,this.m_localPoint);d=Box2D.Common.Math.b2Math.MulTMV(b.R,e.GetNegative());d=this.m_proxyB.GetSupportVertex(d);d=Box2D.Common.Math.b2Math.MulX(b,d);e=(d.x-c.x)*e.x+(d.y-c.y)*e.y;break;case Box2D.Collision.b2SeparationFunction.e_faceB:e=Box2D.Common.Math.b2Math.MulMV(b.R,this.m_axis),d=Box2D.Common.Math.b2Math.MulX(b,this.m_localPoint),c=Box2D.Common.Math.b2Math.MulTMV(a.R,
e.GetNegative()),c=this.m_proxyA.GetSupportVertex(c),c=Box2D.Common.Math.b2Math.MulX(a,c),e=(c.x-d.x)*e.x+(c.y-d.y)*e.y}return e};Box2D.Collision.b2SeparationFunction.e_points=1;Box2D.Collision.b2SeparationFunction.e_faceA=2;Box2D.Collision.b2SeparationFunction.e_faceB=4;Box2D.Collision.b2Simplex=function(){this.m_v1=new Box2D.Collision.b2SimplexVertex;this.m_v2=new Box2D.Collision.b2SimplexVertex;this.m_v3=new Box2D.Collision.b2SimplexVertex;this.m_vertices=[this.m_v1,this.m_v2,this.m_v3]};Box2D.Collision.b2Simplex.prototype.ReadCache=
function(a,b,c,d,e){var f,g;this.m_count=a.count;for(var h=this.m_vertices,l=0;l<this.m_count;l++){var k=h[l];k.indexA=a.indexA[l];k.indexB=a.indexB[l];f=b.GetVertex(k.indexA);g=d.GetVertex(k.indexB);k.wA=Box2D.Common.Math.b2Math.MulX(c,f);k.wB=Box2D.Common.Math.b2Math.MulX(e,g);k.w=Box2D.Common.Math.b2Math.SubtractVV(k.wB,k.wA);k.a=0}1<this.m_count&&(a=a.metric,f=this.GetMetric(),f<0.5*a||2*a<f||f<Number.MIN_VALUE)&&(this.m_count=0);0==this.m_count&&(k=h[0],k.indexA=0,k.indexB=0,f=b.GetVertex(0),
g=d.GetVertex(0),k.wA=Box2D.Common.Math.b2Math.MulX(c,f),k.wB=Box2D.Common.Math.b2Math.MulX(e,g),k.w=Box2D.Common.Math.b2Math.SubtractVV(k.wB,k.wA),this.m_count=1)};Box2D.Collision.b2Simplex.prototype.WriteCache=function(a){a.metric=this.GetMetric();a.count=this.m_count;for(var b=this.m_vertices,c=0;c<this.m_count;c++)a.indexA[c]=b[c].indexA,a.indexB[c]=b[c].indexB};Box2D.Collision.b2Simplex.prototype.GetSearchDirection=function(){if(1==this.m_count)return this.m_v1.w.GetNegative();if(2==this.m_count){var a=
Box2D.Common.Math.b2Math.SubtractVV(this.m_v2.w,this.m_v1.w);return 0<Box2D.Common.Math.b2Math.CrossVV(a,this.m_v1.w.GetNegative())?Box2D.Common.Math.b2Math.CrossFV(1,a):Box2D.Common.Math.b2Math.CrossVF(a,1)}return Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2Simplex.prototype.GetClosestPoint=function(){return 1==this.m_count?this.m_v1.w:2==this.m_count?Box2D.Common.Math.b2Vec2.Get(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y):Box2D.Common.Math.b2Vec2.Get(0,
0)};Box2D.Collision.b2Simplex.prototype.GetWitnessPoints=function(a,b){1==this.m_count?(a.SetV(this.m_v1.wA),b.SetV(this.m_v1.wB)):2==this.m_count?(a.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,a.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,b.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,b.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y):3==this.m_count&&(b.x=a.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,b.y=a.y=this.m_v1.a*
this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y)};Box2D.Collision.b2Simplex.prototype.GetMetric=function(){return 1==this.m_count?0:2==this.m_count?Box2D.Common.Math.b2Math.SubtractVV(this.m_v1.w,this.m_v2.w).Length():3==this.m_count?Box2D.Common.Math.b2Math.CrossVV(Box2D.Common.Math.b2Math.SubtractVV(this.m_v2.w,this.m_v1.w),Box2D.Common.Math.b2Math.SubtractVV(this.m_v3.w,this.m_v1.w)):0};Box2D.Collision.b2Simplex.prototype.Solve2=function(){var a=this.m_v1.w,b=this.m_v2.w,c=
Box2D.Common.Math.b2Math.SubtractVV(b,a),a=-(a.x*c.x+a.y*c.y);0>=a?this.m_count=this.m_v1.a=1:(b=b.x*c.x+b.y*c.y,0>=b?(this.m_count=this.m_v2.a=1,this.m_v1.Set(this.m_v2)):(c=1/(b+a),this.m_v1.a=b*c,this.m_v2.a=a*c,this.m_count=2))};Box2D.Collision.b2Simplex.prototype.Solve3=function(){var a=this.m_v1.w,b=this.m_v2.w,c=this.m_v3.w,d=Box2D.Common.Math.b2Math.SubtractVV(b,a),e=Box2D.Common.Math.b2Math.Dot(a,d),f=Box2D.Common.Math.b2Math.Dot(b,d),e=-e,g=Box2D.Common.Math.b2Math.SubtractVV(c,a),h=Box2D.Common.Math.b2Math.Dot(a,
g),l=Box2D.Common.Math.b2Math.Dot(c,g),h=-h,k=Box2D.Common.Math.b2Math.SubtractVV(c,b),m=Box2D.Common.Math.b2Math.Dot(b,k),k=Box2D.Common.Math.b2Math.Dot(c,k),m=-m,g=Box2D.Common.Math.b2Math.CrossVV(d,g),d=g*Box2D.Common.Math.b2Math.CrossVV(b,c),c=g*Box2D.Common.Math.b2Math.CrossVV(c,a),a=g*Box2D.Common.Math.b2Math.CrossVV(a,b);0>=e&&0>=h?this.m_count=this.m_v1.a=1:0<f&&0<e&&0>=a?(l=1/(f+e),this.m_v1.a=f*l,this.m_v2.a=e*l,this.m_count=2):0<l&&0<h&&0>=c?(f=1/(l+h),this.m_v1.a=l*f,this.m_v3.a=h*f,this.m_count=
2,this.m_v2.Set(this.m_v3)):0>=f&&0>=m?(this.m_count=this.m_v2.a=1,this.m_v1.Set(this.m_v2)):0>=l&&0>=k?(this.m_count=this.m_v3.a=1,this.m_v1.Set(this.m_v3)):0<k&&0<m&&0>=d?(f=1/(k+m),this.m_v2.a=k*f,this.m_v3.a=m*f,this.m_count=2,this.m_v1.Set(this.m_v3)):(f=1/(d+c+a),this.m_v1.a=d*f,this.m_v2.a=c*f,this.m_v3.a=a*f,this.m_count=3)};Box2D.Collision.b2SimplexCache=function(){this.indexA=[0,0,0];this.indexB=[0,0,0]};Box2D.Collision.b2SimplexVertex=function(){};Box2D.Collision.b2SimplexVertex.prototype.Set=
function(a){this.wA.SetV(a.wA);this.wB.SetV(a.wB);this.w.SetV(a.w);this.a=a.a;this.indexA=a.indexA;this.indexB=a.indexB};Box2D.Collision.b2TOIInput=function(){this.proxyA=new Box2D.Collision.b2DistanceProxy;this.proxyB=new Box2D.Collision.b2DistanceProxy;this.sweepA=new Box2D.Common.Math.b2Sweep;this.sweepB=new Box2D.Common.Math.b2Sweep};Box2D.Collision.b2TimeOfImpact={};Box2D.Collision.b2TimeOfImpact.TimeOfImpact=function(a){Box2D.Collision.b2TimeOfImpact.b2_toiCalls++;var b=a.proxyA,c=a.proxyB,
d=a.sweepA,e=a.sweepB,f=b.m_radius+c.m_radius;a=a.tolerance;var g=0,h=0,l=0;Box2D.Collision.b2TimeOfImpact.s_cache.count=0;for(Box2D.Collision.b2TimeOfImpact.s_distanceInput.useRadii=!1;;){d.GetTransform(Box2D.Collision.b2TimeOfImpact.s_xfA,g);e.GetTransform(Box2D.Collision.b2TimeOfImpact.s_xfB,g);Box2D.Collision.b2TimeOfImpact.s_distanceInput.proxyA=b;Box2D.Collision.b2TimeOfImpact.s_distanceInput.proxyB=c;Box2D.Collision.b2TimeOfImpact.s_distanceInput.transformA=Box2D.Collision.b2TimeOfImpact.s_xfA;
Box2D.Collision.b2TimeOfImpact.s_distanceInput.transformB=Box2D.Collision.b2TimeOfImpact.s_xfB;Box2D.Collision.b2Distance.Distance(Box2D.Collision.b2TimeOfImpact.s_distanceOutput,Box2D.Collision.b2TimeOfImpact.s_cache,Box2D.Collision.b2TimeOfImpact.s_distanceInput);if(0>=Box2D.Collision.b2TimeOfImpact.s_distanceOutput.distance){g=1;break}Box2D.Collision.b2TimeOfImpact.s_fcn.Initialize(Box2D.Collision.b2TimeOfImpact.s_cache,b,Box2D.Collision.b2TimeOfImpact.s_xfA,c,Box2D.Collision.b2TimeOfImpact.s_xfB);
var k=Box2D.Collision.b2TimeOfImpact.s_fcn.Evaluate(Box2D.Collision.b2TimeOfImpact.s_xfA,Box2D.Collision.b2TimeOfImpact.s_xfB);if(0>=k){g=1;break}0==h&&(l=k>f?Math.max(f-a,0.75*f):Math.max(k-a,0.02*f));if(k-l<0.5*a){if(0==h){g=1;break}break}var m=g,n=g,q=1;d.GetTransform(Box2D.Collision.b2TimeOfImpact.s_xfA,q);e.GetTransform(Box2D.Collision.b2TimeOfImpact.s_xfB,q);var p=Box2D.Collision.b2TimeOfImpact.s_fcn.Evaluate(Box2D.Collision.b2TimeOfImpact.s_xfA,Box2D.Collision.b2TimeOfImpact.s_xfB);if(p>=l){g=
1;break}for(var r=0;;){var s=0,s=r&1?n+(l-k)*(q-n)/(p-k):0.5*(n+q);d.GetTransform(Box2D.Collision.b2TimeOfImpact.s_xfA,s);e.GetTransform(Box2D.Collision.b2TimeOfImpact.s_xfB,s);var w=Box2D.Collision.b2TimeOfImpact.s_fcn.Evaluate(Box2D.Collision.b2TimeOfImpact.s_xfA,Box2D.Collision.b2TimeOfImpact.s_xfB);if(Math.abs(w-l)<0.025*a){m=s;break}w>l?(n=s,k=w):(q=s,p=w);r++;Box2D.Collision.b2TimeOfImpact.b2_toiRootIters++;if(50==r)break}Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters=Math.max(Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters,
r);if(m<(1+100*Number.MIN_VALUE)*g)break;g=m;h++;Box2D.Collision.b2TimeOfImpact.b2_toiIters++;if(1E3==h)break}Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters=Math.max(Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters,h);return g};Box2D.Collision.b2WorldManifold=function(){this.m_normal=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_points=[];for(var a=this.m_pointCount=0;a<Box2D.Common.b2Settings.b2_maxManifoldPoints;a++)this.m_points[a]=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Collision.b2WorldManifold.prototype.Initialize=
function(a,b,c,d,e){if(0!=a.m_pointCount){var f=0,g,h,l=0,k=0,m=0,n=0,q=0;g=0;switch(a.m_type){case Box2D.Collision.b2Manifold.e_circles:h=b.R;g=a.m_localPoint;f=b.position.x+h.col1.x*g.x+h.col2.x*g.y;b=b.position.y+h.col1.y*g.x+h.col2.y*g.y;h=d.R;g=a.m_points[0].m_localPoint;a=d.position.x+h.col1.x*g.x+h.col2.x*g.y;d=d.position.y+h.col1.y*g.x+h.col2.y*g.y;g=a-f;h=d-b;l=g*g+h*h;l>Box2D.Common.b2Settings.MIN_VALUE_SQUARED?(l=Math.sqrt(l),this.m_normal.x=g/l,this.m_normal.y=h/l):(this.m_normal.x=1,
this.m_normal.y=0);g=b+c*this.m_normal.y;d-=e*this.m_normal.y;this.m_points[0].x=0.5*(f+c*this.m_normal.x+(a-e*this.m_normal.x));this.m_points[0].y=0.5*(g+d);break;case Box2D.Collision.b2Manifold.e_faceA:h=b.R;g=a.m_localPlaneNormal;l=h.col1.x*g.x+h.col2.x*g.y;k=h.col1.y*g.x+h.col2.y*g.y;h=b.R;g=a.m_localPoint;m=b.position.x+h.col1.x*g.x+h.col2.x*g.y;n=b.position.y+h.col1.y*g.x+h.col2.y*g.y;this.m_normal.x=l;this.m_normal.y=k;for(f=0;f<a.m_pointCount;f++)h=d.R,g=a.m_points[f].m_localPoint,q=d.position.x+
h.col1.x*g.x+h.col2.x*g.y,g=d.position.y+h.col1.y*g.x+h.col2.y*g.y,this.m_points[f].x=q+0.5*(c-(q-m)*l-(g-n)*k-e)*l,this.m_points[f].y=g+0.5*(c-(q-m)*l-(g-n)*k-e)*k;break;case Box2D.Collision.b2Manifold.e_faceB:for(h=d.R,g=a.m_localPlaneNormal,l=h.col1.x*g.x+h.col2.x*g.y,k=h.col1.y*g.x+h.col2.y*g.y,h=d.R,g=a.m_localPoint,m=d.position.x+h.col1.x*g.x+h.col2.x*g.y,n=d.position.y+h.col1.y*g.x+h.col2.y*g.y,this.m_normal.x=-l,this.m_normal.y=-k,f=0;f<a.m_pointCount;f++)h=b.R,g=a.m_points[f].m_localPoint,
q=b.position.x+h.col1.x*g.x+h.col2.x*g.y,g=b.position.y+h.col1.y*g.x+h.col2.y*g.y,this.m_points[f].x=q+0.5*(e-(q-m)*l-(g-n)*k-c)*l,this.m_points[f].y=g+0.5*(e-(q-m)*l-(g-n)*k-c)*k}}};Box2D.Dynamics.b2Body=function(a,b){this.ID="Body"+Box2D.Dynamics.b2Body.NEXT_ID++;this.m_xf=new Box2D.Common.Math.b2Transform;this.m_xf.position.SetV(a.position);this.m_xf.R.Set(a.angle);this.m_sweep=new Box2D.Common.Math.b2Sweep;this.m_sweep.localCenter.SetZero();this.m_sweep.t0=1;this.m_sweep.a0=this.m_sweep.a=a.angle;
this.m_sweep.c.x=this.m_xf.R.col1.x*this.m_sweep.localCenter.x+this.m_xf.R.col2.x*this.m_sweep.localCenter.y;this.m_sweep.c.y=this.m_xf.R.col1.y*this.m_sweep.localCenter.x+this.m_xf.R.col2.y*this.m_sweep.localCenter.y;this.m_sweep.c.x+=this.m_xf.position.x;this.m_sweep.c.y+=this.m_xf.position.y;this.m_sweep.c0.SetV(this.m_sweep.c);this.m_linearVelocity=a.linearVelocity.Copy();this.m_force=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_bullet=a.bullet;this.m_fixedRotation=a.fixedRotation;this.m_allowSleep=
a.allowSleep;this.m_awake=a.awake;this.m_active=a.active;this.m_world=b;this.m_jointList=null;this.contactList=new Box2D.Dynamics.Contacts.b2ContactList;this.controllerList=new Box2D.Dynamics.Controllers.b2ControllerList;this.m_controllerCount=0;this.m_angularVelocity=a.angularVelocity;this.m_linearDamping=a.linearDamping;this.m_angularDamping=a.angularDamping;this.m_sleepTime=this.m_torque=0;this.m_type=a.type;this.m_mass=this.m_type==Box2D.Dynamics.b2BodyDef.b2_dynamicBody?1:0;this.m_invMass=this.m_type==
Box2D.Dynamics.b2BodyDef.b2_dynamicBody?1:0;this.m_invI=this.m_I=0;this.m_inertiaScale=a.inertiaScale;this.fixtureList=new Box2D.Dynamics.b2FixtureList;this.m_lists=[]};Box2D.Dynamics.b2Body.prototype.CreateFixture=function(a){a=new Box2D.Dynamics.b2Fixture(this,this.m_xf,a);this.m_active&&a.CreateProxy(this.m_world.m_contactManager.m_broadPhase,this.m_xf);this.fixtureList.AddFixture(a);a.m_body=this;0<a.m_density&&this.ResetMassData();this.m_world.m_newFixture=!0;return a};Box2D.Dynamics.b2Body.prototype.CreateFixture2=
function(a,b){void 0===b&&(b=0);var c=new Box2D.Dynamics.b2FixtureDef;c.shape=a;c.density=b;return this.CreateFixture(c)};Box2D.Dynamics.b2Body.prototype.Destroy=function(){Box2D.Common.Math.b2Vec2.Free(this.m_linearVelocity);Box2D.Common.Math.b2Vec2.Free(this.m_force)};Box2D.Dynamics.b2Body.prototype.DestroyFixture=function(a){this.fixtureList.RemoveFixture(a);for(var b=this.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);b;b=b.GetNextNode())a!=b.contact.m_fixtureA&&
a!=b.contact.m_fixtureB||this.m_world.m_contactManager.Destroy(b.contact);this.m_active&&a.DestroyProxy(this.m_world.m_contactManager.m_broadPhase);a.Destroy();a.m_body=null;this.ResetMassData()};Box2D.Dynamics.b2Body.prototype.SetPositionAndAngle=function(a,b){this.m_xf.R.Set(b);this.m_xf.position.SetV(a);var c=this.m_xf.R,d=this.m_sweep.localCenter;this.m_sweep.c.x=c.col1.x*d.x+c.col2.x*d.y;this.m_sweep.c.y=c.col1.y*d.x+c.col2.y*d.y;this.m_sweep.c.x+=this.m_xf.position.x;this.m_sweep.c.y+=this.m_xf.position.y;
this.m_sweep.c0.SetV(this.m_sweep.c);this.m_sweep.a0=this.m_sweep.a=b;c=this.m_world.m_contactManager.m_broadPhase;for(d=this.fixtureList.GetFirstNode();d;d=d.GetNextNode())d.fixture.Synchronize(c,this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()};Box2D.Dynamics.b2Body.prototype.SetTransform=function(a){this.SetPositionAndAngle(a.position,a.GetAngle())};Box2D.Dynamics.b2Body.prototype.GetTransform=function(){return this.m_xf};Box2D.Dynamics.b2Body.prototype.GetPosition=function(){return this.m_xf.position};
Box2D.Dynamics.b2Body.prototype.SetPosition=function(a){this.SetPositionAndAngle(a,this.GetAngle())};Box2D.Dynamics.b2Body.prototype.GetAngle=function(){return this.m_sweep.a};Box2D.Dynamics.b2Body.prototype.SetAngle=function(a){this.SetPositionAndAngle(this.GetPosition(),a)};Box2D.Dynamics.b2Body.prototype.GetWorldCenter=function(){return this.m_sweep.c};Box2D.Dynamics.b2Body.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter};Box2D.Dynamics.b2Body.prototype.SetLinearVelocity=function(a){this.m_type!=
Box2D.Dynamics.b2BodyDef.b2_staticBody&&this.m_linearVelocity.SetV(a)};Box2D.Dynamics.b2Body.prototype.GetLinearVelocity=function(){return this.m_linearVelocity};Box2D.Dynamics.b2Body.prototype.SetAngularVelocity=function(a){void 0===a&&(a=0);this.m_type!=Box2D.Dynamics.b2BodyDef.b2_staticBody&&(this.m_angularVelocity=a)};Box2D.Dynamics.b2Body.prototype.GetAngularVelocity=function(){return this.m_angularVelocity};Box2D.Dynamics.b2Body.prototype.GetDefinition=function(){var a=new Box2D.Dynamics.b2BodyDef;
a.type=this.GetType();a.allowSleep=this.m_allowSleep;a.angle=this.GetAngle();a.angularDamping=this.m_angularDamping;a.angularVelocity=this.m_angularVelocity;a.fixedRotation=this.m_fixedRotation;a.bullet=this.m_bullet;a.active=this.m_active;a.awake=this.m_awake;a.linearDamping=this.m_linearDamping;a.linearVelocity.SetV(this.GetLinearVelocity());a.position=this.GetPosition();return a};Box2D.Dynamics.b2Body.prototype.ApplyForce=function(a,b){this.m_type==Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&(this.SetAwake(!0),
this.m_force.x+=a.x,this.m_force.y+=a.y,this.m_torque+=(b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x)};Box2D.Dynamics.b2Body.prototype.ApplyTorque=function(a){void 0===a&&(a=0);this.m_type==Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&(this.SetAwake(!0),this.m_torque+=a)};Box2D.Dynamics.b2Body.prototype.ApplyImpulse=function(a,b){this.m_type==Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&(this.SetAwake(!0),this.m_linearVelocity.x+=this.m_invMass*a.x,this.m_linearVelocity.y+=this.m_invMass*a.y,this.m_angularVelocity+=
this.m_invI*((b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x))};Box2D.Dynamics.b2Body.prototype.Split=function(a){for(var b=this.GetLinearVelocity().Copy(),c=this.GetAngularVelocity(),d=this.GetWorldCenter(),e=this.m_world.CreateBody(this.GetDefinition()),f=this.fixtureList.GetFirstNode();f;f=f.GetNextNode()){var g=f.fixture;a(g)&&(this.fixtureList.RemoveFixture(g),e.fixtureList.AddFixture(g))}this.ResetMassData();e.ResetMassData();f=this.GetWorldCenter();a=e.GetWorldCenter();f=Box2D.Common.Math.b2Math.AddVV(b,
Box2D.Common.Math.b2Math.CrossFV(c,Box2D.Common.Math.b2Math.SubtractVV(f,d)));b=Box2D.Common.Math.b2Math.AddVV(b,Box2D.Common.Math.b2Math.CrossFV(c,Box2D.Common.Math.b2Math.SubtractVV(a,d)));this.SetLinearVelocity(f);e.SetLinearVelocity(b);this.SetAngularVelocity(c);e.SetAngularVelocity(c);this.SynchronizeFixtures();e.SynchronizeFixtures();return e};Box2D.Dynamics.b2Body.prototype.Merge=function(a){for(var b=a.fixtureList.GetFirstNode();b;b=b.GetNextNode())this.fixtureList.AddFixture(b.fixture),a.fixtureList.RemoveFixture(b.fixture);
a.ResetMassData();this.ResetMassData();this.SynchronizeFixtures()};Box2D.Dynamics.b2Body.prototype.GetMass=function(){return this.m_mass};Box2D.Dynamics.b2Body.prototype.GetInertia=function(){return this.m_I};Box2D.Dynamics.b2Body.prototype.GetMassData=function(a){a||(a=new Box2D.Collision.Shapes.b2MassData);a.mass=this.m_mass;a.I=this.m_I;a.center.SetV(this.m_sweep.localCenter);return a};Box2D.Dynamics.b2Body.prototype.SetMassData=function(a){if(this.m_type==Box2D.Dynamics.b2BodyDef.b2_dynamicBody){this.m_invI=
this.m_I=this.m_invMass=0;this.m_mass=a.mass;0>=this.m_mass&&(this.m_mass=1);this.m_invMass=1/this.m_mass;0<a.I&&!this.m_fixedRotation&&(this.m_I=a.I-this.m_mass*(a.center.x*a.center.x+a.center.y*a.center.y),this.m_invI=1/this.m_I);var b=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(a.center);this.m_sweep.c0.SetV(Box2D.Common.Math.b2Math.MulX(this.m_xf,this.m_sweep.localCenter));this.m_sweep.c.SetV(this.m_sweep.c0);this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-b.y);this.m_linearVelocity.y+=
this.m_angularVelocity*+(this.m_sweep.c.x-b.x)}};Box2D.Dynamics.b2Body.prototype.ResetMassData=function(){this.m_invI=this.m_I=this.m_invMass=this.m_mass=0;this.m_sweep.localCenter.SetZero();if(this.m_type!=Box2D.Dynamics.b2BodyDef.b2_staticBody&&this.m_type!=Box2D.Dynamics.b2BodyDef.b2_kinematicBody){for(var a=Box2D.Common.Math.b2Vec2.Get(0,0),b=this.fixtureList.GetFirstNode();b;b=b.GetNextNode()){var c=b.fixture;0!=c.m_density&&(c=c.GetMassData(),this.m_mass+=c.mass,a.x+=c.center.x*c.mass,a.y+=
c.center.y*c.mass,this.m_I+=c.I)}0<this.m_mass?(this.m_invMass=1/this.m_mass,a.x*=this.m_invMass,a.y*=this.m_invMass):this.m_invMass=this.m_mass=1;0<this.m_I&&!this.m_fixedRotation?(this.m_I-=this.m_mass*(a.x*a.x+a.y*a.y),this.m_I*=this.m_inertiaScale,this.m_invI=1/this.m_I):this.m_invI=this.m_I=0;b=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(a);this.m_sweep.c0.SetV(Box2D.Common.Math.b2Math.MulX(this.m_xf,this.m_sweep.localCenter));this.m_sweep.c.SetV(this.m_sweep.c0);this.m_linearVelocity.x+=
this.m_angularVelocity*-(this.m_sweep.c.y-b.y);this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-b.x);Box2D.Common.Math.b2Vec2.Free(a);Box2D.Common.Math.b2Vec2.Free(b)}};Box2D.Dynamics.b2Body.prototype.GetWorldPoint=function(a){var b=this.m_xf.R;a=Box2D.Common.Math.b2Vec2.Get(b.col1.x*a.x+b.col2.x*a.y,b.col1.y*a.x+b.col2.y*a.y);a.x+=this.m_xf.position.x;a.y+=this.m_xf.position.y;return a};Box2D.Dynamics.b2Body.prototype.GetWorldVector=function(a){return Box2D.Common.Math.b2Math.MulMV(this.m_xf.R,
a)};Box2D.Dynamics.b2Body.prototype.GetLocalPoint=function(a){return Box2D.Common.Math.b2Math.MulXT(this.m_xf,a)};Box2D.Dynamics.b2Body.prototype.GetLocalVector=function(a){return Box2D.Common.Math.b2Math.MulTMV(this.m_xf.R,a)};Box2D.Dynamics.b2Body.prototype.GetLinearVelocityFromWorldPoint=function(a){return Box2D.Common.Math.b2Vec2.Get(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};Box2D.Dynamics.b2Body.prototype.GetLinearVelocityFromLocalPoint=
function(a){var b=this.m_xf.R;a=Box2D.Common.Math.b2Vec2.Get(b.col1.x*a.x+b.col2.x*a.y,b.col1.y*a.x+b.col2.y*a.y);a.x+=this.m_xf.position.x;a.y+=this.m_xf.position.y;b=Box2D.Common.Math.b2Vec2.Get(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x));Box2D.Common.Math.b2Vec2.Free(a);return b};Box2D.Dynamics.b2Body.prototype.GetLinearDamping=function(){return this.m_linearDamping};Box2D.Dynamics.b2Body.prototype.SetLinearDamping=
function(a){this.m_linearDamping=a};Box2D.Dynamics.b2Body.prototype.GetAngularDamping=function(){return this.m_angularDamping};Box2D.Dynamics.b2Body.prototype.SetAngularDamping=function(a){this.m_angularDamping=a};Box2D.Dynamics.b2Body.prototype.SetType=function(a){if(this.m_type!=a){this.m_type=a;this.ResetMassData();this.m_type==Box2D.Dynamics.b2BodyDef.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0);this.SetAwake(!0);this.m_force.SetZero();this.m_torque=0;for(a=this.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=
a.GetNextNode())a.contact.FlagForFiltering();for(a=0;a<this.m_lists.length;a++)this.m_lists[a].UpdateBody(this)}};Box2D.Dynamics.b2Body.prototype.GetType=function(){return this.m_type};Box2D.Dynamics.b2Body.prototype.SetBullet=function(a){this.m_bullet=a};Box2D.Dynamics.b2Body.prototype.IsBullet=function(){return this.m_bullet};Box2D.Dynamics.b2Body.prototype.SetSleepingAllowed=function(a){(this.m_allowSleep=a)||this.SetAwake(!0)};Box2D.Dynamics.b2Body.prototype.SetAwake=function(a){if(this.m_awake!=
a)for(this.m_awake=a,this.m_sleepTime=0,a||(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0),a=0;a<this.m_lists.length;a++)this.m_lists[a].UpdateBody(this)};Box2D.Dynamics.b2Body.prototype.IsAwake=function(){return this.m_awake};Box2D.Dynamics.b2Body.prototype.SetFixedRotation=function(a){this.m_fixedRotation=a;this.ResetMassData()};Box2D.Dynamics.b2Body.prototype.IsFixedRotation=function(){return this.m_fixedRotation};Box2D.Dynamics.b2Body.prototype.SetActive=
function(a){if(a!=this.m_active){if(a){this.m_active=!0;a=this.m_world.m_contactManager.m_broadPhase;for(var b=this.fixtureList.GetFirstNode();b;b=b.GetNextNode())b.fixture.CreateProxy(a,this.m_xf)}else{this.m_active=!1;a=this.m_world.m_contactManager.m_broadPhase;for(b=this.fixtureList.GetFirstNode();b;b=b.GetNextNode())b.fixture.DestroyProxy(a);for(a=this.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=a.GetNextNode())this.m_world.m_contactManager.Destroy(a.contact)}for(a=
0;a<this.m_lists.length;a++)this.m_lists[a].UpdateBody(this)}};Box2D.Dynamics.b2Body.prototype.IsActive=function(){return this.m_active};Box2D.Dynamics.b2Body.prototype.IsSleepingAllowed=function(){return this.m_allowSleep};Box2D.Dynamics.b2Body.prototype.GetFixtureList=function(){return this.fixtureList};Box2D.Dynamics.b2Body.prototype.GetJointList=function(){return this.m_jointList};Box2D.Dynamics.b2Body.prototype.GetControllerList=function(){return this.controllerList};Box2D.Dynamics.b2Body.prototype.AddController=
function(a){this.controllerList.AddController(a)};Box2D.Dynamics.b2Body.prototype.RemoveController=function(a){this.controllerList.RemoveController(a)};Box2D.Dynamics.b2Body.prototype.GetContactList=function(){return this.contactList};Box2D.Dynamics.b2Body.prototype.GetWorld=function(){return this.m_world};Box2D.Dynamics.b2Body.prototype.SynchronizeFixtures=function(){var a=Box2D.Dynamics.b2Body.s_xf1;a.R.Set(this.m_sweep.a0);var b=a.R,c=this.m_sweep.localCenter;a.position.x=this.m_sweep.c0.x-(b.col1.x*
c.x+b.col2.x*c.y);a.position.y=this.m_sweep.c0.y-(b.col1.y*c.x+b.col2.y*c.y);b=this.m_world.m_contactManager.m_broadPhase;for(c=this.fixtureList.GetFirstNode();c;c=c.GetNextNode())c.fixture.Synchronize(b,a,this.m_xf)};Box2D.Dynamics.b2Body.prototype.SynchronizeTransform=function(){this.m_xf.R.Set(this.m_sweep.a);var a=this.m_xf.R,b=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(a.col1.x*b.x+a.col2.x*b.y);this.m_xf.position.y=this.m_sweep.c.y-(a.col1.y*b.x+a.col2.y*b.y)};Box2D.Dynamics.b2Body.prototype.ShouldCollide=
function(a){if(this.m_type!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&a.m_type!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody)return!1;for(var b=this.m_jointList;b;b=b.next)if(b.other==a&&!1==b.joint.m_collideConnected)return!1;return!0};Box2D.Dynamics.b2Body.prototype.Advance=function(a){this.m_sweep.Advance(a);this.m_sweep.c.SetV(this.m_sweep.c0);this.m_sweep.a=this.m_sweep.a0;this.SynchronizeTransform()};Box2D.Dynamics.b2Body.NEXT_ID=0;Box2D.Dynamics.b2BodyDef=function(){this.position=Box2D.Common.Math.b2Vec2.Get(0,
0);this.linearVelocity=Box2D.Common.Math.b2Vec2.Get(0,0);this.angularDamping=this.linearDamping=this.angularVelocity=this.angle=0;this.awake=this.allowSleep=!0;this.bullet=this.fixedRotation=!1;this.type=Box2D.Dynamics.b2BodyDef.b2_staticBody;this.active=!0;this.inertiaScale=1};Box2D.Dynamics.b2BodyDef.b2_staticBody=0;Box2D.Dynamics.b2BodyDef.b2_kinematicBody=1;Box2D.Dynamics.b2BodyDef.b2_dynamicBody=2;Box2D.Dynamics.b2BodyList=function(){this.bodyFirstNodes=[];for(var a=0;a<=Box2D.Dynamics.b2BodyList.TYPES.allBodies;a++)this.bodyFirstNodes[a]=
null;this.bodyLastNodes=[];for(a=0;a<=Box2D.Dynamics.b2BodyList.TYPES.allBodies;a++)this.bodyLastNodes[a]=null;this.bodyNodeLookup={};this.bodyCount=0};Box2D.Dynamics.b2BodyList.prototype.GetFirstNode=function(a){return this.bodyFirstNodes[a]};Box2D.Dynamics.b2BodyList.prototype.AddBody=function(a){var b=a.ID;null==this.bodyNodeLookup[b]&&(this.CreateNode(a,b,Box2D.Dynamics.b2BodyList.TYPES.allBodies),this.UpdateBody(a),a.m_lists.push(this),this.bodyCount++)};Box2D.Dynamics.b2BodyList.prototype.UpdateBody=
function(a){var b=a.GetType(),c=a.ID,d=a.IsAwake(),e=a.IsActive();b==Box2D.Dynamics.b2BodyDef.b2_dynamicBody?this.CreateNode(a,c,Box2D.Dynamics.b2BodyList.TYPES.dynamicBodies):this.RemoveNode(c,Box2D.Dynamics.b2BodyList.TYPES.dynamicBodies);b!=Box2D.Dynamics.b2BodyDef.b2_staticBody?this.CreateNode(a,c,Box2D.Dynamics.b2BodyList.TYPES.nonStaticBodies):this.RemoveNode(c,Box2D.Dynamics.b2BodyList.TYPES.nonStaticBodies);b!=Box2D.Dynamics.b2BodyDef.b2_staticBody&&e&&d?this.CreateNode(a,c,Box2D.Dynamics.b2BodyList.TYPES.nonStaticActiveAwakeBodies):
this.RemoveNode(c,Box2D.Dynamics.b2BodyList.TYPES.nonStaticActiveAwakeBodies);d?this.CreateNode(a,c,Box2D.Dynamics.b2BodyList.TYPES.awakeBodies):this.RemoveNode(c,Box2D.Dynamics.b2BodyList.TYPES.awakeBodies);e?this.CreateNode(a,c,Box2D.Dynamics.b2BodyList.TYPES.activeBodies):this.RemoveNode(c,Box2D.Dynamics.b2BodyList.TYPES.activeBodies)};Box2D.Dynamics.b2BodyList.prototype.RemoveBody=function(a){var b=a.ID;if(null!=this.bodyNodeLookup[b]){cr.arrayFindRemove(a.m_lists,this);for(a=0;a<=Box2D.Dynamics.b2BodyList.TYPES.allBodies;a++)this.RemoveNode(b,
a);delete this.bodyNodeLookup[b];this.bodyCount--}};Box2D.Dynamics.b2BodyList.prototype.RemoveNode=function(a,b){var c=this.bodyNodeLookup[a];if(null!=c){var d=c[b];null!=d&&(c[b]=null,c=d.GetPreviousNode(),d=d.GetNextNode(),null==c?this.bodyFirstNodes[b]=d:c.SetNextNode(d),null==d?this.bodyLastNodes[b]=c:d.SetPreviousNode(c))}};Box2D.Dynamics.b2BodyList.prototype.CreateNode=function(a,b,c){var d=this.bodyNodeLookup[b];if(null==d){for(var d=[],e=0;e<=Box2D.Dynamics.b2BodyList.TYPES.allBodies;e++)d[e]=
null;this.bodyNodeLookup[b]=d}null==d[c]&&(d[c]=new Box2D.Dynamics.b2BodyListNode(a),a=this.bodyLastNodes[c],null!=a?a.SetNextNode(d[c]):this.bodyFirstNodes[c]=d[c],d[c].SetPreviousNode(a),this.bodyLastNodes[c]=d[c])};Box2D.Dynamics.b2BodyList.prototype.GetBodyCount=function(){return this.bodyCount};Box2D.Dynamics.b2BodyList.TYPES={dynamicBodies:0,nonStaticBodies:1,activeBodies:2,nonStaticActiveAwakeBodies:3,awakeBodies:4,allBodies:5};Box2D.Dynamics.b2BodyListNode=function(a){this.body=a;this.previous=
this.next=null};Box2D.Dynamics.b2BodyListNode.prototype.SetNextNode=function(a){this.next=a};Box2D.Dynamics.b2BodyListNode.prototype.SetPreviousNode=function(a){this.previous=a};Box2D.Dynamics.b2BodyListNode.prototype.GetBody=function(){return this.body};Box2D.Dynamics.b2BodyListNode.prototype.GetNextNode=function(){return this.next};Box2D.Dynamics.b2BodyListNode.prototype.GetPreviousNode=function(){return this.previous};Box2D.Dynamics.b2ContactFilter=function(){};Box2D.Dynamics.b2ContactFilter.prototype.ShouldCollide=
function(a,b){var c=a.GetFilterData(),d=b.GetFilterData();return c.groupIndex==d.groupIndex&&0!=c.groupIndex?0<c.groupIndex:0!=(c.maskBits&d.categoryBits)&&0!=(c.categoryBits&d.maskBits)};Box2D.Dynamics.b2ContactFilter.b2_defaultFilter=new Box2D.Dynamics.b2ContactFilter;Box2D.Dynamics.b2ContactImpulse=function(){this.normalImpulses=[];this.tangentImpulses=[]};Box2D.Dynamics.b2ContactListener=function(){};Box2D.Dynamics.b2ContactListener.prototype.BeginContact=function(a){};Box2D.Dynamics.b2ContactListener.prototype.EndContact=
function(a){};Box2D.Dynamics.b2ContactListener.prototype.PreSolve=function(a,b){};Box2D.Dynamics.b2ContactListener.prototype.PostSolve=function(a,b){};Box2D.Dynamics.b2ContactManager=function(a){this.m_world=a;this.m_contactFilter=Box2D.Dynamics.b2ContactFilter.b2_defaultFilter;this.m_contactListener=Box2D.Dynamics.b2ContactListener.b2_defaultListener;this.m_contactFactory=new Box2D.Dynamics.Contacts.b2ContactFactory;this.m_broadPhase=new Box2D.Collision.b2DynamicTreeBroadPhase};Box2D.Dynamics.b2ContactManager.prototype.AddPair=
function(a,b){var c=a.GetBody(),d=b.GetBody();if(c!=d&&d.ShouldCollide(c)&&this.m_contactFilter.ShouldCollide(a,b)){for(c=d.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);c;c=c.GetNextNode())if(d=c.contact.m_fixtureA,d==a){if(d=c.contact.m_fixtureB,d==b)return}else if(d==b&&(d=c.contact.m_fixtureB,d==a))return;this.m_contactFactory.Create(a,b)}};Box2D.Dynamics.b2ContactManager.prototype.FindNewContacts=function(){var a=this;this.m_broadPhase.UpdatePairs(function(b,
c){a.AddPair(b,c)})};Box2D.Dynamics.b2ContactManager.prototype.Destroy=function(a){var b=a.m_fixtureB;a.m_fixtureA.GetBody();b.GetBody();a.touching&&this.m_contactListener.EndContact(a);0<a.m_manifold.m_pointCount&&(a.m_fixtureA.GetBody().SetAwake(!0),a.m_fixtureB.GetBody().SetAwake(!0));a.RemoveFromLists();this.m_contactFactory.Destroy(a)};Box2D.Dynamics.b2ContactManager.prototype.Collide=function(){for(var a=this.m_world.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=
a.GetNextNode()){var b=a.contact,c=b.m_fixtureA,d=b.m_fixtureB,e=c.GetBody(),f=d.GetBody();if(!1!=e.IsAwake()||!1!=f.IsAwake()){if(b.IsFiltering()){if(!1==f.ShouldCollide(e)){this.Destroy(b);continue}if(!1==this.m_contactFilter.ShouldCollide(c,d)){this.Destroy(b);continue}b.ClearFiltering()}!1==this.m_broadPhase.TestOverlap(c.m_proxy,d.m_proxy)?this.Destroy(b):b.Update(this.m_contactListener)}}};Box2D.Dynamics.b2DestructionListener=function(){};Box2D.Dynamics.b2DestructionListener.prototype.SayGoodbyeJoint=
function(a){};Box2D.Dynamics.b2DestructionListener.prototype.SayGoodbyeFixture=function(a){};Box2D.Dynamics.b2FilterData=function(){this.categoryBits=1;this.maskBits=65535;this.groupIndex=0};Box2D.Dynamics.b2FilterData.prototype.Copy=function(){var a=new Box2D.Dynamics.b2FilterData;a.categoryBits=this.categoryBits;a.maskBits=this.maskBits;a.groupIndex=this.groupIndex;return a};Box2D.Dynamics.b2Fixture=function(a,b,c){this.ID="Fixture"+Box2D.Dynamics.b2Fixture.NEXT_ID++;this.m_filter=c.filter.Copy();
this.m_aabb=Box2D.Collision.b2AABB.Get();this.m_body=a;this.m_shape=c.shape.Copy();this.m_density=c.density;this.m_friction=c.friction;this.m_restitution=c.restitution;this.m_isSensor=c.isSensor};Box2D.Dynamics.b2Fixture.prototype.GetShape=function(){return this.m_shape};Box2D.Dynamics.b2Fixture.prototype.SetSensor=function(a){if(this.m_isSensor!=a&&(this.m_isSensor=a,null!=this.m_body))for(a=this.m_body.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=a.GetNextNode()){var b=
a.contact.m_fixtureA,c=a.contact.m_fixtureB;b!=this&&c!=this||a.contact.SetSensor(b.sensor||c.sensor)}};Box2D.Dynamics.b2Fixture.prototype.IsSensor=function(){return this.m_isSensor};Box2D.Dynamics.b2Fixture.prototype.SetFilterData=function(a){this.m_filter=a.Copy();if(null!=this.m_body)for(a=this.m_body.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=a.GetNextNode())a.contact.m_fixtureA!=this&&a.contact.m_fixtureB!=this||a.contact.FlagForFiltering()};Box2D.Dynamics.b2Fixture.prototype.GetFilterData=
function(){return this.m_filter.Copy()};Box2D.Dynamics.b2Fixture.prototype.GetBody=function(){return this.m_body};Box2D.Dynamics.b2Fixture.prototype.TestPoint=function(a){return this.m_shape.TestPoint(this.m_body.GetTransform(),a)};Box2D.Dynamics.b2Fixture.prototype.RayCast=function(a,b){return this.m_shape.RayCast(a,b,this.m_body.GetTransform())};Box2D.Dynamics.b2Fixture.prototype.GetMassData=function(a){a||(a=new Box2D.Collision.Shapes.b2MassData);this.m_shape.ComputeMass(a,this.m_density);return a};
Box2D.Dynamics.b2Fixture.prototype.SetDensity=function(a){this.m_density=a};Box2D.Dynamics.b2Fixture.prototype.GetDensity=function(){return this.m_density};Box2D.Dynamics.b2Fixture.prototype.GetFriction=function(){return this.m_friction};Box2D.Dynamics.b2Fixture.prototype.SetFriction=function(a){this.m_friction=a};Box2D.Dynamics.b2Fixture.prototype.GetRestitution=function(){return this.m_restitution};Box2D.Dynamics.b2Fixture.prototype.SetRestitution=function(a){this.m_restitution=a};Box2D.Dynamics.b2Fixture.prototype.GetAABB=
function(){return this.m_aabb};Box2D.Dynamics.b2Fixture.prototype.Destroy=function(){Box2D.Collision.b2AABB.Free(this.m_aabb)};Box2D.Dynamics.b2Fixture.prototype.CreateProxy=function(a,b){this.m_shape.ComputeAABB(this.m_aabb,b);this.m_proxy=a.CreateProxy(this.m_aabb,this)};Box2D.Dynamics.b2Fixture.prototype.DestroyProxy=function(a){null!=this.m_proxy&&(a.DestroyProxy(this.m_proxy),this.m_proxy=null)};Box2D.Dynamics.b2Fixture.prototype.Synchronize=function(a,b,c){if(this.m_proxy){var d=Box2D.Collision.b2AABB.Get(),
e=Box2D.Collision.b2AABB.Get();this.m_shape.ComputeAABB(d,b);this.m_shape.ComputeAABB(e,c);this.m_aabb.Combine(d,e);Box2D.Collision.b2AABB.Free(d);Box2D.Collision.b2AABB.Free(e);b=Box2D.Common.Math.b2Math.SubtractVV(c.position,b.position);a.MoveProxy(this.m_proxy,this.m_aabb,b);Box2D.Common.Math.b2Vec2.Free(b)}};Box2D.Dynamics.b2Fixture.NEXT_ID=0;Box2D.Dynamics.b2FixtureDef=function(){this.filter=new Box2D.Dynamics.b2FilterData;this.filter.categoryBits=1;this.filter.maskBits=65535;this.filter.groupIndex=
0;this.shape=null;this.friction=0.2;this.density=this.restitution=0;this.isSensor=!1};Box2D.Dynamics.b2FixtureList=function(){this.fixtureLastNode=this.fixtureFirstNode=null;this.fixtureNodeLookup={};this.fixtureCount=0};Box2D.Dynamics.b2FixtureList.prototype.GetFirstNode=function(){return this.fixtureFirstNode};Box2D.Dynamics.b2FixtureList.prototype.AddFixture=function(a){var b=a.ID;if(null==this.fixtureNodeLookup[b]){a=new Box2D.Dynamics.b2FixtureListNode(a);var c=this.fixtureLastNode;null!=c?c.SetNextNode(a):
this.fixtureFirstNode=a;a.SetPreviousNode(c);this.fixtureLastNode=a;this.fixtureNodeLookup[b]=a;this.fixtureCount++}};Box2D.Dynamics.b2FixtureList.prototype.RemoveFixture=function(a){a=a.ID;var b=this.fixtureNodeLookup[a];if(null!=b){var c=b.GetPreviousNode(),b=b.GetNextNode();null==c?this.fixtureFirstNode=b:c.SetNextNode(b);null==b?this.fixtureLastNode=c:b.SetPreviousNode(c);delete this.fixtureNodeLookup[a];this.fixtureCount--}};Box2D.Dynamics.b2FixtureList.prototype.GetFixtureCount=function(){return this.fixtureCount};
Box2D.Dynamics.b2FixtureListNode=function(a){this.fixture=a;this.previous=this.next=null};Box2D.Dynamics.b2FixtureListNode.prototype.SetNextNode=function(a){this.next=a};Box2D.Dynamics.b2FixtureListNode.prototype.SetPreviousNode=function(a){this.previous=a};Box2D.Dynamics.b2FixtureListNode.prototype.GetNextNode=function(){return this.next};Box2D.Dynamics.b2FixtureListNode.prototype.GetPreviousNode=function(){return this.previous};Box2D.Dynamics.b2Island=function(a,b){this.m_listener=a;this.m_contactSolver=
b;this.m_bodies=[];this.m_dynamicBodies=[];this.m_nonStaticBodies=[];this.m_contacts=[];this.m_joints=[]};Box2D.Dynamics.b2Island.prototype.Clear=function(){this.m_bodies=[];this.m_dynamicBodies=[];this.m_nonStaticBodies=[];this.m_contacts=[];this.m_joints=[]};Box2D.Dynamics.b2Island.prototype.Solve=function(a,b,c){this._InitializeVelocities(a,b);this.m_contactSolver.Initialize(a,this.m_contacts,this.m_contacts.length);this._SolveVelocityConstraints(a);this._SolveBodies(a);this._SolvePositionConstraints(a);
this.Report(this.m_contactSolver.m_constraints);c&&this._SleepIfTired(a)};Box2D.Dynamics.b2Island.prototype._InitializeVelocities=function(a,b){for(var c=0;c<this.m_dynamicBodies.length;c++){var d=this.m_dynamicBodies[c];d.m_linearVelocity.x+=a.dt*(b.x+d.m_invMass*d.m_force.x);d.m_linearVelocity.y+=a.dt*(b.y+d.m_invMass*d.m_force.y);d.m_angularVelocity+=a.dt*d.m_invI*d.m_torque;d.m_linearVelocity.Multiply(Box2D.Common.Math.b2Math.Clamp(1-a.dt*d.m_linearDamping,0,1));d.m_angularVelocity*=Box2D.Common.Math.b2Math.Clamp(1-
a.dt*d.m_angularDamping,0,1)}};Box2D.Dynamics.b2Island.prototype._SolveVelocityConstraints=function(a){this.m_contactSolver.InitVelocityConstraints(a);for(var b=0;b<this.m_joints.length;b++)this.m_joints[b].InitVelocityConstraints(a);for(b=0;b<a.velocityIterations;b++){for(var c=0;c<this.m_joints.length;c++)this.m_joints[c].SolveVelocityConstraints(a);this.m_contactSolver.SolveVelocityConstraints()}for(a=0;a<this.m_joints.length;a++)this.m_joints[a].FinalizeVelocityConstraints();this.m_contactSolver.FinalizeVelocityConstraints()};
Box2D.Dynamics.b2Island.prototype._SolveBodies=function(a){for(var b=0;b<this.m_nonStaticBodies.length;++b){var c=this.m_nonStaticBodies[b],d=a.dt*c.m_linearVelocity.x,e=a.dt*c.m_linearVelocity.y;d*d+e*e>Box2D.Common.b2Settings.b2_maxTranslationSquared&&(c.m_linearVelocity.Normalize(),c.m_linearVelocity.x=c.m_linearVelocity.x*Box2D.Common.b2Settings.b2_maxTranslation*a.inv_dt,c.m_linearVelocity.y=c.m_linearVelocity.y*Box2D.Common.b2Settings.b2_maxTranslation*a.inv_dt);d=a.dt*c.m_angularVelocity;d*
d>Box2D.Common.b2Settings.b2_maxRotationSquared&&(c.m_angularVelocity=0>c.m_angularVelocity?-Box2D.Common.b2Settings.b2_maxRotation*a.inv_dt:Box2D.Common.b2Settings.b2_maxRotation*a.inv_dt);c.m_sweep.c0.SetV(c.m_sweep.c);c.m_sweep.a0=c.m_sweep.a;c.m_sweep.c.x+=a.dt*c.m_linearVelocity.x;c.m_sweep.c.y+=a.dt*c.m_linearVelocity.y;c.m_sweep.a+=a.dt*c.m_angularVelocity;c.SynchronizeTransform()}};Box2D.Dynamics.b2Island.prototype._SolvePositionConstraints=function(a){for(var b=0;b<a.positionIterations;b++){for(var c=
this.m_contactSolver.SolvePositionConstraints(Box2D.Common.b2Settings.b2_contactBaumgarte),d=!0,e=0;e<this.m_joints.length;e++)var f=this.m_joints[e].SolvePositionConstraints(Box2D.Common.b2Settings.b2_contactBaumgarte),d=d&&f;if(c&&d)break}};Box2D.Dynamics.b2Island.prototype._SleepIfTired=function(a){for(var b=Number.MAX_VALUE,c=0;c<this.m_nonStaticBodies.length;c++){var d=this.m_nonStaticBodies[c];!d.m_allowSleep||Math.abs(d.m_angularVelocity)>Box2D.Common.b2Settings.b2_angularSleepTolerance||Box2D.Common.Math.b2Math.Dot(d.m_linearVelocity,
d.m_linearVelocity)>Box2D.Common.b2Settings.b2_linearSleepToleranceSquared?b=d.m_sleepTime=0:(d.m_sleepTime+=a.dt,b=Math.min(b,d.m_sleepTime))}if(b>=Box2D.Common.b2Settings.b2_timeToSleep)for(a=0;a<this.m_bodies.length;a++)this.m_bodies[a].SetAwake(!1)};Box2D.Dynamics.b2Island.prototype.SolveTOI=function(a){var b=0,c=0;this.m_contactSolver.Initialize(a,this.m_contacts,this.m_contacts.length);for(var d=this.m_contactSolver,b=0;b<this.m_joints.length;++b)this.m_joints[b].InitVelocityConstraints(a);
for(b=0;b<a.velocityIterations;++b)for(d.SolveVelocityConstraints(),c=0;c<this.m_joints.length;++c)this.m_joints[c].SolveVelocityConstraints(a);for(b=0;b<this.m_nonStaticBodies.length;++b){var c=this.m_nonStaticBodies[b],e=a.dt*c.m_linearVelocity.x,f=a.dt*c.m_linearVelocity.y;e*e+f*f>Box2D.Common.b2Settings.b2_maxTranslationSquared&&(c.m_linearVelocity.Normalize(),c.m_linearVelocity.x=c.m_linearVelocity.x*Box2D.Common.b2Settings.b2_maxTranslation*a.inv_dt,c.m_linearVelocity.y=c.m_linearVelocity.y*
Box2D.Common.b2Settings.b2_maxTranslation*a.inv_dt);e=a.dt*c.m_angularVelocity;e*e>Box2D.Common.b2Settings.b2_maxRotationSquared&&(c.m_angularVelocity=0>c.m_angularVelocity?-Box2D.Common.b2Settings.b2_maxRotation*a.inv_dt:Box2D.Common.b2Settings.b2_maxRotation*a.inv_dt);c.m_sweep.c0.SetV(c.m_sweep.c);c.m_sweep.a0=c.m_sweep.a;c.m_sweep.c.x+=a.dt*c.m_linearVelocity.x;c.m_sweep.c.y+=a.dt*c.m_linearVelocity.y;c.m_sweep.a+=a.dt*c.m_angularVelocity;c.SynchronizeTransform()}for(b=0;b<a.positionIterations;++b){e=
d.SolvePositionConstraints(0.75);f=!0;for(c=0;c<this.m_joints.length;++c)var g=this.m_joints[c].SolvePositionConstraints(Box2D.Common.b2Settings.b2_contactBaumgarte),f=f&&g;if(e&&f)break}this.Report(d.m_constraints)};Box2D.Dynamics.b2Island.prototype.Report=function(a){if(null!=this.m_listener)for(var b=0;b<this.m_contacts.length;++b){for(var c=this.m_contacts[b],d=a[b],e=new Box2D.Dynamics.b2ContactImpulse,f=0;f<d.pointCount;++f)e.normalImpulses[f]=d.points[f].normalImpulse,e.tangentImpulses[f]=
d.points[f].tangentImpulse;this.m_listener.PostSolve(c,e)}};Box2D.Dynamics.b2Island.prototype.AddBody=function(a){this.m_bodies.push(a);a.GetType()!=Box2D.Dynamics.b2BodyDef.b2_staticBody&&(this.m_nonStaticBodies.push(a),a.GetType()==Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&this.m_dynamicBodies.push(a))};Box2D.Dynamics.b2Island.prototype.AddContact=function(a){this.m_contacts.push(a)};Box2D.Dynamics.b2Island.prototype.AddJoint=function(a){this.m_joints.push(a)};Box2D.Dynamics.b2TimeStep=function(a,
b,c,d,e){this.dt=a;var f=0;0<a&&(f=1/a);this.inv_dt=f;this.dtRatio=b;this.positionIterations=c;this.velocityIterations=d;this.warmStarting=e};Box2D.Dynamics.b2World=function(a,b){this.m_contactManager=new Box2D.Dynamics.b2ContactManager(this);this.m_contactSolver=new Box2D.Dynamics.Contacts.b2ContactSolver;this.m_newFixture=this.m_isLocked=!1;this.m_destructionListener=null;this.bodyList=new Box2D.Dynamics.b2BodyList;this.contactList=new Box2D.Dynamics.Contacts.b2ContactList;this.m_jointList=null;
this.controllerList=new Box2D.Dynamics.Controllers.b2ControllerList;this.m_jointCount=0;this.m_continuousPhysics=this.m_warmStarting=!0;this.m_allowSleep=b;this.m_gravity=a;this.m_inv_dt0=0;this.m_groundBody=this.CreateBody(new Box2D.Dynamics.b2BodyDef)};Box2D.Dynamics.b2World.MAX_TOI=1-100*Number.MIN_VALUE;Box2D.Dynamics.b2World.prototype.SetDestructionListener=function(a){this.m_destructionListener=a};Box2D.Dynamics.b2World.prototype.SetContactFilter=function(a){this.m_contactManager.m_contactFilter=
a};Box2D.Dynamics.b2World.prototype.SetContactListener=function(a){this.m_contactManager.m_contactListener=a};Box2D.Dynamics.b2World.prototype.SetBroadPhase=function(a){var b=this.m_contactManager.m_broadPhase;this.m_contactManager.m_broadPhase=a;for(var c=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);c;c=c.GetNextNode())for(var d=c.body.GetFixtureList().GetFirstNode();d;d=d.GetNextNode()){var e=d.fixture;e.m_proxy=a.CreateProxy(b.GetFatAABB(e.m_proxy),e)}};Box2D.Dynamics.b2World.prototype.GetProxyCount=
function(){return this.m_contactManager.m_broadPhase.GetProxyCount()};Box2D.Dynamics.b2World.prototype.CreateBody=function(a){a=new Box2D.Dynamics.b2Body(a,this);this.bodyList.AddBody(a);return a};Box2D.Dynamics.b2World.prototype.DestroyBody=function(a){for(var b=a.m_jointList;b;){var c=b,b=b.next;this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(c.joint);this.DestroyJoint(c.joint)}for(b=a.GetControllerList().GetFirstNode();b;b=b.GetNextNode())b.controller.RemoveBody(a);for(b=
a.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);b;b=b.GetNextNode())this.m_contactManager.Destroy(b.contact);for(b=a.GetFixtureList().GetFirstNode();b;b=b.GetNextNode())this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(b.fixture),a.DestroyFixture(b.fixture);a.Destroy();this.bodyList.RemoveBody(a)};Box2D.Dynamics.b2World.prototype.CreateJoint=function(a){var b=Box2D.Dynamics.Joints.b2Joint.Create(a);b.m_prev=null;if(b.m_next=this.m_jointList)this.m_jointList.m_prev=
b;this.m_jointList=b;this.m_jointCount++;b.m_edgeA.joint=b;b.m_edgeA.other=b.m_bodyB;b.m_edgeA.prev=null;if(b.m_edgeA.next=b.m_bodyA.m_jointList)b.m_bodyA.m_jointList.prev=b.m_edgeA;b.m_bodyA.m_jointList=b.m_edgeA;b.m_edgeB.joint=b;b.m_edgeB.other=b.m_bodyA;b.m_edgeB.prev=null;if(b.m_edgeB.next=b.m_bodyB.m_jointList)b.m_bodyB.m_jointList.prev=b.m_edgeB;b.m_bodyB.m_jointList=b.m_edgeB;var c=a.bodyA,d=a.bodyB;if(!a.collideConnected)for(a=d.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=
a.GetNextNode())a.contact.GetOther(d)==c&&a.contact.FlagForFiltering();return b};Box2D.Dynamics.b2World.prototype.DestroyJoint=function(a){var b=a.m_collideConnected;a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a==this.m_jointList&&(this.m_jointList=a.m_next);var c=a.m_bodyA,d=a.m_bodyB;c.SetAwake(!0);d.SetAwake(!0);a.m_edgeA.prev&&(a.m_edgeA.prev.next=a.m_edgeA.next);a.m_edgeA.next&&(a.m_edgeA.next.prev=a.m_edgeA.prev);a.m_edgeA==c.m_jointList&&(c.m_jointList=a.m_edgeA.next);
a.m_edgeA.prev=null;a.m_edgeA.next=null;a.m_edgeB.prev&&(a.m_edgeB.prev.next=a.m_edgeB.next);a.m_edgeB.next&&(a.m_edgeB.next.prev=a.m_edgeB.prev);a.m_edgeB==d.m_jointList&&(d.m_jointList=a.m_edgeB.next);a.m_edgeB.prev=null;a.m_edgeB.next=null;this.m_jointCount--;if(!b)for(a=d.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);a;a=a.GetNextNode())a.contact.GetOther(d)==c&&a.contact.FlagForFiltering()};Box2D.Dynamics.b2World.prototype.GetControllerList=function(){return this.controllerList};
Box2D.Dynamics.b2World.prototype.AddController=function(a){if(null!==a.m_world&&a.m_world!=this)throw Error("Controller can only be a member of one world");this.controllerList.AddController(a);a.m_world=this;return a};Box2D.Dynamics.b2World.prototype.RemoveController=function(a){this.controllerList.RemoveController(a);a.m_world=null;a.Clear()};Box2D.Dynamics.b2World.prototype.CreateController=function(a){return this.AddController(a)};Box2D.Dynamics.b2World.prototype.DestroyController=function(a){this.RemoveController(a)};
Box2D.Dynamics.b2World.prototype.SetWarmStarting=function(a){this.m_warmStarting=a};Box2D.Dynamics.b2World.prototype.SetContinuousPhysics=function(a){this.m_continuousPhysics=a};Box2D.Dynamics.b2World.prototype.GetBodyCount=function(){return this.bodyList.GetBodyCount()};Box2D.Dynamics.b2World.prototype.GetJointCount=function(){return this.m_jointCount};Box2D.Dynamics.b2World.prototype.GetContactCount=function(){return this.contactList.GetContactCount()};Box2D.Dynamics.b2World.prototype.SetGravity=
function(a){this.m_gravity=a};Box2D.Dynamics.b2World.prototype.GetGravity=function(){return this.m_gravity};Box2D.Dynamics.b2World.prototype.GetGroundBody=function(){return this.m_groundBody};Box2D.Dynamics.b2World.prototype.Step=function(a,b,c){this.m_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_newFixture=!1);this.m_isLocked=!0;a=new Box2D.Dynamics.b2TimeStep(a,this.m_inv_dt0*a,b,c,this.m_warmStarting);this.m_contactManager.Collide();0<a.dt&&(this.Solve(a),this.m_continuousPhysics&&
this.SolveTOI(a),this.m_inv_dt0=a.inv_dt);this.m_isLocked=!1};Box2D.Dynamics.b2World.prototype.ClearForces=function(){for(var a=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.dynamicBodies);a;a=a.GetNextNode())a.body.m_force.SetZero(),a.body.m_torque=0};Box2D.Dynamics.b2World.prototype.QueryAABB=function(a,b){this.m_contactManager.m_broadPhase.Query(a,b)};Box2D.Dynamics.b2World.prototype.QueryPoint=function(a,b){var c=Box2D.Collision.b2AABB.Get();c.lowerBound_.Set(b.x-Box2D.Common.b2Settings.b2_linearSlop,
b.y-Box2D.Common.b2Settings.b2_linearSlop);c.upperBound_.Set(b.x+Box2D.Common.b2Settings.b2_linearSlop,b.y+Box2D.Common.b2Settings.b2_linearSlop);this.m_contactManager.m_broadPhase.Query(function(c){return c.TestPoint(b)?a(c):!0},c);Box2D.Collision.b2AABB.Free(c)};Box2D.Dynamics.b2World.prototype.RayCast=function(a,b,c){var d=this.m_contactManager.m_broadPhase,e=new Box2D.Collision.b2RayCastOutput,f=new Box2D.Collision.b2RayCastInput(b,c,1);d.RayCast(function(d,f){if(f.RayCast(e,d)){var l=1-e.fraction,
l=Box2D.Common.Math.b2Vec2.Get(l*b.x+e.fraction*c.x,l*b.y+e.fraction*c.y),k=a(f,l,e.normal,e.fraction);Box2D.Common.Math.b2Vec2.Free(l);return k}return d.maxFraction},f)};Box2D.Dynamics.b2World.prototype.RayCastOne=function(a,b){var c=null;this.RayCast(function(a,b,f,g){c=a;return g},a,b);return c};Box2D.Dynamics.b2World.prototype.RayCastAll=function(a,b){var c=[];this.RayCast(function(a,b,f,g){c.push(a);return 1},a,b);return c};Box2D.Dynamics.b2World.prototype.GetBodyList=function(){return this.bodyList};
Box2D.Dynamics.b2World.prototype.GetJointList=function(){return this.m_jointList};Box2D.Dynamics.b2World.prototype.GetContactList=function(){return this.contactList};Box2D.Dynamics.b2World.prototype.IsLocked=function(){return this.m_isLocked};var b2solvearray=[];Box2D.Dynamics.b2World.prototype.Solve=function(a){for(var b=this.controllerList.GetFirstNode();b;b=b.GetNextNode())b.controller.Step(a);for(var b=new Box2D.Dynamics.b2Island(this.m_contactManager.m_contactListener,this.m_contactSolver),c=
this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);c;c=c.GetNextNode())c.body.m_islandFlag=!1;for(var d=this.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);d;d=d.GetNextNode())d.contact.m_islandFlag=!1;for(c=this.m_jointList;c;c=c.m_next)c.m_islandFlag=!1;for(c=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.nonStaticActiveAwakeBodies);c;c=c.GetNextNode())if(d=c.body,!d.m_islandFlag){b.Clear();b2solvearray.length=0;var e=b2solvearray;
e.push(d);for(d.m_islandFlag=!0;0<e.length;){var f=e.pop();b.AddBody(f);f.IsAwake()||f.SetAwake(!0);if(f.GetType()!=Box2D.Dynamics.b2BodyDef.b2_staticBody){for(d=f.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledTouchingContacts);d;d=d.GetNextNode()){var g=d.contact;g.m_islandFlag||(b.AddContact(g),g.m_islandFlag=!0,g=g.GetOther(f),g.m_islandFlag||(e.push(g),g.m_islandFlag=!0))}for(d=f.m_jointList;d;d=d.next)!d.joint.m_islandFlag&&d.other.IsActive()&&(b.AddJoint(d.joint),
d.joint.m_islandFlag=!0,d.other.m_islandFlag||(e.push(d.other),d.other.m_islandFlag=!0))}}b.Solve(a,this.m_gravity,this.m_allowSleep)}for(c=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.nonStaticActiveAwakeBodies);c;c=c.GetNextNode())c.body.SynchronizeFixtures();this.m_contactManager.FindNewContacts()};Box2D.Dynamics.b2World.prototype.SolveTOI=function(a){for(var b=new Box2D.Dynamics.b2Island(this.m_contactManager.m_contactListener,this.m_contactSolver),c=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);c;c=
c.GetNextNode()){var d=c.body;d.m_islandFlag=!1;d.m_sweep.t0=0}for(var e=this.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);e;e=e.GetNextNode())e.contact.m_islandFlag=!1,e.contact.m_toi=null;for(c=this.m_jointList;c;c=c.m_next)c.m_islandFlag=!1;for(;;){var c=this._SolveTOI2(a),f=c.minContact,c=c.minTOI;if(null===f||Box2D.Dynamics.b2World.MAX_TOI<c)break;e=f.m_fixtureA.GetBody();d=f.m_fixtureB.GetBody();Box2D.Dynamics.b2World.s_backupA.Set(e.m_sweep);Box2D.Dynamics.b2World.s_backupB.Set(d.m_sweep);
e.Advance(c);d.Advance(c);f.Update(this.m_contactManager.m_contactListener);f.m_toi=null;if(f.sensor||!f.enabled)e.m_sweep.Set(Box2D.Dynamics.b2World.s_backupA),d.m_sweep.Set(Box2D.Dynamics.b2World.s_backupB),e.SynchronizeTransform(),d.SynchronizeTransform();else if(f.touching){e.GetType()!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&(e=d);b.Clear();b2solvearray.length=0;f=b2solvearray;f.push(e);for(e.m_islandFlag=!0;0<f.length;)if(d=f.pop(),b.AddBody(d),d.IsAwake()||d.SetAwake(!0),d.GetType()==Box2D.Dynamics.b2BodyDef.b2_dynamicBody){for(e=
d.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledTouchingContacts);e&&b.m_contactCount!=Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland;e=e.GetNextNode()){var g=e.contact;g.m_islandFlag||(b.AddContact(g),g.m_islandFlag=!0,g=g.GetOther(d),g.m_islandFlag||(g.GetType()!=Box2D.Dynamics.b2BodyDef.b2_staticBody&&(g.Advance(c),g.SetAwake(!0),f.push(g)),g.m_islandFlag=!0))}for(d=d.m_jointList;d;d=d.next)b.m_jointCount!=Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland&&
!d.joint.m_islandFlag&&d.other.IsActive()&&(b.AddJoint(d.joint),d.joint.m_islandFlag=!0,d.other.m_islandFlag||(d.other.GetType()!=Box2D.Dynamics.b2BodyDef.b2_staticBody&&(d.other.Advance(c),d.other.SetAwake(!0),f.push(d.other)),d.other.m_islandFlag=!0))}b.SolveTOI(new Box2D.Dynamics.b2TimeStep((1-c)*a.dt,0,a.velocityIterations,a.positionIterations,!1));for(c=0;c<b.m_bodies.length;c++)if(b.m_bodies[c].m_islandFlag=!1,b.m_bodies[c].IsAwake()&&b.m_bodies[c].GetType()==Box2D.Dynamics.b2BodyDef.b2_dynamicBody)for(b.m_bodies[c].SynchronizeFixtures(),
e=b.m_bodies[c].contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);e;e=e.GetNextNode())e.contact.m_toi=null;for(c=0;c<b.m_contactCount;c++)b.m_contacts[c].m_islandFlag=!1,b.m_contacts[c].m_toi=null;for(c=0;c<b.m_jointCount;c++)b.m_joints[c].m_islandFlag=!1;this.m_contactManager.FindNewContacts()}}};Box2D.Dynamics.b2World.prototype._SolveTOI2=function(a){for(var b=null,c=1,d=this.contactList.GetFirstNode(Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledContinuousContacts);d;d=
d.GetNextNode()){var e=d.contact;if(!this._SolveTOI2SkipContact(a,e)){var f=1;if(null!=e.m_toi)f=e.m_toi;else{if(e.touching)f=1;else{var f=e.m_fixtureA.GetBody(),g=e.m_fixtureB.GetBody(),h=f.m_sweep.t0;f.m_sweep.t0<g.m_sweep.t0?(h=g.m_sweep.t0,f.m_sweep.Advance(h)):g.m_sweep.t0<f.m_sweep.t0&&(h=f.m_sweep.t0,g.m_sweep.Advance(h));f=e.ComputeTOI(f.m_sweep,g.m_sweep);0<f&&1>f&&(f=(1-f)*h+f)}e.m_toi=f}Number.MIN_VALUE<f&&f<c&&(b=e,c=f)}}return{minContact:b,minTOI:c}};Box2D.Dynamics.b2World.prototype._SolveTOI2SkipContact=
function(a,b){var c=b.m_fixtureA.GetBody(),d=b.m_fixtureB.GetBody();return c.GetType()==Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&c.IsAwake()||d.GetType()==Box2D.Dynamics.b2BodyDef.b2_dynamicBody&&d.IsAwake()?!1:!0};Box2D.Dynamics.Contacts.b2Contact=function(a,b){this.ID="Contact"+Box2D.Dynamics.Contacts.b2Contact.NEXT_ID++;this.m_manifold=new Box2D.Collision.b2Manifold;this.m_oldManifold=new Box2D.Collision.b2Manifold;this.touching=!1;var c=a.GetBody(),d=b.GetBody();this.continuous=c.GetType()!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody||
c.IsBullet()||d.GetType()!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody||d.IsBullet();this.sensor=a.IsSensor()||b.IsSensor();this.filtering=!1;this.m_fixtureA=a;this.m_fixtureB=b;this.enabled=!0;this.bodyAList=c.GetContactList();this.bodyBList=d.GetContactList();this.worldList=d.GetWorld().GetContactList();this.AddToLists()};Box2D.Dynamics.Contacts.b2Contact.prototype.Reset=function(a,b){this.m_manifold.Reset();this.m_oldManifold.Reset();this.touching=!1;var c=a.GetBody(),d=b.GetBody();this.continuous=
c.GetType()!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody||c.IsBullet()||d.GetType()!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody||d.IsBullet();this.sensor=a.IsSensor()||b.IsSensor();this.filtering=!1;this.m_fixtureA=a;this.m_fixtureB=b;this.enabled=!0;this.bodyAList=c.GetContactList();this.bodyBList=d.GetContactList();this.worldList=d.GetWorld().GetContactList();this.AddToLists()};Box2D.Dynamics.Contacts.b2Contact.prototype.AddToLists=function(){this.bodyAList.AddContact(this);this.bodyBList.AddContact(this);
this.worldList.AddContact(this);this.UpdateLists()};Box2D.Dynamics.Contacts.b2Contact.prototype.UpdateLists=function(){var a=!1,b=!1;!this.IsSensor()&&this.IsEnabled()&&(this.IsTouching()&&(a=!0),this.IsContinuous()&&(b=!0));this.bodyAList.UpdateContact(this,a,b);this.bodyBList.UpdateContact(this,a,b);this.worldList.UpdateContact(this,a,b)};Box2D.Dynamics.Contacts.b2Contact.prototype.RemoveFromLists=function(){this.bodyAList.RemoveContact(this);this.bodyBList.RemoveContact(this);this.worldList.RemoveContact(this)};
Box2D.Dynamics.Contacts.b2Contact.prototype.GetManifold=function(){return this.m_manifold};Box2D.Dynamics.Contacts.b2Contact.prototype.GetWorldManifold=function(a){var b=this.m_fixtureA.GetBody(),c=this.m_fixtureB.GetBody(),d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();a.Initialize(this.m_manifold,b.GetTransform(),d.m_radius,c.GetTransform(),e.m_radius)};Box2D.Dynamics.Contacts.b2Contact.prototype.IsTouching=function(){return this.touching};Box2D.Dynamics.Contacts.b2Contact.prototype.IsContinuous=
function(){return this.continuous};Box2D.Dynamics.Contacts.b2Contact.prototype.SetSensor=function(a){this.sensor=a;this.UpdateLists()};Box2D.Dynamics.Contacts.b2Contact.prototype.IsSensor=function(){return this.sensor};Box2D.Dynamics.Contacts.b2Contact.prototype.SetEnabled=function(a){this.enabled=a;this.UpdateLists()};Box2D.Dynamics.Contacts.b2Contact.prototype.IsEnabled=function(){return this.enabled};Box2D.Dynamics.Contacts.b2Contact.prototype.GetNext=function(){return this.m_next};Box2D.Dynamics.Contacts.b2Contact.prototype.GetFixtureA=
function(){return this.m_fixtureA};Box2D.Dynamics.Contacts.b2Contact.prototype.GetFixtureB=function(){return this.m_fixtureB};Box2D.Dynamics.Contacts.b2Contact.prototype.GetOther=function(a){var b=this.m_fixtureA.GetBody();return b!=a?b:this.m_fixtureB.GetBody()};Box2D.Dynamics.Contacts.b2Contact.prototype.FlagForFiltering=function(){this.filtering=!0};Box2D.Dynamics.Contacts.b2Contact.prototype.ClearFiltering=function(){this.filtering=!1};Box2D.Dynamics.Contacts.b2Contact.prototype.IsFiltering=function(){return this.filtering};
Box2D.Dynamics.Contacts.b2Contact.prototype.Update=function(a){var b=this.m_oldManifold;this.m_oldManifold=this.m_manifold;this.m_manifold=b;this.enabled=!0;var b=!1,c=this.IsTouching(),d=this.m_fixtureA.GetBody(),e=this.m_fixtureB.GetBody(),f=this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb);if(this.sensor)f&&(b=Box2D.Collision.Shapes.b2Shape.TestOverlap(this.m_fixtureA.GetShape(),d.GetTransform(),this.m_fixtureB.GetShape(),e.GetTransform())),this.m_manifold.m_pointCount=0;else{d.GetType()!=
Box2D.Dynamics.b2BodyDef.b2_dynamicBody||d.IsBullet()||e.GetType()!=Box2D.Dynamics.b2BodyDef.b2_dynamicBody||e.IsBullet()?this.continuous=!0:this.continuous=!1;if(f)for(this.Evaluate(),b=0<this.m_manifold.m_pointCount,f=0;f<this.m_manifold.m_pointCount;f++){var g=this.m_manifold.m_points[f];g.m_normalImpulse=0;for(var h=g.m_tangentImpulse=0;h<this.m_oldManifold.m_pointCount;h++){var l=this.m_oldManifold.m_points[h];if(l.m_id.GetKey()==g.m_id.GetKey()){g.m_normalImpulse=l.m_normalImpulse;g.m_tangentImpulse=
l.m_tangentImpulse;break}}}else this.m_manifold.m_pointCount=0;b!=c&&(d.SetAwake(!0),e.SetAwake(!0))}this.touching=b;b!=c&&this.UpdateLists();!c&&b&&a.BeginContact(this);c&&!b&&a.EndContact(this);this.sensor||a.PreSolve(this,this.m_oldManifold)};Box2D.Dynamics.Contacts.b2Contact.prototype.Evaluate=function(){};Box2D.Dynamics.Contacts.b2Contact.prototype.ComputeTOI=function(a,b){Box2D.Dynamics.Contacts.b2Contact.s_input.proxyA.Set(this.m_fixtureA.GetShape());Box2D.Dynamics.Contacts.b2Contact.s_input.proxyB.Set(this.m_fixtureB.GetShape());
Box2D.Dynamics.Contacts.b2Contact.s_input.sweepA=a;Box2D.Dynamics.Contacts.b2Contact.s_input.sweepB=b;Box2D.Dynamics.Contacts.b2Contact.s_input.tolerance=Box2D.Common.b2Settings.b2_linearSlop;return Box2D.Collision.b2TimeOfImpact.TimeOfImpact(Box2D.Dynamics.Contacts.b2Contact.s_input)};Box2D.Dynamics.Contacts.b2Contact.s_input=new Box2D.Collision.b2TOIInput;Box2D.Dynamics.Contacts.b2Contact.NEXT_ID=0;Box2D.Dynamics.Contacts.b2CircleContact=function(a,b){Box2D.Dynamics.Contacts.b2Contact.call(this,
a,b)};c2inherit(Box2D.Dynamics.Contacts.b2CircleContact,Box2D.Dynamics.Contacts.b2Contact);Box2D.Dynamics.Contacts.b2CircleContact.prototype.Reset=function(a,b){Box2D.Dynamics.Contacts.b2Contact.prototype.Reset.call(this,a,b)};Box2D.Dynamics.Contacts.b2CircleContact.prototype.Evaluate=function(){Box2D.Collision.b2Collision.CollideCircles(this.m_manifold,this.m_fixtureA.GetShape(),this.m_fixtureA.GetBody().m_xf,this.m_fixtureB.GetShape(),this.m_fixtureB.GetBody().m_xf)};Box2D.Dynamics.Contacts.b2ContactConstraint=
function(){this.localPlaneNormal=Box2D.Common.Math.b2Vec2.Get(0,0);this.localPoint=Box2D.Common.Math.b2Vec2.Get(0,0);this.normal=Box2D.Common.Math.b2Vec2.Get(0,0);this.normalMass=new Box2D.Common.Math.b2Mat22;this.K=new Box2D.Common.Math.b2Mat22;this.points=[];for(var a=0;a<Box2D.Common.b2Settings.b2_maxManifoldPoints;a++)this.points[a]=new Box2D.Dynamics.Contacts.b2ContactConstraintPoint};Box2D.Dynamics.Contacts.b2ContactConstraintPoint=function(){this.localPoint=Box2D.Common.Math.b2Vec2.Get(0,0);
this.rA=Box2D.Common.Math.b2Vec2.Get(0,0);this.rB=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Dynamics.Contacts.b2ContactConstraintPoint.prototype.Reset=function(){this.localPoint.Set(0,0);this.rA.Set(0,0);this.rB.Set(0,0)};Box2D.Dynamics.Contacts.b2ContactFactory=function(){this.m_registers={};this.m_freeContacts={};this.AddType(Box2D.Dynamics.Contacts.b2CircleContact,Box2D.Collision.Shapes.b2CircleShape.NAME,Box2D.Collision.Shapes.b2CircleShape.NAME);this.AddType(Box2D.Dynamics.Contacts.b2PolyAndCircleContact,
Box2D.Collision.Shapes.b2PolygonShape.NAME,Box2D.Collision.Shapes.b2CircleShape.NAME);this.AddType(Box2D.Dynamics.Contacts.b2PolygonContact,Box2D.Collision.Shapes.b2PolygonShape.NAME,Box2D.Collision.Shapes.b2PolygonShape.NAME);this.AddType(Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,Box2D.Collision.Shapes.b2EdgeShape.NAME,Box2D.Collision.Shapes.b2CircleShape.NAME);this.AddType(Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,Box2D.Collision.Shapes.b2PolygonShape.NAME,Box2D.Collision.Shapes.b2EdgeShape.NAME)};
Box2D.Dynamics.Contacts.b2ContactFactory.prototype.AddType=function(a,b,c){this.m_freeContacts[b]=this.m_freeContacts[b]||{};this.m_freeContacts[b][c]=this.m_freeContacts[b][c]||[];this.m_registers[b]=this.m_registers[b]||{};this.m_registers[b][c]=new Box2D.Dynamics.Contacts.b2ContactRegister;this.m_registers[b][c].ctor=a;this.m_registers[b][c].primary=!0;b!=c&&(this.m_registers[c]=this.m_registers[c]||{},this.m_registers[c][b]=new Box2D.Dynamics.Contacts.b2ContactRegister,this.m_registers[c][b].ctor=
a,this.m_registers[c][b].primary=!1)};Box2D.Dynamics.Contacts.b2ContactFactory.prototype.Create=function(a,b){var c=a.GetShape().GetTypeName(),d=b.GetShape().GetTypeName(),e=this.m_registers[c][d],f=e.ctor;return null!=f?e.primary?0<this.m_freeContacts[c][d].length?(c=this.m_freeContacts[c][d].pop(),c.Reset(a,b),c):new f(a,b):0<this.m_freeContacts[d][c].length?(c=this.m_freeContacts[d][c].pop(),c.Reset(b,a),c):new f(b,a):null};Box2D.Dynamics.Contacts.b2ContactFactory.prototype.Destroy=function(a){var b=
a.m_fixtureA.GetShape().GetTypeName(),c=a.m_fixtureB.GetShape().GetTypeName();this.m_freeContacts[b][c].push(a)};Box2D.Dynamics.Contacts.b2ContactList=function(){this.contactFirstNodes=[];for(var a=0;a<=Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts;a++)this.contactFirstNodes[a]=null;this.contactLastNodes=[];for(a=0;a<=Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts;a++)this.contactLastNodes[a]=null;this.contactNodeLookup={};this.contactCount=0};Box2D.Dynamics.Contacts.b2ContactList.prototype.GetFirstNode=
function(a){return this.contactFirstNodes[a]};Box2D.Dynamics.Contacts.b2ContactList.prototype.AddContact=function(a){var b=a.ID;if(null==this.contactNodeLookup[b]){this.contactNodeLookup[b]=[];for(var c=0;c<=Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts;c++)this.contactNodeLookup[b][c]=null;this.CreateNode(a,b,Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts);this.contactCount++}};Box2D.Dynamics.Contacts.b2ContactList.prototype.UpdateContact=function(a,b,c){b?this.CreateNode(a,a.ID,
Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledTouchingContacts):this.RemoveNode(a.ID,Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledTouchingContacts);c?this.CreateNode(a,a.ID,Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledContinuousContacts):this.RemoveNode(a.ID,Box2D.Dynamics.Contacts.b2ContactList.TYPES.nonSensorEnabledContinuousContacts)};Box2D.Dynamics.Contacts.b2ContactList.prototype.RemoveContact=function(a){a=a.ID;if(null!=this.contactNodeLookup[a]){for(var b=
0;b<=Box2D.Dynamics.Contacts.b2ContactList.TYPES.allContacts;b++)this.RemoveNode(a,b);delete this.contactNodeLookup[a];this.contactCount--}};Box2D.Dynamics.Contacts.b2ContactList.prototype.RemoveNode=function(a,b){var c=this.contactNodeLookup[a];if(null!=c){var d=c[b];if(null!=d){c[b]=null;var c=d.GetPreviousNode(),e=d.GetNextNode();null==c?this.contactFirstNodes[b]=e:c.SetNextNode(e);null==e?this.contactLastNodes[b]=c:e.SetPreviousNode(c);Box2D.Dynamics.Contacts.b2ContactListNode.FreeNode(d)}}};
Box2D.Dynamics.Contacts.b2ContactList.prototype.CreateNode=function(a,b,c){b=this.contactNodeLookup[b];null==b[c]&&(b[c]=Box2D.Dynamics.Contacts.b2ContactListNode.GetNode(a),a=this.contactLastNodes[c],null!=a?(a.SetNextNode(b[c]),b[c].SetPreviousNode(a)):this.contactFirstNodes[c]=b[c],this.contactLastNodes[c]=b[c])};Box2D.Dynamics.Contacts.b2ContactList.prototype.GetContactCount=function(){return this.contactCount};Box2D.Dynamics.Contacts.b2ContactList.TYPES={nonSensorEnabledTouchingContacts:0,nonSensorEnabledContinuousContacts:1,
allContacts:2};Box2D.Dynamics.Contacts.b2ContactListNode=function(a){this.contact=a;this.previous=this.next=null};Box2D.Dynamics.Contacts.b2ContactListNode.freeNodes=[];Box2D.Dynamics.Contacts.b2ContactListNode.GetNode=function(a){if(0<Box2D.Dynamics.Contacts.b2ContactListNode.freeNodes.length){var b=Box2D.Dynamics.Contacts.b2ContactListNode.freeNodes.pop();b.next=null;b.previous=null;b.contact=a;return b}return new Box2D.Dynamics.Contacts.b2ContactListNode(a)};Box2D.Dynamics.Contacts.b2ContactListNode.FreeNode=
function(a){Box2D.Dynamics.Contacts.b2ContactListNode.freeNodes.push(a)};Box2D.Dynamics.Contacts.b2ContactListNode.prototype.SetNextNode=function(a){this.next=a};Box2D.Dynamics.Contacts.b2ContactListNode.prototype.SetPreviousNode=function(a){this.previous=a};Box2D.Dynamics.Contacts.b2ContactListNode.prototype.GetContact=function(){return this.contact};Box2D.Dynamics.Contacts.b2ContactListNode.prototype.GetNextNode=function(){return this.next};Box2D.Dynamics.Contacts.b2ContactListNode.prototype.GetPreviousNode=
function(){return this.previous};Box2D.Dynamics.Contacts.b2ContactRegister=function(){this.pool=null;this.poolCount=0};Box2D.Dynamics.Contacts.b2PositionSolverManifold=function(){this.m_normal=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_separations=[];this.m_points=[];for(var a=0;a<Box2D.Common.b2Settings.b2_maxManifoldPoints;a++)this.m_points[a]=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Dynamics.Contacts.b2PositionSolverManifold.prototype.Initialize=function(a){switch(a.type){case Box2D.Collision.b2Manifold.e_circles:this._InitializeCircles(a);
break;case Box2D.Collision.b2Manifold.e_faceA:this._InitializeFaceA(a);break;case Box2D.Collision.b2Manifold.e_faceB:this._InitializeFaceB(a)}};Box2D.Dynamics.Contacts.b2PositionSolverManifold.prototype._InitializeCircles=function(a){var b=a.bodyA.m_xf.R,c=a.localPoint,d=a.bodyA.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y),e=a.bodyA.m_xf.position.y+(b.col1.y*c.x+b.col2.y*c.y),b=a.bodyB.m_xf.R,c=a.points[0].localPoint,f=a.bodyB.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y),b=a.bodyB.m_xf.position.y+(b.col1.y*
c.x+b.col2.y*c.y),c=f-d,g=b-e,h=c*c+g*g;h>Box2D.Common.b2Settings.MIN_VALUE_SQUARED?(h=Math.sqrt(h),this.m_normal.x=c/h,this.m_normal.y=g/h):(this.m_normal.x=1,this.m_normal.y=0);this.m_points[0].x=0.5*(d+f);this.m_points[0].y=0.5*(e+b);this.m_separations[0]=c*this.m_normal.x+g*this.m_normal.y-a.radius};Box2D.Dynamics.Contacts.b2PositionSolverManifold.prototype._InitializeFaceA=function(a){this.m_normal.x=a.bodyA.m_xf.R.col1.x*a.localPlaneNormal.x+a.bodyA.m_xf.R.col2.x*a.localPlaneNormal.y;this.m_normal.y=
a.bodyA.m_xf.R.col1.y*a.localPlaneNormal.x+a.bodyA.m_xf.R.col2.y*a.localPlaneNormal.y;for(var b=a.bodyA.m_xf.position.x+(a.bodyA.m_xf.R.col1.x*a.localPoint.x+a.bodyA.m_xf.R.col2.x*a.localPoint.y),c=a.bodyA.m_xf.position.y+(a.bodyA.m_xf.R.col1.y*a.localPoint.x+a.bodyA.m_xf.R.col2.y*a.localPoint.y),d=0;d<a.pointCount;d++){var e=a.bodyB.m_xf.position.x+(a.bodyB.m_xf.R.col1.x*a.points[d].localPoint.x+a.bodyB.m_xf.R.col2.x*a.points[d].localPoint.y),f=a.bodyB.m_xf.position.y+(a.bodyB.m_xf.R.col1.y*a.points[d].localPoint.x+
a.bodyB.m_xf.R.col2.y*a.points[d].localPoint.y);this.m_separations[d]=(e-b)*this.m_normal.x+(f-c)*this.m_normal.y-a.radius;this.m_points[d].x=e;this.m_points[d].y=f}};Box2D.Dynamics.Contacts.b2PositionSolverManifold.prototype._InitializeFaceB=function(a){this.m_normal.x=a.bodyB.m_xf.R.col1.x*a.localPlaneNormal.x+a.bodyB.m_xf.R.col2.x*a.localPlaneNormal.y;this.m_normal.y=a.bodyB.m_xf.R.col1.y*a.localPlaneNormal.x+a.bodyB.m_xf.R.col2.y*a.localPlaneNormal.y;for(var b=a.bodyB.m_xf.position.x+(a.bodyB.m_xf.R.col1.x*
a.localPoint.x+a.bodyB.m_xf.R.col2.x*a.localPoint.y),c=a.bodyB.m_xf.position.y+(a.bodyB.m_xf.R.col1.y*a.localPoint.x+a.bodyB.m_xf.R.col2.y*a.localPoint.y),d=0;d<a.pointCount;d++){var e=a.bodyA.m_xf.position.x+(a.bodyA.m_xf.R.col1.x*a.points[d].localPoint.x+a.bodyA.m_xf.R.col2.x*a.points[d].localPoint.y),f=a.bodyA.m_xf.position.y+(a.bodyA.m_xf.R.col1.y*a.points[d].localPoint.x+a.bodyA.m_xf.R.col2.y*a.points[d].localPoint.y);this.m_separations[d]=(e-b)*this.m_normal.x+(f-c)*this.m_normal.y-a.radius;
this.m_points[d].Set(e,f)}this.m_normal.x*=-1;this.m_normal.y*=-1};Box2D.Dynamics.Contacts.b2ContactSolver=function(){this.m_constraints=[]};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.Initialize=function(a,b,c){for(this.m_constraintCount=c;this.m_constraints.length<this.m_constraintCount;)this.m_constraints[this.m_constraints.length]=new Box2D.Dynamics.Contacts.b2ContactConstraint;for(a=0;a<c;a++){var d=b[a],e=d.m_fixtureA,f=d.m_fixtureB,g=e.m_shape.m_radius,h=f.m_shape.m_radius,l=e.GetBody(),
k=f.GetBody(),m=d.GetManifold(),n=Box2D.Common.b2Settings.b2MixFriction(e.GetFriction(),f.GetFriction()),q=Box2D.Common.b2Settings.b2MixRestitution(e.GetRestitution(),f.GetRestitution()),p=l.m_linearVelocity.x,r=l.m_linearVelocity.y,s=k.m_linearVelocity.x,w=k.m_linearVelocity.y,x=l.m_angularVelocity,C=k.m_angularVelocity;Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.Initialize(m,l.m_xf,g,k.m_xf,h);f=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.m_normal.x;d=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.m_normal.y;
e=this.m_constraints[a];e.bodyA=l;e.bodyB=k;e.manifold=m;e.normal.x=f;e.normal.y=d;e.pointCount=m.m_pointCount;e.friction=n;e.restitution=q;e.localPlaneNormal.x=m.m_localPlaneNormal.x;e.localPlaneNormal.y=m.m_localPlaneNormal.y;e.localPoint.x=m.m_localPoint.x;e.localPoint.y=m.m_localPoint.y;e.radius=g+h;e.type=m.m_type;for(g=0;g<e.pointCount;++g){n=m.m_points[g];h=e.points[g];h.normalImpulse=n.m_normalImpulse;h.tangentImpulse=n.m_tangentImpulse;h.localPoint.SetV(n.m_localPoint);var n=h.rA.x=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.m_points[g].x-
l.m_sweep.c.x,q=h.rA.y=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.m_points[g].y-l.m_sweep.c.y,F=h.rB.x=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.m_points[g].x-k.m_sweep.c.x,I=h.rB.y=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold.m_points[g].y-k.m_sweep.c.y,D=n*d-q*f,v=F*d-I*f,D=D*D,v=v*v;h.normalMass=1/(l.m_invMass+k.m_invMass+l.m_invI*D+k.m_invI*v);var u=l.m_mass*l.m_invMass+k.m_mass*k.m_invMass,u=u+(l.m_mass*l.m_invI*D+k.m_mass*k.m_invI*v);h.equalizedMass=1/u;
v=d;u=-f;D=n*u-q*v;v=F*u-I*v;D*=D;v*=v;h.tangentMass=1/(l.m_invMass+k.m_invMass+l.m_invI*D+k.m_invI*v);h.velocityBias=0;n=e.normal.x*(s+-C*I-p- -x*q)+e.normal.y*(w+C*F-r-x*n);n<-Box2D.Common.b2Settings.b2_velocityThreshold&&(h.velocityBias+=-e.restitution*n)}2==e.pointCount&&(w=e.points[0],s=e.points[1],m=l.m_invMass,l=l.m_invI,p=k.m_invMass,k=k.m_invI,r=w.rA.x*d-w.rA.y*f,w=w.rB.x*d-w.rB.y*f,x=s.rA.x*d-s.rA.y*f,s=s.rB.x*d-s.rB.y*f,f=m+p+l*r*r+k*w*w,d=m+p+l*x*x+k*s*s,k=m+p+l*r*x+k*w*s,f*f<100*(f*d-
k*k)?(e.K.col1.Set(f,k),e.K.col2.Set(k,d),e.K.GetInverse(e.normalMass)):e.pointCount=1)}};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.InitVelocityConstraints=function(a){for(var b=0;b<this.m_constraintCount;++b){var c=this.m_constraints[b],d=c.bodyA,e=c.bodyB,f=d.m_invMass,g=d.m_invI,h=e.m_invMass,l=e.m_invI,k=c.normal.x,m=c.normal.y,n=m,q=-k,p=0,r=0;if(a.warmStarting)for(r=c.pointCount,p=0;p<r;++p){var s=c.points[p];s.normalImpulse*=a.dtRatio;s.tangentImpulse*=a.dtRatio;var w=s.normalImpulse*
k+s.tangentImpulse*n,x=s.normalImpulse*m+s.tangentImpulse*q;d.m_angularVelocity-=g*(s.rA.x*x-s.rA.y*w);d.m_linearVelocity.x-=f*w;d.m_linearVelocity.y-=f*x;e.m_angularVelocity+=l*(s.rB.x*x-s.rB.y*w);e.m_linearVelocity.x+=h*w;e.m_linearVelocity.y+=h*x}else for(r=c.pointCount,p=0;p<r;++p)d=c.points[p],d.normalImpulse=0,d.tangentImpulse=0}};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolveVelocityConstraints=function(){for(var a=0;a<this.m_constraintCount;a++)this.SolveVelocityConstraints_Constraint(this.m_constraints[a])};
Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolveVelocityConstraints_Constraint=function(a){for(var b=a.normal.x,c=a.normal.y,d=0;d<a.pointCount;d++)Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolveVelocityConstraints_ConstraintPoint(a,a.points[d]);if(1==a.pointCount){var d=a.points[0],e=d.normalImpulse-d.normalMass*((a.bodyB.m_linearVelocity.x-a.bodyB.m_angularVelocity*d.rB.y-a.bodyA.m_linearVelocity.x+a.bodyA.m_angularVelocity*d.rA.y)*b+(a.bodyB.m_linearVelocity.y+a.bodyB.m_angularVelocity*
d.rB.x-a.bodyA.m_linearVelocity.y-a.bodyA.m_angularVelocity*d.rA.x)*c-d.velocityBias),e=0<e?e:0,f=e-d.normalImpulse,g=f*b,c=f*c;a.bodyA.m_linearVelocity.x-=a.bodyA.m_invMass*g;a.bodyA.m_linearVelocity.y-=a.bodyA.m_invMass*c;a.bodyA.m_angularVelocity-=a.bodyA.m_invI*(d.rA.x*c-d.rA.y*g);a.bodyB.m_linearVelocity.x+=a.bodyB.m_invMass*g;a.bodyB.m_linearVelocity.y+=a.bodyB.m_invMass*c;a.bodyB.m_angularVelocity+=a.bodyB.m_invI*(d.rB.x*c-d.rB.y*g);d.normalImpulse=e}else for(var d=a.points[0],e=a.points[1],
f=d.normalImpulse,g=e.normalImpulse,h=(a.bodyB.m_linearVelocity.x-a.bodyB.m_angularVelocity*d.rB.y-a.bodyA.m_linearVelocity.x+a.bodyA.m_angularVelocity*d.rA.y)*b+(a.bodyB.m_linearVelocity.y+a.bodyB.m_angularVelocity*d.rB.x-a.bodyA.m_linearVelocity.y-a.bodyA.m_angularVelocity*d.rA.x)*c-d.velocityBias,c=(a.bodyB.m_linearVelocity.x-a.bodyB.m_angularVelocity*e.rB.y-a.bodyA.m_linearVelocity.x+a.bodyA.m_angularVelocity*e.rA.y)*b+(a.bodyB.m_linearVelocity.y+a.bodyB.m_angularVelocity*e.rB.x-a.bodyA.m_linearVelocity.y-
a.bodyA.m_angularVelocity*e.rA.x)*c-e.velocityBias,h=h-(a.K.col1.x*f+a.K.col2.x*g),c=c-(a.K.col1.y*f+a.K.col2.y*g);;){b=-(a.normalMass.col1.x*h+a.normalMass.col2.x*c);if(0<=b){var l=-(a.normalMass.col1.y*h+a.normalMass.col2.y*c);if(0<=l){this.SolveVelocityConstraints_ConstraintPointUpdate(a,d,e,b-f,l-g);d.normalImpulse=b;e.normalImpulse=l;break}}b=-d.normalMass*h;if(0<=b&&0<=a.K.col1.y*b+c){this.SolveVelocityConstraints_ConstraintPointUpdate(a,d,e,b-f,-g);d.normalImpulse=b;e.normalImpulse=0;break}b=
-e.normalMass*c;if(0<=b&&0<=a.K.col2.x*b+h){this.SolveVelocityConstraints_ConstraintPointUpdate(a,d,e,-f,b-g);d.normalImpulse=0;e.normalImpulse=b;break}if(0<=h&&0<=c){this.SolveVelocityConstraints_ConstraintPointUpdate(a,d,e,-f,-g);d.normalImpulse=0;e.normalImpulse=0;break}break}};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolveVelocityConstraints_ConstraintPoint=function(a,b){var c=a.normal.y,d=-a.normal.x,e=a.friction*b.normalImpulse,e=Box2D.Common.Math.b2Math.Clamp(b.tangentImpulse-b.tangentMass*
((a.bodyB.m_linearVelocity.x-a.bodyB.m_angularVelocity*b.rB.y-a.bodyA.m_linearVelocity.x+a.bodyA.m_angularVelocity*b.rA.y)*c+(a.bodyB.m_linearVelocity.y+a.bodyB.m_angularVelocity*b.rB.x-a.bodyA.m_linearVelocity.y-a.bodyA.m_angularVelocity*b.rA.x)*d),-e,e),f=e-b.tangentImpulse,c=f*c,d=f*d;a.bodyA.m_linearVelocity.x-=a.bodyA.m_invMass*c;a.bodyA.m_linearVelocity.y-=a.bodyA.m_invMass*d;a.bodyA.m_angularVelocity-=a.bodyA.m_invI*(b.rA.x*d-b.rA.y*c);a.bodyB.m_linearVelocity.x+=a.bodyB.m_invMass*c;a.bodyB.m_linearVelocity.y+=
a.bodyB.m_invMass*d;a.bodyB.m_angularVelocity+=a.bodyB.m_invI*(b.rB.x*d-b.rB.y*c);b.tangentImpulse=e};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolveVelocityConstraints_ConstraintPointUpdate=function(a,b,c,d,e){var f=d*a.normal.x;d*=a.normal.y;var g=e*a.normal.x;e*=a.normal.y;a.bodyA.m_linearVelocity.x-=a.bodyA.m_invMass*(f+g);a.bodyA.m_linearVelocity.y-=a.bodyA.m_invMass*(d+e);a.bodyA.m_angularVelocity-=a.bodyA.m_invI*(b.rA.x*d-b.rA.y*f+c.rA.x*e-c.rA.y*g);a.bodyB.m_linearVelocity.x+=a.bodyB.m_invMass*
(f+g);a.bodyB.m_linearVelocity.y+=a.bodyB.m_invMass*(d+e);a.bodyB.m_angularVelocity+=a.bodyB.m_invI*(b.rB.x*d-b.rB.y*f+c.rB.x*e-c.rB.y*g);b.normalImpulse=0;c.normalImpulse=0};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.FinalizeVelocityConstraints=function(){for(var a=0;a<this.m_constraintCount;++a)for(var b=this.m_constraints[a],c=b.manifold,d=0;d<b.pointCount;++d){var e=c.m_points[d],f=b.points[d];e.m_normalImpulse=f.normalImpulse;e.m_tangentImpulse=f.tangentImpulse}};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolvePositionConstraints=
function(a){void 0===a&&(a=0);for(var b=0,c=0;c<this.m_constraintCount;c++){var d=this.m_constraints[c],e=d.bodyA,f=d.bodyB,g=e.m_mass*e.m_invMass,h=e.m_mass*e.m_invI,l=f.m_mass*f.m_invMass,k=f.m_mass*f.m_invI;Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.Initialize(d);for(var m=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.m_normal,n=0;n<d.pointCount;n++){var q=d.points[n],p=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.m_points[n],r=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.m_separations[n],
s=p.x-e.m_sweep.c.x,w=p.y-e.m_sweep.c.y,x=p.x-f.m_sweep.c.x,p=p.y-f.m_sweep.c.y,b=b<r?b:r,r=Box2D.Common.Math.b2Math.Clamp(a*(r+Box2D.Common.b2Settings.b2_linearSlop),-Box2D.Common.b2Settings.b2_maxLinearCorrection,0),r=-q.equalizedMass*r,q=r*m.x,r=r*m.y;e.m_sweep.c.x-=g*q;e.m_sweep.c.y-=g*r;e.m_sweep.a-=h*(s*r-w*q);e.SynchronizeTransform();f.m_sweep.c.x+=l*q;f.m_sweep.c.y+=l*r;f.m_sweep.a+=k*(x*r-p*q);f.SynchronizeTransform()}}return b>-1.5*Box2D.Common.b2Settings.b2_linearSlop};Box2D.Dynamics.Contacts.b2ContactSolver.prototype.SolvePositionConstraints_NEW=
function(a){void 0===a&&(a=0);for(var b=0,c=0;c<this.m_constraintCount;c++){var d=this.m_constraints[c],e=d.bodyA,f=d.bodyB,g=e.m_mass*e.m_invMass,h=e.m_mass*e.m_invI,l=f.m_mass*f.m_invMass,k=f.m_mass*f.m_invI;Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.Initialize(d);for(var m=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.m_normal,n=0;n<d.pointCount;n++){var q=d.points[n],p=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.m_points[n],r=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm.m_separations[n],
s=p.x-e.m_sweep.c.x,w=p.y-e.m_sweep.c.y,x=p.x-f.m_sweep.c.x,p=p.y-f.m_sweep.c.y;r<b&&(b=r);0!=a&&Box2D.Common.Math.b2Math.Clamp(a*(r+Box2D.Common.b2Settings.b2_linearSlop),-Box2D.Common.b2Settings.b2_maxLinearCorrection,0);r=0*-q.equalizedMass;q=r*m.x;r*=m.y;e.m_sweep.c.x-=g*q;e.m_sweep.c.y-=g*r;e.m_sweep.a-=h*(s*r-w*q);e.SynchronizeTransform();f.m_sweep.c.x+=l*q;f.m_sweep.c.y+=l*r;f.m_sweep.a+=k*(x*r-p*q);f.SynchronizeTransform()}}return b>-1.5*Box2D.Common.b2Settings.b2_linearSlop};Box2D.Dynamics.Contacts.b2EdgeAndCircleContact=
function(a,b){Box2D.Dynamics.Contacts.b2Contact.call(this,a,b)};c2inherit(Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,Box2D.Dynamics.Contacts.b2Contact);Box2D.Dynamics.Contacts.b2EdgeAndCircleContact.prototype.Reset=function(a,b){Box2D.Dynamics.Contacts.b2Contact.prototype.Reset.call(this,a,b)};Box2D.Dynamics.Contacts.b2EdgeAndCircleContact.prototype.Evaluate=function(){this.m_fixtureA.GetBody();this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,this.m_fixtureA.GetShape(),this.m_fixtureA.GetBody().m_xf,
this.m_fixtureB.GetShape(),this.m_fixtureB.GetBody().m_xf)};Box2D.Dynamics.Contacts.b2EdgeAndCircleContact.prototype.b2CollideEdgeAndCircle=function(a,b,c,d,e){};Box2D.Dynamics.Contacts.b2PolyAndCircleContact=function(a,b){Box2D.Dynamics.Contacts.b2Contact.call(this,a,b)};c2inherit(Box2D.Dynamics.Contacts.b2PolyAndCircleContact,Box2D.Dynamics.Contacts.b2Contact);Box2D.Dynamics.Contacts.b2PolyAndCircleContact.prototype.Reset=function(a,b){Box2D.Dynamics.Contacts.b2Contact.prototype.Reset.call(this,
a,b)};Box2D.Dynamics.Contacts.b2PolyAndCircleContact.prototype.Evaluate=function(){Box2D.Collision.b2Collision.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape(),this.m_fixtureA.GetBody().m_xf,this.m_fixtureB.GetShape(),this.m_fixtureB.GetBody().m_xf)};Box2D.Dynamics.Contacts.b2PolyAndEdgeContact=function(a,b){Box2D.Dynamics.Contacts.b2Contact.call(this,a,b)};c2inherit(Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,Box2D.Dynamics.Contacts.b2Contact);Box2D.Dynamics.Contacts.b2PolyAndEdgeContact.prototype.Reset=
function(a,b){Box2D.Dynamics.Contacts.b2Contact.prototype.Reset.call(this,a,b)};Box2D.Dynamics.Contacts.b2PolyAndEdgeContact.prototype.Evaluate=function(){this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape(),this.m_fixtureA.GetBody().m_xf,this.m_fixtureB.GetShape(),this.m_fixtureB.GetBody().m_xf)};Box2D.Dynamics.Contacts.b2PolyAndEdgeContact.prototype.b2CollidePolyAndEdge=function(a,b,c,d,e){};Box2D.Dynamics.Contacts.b2PolygonContact=function(a,b){Box2D.Dynamics.Contacts.b2Contact.call(this,
a,b)};c2inherit(Box2D.Dynamics.Contacts.b2PolygonContact,Box2D.Dynamics.Contacts.b2Contact);Box2D.Dynamics.Contacts.b2PolygonContact.prototype.Reset=function(a,b){Box2D.Dynamics.Contacts.b2Contact.prototype.Reset.call(this,a,b)};Box2D.Dynamics.Contacts.b2PolygonContact.prototype.Evaluate=function(){Box2D.Collision.b2Collision.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape(),this.m_fixtureA.GetBody().m_xf,this.m_fixtureB.GetShape(),this.m_fixtureB.GetBody().m_xf)};Box2D.Dynamics.Controllers.b2Controller=
function(){this.ID="Controller"+Box2D.Dynamics.Controllers.b2Controller.NEXT_ID++;this.m_world=null;this.bodyList=new Box2D.Dynamics.b2BodyList};Box2D.Dynamics.Controllers.b2Controller.prototype.Step=function(a){};Box2D.Dynamics.Controllers.b2Controller.prototype.AddBody=function(a){this.bodyList.AddBody(a);a.AddController(this)};Box2D.Dynamics.Controllers.b2Controller.prototype.RemoveBody=function(a){this.bodyList.RemoveBody(a);a.RemoveController(this)};Box2D.Dynamics.Controllers.b2Controller.prototype.Clear=
function(){for(var a=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);a;a=a.GetNextNode())this.RemoveBody(a.body)};Box2D.Dynamics.Controllers.b2Controller.prototype.GetBodyList=function(){return this.bodyList};Box2D.Dynamics.Controllers.b2Controller.NEXT_ID=0;Box2D.Dynamics.Controllers.b2BuoyancyController=function(){Box2D.Dynamics.Controllers.b2Controller.call(this);this.normal=Box2D.Common.Math.b2Vec2.Get(0,-1);this.density=this.offset=0;this.velocity=Box2D.Common.Math.b2Vec2.Get(0,
0);this.linearDrag=2;this.angularDrag=1;this.useDensity=!1;this.useWorldGravity=!0;this.gravity=null};c2inherit(Box2D.Dynamics.Controllers.b2BuoyancyController,Box2D.Dynamics.Controllers.b2Controller);Box2D.Dynamics.Controllers.b2BuoyancyController.prototype.Step=function(a){this.useWorldGravity&&(this.gravity=this.m_world.GetGravity().Copy());for(a=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.awakeBodies);a;a=a.GetNextNode()){for(var b=a.body,c=Box2D.Common.Math.b2Vec2.Get(0,0),d=Box2D.Common.Math.b2Vec2.Get(0,
0),e=0,f=0,g=b.GetFixtureList().GetFirstNode();g;g=g.GetNextNode()){var h=Box2D.Common.Math.b2Vec2.Get(0,0),l=g.fixture.GetShape().ComputeSubmergedArea(this.normal,this.offset,b.GetTransform(),h),e=e+l;c.x+=l*h.x;c.y+=l*h.y;var k=0,k=1,f=f+l*k;d.x+=l*h.x*k;d.y+=l*h.y*k}e<Number.MIN_VALUE||(c.x/=e,c.y/=e,d.x/=f,d.y/=f,f=this.gravity.GetNegative(),f.Multiply(this.density*e),b.ApplyForce(f,d),f=b.GetLinearVelocityFromWorldPoint(c),f.Subtract(this.velocity),f.Multiply(-this.linearDrag*e),b.ApplyForce(f,
c),b.ApplyTorque(-b.GetInertia()/b.GetMass()*e*b.GetAngularVelocity()*this.angularDrag),Box2D.Common.Math.b2Vec2.Free(c),Box2D.Common.Math.b2Vec2.Free(d))}};Box2D.Dynamics.Controllers.b2ConstantAccelController=function(){Box2D.Dynamics.Controllers.b2Controller.call(this);this.A=Box2D.Common.Math.b2Vec2.Get(0,0)};c2inherit(Box2D.Dynamics.Controllers.b2ConstantAccelController,Box2D.Dynamics.Controllers.b2Controller);Box2D.Dynamics.Controllers.b2ConstantAccelController.prototype.Step=function(a){a=Box2D.Common.Math.b2Vec2.Get(this.A.x*
a.dt,this.A.y*a.dt);for(var b=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.awakeBodies);b;b=b.GetNextNode()){var c=b.body,d=c.GetLinearVelocity();c.SetLinearVelocity(Box2D.Common.Math.b2Vec2.Get(d.x+a.x,d.y+a.y))}Box2D.Common.Math.b2Vec2.Free(a)};Box2D.Dynamics.Controllers.b2ConstantForceController=function(){Box2D.Dynamics.Controllers.b2Controller.call(this);this.F=Box2D.Common.Math.b2Vec2.Get(0,0)};c2inherit(Box2D.Dynamics.Controllers.b2ConstantForceController,Box2D.Dynamics.Controllers.b2Controller);
Box2D.Dynamics.Controllers.b2ConstantForceController.prototype.Step=function(a){for(a=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.awakeBodies);a;a=a.GetNextNode()){var b=a.body;b.ApplyForce(this.F,b.GetWorldCenter())}};Box2D.Dynamics.Controllers.b2ControllerList=function(){this.controllerLastNode=this.controllerFirstNode=null;this.controllerNodeLookup={};this.controllerCount=0};Box2D.Dynamics.Controllers.b2ControllerList.prototype.GetFirstNode=function(){return this.controllerFirstNode};
Box2D.Dynamics.Controllers.b2ControllerList.prototype.AddController=function(a){var b=a.ID;if(null==this.controllerNodeLookup[b]){a=new Box2D.Dynamics.Controllers.b2ControllerListNode(a);var c=this.controllerLastNode;null!=c?c.SetNextNode(a):this.controllerFirstNode=a;a.SetPreviousNode(c);this.controllerLastNode=a;this.controllerNodeLookup[b]=a;this.controllerCount++}};Box2D.Dynamics.Controllers.b2ControllerList.prototype.RemoveController=function(a){a=a.ID;var b=this.controllerNodeLookup[a];if(null!=
b){var c=b.GetPreviousNode(),b=b.GetNextNode();null==c?this.controllerFirstNode=b:c.SetNextNode(b);null==b?this.controllerLastNode=c:b.SetPreviousNode(c);delete this.controllerNodeLookup[a];this.controllerCount--}};Box2D.Dynamics.Controllers.b2ControllerList.prototype.GetControllerCount=function(){return this.controllerCount};Box2D.Dynamics.Controllers.b2ControllerListNode=function(a){this.controller=a;this.previous=this.next=null};Box2D.Dynamics.Controllers.b2ControllerListNode.prototype.SetNextNode=
function(a){this.next=a};Box2D.Dynamics.Controllers.b2ControllerListNode.prototype.SetPreviousNode=function(a){this.previous=a};Box2D.Dynamics.Controllers.b2ControllerListNode.prototype.GetNextNode=function(){return this.next};Box2D.Dynamics.Controllers.b2ControllerListNode.prototype.GetPreviousNode=function(){return this.previous};Box2D.Dynamics.Controllers.b2GravityController=function(){Box2D.Dynamics.Controllers.b2Controller.call(this);this.G=1;this.invSqr=!0};c2inherit(Box2D.Dynamics.Controllers.b2GravityController,
Box2D.Dynamics.Controllers.b2Controller);Box2D.Dynamics.Controllers.b2GravityController.prototype.Step=function(a){var b=a=null,c=0,d=null,e=null,f=0,g=0,h=0,f=null;if(this.invSqr)for(var l=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);l;l=l.GetNextNode()){a=l.body;for(var b=a.GetWorldCenter(),c=a.GetMass(),k=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);k;k=k.GetNextNode())if(d=k.body,a.IsAwake()||d.IsAwake())e=d.GetWorldCenter(),f=e.x-b.x,g=e.y-b.y,
h=f*f+g*g,h<Number.MIN_VALUE||(f=Box2D.Common.Math.b2Vec2.Get(f,g),f.Multiply(this.G/h/Math.sqrt(h)*c*d.GetMass()),a.IsAwake()&&a.ApplyForce(f,b),f.Multiply(-1),d.IsAwake()&&d.ApplyForce(f,e),Box2D.Common.Math.b2Vec2.Free(f))}else for(l=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);l;l=l.GetNextNode())for(a=bodyNode.body,b=a.GetWorldCenter(),c=a.GetMass(),k=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.allBodies);k;k=k.GetNextNode())if(d=bodyNode.body,a.IsAwake()||
d.IsAwake())e=d.GetWorldCenter(),f=e.x-b.x,g=e.y-b.y,h=f*f+g*g,h<Number.MIN_VALUE||(f=Box2D.Common.Math.b2Vec2.Get(f,g),f.Multiply(this.G/h*c*d.GetMass()),a.IsAwake()&&a.ApplyForce(f,b),f.Multiply(-1),d.IsAwake()&&d.ApplyForce(f,e),Box2D.Common.Math.b2Vec2.Free(f))};Box2D.Dynamics.Controllers.b2TensorDampingController=function(){Box2D.Dynamics.Controllers.b2Controller.call(this);this.T=new Box2D.Common.Math.b2Mat22;this.maxTimestep=0};c2inherit(Box2D.Dynamics.Controllers.b2TensorDampingController,
Box2D.Dynamics.Controllers.b2Controller);Box2D.Dynamics.Controllers.b2TensorDampingController.prototype.SetAxisAligned=function(a,b){this.T.col1.x=-a;this.T.col1.y=0;this.T.col2.x=0;this.T.col2.y=-b;this.maxTimestep=0<a||0<b?1/Math.max(a,b):0};Box2D.Dynamics.Controllers.b2TensorDampingController.prototype.Step=function(a){a=a.dt;if(!(a<=Number.MIN_VALUE)){a>this.maxTimestep&&0<this.maxTimestep&&(a=this.maxTimestep);for(var b=this.bodyList.GetFirstNode(Box2D.Dynamics.b2BodyList.TYPES.awakeBodies);b;b=
b.GetNextNode()){var c=b.body,d=c.GetWorldVector(Box2D.Common.Math.b2Math.MulMV(this.T,c.GetLocalVector(c.GetLinearVelocity())));c.SetLinearVelocity(Box2D.Common.Math.b2Vec2.Get(c.GetLinearVelocity().x+d.x*a,c.GetLinearVelocity().y+d.y*a))}}};Box2D.Dynamics.Joints.b2Joint=function(a){this.m_edgeA=new Box2D.Dynamics.Joints.b2JointEdge;this.m_edgeB=new Box2D.Dynamics.Joints.b2JointEdge;this.m_localCenterA=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localCenterB=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_type=
a.type;this.m_next=this.m_prev=null;this.m_bodyA=a.bodyA;this.m_bodyB=a.bodyB;this.m_collideConnected=a.collideConnected};Box2D.Dynamics.Joints.b2Joint.prototype.GetType=function(){return this.m_type};Box2D.Dynamics.Joints.b2Joint.prototype.GetAnchorA=function(){return null};Box2D.Dynamics.Joints.b2Joint.prototype.GetAnchorB=function(){return null};Box2D.Dynamics.Joints.b2Joint.prototype.GetReactionForce=function(a){return null};Box2D.Dynamics.Joints.b2Joint.prototype.GetReactionTorque=function(a){return 0};
Box2D.Dynamics.Joints.b2Joint.prototype.GetBodyA=function(){return this.m_bodyA};Box2D.Dynamics.Joints.b2Joint.prototype.GetBodyB=function(){return this.m_bodyB};Box2D.Dynamics.Joints.b2Joint.prototype.GetNext=function(){return this.m_next};Box2D.Dynamics.Joints.b2Joint.prototype.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()};Box2D.Dynamics.Joints.b2Joint.Create=function(a){return a.Create()};Box2D.Dynamics.Joints.b2Joint.prototype.InitVelocityConstraints=function(a){};
Box2D.Dynamics.Joints.b2Joint.prototype.SolveVelocityConstraints=function(a){};Box2D.Dynamics.Joints.b2Joint.prototype.FinalizeVelocityConstraints=function(){};Box2D.Dynamics.Joints.b2Joint.prototype.SolvePositionConstraints=function(a){return!1};Box2D.Dynamics.Joints.b2Joint.e_unknownJoint=0;Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint=1;Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint=2;Box2D.Dynamics.Joints.b2Joint.e_distanceJoint=3;Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint=4;Box2D.Dynamics.Joints.b2Joint.e_mouseJoint=
5;Box2D.Dynamics.Joints.b2Joint.e_gearJoint=6;Box2D.Dynamics.Joints.b2Joint.e_lineJoint=7;Box2D.Dynamics.Joints.b2Joint.e_weldJoint=8;Box2D.Dynamics.Joints.b2Joint.e_frictionJoint=9;Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit=0;Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit=1;Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit=2;Box2D.Dynamics.Joints.b2Joint.e_equalLimits=3;Box2D.Dynamics.Joints.b2JointDef=function(){this.type=Box2D.Dynamics.Joints.b2Joint.e_unknownJoint;this.bodyB=this.bodyA=null;this.collideConnected=
!1};Box2D.Dynamics.Joints.b2JointEdge=function(){};Box2D.Dynamics.Joints.b2DistanceJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_localAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor2=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_u=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_length=a.length;this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_bias=this.m_gamma=this.m_impulse=
0};c2inherit(Box2D.Dynamics.Joints.b2DistanceJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetReactionForce=function(a){return Box2D.Common.Math.b2Vec2.Get(a*this.m_impulse*this.m_u.x,a*this.m_impulse*this.m_u.y)};
Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetReactionTorque=function(a){return 0};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetLength=function(){return this.m_length};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.SetLength=function(a){this.m_length=a};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetFrequency=function(){return this.m_frequencyHz};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.SetFrequency=function(a){this.m_frequencyHz=a};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.GetDampingRatio=
function(){return this.m_dampingRatio};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.SetDampingRatio=function(a){this.m_dampingRatio=a};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.InitVelocityConstraints=function(a){var b,c=0,d=this.m_bodyA,e=this.m_bodyB;b=d.m_xf.R;var f=this.m_localAnchor1.x-d.m_sweep.localCenter.x,g=this.m_localAnchor1.y-d.m_sweep.localCenter.y,c=b.col1.x*f+b.col2.x*g,g=b.col1.y*f+b.col2.y*g,f=c;b=e.m_xf.R;var h=this.m_localAnchor2.x-e.m_sweep.localCenter.x,l=this.m_localAnchor2.y-
e.m_sweep.localCenter.y,c=b.col1.x*h+b.col2.x*l,l=b.col1.y*h+b.col2.y*l,h=c;this.m_u.x=e.m_sweep.c.x+h-d.m_sweep.c.x-f;this.m_u.y=e.m_sweep.c.y+l-d.m_sweep.c.y-g;c=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);c>Box2D.Common.b2Settings.b2_linearSlop?this.m_u.Multiply(1/c):this.m_u.SetZero();b=f*this.m_u.y-g*this.m_u.x;var k=h*this.m_u.y-l*this.m_u.x;b=d.m_invMass+d.m_invI*b*b+e.m_invMass+e.m_invI*k*k;this.m_mass=0!=b?1/b:0;if(0<this.m_frequencyHz){var c=c-this.m_length,k=2*Math.PI*this.m_frequencyHz,
m=this.m_mass*k*k;this.m_gamma=a.dt*(2*this.m_mass*this.m_dampingRatio*k+a.dt*m);this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0;this.m_bias=c*a.dt*m*this.m_gamma;this.m_mass=b+this.m_gamma;this.m_mass=0!=this.m_mass?1/this.m_mass:0}a.warmStarting?(this.m_impulse*=a.dtRatio,a=this.m_impulse*this.m_u.x,b=this.m_impulse*this.m_u.y,d.m_linearVelocity.x-=d.m_invMass*a,d.m_linearVelocity.y-=d.m_invMass*b,d.m_angularVelocity-=d.m_invI*(f*b-g*a),e.m_linearVelocity.x+=e.m_invMass*a,e.m_linearVelocity.y+=e.m_invMass*
b,e.m_angularVelocity+=e.m_invI*(h*b-l*a)):this.m_impulse=0};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.SolveVelocityConstraints=function(a){a=this.m_localAnchor1.x-this.m_bodyA.m_sweep.localCenter.x;var b=this.m_localAnchor1.y-this.m_bodyA.m_sweep.localCenter.y,c=this.m_bodyA.m_xf.R.col1.x*a+this.m_bodyA.m_xf.R.col2.x*b,b=this.m_bodyA.m_xf.R.col1.y*a+this.m_bodyA.m_xf.R.col2.y*b;a=c;var d=this.m_localAnchor2.x-this.m_bodyB.m_sweep.localCenter.x,e=this.m_localAnchor2.y-this.m_bodyB.m_sweep.localCenter.y,
c=this.m_bodyB.m_xf.R.col1.x*d+this.m_bodyB.m_xf.R.col2.x*e,e=this.m_bodyB.m_xf.R.col1.y*d+this.m_bodyB.m_xf.R.col2.y*e,d=c,f=-this.m_mass*(this.m_u.x*(this.m_bodyB.m_linearVelocity.x-this.m_bodyB.m_angularVelocity*e-(this.m_bodyA.m_linearVelocity.x-this.m_bodyA.m_angularVelocity*b))+this.m_u.y*(this.m_bodyB.m_linearVelocity.y+this.m_bodyB.m_angularVelocity*d-(this.m_bodyA.m_linearVelocity.y+this.m_bodyA.m_angularVelocity*a))+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=f;c=f*this.m_u.x;
f*=this.m_u.y;this.m_bodyA.m_linearVelocity.x-=this.m_bodyA.m_invMass*c;this.m_bodyA.m_linearVelocity.y-=this.m_bodyA.m_invMass*f;this.m_bodyA.m_angularVelocity-=this.m_bodyA.m_invI*(a*f-b*c);this.m_bodyB.m_linearVelocity.x+=this.m_bodyB.m_invMass*c;this.m_bodyB.m_linearVelocity.y+=this.m_bodyB.m_invMass*f;this.m_bodyB.m_angularVelocity+=this.m_bodyB.m_invI*(d*f-e*c)};Box2D.Dynamics.Joints.b2DistanceJoint.prototype.SolvePositionConstraints=function(a){if(0<this.m_frequencyHz)return!0;a=this.m_localAnchor1.x-
this.m_bodyA.m_sweep.localCenter.x;var b=this.m_localAnchor1.y-this.m_bodyA.m_sweep.localCenter.y,c=this.m_bodyA.m_xf.R.col1.x*a+this.m_bodyA.m_xf.R.col2.x*b,b=this.m_bodyA.m_xf.R.col1.y*a+this.m_bodyA.m_xf.R.col2.y*b;a=c;var d=this.m_localAnchor2.x-this.m_bodyB.m_sweep.localCenter.x,e=this.m_localAnchor2.y-this.m_bodyB.m_sweep.localCenter.y,c=this.m_bodyB.m_xf.R.col1.x*d+this.m_bodyB.m_xf.R.col2.x*e,e=this.m_bodyB.m_xf.R.col1.y*d+this.m_bodyB.m_xf.R.col2.y*e,d=c,f=this.m_bodyB.m_sweep.c.x+d-this.m_bodyA.m_sweep.c.x-
a,g=this.m_bodyB.m_sweep.c.y+e-this.m_bodyA.m_sweep.c.y-b,c=Math.sqrt(f*f+g*g),f=f/c,g=g/c,c=Box2D.Common.Math.b2Math.Clamp(c-this.m_length,-Box2D.Common.b2Settings.b2_maxLinearCorrection,Box2D.Common.b2Settings.b2_maxLinearCorrection),h=-this.m_mass*c;this.m_u.Set(f,g);f=h*this.m_u.x;g=h*this.m_u.y;this.m_bodyA.m_sweep.c.x-=this.m_bodyA.m_invMass*f;this.m_bodyA.m_sweep.c.y-=this.m_bodyA.m_invMass*g;this.m_bodyA.m_sweep.a-=this.m_bodyA.m_invI*(a*g-b*f);this.m_bodyB.m_sweep.c.x+=this.m_bodyB.m_invMass*
f;this.m_bodyB.m_sweep.c.y+=this.m_bodyB.m_invMass*g;this.m_bodyB.m_sweep.a+=this.m_bodyB.m_invI*(d*g-e*f);this.m_bodyA.SynchronizeTransform();this.m_bodyB.SynchronizeTransform();return Math.abs(c)<Box2D.Common.b2Settings.b2_linearSlop};Box2D.Dynamics.Joints.b2DistanceJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.type=Box2D.Dynamics.Joints.b2Joint.e_distanceJoint;this.length=
1;this.dampingRatio=this.frequencyHz=0};c2inherit(Box2D.Dynamics.Joints.b2DistanceJointDef,Box2D.Dynamics.Joints.b2JointDef);Box2D.Dynamics.Joints.b2DistanceJointDef.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(d));a=d.x-c.x;c=d.y-c.y;this.length=Math.sqrt(a*a+c*c);this.dampingRatio=this.frequencyHz=0};Box2D.Dynamics.Joints.b2DistanceJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2DistanceJoint(this)};
Box2D.Dynamics.Joints.b2FrictionJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_linearMass=new Box2D.Common.Math.b2Mat22;this.m_linearImpulse=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchorA.SetV(a.localAnchorA);this.m_localAnchorB.SetV(a.localAnchorB);this.m_linearMass.SetZero();this.m_angularMass=0;this.m_linearImpulse.SetZero();this.m_angularImpulse=0;this.m_maxForce=
a.maxForce;this.m_maxTorque=a.maxTorque};c2inherit(Box2D.Dynamics.Joints.b2FrictionJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2FrictionJoint.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return new b2Vec2(a*this.m_linearImpulse.x,
a*this.m_linearImpulse.y)};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.GetReactionTorque=function(a){void 0===a&&(a=0);return a*this.m_angularImpulse};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.SetMaxForce=function(a){void 0===a&&(a=0);this.m_maxForce=a};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.GetMaxForce=function(){return this.m_maxForce};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.SetMaxTorque=function(a){void 0===a&&(a=0);this.m_maxTorque=a};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.GetMaxTorque=
function(){return this.m_maxTorque};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.InitVelocityConstraints=function(a){var b,c=0,d=this.m_bodyA,e=this.m_bodyB;b=d.m_xf.R;var f=this.m_localAnchorA.x-d.m_sweep.localCenter.x,g=this.m_localAnchorA.y-d.m_sweep.localCenter.y,c=b.col1.x*f+b.col2.x*g,g=b.col1.y*f+b.col2.y*g,f=c;b=e.m_xf.R;var h=this.m_localAnchorB.x-e.m_sweep.localCenter.x,l=this.m_localAnchorB.y-e.m_sweep.localCenter.y,c=b.col1.x*h+b.col2.x*l,l=b.col1.y*h+b.col2.y*l,h=c;b=d.m_invMass;var c=
e.m_invMass,k=d.m_invI,m=e.m_invI,n=new Box2D.Common.Math.b2Mat22;n.col1.x=b+c;n.col2.x=0;n.col1.y=0;n.col2.y=b+c;n.col1.x+=k*g*g;n.col2.x+=-k*f*g;n.col1.y+=-k*f*g;n.col2.y+=k*f*f;n.col1.x+=m*l*l;n.col2.x+=-m*h*l;n.col1.y+=-m*h*l;n.col2.y+=m*h*h;n.GetInverse(this.m_linearMass);this.m_angularMass=k+m;0<this.m_angularMass&&(this.m_angularMass=1/this.m_angularMass);a.warmStarting?(this.m_linearImpulse.x*=a.dtRatio,this.m_linearImpulse.y*=a.dtRatio,this.m_angularImpulse*=a.dtRatio,a=this.m_linearImpulse,
d.m_linearVelocity.x-=b*a.x,d.m_linearVelocity.y-=b*a.y,d.m_angularVelocity-=k*(f*a.y-g*a.x+this.m_angularImpulse),e.m_linearVelocity.x+=c*a.x,e.m_linearVelocity.y+=c*a.y,e.m_angularVelocity+=m*(h*a.y-l*a.x+this.m_angularImpulse)):(this.m_linearImpulse.SetZero(),this.m_angularImpulse=0)};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.SolveVelocityConstraints=function(a){var b,c=0,d=this.m_bodyA,e=this.m_bodyB,f=d.m_linearVelocity,g=d.m_angularVelocity,h=e.m_linearVelocity,l=e.m_angularVelocity,k=
d.m_invMass,m=e.m_invMass,n=d.m_invI,q=e.m_invI;b=d.m_xf.R;var p=this.m_localAnchorA.x-d.m_sweep.localCenter.x,r=this.m_localAnchorA.y-d.m_sweep.localCenter.y,c=b.col1.x*p+b.col2.x*r,r=b.col1.y*p+b.col2.y*r,p=c;b=e.m_xf.R;var s=this.m_localAnchorB.x-e.m_sweep.localCenter.x,w=this.m_localAnchorB.y-e.m_sweep.localCenter.y,c=b.col1.x*s+b.col2.x*w,w=b.col1.y*s+b.col2.y*w,s=c;b=0;var c=-this.m_angularMass*(l-g),x=this.m_angularImpulse;b=a.dt*this.m_maxTorque;this.m_angularImpulse=Box2D.Common.Math.b2Math.Clamp(this.m_angularImpulse+
c,-b,b);c=this.m_angularImpulse-x;g-=n*c;l+=q*c;b=Box2D.Common.Math.b2Math.MulMV(this.m_linearMass,Box2D.Common.Math.b2Vec2.Get(-(h.x-l*w-f.x+g*r),-(h.y+l*s-f.y-g*p)));c=this.m_linearImpulse.Copy();this.m_linearImpulse.Add(b);b=a.dt*this.m_maxForce;this.m_linearImpulse.LengthSquared()>b*b&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(b));b=Box2D.Common.Math.b2Math.SubtractVV(this.m_linearImpulse,c);f.x-=k*b.x;f.y-=k*b.y;g-=n*(p*b.y-r*b.x);h.x+=m*b.x;h.y+=m*b.y;l+=q*(s*b.y-w*b.x);
d.m_angularVelocity=g;e.m_angularVelocity=l};Box2D.Dynamics.Joints.b2FrictionJoint.prototype.SolvePositionConstraints=function(a){return!0};Box2D.Dynamics.Joints.b2FrictionJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.type=Box2D.Dynamics.Joints.b2Joint.e_frictionJoint;this.maxTorque=this.maxForce=0};c2inherit(Box2D.Dynamics.Joints.b2FrictionJointDef,Box2D.Dynamics.Joints.b2JointDef);
Box2D.Dynamics.Joints.b2FrictionJointDef.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(c))};Box2D.Dynamics.Joints.b2FrictionJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2FrictionJoint(this)};Box2D.Dynamics.Joints.b2GearJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_groundAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_groundAnchor2=Box2D.Common.Math.b2Vec2.Get(0,
0);this.m_localAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor2=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_J=new Box2D.Dynamics.Joints.b2Jacobian;var b=a.joint1.m_type,c=a.joint2.m_type;this.m_prismatic2=this.m_revolute2=this.m_prismatic1=this.m_revolute1=null;var d=0,e=0;this.m_ground1=a.joint1.GetBodyA();this.m_bodyA=a.joint1.GetBodyB();b==Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint?(this.m_revolute1=a.joint1,this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2),
d=this.m_revolute1.GetJointAngle()):(this.m_prismatic1=a.joint1,this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2),d=this.m_prismatic1.GetJointTranslation());this.m_ground2=a.joint2.GetBodyA();this.m_bodyB=a.joint2.GetBodyB();c==Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint?(this.m_revolute2=a.joint2,this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2),e=this.m_revolute2.GetJointAngle()):
(this.m_prismatic2=a.joint2,this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2),e=this.m_prismatic2.GetJointTranslation());this.m_ratio=a.ratio;this.m_constant=d+this.m_ratio*e;this.m_impulse=0};c2inherit(Box2D.Dynamics.Joints.b2GearJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2GearJoint.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};Box2D.Dynamics.Joints.b2GearJoint.prototype.GetAnchorB=
function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};Box2D.Dynamics.Joints.b2GearJoint.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return Box2D.Common.Math.b2Vec2.Get(a*this.m_impulse*this.m_J.linearB.x,a*this.m_impulse*this.m_J.linearB.y)};Box2D.Dynamics.Joints.b2GearJoint.prototype.GetReactionTorque=function(a){void 0===a&&(a=0);var b=this.m_bodyB.m_xf.R,c=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,d=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,
e=b.col1.x*c+b.col2.x*d,d=b.col1.y*c+b.col2.y*d;return a*(this.m_impulse*this.m_J.angularB-e*this.m_impulse*this.m_J.linearB.y+d*this.m_impulse*this.m_J.linearB.x)};Box2D.Dynamics.Joints.b2GearJoint.prototype.GetRatio=function(){return this.m_ratio};Box2D.Dynamics.Joints.b2GearJoint.prototype.SetRatio=function(a){void 0===a&&(a=0);this.m_ratio=a};Box2D.Dynamics.Joints.b2GearJoint.prototype.InitVelocityConstraints=function(a){var b=this.m_ground1,c=this.m_ground2,d=this.m_bodyA,e=this.m_bodyB,f=0,
g=0,h=0,l=0,k=h=0,m=0;this.m_J.SetZero();this.m_revolute1?(this.m_J.angularA=-1,m+=d.m_invI):(b=b.m_xf.R,g=this.m_prismatic1.m_localXAxis1,f=b.col1.x*g.x+b.col2.x*g.y,g=b.col1.y*g.x+b.col2.y*g.y,b=d.m_xf.R,h=this.m_localAnchor1.x-d.m_sweep.localCenter.x,l=this.m_localAnchor1.y-d.m_sweep.localCenter.y,k=b.col1.x*h+b.col2.x*l,l=b.col1.y*h+b.col2.y*l,h=k*g-l*f,this.m_J.linearA.Set(-f,-g),this.m_J.angularA=-h,m+=d.m_invMass+d.m_invI*h*h);this.m_revolute2?(this.m_J.angularB=-this.m_ratio,m+=this.m_ratio*
this.m_ratio*e.m_invI):(b=c.m_xf.R,g=this.m_prismatic2.m_localXAxis1,f=b.col1.x*g.x+b.col2.x*g.y,g=b.col1.y*g.x+b.col2.y*g.y,b=e.m_xf.R,h=this.m_localAnchor2.x-e.m_sweep.localCenter.x,l=this.m_localAnchor2.y-e.m_sweep.localCenter.y,k=b.col1.x*h+b.col2.x*l,l=b.col1.y*h+b.col2.y*l,h=k*g-l*f,this.m_J.linearB.Set(-this.m_ratio*f,-this.m_ratio*g),this.m_J.angularB=-this.m_ratio*h,m+=this.m_ratio*this.m_ratio*(e.m_invMass+e.m_invI*h*h));this.m_mass=0<m?1/m:0;a.warmStarting?(d.m_linearVelocity.x+=d.m_invMass*
this.m_impulse*this.m_J.linearA.x,d.m_linearVelocity.y+=d.m_invMass*this.m_impulse*this.m_J.linearA.y,d.m_angularVelocity+=d.m_invI*this.m_impulse*this.m_J.angularA,e.m_linearVelocity.x+=e.m_invMass*this.m_impulse*this.m_J.linearB.x,e.m_linearVelocity.y+=e.m_invMass*this.m_impulse*this.m_J.linearB.y,e.m_angularVelocity+=e.m_invI*this.m_impulse*this.m_J.angularB):this.m_impulse=0};Box2D.Dynamics.Joints.b2GearJoint.prototype.SolveVelocityConstraints=function(a){a=this.m_bodyA;var b=this.m_bodyB,c=this.m_J.Compute(a.m_linearVelocity,
a.m_angularVelocity,b.m_linearVelocity,b.m_angularVelocity),c=-this.m_mass*c;this.m_impulse+=c;a.m_linearVelocity.x+=a.m_invMass*c*this.m_J.linearA.x;a.m_linearVelocity.y+=a.m_invMass*c*this.m_J.linearA.y;a.m_angularVelocity+=a.m_invI*c*this.m_J.angularA;b.m_linearVelocity.x+=b.m_invMass*c*this.m_J.linearB.x;b.m_linearVelocity.y+=b.m_invMass*c*this.m_J.linearB.y;b.m_angularVelocity+=b.m_invI*c*this.m_J.angularB};Box2D.Dynamics.Joints.b2GearJoint.prototype.SolvePositionConstraints=function(a){a=this.m_bodyA;
var b=this.m_bodyB,c=0,d=0,c=this.m_revolute1?this.m_revolute1.GetJointAngle():this.m_prismatic1.GetJointTranslation(),d=this.m_revolute2?this.m_revolute2.GetJointAngle():this.m_prismatic2.GetJointTranslation(),c=-this.m_mass*(this.m_constant-(c+this.m_ratio*d));a.m_sweep.c.x+=a.m_invMass*c*this.m_J.linearA.x;a.m_sweep.c.y+=a.m_invMass*c*this.m_J.linearA.y;a.m_sweep.a+=a.m_invI*c*this.m_J.angularA;b.m_sweep.c.x+=b.m_invMass*c*this.m_J.linearB.x;b.m_sweep.c.y+=b.m_invMass*c*this.m_J.linearB.y;b.m_sweep.a+=
b.m_invI*c*this.m_J.angularB;a.SynchronizeTransform();b.SynchronizeTransform();return 0<Box2D.Common.b2Settings.b2_linearSlop};Box2D.Dynamics.Joints.b2GearJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.type=Box2D.Dynamics.Joints.b2Joint.e_gearJoint;this.joint2=this.joint1=null;this.ratio=1};c2inherit(Box2D.Dynamics.Joints.b2GearJointDef,Box2D.Dynamics.Joints.b2JointDef);Box2D.Dynamics.Joints.b2GearJointDef.prototype.Initialize=function(a,b,c){this.joint1=a;this.bodyA=a.GetBodyA();
this.joint2=b;this.bodyB=b.GetBodyA();this.ratio=c};Box2D.Dynamics.Joints.b2GearJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2GearJoint(this)};Box2D.Dynamics.Joints.b2Jacobian=function(){this.linearA=Box2D.Common.Math.b2Vec2.Get(0,0);this.linearB=Box2D.Common.Math.b2Vec2.Get(0,0)};Box2D.Dynamics.Joints.b2Jacobian.prototype.SetZero=function(){this.linearA.SetZero();this.angularA=0;this.linearB.SetZero();this.angularB=0};Box2D.Dynamics.Joints.b2Jacobian.prototype.Set=function(a,
b,c,d){void 0===b&&(b=0);void 0===d&&(d=0);this.linearA.SetV(a);this.angularA=b;this.linearB.SetV(c);this.angularB=d};Box2D.Dynamics.Joints.b2Jacobian.prototype.Compute=function(a,b,c,d){void 0===b&&(b=0);void 0===d&&(d=0);return this.linearA.x*a.x+this.linearA.y*a.y+this.angularA*b+(this.linearB.x*c.x+this.linearB.y*c.y)+this.angularB*d};Box2D.Dynamics.Joints.b2LineJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_localAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor2=
Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localXAxis1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localYAxis1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_axis=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_perp=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_K=new Box2D.Common.Math.b2Mat22;this.m_impulse=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_localXAxis1.SetV(a.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;this.m_localYAxis1.y=
this.m_localXAxis1.x;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=a.lowerTranslation;this.m_upperTranslation=a.upperTranslation;this.m_maxMotorForce=a.maxMotorForce;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};c2inherit(Box2D.Dynamics.Joints.b2LineJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2LineJoint.prototype.GetAnchorA=
function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return Box2D.Common.Math.b2Vec2.Get(a*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x),a*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y))};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetReactionTorque=
function(a){void 0===a&&(a=0);return a*this.m_impulse.y};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetJointTranslation=function(){var a=this.m_bodyA,b=this.m_bodyB,c=a.GetWorldPoint(this.m_localAnchor1),d=b.GetWorldPoint(this.m_localAnchor2),b=d.x-c.x,c=d.y-c.y,a=a.GetWorldVector(this.m_localXAxis1);return a.x*b+a.y*c};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetJointSpeed=function(){var a=this.m_bodyA,b=this.m_bodyB,c;c=a.m_xf.R;var d=this.m_localAnchor1.x-a.m_sweep.localCenter.x,e=this.m_localAnchor1.y-
a.m_sweep.localCenter.y,f=c.col1.x*d+c.col2.x*e,e=c.col1.y*d+c.col2.y*e,d=f;c=b.m_xf.R;var g=this.m_localAnchor2.x-b.m_sweep.localCenter.x,h=this.m_localAnchor2.y-b.m_sweep.localCenter.y,f=c.col1.x*g+c.col2.x*h,h=c.col1.y*g+c.col2.y*h,g=f;c=b.m_sweep.c.x+g-(a.m_sweep.c.x+d);var f=b.m_sweep.c.y+h-(a.m_sweep.c.y+e),l=a.GetWorldVector(this.m_localXAxis1),k=a.m_linearVelocity,m=b.m_linearVelocity,a=a.m_angularVelocity,b=b.m_angularVelocity;return c*-a*l.y+f*a*l.x+(l.x*(m.x+-b*h-k.x- -a*e)+l.y*(m.y+b*
g-k.y-a*d))};Box2D.Dynamics.Joints.b2LineJoint.prototype.IsLimitEnabled=function(){return this.m_enableLimit};Box2D.Dynamics.Joints.b2LineJoint.prototype.EnableLimit=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableLimit=a};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetUpperLimit=function(){return this.m_upperTranslation};Box2D.Dynamics.Joints.b2LineJoint.prototype.SetLimits=
function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_lowerTranslation=a;this.m_upperTranslation=b};Box2D.Dynamics.Joints.b2LineJoint.prototype.IsMotorEnabled=function(){return this.m_enableMotor};Box2D.Dynamics.Joints.b2LineJoint.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=a};Box2D.Dynamics.Joints.b2LineJoint.prototype.SetMotorSpeed=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};Box2D.Dynamics.Joints.b2LineJoint.prototype.SetMaxMotorForce=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorForce=a};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetMaxMotorForce=function(){return this.m_maxMotorForce};Box2D.Dynamics.Joints.b2LineJoint.prototype.GetMotorForce=function(){return this.m_motorImpulse};
Box2D.Dynamics.Joints.b2LineJoint.prototype.InitVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,d,e=0;this.m_localCenterA.SetV(b.GetLocalCenter());this.m_localCenterB.SetV(c.GetLocalCenter());var f=b.GetTransform();c.GetTransform();d=b.m_xf.R;var g=this.m_localAnchor1.x-this.m_localCenterA.x,h=this.m_localAnchor1.y-this.m_localCenterA.y,e=d.col1.x*g+d.col2.x*h,h=d.col1.y*g+d.col2.y*h,g=e;d=c.m_xf.R;var l=this.m_localAnchor2.x-this.m_localCenterB.x,k=this.m_localAnchor2.y-this.m_localCenterB.y,
e=d.col1.x*l+d.col2.x*k,k=d.col1.y*l+d.col2.y*k,l=e;d=c.m_sweep.c.x+l-b.m_sweep.c.x-g;e=c.m_sweep.c.y+k-b.m_sweep.c.y-h;this.m_invMassA=b.m_invMass;this.m_invMassB=c.m_invMass;this.m_invIA=b.m_invI;this.m_invIB=c.m_invI;this.m_axis.SetV(Box2D.Common.Math.b2Math.MulMV(f.R,this.m_localXAxis1));this.m_a1=(d+g)*this.m_axis.y-(e+h)*this.m_axis.x;this.m_a2=l*this.m_axis.y-k*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2;this.m_motorMass=
this.m_motorMass>Number.MIN_VALUE?1/this.m_motorMass:0;this.m_perp.SetV(Box2D.Common.Math.b2Math.MulMV(f.R,this.m_localYAxis1));this.m_s1=(d+g)*this.m_perp.y-(e+h)*this.m_perp.x;this.m_s2=l*this.m_perp.y-k*this.m_perp.x;f=this.m_invMassA;g=this.m_invMassB;h=this.m_invIA;l=this.m_invIB;this.m_K.col1.x=f+g+h*this.m_s1*this.m_s1+l*this.m_s2*this.m_s2;this.m_K.col1.y=h*this.m_s1*this.m_a1+l*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=f+g+h*this.m_a1*this.m_a1+l*this.m_a2*this.m_a2;
this.m_enableLimit?(d=this.m_axis.x*d+this.m_axis.y*e,Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*Box2D.Common.b2Settings.b2_linearSlop?this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_equalLimits:d<=this.m_lowerTranslation?this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit&&(this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit,this.m_impulse.y=0):d>=this.m_upperTranslation?this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(this.m_limitState=
Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit,this.m_impulse.y=0):(this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit,this.m_impulse.y=0)):this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit;!1==this.m_enableMotor&&(this.m_motorImpulse=0);a.warmStarting?(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_motorImpulse*=a.dtRatio,a=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x,d=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+
this.m_impulse.y)*this.m_axis.y,e=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1,f=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2,b.m_linearVelocity.x-=this.m_invMassA*a,b.m_linearVelocity.y-=this.m_invMassA*d,b.m_angularVelocity-=this.m_invIA*e,c.m_linearVelocity.x+=this.m_invMassB*a,c.m_linearVelocity.y+=this.m_invMassB*d,c.m_angularVelocity+=this.m_invIB*f):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};Box2D.Dynamics.Joints.b2LineJoint.prototype.SolveVelocityConstraints=
function(a){var b=this.m_bodyA,c=this.m_bodyB,d=b.m_linearVelocity,e=b.m_angularVelocity,f=c.m_linearVelocity,g=c.m_angularVelocity,h=0,l=0,k=0,m=0;this.m_enableMotor&&this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_equalLimits&&(m=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(f.x-d.x)+this.m_axis.y*(f.y-d.y)+this.m_a2*g-this.m_a1*e)),h=this.m_motorImpulse,l=a.dt*this.m_maxMotorForce,this.m_motorImpulse=Box2D.Common.Math.b2Math.Clamp(this.m_motorImpulse+m,-l,l),m=this.m_motorImpulse-h,h=
m*this.m_axis.x,l=m*this.m_axis.y,k=m*this.m_a1,m*=this.m_a2,d.x-=this.m_invMassA*h,d.y-=this.m_invMassA*l,e-=this.m_invIA*k,f.x+=this.m_invMassB*h,f.y+=this.m_invMassB*l,g+=this.m_invIB*m);l=this.m_perp.x*(f.x-d.x)+this.m_perp.y*(f.y-d.y)+this.m_s2*g-this.m_s1*e;this.m_enableLimit&&this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit?(k=this.m_axis.x*(f.x-d.x)+this.m_axis.y*(f.y-d.y)+this.m_a2*g-this.m_a1*e,h=this.m_impulse.Copy(),a=this.m_K.Solve(Box2D.Common.Math.b2Vec2.Get(0,0),-l,
-k),this.m_impulse.Add(a),this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit?this.m_impulse.y=Math.max(this.m_impulse.y,0):this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(this.m_impulse.y=Math.min(this.m_impulse.y,0)),l=-l-(this.m_impulse.y-h.y)*this.m_K.col2.x,k=0,k=0!=this.m_K.col1.x?l/this.m_K.col1.x+h.x:h.x,this.m_impulse.x=k,a.x=this.m_impulse.x-h.x,a.y=this.m_impulse.y-h.y,h=a.x*this.m_perp.x+a.y*this.m_axis.x,l=a.x*this.m_perp.y+a.y*this.m_axis.y,k=a.x*this.m_s1+
a.y*this.m_a1,m=a.x*this.m_s2+a.y*this.m_a2):(a=0,a=0!=this.m_K.col1.x?-l/this.m_K.col1.x:0,this.m_impulse.x+=a,h=a*this.m_perp.x,l=a*this.m_perp.y,k=a*this.m_s1,m=a*this.m_s2);d.x-=this.m_invMassA*h;d.y-=this.m_invMassA*l;e-=this.m_invIA*k;f.x+=this.m_invMassB*h;f.y+=this.m_invMassB*l;g+=this.m_invIB*m;b.m_linearVelocity.SetV(d);b.m_angularVelocity=e;c.m_linearVelocity.SetV(f);c.m_angularVelocity=g};Box2D.Dynamics.Joints.b2LineJoint.prototype.SolvePositionConstraints=function(a){a=this.m_bodyA;var b=
this.m_bodyB,c=a.m_sweep.c,d=a.m_sweep.a,e=b.m_sweep.c,f=b.m_sweep.a,g,h=0,l=0,k=0,m=0,n=g=0,q=0,l=!1,p=0,r=Box2D.Common.Math.b2Mat22.FromAngle(d),k=Box2D.Common.Math.b2Mat22.FromAngle(f);g=r;var q=this.m_localAnchor1.x-this.m_localCenterA.x,s=this.m_localAnchor1.y-this.m_localCenterA.y,h=g.col1.x*q+g.col2.x*s,s=g.col1.y*q+g.col2.y*s,q=h;g=k;k=this.m_localAnchor2.x-this.m_localCenterB.x;m=this.m_localAnchor2.y-this.m_localCenterB.y;h=g.col1.x*k+g.col2.x*m;m=g.col1.y*k+g.col2.y*m;k=h;g=e.x+k-c.x-q;
h=e.y+m-c.y-s;if(this.m_enableLimit){this.m_axis=Box2D.Common.Math.b2Math.MulMV(r,this.m_localXAxis1);this.m_a1=(g+q)*this.m_axis.y-(h+s)*this.m_axis.x;this.m_a2=k*this.m_axis.y-m*this.m_axis.x;var w=this.m_axis.x*g+this.m_axis.y*h;Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*Box2D.Common.b2Settings.b2_linearSlop?(p=Box2D.Common.Math.b2Math.Clamp(w,-Box2D.Common.b2Settings.b2_maxLinearCorrection,Box2D.Common.b2Settings.b2_maxLinearCorrection),n=Math.abs(w),l=!0):w<=this.m_lowerTranslation?
(p=Box2D.Common.Math.b2Math.Clamp(w-this.m_lowerTranslation+Box2D.Common.b2Settings.b2_linearSlop,-Box2D.Common.b2Settings.b2_maxLinearCorrection,0),n=this.m_lowerTranslation-w,l=!0):w>=this.m_upperTranslation&&(p=Box2D.Common.Math.b2Math.Clamp(w-this.m_upperTranslation+Box2D.Common.b2Settings.b2_linearSlop,0,Box2D.Common.b2Settings.b2_maxLinearCorrection),n=w-this.m_upperTranslation,l=!0)}this.m_perp=Box2D.Common.Math.b2Math.MulMV(r,this.m_localYAxis1);this.m_s1=(g+q)*this.m_perp.y-(h+s)*this.m_perp.x;
this.m_s2=k*this.m_perp.y-m*this.m_perp.x;r=Box2D.Common.Math.b2Vec2.Get(0,0);s=this.m_perp.x*g+this.m_perp.y*h;n=Math.max(n,Math.abs(s));q=0;l?(l=this.m_invMassA,k=this.m_invMassB,m=this.m_invIA,g=this.m_invIB,this.m_K.col1.x=l+k+m*this.m_s1*this.m_s1+g*this.m_s2*this.m_s2,this.m_K.col1.y=m*this.m_s1*this.m_a1+g*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=l+k+m*this.m_a1*this.m_a1+g*this.m_a2*this.m_a2,this.m_K.Solve(r,-s,-p)):(l=this.m_invMassA,k=this.m_invMassB,m=this.m_invIA,
g=this.m_invIB,p=l+k+m*this.m_s1*this.m_s1+g*this.m_s2*this.m_s2,r.x=0!=p?-s/p:0,r.y=0);p=r.x*this.m_perp.x+r.y*this.m_axis.x;l=r.x*this.m_perp.y+r.y*this.m_axis.y;s=r.x*this.m_s1+r.y*this.m_a1;r=r.x*this.m_s2+r.y*this.m_a2;c.x-=this.m_invMassA*p;c.y-=this.m_invMassA*l;d-=this.m_invIA*s;e.x+=this.m_invMassB*p;e.y+=this.m_invMassB*l;f+=this.m_invIB*r;a.m_sweep.a=d;b.m_sweep.a=f;a.SynchronizeTransform();b.SynchronizeTransform();return n<=Box2D.Common.b2Settings.b2_linearSlop&&q<=Box2D.Common.b2Settings.b2_angularSlop};
Box2D.Dynamics.Joints.b2LineJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAxisA=Box2D.Common.Math.b2Vec2.Get(0,0);this.type=Box2D.Dynamics.Joints.b2Joint.e_lineJoint;this.localAxisA.Set(1,0);this.enableLimit=!1;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=!1;this.motorSpeed=this.maxMotorForce=0};c2inherit(Box2D.Dynamics.Joints.b2LineJointDef,Box2D.Dynamics.Joints.b2JointDef);
Box2D.Dynamics.Joints.b2LineJointDef.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);this.localAxisA=this.bodyA.GetLocalVector(d)};Box2D.Dynamics.Joints.b2LineJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2LineJoint(this)};Box2D.Dynamics.Joints.b2PrismaticJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_localAnchor1=Box2D.Common.Math.b2Vec2.Get(0,
0);this.m_localAnchor2=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localXAxis1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localYAxis1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_axis=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_perp=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_K=new Box2D.Common.Math.b2Mat33;this.m_impulse=new Box2D.Common.Math.b2Vec3(0,0,0);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_localXAxis1.SetV(a.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;
this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_refAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=a.lowerTranslation;this.m_upperTranslation=a.upperTranslation;this.m_maxMotorForce=a.maxMotorForce;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};c2inherit(Box2D.Dynamics.Joints.b2PrismaticJoint,
Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return Box2D.Common.Math.b2Vec2.Get(a*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),
a*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetReactionTorque=function(a){void 0===a&&(a=0);return a*this.m_impulse.y};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetJointTranslation=function(){var a=this.m_bodyA,b=this.m_bodyB,c=a.GetWorldPoint(this.m_localAnchor1),d=b.GetWorldPoint(this.m_localAnchor2),b=d.x-c.x,c=d.y-c.y,a=a.GetWorldVector(this.m_localXAxis1);return a.x*b+a.y*c};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetJointSpeed=
function(){var a=this.m_bodyA,b=this.m_bodyB,c;c=a.m_xf.R;var d=this.m_localAnchor1.x-a.m_sweep.localCenter.x,e=this.m_localAnchor1.y-a.m_sweep.localCenter.y,f=c.col1.x*d+c.col2.x*e,e=c.col1.y*d+c.col2.y*e,d=f;c=b.m_xf.R;var g=this.m_localAnchor2.x-b.m_sweep.localCenter.x,h=this.m_localAnchor2.y-b.m_sweep.localCenter.y,f=c.col1.x*g+c.col2.x*h,h=c.col1.y*g+c.col2.y*h,g=f;c=b.m_sweep.c.x+g-(a.m_sweep.c.x+d);var f=b.m_sweep.c.y+h-(a.m_sweep.c.y+e),l=a.GetWorldVector(this.m_localXAxis1),k=a.m_linearVelocity,
m=b.m_linearVelocity,a=a.m_angularVelocity,b=b.m_angularVelocity;return c*-a*l.y+f*a*l.x+(l.x*(m.x+-b*h-k.x- -a*e)+l.y*(m.y+b*g-k.y-a*d))};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.IsLimitEnabled=function(){return this.m_enableLimit};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.EnableLimit=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableLimit=a};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetUpperLimit=
function(){return this.m_upperTranslation};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.SetLimits=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_lowerTranslation=a;this.m_upperTranslation=b};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.IsMotorEnabled=function(){return this.m_enableMotor};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=
a};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.SetMotorSpeed=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.SetMaxMotorForce=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorForce=a};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.GetMotorForce=
function(){return this.m_motorImpulse};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.InitVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,d,e=0;this.m_localCenterA.SetV(b.GetLocalCenter());this.m_localCenterB.SetV(c.GetLocalCenter());var f=b.GetTransform();c.GetTransform();d=b.m_xf.R;var g=this.m_localAnchor1.x-this.m_localCenterA.x,h=this.m_localAnchor1.y-this.m_localCenterA.y,e=d.col1.x*g+d.col2.x*h,h=d.col1.y*g+d.col2.y*h,g=e;d=c.m_xf.R;var l=this.m_localAnchor2.x-this.m_localCenterB.x,
k=this.m_localAnchor2.y-this.m_localCenterB.y,e=d.col1.x*l+d.col2.x*k,k=d.col1.y*l+d.col2.y*k,l=e;d=c.m_sweep.c.x+l-b.m_sweep.c.x-g;e=c.m_sweep.c.y+k-b.m_sweep.c.y-h;this.m_invMassA=b.m_invMass;this.m_invMassB=c.m_invMass;this.m_invIA=b.m_invI;this.m_invIB=c.m_invI;this.m_axis.SetV(Box2D.Common.Math.b2Math.MulMV(f.R,this.m_localXAxis1));this.m_a1=(d+g)*this.m_axis.y-(e+h)*this.m_axis.x;this.m_a2=l*this.m_axis.y-k*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*
this.m_a1+this.m_invIB*this.m_a2*this.m_a2;this.m_motorMass>Number.MIN_VALUE&&(this.m_motorMass=1/this.m_motorMass);this.m_perp.SetV(Box2D.Common.Math.b2Math.MulMV(f.R,this.m_localYAxis1));this.m_s1=(d+g)*this.m_perp.y-(e+h)*this.m_perp.x;this.m_s2=l*this.m_perp.y-k*this.m_perp.x;f=this.m_invMassA;g=this.m_invMassB;h=this.m_invIA;l=this.m_invIB;this.m_K.col1.x=f+g+h*this.m_s1*this.m_s1+l*this.m_s2*this.m_s2;this.m_K.col1.y=h*this.m_s1+l*this.m_s2;this.m_K.col1.z=h*this.m_s1*this.m_a1+l*this.m_s2*
this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=h+l;this.m_K.col2.z=h*this.m_a1+l*this.m_a2;this.m_K.col3.x=this.m_K.col1.z;this.m_K.col3.y=this.m_K.col2.z;this.m_K.col3.z=f+g+h*this.m_a1*this.m_a1+l*this.m_a2*this.m_a2;this.m_enableLimit?(d=this.m_axis.x*d+this.m_axis.y*e,Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*Box2D.Common.b2Settings.b2_linearSlop?this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_equalLimits:d<=this.m_lowerTranslation?this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit&&
(this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit,this.m_impulse.z=0):d>=this.m_upperTranslation?this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit,this.m_impulse.z=0)):this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit;!1==this.m_enableMotor&&(this.m_motorImpulse=0);a.warmStarting?(this.m_impulse.x*=a.dtRatio,
this.m_impulse.y*=a.dtRatio,this.m_motorImpulse*=a.dtRatio,a=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x,d=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y,e=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,f=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2,b.m_linearVelocity.x-=this.m_invMassA*a,b.m_linearVelocity.y-=this.m_invMassA*d,
b.m_angularVelocity-=this.m_invIA*e,c.m_linearVelocity.x+=this.m_invMassB*a,c.m_linearVelocity.y+=this.m_invMassB*d,c.m_angularVelocity+=this.m_invIB*f):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.SolveVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,d=b.m_linearVelocity,e=b.m_angularVelocity,f=c.m_linearVelocity,g=c.m_angularVelocity,h=0,l=0,k=0,m=0;this.m_enableMotor&&this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_equalLimits&&
(m=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(f.x-d.x)+this.m_axis.y*(f.y-d.y)+this.m_a2*g-this.m_a1*e)),h=this.m_motorImpulse,a=a.dt*this.m_maxMotorForce,this.m_motorImpulse=Box2D.Common.Math.b2Math.Clamp(this.m_motorImpulse+m,-a,a),m=this.m_motorImpulse-h,h=m*this.m_axis.x,l=m*this.m_axis.y,k=m*this.m_a1,m*=this.m_a2,d.x-=this.m_invMassA*h,d.y-=this.m_invMassA*l,e-=this.m_invIA*k,f.x+=this.m_invMassB*h,f.y+=this.m_invMassB*l,g+=this.m_invIB*m);k=this.m_perp.x*(f.x-d.x)+this.m_perp.y*(f.y-
d.y)+this.m_s2*g-this.m_s1*e;l=g-e;this.m_enableLimit&&this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit?(a=this.m_axis.x*(f.x-d.x)+this.m_axis.y*(f.y-d.y)+this.m_a2*g-this.m_a1*e,h=this.m_impulse.Copy(),a=this.m_K.Solve33(new Box2D.Common.Math.b2Vec3(0,0,0),-k,-l,-a),this.m_impulse.Add(a),this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit?this.m_impulse.z=Math.max(this.m_impulse.z,0):this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(this.m_impulse.z=Math.min(this.m_impulse.z,
0)),k=-k-(this.m_impulse.z-h.z)*this.m_K.col3.x,l=-l-(this.m_impulse.z-h.z)*this.m_K.col3.y,l=this.m_K.Solve22(Box2D.Common.Math.b2Vec2.Get(0,0),k,l),l.x+=h.x,l.y+=h.y,this.m_impulse.x=l.x,this.m_impulse.y=l.y,a.x=this.m_impulse.x-h.x,a.y=this.m_impulse.y-h.y,a.z=this.m_impulse.z-h.z,h=a.x*this.m_perp.x+a.z*this.m_axis.x,l=a.x*this.m_perp.y+a.z*this.m_axis.y,k=a.x*this.m_s1+a.y+a.z*this.m_a1,m=a.x*this.m_s2+a.y+a.z*this.m_a2):(a=this.m_K.Solve22(Box2D.Common.Math.b2Vec2.Get(0,0),-k,-l),this.m_impulse.x+=
a.x,this.m_impulse.y+=a.y,h=a.x*this.m_perp.x,l=a.x*this.m_perp.y,k=a.x*this.m_s1+a.y,m=a.x*this.m_s2+a.y);d.x-=this.m_invMassA*h;d.y-=this.m_invMassA*l;e-=this.m_invIA*k;f.x+=this.m_invMassB*h;f.y+=this.m_invMassB*l;g+=this.m_invIB*m;b.m_linearVelocity.SetV(d);b.m_angularVelocity=e;c.m_linearVelocity.SetV(f);c.m_angularVelocity=g};Box2D.Dynamics.Joints.b2PrismaticJoint.prototype.SolvePositionConstraints=function(a){a=this.m_bodyA;var b=this.m_bodyB,c=a.m_sweep.c,d=a.m_sweep.a,e=b.m_sweep.c,f=b.m_sweep.a,
g,h=0,l=0,k=0,m=h=g=0,n=0,l=!1,q=0,p=Box2D.Common.Math.b2Mat22.FromAngle(d),r=Box2D.Common.Math.b2Mat22.FromAngle(f);g=p;var n=this.m_localAnchor1.x-this.m_localCenterA.x,s=this.m_localAnchor1.y-this.m_localCenterA.y,h=g.col1.x*n+g.col2.x*s,s=g.col1.y*n+g.col2.y*s,n=h;g=r;r=this.m_localAnchor2.x-this.m_localCenterB.x;k=this.m_localAnchor2.y-this.m_localCenterB.y;h=g.col1.x*r+g.col2.x*k;k=g.col1.y*r+g.col2.y*k;r=h;g=e.x+r-c.x-n;h=e.y+k-c.y-s;if(this.m_enableLimit){this.m_axis=Box2D.Common.Math.b2Math.MulMV(p,
this.m_localXAxis1);this.m_a1=(g+n)*this.m_axis.y-(h+s)*this.m_axis.x;this.m_a2=r*this.m_axis.y-k*this.m_axis.x;var w=this.m_axis.x*g+this.m_axis.y*h;Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*Box2D.Common.b2Settings.b2_linearSlop?(q=Box2D.Common.Math.b2Math.Clamp(w,-Box2D.Common.b2Settings.b2_maxLinearCorrection,Box2D.Common.b2Settings.b2_maxLinearCorrection),m=Math.abs(w),l=!0):w<=this.m_lowerTranslation?(q=Box2D.Common.Math.b2Math.Clamp(w-this.m_lowerTranslation+Box2D.Common.b2Settings.b2_linearSlop,
-Box2D.Common.b2Settings.b2_maxLinearCorrection,0),m=this.m_lowerTranslation-w,l=!0):w>=this.m_upperTranslation&&(q=Box2D.Common.Math.b2Math.Clamp(w-this.m_upperTranslation+Box2D.Common.b2Settings.b2_linearSlop,0,Box2D.Common.b2Settings.b2_maxLinearCorrection),m=w-this.m_upperTranslation,l=!0)}this.m_perp=Box2D.Common.Math.b2Math.MulMV(p,this.m_localYAxis1);this.m_s1=(g+n)*this.m_perp.y-(h+s)*this.m_perp.x;this.m_s2=r*this.m_perp.y-k*this.m_perp.x;p=new Box2D.Common.Math.b2Vec3(0,0,0);s=this.m_perp.x*
g+this.m_perp.y*h;r=f-d-this.m_refAngle;m=Math.max(m,Math.abs(s));n=Math.abs(r);l?(l=this.m_invMassA,k=this.m_invMassB,g=this.m_invIA,h=this.m_invIB,this.m_K.col1.x=l+k+g*this.m_s1*this.m_s1+h*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1+h*this.m_s2,this.m_K.col1.z=g*this.m_s1*this.m_a1+h*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=g+h,this.m_K.col2.z=g*this.m_a1+h*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=l+k+g*this.m_a1*
this.m_a1+h*this.m_a2*this.m_a2,this.m_K.Solve33(p,-s,-r,-q)):(l=this.m_invMassA,k=this.m_invMassB,g=this.m_invIA,h=this.m_invIB,q=g*this.m_s1+h*this.m_s2,w=g+h,this.m_K.col1.Set(l+k+g*this.m_s1*this.m_s1+h*this.m_s2*this.m_s2,q,0),this.m_K.col2.Set(q,w,0),q=this.m_K.Solve22(Box2D.Common.Math.b2Vec2.Get(0,0),-s,-r),p.x=q.x,p.y=q.y,p.z=0);q=p.x*this.m_perp.x+p.z*this.m_axis.x;l=p.x*this.m_perp.y+p.z*this.m_axis.y;s=p.x*this.m_s1+p.y+p.z*this.m_a1;p=p.x*this.m_s2+p.y+p.z*this.m_a2;c.x-=this.m_invMassA*
q;c.y-=this.m_invMassA*l;d-=this.m_invIA*s;e.x+=this.m_invMassB*q;e.y+=this.m_invMassB*l;f+=this.m_invIB*p;a.m_sweep.a=d;b.m_sweep.a=f;a.SynchronizeTransform();b.SynchronizeTransform();return m<=Box2D.Common.b2Settings.b2_linearSlop&&n<=Box2D.Common.b2Settings.b2_angularSlop};Box2D.Dynamics.Joints.b2PrismaticJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAxisA=Box2D.Common.Math.b2Vec2.Get(0,
0);this.type=Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint;this.localAxisA.Set(1,0);this.referenceAngle=0;this.enableLimit=!1;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=!1;this.motorSpeed=this.maxMotorForce=0};c2inherit(Box2D.Dynamics.Joints.b2PrismaticJointDef,Box2D.Dynamics.Joints.b2JointDef);Box2D.Dynamics.Joints.b2PrismaticJointDef.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);
this.localAxisA=this.bodyA.GetLocalVector(d);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.Dynamics.Joints.b2PrismaticJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2PrismaticJoint(this)};Box2D.Dynamics.Joints.b2PulleyJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_groundAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_groundAnchor2=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor2=
Box2D.Common.Math.b2Vec2.Get(0,0);this.m_u1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_u2=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_ground=this.m_bodyA.m_world.m_groundBody;this.m_groundAnchor1.x=a.groundAnchorA.x-this.m_ground.m_xf.position.x;this.m_groundAnchor1.y=a.groundAnchorA.y-this.m_ground.m_xf.position.y;this.m_groundAnchor2.x=a.groundAnchorB.x-this.m_ground.m_xf.position.x;this.m_groundAnchor2.y=a.groundAnchorB.y-this.m_ground.m_xf.position.y;this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);
this.m_ratio=a.ratio;this.m_constant=a.lengthA+this.m_ratio*a.lengthB;this.m_maxLength1=Math.min(a.maxLengthA,this.m_constant-this.m_ratio*Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength);this.m_maxLength2=Math.min(a.maxLengthB,(this.m_constant-Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength)/this.m_ratio);this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};c2inherit(Box2D.Dynamics.Joints.b2PulleyJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetAnchorA=
function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return Box2D.Common.Math.b2Vec2.Get(a*this.m_impulse*this.m_u2.x,a*this.m_impulse*this.m_u2.y)};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetReactionTorque=function(a){return 0};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetGroundAnchorA=
function(){var a=this.m_ground.m_xf.position.Copy();a.Add(this.m_groundAnchor1);return a};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetGroundAnchorB=function(){var a=this.m_ground.m_xf.position.Copy();a.Add(this.m_groundAnchor2);return a};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetLength1=function(){var a=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),b=a.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x),a=a.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y);return Math.sqrt(b*
b+a*a)};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetLength2=function(){var a=this.m_bodyB.GetWorldPoint(this.m_localAnchor2),b=a.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor2.x),a=a.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor2.y);return Math.sqrt(b*b+a*a)};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.GetRatio=function(){return this.m_ratio};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.InitVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,d;d=b.m_xf.R;var e=
this.m_localAnchor1.x-b.m_sweep.localCenter.x,f=this.m_localAnchor1.y-b.m_sweep.localCenter.y,g=d.col1.x*e+d.col2.x*f,f=d.col1.y*e+d.col2.y*f,e=g;d=c.m_xf.R;var h=this.m_localAnchor2.x-c.m_sweep.localCenter.x,l=this.m_localAnchor2.y-c.m_sweep.localCenter.y,g=d.col1.x*h+d.col2.x*l,l=d.col1.y*h+d.col2.y*l,h=g;d=c.m_sweep.c.x+h;var g=c.m_sweep.c.y+l,k=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,m=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.Set(b.m_sweep.c.x+e-(this.m_ground.m_xf.position.x+
this.m_groundAnchor1.x),b.m_sweep.c.y+f-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y));this.m_u2.Set(d-k,g-m);d=this.m_u1.Length();g=this.m_u2.Length();d>Box2D.Common.b2Settings.b2_linearSlop?this.m_u1.Multiply(1/d):this.m_u1.SetZero();g>Box2D.Common.b2Settings.b2_linearSlop?this.m_u2.Multiply(1/g):this.m_u2.SetZero();0<this.m_constant-d-this.m_ratio*g?(this.m_state=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit,this.m_impulse=0):this.m_state=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit;d<
this.m_maxLength1?(this.m_limitState1=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit,this.m_limitImpulse1=0):this.m_limitState1=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit;g<this.m_maxLength2?(this.m_limitState2=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit,this.m_limitImpulse2=0):this.m_limitState2=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit;d=e*this.m_u1.y-f*this.m_u1.x;g=h*this.m_u2.y-l*this.m_u2.x;this.m_limitMass1=b.m_invMass+b.m_invI*d*d;this.m_limitMass2=c.m_invMass+c.m_invI*g*g;this.m_pulleyMass=
this.m_limitMass1+this.m_ratio*this.m_ratio*this.m_limitMass2;this.m_limitMass1=1/this.m_limitMass1;this.m_limitMass2=1/this.m_limitMass2;this.m_pulleyMass=1/this.m_pulleyMass;a.warmStarting?(this.m_impulse*=a.dtRatio,this.m_limitImpulse1*=a.dtRatio,this.m_limitImpulse2*=a.dtRatio,a=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.x,d=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.y,g=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.x,k=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*
this.m_u2.y,b.m_linearVelocity.x+=b.m_invMass*a,b.m_linearVelocity.y+=b.m_invMass*d,b.m_angularVelocity+=b.m_invI*(e*d-f*a),c.m_linearVelocity.x+=c.m_invMass*g,c.m_linearVelocity.y+=c.m_invMass*k,c.m_angularVelocity+=c.m_invI*(h*k-l*g)):this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.SolveVelocityConstraints=function(a){a=this.m_bodyA;var b=this.m_bodyB,c;c=a.m_xf.R;var d=this.m_localAnchor1.x-a.m_sweep.localCenter.x,e=this.m_localAnchor1.y-
a.m_sweep.localCenter.y,f=c.col1.x*d+c.col2.x*e,e=c.col1.y*d+c.col2.y*e,d=f;c=b.m_xf.R;var g=this.m_localAnchor2.x-b.m_sweep.localCenter.x,h=this.m_localAnchor2.y-b.m_sweep.localCenter.y,f=c.col1.x*g+c.col2.x*h,h=c.col1.y*g+c.col2.y*h,g=f,l=f=c=0,k=0;c=k=c=k=l=f=c=0;this.m_state==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(c=a.m_linearVelocity.x+-a.m_angularVelocity*e,f=a.m_linearVelocity.y+a.m_angularVelocity*d,l=b.m_linearVelocity.x+-b.m_angularVelocity*h,k=b.m_linearVelocity.y+b.m_angularVelocity*
g,c=-(this.m_u1.x*c+this.m_u1.y*f)-this.m_ratio*(this.m_u2.x*l+this.m_u2.y*k),k=this.m_pulleyMass*-c,c=this.m_impulse,this.m_impulse=Math.max(0,this.m_impulse+k),k=this.m_impulse-c,c=-k*this.m_u1.x,f=-k*this.m_u1.y,l=-this.m_ratio*k*this.m_u2.x,k=-this.m_ratio*k*this.m_u2.y,a.m_linearVelocity.x+=a.m_invMass*c,a.m_linearVelocity.y+=a.m_invMass*f,a.m_angularVelocity+=a.m_invI*(d*f-e*c),b.m_linearVelocity.x+=b.m_invMass*l,b.m_linearVelocity.y+=b.m_invMass*k,b.m_angularVelocity+=b.m_invI*(g*k-h*l));this.m_limitState1==
Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(c=a.m_linearVelocity.x+-a.m_angularVelocity*e,f=a.m_linearVelocity.y+a.m_angularVelocity*d,c=-(this.m_u1.x*c+this.m_u1.y*f),k=-this.m_limitMass1*c,c=this.m_limitImpulse1,this.m_limitImpulse1=Math.max(0,this.m_limitImpulse1+k),k=this.m_limitImpulse1-c,c=-k*this.m_u1.x,f=-k*this.m_u1.y,a.m_linearVelocity.x+=a.m_invMass*c,a.m_linearVelocity.y+=a.m_invMass*f,a.m_angularVelocity+=a.m_invI*(d*f-e*c));this.m_limitState2==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&
(l=b.m_linearVelocity.x+-b.m_angularVelocity*h,k=b.m_linearVelocity.y+b.m_angularVelocity*g,c=-(this.m_u2.x*l+this.m_u2.y*k),k=-this.m_limitMass2*c,c=this.m_limitImpulse2,this.m_limitImpulse2=Math.max(0,this.m_limitImpulse2+k),k=this.m_limitImpulse2-c,l=-k*this.m_u2.x,k=-k*this.m_u2.y,b.m_linearVelocity.x+=b.m_invMass*l,b.m_linearVelocity.y+=b.m_invMass*k,b.m_angularVelocity+=b.m_invI*(g*k-h*l))};Box2D.Dynamics.Joints.b2PulleyJoint.prototype.SolvePositionConstraints=function(a){a=this.m_bodyA;var b=
this.m_bodyB,c,d=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,e=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,f=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,g=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,h=0,l=0,k=0,m=0,n=c=0,q=0,p=0,r=n=p=c=n=c=0;this.m_state==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(c=a.m_xf.R,h=this.m_localAnchor1.x-a.m_sweep.localCenter.x,l=this.m_localAnchor1.y-a.m_sweep.localCenter.y,n=c.col1.x*h+c.col2.x*l,l=c.col1.y*h+c.col2.y*l,h=n,c=
b.m_xf.R,k=this.m_localAnchor2.x-b.m_sweep.localCenter.x,m=this.m_localAnchor2.y-b.m_sweep.localCenter.y,n=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=n,c=a.m_sweep.c.x+h,n=a.m_sweep.c.y+l,q=b.m_sweep.c.x+k,p=b.m_sweep.c.y+m,this.m_u1.Set(c-d,n-e),this.m_u2.Set(q-f,p-g),c=this.m_u1.Length(),n=this.m_u2.Length(),c>Box2D.Common.b2Settings.b2_linearSlop?this.m_u1.Multiply(1/c):this.m_u1.SetZero(),n>Box2D.Common.b2Settings.b2_linearSlop?this.m_u2.Multiply(1/n):this.m_u2.SetZero(),c=this.m_constant-
c-this.m_ratio*n,r=Math.max(r,-c),c=Box2D.Common.Math.b2Math.Clamp(c+Box2D.Common.b2Settings.b2_linearSlop,-Box2D.Common.b2Settings.b2_maxLinearCorrection,0),p=-this.m_pulleyMass*c,c=-p*this.m_u1.x,n=-p*this.m_u1.y,q=-this.m_ratio*p*this.m_u2.x,p=-this.m_ratio*p*this.m_u2.y,a.m_sweep.c.x+=a.m_invMass*c,a.m_sweep.c.y+=a.m_invMass*n,a.m_sweep.a+=a.m_invI*(h*n-l*c),b.m_sweep.c.x+=b.m_invMass*q,b.m_sweep.c.y+=b.m_invMass*p,b.m_sweep.a+=b.m_invI*(k*p-m*q),a.SynchronizeTransform(),b.SynchronizeTransform());
this.m_limitState1==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(c=a.m_xf.R,h=this.m_localAnchor1.x-a.m_sweep.localCenter.x,l=this.m_localAnchor1.y-a.m_sweep.localCenter.y,n=c.col1.x*h+c.col2.x*l,l=c.col1.y*h+c.col2.y*l,h=n,c=a.m_sweep.c.x+h,n=a.m_sweep.c.y+l,this.m_u1.Set(c-d,n-e),c=this.m_u1.Length(),c>Box2D.Common.b2Settings.b2_linearSlop?(this.m_u1.x*=1/c,this.m_u1.y*=1/c):this.m_u1.SetZero(),c=this.m_maxLength1-c,r=Math.max(r,-c),c=Box2D.Common.Math.b2Math.Clamp(c+Box2D.Common.b2Settings.b2_linearSlop,
-Box2D.Common.b2Settings.b2_maxLinearCorrection,0),p=-this.m_limitMass1*c,c=-p*this.m_u1.x,n=-p*this.m_u1.y,a.m_sweep.c.x+=a.m_invMass*c,a.m_sweep.c.y+=a.m_invMass*n,a.m_sweep.a+=a.m_invI*(h*n-l*c),a.SynchronizeTransform());this.m_limitState2==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(c=b.m_xf.R,k=this.m_localAnchor2.x-b.m_sweep.localCenter.x,m=this.m_localAnchor2.y-b.m_sweep.localCenter.y,n=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=n,q=b.m_sweep.c.x+k,p=b.m_sweep.c.y+m,this.m_u2.Set(q-
f,p-g),n=this.m_u2.Length(),n>Box2D.Common.b2Settings.b2_linearSlop?(this.m_u2.x*=1/n,this.m_u2.y*=1/n):this.m_u2.SetZero(),c=this.m_maxLength2-n,r=Math.max(r,-c),c=Box2D.Common.Math.b2Math.Clamp(c+Box2D.Common.b2Settings.b2_linearSlop,-Box2D.Common.b2Settings.b2_maxLinearCorrection,0),p=-this.m_limitMass2*c,q=-p*this.m_u2.x,p=-p*this.m_u2.y,b.m_sweep.c.x+=b.m_invMass*q,b.m_sweep.c.y+=b.m_invMass*p,b.m_sweep.a+=b.m_invI*(k*p-m*q),b.SynchronizeTransform());return r<Box2D.Common.b2Settings.b2_linearSlop};
Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength=1;Box2D.Dynamics.Joints.b2PulleyJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.groundAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.groundAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.type=Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint;this.groundAnchorA.Set(-1,1);this.groundAnchorB.Set(1,1);this.localAnchorA.Set(-1,0);this.localAnchorB.Set(1,
0);this.maxLengthB=this.lengthB=this.maxLengthA=this.lengthA=0;this.ratio=1;this.collideConnected=!0};c2inherit(Box2D.Dynamics.Joints.b2PulleyJointDef,Box2D.Dynamics.Joints.b2JointDef);Box2D.Dynamics.Joints.b2PulleyJointDef.prototype.Initialize=function(a,b,c,d,e,f,g){void 0===g&&(g=0);this.bodyA=a;this.bodyB=b;this.groundAnchorA.SetV(c);this.groundAnchorB.SetV(d);this.localAnchorA=this.bodyA.GetLocalPoint(e);this.localAnchorB=this.bodyB.GetLocalPoint(f);a=e.x-c.x;c=e.y-c.y;this.lengthA=Math.sqrt(a*
a+c*c);c=f.x-d.x;d=f.y-d.y;this.lengthB=Math.sqrt(c*c+d*d);this.ratio=g;g=this.lengthA+this.ratio*this.lengthB;this.maxLengthA=g-this.ratio*Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength;this.maxLengthB=(g-Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength)/this.ratio};Box2D.Dynamics.Joints.b2PulleyJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2PulleyJoint(this)};Box2D.Dynamics.Joints.b2RevoluteJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.K=
new Box2D.Common.Math.b2Mat22;this.K1=new Box2D.Common.Math.b2Mat22;this.K2=new Box2D.Common.Math.b2Mat22;this.K3=new Box2D.Common.Math.b2Mat22;this.impulse3=new Box2D.Common.Math.b2Vec3(0,0,0);this.impulse2=Box2D.Common.Math.b2Vec2.Get(0,0);this.reduced=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor1=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchor2=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_impulse=new Box2D.Common.Math.b2Vec3(0,0,0);this.m_mass=new Box2D.Common.Math.b2Mat33;this.m_localAnchor1.SetV(a.localAnchorA);
this.m_localAnchor2.SetV(a.localAnchorB);this.m_referenceAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=0;this.m_lowerAngle=a.lowerAngle;this.m_upperAngle=a.upperAngle;this.m_maxMotorTorque=a.maxMotorTorque;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit};c2inherit(Box2D.Dynamics.Joints.b2RevoluteJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetAnchorA=
function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return Box2D.Common.Math.b2Vec2.Get(a*this.m_impulse.x,a*this.m_impulse.y)};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetReactionTorque=function(a){void 0===a&&(a=0);return a*this.m_impulse.z};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetJointAngle=
function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.IsLimitEnabled=function(){return this.m_enableLimit};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.EnableLimit=function(a){this.m_enableLimit=a};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetLowerLimit=function(){return this.m_lowerAngle};
Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetUpperLimit=function(){return this.m_upperAngle};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.SetLimits=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_lowerAngle=a;this.m_upperAngle=b};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.IsMotorEnabled=function(){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);return this.m_enableMotor};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.EnableMotor=function(a){this.m_enableMotor=a};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.SetMotorSpeed=
function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.SetMaxMotorTorque=function(a){void 0===a&&(a=0);this.m_maxMotorTorque=a};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.GetMotorTorque=function(){return this.m_maxMotorTorque};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.InitVelocityConstraints=function(a){var b=
this.m_bodyA,c=this.m_bodyB,d,e=0;d=b.m_xf.R;var f=this.m_localAnchor1.x-b.m_sweep.localCenter.x,g=this.m_localAnchor1.y-b.m_sweep.localCenter.y,e=d.col1.x*f+d.col2.x*g,g=d.col1.y*f+d.col2.y*g,f=e;d=c.m_xf.R;var h=this.m_localAnchor2.x-c.m_sweep.localCenter.x,l=this.m_localAnchor2.y-c.m_sweep.localCenter.y,e=d.col1.x*h+d.col2.x*l,l=d.col1.y*h+d.col2.y*l,h=e;d=b.m_invMass;var e=c.m_invMass,k=b.m_invI,m=c.m_invI;this.m_mass.col1.x=d+e+g*g*k+l*l*m;this.m_mass.col2.x=-g*f*k-l*h*m;this.m_mass.col3.x=-g*
k-l*m;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=d+e+f*f*k+h*h*m;this.m_mass.col3.y=f*k+h*m;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=k+m;this.m_motorMass=1/(k+m);this.m_enableMotor||(this.m_motorImpulse=0);if(this.m_enableLimit){var n=c.m_sweep.a-b.m_sweep.a-this.m_referenceAngle;Math.abs(this.m_upperAngle-this.m_lowerAngle)<2*Box2D.Common.b2Settings.b2_angularSlop?this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_equalLimits:n<=
this.m_lowerAngle?(this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit):n>=this.m_upperAngle?(this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit):(this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit;a.warmStarting?
(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_motorImpulse*=a.dtRatio,a=this.m_impulse.x,n=this.m_impulse.y,b.m_linearVelocity.x-=d*a,b.m_linearVelocity.y-=d*n,b.m_angularVelocity-=k*(f*n-g*a+this.m_motorImpulse+this.m_impulse.z),c.m_linearVelocity.x+=e*a,c.m_linearVelocity.y+=e*n,c.m_angularVelocity+=m*(h*n-l*a+this.m_motorImpulse+this.m_impulse.z)):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.SolveVelocityConstraints=function(a){var b=
this.m_bodyA,c=this.m_bodyB,d=0,e=d=0,f=0,g=0,h=0,l=b.m_linearVelocity,k=b.m_angularVelocity,m=c.m_linearVelocity,n=c.m_angularVelocity,q=b.m_invMass,p=c.m_invMass,r=b.m_invI,s=c.m_invI;this.m_enableMotor&&this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_equalLimits&&(e=this.m_motorMass*-(n-k-this.m_motorSpeed),f=this.m_motorImpulse,g=a.dt*this.m_maxMotorTorque,this.m_motorImpulse=Box2D.Common.Math.b2Math.Clamp(this.m_motorImpulse+e,-g,g),e=this.m_motorImpulse-f,k-=r*e,n+=s*e);if(this.m_enableLimit&&
this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit){a=b.m_xf.R;e=this.m_localAnchor1.x-b.m_sweep.localCenter.x;f=this.m_localAnchor1.y-b.m_sweep.localCenter.y;d=a.col1.x*e+a.col2.x*f;f=a.col1.y*e+a.col2.y*f;e=d;a=c.m_xf.R;g=this.m_localAnchor2.x-c.m_sweep.localCenter.x;h=this.m_localAnchor2.y-c.m_sweep.localCenter.y;d=a.col1.x*g+a.col2.x*h;h=a.col1.y*g+a.col2.y*h;g=d;a=m.x+-n*h-l.x- -k*f;var w=m.y+n*g-l.y-k*e;this.m_mass.Solve33(this.impulse3,-a,-w,-(n-k));this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_equalLimits?
this.m_impulse.Add(this.impulse3):this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit?(d=this.m_impulse.z+this.impulse3.z,0>d&&(this.m_mass.Solve22(this.reduced,-a,-w),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)):this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(d=this.m_impulse.z+this.impulse3.z,0<d&&(this.m_mass.Solve22(this.reduced,
-a,-w),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0));l.x-=q*this.impulse3.x;l.y-=q*this.impulse3.y;k-=r*(e*this.impulse3.y-f*this.impulse3.x+this.impulse3.z);m.x+=p*this.impulse3.x;m.y+=p*this.impulse3.y;n+=s*(g*this.impulse3.y-h*this.impulse3.x+this.impulse3.z)}else a=b.m_xf.R,e=this.m_localAnchor1.x-b.m_sweep.localCenter.x,f=this.m_localAnchor1.y-b.m_sweep.localCenter.y,
d=a.col1.x*e+a.col2.x*f,f=a.col1.y*e+a.col2.y*f,e=d,a=c.m_xf.R,g=this.m_localAnchor2.x-c.m_sweep.localCenter.x,h=this.m_localAnchor2.y-c.m_sweep.localCenter.y,d=a.col1.x*g+a.col2.x*h,h=a.col1.y*g+a.col2.y*h,g=d,this.m_mass.Solve22(this.impulse2,-(m.x+-n*h-l.x- -k*f),-(m.y+n*g-l.y-k*e)),this.m_impulse.x+=this.impulse2.x,this.m_impulse.y+=this.impulse2.y,l.x-=q*this.impulse2.x,l.y-=q*this.impulse2.y,k-=r*(e*this.impulse2.y-f*this.impulse2.x),m.x+=p*this.impulse2.x,m.y+=p*this.impulse2.y,n+=s*(g*this.impulse2.y-
h*this.impulse2.x);b.m_linearVelocity.SetV(l);b.m_angularVelocity=k;c.m_linearVelocity.SetV(m);c.m_angularVelocity=n};Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.SolvePositionConstraints=function(a){var b=0,c;a=this.m_bodyA;var d=this.m_bodyB,e=0,f=c=0,g=0,h=0;if(this.m_enableLimit&&this.m_limitState!=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit){var b=d.m_sweep.a-a.m_sweep.a-this.m_referenceAngle,l=0;this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_equalLimits?(b=Box2D.Common.Math.b2Math.Clamp(b-
this.m_lowerAngle,-Box2D.Common.b2Settings.b2_maxAngularCorrection,Box2D.Common.b2Settings.b2_maxAngularCorrection),l=-this.m_motorMass*b,e=Math.abs(b)):this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit?(b-=this.m_lowerAngle,e=-b,b=Box2D.Common.Math.b2Math.Clamp(b+Box2D.Common.b2Settings.b2_angularSlop,-Box2D.Common.b2Settings.b2_maxAngularCorrection,0),l=-this.m_motorMass*b):this.m_limitState==Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit&&(e=b-=this.m_upperAngle,b=Box2D.Common.Math.b2Math.Clamp(b-
Box2D.Common.b2Settings.b2_angularSlop,0,Box2D.Common.b2Settings.b2_maxAngularCorrection),l=-this.m_motorMass*b);a.m_sweep.a-=a.m_invI*l;d.m_sweep.a+=d.m_invI*l;a.SynchronizeTransform();d.SynchronizeTransform()}c=a.m_xf.R;l=this.m_localAnchor1.x-a.m_sweep.localCenter.x;b=this.m_localAnchor1.y-a.m_sweep.localCenter.y;f=c.col1.x*l+c.col2.x*b;b=c.col1.y*l+c.col2.y*b;l=f;c=d.m_xf.R;var k=this.m_localAnchor2.x-d.m_sweep.localCenter.x,m=this.m_localAnchor2.y-d.m_sweep.localCenter.y,f=c.col1.x*k+c.col2.x*
m,m=c.col1.y*k+c.col2.y*m,k=f,g=d.m_sweep.c.x+k-a.m_sweep.c.x-l,h=d.m_sweep.c.y+m-a.m_sweep.c.y-b,n=g*g+h*h;c=Math.sqrt(n);var f=a.m_invMass,q=d.m_invMass,p=a.m_invI,r=d.m_invI,s=10*Box2D.Common.b2Settings.b2_linearSlop;n>s*s&&(n=1/(f+q),g=n*-g,h=n*-h,a.m_sweep.c.x-=0.5*f*g,a.m_sweep.c.y-=0.5*f*h,d.m_sweep.c.x+=0.5*q*g,d.m_sweep.c.y+=0.5*q*h,g=d.m_sweep.c.x+k-a.m_sweep.c.x-l,h=d.m_sweep.c.y+m-a.m_sweep.c.y-b);this.K1.col1.x=f+q;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=f+q;this.K2.col1.x=p*
b*b;this.K2.col2.x=-p*l*b;this.K2.col1.y=-p*l*b;this.K2.col2.y=p*l*l;this.K3.col1.x=r*m*m;this.K3.col2.x=-r*k*m;this.K3.col1.y=-r*k*m;this.K3.col2.y=r*k*k;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.AddM(this.K3);this.K.Solve(Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse,-g,-h);g=Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse.x;h=Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse.y;a.m_sweep.c.x-=a.m_invMass*g;a.m_sweep.c.y-=a.m_invMass*h;a.m_sweep.a-=a.m_invI*(l*h-b*g);d.m_sweep.c.x+=d.m_invMass*
g;d.m_sweep.c.y+=d.m_invMass*h;d.m_sweep.a+=d.m_invI*(k*h-m*g);a.SynchronizeTransform();d.SynchronizeTransform();return c<=Box2D.Common.b2Settings.b2_linearSlop&&e<=Box2D.Common.b2Settings.b2_angularSlop};Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Dynamics.Joints.b2RevoluteJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.type=Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint;
this.localAnchorA.SetZero();this.localAnchorB.SetZero();this.motorSpeed=this.maxMotorTorque=this.upperAngle=this.lowerAngle=this.referenceAngle=0;this.enableMotor=this.enableLimit=!1};c2inherit(Box2D.Dynamics.Joints.b2RevoluteJointDef,Box2D.Dynamics.Joints.b2JointDef);Box2D.Dynamics.Joints.b2RevoluteJointDef.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);this.referenceAngle=this.bodyB.GetAngle()-
this.bodyA.GetAngle()};Box2D.Dynamics.Joints.b2RevoluteJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2RevoluteJoint(this)};Box2D.Dynamics.Joints.b2WeldJoint=function(a){Box2D.Dynamics.Joints.b2Joint.call(this,a);this.m_localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.m_impulse=new Box2D.Common.Math.b2Vec3(0,0,0);this.m_mass=new Box2D.Common.Math.b2Mat33;this.m_localAnchorA.SetV(a.localAnchorA);this.m_localAnchorB.SetV(a.localAnchorB);
this.m_referenceAngle=a.referenceAngle};c2inherit(Box2D.Dynamics.Joints.b2WeldJoint,Box2D.Dynamics.Joints.b2Joint);Box2D.Dynamics.Joints.b2WeldJoint.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};Box2D.Dynamics.Joints.b2WeldJoint.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};Box2D.Dynamics.Joints.b2WeldJoint.prototype.GetReactionForce=function(a){return Box2D.Common.Math.b2Vec2.Get(a*this.m_impulse.x,a*this.m_impulse.y)};
Box2D.Dynamics.Joints.b2WeldJoint.prototype.GetReactionTorque=function(a){return a*this.m_impulse.z};Box2D.Dynamics.Joints.b2WeldJoint.prototype.InitVelocityConstraints=function(a){var b,c=0,d=this.m_bodyA,e=this.m_bodyB;b=d.m_xf.R;var f=this.m_localAnchorA.x-d.m_sweep.localCenter.x,g=this.m_localAnchorA.y-d.m_sweep.localCenter.y,c=b.col1.x*f+b.col2.x*g,g=b.col1.y*f+b.col2.y*g,f=c;b=e.m_xf.R;var h=this.m_localAnchorB.x-e.m_sweep.localCenter.x,l=this.m_localAnchorB.y-e.m_sweep.localCenter.y,c=b.col1.x*
h+b.col2.x*l,l=b.col1.y*h+b.col2.y*l,h=c;b=d.m_invMass;var c=e.m_invMass,k=d.m_invI,m=e.m_invI;this.m_mass.col1.x=b+c+g*g*k+l*l*m;this.m_mass.col2.x=-g*f*k-l*h*m;this.m_mass.col3.x=-g*k-l*m;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=b+c+f*f*k+h*h*m;this.m_mass.col3.y=f*k+h*m;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=k+m;a.warmStarting?(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_impulse.z*=a.dtRatio,d.m_linearVelocity.x-=
b*this.m_impulse.x,d.m_linearVelocity.y-=b*this.m_impulse.y,d.m_angularVelocity-=k*(f*this.m_impulse.y-g*this.m_impulse.x+this.m_impulse.z),e.m_linearVelocity.x+=c*this.m_impulse.x,e.m_linearVelocity.y+=c*this.m_impulse.y,e.m_angularVelocity+=m*(h*this.m_impulse.y-l*this.m_impulse.x+this.m_impulse.z)):this.m_impulse.SetZero()};Box2D.Dynamics.Joints.b2WeldJoint.prototype.SolveVelocityConstraints=function(a){var b,c=0;a=this.m_bodyA;var d=this.m_bodyB,e=a.m_linearVelocity,f=a.m_angularVelocity,g=d.m_linearVelocity,
h=d.m_angularVelocity,l=a.m_invMass,k=d.m_invMass,m=a.m_invI,n=d.m_invI;b=a.m_xf.R;var q=this.m_localAnchorA.x-a.m_sweep.localCenter.x,p=this.m_localAnchorA.y-a.m_sweep.localCenter.y,c=b.col1.x*q+b.col2.x*p,p=b.col1.y*q+b.col2.y*p,q=c;b=d.m_xf.R;var r=this.m_localAnchorB.x-d.m_sweep.localCenter.x,s=this.m_localAnchorB.y-d.m_sweep.localCenter.y,c=b.col1.x*r+b.col2.x*s,s=b.col1.y*r+b.col2.y*s,r=c;b=g.x-h*s-e.x+f*p;var c=g.y+h*r-e.y-f*q,w=h-f,x=new Box2D.Common.Math.b2Vec3(0,0,0);this.m_mass.Solve33(x,
-b,-c,-w);this.m_impulse.Add(x);e.x-=l*x.x;e.y-=l*x.y;f-=m*(q*x.y-p*x.x+x.z);g.x+=k*x.x;g.y+=k*x.y;h+=n*(r*x.y-s*x.x+x.z);a.m_angularVelocity=f;d.m_angularVelocity=h};Box2D.Dynamics.Joints.b2WeldJoint.prototype.SolvePositionConstraints=function(a){var b,c=0;a=this.m_bodyA;var d=this.m_bodyB;b=a.m_xf.R;var e=this.m_localAnchorA.x-a.m_sweep.localCenter.x,f=this.m_localAnchorA.y-a.m_sweep.localCenter.y,c=b.col1.x*e+b.col2.x*f,f=b.col1.y*e+b.col2.y*f,e=c;b=d.m_xf.R;var g=this.m_localAnchorB.x-d.m_sweep.localCenter.x,
h=this.m_localAnchorB.y-d.m_sweep.localCenter.y,c=b.col1.x*g+b.col2.x*h,h=b.col1.y*g+b.col2.y*h,g=c;b=a.m_invMass;var c=d.m_invMass,l=a.m_invI,k=d.m_invI,m=d.m_sweep.c.x+g-a.m_sweep.c.x-e,n=d.m_sweep.c.y+h-a.m_sweep.c.y-f,q=d.m_sweep.a-a.m_sweep.a-this.m_referenceAngle,p=10*Box2D.Common.b2Settings.b2_linearSlop,r=Math.sqrt(m*m+n*n),s=Math.abs(q);r>p&&(l*=1,k*=1);this.m_mass.col1.x=b+c+f*f*l+h*h*k;this.m_mass.col2.x=-f*e*l-h*g*k;this.m_mass.col3.x=-f*l-h*k;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=
b+c+e*e*l+g*g*k;this.m_mass.col3.y=e*l+g*k;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=l+k;p=new Box2D.Common.Math.b2Vec3(0,0,0);this.m_mass.Solve33(p,-m,-n,-q);a.m_sweep.c.x-=b*p.x;a.m_sweep.c.y-=b*p.y;a.m_sweep.a-=l*(e*p.y-f*p.x+p.z);d.m_sweep.c.x+=c*p.x;d.m_sweep.c.y+=c*p.y;d.m_sweep.a+=k*(g*p.y-h*p.x+p.z);a.SynchronizeTransform();d.SynchronizeTransform();return r<=Box2D.Common.b2Settings.b2_linearSlop&&s<=Box2D.Common.b2Settings.b2_angularSlop};
Box2D.Dynamics.Joints.b2WeldJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.call(this);this.localAnchorA=Box2D.Common.Math.b2Vec2.Get(0,0);this.localAnchorB=Box2D.Common.Math.b2Vec2.Get(0,0);this.type=Box2D.Dynamics.Joints.b2Joint.e_weldJoint;this.referenceAngle=0};c2inherit(Box2D.Dynamics.Joints.b2WeldJointDef,Box2D.Dynamics.Joints.b2JointDef);Box2D.Dynamics.Joints.b2WeldJointDef.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));
this.localAnchorB.SetV(this.bodyB.GetLocalPoint(c));this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.Dynamics.Joints.b2WeldJointDef.prototype.Create=function(){return new Box2D.Dynamics.Joints.b2WeldJoint(this)};Box2D.Collision.b2Collision.s_incidentEdge=Box2D.Collision.b2Collision.MakeClipPointVector();Box2D.Collision.b2Collision.s_clipPoints1=Box2D.Collision.b2Collision.MakeClipPointVector();Box2D.Collision.b2Collision.s_clipPoints2=Box2D.Collision.b2Collision.MakeClipPointVector();
Box2D.Collision.b2Collision.s_localTangent=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2Collision.s_localNormal=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2Collision.s_planePoint=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2Collision.s_normal=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2Collision.s_tangent=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2Collision.s_tangent2=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2Collision.s_v11=Box2D.Common.Math.b2Vec2.Get(0,
0);Box2D.Collision.b2Collision.s_v12=Box2D.Common.Math.b2Vec2.Get(0,0);Box2D.Collision.b2TimeOfImpact.b2_toiCalls=0;Box2D.Collision.b2TimeOfImpact.b2_toiIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiRootIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters=0;Box2D.Collision.b2TimeOfImpact.s_cache=new Box2D.Collision.b2SimplexCache;Box2D.Collision.b2TimeOfImpact.s_distanceInput=new Box2D.Collision.b2DistanceInput;Box2D.Collision.b2TimeOfImpact.s_xfA=
new Box2D.Common.Math.b2Transform;Box2D.Collision.b2TimeOfImpact.s_xfB=new Box2D.Common.Math.b2Transform;Box2D.Collision.b2TimeOfImpact.s_fcn=new Box2D.Collision.b2SeparationFunction;Box2D.Collision.b2TimeOfImpact.s_distanceOutput=new Box2D.Collision.b2DistanceOutput;Box2D.Dynamics.b2Body.s_xf1=new Box2D.Common.Math.b2Transform;Box2D.Dynamics.b2ContactListener.b2_defaultListener=new Box2D.Dynamics.b2ContactListener;Box2D.Dynamics.b2ContactManager.s_evalCP=new Box2D.Collision.b2ContactPoint;Box2D.Dynamics.b2World.s_xf=
new Box2D.Common.Math.b2Transform;Box2D.Dynamics.b2World.s_backupA=new Box2D.Common.Math.b2Sweep;Box2D.Dynamics.b2World.s_backupB=new Box2D.Common.Math.b2Sweep;Box2D.Dynamics.Contacts.b2Contact.s_input=new Box2D.Collision.b2TOIInput;Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold=new Box2D.Collision.b2WorldManifold;Box2D.Dynamics.Contacts.b2ContactSolver.s_psm=new Box2D.Dynamics.Contacts.b2PositionSolverManifold}cr.b2Separator=function(){};
cr.b2Separator.det=function(a,b,c,d,e,f){return a*d+c*f+e*b-b*c-d*e-f*a};cr.b2Separator.hitRay=function(a,b,c,d,e,f,g,h){var l=c-a,k=d-b,m=g-e,n=h-f,m=(m*(f-b)-n*(e-a))/(k*m-l*n),l=a+m*l,k=b+m*k;a=cr.b2Separator.isOnSegment(c,d,a,b,l,k);e=cr.b2Separator.isOnSegment(l,k,e,f,g,h);return a&&e?Box2D.Common.Math.b2Vec2.Get(l,k):null};
cr.b2Separator.isOnSegment=function(a,b,c,d,e,f){return(c+0.1>=a&&a>=e-0.1||c-0.1<=a&&a<=e+0.1)&&(d+0.1>=b&&b>=f-0.1||d-0.1<=b&&b<=f+0.1)&&cr.b2Separator.isOnLine(a,b,c,d,e,f)};cr.b2Separator.isOnLine=function(a,b,c,d,e,f){return 0.1<Math.abs(e-c)?0.1>Math.abs((f-d)/(e-c)*(a-c)+d-b):0.1>Math.abs(a-c)};cr.b2Separator.pointsMatch=function(a,b,c,d){return 0.1>Math.abs(c-a)&&0.1>Math.abs(d-b)};
cr.b2Separator.Separate=function(a,b){var c=Box2D.Common.Math.b2Vec2,d=cr.b2Separator.calcShapes(a),e=[],f,g,h,l,k,m,n,q,p;k=0;for(m=d.length;k<m;k++){g=d[k];f=[];f.length=g.length;n=p=0;for(q=g.length;n<q;n++)h=g[n],l=g[(n+1)%q],p+=h.x*l.y-h.y*l.x,f[n]=c.Get(h.x,h.y);p=Math.abs(p/2);p>=0.001*b&&e.push(f)}return e};
cr.b2Separator.calcShapes=function(a){var b=[],c=0,d=0,e=0,f=0,g=0,h=g=0,l=0,k=0,m=0,f=0,n,q,p,r=f=c=0,s=0,e=[],l=[],w=!1,x=[],C=[];for(C.push(a);C.length;){b=C[0];d=b.length;w=!0;for(c=0;c<d;c++)if(k=c,m=c<d-1?c+1:c+1-d,f=c<d-2?c+2:c+2-d,a=b[k],n=b[m],f=b[f],f=cr.b2Separator.det(a.x,a.y,n.x,n.y,f.x,f.y),0>f){w=!1;l=1E9;for(e=0;e<d;e++)e!==k&&e!==m&&(c=e,f=e<d-1?e+1:0,g=b[c],h=b[f],q=cr.b2Separator.hitRay(a.x,a.y,n.x,n.y,g.x,g.y,h.x,h.y))&&(g=n.x-q.x,h=n.y-q.y,g=g*g+h*h,g<l&&(s=c,r=f,p=q,l=g));if(1E9===
l)return[];e=[];l=[];c=s;f=r;g=b[c];h=b[f];cr.b2Separator.pointsMatch(p.x,p.y,h.x,h.y)||e.push(p);cr.b2Separator.pointsMatch(p.x,p.y,g.x,g.y)||l.push(p);s=-1;for(r=k;;){if(r!==f)e.push(b[r]);else{if(0>s||s>=d)return[];cr.b2Separator.isOnSegment(h.x,h.y,b[s].x,b[s].y,a.x,a.y)||e.push(b[r]);break}s=r;0>r-1?r=d-1:r--}e.reverse();s=-1;for(r=m;;){if(r!==c)l.push(b[r]);else{if(0>s||s>=d)return[];r!==c||cr.b2Separator.isOnSegment(g.x,g.y,b[s].x,b[s].y,n.x,n.y)||l.push(b[r]);break}s=r;r+1>d-1?r=0:r++}C.push(e,
l);C.shift();break}w&&x.push(C.shift())}return x};
cr.behaviors.Physics=function(a){for(var b=0;4E3>b;b++)Box2D.Common.Math.b2Vec2._freeCache.push(new Box2D.Common.Math.b2Vec2(0,0));this.runtime=a;this.world=new Box2D.Dynamics.b2World(Box2D.Common.Math.b2Vec2.Get(0,10),!0);this.worldG=10;this.lastUpdateTick=-1;a=new Box2D.Dynamics.b2ContactListener;a.behavior=this;a.BeginContact=function(a){var b=a.m_fixtureA.GetBody().c2userdata;a=a.m_fixtureB.GetBody().c2userdata;this.behavior.runtime.registerCollision(b.inst,a.inst)};this.world.SetContactListener(a);
a=new Box2D.Dynamics.b2ContactFilter;a.behavior=this;a.ShouldCollide=function(a,b){if(this.behavior.allCollisionsEnabled)return!0;var e=a.GetBody().c2userdata.inst.type,f=b.GetBody().c2userdata.inst.type,g=e.extra.Physics_DisabledCollisions;return g&&g.contains(f)?!1:(g=f.extra.Physics_DisabledCollisions)&&g.contains(e)?!1:!0};this.world.SetContactFilter(a);this.steppingMode=0;this.velocityIterations=8;this.positionIterations=3;this.allCollisionsEnabled=!0};
(function(){function a(){}function b(){}function c(a,b,c){c?((c=a.extra.Physics_DisabledCollisions)&&c.remove(b),(c=b.extra.Physics_DisabledCollisions)&&c.remove(a)):(a.extra.Physics_DisabledCollisions||(a.extra.Physics_DisabledCollisions=new cr.ObjectSet),a.extra.Physics_DisabledCollisions.add(b),b.extra.Physics_DisabledCollisions||(b.extra.Physics_DisabledCollisions=new cr.ObjectSet),b.extra.Physics_DisabledCollisions.add(a))}function d(){}var e=Box2D.Common.Math.b2Vec2,f=Box2D.Dynamics.b2BodyDef,
g=Box2D.Dynamics.b2FixtureDef,h=Box2D.Collision.Shapes.b2PolygonShape,l=Box2D.Collision.Shapes.b2CircleShape,k=Box2D.Dynamics.Joints.b2DistanceJointDef,m=Box2D.Dynamics.Joints.b2RevoluteJointDef,n=cr.behaviors.Physics.prototype;n.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};n.Type.prototype.onCreate=function(){};n.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime;this.world=this.behavior.world};var q=n.Instance.prototype;q.onCreate=
function(){this.immovable=0!==this.properties[0];this.collisionmask=this.properties[1];this.preventRotation=0!==this.properties[2];this.density=this.properties[3];this.friction=this.properties[4];this.restitution=this.properties[5];this.linearDamping=this.properties[6];this.angularDamping=this.properties[7];this.bullet=0!==this.properties[8];this.enabled=0!==this.properties[9];this.body=null;this.inst.update_bbox();this.lastKnownX=this.inst.x;this.lastKnownY=this.inst.y;this.lastKnownAngle=this.inst.angle;
this.lastHeight=this.lastWidth=0;this.recreateBody=this.lastTickOverride=!1;this.lastAnimation=null;this.lastAnimationFrame=-1;this.myJoints?(this.myJoints.length=0,this.myCreatedJoints.length=0,this.joiningMe.clear()):(this.myJoints=[],this.myCreatedJoints=[],this.joiningMe=new cr.ObjectSet);var a=this;this.recycled||(this.myDestroyCallback=function(b){a.onInstanceDestroyed(b)});this.runtime.addDestroyCallback(this.myDestroyCallback)};q.postCreate=function(){this.inst.update_bbox();this.createBody();
this.lastAnimation=this.inst.cur_animation;this.lastAnimationFrame=this.inst.cur_frame};q.onDestroy=function(){this.destroyMyJoints();this.myCreatedJoints.length=0;this.joiningMe.clear();this.body&&(this.world.DestroyBody(this.body),this.body=null);this.runtime.removeDestroyCallback(this.myDestroyCallback)};q.saveToJSON=function(){var a={e:this.enabled,im:this.immovable,pr:this.preventRotation,d:this.density,fr:this.friction,re:this.restitution,ld:this.linearDamping,ad:this.angularDamping,b:this.bullet,
mcj:this.myCreatedJoints};if(this.enabled){var b=e.Get(0,0);b.SetV(this.body.GetLinearVelocity());a.vx=b.x;a.vy=b.y;a.om=this.body.GetAngularVelocity()}return a};q.loadFromJSON=function(a){this.destroyMyJoints();this.myCreatedJoints.length=0;this.joiningMe.clear();this.body&&(this.world.DestroyBody(this.body),this.body=null);this.enabled=a.e;this.immovable=a.im;this.preventRotation=a.pr;this.density=a.d;this.friction=a.fr;this.restitution=a.re;this.linearDamping=a.ld;this.angularDamping=a.ad;this.bullet=
a.b;this.lastKnownX=this.inst.x;this.lastKnownY=this.inst.y;this.lastKnownAngle=this.inst.angle;this.lastWidth=this.inst.width;this.lastHeight=this.inst.height;this.enabled&&(this.createBody(),this.body.SetLinearVelocity(e.Get(a.vx,a.vy)),this.body.SetAngularVelocity(a.om),0===a.vx&&0===a.vy&&0===a.om||this.body.SetAwake(!0),this.myCreatedJoints=a.mcj)};q.afterLoad=function(){this.enabled&&this.recreateMyJoints();this.behavior.lastUpdateTick=this.runtime.tickcount-1};q.onInstanceDestroyed=function(a){var b,
c,d,e=a.uid;d=b=0;for(c=this.myCreatedJoints.length;b<c;b++)this.myCreatedJoints[d]=this.myCreatedJoints[b],d<this.myJoints.length&&(this.myJoints[d]=this.myJoints[b]),this.myCreatedJoints[b].params[1]==e?this.world.DestroyJoint(this.myJoints[b]):d++;this.myCreatedJoints.length=d;d<this.myJoints.length&&(this.myJoints.length=d);this.joiningMe.remove(a)};q.destroyMyJoints=function(){var a,b;a=0;for(b=this.myJoints.length;a<b;a++)this.world.DestroyJoint(this.myJoints[a]);this.myJoints.length=0};q.recreateMyJoints=
function(){var a,b,c;a=0;for(b=this.myCreatedJoints.length;a<b;a++)switch(c=this.myCreatedJoints[a],c.type){case 0:this.doCreateDistanceJoint(c.params[0],c.params[1],c.params[2],c.params[3],c.params[4]);break;case 1:this.doCreateRevoluteJoint(c.params[0],c.params[1]);break;case 2:this.doCreateLimitedRevoluteJoint(c.params[0],c.params[1],c.params[2],c.params[3])}};q.destroyBody=function(){this.body&&(this.destroyMyJoints(),this.world.DestroyBody(this.body),this.body=null,this.inst.extra.box2dbody=
null)};q.createBody=function(){if(this.enabled){var a=this.inst,b=!1,c=null,d=null,k,m,n,q,D,v;this.body&&(b=!0,c=e.Get(0,0),c.SetV(this.body.GetLinearVelocity()),d=this.body.GetAngularVelocity(),this.destroyBody());var u=new g;u.density=this.density;u.friction=this.friction;u.restitution=this.restitution;k=new f;k.type=this.immovable?0:2;a.update_bbox();k.position.x=0.02*a.bquad.midX();k.position.y=0.02*a.bquad.midY();k.angle=a.angle;k.fixedRotation=this.preventRotation;k.linearDamping=this.linearDamping;
k.angularDamping=this.angularDamping;k.bullet=this.bullet;v=this.inst.collision_poly&&!this.inst.collision_poly.is_empty();this.body=this.world.CreateBody(k);this.body.c2userdata=this;k=this.collisionmask;v||0!==this.collisionmask||(k=1);m=Math.max(Math.abs(a.width),1);n=Math.max(Math.abs(a.height),1);var z=0>a.width;q=0>a.height;if(0===k){k=a.angle;a.angle=0;a.set_bbox_changed();a.update_bbox();D=a.bquad.midX()-a.x;var A=a.bquad.midY()-a.y;a.angle=k;a.set_bbox_changed();a.collision_poly.cache_poly(z?
-m:m,q?-n:n,0);var B=a.collision_poly.pts_cache,t=a.collision_poly.pts_count;v=[];v.length=t;for(k=0;k<t;k++)v[k]=e.Get(B[2*k]-D,B[2*k+1]-A);z!==q&&v.reverse();z=cr.b2Separator.Separate(v,m*n);for(k=0;k<t;k++)e.Free(v[k]);if(z.length)for(k=0,m=z.length;k<m;k++){v=z[k];n=0;for(q=v.length;n<q;n++)D=v[n],D.x*=0.02,D.y*=0.02;u.shape=new h;u.shape.SetAsArray(v,v.length);this.body.CreateFixture(u);n=0;for(q=v.length;n<q;n++)e.Free(v[n])}else u.shape=new h,u.shape.SetAsBox(0.01*m,0.01*n),this.body.CreateFixture(u)}else 1===
k?(u.shape=new h,u.shape.SetAsBox(0.01*m,0.01*n)):u.shape=new l(0.01*Math.min(m,n)),this.body.CreateFixture(u);a.extra.box2dbody=this.body;this.lastWidth=a.width;this.lastHeight=a.height;if(b)for(this.body.SetLinearVelocity(c),this.body.SetAngularVelocity(d),e.Free(c),this.recreateMyJoints(),v=this.joiningMe.valuesRef(),k=0,m=v.length;k<m;k++)a=v[k].extra.box2dbody.c2userdata,a.destroyMyJoints(),a.recreateMyJoints()}};q.tick=function(){if(this.enabled){var a=this.inst,b;0===this.behavior.steppingMode?
b=this.runtime.timescale/60:(b=this.runtime.getDt(this.inst),b>1/30&&(b=1/30));this.runtime.tickcount>this.behavior.lastUpdateTick&&0<this.runtime.timescale&&(this.world.Step(b,this.behavior.velocityIterations,this.behavior.positionIterations),this.world.ClearForces(),this.behavior.lastUpdateTick=this.runtime.tickcount);if(this.recreateBody||a.width!==this.lastWidth||a.height!==this.lastHeight||a.cur_animation!==this.lastAnimation||a.cur_frame!==this.lastAnimationFrame)this.createBody(),this.recreateBody=
!1,this.lastAnimation=a.cur_animation,this.lastAnimationFrame=a.cur_frame;b=a.angle!==this.lastKnownAngle;if(a.x!==this.lastKnownX||a.y!==this.lastKnownY){a.update_bbox();var c=a.bquad.midX(),d=a.bquad.midY(),f=c-this.lastKnownX,g=d-this.lastKnownY;this.body.SetPosition(e.Get(0.02*c,0.02*d));this.body.SetLinearVelocity(e.Get(f,g));this.lastTickOverride=!0;this.body.SetAwake(!0)}else this.lastTickOverride&&(this.lastTickOverride=!1,this.body.SetLinearVelocity(e.Get(0,0)),this.body.SetPosition(e.Get(0.02*
a.bquad.midX(),0.02*a.bquad.midY())));b&&(this.body.SetAngle(a.angle),this.body.SetAwake(!0));c=this.body.GetPosition();b=c.x/0.02;c=c.y/0.02;d=this.body.GetAngle();if(b!==a.x||c!==a.y||d!==a.angle)if(a.x=b,a.y=c,a.angle=d,a.set_bbox_changed(),a.update_bbox(),b=a.bquad.midX()-a.x,c=a.bquad.midY()-a.y,0!==b||0!==c)a.x-=b,a.y-=c,a.set_bbox_changed();this.lastKnownX=a.x;this.lastKnownY=a.y;this.lastKnownAngle=a.angle}};q.getInstImgPointX=function(a){return-1!==a&&this.inst.getImagePoint?0===a&&this.body?
(this.body.GetPosition().x+this.body.GetLocalCenter().x)/0.02:this.inst.getImagePoint(a,!0):this.inst.x};q.getInstImgPointY=function(a){return-1!==a&&this.inst.getImagePoint?0===a&&this.body?(this.body.GetPosition().y+this.body.GetLocalCenter().y)/0.02:this.inst.getImagePoint(a,!1):this.inst.y};a.prototype.IsSleeping=function(){return this.enabled?!this.body.IsAwake():!1};a.prototype.CompareVelocity=function(a,b,c){if(!this.enabled)return!1;var d=this.body.GetLinearVelocity();0===a?d=d.x/0.02:1===
a?d=d.y/0.02:(a=d.x/0.02,d=d.y/0.02,d=cr.distanceTo(0,0,a,d));return cr.do_cmp(d,b,c)};a.prototype.CompareAngularVelocity=function(a,b){if(!this.enabled)return!1;var c=cr.to_degrees(this.body.GetAngularVelocity());return cr.do_cmp(c,a,b)};a.prototype.CompareMass=function(a,b){if(!this.enabled)return!1;var c=this.body.GetMass()/0.02;return cr.do_cmp(c,a,b)};a.prototype.IsEnabled=function(){return this.enabled};n.cnds=new a;b.prototype.ApplyForce=function(a,b,c){if(this.enabled){var d=this.getInstImgPointX(c);
c=this.getInstImgPointY(c);this.body.ApplyForce(e.Get(a,b),e.Get(0.02*d,0.02*c))}};b.prototype.ApplyForceToward=function(a,b,c,d){if(this.enabled){var f=this.getInstImgPointX(d);d=this.getInstImgPointY(d);b=cr.angleTo(f,d,b,c);this.body.ApplyForce(e.Get(Math.cos(b)*a,Math.sin(b)*a),e.Get(0.02*f,0.02*d))}};b.prototype.ApplyForceAtAngle=function(a,b,c){if(this.enabled){b=cr.to_radians(b);var d=this.getInstImgPointX(c);c=this.getInstImgPointY(c);this.body.ApplyForce(e.Get(Math.cos(b)*a,Math.sin(b)*a),
e.Get(0.02*d,0.02*c))}};b.prototype.ApplyImpulse=function(a,b,c){if(this.enabled){var d=this.getInstImgPointX(c);c=this.getInstImgPointY(c);this.body.ApplyImpulse(e.Get(a,b),e.Get(0.02*d,0.02*c));this.lastTickOverride=!1;this.lastKnownX=this.inst.x;this.lastKnownY=this.inst.y}};b.prototype.ApplyImpulseToward=function(a,b,c,d){if(this.enabled){var f=this.getInstImgPointX(d);d=this.getInstImgPointY(d);b=cr.angleTo(f,d,b,c);this.body.ApplyImpulse(e.Get(Math.cos(b)*a,Math.sin(b)*a),e.Get(0.02*f,0.02*
d));this.lastTickOverride=!1;this.lastKnownX=this.inst.x;this.lastKnownY=this.inst.y}};b.prototype.ApplyImpulseAtAngle=function(a,b,c){if(this.enabled){b=cr.to_radians(b);var d=this.getInstImgPointX(c);c=this.getInstImgPointY(c);this.body.ApplyImpulse(e.Get(Math.cos(b)*a,Math.sin(b)*a),e.Get(0.02*d,0.02*c));this.lastTickOverride=!1;this.lastKnownX=this.inst.x;this.lastKnownY=this.inst.y}};b.prototype.ApplyTorque=function(a){this.enabled&&this.body.ApplyTorque(cr.to_radians(a))};b.prototype.ApplyTorqueToAngle=
function(a,b){this.enabled&&(a=cr.to_radians(a),b=cr.to_radians(b),cr.angleClockwise(this.inst.angle,b)?this.body.ApplyTorque(-a):this.body.ApplyTorque(a))};b.prototype.ApplyTorqueToPosition=function(a,b,c){this.enabled&&(a=cr.to_radians(a),b=cr.angleTo(this.inst.x,this.inst.y,b,c),cr.angleClockwise(this.inst.angle,b)?this.body.ApplyTorque(-a):this.body.ApplyTorque(a))};b.prototype.SetAngularVelocity=function(a){this.enabled&&(this.body.SetAngularVelocity(cr.to_radians(a)),this.body.SetAwake(!0))};
b.prototype.CreateDistanceJoint=function(a,b,c,d,e){b&&this.enabled&&(b=b.getFirstPicked(this.inst))&&b!=this.inst&&b.extra.box2dbody&&(this.myCreatedJoints.push({type:0,params:[a,b.uid,c,d,e]}),this.doCreateDistanceJoint(a,b.uid,c,d,e))};q.doCreateDistanceJoint=function(a,b,c,d,f){if(this.enabled&&(b=this.runtime.getObjectByUID(b))&&b!=this.inst&&b.extra.box2dbody){b.extra.box2dbody.c2userdata.joiningMe.add(this.inst);var g=this.getInstImgPointX(a);a=this.getInstImgPointY(a);var h;b.getImagePoint?
(h=b.getImagePoint(c,!0),c=b.getImagePoint(c,!1)):(h=b.x,c=b.y);var l=g-h,m=a-c,n=new k;n.Initialize(this.body,b.extra.box2dbody,e.Get(0.02*g,0.02*a),e.Get(0.02*h,0.02*c));n.length=0.02*Math.sqrt(l*l+m*m);n.dampingRatio=d;n.frequencyHz=f;this.myJoints.push(this.world.CreateJoint(n))}};b.prototype.CreateRevoluteJoint=function(a,b){if(b&&this.enabled){var c=b.getFirstPicked(this.inst);c&&c!=this.inst&&c.extra.box2dbody&&(this.myCreatedJoints.push({type:1,params:[a,c.uid]}),this.doCreateRevoluteJoint(a,
c.uid))}};q.doCreateRevoluteJoint=function(a,b){if(this.enabled){var c=this.runtime.getObjectByUID(b);if(c&&c!=this.inst&&c.extra.box2dbody){c.extra.box2dbody.c2userdata.joiningMe.add(this.inst);var d=this.getInstImgPointX(a),f=this.getInstImgPointY(a),g=new m;g.Initialize(this.body,c.extra.box2dbody,e.Get(0.02*d,0.02*f));this.myJoints.push(this.world.CreateJoint(g))}}};b.prototype.CreateLimitedRevoluteJoint=function(a,b,c,d){b&&this.enabled&&(b=b.getFirstPicked(this.inst))&&b!=this.inst&&b.extra.box2dbody&&
(this.myCreatedJoints.push({type:2,params:[a,b.uid,c,d]}),this.doCreateLimitedRevoluteJoint(a,b.uid,c,d))};q.doCreateLimitedRevoluteJoint=function(a,b,c,d){if(this.enabled&&(b=this.runtime.getObjectByUID(b))&&b!=this.inst&&b.extra.box2dbody){b.extra.box2dbody.c2userdata.joiningMe.add(this.inst);var f=this.getInstImgPointX(a);a=this.getInstImgPointY(a);var g=new m;g.Initialize(this.body,b.extra.box2dbody,e.Get(0.02*f,0.02*a));g.enableLimit=!0;g.lowerAngle=cr.to_radians(c);g.upperAngle=cr.to_radians(d);
this.myJoints.push(this.world.CreateJoint(g))}};b.prototype.SetWorldGravity=function(a){if(a!==this.behavior.worldG){this.world.SetGravity(e.Get(0,a));this.behavior.worldG=a;var b,c=this.behavior.my_instances.valuesRef();a=0;for(b=c.length;a<b;a++)c[a].extra.box2dbody&&c[a].extra.box2dbody.SetAwake(!0)}};b.prototype.SetSteppingMode=function(a){this.behavior.steppingMode=a};b.prototype.SetIterations=function(a,b){1>a&&(a=1);1>b&&(b=1);this.behavior.velocityIterations=a;this.behavior.positionIterations=
b};b.prototype.SetVelocity=function(a,b){this.enabled&&(this.body.SetLinearVelocity(e.Get(0.02*a,0.02*b)),this.body.SetAwake(!0),this.lastTickOverride=!1,this.lastKnownX=this.inst.x,this.lastKnownY=this.inst.y)};b.prototype.SetDensity=function(a){this.enabled&&this.density!==a&&(this.density=a,this.recreateBody=!0)};b.prototype.SetFriction=function(a){this.enabled&&this.friction!==a&&(this.friction=a,this.recreateBody=!0)};b.prototype.SetElasticity=function(a){this.enabled&&this.restitution!==a&&
(this.restitution=a,this.recreateBody=!0)};b.prototype.SetLinearDamping=function(a){this.enabled&&this.linearDamping!==a&&(this.linearDamping=a,this.body.SetLinearDamping(a))};b.prototype.SetAngularDamping=function(a){this.enabled&&this.angularDamping!==a&&(this.angularDamping=a,this.body.SetAngularDamping(a))};b.prototype.SetImmovable=function(a){this.enabled&&this.immovable!==(0!==a)&&(this.immovable=0!==a,this.body.SetType(this.immovable?0:2),this.body.SetAwake(!0))};b.prototype.EnableCollisions=
function(a,b){if(a&&this.enabled){var d,e;if(a.is_family)for(d=0,e=a.members.length;d<e;d++)c(this.inst.type,a.members[d],0!==b);else c(this.inst.type,a,0!==b);this.behavior.allCollisionsEnabled=!1}};b.prototype.SetPreventRotate=function(a){this.enabled&&this.preventRotation!==(0!==a)&&(this.preventRotation=0!==a,this.body.SetFixedRotation(this.preventRotation),this.body.m_torque=0,this.body.SetAngularVelocity(0),this.body.SetAwake(!0))};b.prototype.SetBullet=function(a){this.enabled&&this.bullet!==
(0!==a)&&(this.bullet=0!==a,this.body.SetBullet(this.bullet),this.body.SetAwake(!0))};b.prototype.RemoveJoints=function(){this.enabled&&(this.destroyMyJoints(),this.myCreatedJoints.length=0,this.joiningMe.clear())};b.prototype.SetEnabled=function(a){this.enabled&&0===a?(this.destroyBody(),this.enabled=!1):this.enabled||1!==a||(this.enabled=!0,this.createBody())};n.acts=new b;d.prototype.VelocityX=function(a){a.set_float(this.enabled?this.body.GetLinearVelocity().x/0.02:0)};d.prototype.VelocityY=function(a){a.set_float(this.enabled?
this.body.GetLinearVelocity().y/0.02:0)};d.prototype.AngularVelocity=function(a){a.set_float(this.enabled?cr.to_degrees(this.body.GetAngularVelocity()):0)};d.prototype.Mass=function(a){a.set_float(this.enabled?this.body.GetMass()/0.02:0)};d.prototype.CenterOfMassX=function(a){a.set_float(this.enabled?(this.body.GetPosition().x+this.body.GetLocalCenter().x)/0.02:0)};d.prototype.CenterOfMassY=function(a){a.set_float(this.enabled?(this.body.GetPosition().y+this.body.GetLocalCenter().y)/0.02:0)};d.prototype.Density=
function(a){a.set_float(this.enabled?this.density:0)};d.prototype.Friction=function(a){a.set_float(this.enabled?this.friction:0)};d.prototype.Elasticity=function(a){a.set_float(this.enabled?this.restitution:0)};d.prototype.LinearDamping=function(a){a.set_float(this.enabled?this.linearDamping:0)};d.prototype.AngularDamping=function(a){a.set_float(this.enabled?this.angularDamping:0)};n.exps=new d})();cr.behaviors.Pin=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(){}var d=cr.behaviors.Pin.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var e=d.Instance.prototype;e.onCreate=function(){this.pinObject=null;this.pinObjectUid=-1;this.mode=this.lastKnownAngle=this.theirStartAngle=this.myStartAngle=this.pinDist=this.pinAngle=0;var a=this;this.recycled||
(this.myDestroyCallback=function(b){a.onInstanceDestroyed(b)});this.runtime.addDestroyCallback(this.myDestroyCallback)};e.saveToJSON=function(){return{uid:this.pinObject?this.pinObject.uid:-1,pa:this.pinAngle,pd:this.pinDist,msa:this.myStartAngle,tsa:this.theirStartAngle,lka:this.lastKnownAngle,m:this.mode}};e.loadFromJSON=function(a){this.pinObjectUid=a.uid;this.pinAngle=a.pa;this.pinDist=a.pd;this.myStartAngle=a.msa;this.theirStartAngle=a.tsa;this.lastKnownAngle=a.lka;this.mode=a.m};e.afterLoad=
function(){this.pinObject=-1===this.pinObjectUid?null:this.runtime.getObjectByUID(this.pinObjectUid);this.pinObjectUid=-1};e.onInstanceDestroyed=function(a){this.pinObject==a&&(this.pinObject=null)};e.onDestroy=function(){this.pinObject=null;this.runtime.removeDestroyCallback(this.myDestroyCallback)};e.tick=function(){};e.tick2=function(){if(this.pinObject){this.lastKnownAngle!==this.inst.angle&&(this.myStartAngle=cr.clamp_angle(this.myStartAngle+(this.inst.angle-this.lastKnownAngle)));var a=this.inst.x,
b=this.inst.y;if(3===this.mode||4===this.mode){var c=cr.distanceTo(this.inst.x,this.inst.y,this.pinObject.x,this.pinObject.y);if(c>this.pinDist||4===this.mode&&c<this.pinDist)b=cr.angleTo(this.pinObject.x,this.pinObject.y,this.inst.x,this.inst.y),a=this.pinObject.x+Math.cos(b)*this.pinDist,b=this.pinObject.y+Math.sin(b)*this.pinDist}else a=this.pinObject.x+Math.cos(this.pinObject.angle+this.pinAngle)*this.pinDist,b=this.pinObject.y+Math.sin(this.pinObject.angle+this.pinAngle)*this.pinDist;this.lastKnownAngle=
c=cr.clamp_angle(this.myStartAngle+(this.pinObject.angle-this.theirStartAngle));0!==this.mode&&1!==this.mode&&3!==this.mode&&4!==this.mode||this.inst.x===a&&this.inst.y===b||(this.inst.x=a,this.inst.y=b,this.inst.set_bbox_changed());0!==this.mode&&2!==this.mode||this.inst.angle===c||(this.inst.angle=c,this.inst.set_bbox_changed())}};a.prototype.IsPinned=function(){return!!this.pinObject};d.cnds=new a;b.prototype.Pin=function(a,b){if(a){var c=a.getFirstPicked(this.inst);c&&(this.pinObject=c,this.pinAngle=
cr.angleTo(c.x,c.y,this.inst.x,this.inst.y)-c.angle,this.pinDist=cr.distanceTo(c.x,c.y,this.inst.x,this.inst.y),this.lastKnownAngle=this.myStartAngle=this.inst.angle,this.theirStartAngle=c.angle,this.mode=b)}};b.prototype.Unpin=function(){this.pinObject=null};d.acts=new b;c.prototype.PinnedUID=function(a){a.set_int(this.pinObject?this.pinObject.uid:-1)};d.exps=new c})();cr.behaviors.Platform=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(){}var d=cr.behaviors.Platform.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime;this.simjump=this.simright=this.simleft=this.ignoreInput=this.jumped=this.jumpkey=this.rightkey=this.leftkey=!1;this.lastFloorObject=null;this.loadFloorObject=-1;this.lastFloorY=this.lastFloorX=0;this.floorIsJumpthru=
!1;this.fallthrough=this.animMode=0;this.firstTick=!0;this.dy=this.dx=0};var e=d.Instance.prototype;e.updateGravity=function(){this.downx=Math.cos(this.ga);this.downy=Math.sin(this.ga);this.rightx=Math.cos(this.ga-Math.PI/2);this.righty=Math.sin(this.ga-Math.PI/2);this.downx=cr.round6dp(this.downx);this.downy=cr.round6dp(this.downy);this.rightx=cr.round6dp(this.rightx);this.righty=cr.round6dp(this.righty);this.g1=this.g;0>this.g&&(this.downx*=-1,this.downy*=-1,this.g=Math.abs(this.g))};e.onCreate=
function(){this.maxspeed=this.properties[0];this.acc=this.properties[1];this.dec=this.properties[2];this.jumpStrength=this.properties[3];this.g1=this.g=this.properties[4];this.maxFall=this.properties[5];this.defaultControls=1===this.properties[6];this.enabled=0!==this.properties[7];this.wasOnFloor=!1;this.wasOverJumpthru=this.runtime.testOverlapJumpThru(this.inst);this.ga=cr.to_radians(90);this.updateGravity();var a=this;this.defaultControls&&!this.runtime.isDomFree&&(jQuery(document).keydown(function(b){a.onKeyDown(b)}),
jQuery(document).keyup(function(b){a.onKeyUp(b)}));this.recycled||(this.myDestroyCallback=function(b){a.onInstanceDestroyed(b)});this.runtime.addDestroyCallback(this.myDestroyCallback)};e.saveToJSON=function(){return{ii:this.ignoreInput,lfx:this.lastFloorX,lfy:this.lastFloorY,lfo:this.lastFloorObject?this.lastFloorObject.uid:-1,am:this.animMode,en:this.enabled,fall:this.fallthrough,ft:this.firstTick,dx:this.dx,dy:this.dy,ms:this.maxspeed,acc:this.acc,dec:this.dec,js:this.jumpStrength,g:this.g,g1:this.g1,
mf:this.maxFall,wof:this.wasOnFloor,woj:this.wasOverJumpthru,ga:this.ga}};e.loadFromJSON=function(a){this.ignoreInput=a.ii;this.lastFloorX=a.lfx;this.lastFloorY=a.lfy;this.loadFloorObject=a.lfo;this.animMode=a.am;this.enabled=a.en;this.fallthrough=a.fall;this.firstTick=a.ft;this.dx=a.dx;this.dy=a.dy;this.maxspeed=a.ms;this.acc=a.acc;this.dec=a.dec;this.jumpStrength=a.js;this.g=a.g;this.g1=a.g1;this.maxFall=a.mf;this.wasOnFloor=a.wof;this.wasOverJumpthru=a.woj;this.ga=a.ga;this.simjump=this.simright=
this.simleft=this.jumped=this.jumpkey=this.rightkey=this.leftkey=!1;this.updateGravity()};e.afterLoad=function(){this.lastFloorObject=-1===this.loadFloorObject?null:this.runtime.getObjectByUID(this.loadFloorObject)};e.onInstanceDestroyed=function(a){this.lastFloorObject==a&&(this.lastFloorObject=null)};e.onDestroy=function(){this.lastFloorObject=null;this.runtime.removeDestroyCallback(this.myDestroyCallback)};e.onKeyDown=function(a){switch(a.which){case 38:a.preventDefault();this.jumpkey=!0;break;
case 37:a.preventDefault();this.leftkey=!0;break;case 39:a.preventDefault(),this.rightkey=!0}};e.onKeyUp=function(a){switch(a.which){case 38:a.preventDefault();this.jumped=this.jumpkey=!1;break;case 37:a.preventDefault();this.leftkey=!1;break;case 39:a.preventDefault(),this.rightkey=!1}};e.getGDir=function(){return 0>this.g?-1:1};e.isOnFloor=function(){var a=null,b=null,c,d;c=this.inst.x;d=this.inst.y;this.inst.x+=this.downx;this.inst.y+=this.downy;this.inst.set_bbox_changed();if(this.lastFloorObject&&
this.runtime.testOverlap(this.inst,this.lastFloorObject))return this.inst.x=c,this.inst.y=d,this.inst.set_bbox_changed(),this.lastFloorObject;(a=this.runtime.testOverlapSolid(this.inst))||0!==this.fallthrough||(b=this.runtime.testOverlapJumpThru(this.inst,!0));this.inst.x=c;this.inst.y=d;this.inst.set_bbox_changed();if(a){if(this.runtime.testOverlap(this.inst,a))return null;this.floorIsJumpthru=!1;return a}if(b&&b.length){d=a=0;for(c=b.length;a<c;a++)b[d]=b[a],this.runtime.testOverlap(this.inst,b[a])||
d++;if(1<=d)return this.floorIsJumpthru=!0,b[0]}return null};e.tick=function(){};e.posttick=function(){var a=this.runtime.getDt(this.inst),b,c,d,e,m,n,q,p,r;this.jumpkey||this.simjump||(this.jumped=!1);var s=this.leftkey||this.simleft;d=this.rightkey||this.simright;var w=(this.jumpkey||this.simjump)&&!this.jumped;this.simjump=this.simright=this.simleft=!1;if(this.enabled){this.ignoreInput&&(w=d=s=!1);p=this.lastFloorObject;r=!1;this.firstTick&&((this.runtime.testOverlapSolid(this.inst)||this.runtime.testOverlapJumpThru(this.inst))&&
this.runtime.pushOutSolid(this.inst,-this.downx,-this.downy,4,!0),this.firstTick=!1);!p||0!==this.dy||p.y===this.lastFloorY&&p.x===this.lastFloorX||(b=p.x-this.lastFloorX,c=p.y-this.lastFloorY,this.inst.x+=b,this.inst.y+=c,this.inst.set_bbox_changed(),this.lastFloorX=p.x,this.lastFloorY=p.y,r=!0,this.runtime.testOverlapSolid(this.inst)&&this.runtime.pushOutSolid(this.inst,-b,-c,2.5*Math.sqrt(b*b+c*c)));var x=this.isOnFloor();if(c=this.runtime.testOverlapSolid(this.inst))if(this.runtime.pushOutSolidNearest(this.inst,
Math.max(this.inst.width,this.inst.height)/2))this.runtime.registerCollision(this.inst,c);else return;x?(0<this.dy&&(this.wasOnFloor||(this.runtime.pushInFractional(this.inst,-this.downx,-this.downy,x,16),this.wasOnFloor=!0),this.dy=0),p!=x?(this.lastFloorObject=x,this.lastFloorX=x.x,this.lastFloorY=x.y,this.runtime.registerCollision(this.inst,x)):r&&(c=this.runtime.testOverlapSolid(this.inst))&&(this.runtime.registerCollision(this.inst,c),0!==b&&(0<b?this.runtime.pushOutSolid(this.inst,-this.rightx,
-this.righty):this.runtime.pushOutSolid(this.inst,this.rightx,this.righty)),this.runtime.pushOutSolid(this.inst,-this.downx,-this.downy)),w&&(p=this.inst.x,r=this.inst.y,this.inst.x-=this.downx,this.inst.y-=this.downy,this.inst.set_bbox_changed(),this.runtime.testOverlapSolid(this.inst)?w=!1:(this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnJump,this.inst),this.animMode=2,this.dy=-this.jumpStrength,this.jumped=!0),this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed())):(this.lastFloorObject=
null,this.dy+=this.g*a,this.dy>this.maxFall&&(this.dy=this.maxFall),w&&(this.jumped=!0));this.wasOnFloor=!!x;s==d&&(0>this.dx?(this.dx+=this.dec*a,0<this.dx&&(this.dx=0)):0<this.dx&&(this.dx-=this.dec*a,0>this.dx&&(this.dx=0)));s&&!d&&(this.dx=0<this.dx?this.dx-(this.acc+this.dec)*a:this.dx-this.acc*a);d&&!s&&(this.dx=0>this.dx?this.dx+(this.acc+this.dec)*a:this.dx+this.acc*a);this.dx>this.maxspeed?this.dx=this.maxspeed:this.dx<-this.maxspeed&&(this.dx=-this.maxspeed);s=!1;0!==this.dx&&(p=this.inst.x,
r=this.inst.y,b=this.dx*a*this.rightx,c=this.dx*a*this.righty,this.inst.x+=this.rightx*(1<this.dx?1:-1)-this.downx,this.inst.y+=this.righty*(1<this.dx?1:-1)-this.downy,this.inst.set_bbox_changed(),e=!1,m=this.runtime.testOverlapSolid(this.inst),this.inst.x=p+b,this.inst.y=r+c,this.inst.set_bbox_changed(),d=this.runtime.testOverlapSolid(this.inst),!d&&x&&(d=this.runtime.testOverlapJumpThru(this.inst))&&(this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed(),this.runtime.testOverlap(this.inst,d)?
(d=null,e=!1):e=!0,this.inst.x=p+b,this.inst.y=r+c,this.inst.set_bbox_changed()),d?(b=Math.abs(this.dx*a)+2,m||!this.runtime.pushOutSolid(this.inst,-this.downx,-this.downy,b,e,d))?(this.runtime.registerCollision(this.inst,d),b=Math.max(Math.abs(2.5*this.dx*a),30),this.runtime.pushOutSolid(this.inst,this.rightx*(0>this.dx?1:-1),this.righty*(0>this.dx?1:-1),b,!1)?!x||e||this.floorIsJumpthru||(p=this.inst.x,r=this.inst.y,this.inst.x+=this.downx,this.inst.y+=this.downy,this.runtime.testOverlapSolid(this.inst)?
this.runtime.pushOutSolid(this.inst,-this.downx,-this.downy,3,!1)||(this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed()):(this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed())):(this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed()),e||(this.dx=0)):!m&&15>Math.abs(this.dy)&&(this.dy=0,x||(s=!0)):(p=this.isOnFloor(),x&&!p?(c=Math.ceil(Math.abs(this.dx*a))+2,p=this.inst.x,r=this.inst.y,this.inst.x+=this.downx*c,this.inst.y+=this.downy*c,this.inst.set_bbox_changed(),this.runtime.testOverlapSolid(this.inst)||
this.runtime.testOverlapJumpThru(this.inst)?this.runtime.pushOutSolid(this.inst,-this.downx,-this.downy,c+2,!0):(this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed())):p&&0===this.dy&&this.runtime.pushInFractional(this.inst,-this.downx,-this.downy,p,16)));if(0!==this.dy){p=this.inst.x;r=this.inst.y;this.inst.x+=this.dy*a*this.downx;this.inst.y+=this.dy*a*this.downy;b=this.inst.x;d=this.inst.y;this.inst.set_bbox_changed();c=this.runtime.testOverlapSolid(this.inst);e=!1;if(!c&&0<this.dy&&!x){if((e=
0<this.fallthrough?null:this.runtime.testOverlapJumpThru(this.inst,!0))&&e.length){if(this.wasOverJumpthru){this.inst.x=p;this.inst.y=r;this.inst.set_bbox_changed();q=m=0;for(n=e.length;m<n;m++)e[q]=e[m],this.runtime.testOverlap(this.inst,e[m])||q++;e.length=q;this.inst.x=b;this.inst.y=d;this.inst.set_bbox_changed()}1<=e.length&&(c=e[0])}e=!!c}c&&(this.runtime.registerCollision(this.inst,c),b=e?Math.abs(2.5*this.dy*a+10):Math.max(Math.abs(2.5*this.dy*a+10),30),this.runtime.pushOutSolid(this.inst,
this.downx*(0>this.dy?1:-1),this.downy*(0>this.dy?1:-1),b,e,c)?(this.lastFloorObject=c,this.lastFloorX=c.x,this.lastFloorY=c.y,(this.floorIsJumpthru=e)&&(s=!0),this.dy=0):(this.inst.x=p,this.inst.y=r,this.inst.set_bbox_changed(),this.wasOnFloor=!0,e||(this.dy=0)))}3!==this.animMode&&0<this.dy&&!x&&(this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnFall,this.inst),this.animMode=3);if(x||s)3===this.animMode||s||w&&0===this.dy?(this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnLand,
this.inst),this.animMode=0===this.dx&&0===this.dy?0:1):(0!==this.animMode&&0===this.dx&&0===this.dy&&(this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnStop,this.inst),this.animMode=0),1===this.animMode||0===this.dx&&0===this.dy||w||(this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnMove,this.inst),this.animMode=1));0<this.fallthrough&&this.fallthrough--;this.wasOverJumpthru=this.runtime.testOverlapJumpThru(this.inst)}};a.prototype.IsMoving=function(){return 0!==this.dx||0!==this.dy};
a.prototype.CompareSpeed=function(a,b){var c=Math.sqrt(this.dx*this.dx+this.dy*this.dy);return cr.do_cmp(c,a,b)};a.prototype.IsOnFloor=function(){if(0!==this.dy)return!1;var a=null,b=null,c,d;c=this.inst.x;d=this.inst.y;this.inst.x+=this.downx;this.inst.y+=this.downy;this.inst.set_bbox_changed();(a=this.runtime.testOverlapSolid(this.inst))||0!==this.fallthrough||(b=this.runtime.testOverlapJumpThru(this.inst,!0));this.inst.x=c;this.inst.y=d;this.inst.set_bbox_changed();if(a)return!this.runtime.testOverlap(this.inst,
a);if(b&&b.length){d=a=0;for(c=b.length;a<c;a++)b[d]=b[a],this.runtime.testOverlap(this.inst,b[a])||d++;if(1<=d)return!0}return!1};a.prototype.IsByWall=function(a){var b=!1,c=this.inst.x,d=this.inst.y;this.inst.x-=3*this.downx;this.inst.y-=3*this.downy;this.inst.set_bbox_changed();if(this.runtime.testOverlapSolid(this.inst))return this.inst.x=c,this.inst.y=d,this.inst.set_bbox_changed(),!1;0===a?(this.inst.x-=2*this.rightx,this.inst.y-=2*this.righty):(this.inst.x+=2*this.rightx,this.inst.y+=2*this.righty);
this.inst.set_bbox_changed();b=this.runtime.testOverlapSolid(this.inst);this.inst.x=c;this.inst.y=d;this.inst.set_bbox_changed();return b};a.prototype.IsJumping=function(){return 0>this.dy};a.prototype.IsFalling=function(){return 0<this.dy};a.prototype.OnJump=function(){return!0};a.prototype.OnFall=function(){return!0};a.prototype.OnStop=function(){return!0};a.prototype.OnMove=function(){return!0};a.prototype.OnLand=function(){return!0};d.cnds=new a;b.prototype.SetIgnoreInput=function(a){this.ignoreInput=
a};b.prototype.SetMaxSpeed=function(a){this.maxspeed=a;0>this.maxspeed&&(this.maxspeed=0)};b.prototype.SetAcceleration=function(a){this.acc=a;0>this.acc&&(this.acc=0)};b.prototype.SetDeceleration=function(a){this.dec=a;0>this.dec&&(this.dec=0)};b.prototype.SetJumpStrength=function(a){this.jumpStrength=a;0>this.jumpStrength&&(this.jumpStrength=0)};b.prototype.SetGravity=function(a){this.g1!==a&&(this.g=a,this.updateGravity(),this.runtime.testOverlapSolid(this.inst)&&(this.runtime.pushOutSolid(this.inst,
this.downx,this.downy,10),this.inst.x+=2*this.downx,this.inst.y+=2*this.downy,this.inst.set_bbox_changed()),this.lastFloorObject=null)};b.prototype.SetMaxFallSpeed=function(a){this.maxFall=a;0>this.maxFall&&(this.maxFall=0)};b.prototype.SimulateControl=function(a){switch(a){case 0:this.simleft=!0;break;case 1:this.simright=!0;break;case 2:this.simjump=!0}};b.prototype.SetVectorX=function(a){this.dx=a};b.prototype.SetVectorY=function(a){this.dy=a};b.prototype.SetGravityAngle=function(a){a=cr.to_radians(a);
a=cr.clamp_angle(a);this.ga!==a&&(this.ga=a,this.updateGravity(),this.lastFloorObject=null)};b.prototype.SetEnabled=function(a){this.enabled=1===a};b.prototype.FallThrough=function(){var a=this.inst.x,b=this.inst.y;this.inst.x+=this.downx;this.inst.y+=this.downy;this.inst.set_bbox_changed();var c=this.runtime.testOverlapJumpThru(this.inst,!1);this.inst.x=a;this.inst.y=b;this.inst.set_bbox_changed();c&&(this.fallthrough=3,this.lastFloorObject=null)};d.acts=new b;c.prototype.Speed=function(a){a.set_float(Math.sqrt(this.dx*
this.dx+this.dy*this.dy))};c.prototype.MaxSpeed=function(a){a.set_float(this.maxspeed)};c.prototype.Acceleration=function(a){a.set_float(this.acc)};c.prototype.Deceleration=function(a){a.set_float(this.dec)};c.prototype.JumpStrength=function(a){a.set_float(this.jumpStrength)};c.prototype.Gravity=function(a){a.set_float(this.g)};c.prototype.GravityAngle=function(a){a.set_float(cr.to_degrees(this.ga))};c.prototype.MaxFallSpeed=function(a){a.set_float(this.maxFall)};c.prototype.MovingAngle=function(a){a.set_float(cr.to_degrees(Math.atan2(this.dy,
this.dx)))};c.prototype.VectorX=function(a){a.set_float(this.dx)};c.prototype.VectorY=function(a){a.set_float(this.dy)};d.exps=new c})();cr.behaviors.Rex_MoveTo=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(){}var d=cr.behaviors.Rex_MoveTo.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var e=d.Instance.prototype;e.onCreate=function(){this.activated=1==this.properties[0];this.move={max:this.properties[1],acc:this.properties[2],dec:this.properties[3]};this.target={x:0,y:0,a:0};this.is_moving=
!1;this.remain_distance=this.current_speed=0;this.is_hit_target=!1;this._pre_pos={x:0,y:0};this._moving_angle_info={x:0,y:0,a:-1};this._last_tick=null;this.is_my_call=!1};e.tick=function(){this.is_hit_target&&(this.is_my_call=!0,this.runtime.trigger(cr.behaviors.Rex_MoveTo.prototype.cnds.OnHitTarget,this.inst),this.is_hit_target=this.is_my_call=!1);if(this.activated&&this.is_moving){var a=this.runtime.getDt(this.inst);if(0!=a){this._pre_pos.x==this.inst.x&&this._pre_pos.y==this.inst.y||this._reset_current_pos();
var b=!1;0!=this.move.dec&&(b=this.current_speed,b=b*b/(2*this.move.dec)>=this.remain_distance);b=b?-this.move.dec:this.move.acc;0!=b&&this.SetCurrentSpeed(this.current_speed+b*a);a*=this.current_speed;this.remain_distance-=a;0>=this.remain_distance||0>=this.current_speed?(this.is_moving=!1,this.inst.x=this.target.x,this.inst.y=this.target.y,this.SetCurrentSpeed(0),this.moving_angle_get(),this.is_hit_target=!0):(b=this.target.a,this.inst.x+=a*Math.cos(b),this.inst.y+=a*Math.sin(b));this.inst.set_bbox_changed();
this._pre_pos.x=this.inst.x;this._pre_pos.y=this.inst.y}}};e.tick2=function(){this._moving_angle_info.x=this.inst.x;this._moving_angle_info.y=this.inst.y};e.SetCurrentSpeed=function(a){null!=a?this.current_speed=a>this.move.max?this.move.max:a:0==this.move.acc&&(this.current_speed=this.move.max)};e._reset_current_pos=function(){var a=this.target.x-this.inst.x,b=this.target.y-this.inst.y;this.target.a=Math.atan2(b,a);this.remain_distance=Math.sqrt(a*a+b*b);this._pre_pos.x=this.inst.x;this._pre_pos.y=
this.inst.y};e.SetTargetPos=function(a,b){this.is_moving=!0;this.target.x=a;this.target.y=b;this._reset_current_pos();this.SetCurrentSpeed(null);this._moving_angle_info.x=this.inst.x;this._moving_angle_info.y=this.inst.y};e.is_tick_changed=function(){var a=this.runtime.tickcount,b=this._last_tick!=a;this._last_tick=a;return b};e.moving_angle_get=function(a){if(this.is_tick_changed()){a=this.inst.x-this._moving_angle_info.x;var b=this.inst.y-this._moving_angle_info.y;if(0!=a||0!=b)this._moving_angle_info.a=
cr.to_clamped_degrees(Math.atan2(b,a))}return this._moving_angle_info.a};e.saveToJSON=function(){return{en:this.activated,v:this.move,t:this.target,is_m:this.is_moving,c_spd:this.current_speed,rd:this.remain_distance,is_ht:this.is_hit_target,pp:this._pre_pos,ma:this._moving_angle_info,lt:this._last_tick}};e.loadFromJSON=function(a){this.activated=a.en;this.move=a.v;this.target=a.t;this.is_moving=a.is_m;this.current_speed=a.c_spd;this.remain_distance=a.rd;this.is_hit_target=a.is_ht;this._pre_pos=a.pp;
this._moving_angle_info=a.ma;this._last_tick=a.lt};d.cnds=new a;a.prototype.OnHitTarget=function(){return this.is_my_call};a.prototype.CompareSpeed=function(a,b){return cr.do_cmp(this.current_speed,a,b)};a.prototype.OnMoving=function(){return!1};a.prototype.IsMoving=function(){return this.activated&&this.is_moving};a.prototype.CompareMovingAngle=function(a,b){return-1!=this.moving_angle_get()?cr.do_cmp(this.moving_angle_get(),a,b):!1};d.acts=new b;b.prototype.SetActivated=function(a){this.activated=
1==a};b.prototype.SetMaxSpeed=function(a){this.move.max=a;this.SetCurrentSpeed(null)};b.prototype.SetAcceleration=function(a){this.move.acc=a;this.SetCurrentSpeed(null)};b.prototype.SetDeceleration=function(a){this.move.dec=a};b.prototype.SetTargetPos=function(a,b){this.SetTargetPos(a,b)};b.prototype.SetCurrentSpeed=function(a){this.SetCurrentSpeed(a)};b.prototype.SetTargetPosOnObject=function(a){a&&(a=a.getFirstPicked(),null!=a&&this.SetTargetPos(a.x,a.y))};b.prototype.SetTargetPosByDeltaXY=function(a,
b){this.SetTargetPos(this.inst.x+a,this.inst.y+b)};b.prototype.SetTargetPosByDistanceAngle=function(a,b){var c=cr.to_clamped_radians(b),d=a*Math.cos(c),c=a*Math.sin(c);this.SetTargetPos(this.inst.x+d,this.inst.y+c)};b.prototype.Stop=function(){this.is_moving=!1};d.exps=new c;c.prototype.Activated=function(a){a.set_int(this.activated?1:0)};c.prototype.Speed=function(a){a.set_float(this.current_speed)};c.prototype.MaxSpeed=function(a){a.set_float(this.move.max)};c.prototype.Acc=function(a){a.set_float(this.move.acc)};
c.prototype.Dec=function(a){a.set_float(this.move.dec)};c.prototype.TargetX=function(a){a.set_float(this.target.x)};c.prototype.TargetY=function(a){a.set_float(this.target.y)};c.prototype.MovingAngle=function(a){a.set_float(this.moving_angle_get())}})();cr.behaviors.Sin=function(a){this.runtime=a};
(function(){function a(){}function b(){}function c(){}var d=cr.behaviors.Sin.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime;this.i=0};var e=d.Instance.prototype,f=2*Math.PI,g=Math.PI/2,h=3*Math.PI/2;e.onCreate=function(){this.active=1===this.properties[0];this.movement=this.properties[1];this.wave=this.properties[2];this.period=
this.properties[3];this.period+=Math.random()*this.properties[4];0===this.period?this.i=0:(this.i=this.properties[5]/this.period*f,this.i+=Math.random()*this.properties[6]/this.period*f);this.mag=this.properties[7];this.mag+=Math.random()*this.properties[8];this.ratio=this.initialValue2=this.initialValue=0;this.init()};e.saveToJSON=function(){return{i:this.i,a:this.active,mv:this.movement,w:this.wave,p:this.period,mag:this.mag,iv:this.initialValue,iv2:this.initialValue2,r:this.ratio,lkv:this.lastKnownValue,
lkv2:this.lastKnownValue2}};e.loadFromJSON=function(a){this.i=a.i;this.active=a.a;this.movement=a.mv;this.wave=a.w;this.period=a.p;this.mag=a.mag;this.initialValue=a.iv;this.initialValue2=a.iv2||0;this.ratio=a.r;this.lastKnownValue=a.lkv;this.lastKnownValue2=a.lkv2||0};e.init=function(){switch(this.movement){case 0:this.initialValue=this.inst.x;break;case 1:this.initialValue=this.inst.y;break;case 2:this.initialValue=this.inst.width;this.ratio=this.inst.height/this.inst.width;break;case 3:this.initialValue=
this.inst.width;break;case 4:this.initialValue=this.inst.height;break;case 5:this.initialValue=this.inst.angle;this.mag=cr.to_radians(this.mag);break;case 6:this.initialValue=this.inst.opacity;break;case 7:this.initialValue=0;break;case 8:this.initialValue=this.inst.x,this.initialValue2=this.inst.y}this.lastKnownValue=this.initialValue;this.lastKnownValue2=this.initialValue2};e.waveFunc=function(a){a%=f;switch(this.wave){case 0:return Math.sin(a);case 1:return a<=g?a/g:a<=h?1-2*(a-g)/Math.PI:(a-h)/
g-1;case 2:return 2*a/f-1;case 3:return-2*a/f+1;case 4:return a<Math.PI?-1:1}return 0};e.tick=function(){var a=this.runtime.getDt(this.inst);if(this.active&&0!==a){0===this.period?this.i=0:(this.i+=a/this.period*f,this.i%=f);switch(this.movement){case 0:this.inst.x!==this.lastKnownValue&&(this.initialValue+=this.inst.x-this.lastKnownValue);this.inst.x=this.initialValue+this.waveFunc(this.i)*this.mag;this.lastKnownValue=this.inst.x;break;case 1:this.inst.y!==this.lastKnownValue&&(this.initialValue+=
this.inst.y-this.lastKnownValue);this.inst.y=this.initialValue+this.waveFunc(this.i)*this.mag;this.lastKnownValue=this.inst.y;break;case 2:this.inst.width=this.initialValue+this.waveFunc(this.i)*this.mag;this.inst.height=this.inst.width*this.ratio;break;case 3:this.inst.width=this.initialValue+this.waveFunc(this.i)*this.mag;break;case 4:this.inst.height=this.initialValue+this.waveFunc(this.i)*this.mag;break;case 5:this.inst.angle!==this.lastKnownValue&&(this.initialValue=cr.clamp_angle(this.initialValue+
(this.inst.angle-this.lastKnownValue)));this.inst.angle=cr.clamp_angle(this.initialValue+this.waveFunc(this.i)*this.mag);this.lastKnownValue=this.inst.angle;break;case 6:this.inst.opacity=this.initialValue+this.waveFunc(this.i)*this.mag/100;0>this.inst.opacity?this.inst.opacity=0:1<this.inst.opacity&&(this.inst.opacity=1);break;case 8:this.inst.x!==this.lastKnownValue&&(this.initialValue+=this.inst.x-this.lastKnownValue),this.inst.y!==this.lastKnownValue2&&(this.initialValue2+=this.inst.y-this.lastKnownValue2),
this.inst.x=this.initialValue+Math.cos(this.inst.angle)*this.waveFunc(this.i)*this.mag,this.inst.y=this.initialValue2+Math.sin(this.inst.angle)*this.waveFunc(this.i)*this.mag,this.lastKnownValue=this.inst.x,this.lastKnownValue2=this.inst.y}this.inst.set_bbox_changed()}};e.onSpriteFrameChanged=function(a,b){switch(this.movement){case 2:this.initialValue*=b.width/a.width;this.ratio=b.height/b.width;break;case 3:this.initialValue*=b.width/a.width;break;case 4:this.initialValue*=b.height/a.height}};a.prototype.IsActive=
function(){return this.active};a.prototype.CompareMovement=function(a){return this.movement===a};a.prototype.ComparePeriod=function(a,b){return cr.do_cmp(this.period,a,b)};a.prototype.CompareMagnitude=function(a,b){return 5===this.movement?cr.do_cmp(this.mag,a,cr.to_radians(b)):cr.do_cmp(this.mag,a,b)};a.prototype.CompareWave=function(a){return this.wave===a};d.cnds=new a;b.prototype.SetActive=function(a){this.active=1===a};b.prototype.SetPeriod=function(a){this.period=a};b.prototype.SetMagnitude=
function(a){this.mag=a;5===this.movement&&(this.mag=cr.to_radians(this.mag))};b.prototype.SetMovement=function(a){5===this.movement&&(this.mag=cr.to_degrees(this.mag));this.movement=a;this.init()};b.prototype.SetWave=function(a){this.wave=a};d.acts=new b;c.prototype.CyclePosition=function(a){a.set_float(this.i/f)};c.prototype.Period=function(a){a.set_float(this.period)};c.prototype.Magnitude=function(a){5===this.movement?a.set_float(cr.to_degrees(this.mag)):a.set_float(this.mag)};c.prototype.Value=
function(a){a.set_float(this.waveFunc(this.i)*this.mag)};d.exps=new c})();cr.behaviors.jumpthru=function(a){this.runtime=a};
(function(){function a(){}function b(){}var c=cr.behaviors.jumpthru.prototype;c.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};c.Type.prototype.onCreate=function(){};c.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var d=c.Instance.prototype;d.onCreate=function(){this.inst.extra.jumpthruEnabled=0!==this.properties[0]};d.tick=function(){};a.prototype.IsEnabled=function(){return this.inst.extra.jumpthruEnabled};c.cnds=new a;
b.prototype.SetEnabled=function(a){this.inst.extra.jumpthruEnabled=!!a};c.acts=new b})();cr.behaviors.scrollto=function(a){this.runtime=a;this.shakeMode=this.shakeEnd=this.shakeStart=this.shakeMag=0};
(function(){function a(){}var b=cr.behaviors.scrollto.prototype;b.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};b.Type.prototype.onCreate=function(){};b.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var c=b.Instance.prototype;c.onCreate=function(){};c.saveToJSON=function(){return{smg:this.behavior.shakeMag,ss:this.behavior.shakeStart,se:this.behavior.shakeEnd,smd:this.behavior.shakeMode}};c.loadFromJSON=function(a){this.behavior.shakeMag=
a.smg;this.behavior.shakeStart=a.ss;this.behavior.shakeEnd=a.se;this.behavior.shakeMode=a.smd};c.tick=function(){};c.tick2=function(){var a=this.behavior.my_instances.values(),b=0,c=0,g,h;g=0;for(h=a.length;g<h;g++)b+=a[g].x,c+=a[g].y;g=this.inst.layer.layout;var l=this.runtime.kahanTime.sum,k=h=0;l>=this.behavior.shakeStart&&l<this.behavior.shakeEnd&&(h=this.behavior.shakeMag*Math.min(this.runtime.timescale,1),0===this.behavior.shakeMode&&(h*=1-(l-this.behavior.shakeStart)/(this.behavior.shakeEnd-
this.behavior.shakeStart)),l=2*Math.random()*Math.PI,k=Math.random()*h,h=Math.cos(l)*k,k*=Math.sin(l));g.scrollToX(b/a.length+h);g.scrollToY(c/a.length+k)};a.prototype.Shake=function(a,b,c){this.behavior.shakeMag=a;this.behavior.shakeStart=this.runtime.kahanTime.sum;this.behavior.shakeEnd=this.behavior.shakeStart+b;this.behavior.shakeMode=c};b.acts=new a})();cr.behaviors.solid=function(a){this.runtime=a};
(function(){function a(){}function b(){}var c=cr.behaviors.solid.prototype;c.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};c.Type.prototype.onCreate=function(){};c.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var d=c.Instance.prototype;d.onCreate=function(){this.inst.extra.solidEnabled=0!==this.properties[0]};d.tick=function(){};a.prototype.IsEnabled=function(){return this.inst.extra.solidEnabled};c.cnds=new a;b.prototype.SetEnabled=
function(a){this.inst.extra.solidEnabled=!!a};c.acts=new b})();
cr.getProjectModel=function(){return[null,null,[[cr.plugins_.CJSAds,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.Keyboard,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.Particles,!1,!0,!0,!1,!0,!0,!0,!0,!0],[cr.plugins_.Sprite,!1,!0,!0,!0,!0,!0,!0,!0,!1],[cr.plugins_.Spritefont2,!1,!0,!0,!0,!0,!0,!0,!0,!0],[cr.plugins_.Text,!1,!0,!0,!0,!0,!0,!0,!0,!1],[cr.plugins_.Touch,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.TiledBg,!1,!0,!0,!0,!0,!0,!0,!0,!0],[cr.plugins_.Audio,!0,!1,!1,!1,!1,!1,!1,!1,!1]],[["t0",cr.plugins_.TiledBg,
!1,[],0,0,["backgroundtile.png",100,1],null,[],!1,!1,7145216628892648,[]],["t1",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,0x648321cf7a139,[["player-sheet0.png",289,0,0,32,32,1,0.5,1,[],[-0.3125,-0.8125,0,-0.9375,0.3125,-0.8125,0.4375,-0.5,0.296875,-0.203125,0,-0.125,-0.28125,-0.21875,-0.40625,-0.5],0]]]],[["Platform",cr.behaviors.Platform,4786656577941331],["ScrollTo",cr.behaviors.scrollto,0xfbde30225713b]],!1,!1,546293000178772,[]],["t2",cr.plugins_.TiledBg,!1,[],1,0,["jumpthrutile.png",
7328,0],null,[["Jumpthru",cr.behaviors.jumpthru,0x68138ca20396f]],!1,!1,6492358468608086,[]],["t3",cr.plugins_.Keyboard,!1,[],0,0,null,null,[],!1,!1,6173429976389888,[],[]],["t4",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,0xe2c4bc700c90f,[]],["t5",cr.plugins_.Sprite,!1,[],1,0,null,[["idle",15,!0,1,0,!1,7461856495171574,[["blue-sheet0.png",288801,1,1,80,130,1,0.525,0.976923,[["pegafolha",0.575,0.553846]],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,
-0.4375,-0.476923],0],["blue-sheet0.png",288801,82,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,163,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,244,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,
-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,325,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,406,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,1,132,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,
0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,82,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0]]],["jump",5,!1,5,0,!1,0xbf20c3d209fe7,[["blue-sheet0.png",288801,163,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0]]],["walk",40,!0,1,0,!1,0xedcaa94e20f82,[["blue-sheet0.png",
288801,244,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0],["blue-sheet0.png",288801,325,132,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,406,132,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",
288801,1,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,82,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,163,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",
288801,244,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,325,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,406,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",
46683,1,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,82,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,163,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0]]]],[["Pin",cr.behaviors.Pin,
7218321485395873]],!1,!1,5940815889574782,[]],["t6",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,7924998130068514,[["sprite2-sheet0.png",155,0,0,250,250,1,0.5,0.5,[],[],1]]]],[],!1,!1,6455014148255642,[]],["t7",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground.png",31487,1],null,[],!1,!1,0x88cf4383eeb94,[]],["t8",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground2.png",4623,0],null,[],!1,!1,9937836611902416,[]],["t9",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground3.png",33603,1],null,[],!1,
!1,5179571501512806,[]],["t10",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground4.png",331,0],null,[],!1,!1,0x827897c6127de,[]],["t11",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,854687480383229,[["sprite3-sheet0.png",684,0,0,32,32,1,0.5,0.5,[],[],0]]]],[],!1,!1,9121429005652176,[]],["t12",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground5.png",688,0],null,[],!1,!1,5930772157794389,[]],["t13",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,8278076624004862,[["sprite4-sheet0.png",
3807,0,0,800,600,1,0.50125,0.5,[],[],1]]]],[],!1,!1,7082399922422947,[]],["t14",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xcc4250939cc81,[["sprite5-sheet0.png",23142,0,0,172,252,1,0.5,0.5,[],[0.430233,0,0.27907,0.349206,0,0.392857,-0.284884,0.353175,-0.453488,0,-0.389535,-0.424603,0,-0.488095,0.337209,-0.388889],0]]]],[],!1,!1,0x4410e32b59af3,[]],["t15",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground6.png",10126,0],null,[],!1,!1,0x532b739687ca4,[]],["t16",cr.plugins_.TiledBg,!1,[],
0,0,["tiledbackground7.png",12770,0],null,[],!1,!1,0x70d0f13bfc582,[]],["t17",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0x7873fa55dafba,[["sprite6-sheet0.png",78988,0,0,1200,500,1,0,0.5,[],[0.173836,-0.040906,0.499889,-0.34226,0.794518,0.042672,0.771339,-2.94E-4,0.499889,0.235138,0.0853577,0.274573,0.166481,-2.94E-4],0]]]],[["Sine",cr.behaviors.Sin,7769079880761715]],!1,!1,9486504757464964,[]],["t18",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,7694407424224186,[["sprite7-sheet0.png",
12757,0,0,128,128,1,0.5,0.5,[],[-0.404437,-0.391473,-0.001706,-0.383721,0.414676,-0.403101,0.360068,0,0.356655,0.337209,-0.001706,0.5,-0.383959,0.368217],0]]]],[],!1,!1,8834925581435457,[]],["t19",cr.plugins_.Sprite,!1,[],1,0,null,[["idle",15,!0,1,0,!1,7909311854574402,[["blue-sheet0.png",288801,1,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,82,1,80,130,1,0.525,0.976923,
[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,163,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,244,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",
288801,325,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,406,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,1,132,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,
-0.4375,-0.476923],0],["blue-sheet0.png",288801,82,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0]]],["walk",20,!0,1,0,!1,7508023450986269,[["blue-sheet0.png",288801,244,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0],["blue-sheet0.png",288801,325,132,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,
0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,406,132,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,1,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,82,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,
0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,163,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,244,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,325,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,
-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,406,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,1,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,82,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,
-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,163,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0]]],["jump",5,!0,1,0,!1,5928909244733456,[["blue-sheet0.png",288801,163,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0]]]],[["Pin",cr.behaviors.Pin,0x825908496abb9]],!1,!1,8818621832530907,[]],
["t20",cr.plugins_.Particles,!1,[],1,0,["particles.png",115,0],null,[["Pin",cr.behaviors.Pin,5030150334463151]],!1,!1,0xb4ed1acfc4829,[]],["t21",cr.plugins_.Sprite,!1,[],2,0,null,[["idle",15,!0,1,0,!1,9246351750315752,[["blue-sheet0.png",288801,1,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,82,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,
0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,163,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,244,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,325,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,
-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,406,1,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,1,132,80,130,1,0.525,0.976923,[],[-0.3,-0.838461,-0.025,-0.907692,0.3625,-0.907692,0.2875,-0.092308,-0.025,-0.0538461,-0.3,-0.115385,-0.4375,-0.476923],0],["blue-sheet0.png",288801,82,132,
80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0]]],["walk",20,!0,1,0,!1,0x8419bebca9b5,[["blue-sheet0.png",288801,244,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0],["blue-sheet0.png",288801,325,132,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",
288801,406,132,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,1,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,82,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",
288801,163,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,244,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",288801,325,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet0.png",
288801,406,263,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,1,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",46683,82,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0],["blue-sheet1.png",
46683,163,1,80,130,1,0.5,0.961538,[],[-0.275,-0.823076,0,-0.892308,0.3875,-0.892308,0.3125,-0.0769234,0,-0.0384614,-0.275,-0.1,-0.4125,-0.461538],0]]],["jump",5,!0,1,0,!1,7477884121087139,[["blue-sheet0.png",288801,163,132,80,130,1,0.5,1,[],[-0.275,-0.861538,0,-0.930769,0.3875,-0.930769,0.3125,-0.115385,0,-0.076923,-0.275,-0.138462,-0.4125,-0.5],0]]]],[["Pin",cr.behaviors.Pin,0x7c28633d10341],["Fade",cr.behaviors.Fade,0x48652338bcd7e]],!1,!1,925708926480006,[]],["t22",cr.plugins_.Sprite,!1,[],1,0,
null,[["Default",5,!1,1,0,!1,6752222856934476,[["livros-sheet0.png",60358,0,0,351,269,1,0.501424,0.501859,[],[-0.22613,-0.279971,-0.0903695,-0.422364,0.442124,-0.443035,0.353954,0.0501863,0.254485,0.475836,-0.00205049,0.485069,-0.277658,0.406729,-0.197937,-0.0873607],0]]]],[["Solid",cr.behaviors.solid,7908295687019607]],!1,!1,4641673571201044,[]],["t23",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,5412782426951773,[["livros1-sheet0.png",33253,0,0,158,232,1,0.5,0.5,[],[-0.380672,-0.414251,
0.011818,-0.430326,0.410531,-0.426849,0.415966,0,0.468386,0.47443,0.081438,0.480489,-0.34241,0.468891,-0.394724,-0.00431001],0]]]],[["Solid",cr.behaviors.solid,4798199816778654]],!1,!1,0xeebfa7745af34,[]],["t24",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,649118573322217,[["sprite-sheet0.png",62387,0,0,209,298,1,0.502392,0.5,[],[-0.414416,-0.267139,0.00147462,-0.463411,0.348914,-0.46282,0.451736,-6.42985E-4,0.413204,0.440798,-0.00330934,0.472973,-0.416154,0.439511,-0.487713,-6.42985E-4],
0]]]],[["Solid",cr.behaviors.solid,0x872f1e03f4ba6],["Sine",cr.behaviors.Sin,8023000264382289]],!1,!1,5306318377691776,[]],["t25",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,4549312007268637,[["sprite8-sheet0.png",56495,0,0,208,327,1,0.5,1,[],[-0.259615,-0.95107,0,-0.954128,0.389423,-0.929664,0.235576,-0.623853,0.45673,-0.623853,0.259615,-0.00305802,-0.298077,-0.00917399,-0.423077,-0.853211],0]]]],[["Solid",cr.behaviors.solid,7987925103529982]],!1,!1,0xca501a0e3c701,[]],["t26",cr.plugins_.Sprite,
!1,[],0,0,null,[["Default",5,!1,1,0,!1,5932935279149236,[["sprite9-sheet0.png",567849,0,0,1616,240,1,0.5,0.504167,[],[-0.455432,-0.134001,0,-0.292381,0.439911,-0.00508767,0.441685,-0.00508767,0.486475,0.383494,0,0.449792,-0.48337,0.357711],0]]]],[],!1,!1,7998586810852991,[]],["t27",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0xb88a8f6c41310,[["sprite10-sheet0.png",160313,0,0,588,821,1,0.5,0.500609,[],[-0.387755,-0.420219,0,-0.483557,0.413265,-0.43849,0.392857,0.422655,0,0.45676,-0.348639,
0.390987,-0.355442,-0.00121805],0]]]],[["Solid",cr.behaviors.solid,9633513579866620]],!1,!1,0x722927e0db4b2,[]],["t28",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,8325317499455323,[["sprite11-sheet0.png",29267,0,0,244,125,1,0.5,0.504,[],[-0.491803,-0.488,-0.262295,-0.424,0.020492,-0.472,0.204918,-0.424,0.372951,-0.456,0.479508,-0.24,-0.036885,0.328],0]]]],[["Solid",cr.behaviors.solid,5251532114729435],["Sine",cr.behaviors.Sin,6899370151201489]],!1,!1,337710061303121,[]],["t29",cr.plugins_.TiledBg,
!1,[],0,0,["tiledbackground8.png",175730,1],null,[],!1,!1,0xda877d080329d,[]],["t30",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,9647797700692148,[["sprite12-sheet0.png",245365,0,0,1040,371,1,0.5,1,[],[-0.298077,-0.641509,-0.016346,-0.695418,0.338462,-0.846361,0.480769,-0.256065,0.215385,-0.010782,-0.016346,-0.02965,-0.249038,-0.00808603,-0.478846,-0.256065],0]]]],[],!1,!1,0xbd6953bb30983,[]],["t31",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground9.png",171588,0],null,[],!1,!1,8741289979423198,
[]],["t32",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,378142939201238,[["sprite13-sheet0.png",78346,0,0,481,237,1,0.50104,1,[],[-0.442827,-0.983122,0.24948,-0.970464,0.24948,-0.599156,0.477131,-0.57595,-0.0727655,-0.075949,-0.442827,-0.645569],0]]]],[["Solid",cr.behaviors.solid,6936008764170112],["Sine",cr.behaviors.Sin,0x8744923c7a9ce]],!1,!1,0x8f191161cba04,[]],["t33",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xc0ebc20553356,[["sprite14-sheet0.png",93375,0,0,269,448,
1,0.408922,0.662946,[],[],0]]]],[],!1,!1,8161763621765137,[]],["t34",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,8202708604570604,[["sprite15-sheet0.png",112005,0,0,980,148,1,0.5,1,[],[-0.490816,-0.959459,0.10102,-0.966216,0.478571,-0.959459,0.301021,0,-0.306122,-0.013514],0]]]],[["Solid",cr.behaviors.solid,0xe3ef9ab4352b7]],!1,!1,7255742354525031,[]],["t35",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xc006ea52253c,[["sprite16-sheet0.png",151260,0,0,348,602,1,0.5,1,[],
[-0.307471,-0.38206,0.086207,-0.965116,0.462644,-0.372093,0.41092,-0.403654,0.41092,-0.465116,0.086207,-0.00332201,-0.465517,-0.333887,-0.29023,-0.403654],0]]]],[],!1,!1,7803535020285035,[]],["t36",cr.plugins_.Audio,!1,[],0,0,null,null,[],!1,!1,0xbb3890ed1f96f,[],[0,0,1,1,600,600,1E4,1,5E3,1]],["t37",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0xcb19754bf48ff,[["sprite17-sheet0.png",79502,0,0,454,263,1,0.623348,-0.0114068,[],[-0.387665,0.361217,-0.389868,0.0608365,0.303965,0.0608366,
0,0.927757,-0.612335,0.387833],0]]]],[["Solid",cr.behaviors.solid,9755136050961514]],!1,!1,8674180187536494,[]],["t38",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,7815426053606404,[["sprite18-sheet0.png",94365,0,0,553,294,1,0.526221,0.510204,[],[-0.283906,-0.32653,0.0271254,-0.360544,0.410488,-0.176871,0.403255,0.00340092,0.446654,0.0306119,3.57628E-7,0.469388,-0.508137,-0.0952381,-0.285715,-0.221089],0]]]],[["Solid",cr.behaviors.solid,8408115471222646]],!1,!1,0xf4aaa2e64a829,[]],["t39",
cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,5407855419935963,[["sprite19-sheet0.png",82475,0,0,536,248,1,0.527985,0.524194,[],[-0.291045,-0.0887095,-0.285448,-0.439516,0.401119,-0.407258,0.419776,-0.0887095,0.434702,0.334677,-1.19209E-7,0.44758,-0.339552,0.443549,-0.481343,-0.0887095],0]]]],[["Solid",cr.behaviors.solid,0x7a7cbb7eb48fd]],!1,!1,6209229311985549,[]],["t40",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,7798058748225117,[["sprite20-sheet0.png",120343,0,0,346,
545,1,0.447977,0.655046,[],[-0.404624,0.0183491,1.19209E-7,-0.649541,0.263006,-0.647706,0.514451,1.19209E-7,0.514451,0.0513761,1.19209E-7,0.341284,-0.404624,-0.0183489],0]]]],[],!1,!1,605160766696255,[]],["t41",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0x807060639bea2,[["sprite21-sheet0.png",59631,0,0,1129,57,1,0.504872,0.45614,[],[-0.131976,-0.105263,0.495128,-0.245614,0.302038,0.350877,-0.394155,0.403509,-0.502214,-0.175438],0]]]],[["Solid",cr.behaviors.solid,317045686551204]],!1,
!1,4541447464129487,[]],["t42",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,5720935008751738,[["sprite22-sheet0.png",43698,0,0,753,108,1,0.501992,0.509259,[],[-0.486056,-0.398148,-0.00265604,-0.388889,0.475432,-0.351852,0.278885,-0.00925928,0.482072,0.37963,-0.00265604,0.435185,-0.494024,0.435185,-0.413015,-0.00925928],0]]]],[],!1,!1,8111319495194918,[]],["t43",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,5243336797207819,[["sprite23-sheet0.png",298180,0,0,546,955,1,0.5,
0.500524,[],[-0.408425,-0.448168,0,-0.494241,0.421245,-0.455497,0.349817,-0.00104758,0.362637,0.420942,0,0.473298,-0.397436,0.440837,-0.428571,-0.00104758],0]]]],[],!1,!1,0xc447e9a1622e8,[]],["t44",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,818152642176101,[["circleup-sheet0.png",4103,0,0,122,143,1,0.508197,0.573427,[],[],0]]]],[],!1,!1,6860276906814055,[]],["t45",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,6374414022006739,[["circledown-sheet0.png",4041,0,0,122,143,1,
0.5,0.433566,[],[],0]]]],[],!1,!1,0xf93b757f576d5,[]],["t46",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x479ffb623be52,[["circleleft-sheet0.png",4014,0,0,143,122,1,0.566434,0.5,[],[],0]]]],[],!1,!1,7216714529512729,[]],["t47",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,713187956272576,[["circleright-sheet0.png",3977,0,0,143,122,1,0.426573,0.5,[],[],0]]]],[],!1,!1,0xa765663eb9849,[]],["t48",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xe21c85b500451,[["sprite28-sheet0.png",
122024,0,0,875,1590,1,0.500571,0.5,[],[-0.404571,-0.44717,0.405715,-0.448428,0.285715,0,0.284572,0.381761,-0.323428,0.402516,-0.323428,0],0]]]],[],!1,!1,9958278267857192,[]],["t49",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x3a0b43b575f7f,[["marca-sheet0.png",5954,0,0,282,292,1,0.5,0.5,[],[-0.471631,-0.472603,0.468085,-0.469178,0.5,0.017123,0.443262,0.445205,-0.443262,0.445205,-0.485816,0.013699],0]]]],[],!1,!1,523403891269873,[]],["t50",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",
5,!1,1,0,!1,0x5b3235c65bdc6,[["sprite30-sheet0.png",55041,0,0,333,223,1,0.501502,0.502242,[],[-0.339339,-0.26009,-0.00300351,-0.461883,0.378379,-0.32287,0.48048,-0.00448415,0.339339,0.26009,-0.00300351,0.466368,-0.3994,0.345292,-0.438438,-0.00448415],0]]]],[],!1,!1,6971636801711656,[]],["t51",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground10.png",55054,0],null,[],!1,!1,7648925313045847,[]],["t52",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground11.png",50738,0],null,[],!1,!1,0xa2e70e0eef02,[]],["t53",
cr.plugins_.TiledBg,!1,[],1,0,["tiledbackground9.png",171588,0],null,[["Solid",cr.behaviors.solid,7694921029874619]],!1,!1,0x8305fd6d3e6b9,[]],["t54",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,6289436542188188,[["sprite31-sheet0.png",171575,0,0,512,130,1,0.5,0.5,[],[-0.203125,-0.261539,-0.00585899,-0.469231,0.175781,-0.223077,0.5,-0.4,0.498047,-0.176924,-0.5,-0.130769,-0.5,-0.361538],0]]]],[["Solid",cr.behaviors.solid,6792986625220674]],!1,!1,833825433814122,[]],["t55",cr.plugins_.Sprite,
!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x909ad56adf82f,[["sprite32-sheet0.png",155,0,0,250,250,1,0.5,0.5,[],[],1]]]],[],!1,!1,0x51f6b673da249,[]],["t56",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,8221883579506871,[["montinho-sheet0.png",129822,0,0,400,200,1,0.5,0.5,[],[-0.245369,-0.318394,0,-0.497722,0.209012,-0.339282,0.357281,0,0.450605,0.400604,0,0.495444,-0.466249,0.420273],0]]]],[["Solid",cr.behaviors.solid,678476556140334]],!1,!1,8528679006597454,[]],["t57",cr.plugins_.Sprite,
!1,[],0,0,null,[["Default",5,!1,1,0,!1,8767806705493766,[["sprite34-sheet0.png",155,0,0,250,250,1,0.5,0.5,[],[],1]]]],[],!1,!1,7140909724245668,[]],["t58",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x83f00c4d6d860,[["setas-sheet0.png",47046,0,0,913,269,1,0.500548,0.501859,[],[-0.495071,-0.483271,-0.00109565,-0.501859,0.493976,-0.483271,0.493976,0.479554,-0.00109565,0.498141,-0.495071,0.479554],0]]]],[],!1,!1,0x50f9cdfe0838a,[]],["t59",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,
!1,1,0,!1,6964283127701938,[["jogar-sheet0.png",6939,0,0,446,82,1,0.5,0.5,[],[-0.497758,-0.487805,0.497758,-0.487805,0.497758,0.487805,-0.497758,0.487805],0]]]],[],!1,!1,7018990270683125,[]],["t60",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,4726318468632167,[["instru-sheet0.png",10423,0,0,445,81,1,0.501124,0.506173,[],[],0]]]],[["Fade",cr.behaviors.Fade,0xc3d25e8abb863]],!1,!1,6910683653984226,[]],["t61",cr.plugins_.Touch,!1,[],0,0,null,null,[],!1,!1,0x689326af02ab6,[],[1]],["t62",
cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,788982481985989,[["sprite29-sheet0.png",915,0,0,45,45,1,0.511111,0.511111,[],[-0.355555,-0.355555,-0.0222221,-0.511111,0.333333,-0.355555,0.488889,-0.0222221,0.333333,0.333333,-0.0222221,0.488889,-0.355555,0.333333,-0.511111,-0.0222221],0]]]],[["Pin",cr.behaviors.Pin,7421548632772244]],!1,!1,6771593694629499,[]],["t63",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0x6f881bdffb2c6,[["fadebranco-sheet0.png",155,0,0,250,250,1,0.5,
0.5,[],[],4]]]],[["Fade",cr.behaviors.Fade,7208076135855465]],!1,!1,6837961364098626,[]],["t64",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,8139944736700759,[["instru3-sheet0.png",7161,0,0,551,40,1,0.500907,0.5,[],[-0.470054,-0.075,-0.00181442,-0.075,0.46461,-0.025,0.490019,0,0.477314,0.2,-0.00181442,0,-0.475499,0.15,-0.499093,0],0]]]],[["Fade",cr.behaviors.Fade,0xaa4059910148]],!1,!1,9685292762992300,[]],["t65",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,5609885202070216,
[["instru4-sheet0.png",8033,0,0,522,78,1,0.5,0.5,[],[-0.438697,-0.089744,0.438697,-0.089744,0.48659,0,0.43295,0.051282,0,0.051282,-0.413793,-0.076923,-0.498084,0],0]]]],[["Fade",cr.behaviors.Fade,5258651654995835]],!1,!1,7395341856397245,[]],["t66",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,400455082616498,[["jogar1-sheet0.png",8806,0,0,555,102,1,0.500901,0.5,[],[-0.499099,-0.490196,0.497297,-0.490196,0.497297,0.490196,-0.499099,0.490196],0]]]],[["Physics",cr.behaviors.Physics,0xe1468920e8494]],
!1,!1,0xcf59125c020f9,[]],["t67",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x4c4f10ecb7d6c,[["compartilhar-sheet0.png",9950,0,0,446,82,1,0.5,0.5,[],[-0.497758,-0.487805,0.497758,-0.487805,0.497758,0.487805,-0.497758,0.487805],0]]]],[],!1,!1,6304805914365352,[]],["t68",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,7107787592306074,[["treinar-sheet0.png",8612,0,0,446,82,1,0.5,0.5,[],[-0.497758,-0.487805,0.497758,-0.487805,0.497758,0.487805,-0.497758,0.487805],0]]]],[],!1,
!1,9117211217355104,[]],["t69",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0x5b8976be97083,[["fadebranco-sheet0.png",155,0,0,250,250,1,0.5,0.5,[],[],4]]]],[["Fade",cr.behaviors.Fade,76478841757805]],!1,!1,7256116728315663,[]],["t70",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,6051004534068333,[["fadeinblue-sheet0.png",155,0,0,250,250,1,0.5,0.5,[],[],1]]]],[["Fade",cr.behaviors.Fade,9901566628417656]],!1,!1,6475914876799648,[]],["t71",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",
5,!1,1,0,!1,7921267186012392,[["sprite33-sheet0.png",10767,0,0,470,93,1,0.5,0.505376,[],[-0.451064,-0.258064,0.393617,0.0322577,0.446809,-0.0107524,0.465957,0.322581,-0.485106,0.419355,-0.480851,-0.0107524],0]]]],[],!1,!1,6563773570731518,[]],["t72",cr.plugins_.Sprite,!1,[],3,0,null,[["Default",5,!0,1,0,!1,8922312824995011,[["coin-sheet0.png",3648,0,0,50,50,1,0.5,0.5,[],[-0.307229,-0.307229,-0.006024,-0.439759,0.307229,-0.307229,0.439759,-0.006024,0.307229,0.307229,-0.006024,0.439759,-0.307229,0.307229,
-0.439759,-0.006024],0],["coin-sheet1.png",1943,0,0,20,50,1,0.5,0.5,[],[-0.294118,-0.406667,0,-0.486667,0.294118,-0.406667,0.470588,-0.00666699,0.294118,0.406667,0,0.486667,-0.294118,0.406667,-0.470588,-0.00666699],0]]]],[["MoveTo",cr.behaviors.Rex_MoveTo,8752043523952351],["Fade",cr.behaviors.Fade,9150441810229702],["Sine",cr.behaviors.Sin,7915802000698364]],!1,!1,0x3eed95b939e4f,[]],["t73",cr.plugins_.Spritefont2,!1,[],0,0,["spritefont.png",40098,0],null,[],!1,!1,5924207729202439,[]],["t74",cr.plugins_.Sprite,
!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x3c823ccd88ade,[["refercoin-sheet0.png",155,0,0,250,250,1,0.5,0.5,[],[],1]]]],[],!1,!1,7691767825320651,[]],["t75",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,9218947048801822,[]],["t76",cr.plugins_.Sprite,!1,[9917901903827188],1,0,null,[["Default",15,!0,1,0,!1,8807870944501796,[["livrosazuis-sheet0.png",59561,1,1,133,80,1,0.406015,0.5875,[],[],0],["livrosazuis-sheet0.png",59561,1,163,128,80,1,0.414063,0.6,[],[],0],["livrosazuis-sheet0.png",59561,135,80,114,
78,1,0.438596,0.602564,[],[],0],["livrosazuis-sheet0.png",59561,135,1,117,78,1,0.435897,0.602564,[],[],0],["livrosazuis-sheet0.png",59561,130,163,123,78,1,0.422764,0.602564,[],[],0],["livrosazuis-sheet0.png",59561,1,82,132,80,1,0.409091,0.6,[],[],0]]]],[["Sine",cr.behaviors.Sin,8213078397314794]],!1,!1,5929973400205515,[]],["t77",cr.plugins_.Particles,!1,[],0,0,["particles2.png",784,0],null,[],!1,!1,9891978579161908,[]],["t78",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",15,!1,1,0,!1,0xcaa0bdd4c560b,
[["folha-sheet0.png",1698,0,0,60,47,1,0.5,0.489362,[],[-0.166667,0.117021,-0.241667,-0.489362,0.133334,-0.457447,0.158333,0.0957443],0],["folha-sheet1.png",2442,0,0,60,47,1,0.5,0.489362,[],[-0.166667,0.117021,-0.241667,-0.489362,0.133334,-0.457447,0.158333,0.0957443],0]]]],[["Pin",cr.behaviors.Pin,0x9e8941cfcf51],["Fade",cr.behaviors.Fade,8591802798375078]],!1,!1,0xd8471a76f9399,[]],["t79",cr.plugins_.Sprite,!1,[0x555f67be33eb3],0,0,null,[["Default",5,!1,1,0,!1,8081116237135398,[["vida-sheet0.png",
493,0,0,32,32,1,0.5,0.5,[],[],0]]]],[],!1,!1,5454841801440344,[]],["t80",cr.plugins_.Sprite,!1,[505833962281251],0,0,null,[["Default",5,!1,1,0,!1,0x93a0724cf5d91,[["vida2-sheet0.png",440,0,0,32,32,1,0.5,0.5,[],[],0]]]],[],!1,!1,26490208257337,[]],["t81",cr.plugins_.Sprite,!1,[0x8d6064c448896],0,0,null,[["Default",5,!1,1,0,!1,6534835847148949,[["vida3-sheet0.png",440,0,0,32,32,1,0.5,0.5,[],[],0]]]],[],!1,!1,0x8231268127c7c,[]],["t82",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0x97a71919208b5,
[["sprite24-sheet0.png",6192,0,0,60,53,1,0.5,0.943396,[],[-0.391667,-0.84434,0.3125,-0.84434,0.5,0.0566038,-0.5,0.0566038],0]]]],[["Jumpthru",cr.behaviors.jumpthru,9512099913964200]],!1,!1,0x5b5f67cd72682,[]],["t83",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,412989252720582,[["sprite25-sheet0.png",168,0,0,250,250,1,0.5,0.5,[],[],0]]]],[["Physics",cr.behaviors.Physics,7475195542408054]],!1,!1,5236329194420847,[]],["t84",cr.plugins_.CJSAds,!1,[],0,0,null,null,[],!1,!1,0xefa7a0a59a6f0,
[],[0,0,1]],["t85",cr.plugins_.Sprite,!0,[],0,0,null,null,[],!1,!1,8178288212235268,[]]],[[85,28,32,34,37,38,39,41,25]],[["abertura",1024,768,!1,"sheetabertura",5478453028398797,[["Layer 0",0,7133924237518806,!0,[255,255,255],!1,1,1,1,!1,1,0,0,[[[1558,405,0,3128,840,0,0,1,0.50125,0.5,0,0,[]],13,55,[],[],[0,"Default",0,1]],[[256,707,0,512,136,0,0,1,0.5,0.5,0,0,[]],54,58,[],[[1]],[0,"Default",0,1]],[[768,707,0,518,132,0,0,1,0.5,0.5,0,0,[]],54,60,[],[[1]],[0,"Default",0,1]],[[864,686,0,167,110,0,0.0320136,
1,0.5,0.5,0,0,[]],56,76,[],[[1]],[0,"Default",0,1]],[[479,148,0,224.053,231.998,0,0,1,0.5,0.5,0,0,[]],49,100,[],[],[0,"Default",0,1]],[[480,331,0,450.929,82.8734,0,0,1,0.500901,0.5,0,0,[]],66,102,[],[[1,0,0,1,0.5,0.2,0,0.01,0,1]],[0,"Default",0,1]],[[480,513,0,327.419,60.1981,0,0,1,0.5,0.5,0,0,[]],67,101,[],[],[0,"Default",0,1]],[[480,427,0,330.527,60.7695,0,0,1,0.5,0.5,0,0,[]],68,103,[],[],[0,"Default",0,1]],[[448,1344,0,344.284,68.1243,0,-0.0954052,1,0.5,0.505376,0,0,[]],71,106,[],[],[0,"Default",
0,1]],[[269,260,0,128,128,0,-1.71858,1,0,0.5,0,0,[]],20,56,[],[[]],[10,20,0,100,20,100,120,0,0,0,0,0,-150,0,0,800,0,0,1]],[[269,292,0,61.4892,99.92,0,0,1,0.525,0.976923,0,0,[]],5,65,[],[[]],[0,"Default",0,1]],[[1280,704,0,518,132,0,0,1,0.5,0.5,0,0,[]],54,155,[],[[1]],[0,"Default",0,1]]],[]]],[],[]],["jogo",15E3,1300,!1,"sheetjogo",0x6112b46aa3fb1,[["CEU",0,9498886411674304,!0,[255,255,255],!1,1,1,1,!1,1,0,0,[[[7571.22,576,0,15168,1312,0,0,1,0.50125,0.5,0,0,[]],13,39,[],[],[0,"Default",0,1]]],[]],
["NUVEMS",1,6947350343976007,!0,[255,255,255],!0,0.2,0.2,1,!1,1,0,0,[[[-750,350,0,1472,464,0,0,0.85,0,0.5,0,0,[]],17,52,[],[[1,0,0,150,0,0,0,500,0]],[0,"Default",0,1]],[[624,248,0,1728,560,0,0,1,0,0.5,0,0,[]],17,53,[],[[1,0,0,150,0,0,0,500,0]],[0,"Default",0,1]],[[3184,96,0,1248,448,0,0,1,0,0.5,0,0,[]],17,89,[],[[1,0,0,150,0,0,0,500,0]],[0,"Default",0,1]],[[2368,304,0,880,320,0,0,1,0,0.5,0,0,[]],17,90,[],[[1,0,0,150,0,0,0,500,0]],[0,"Default",0,1]]],[]],["Background",2,0xb911a612c2c2f,!0,[255,255,
255],!0,0.6,0.6,1,!1,1,0,0,[[[4960,784,0,584.77,106.077,0,0,1,0.5,0.504167,0,0,[]],26,88,[],[],[0,"Default",0,1]],[[1936,784,0,1616,240,0,0,1,0.5,0.504167,0,0,[]],26,64,[],[],[0,"Default",0,1]],[[0,816,0,10544,480,0,0,1,0,0,0,0,[]],29,69,[],[],[0,0]],[[1056,1536,0,206,336,0,0,1,0.5,0.5,0,0,[]],14,44,[],[],[0,"Default",0,1]],[[2176,821,0,231.996,82.7601,0,0,1,0.5,1,0,0,[]],30,9,[],[],[0,"Default",0,1]],[[640,848,0,1040,371,0,0,1,0.5,1,0,0,[]],30,67,[],[],[0,"Default",0,1]],[[3728,832,0,752,288,0,0,
1,0.5,1,0,0,[]],30,80,[],[],[0,"Default",0,1]],[[3216,608,0,243.937,463.515,0,0,1,0.5,0.500524,0,0,[]],43,96,[],[],[0,"Default",0,1]]],[]],["Background2",3,8561607896272614,!0,[255,255,255],!0,0.8,0.8,1,!1,1,0,0,[[[1376,816,0,384,752,0,0,1,0.408922,0.662946,0,0,[]],33,29,[],[],[0,"Default",0,1]],[[1856,1088,0,416,800,0,0,1,0.5,1,0,0,[]],35,37,[],[],[0,"Default",0,1]],[[3632,944,0,368,624,0,0,1,0.447977,0.655046,0,0,[]],40,82,[],[],[0,"Default",0,1]],[[5152,864,0,384,752,0,0,1,0.408922,0.662946,0,
0,[]],33,91,[],[],[0,"Default",0,1]],[[5648,1136,0,416,800,0,0,1,0.5,1,0,0,[]],35,92,[],[],[0,"Default",0,1]],[[464,560,0,519.576,72.9209,0,0,1,0.501992,0.509259,0,0,[]],42,95,[],[],[0,"Default",0,1]]],[]],["ROSAS",4,455271004092315,!0,[255,255,255],!0,0.9,0.9,1,!1,1,0,0,[[[6752,1008,0,256.772,466.592,0,0,1,0.500571,0.5,0,0,[]],48,6,[],[],[0,"Default",0,1]]],[]],["Game",5,753221249086637,!0,[255,255,255],!0,1,1,1,!1,1,0,0,[[[-16,1184,0,15376,128,0,0,1,0,0,0,0,[]],31,70,[],[],[0,0]],[[1936,1184,0,
128,32,0,-0.00458482,1,0,0,0,0,[]],10,30,[],[],[0,0]],[[1392,1200,0,128,32,0,-0.00458482,1,0,0,0,0,[]],10,8,[],[],[0,0]],[[944,1184,0,128,32,0,-0.00458482,1,0,0,0,0,[]],10,12,[],[],[0,0]],[[1168,1200,0,128,32,0,-0.00458482,1,0,0,0,0,[]],10,14,[],[],[0,0]],[[1696,1232,0,128,32,0,-0.00458482,1,0,0,0,0,[]],10,15,[],[],[0,0]],[[2960,1216,0,128,32,0,-0.00458482,1,0,0,0,0,[]],10,17,[],[],[0,0]],[[3680,1200,0,128,32,0,-0.00458482,1,0,0,0,0,[]],10,86,[],[],[0,0]],[[3824,1200,0,128,32,0,-0.00458482,1,0,0,
0,0,[]],10,87,[],[],[0,0]],[[-720,1027,0,259.305,198.727,0,0,1,0.501424,0.501859,0,0,[]],22,59,[],[[1]],[0,"Default",0,1]],[[-764,1056,0,219,321,0,0,1,0.502392,0.5,0,0,[]],24,61,[],[[1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[-641,1152,0,130,200,0,0,1,0.5,0.500609,0,0,[]],27,66,[],[[1]],[0,"Default",0,1]],[[768,1216,0,244,125,0,0,1,0.5,0.504,0,0,[]],28,68,[],[[1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[416,1216,0,244,125,0,0,1,0.5,0.504,0,0,[]],28,63,[],[[1],[0,0,0,4,0,0,0,50,0]],[0,"Default",
0,1]],[[-736,1244,0,259.305,198.727,0,0,1,0.501424,0.501859,0,0,[]],22,62,[],[[1]],[0,"Default",0,1]],[[1024,1168,0,224,144,0,0,1,0.50104,1,0,0,[]],32,71,[],[[1],[0,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[1200,1024,0,224,144,0,0,1,0.50104,1,0,0,[]],32,72,[],[[1],[0,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[4800,880,0,1129,57,0,0,1,0.504872,0.45614,0,0,[]],41,97,[],[[1]],[0,"Default",0,1]],[[6240,1232,0,1129,57,0,0,1,0.504872,0.45614,0,0,[]],41,98,[],[[1]],[0,"Default",0,1]],[[7440,1216,0,1129,57,0,
0,1,0.504872,0.45614,0,0,[]],41,99,[],[[1]],[0,"Default",0,1]],[[3040,736,0,1129,57,0,0,1,0.504872,0.45614,0,0,[]],41,94,[],[[1]],[0,"Default",0,1]],[[144,896,0,128,128,0,-1.71858,1,0,0.5,0,0,[]],20,57,[],[[]],[10,20,0,100,20,100,120,0,0,0,0,0,-150,0,0,800,0,0,1]],[[144,944,0,32,32,0,0,1,0.5,1,0,0,[]],1,1,[],[[330,1500,1500,650,1500,1E3,1,1],[]],[1,"Default",0,1]],[[8749,1204,0,1129,57,0,0,1,0.504872,0.45614,0,0,[]],41,145,[],[[1]],[0,"Default",0,1]],[[10161,1200,0,1129,57,0,0,1,0.504872,0.45614,
0,0,[]],41,146,[],[[1]],[0,"Default",0,1]],[[11557,1188,0,1129,57,0,0,1,0.504872,0.45614,0,0,[]],41,147,[],[[1]],[0,"Default",0,1]],[[2663,536,0,102,95.4,0,0,1,0.5,0.943396,0,0,[]],82,152,[],[[1]],[0,"Default",0,1]],[[140.282,941.694,0,61.4892,99.92,0,0,1,0.525,0.976923,0,0,[]],5,21,[],[[]],[0,"Default",0,1]],[[96,1264,0,208,312,0,0,1,0.5,1,0,0,[]],25,23,[],[[1]],[0,"Default",0,1]],[[1376,784,0,224,144,0,0,1,0.50104,1,0,0,[]],32,73,[],[[1],[1,1,0,4,0,0,0,250,0]],[0,"Default",0,1]],[[2288,1200,0,244,
125,0,0,1,0.5,0.504,0,0,[]],28,38,[],[[1],[0,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[2320,560,0,272,160,0,0,1,0.623348,-0.0114068,0,0,[]],37,74,[],[[1]],[0,"Default",0,1]],[[1952,464,0,256,160,0,0,1,0.527985,0.524194,0,0,[]],39,77,[],[[1]],[0,"Default",0,1]],[[3744,1232,0,208,312,0,0,1,0.5,1,0,0,[]],25,78,[],[[1]],[0,"Default",0,1]],[[5472,1248,0,208,312,0,0,1,0.5,1,0,0,[]],25,79,[],[[1]],[0,"Default",0,1]],[[1648,304,0,256,160,0,0,1,0.527985,0.524194,0,0,[]],39,83,[],[[1]],[0,"Default",0,1]],[[2E3,
976,0,244,125,0,0,1,0.5,0.504,0,0,[]],28,84,[],[[1],[1,1,0,4,0,0,0,200,0]],[0,"Default",0,1]],[[2880,1184,0,244,125,0,0,1,0.5,0.504,0,0,[]],28,85,[],[[1],[1,0,0,4,0,0,0,300,0]],[0,"Default",0,1]],[[4064,1216,0,208,384,0,0,1,0.5,1,0,0,[]],25,93,[],[[1]],[0,"Default",0,1]],[[550.595,1376.5,0,52,42,0,1.55666,1,0.5,0.489362,0,0,[]],78,149,[],[[],[0,0,2,1,1]],[0,"Default",0,1]],[[2944,130,0,133,80,0,0,1,0.406015,0.5875,0,0,[]],76,11,[[0]],[[1,0,1,4,0,0,0,200,0]],[0,"Default",0,1]],[[724,821,0,-69,53,0,
0,1,0.406015,0.5875,0,0,[]],76,13,[[0]],[[1,0,1,4,0,0,0,500,0]],[0,"Default",0,1]],[[9619,838,0,81,53,0,0,1,0.406015,0.5875,0,0,[]],76,33,[[0]],[[1,0,1,4,0,0,0,500,0]],[0,"Default",0,1]],[[2659,500,0,128,128,0,-1.57069,1,0,0.5,0,0,[]],77,148,[],[],[5,60,0,200,32,100,0,0,0,0,0,0,-150,0,0,800,0,2,1]]],[]],["COINS",6,0x4723741f076ab,!0,[255,255,255],!0,1,1,1,!1,1,0,0,[[[700,1E3,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,107,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1968,
304,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,110,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[750,1E3,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,109,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[800,1E3,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,111,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[850,1E3,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,112,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1150,
750,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,113,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[950,950,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,114,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1E3,950,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,115,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1200,800,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,116,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1250,
750,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,117,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1350,350,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,118,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1300,400,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,119,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1700,100,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,120,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],
[[1650,100,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,121,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[1600,100,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,122,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,8,0,4,0,0,0,20,0]],[0,"Default",0,1]],[[2600,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,124,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[2700,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,125,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",
0,1]],[[2800,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,126,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[2900,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,127,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3E3,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,128,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3050,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,129,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",
0,1]],[[3100,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,130,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3150,550,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,131,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3300,665,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,132,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3300,615,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,133,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",
0,1]],[[3300,565,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,134,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3350,565,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,135,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3350,665,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,136,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3350,615,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,137,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",
0,1]],[[3400,615,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,138,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3400,665,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,139,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]],[[3400,565,0,50,50,0,0,1,0.5,0.5,0,0,[]],72,140,[],[[1,2E3,1900,1800],[0,0,0.5,0.5,1],[1,0,0,4,0,0,0,50,0]],[0,"Default",0,1]]],[]],["tabletcontrol",7,935843566174349,!1,[255,255,255],!0,0,0,0.5,!1,1,0,0,[[[-922,-173,0,352,32,0,0,1,0,0,0,0,[]],
4,19,[],[],["Arrow keys or WASD to move",0,"12pt Arial","rgb(0,0,0)",0,0,0,0,0]],[[950,513,0,122,143,0,0,1,0.508197,0.573427,0,0,[]],44,0,[],[],[0,"Default",0,1]],[[900,663,0,122,143,0,0,1,0.5,0.433566,0,0,[]],45,3,[],[],[0,"Default",0,1]],[[100,513,0,143,122,0,0,1,0.566434,0.5,0,0,[]],46,4,[],[],[0,"Default",0,1]],[[150,663,0,143,122,0,0,1,0.426573,0.5,0,0,[]],47,5,[],[],[0,"Default",0,1]]],[]],["UI",8,9383509334705256,!0,[255,255,255],!0,0,0,1,!1,1,0,0,[[[550,-67,0,450,250,0,0,1,0,0,0,0,[]],73,
108,[],[],[32,32,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;:?!-_~#\"'&()[]|`\\/@\u00b0+=*$\u00a3\u20ac<>","100",1.5,0,2,1,0,0,0,0]],[[0,-200,0,250,100,0,0,1,0,0,0,0,[]],75,123,[],[],["100",0,"36pt Arial","rgb(0,0,0)",0,0,0,0,0]],[[929.5,523,0,2908,1161,0,0,1,0.5,0.5,0,0,[]],69,104,[],[[1,0,0,1,1]],[0,"Default",0,1]],[[444,50,0,32,32,0,0,1,0.5,0.5,0,0,[]],79,150,[[0]],[],[1,"Default",0,1]],[[496,49,0,32,32,0,0,1,0.5,0.5,0,0,[]],80,153,[[0]],[],[1,"Default",0,1]],[[542,52,0,
32,32,0,0,1,0.5,0.5,0,0,[]],81,151,[[0]],[],[1,"Default",0,1]]],[]]],[],[]],["treinamento",3E3,768,!1,"sheettreinamento",0xe903c9654836a,[["background",0,7740376681886821,!0,[255,255,255],!1,0,0,1,!1,1,0,0,[[[1389.28,350,0,3350,850,0,0,1,0.50125,0.5,0,0,[]],13,32,[],[],[0,"Default",0,1]],[[500,233,0,269.131,278.675,0,0,1,0.5,0.5,0,0,[]],49,7,[],[],[0,"Default",0,1]]],[]],["game",1,9243750733733198,!0,[255,255,255],!0,1,1,1,!1,1,0,0,[[[287,242,0,128,128,0,-1.71858,1,0,0.5,0,0,[]],20,18,[],[[]],[10,
20,0,100,20,100,120,0,0,0,0,0,-150,0,0,800,0,0,1]],[[287,290,0,32,32,0,0,1,0.5,1,0,0,[]],1,22,[],[[330,1500,1500,650,1500,1E3,1,1],[]],[1,"Default",0,1]],[[112,678,0,808,184,0,0,1,0.5,0.5,0,0,[]],54,16,[],[[1]],[0,"Default",0,1]],[[766.5,686.5,0,500,200,0,0,1,0.5,0.5,0,0,[]],54,26,[],[[1]],[0,"Default",0,1]],[[1252.92,689.202,0,550,200,0,0.0312273,1,0.5,0.5,0,0,[]],54,27,[],[[1]],[0,"Default",0,1]],[[1763,696,0,550,200,0,0,1,0.5,0.5,0,0,[]],54,31,[],[[1]],[0,"Default",0,1]],[[284,287,0,61.4892,99.92,
0,0,1,0.525,0.976923,0,0,[]],5,25,[],[[]],[0,"Default",0,1]],[[849.256,614.002,0,118,92,0,0.0320136,1,0.5,0.5,0,0,[]],56,35,[],[[1]],[0,"Default",0,1]],[[2027,430,0,50,100,0,0,1,0.5,0.5,0,0,[]],57,34,[],[],[1,"Default",0,1]],[[2271,700,0,550,200,0,0,1,0.5,0.5,0,0,[]],54,36,[],[[1]],[0,"Default",0,1]],[[2796,696,0,500,200,0,0,1,0.5,0.5,0,0,[]],54,40,[],[[1]],[0,"Default",0,1]],[[2014,727,0,208,312,0,0,1,0.5,1,0,0,[]],25,41,[],[[1]],[0,"Default",0,1]],[[489.716,648.908,0,156,119,0,0.0108694,1,0.5,0.5,
0,0,[]],56,10,[],[[1]],[0,"Default",0,1]]],[]],["tabletcontrol",2,0x9ab11d7e1de49,!0,[255,255,255],!0,0,0,0.5,!1,1,0,0,[[[950,400,0,122,143,0,0,1,0.508197,0.573427,0,0,[]],44,141,[],[],[0,"Default",0,1]],[[900,550,0,122,143,0,0,1,0.5,0.433566,0,0,[]],45,142,[],[],[0,"Default",0,1]],[[100,400,0,143,122,0,0,1,0.566434,0.5,0,0,[]],46,143,[],[],[0,"Default",0,1]],[[150,550,0,143,122,0,0,1,0.426573,0.5,0,0,[]],47,144,[],[],[0,"Default",0,1]]],[]],["UI",3,0xb87c301030469,!0,[255,255,255],!0,0,0,1,!1,1,
0,0,[[[19,246,0,208.382,37.9303,0,-1.5708,1,0.501124,0.506173,0,0,[]],60,45,[],[[0,0,2,1,1]],[1,"Default",0,1]],[[-1E3,250,0,1050.1,309.394,0,0,1,0.500548,0.501859,0,0,[]],58,42,[],[],[0,"Default",0,1]],[[503.909,49.3197,0,329.819,60.6393,0,0,1,0.5,0.5,0,0,[]],59,43,[],[],[1,"Default",0,1]],[[-516,138,0,45,45,0,0,1,0.511111,0.511111,0,0,[]],62,48,[],[[]],[0,"Default",0,1]],[[694,354,0,2254,900,0,0,1,0.5,0.5,0,0,[]],63,50,[],[[0,2,0,3,1]],[1,"Default",0,1]],[[504,406,0,551,40,0,0,1,0.500907,0.5,0,
0,[]],64,51,[],[[0,1,3,1,1]],[1,"Default",0,0]],[[504,406,0,522,78,0,0,1,0.5,0.5,0,0,[]],65,54,[],[[0,1,2,1,1]],[1,"Default",0,1]],[[668,392,0,2214,942,0,0,1,0.5,0.5,0,0,[]],70,105,[],[[1,0,0,1,1]],[0,"Default",0,1]]],[]]],[],[]]],[["sheetjogo",[[1,"duplojump",0,0,!1,!1,8491227657704226,!1],[1,"heart",0,0,!1,!1,8492366307560462,!1],[1,"playmobile",0,0,!1,!1,0x9093aeb45ebc3,!1],[1,"placar",0,0,!1,!1,6262890490915369,!1],[1,"disparitionSpeed",0,15,!1,!1,5289944242633006,!1],[0,null,!1,null,6974034860020791,
[[1,cr.plugins_.Sprite.prototype.cnds.CompareY,null,0,!1,!1,!1,0x9958184be7912,!1,[[8,4],[0,[19,cr.system_object.prototype.exps.layoutheight]]]]],[[-1,cr.system_object.prototype.acts.RestartLayout,null,4987054837619637,!1],[-1,cr.system_object.prototype.acts.ResetGlobals,null,6109291222800267,!1],[36,cr.plugins_.Audio.prototype.acts.StopAll,null,6354902323005859,!1]]],[0,null,!1,null,7451489243880622,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0xd766540d0a3d9,!1]],[[5,cr.behaviors.Pin.prototype.acts.Pin,
"Pin",6325749096594826,!1,[[4,1],[3,0]]],[20,cr.behaviors.Pin.prototype.acts.Pin,"Pin",0x39071b795c28a,!1,[[4,5],[3,0]]],[-1,cr.system_object.prototype.acts.SetVar,null,0x8177573939d2a,!1,[[11,"placar"],[7,[0,0]]]]]],[0,null,!1,null,0x44034ee586d06,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,6805582419763449,!1]],[[21,cr.behaviors.Pin.prototype.acts.Pin,"Pin",7447457210236594,!1,[[4,5],[3,0]]],[21,cr.plugins_.Sprite.prototype.acts.SetPosToObject,null,9404067278929980,!1,[[4,
5],[7,[0,0]]]],[36,cr.plugins_.Audio.prototype.acts.PlayByName,null,978639008685635,!1,[[3,1],[1,[2,"Avarus_01"]],[3,1],[0,[0,0]],[1,[2,""]]]]]],[0,null,!1,null,0xfc7c33359341,[[-1,cr.system_object.prototype.cnds.OnLayoutEnd,null,1,!1,!1,!1,0xf9935b70a3677,!1]],[[36,cr.plugins_.Audio.prototype.acts.StopAll,null,4535387826969992,!1]]],[0,null,!1,null,0x7d6fdcbdf1421,[[85,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,6168408135727314,!1,[[4,1]]]],[[36,cr.plugins_.Audio.prototype.acts.PlayByName,
null,0xb56a6e836fe4a,!1,[[3,0],[1,[2,"musical004"]],[3,0],[0,[0,-2]],[1,[2,"playermusic"]]]]]],[0,[!0,"COINS"],!1,null,0x413cdd86f5df6,[[-1,cr.system_object.prototype.cnds.IsGroupActive,null,0,!1,!1,!1,0x413cdd86f5df6,!1,[[1,[2,"COINS"]]]]],[],[[0,null,!1,null,0xf956aafc1266,[[5,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,9962152837334454,!1,[[4,72]]]],[[72,cr.behaviors.Rex_MoveTo.prototype.acts.SetTargetPos,"MoveTo",6835373072623372,!1,[[0,[19,cr.system_object.prototype.exps.viewportright,
[[0,6]]]],[0,[19,cr.system_object.prototype.exps.viewporttop,[[0,6]]]]]],[72,cr.behaviors.Fade.prototype.acts.StartFade,"Fade",6345024196081089,!1],[-1,cr.system_object.prototype.acts.AddVar,null,7278630695194447,!1,[[11,"placar"],[7,[0,100]]]]]]]],[0,[!1,"ipadcontrol"],!1,null,5967874153916453,[[-1,cr.system_object.prototype.cnds.IsGroupActive,null,0,!1,!1,!1,5967874153916453,!1,[[1,[2,"ipadcontrol"]]]]],[],[[0,null,!1,null,5052758329365073,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchEnd,null,1,
!1,!1,!1,931151595192802,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,9667649816346008,!1,[[1,[2,"idle"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,0x4200e6d746b63,!1,[[5,[0,7]],[0,[0,50]]]]]],[0,null,!1,null,0x626c53a687fef,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xaf1f1ca5a19e0,!1,[[4,45]]]],[[1,cr.behaviors.Platform.prototype.acts.FallThrough,"Platform",7624836251682527,!1],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,6046093296052308,
!1,[[1,[2,"jump"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,0xd03315c21536f,!1,[[5,[0,7]],[0,[0,100]]]]]],[0,null,!1,null,8210743627830969,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,7776426628481815,!1,[[4,44]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0xd76433de53fe7,!1,[[3,2]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x72123c51381ea,!1,[[1,[2,"jump"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,
null,0x76ba913bfddeb,!1,[[5,[0,7]],[0,[0,100]]]]]],[0,null,!1,null,0xc6ce9699a098,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xd622c125566d1,!1,[[4,46]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0xf182a8232c529,!1,[[3,0]]],[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,6121511608820358,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,9621733762382488,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x90222d1d9cb03,
!1,[[1,[2,"walk"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,0xe9a43b10e7f8,!1,[[5,[0,7]],[0,[0,100]]]]]],[0,null,!1,null,0x498479137d03e,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,7116473516265964,!1,[[4,47]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0x96749f6974924,!1,[[3,1]]],[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,5375178451902329,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,0x50628a5ab715e,
!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x9f2b41f039ddf,!1,[[1,[2,"walk"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,6982838694654828,!1,[[5,[0,7]],[0,[0,100]]]]]],[0,null,!1,null,6826203814716699,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,8267538417496697,!1,[[4,44]]],[1,cr.behaviors.Platform.prototype.cnds.IsJumping,"Platform",0,!1,!0,!1,0xee315ee9748f5,!1],[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,
!1,!1,6363634633050629,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,6456044493297468,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,5952008922585581,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,6403630049469674,!1,[[4,44]]],[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,!0,!1,0xca8eacd10af59,!1],[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0xf37214ce85341,!1,[[11,"duplojump"],[8,0],[7,[0,1]]]]],[[1,cr.behaviors.Platform.prototype.acts.SetVectorY,
"Platform",6010672520168079,!1,[[0,[0,-700]]]],[-1,cr.system_object.prototype.acts.AddVar,null,705866954686265,!1,[[11,"duplojump"],[7,[0,1]]]]]],[0,null,!1,null,9031832342670108,[[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,!1,!1,0xa7f80537f13b7,!1]],[[-1,cr.system_object.prototype.acts.SetVar,null,7205637327981566,!1,[[11,"duplojump"],[7,[0,0]]]]]],[0,null,!1,null,0x73ee1824c734f,[[1,cr.behaviors.Platform.prototype.cnds.OnJump,"Platform",1,!1,!1,!1,0x5a5b3d467b529,!1]],[[-1,
cr.system_object.prototype.acts.SetVar,null,0x5e5c28ca33b8a,!1,[[11,"duplojump"],[7,[0,1]]]]]],[0,null,!1,null,5027380987223146,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,9122734094052184,!1,[[4,44]]],[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xf4a5c330e9d3a,!1,[[4,47]]],[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,!1,!1,8773122720967508,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,4884194942432446,!1,[[1,[2,"walk"]],
[3,1]]]]],[0,null,!1,null,0x8d59f8841d21a,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,6063916475061207,!1,[[4,44]]],[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,9841436735952694,!1,[[4,46]]],[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,!1,!1,5197440437885782,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,8888485307989299,!1,[[1,[2,"walk"]],[3,1]]]]]]],[0,[!0,"PLAYER CONTROL"],!1,null,0x5dfa099f649de,[[-1,cr.system_object.prototype.cnds.IsGroupActive,
null,0,!1,!1,!1,0x5dfa099f649de,!1,[[1,[2,"PLAYER CONTROL"]]]]],[],[[0,null,!1,null,7218988630200918,[[3,cr.plugins_.Keyboard.prototype.cnds.OnAnyKeyReleased,null,1,!1,!1,!1,0xaac32bb266706,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,37676615900399,!1,[[1,[2,"idle"]],[3,1]]]]],[0,null,!1,null,9116715979140964,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,5725546106360969,!1,[[9,40]]]],[[1,cr.behaviors.Platform.prototype.acts.FallThrough,"Platform",8046894921939085,!1],
[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x41b68251f3ddd,!1,[[1,[2,"jump"]],[3,1]]]]],[0,null,!1,null,6693904063639312,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,0xfd50448cd69bd,!1,[[9,38]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0x4e4bbff350310,!1,[[3,2]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,6421068367731727,!1,[[1,[2,"jump"]],[3,1]]]]],[0,null,!1,null,6265008838076915,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,
!1,!1,!1,9708036439573192,!1,[[9,87]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",4850445713131698,!1,[[3,2]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x605ec857f9f9e,!1,[[1,[2,"jump"]],[3,1]]]]],[0,null,!1,null,4954986959899276,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0xd5d179328eccd,!1,[[9,65]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",4698835552765649,!1,[[3,0]]]]],[0,null,!1,null,518511805372338,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,
null,0,!1,!1,!1,6612361169938893,!1,[[9,83]]]],[[1,cr.behaviors.Platform.prototype.acts.FallThrough,"Platform",6842145310257474,!1]]],[0,null,!1,null,4566275215655822,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0x88cf5cfdc3c24,!1,[[9,68]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0xb5c1e677df871,!1,[[3,1]]]]],[0,null,!0,null,7191727085184437,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,0xde70cb4b46153,!1,[[9,37]]],[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,
null,1,!1,!1,!1,8452004584967279,!1,[[9,65]]]],[[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,7003427655493546,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,0xe3130e0581965,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,853539822827669,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!0,null,5687517711223989,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,7079046118856472,!1,[[9,39]]],[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,0x5de12794aafb5,
!1,[[9,68]]]],[[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,822114432139511,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,571199029445594,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,4610326019648237,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,0xffc20ad71dc2a,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased,null,1,!1,!1,!1,8641485736718004,!1,[[9,38]]],[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,6535861863217443,!1,[[9,39]]]],
[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x44df411dafa18,!1,[[1,[2,"idle"]],[3,1]]],[-1,cr.system_object.prototype.acts.Wait,null,6247572903244174,!1,[[0,[1,0.2]]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,9417060034071084,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,0x6f29a3665d34f,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased,null,1,!1,!1,!1,5388736477021031,!1,[[9,38]]],[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0xc2b0b72c7b62a,!1,[[9,37]]]],[[5,
cr.plugins_.Sprite.prototype.acts.SetAnim,null,6138213854011504,!1,[[1,[2,"idle"]],[3,1]]],[-1,cr.system_object.prototype.acts.Wait,null,0xd246e0166439e,!1,[[0,[1,0.2]]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,8813567207821084,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,6409476451699385,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0xb825821f2b7e7,!1,[[9,38]]],[1,cr.behaviors.Platform.prototype.cnds.IsJumping,"Platform",0,!1,!0,!1,0x767f44e77358d,!1],[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,
"Platform",0,!1,!1,!1,0xc63fd48a18d7d,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0xa7f8093da8eb5,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,5006515121856372,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,7913031031208967,!1,[[9,38]]],[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,!0,!1,0xd75b9e3ecbcbe,!1],[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0x8372c46c111f7,!1,[[11,"duplojump"],[8,0],[7,[0,1]]]]],[[1,cr.behaviors.Platform.prototype.acts.SetVectorY,
"Platform",0xd24aee836bc0d,!1,[[0,[0,-700]]]],[-1,cr.system_object.prototype.acts.AddVar,null,4972571829722861,!1,[[11,"duplojump"],[7,[0,1]]]]]],[0,null,!1,null,0xeab987c6ed103,[[1,cr.behaviors.Platform.prototype.cnds.IsOnFloor,"Platform",0,!1,!1,!1,0x49fe215c599ad,!1]],[[-1,cr.system_object.prototype.acts.SetVar,null,7982464035060347,!1,[[11,"duplojump"],[7,[0,0]]]]]],[0,null,!1,null,0x96260b1e1ac49,[[1,cr.behaviors.Platform.prototype.cnds.OnJump,"Platform",1,!1,!1,!1,0x5fac7ad7479e3,!1]],[[-1,
cr.system_object.prototype.acts.SetVar,null,9216558236880996,!1,[[11,"duplojump"],[7,[0,1]]]]]]]],[0,null,!1,null,0xd16699fac8753,[[-1,cr.system_object.prototype.cnds.EveryTick,null,0,!1,!1,!1,5783722987428497,!1]],[[73,cr.plugins_.Spritefont2.prototype.acts.SetText,null,0x5cbda833dd9bb,!1,[[7,[10,[2,""],[23,"placar"]]]]],[75,cr.plugins_.Text.prototype.acts.SetText,null,4570398586038999,!1,[[7,[10,[2,""],[23,"placar"]]]]]]],[0,null,!1,null,0x9024aa310d42f,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,
null,1,!1,!1,!1,0x4f4f1b224a5b8,!1],[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0x6a928515e19c2,!1,[[11,"playmobile"],[8,0],[7,[0,1]]]]],[[-1,cr.system_object.prototype.acts.SetGroupActive,null,6635804854780999,!1,[[1,[2,"ipadcontrol"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerVisible,null,0xbf5fc1da21a3f,!1,[[5,[0,7]],[3,1]]]]],[0,null,!1,null,0xa2248c1ac86bb,[[-1,cr.system_object.prototype.cnds.IsMobile,null,0,!1,!1,!1,9834276572415738,!1]],[[-1,cr.system_object.prototype.acts.SetVar,
null,5437728688132536,!1,[[11,"playmobile"],[7,[0,1]]]]]],[0,null,!1,null,8032811456015532,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0x9e09e711a76be,!1],[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,6294578833561575,!1,[[11,"playmobile"],[8,0],[7,[0,0]]]]],[[-1,cr.system_object.prototype.acts.SetLayerVisible,null,6517831840291998,!1,[[5,[0,7]],[3,0]]]]],[0,null,!1,null,5438192491174633,[[-1,cr.system_object.prototype.cnds.Compare,null,0,!1,!1,!1,6524033116196447,
!1,[[7,[22,76,"Sine",cr.behaviors.Sin.prototype.exps.CyclePosition,!1,null]],[8,4],[7,[1,0.25]]]]],[[76,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,0x8f11e40803205,!1,[[3,1]]]]],[0,null,!1,null,7195486468842467,[[-1,cr.system_object.prototype.cnds.Compare,null,0,!1,!1,!1,6244728652938722,!1,[[7,[22,76,"Sine",cr.behaviors.Sin.prototype.exps.CyclePosition,!1,null]],[8,4],[7,[1,0.75]]]]],[[76,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,7749360575646436,!1,[[3,0]]]]],[0,null,!1,null,9606083761257394,
[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0x51198c7537148,!1]],[[78,cr.plugins_.Sprite.prototype.acts.StopAnim,null,415016761065852,!1]]],[0,null,!1,null,0xbad5aa7651135,[[5,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,4724502880168289,!1,[[4,76]]],[76,cr.plugins_.Sprite.prototype.cnds.CompareInstanceVar,null,0,!1,!1,!1,5842048479996859,!1,[[10,0],[8,0],[7,[0,0]]]]],[[-1,cr.system_object.prototype.acts.CreateObject,null,0xc65a9cbd9485a,!1,[[4,78],[5,[0,
5]],[0,[20,5,cr.plugins_.Sprite.prototype.exps.ImagePointX,!1,null,[[0,1]]]],[0,[20,5,cr.plugins_.Sprite.prototype.exps.ImagePointY,!1,null,[[0,1]]]]]],[76,cr.plugins_.Sprite.prototype.acts.SetInstanceVar,null,6461716622905261,!1,[[10,0],[7,[0,1]]]],[78,cr.plugins_.Sprite.prototype.acts.ZMoveToObject,null,8008508504224342,!1,[[3,1],[4,76]]],[78,cr.plugins_.Sprite.prototype.acts.StartAnim,null,7670272655057775,!1,[[3,0]]],[78,cr.behaviors.Pin.prototype.acts.Pin,"Pin",5189871606944867,!1,[[4,5],[3,
3]]],[78,cr.behaviors.Fade.prototype.acts.StartFade,"Fade",9113284340729964,!1],[-1,cr.system_object.prototype.acts.AddVar,null,0xf34fb6c5027b3,!1,[[11,"heart"],[7,[0,1]]]]]],[0,null,!1,null,9568860404230682,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0xb57a43c6149b9,!1,[[11,"heart"],[8,0],[7,[0,1]]]]],[[79,cr.plugins_.Sprite.prototype.acts.SetVisible,null,8776752898421466,!1,[[3,1]]]]],[0,null,!1,null,9909739380357066,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,
!1,!1,8626614462872124,!1,[[11,"heart"],[8,0],[7,[0,2]]]]],[[80,cr.plugins_.Sprite.prototype.acts.SetVisible,null,0x7971f9ba7ce05,!1,[[3,1]]]]],[0,null,!1,null,5409549840596792,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0xad3e4b2aa24eb,!1,[[11,"heart"],[8,0],[7,[0,3]]]]],[[81,cr.plugins_.Sprite.prototype.acts.SetVisible,null,0x4ac8bacd7b90c,!1,[[3,1]]]]]]],["sheettreinamento",[[0,null,!1,null,0xea43d550d009c,[[1,cr.plugins_.Sprite.prototype.cnds.CompareY,null,0,!1,!1,!1,0xf24c69f9bc25d,
!1,[[8,4],[0,[19,cr.system_object.prototype.exps.layoutheight]]]]],[[-1,cr.system_object.prototype.acts.RestartLayout,null,5654822686884825,!1],[36,cr.plugins_.Audio.prototype.acts.StopAll,null,8273974528490568,!1]]],[0,null,!1,null,452750858342531,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0xc38948c5197a3,!1]],[[5,cr.behaviors.Pin.prototype.acts.Pin,"Pin",6969822270519836,!1,[[4,1],[3,0]]],[20,cr.behaviors.Pin.prototype.acts.Pin,"Pin",7028306229639736,!1,[[4,5],[3,0]]]]],
[0,null,!1,null,0xaa8b4d656c911,[[3,cr.plugins_.Keyboard.prototype.cnds.OnAnyKeyReleased,null,1,!1,!1,!1,4877986837025183,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x685140ed1f881,!1,[[1,[2,"idle"]],[3,1]]],[21,cr.plugins_.Sprite.prototype.acts.Destroy,null,0xf411fd4400ee3,!1]]],[0,null,!1,null,7331161863694191,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,5840774413412682,!1]],[[21,cr.behaviors.Pin.prototype.acts.Pin,"Pin",6381911158699348,!1,[[4,5],[3,0]]],[21,
cr.plugins_.Sprite.prototype.acts.SetPosToObject,null,0x40b5e0400db41,!1,[[4,5],[7,[0,0]]]],[36,cr.plugins_.Audio.prototype.acts.PlayByName,null,695104354312398,!1,[[3,1],[1,[2,"Avarus_01"]],[3,1],[0,[0,0]],[1,[2,""]]]]]],[0,null,!1,null,380061707469254,[[-1,cr.system_object.prototype.cnds.OnLayoutEnd,null,1,!1,!1,!1,0xd4d7f8ed6d11d,!1]],[[36,cr.plugins_.Audio.prototype.acts.StopAll,null,9501002601963264,!1]]],[0,null,!1,null,0xc712457b9cf21,[[85,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,
0,!1,!1,!0,6107720063326101,!1,[[4,1]]]],[[36,cr.plugins_.Audio.prototype.acts.PlayByName,null,6312450384088766,!1,[[3,0],[1,[2,"musical004"]],[3,0],[0,[0,-2]],[1,[2,"playermusic"]]]]]],[0,null,!1,null,6079511036369103,[[5,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,5885508913871456,!1,[[4,57]]]],[[63,cr.plugins_.Sprite.prototype.acts.SetVisible,null,6521225475154321,!1,[[3,1]]],[63,cr.behaviors.Fade.prototype.acts.StartFade,"Fade",9687906453887740,!1],[-1,cr.system_object.prototype.acts.Wait,
null,9082504644293420,!1,[[0,[0,2]]]],[-1,cr.system_object.prototype.acts.GoToLayoutByName,null,5267119201646441,!1,[[1,[2,"jogo"]]]]]],[0,null,!1,null,7326841951957813,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,5297060643927713,!1,[[4,60]]]],[]],[0,null,!1,null,0xf6b60e6f17ef6,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,0x79e1774489baa,!1,[[4,49]]]],[[60,cr.plugins_.Sprite.prototype.acts.SetVisible,null,9487490689883404,!1,[[3,1]]],[60,cr.behaviors.Fade.prototype.acts.StartFade,
"Fade",6428987759111472,!1],[-1,cr.system_object.prototype.acts.CreateObject,null,25670655796336,!1,[[4,60],[5,[0,0]],[0,[20,60,cr.plugins_.Sprite.prototype.exps.X,!1,null]],[0,[20,60,cr.plugins_.Sprite.prototype.exps.Y,!1,null]]]]]],[0,null,!1,null,5373007660973571,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0xe781b0da23586,!1]],[[62,cr.behaviors.Pin.prototype.acts.Pin,"Pin",5639519055233637,!1,[[4,58],[3,0]]],[63,cr.plugins_.Sprite.prototype.acts.SetVisible,null,9650184112403180,
!1,[[3,0]]]]],[0,null,!1,null,0x83cc34f69703f,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,0x9569ce2b8c064,!1,[[4,62]]]],[]],[0,null,!1,null,7140995790058155,[[5,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,7987485998146218,!1,[[4,25]]]],[[59,cr.plugins_.Sprite.prototype.acts.SetVisible,null,6598423415095721,!1,[[3,1]]]]],[0,null,!1,null,5975893084965648,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,8944096112449418,!1,[[4,59]]]],[[-1,
cr.system_object.prototype.acts.GoToLayoutByName,null,9192794826591822,!1,[[1,[2,"jogo"]]]]]],[0,null,!1,null,5821276880942957,[[1,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,0x7a0fcc8b5b11f,!1,[[4,54]]]],[[64,cr.plugins_.Sprite.prototype.acts.SetVisible,null,6183165108124044,!1,[[3,1]]],[64,cr.behaviors.Fade.prototype.acts.StartFade,"Fade",7818529145068223,!1]]],[0,null,!1,null,6826962391110743,[[5,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,0x6b95452ed8475,!1,
[[4,56]]]],[[65,cr.plugins_.Sprite.prototype.acts.SetVisible,null,5286177995006326,!1,[[3,1]]],[65,cr.behaviors.Fade.prototype.acts.StartFade,"Fade",5672135332529039,!1]]],[0,[!1,"ipadcontrol"],!1,null,7869342542512946,[[-1,cr.system_object.prototype.cnds.IsGroupActive,null,0,!1,!1,!1,7869342542512946,!1,[[1,[2,"ipadcontrol"]]]]],[],[[0,null,!1,null,5052758329365073,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchEnd,null,1,!1,!1,!1,931151595192802,!1]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,
null,9667649816346008,!1,[[1,[2,"idle"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,0x4200e6d746b63,!1,[[5,[0,2]],[0,[0,50]]]]]],[0,null,!1,null,0x626c53a687fef,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xaf1f1ca5a19e0,!1,[[4,45]]]],[[1,cr.behaviors.Platform.prototype.acts.FallThrough,"Platform",7624836251682527,!1],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,6046093296052308,!1,[[1,[2,"jump"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,
null,0xd03315c21536f,!1,[[5,[0,2]],[0,[0,100]]]]]],[0,null,!1,null,8210743627830969,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,7776426628481815,!1,[[4,44]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0xd76433de53fe7,!1,[[3,2]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x72123c51381ea,!1,[[1,[2,"jump"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,0x76ba913bfddeb,!1,[[5,[0,2]],[0,[0,100]]]]]],[0,null,!1,null,0xc6ce9699a098,
[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xd622c125566d1,!1,[[4,46]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0xf182a8232c529,!1,[[3,0]]],[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,6121511608820358,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,9621733762382488,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x90222d1d9cb03,!1,[[1,[2,"walk"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,
null,0xe9a43b10e7f8,!1,[[5,[0,2]],[0,[0,100]]]]]],[0,null,!1,null,0x498479137d03e,[[61,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,7116473516265964,!1,[[4,47]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0x96749f6974924,!1,[[3,1]]],[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,5375178451902329,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,0x50628a5ab715e,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x9f2b41f039ddf,
!1,[[1,[2,"walk"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerOpacity,null,6982838694654828,!1,[[5,[0,2]],[0,[0,100]]]]]]]],[0,null,!1,null,0x6de0055864355,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0xd13ca361ee758,!1],[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,6255945878359837,!1,[[11,"playmobile"],[8,0],[7,[0,1]]]]],[[-1,cr.system_object.prototype.acts.SetGroupActive,null,6048810982133607,!1,[[1,[2,"ipadcontrol"]],[3,1]]],[-1,cr.system_object.prototype.acts.SetLayerVisible,
null,8236728175543533,!1,[[5,[0,2]],[3,1]]]]],[0,null,!1,null,0xf39f77c44809d,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,7927901234475713,!1],[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0xc32b85e6332ea,!1,[[11,"playmobile"],[8,0],[7,[0,0]]]]],[[-1,cr.system_object.prototype.acts.SetLayerVisible,null,9635459555184666,!1,[[5,[0,2]],[3,0]]]]],[0,[!0,"keyboard"],!1,null,8387789644504559,[[-1,cr.system_object.prototype.cnds.IsGroupActive,null,0,!1,!1,!1,8387789644504559,
!1,[[1,[2,"keyboard"]]]]],[],[[0,null,!1,null,6757918979819315,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased,null,1,!1,!1,!1,0x406066854fb0d,!1,[[9,38]]]],[[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x9dbb286d568b1,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,0x964e79abea0d5,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,751446379822874,!1,[[9,38]]]],[[-1,cr.system_object.prototype.acts.Wait,null,0xf0cd10b373d2e,!1,[[0,[0,1]]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,
null,0x6b232251b06b8,!1,[[1,[2,"walk"]],[3,1]]]]],[0,null,!1,null,9711459527410694,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,756697232813349,!1,[[9,40]]]],[[1,cr.behaviors.Platform.prototype.acts.FallThrough,"Platform",9477532473024736,!1],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x4b86903defee1,!1,[[1,[2,"jump"]],[3,1]]]]],[0,null,!1,null,9452811893174376,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,6558587610673812,!1,[[9,38]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,
"Platform",6485133814633643,!1,[[3,2]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x83676602c4173,!1,[[1,[2,"jump"]],[3,1]]]]],[0,null,!1,null,9907228234882220,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,8723030688017172,!1,[[9,87]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",5605090707772134,!1,[[3,2]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x7e07912a95373,!1,[[1,[2,"jump"]],[3,1]]]]],[0,null,!1,null,0xdc89c935352a8,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,
null,0,!1,!1,!1,0xe017097c313dc,!1,[[9,65]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,"Platform",0x61fc44d5d9903,!1,[[3,0]]]]],[0,null,!1,null,0x4bce97ba56abb,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0xb6e2714d4584c,!1,[[9,83]]]],[[1,cr.behaviors.Platform.prototype.acts.FallThrough,"Platform",5480613215550157,!1]]],[0,null,!1,null,0x6fc392c75951f,[[3,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,9061133688519156,!1,[[9,68]]]],[[1,cr.behaviors.Platform.prototype.acts.SimulateControl,
"Platform",6520527069174837,!1,[[3,1]]]]],[0,null,!0,null,8022716592685132,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,5605297606639196,!1,[[9,37]]],[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,8551875176969303,!1,[[9,65]]]],[[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,8159818684280412,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,6164008861674439,!1,[[3,0]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0xecb7abb57d4ba,!1,[[1,[2,
"walk"]],[3,1]]]]],[0,null,!0,null,6296568835842859,[[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,0x6edd1b9bdb44e,!1,[[9,39]]],[3,cr.plugins_.Keyboard.prototype.cnds.OnKey,null,1,!1,!1,!1,8168756638176151,!1,[[9,68]]]],[[1,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,8469177506379186,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetMirrored,null,6696059191064887,!1,[[3,1]]],[5,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0xec7c5116e2c61,!1,[[1,[2,"walk"]],[3,1]]]]]]]]],
["sheetabertura",[[0,null,!1,null,0xffcc604ede505,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,9028997564538774,!1,[[4,68]]]],[[-1,cr.system_object.prototype.acts.GoToLayoutByName,null,0xfbd6d0f8fe7f0,!1,[[1,[2,"treinamento"]]]]]],[0,null,!1,null,8656105669245088,[[61,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,5284631654721004,!1,[[4,66]]]],[[-1,cr.system_object.prototype.acts.GoToLayoutByName,null,8261059046118572,!1,[[1,[2,"jogo"]]]]]],[0,null,!1,null,
9084369186510766,[[-1,cr.system_object.prototype.cnds.IsMobile,null,0,!1,!1,!1,7105925874584015,!1]],[[-1,cr.system_object.prototype.acts.SetVar,null,9736467250434256,!1,[[11,"playmobile"],[7,[0,1]]]]]]]]],"",!1,1024,768,3,!0,!0,!0,"1.0",1,!1,0,!1,156,!1,[]]};

createCocoonJSRuntime();

})();
