/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 513:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Game = void 0;
var Game = /** @class */ (function () {
    function Game() {
        var _this = this;
        this.showToolbox = function (root) {
            var form = document.createElement('form');
            form.style.padding = '10px 5px';
            form.style.background = '#2f2f2f';
            form.style.color = 'white';
            form.style.position = 'fixed';
            form.style.top = '50vh';
            form.style.left = '0';
            form.style.display = 'flex';
            form.style.flexDirection = 'column';
            var isShowHitboxCheckbox = _this.createCheckbox('Хитбокс', 'isShowHitbox');
            var isShowGridCheckbox = _this.createCheckbox('Сетка', 'isShowGrid');
            var isShowHitboxGridCheckbox = _this.createCheckbox('Сетка хитбокса', 'isShowHitboxGrid');
            form.append(isShowHitboxCheckbox);
            form.append(isShowGridCheckbox);
            form.append(isShowHitboxGridCheckbox);
            document.querySelector(root || 'body').append(form);
        };
        this.createCheckbox = function (innerText, name) {
            var checkbox = document.createElement('input');
            checkbox.name = name;
            checkbox.type = 'checkbox';
            // @ts-ignore
            checkbox.onchange = function () { return Game[name] = !Game[name]; };
            var label = document.createElement('label');
            label.innerText = innerText;
            label.append(checkbox);
            return label;
        };
        if (!Game.instance) {
            Game.instance = this;
        }
        return Game.instance;
    }
    return Game;
}());
exports.Game = Game;
exports["default"] = Game;


/***/ }),

/***/ 607:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CanvasObject = void 0;
function addEventListener(type, cb) {
    this.listeners[type] = cb;
}
var CanvasObject = /** @class */ (function () {
    function CanvasObject() {
        this.isOver = false;
        this.listeners = {};
        this.addEventListener = addEventListener.bind(this);
        this.map = {};
        this.id = -1;
        this.gridColor = 'black';
        this.isCb = function (arg) { return typeof arg === 'function'; };
    }
    return CanvasObject;
}());
exports.CanvasObject = CanvasObject;


/***/ }),

/***/ 904:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Grid = void 0;
var GameObject_1 = __webpack_require__(607);
var constants_1 = __webpack_require__(396);
var utils_1 = __webpack_require__(147);
var Game_1 = __importDefault(__webpack_require__(513));
var Grid = /** @class */ (function (_super) {
    __extends(Grid, _super);
    function Grid() {
        var _this = _super.call(this) || this;
        _this.width = constants_1.ORIGIN_PARAMS.gridCellWidth;
        _this.height = constants_1.ORIGIN_PARAMS.gridCellHeight;
        _this.cells = {};
        _this.updateCell = function (x, y, data, canvas, gridColor) {
            _this.cells[(0, utils_1.getMapKey)(x, y)] = __assign(__assign({}, _this.cells[(0, utils_1.getMapKey)(x, y)]), data);
            if (Game_1.default.isShowHitboxGrid) {
                _this.drawCell(canvas)({
                    x: x,
                    y: y,
                    strokeStyle: gridColor,
                });
            }
        };
        _this.drawCell = function (canvas) { return function (params) {
            var object = new Path2D();
            canvas.context.fillStyle = 'transparent';
            canvas.context.strokeStyle = params.strokeStyle || '#8292ff';
            object.rect(params.x * _this.width, params.y * _this.height, _this.width, _this.height);
            canvas.context.stroke(object);
            canvas.context.fill(object);
        }; };
        _this.draw = function (canvas) {
            var xCount = constants_1.ORIGIN_PARAMS.canvasWidth / constants_1.ORIGIN_PARAMS.gridCellWidth;
            var yCount = constants_1.ORIGIN_PARAMS.canvasHeight / constants_1.ORIGIN_PARAMS.gridCellHeight;
            for (var x = 0; x < xCount; x++) {
                for (var y = 0; y < yCount; y++) {
                    if (Game_1.default.isShowGrid) {
                        _this.drawCell(canvas)({ x: x, y: y });
                    }
                    _this.cells[(0, utils_1.getMapKey)(x, y)] = {
                        x: x,
                        y: y,
                        cost: 0,
                        id: -1,
                    };
                }
            }
        };
        _this.width = constants_1.ORIGIN_PARAMS.gridCellWidth;
        _this.height = constants_1.ORIGIN_PARAMS.gridCellHeight;
        return _this;
    }
    return Grid;
}(GameObject_1.CanvasObject));
exports.Grid = Grid;
exports["default"] = Grid;


/***/ }),

/***/ 396:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BACKGROUND = exports.ORIGIN_PARAMS = void 0;
exports.ORIGIN_PARAMS = {
    canvasWidth: 1420,
    canvasHeight: 1020,
    gridCellWidth: 20,
    gridCellHeight: 20,
    cellWidth: 50,
    cellHeight: 50,
};
exports.BACKGROUND = '#b7f2ff';


/***/ }),

/***/ 147:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getMapKey = void 0;
var getMapKey = function (x, y) { return "x".concat(x, "y").concat(y); };
exports.getMapKey = getMapKey;


/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module is referenced by other modules so it can't be inlined
/******/ 	var __webpack_exports__ = __webpack_require__(904);
/******/ 	var __webpack_export_target__ = exports;
/******/ 	for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
/******/ 	if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
/******/ 	
/******/ })()
;