/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 15);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export isObject */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isCommonArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isTypedArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isEqual; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return removeFromArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return parametrizeString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return noop; });
var isObject = function (obj) {
    return obj === Object(obj);
};
var isCommonArray = function (a) {
    return !!(a.splice);
};
var isTypedArray = function (a) {
    return !!(a.buffer);
};
var isArray = function (a) {
    return isCommonArray(a) || isTypedArray(a);
};
var isEqualArray = function (a, b) {
    for (var i = 0, max = a.length; i < max; i++) {
        if (a[i] !== b[i])
            return false;
    }
    return true;
};
var isEqualObject = function (a, b) {
    throw new Error('not implemented');
};
var isEqual = function (a, b) {
    if (a === null || a === undefined)
        return false;
    if (isArray(a) && isArray(b))
        return isEqualArray(a, b);
    else if (isObject(a) && isObject(b))
        return isEqualObject(a, b);
    return a === b;
};
var removeFromArray = function (arr, predicate) {
    var i = arr.length;
    var cnt = 0;
    while (i--) {
        if (predicate(arr[i])) {
            arr.splice(i, 1);
            cnt++;
        }
    }
    return cnt;
};
var parametrizeString = function (source, args) {
    Object.keys(args).forEach(function (key) {
        source = source.split(key).join('' + args[key]);
    });
    return source;
};
var noop = function (arg) { };


/***/ }),

/***/ 15:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);

// EXTERNAL MODULE: ./engine/misc/object.ts
var object = __webpack_require__(0);

// CONCATENATED MODULE: ./engine/debug/httpClient.ts

var objectToQuery = function (o) {
    if (o === undefined || o === null)
        return '';
    if (o instanceof FormData)
        return o;
    var paramsArr = [];
    if (typeof o === 'string' || typeof o === 'number')
        return o.toString();
    for (var key in o) {
        paramsArr.push([key, encodeURIComponent(o[key])]);
    }
    return paramsArr.map(function (item) { return [item[0] + '=' + item[1]]; }).join('&');
};
var request = function (data) {
    var abortTmr;
    var resolved = false;
    data.method = data.method || 'get';
    if (data.data && data.method === 'get')
        data.url += '?' + objectToQuery(data.data);
    var xhr = new XMLHttpRequest();
    var resolveFn = object["e" /* noop */], rejectFn = object["e" /* noop */];
    var promise;
    if (window.Promise) {
        promise = new Promise(function (resolve, reject) {
            resolveFn = resolve;
            rejectFn = reject;
        });
    }
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            if (xhr.status === 200 || xhr.status === 0) {
                var resp = xhr.responseText;
                var contentType = xhr.getResponseHeader("Content-Type") || '';
                if (contentType.toLowerCase().indexOf('json') > -1)
                    resp = JSON.parse(resp);
                if (data.success) {
                    data.success(resp);
                }
                resolveFn(resp);
            }
            else {
                if (data.error)
                    data.error({ status: xhr.status, error: xhr.statusText });
                rejectFn(xhr.statusText);
            }
            clearTimeout(abortTmr);
            resolved = true;
        }
    };
    xhr.open(data.method, data.url, true);
    if (data.requestType) {
        if (data.requestType !== 'multipart/form-data')
            xhr.setRequestHeader("Content-Type", data.requestType);
    }
    else {
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    }
    if (data.requestType === 'application/json')
        data.data = data.data && JSON.stringify(data.data);
    xhr.send(data.data);
    if (data.timeout) {
        abortTmr = setTimeout(function () {
            if (resolved)
                return;
            xhr.abort();
            if (data.ontimeout)
                data.ontimeout();
            rejectFn('timeout');
        }, data.timeout);
    }
    return promise;
};
var httpClient;
(function (httpClient) {
    httpClient.get = function (url, data, success, error) {
        return request({
            method: 'get',
            url: url,
            data: data,
            success: success,
            error: error
        });
    };
    httpClient.post = function (url, data, success, error) {
        return request({
            method: 'post',
            url: url,
            data: data,
            requestType: 'application/json',
            success: success,
            error: error
        });
    };
    httpClient.postMultiPart = function (url, file, data, success, error) {
        var formData = new FormData();
        Object.keys(data).forEach(function (key) {
            formData.append(key, data[key]);
        });
        formData.append('file', file);
        formData.append('fileName', file.name);
        return request({
            method: 'post',
            url: url,
            data: formData,
            requestType: 'multipart/form-data',
            success: success,
            error: error
        });
    };
})(httpClient || (httpClient = {}));

// CONCATENATED MODULE: ./engine/debug/debug.ts

var devConsole = document.createElement('div');
var css = {
    "position": 'absolute',
    "right": 0,
    "top": 0,
    'background-color': 'black',
    'min-width': '20px',
    'min-height': '20px',
    'opacity': 0.5,
    'pointer-events': 'none',
    'display': 'block',
    'z-index': 1000
};
Object.keys(css).forEach(function (key) { return devConsole.style.setProperty(key, '' + css[key]); });
var fpsLabel = document.createElement('span');
fpsLabel.style.cssText = 'color:white;user-select: none;';
devConsole.appendChild(fpsLabel);
var tmr;
var onLoad = function (fn) {
    if (document.readyState === 'complete')
        fn();
    else {
        window.addEventListener('load', function (e) {
            fn();
        });
    }
};
onLoad(function () {
    document.body.appendChild(devConsole);
    tmr = setInterval(function () {
        var game = window.game;
        if (!game)
            return;
        fpsLabel.textContent = 'fps:' + ("" + game.fps) || false;
    }, 1000);
});
var prepareMessage = function (e, lineNum) {
    var msg;
    if (typeof e === 'string') {
        msg = e;
    }
    else
        msg = e.message || e.reason || e.error;
    if (msg && msg.message)
        msg = msg.message;
    if (!msg) {
        if (e.target) {
            ['img', 'audio', 'link', 'script'].some(function (it) {
                if (e.target.tagName && e.target.tagName.toLowerCase() === it) {
                    msg = "can not load " + it + " with location " + (e.target.src || e.target.href);
                    return true;
                }
                return false;
            });
        }
    }
    if (!msg)
        msg = '';
    if (msg.indexOf('Uncaught') === 0)
        msg = msg.replace('Uncaught', '').trim();
    if (!msg) {
        msg = 'Unknown error: ' + e.toString();
    }
    if (lineNum)
        msg = "error in line " + lineNum + ":  " + msg;
    return msg;
};
var renderError = function (filename, runtimeInfo, debugInfo) {
    var tmpl = "\n\n        <style>\n            .errorHeader {text-align: center;}\n            .errorText {\n                color: #ff8882;\n                white-space: pre-wrap;\n            }\n            .errorCol {color: #f30000;text-decoration: underline;}\n            .errorRow {\n                color: #bf1313;\n                font-weight: bold;\n            }\n            .errorBlockHolder {\n                background: #615f5fb8;\n                height: 100%;\n                bottom: 0;\n                left: 0;\n                right: 0;\n                top: 0;\n                position: absolute;\n            }\n            .errorBlock {\n                position: absolute;\n                left: 0;top:0;right:0;\n                border: 1px solid grey;\n                background-color: rgba(21, 15, 121, 0.88);\n                font-family: monospace;\n                padding: 10px;\n                -webkit-touch-callout: default;\n                -webkit-user-select: text;\n                user-select: text;\n                color: #fffef8;\n            }\n            .errorBlockInternal {\n                padding: 5px;\n                border: 1px solid #8f9624;\n            }\n            .errorClose {\n                position: absolute;\n                top: 15px;\n                right: 5px;\n                content: 'x';\n                width: 20px;\n                height: 20px;\n                cursor: pointer;\n                color: white;\n            }\n       </style>\n\n  <div class=\"errorBlock\">\n        <div class=\"errorBlockInternal\">\n            <div class=\"errorClose\" onclick=\"this.closest('.errorBlockHolder').remove();\">x</div>\n            <h1 class=\"errorHeader\">Runtime error!</h1>\n            <h3 class=\"errorText\">" + runtimeInfo + "</h3>\n            <div>" + (filename ? filename : '') + "</div>\n            <div>-------------------</div>\n           <pre>$_content</pre>\n        </div>\n  </div>\n\n";
    var errDiv = document.createElement('div');
    errDiv.className = 'errorBlockHolder';
    errDiv.innerHTML = tmpl.replace('$_content', debugInfo);
    document.body.appendChild(errDiv);
    document.title = 'runtime error!';
    devConsole.style.display = 'none';
};
var stopGame = function () {
    clearInterval(tmr);
    var game = window.game;
    if (game) {
        try {
            game.destroy();
        }
        catch (e) {
            console.error(e);
        }
    }
};
var handleCatchError = function (e) {
    var lineNum = e.lineno;
    var colNum = e.colno;
    var filename = e.filename;
    var runtimeInfo = prepareMessage(e, lineNum);
    if (filename) {
        try {
            httpClient.get(filename, { r: Math.random() }, function (file) {
                if (!file)
                    return;
                try {
                    var strings = file.split('\n');
                    var linesAfter = 5;
                    var linesBefore = 5;
                    var errorString = strings[lineNum - 1] || '';
                    errorString = errorString.substr(0, colNum - 1) + "<span class=\"errorCol\">" + errorString[colNum - 1] + "</span>" + errorString.substr(colNum);
                    errorString = "<span class=\"errorRow\">" + errorString + "</span>\n";
                    var debugInfo = '';
                    for (var i = -linesBefore; i < linesAfter; i++) {
                        var index = lineNum + i;
                        if (index < 0 || index > strings.length - 1)
                            continue;
                        var s = strings[index];
                        if (index === lineNum - 1)
                            debugInfo += errorString;
                        else
                            debugInfo += s + '\n';
                    }
                    renderError(filename, runtimeInfo, debugInfo);
                }
                catch (e) {
                    console.error(e);
                    renderError('', runtimeInfo, '');
                }
            }, function (err) {
                console.error(err);
                renderError('', runtimeInfo, '');
            });
        }
        catch (e) {
            renderError('', runtimeInfo, '');
        }
    }
    else {
        renderError('', runtimeInfo, '');
    }
};
var extractPromiseError = function (e) {
    var r = 'Async error\n';
    if (e.substr !== undefined)
        r += e;
    if (e.message)
        r += e.message + "\n";
    if (e.stack)
        r += e.stack;
    return r;
};
window.addEventListener('error', function (e) {
    stopGame();
    handleCatchError(e);
}, true);
window.addEventListener('unhandledrejection', function (e) {
    stopGame();
    renderError('', extractPromiseError(e.reason), '');
});


/***/ })

/******/ });