// Class: openfl._internal.renderer.dom.DOMTilemap

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../../../hxClasses_stub").default;
var $import = require("./../../../../import_stub").default;
function js_Browser() {return require("./../../../../js/Browser");}
function openfl__$internal_renderer_dom_DOMRenderer() {return require("./../../../../openfl/_internal/renderer/dom/DOMRenderer");}
function openfl__$internal_renderer_canvas_CanvasTilemap() {return require("./../../../../openfl/_internal/renderer/canvas/CanvasTilemap");}

// Constructor

var DOMTilemap = function(){}

// Meta

DOMTilemap.__name__ = ["openfl","_internal","renderer","dom","DOMTilemap"];
DOMTilemap.prototype = {
	
};
DOMTilemap.prototype.__class__ = $hxClasses["openfl._internal.renderer.dom.DOMTilemap"] = DOMTilemap;

// Init



// Statics

DOMTilemap.clear = function(tilemap,renderSession) {
	if(tilemap.__canvas != null) {
		renderSession.element.removeChild(tilemap.__canvas);
		tilemap.__canvas = null;
		tilemap.__style = null;
	}
}
DOMTilemap.render = function(tilemap,renderSession) {
	if(tilemap.stage != null && tilemap.__worldVisible && tilemap.__renderable && tilemap.__tiles.get_length() > 0) {
		if(tilemap.__canvas == null) {
			tilemap.__canvas = (js_Browser().default).get_document().createElement("canvas");
			tilemap.__context = tilemap.__canvas.getContext("2d");
			(openfl__$internal_renderer_dom_DOMRenderer().default).initializeElement(tilemap,tilemap.__canvas,renderSession);
		}
		tilemap.__canvas.width = tilemap.__width;
		tilemap.__canvas.height = tilemap.__height;
		tilemap.__context.globalAlpha = tilemap.__worldAlpha;
		renderSession.context = tilemap.__context;
		(openfl__$internal_renderer_canvas_CanvasTilemap().default).render(tilemap,renderSession);
		renderSession.context = null;
		(openfl__$internal_renderer_dom_DOMRenderer().default).updateClip(tilemap,renderSession);
		(openfl__$internal_renderer_dom_DOMRenderer().default).applyStyle(tilemap,renderSession,true,false,true);
	} else {
		DOMTilemap.clear(tilemap,renderSession);
	}
}


// Export

exports.default = DOMTilemap;