"use strict";
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var application_context_1 = require("../app/application-context");
var events_1 = require("events");
var sdl_window_opts_1 = require("./sdl-window-opts");
var sdl_context_1 = require("../sdl-context");
var messagebox_1 = require("./messagebox");
var sdl_1 = require("../sdl");
var mouse_event_1 = require("../event/mouse-event");
var key_event_1 = require("../event/key-event");
var sdl_document_1 = require("../document/sdl-document");
var sdl_canvas_1 = require("../canvas/sdl-canvas");
var sdl_navigator_1 = require("./sdl-navigator");
var sdl_performance_1 = require("../performance/sdl-performance");
var NodeCanvasImage = require('canvas').Image;
var createInternalCanvas = require('canvas').createCanvas;
var loadImage = require('canvas').loadImage;
var SdlWindow = /** @class */ (function (_super) {
    __extends(SdlWindow, _super);
    function SdlWindow(options) {
        var _this = _super.call(this) || this;
        _this.options = options;
        _this._hasMouseEnteredWindow = false;
        _this.init();
        _this._navigator = new sdl_navigator_1.SdlNavigator(_this);
        _this._performance = new sdl_performance_1.SdlPerformance(_this);
        _this.createCanvas();
        application_context_1.applicationContext.registerWindow(_this);
        setTimeout(function () {
            _this.emit('load');
        }, 100);
        return _this;
    }
    SdlWindow.prototype.disableFullScreen = function () {
        this.fullScreen = false;
    };
    SdlWindow.prototype.enableFullScreen = function () {
        this.fullScreen = true;
    };
    SdlWindow.prototype.windowImplementation = function () {
        return this;
    };
    SdlWindow.prototype.stopPropagation = function (event) {
    };
    SdlWindow.prototype.stopImmediatePropagation = function (event) {
    };
    SdlWindow.prototype.preventDefault = function (event) {
    };
    SdlWindow.prototype.addEventListener = function (type, listener, options) {
        switch (type) {
            case 'load':
            case 'DOMContentLoaded':
                this.on('load', listener);
                break;
            case 'dragstart':
                this.on('dropBegin', listener);
                break;
            case 'drop':
                this.on('drop', listener);
                break;
            case 'mouseleave':
            case 'mouseout':
                this.on('mouseleave', listener);
                break;
            case 'maximize':
                this.on(type, listener);
                break;
            case 'minimize':
                this.on(type, listener);
                break;
            case 'mouseenter':
            case 'mouseover':
                this.on('mouseenter', listener);
                break;
            case 'move':
                this.on(type, listener);
                break;
            case 'hide':
                this.on(type, listener);
                break;
            case 'show':
                this.on(type, listener);
                break;
            case 'resize':
                this.on(type, listener);
                break;
            case 'blur':
                this.on(type, listener);
                break;
            case 'focus':
                this.on(type, listener);
                break;
            case 'close':
                this.on(type, listener);
                break;
            case 'datachange':
                this.on('change', listener);
                break;
            case 'keyup':
                this.on(type, listener);
                break;
            case 'keydown':
                this.on(type, listener);
                break;
            case 'keypress':
                this.on(type, listener);
                break;
            case 'mousemove':
                this.on('mousemove', listener);
                break;
            case 'mousedown':
                this.on(type, listener);
                break;
            case 'mouseup':
                this.on(type, listener);
                break;
            case 'mousewheel':
                this.on(type, listener);
                break;
            case 'click':
                this.on(type, listener);
                break;
        }
    };
    SdlWindow.prototype.alert = function (message) {
        messagebox_1.alert(message || '', this._windowPtr);
    };
    SdlWindow.prototype.atob = function (encodedString) {
        return '';
    };
    SdlWindow.prototype.blur = function () {
        this.emit('blur');
    };
    SdlWindow.prototype.btoa = function (rawString) {
        return '';
    };
    SdlWindow.prototype.cancelAnimationFrame = function (handle) {
        var _this = this;
        this.listeners('renderFrame').forEach(function (listener) {
            _this.off('renderFrame', listener);
        });
    };
    SdlWindow.prototype.captureEvents = function () {
    };
    SdlWindow.prototype.clearInterval = function (handle) {
    };
    SdlWindow.prototype.clearTimeout = function (handle) {
    };
    SdlWindow.prototype.confirm = function (message) {
        return messagebox_1.confirm(message, this._windowPtr);
    };
    SdlWindow.prototype.createImageBitmap = function (image, sx, sy, sw, sh) {
        return undefined;
    };
    SdlWindow.prototype.departFocus = function (navigationReason, origin) {
    };
    SdlWindow.prototype.dispatchEvent = function (event) {
        return false;
    };
    SdlWindow.prototype.fetch = function (input, init) {
        return undefined;
    };
    SdlWindow.prototype.getComputedStyle = function (elt, pseudoElt) {
        return undefined;
    };
    SdlWindow.prototype.getMatchedCSSRules = function (elt, pseudoElt) {
        return undefined;
    };
    SdlWindow.prototype.getSelection = function () {
        return undefined;
    };
    SdlWindow.prototype.matchMedia = function (query) {
        return undefined;
    };
    SdlWindow.prototype.moveBy = function (x, y) {
    };
    SdlWindow.prototype.moveTo = function (x, y) {
    };
    SdlWindow.prototype.msWriteProfilerMark = function (profilerMarkName) {
    };
    SdlWindow.prototype.open = function (url, target, features, replace) {
        return undefined;
    };
    SdlWindow.prototype.postMessage = function (message, targetOrigin, transfer) {
    };
    SdlWindow.prototype.print = function () {
    };
    SdlWindow.prototype.prompt = function (message, _default) {
        return undefined;
    };
    SdlWindow.prototype.queueMicrotask = function (callback) {
    };
    SdlWindow.prototype.releaseEvents = function () {
    };
    SdlWindow.prototype.removeEventListener = function (type, listener, options) {
        switch (type) {
            case 'mouseleave':
            case 'mouseout':
                this.off('mouseleave', listener);
                break;
            case 'mouseenter':
            case 'mouseover':
                this.off('mouseenter', listener);
                break;
            case 'datachange':
                this.off('change', listener);
                break;
            default:
                this.off(type, listener);
                break;
        }
    };
    SdlWindow.prototype.requestAnimationFrame = function (callback) {
        this.once('renderFrame', callback);
        return Number.MAX_VALUE;
    };
    SdlWindow.prototype.resizeBy = function (x, y) {
    };
    SdlWindow.prototype.resizeTo = function (x, y) {
    };
    SdlWindow.prototype.scroll = function (options, y) {
    };
    SdlWindow.prototype.scrollBy = function (options, y) {
    };
    SdlWindow.prototype.scrollTo = function (options, y) {
    };
    SdlWindow.prototype.setInterval = function (handler, timeout) {
        var args = [];
        for (var _i = 2; _i < arguments.length; _i++) {
            args[_i - 2] = arguments[_i];
        }
        return setInterval(handler, timeout, args);
    };
    SdlWindow.prototype.setTimeout = function (handler, timeout) {
        var args = [];
        for (var _i = 2; _i < arguments.length; _i++) {
            args[_i - 2] = arguments[_i];
        }
        return setTimeout(handler, timeout, args);
    };
    SdlWindow.prototype.stop = function () {
    };
    SdlWindow.prototype.webkitCancelAnimationFrame = function (handle) {
        this.cancelAnimationFrame(handle);
    };
    SdlWindow.prototype.webkitConvertPointFromNodeToPage = function (node, pt) {
        return undefined;
    };
    SdlWindow.prototype.webkitConvertPointFromPageToNode = function (node, pt) {
        return undefined;
    };
    SdlWindow.prototype.webkitRequestAnimationFrame = function (callback) {
        return this.requestAnimationFrame(callback);
    };
    Object.defineProperty(SdlWindow.prototype, "canvasWidth", {
        get: function () {
            return this._context.width;
        },
        set: function (val) {
            if (this.options.scaleCanvasToWindowSize) {
                var size = this.size;
                this.size = size = { w: val, h: size.h };
            }
            else if (this.options.fitCanvasInWindow) {
                var size = this.size;
                this.size = size = { w: val, h: size.h };
                this._internalCanvas.width = size.w;
            }
            else {
                this._internalCanvas.width = val;
            }
        },
        enumerable: true,
        configurable: true
    });
    SdlWindow.prototype.configureCanvasSize = function (w, h) {
        if (this.options.fitCanvasInWindow) {
            this._internalCanvas.width = this.size.w;
            this._internalCanvas.height = this.size.h;
        }
        else {
            this._internalCanvas.width = w;
            this._internalCanvas.height = h;
        }
    };
    Object.defineProperty(SdlWindow.prototype, "canvasHeight", {
        get: function () {
            return this._context.height;
        },
        set: function (val) {
            if (this.options.scaleCanvasToWindowSize) {
                var size = this.size;
                this.size = size = { w: size.w, h: val };
            }
            else if (this.options.fitCanvasInWindow) {
                var size = this.size;
                this.size = size = { w: size.w, h: val };
                this._internalCanvas.height = size.h;
            }
            else {
                this._internalCanvas.height = val;
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "canvasY", {
        set: function (y) {
            if (this.options.fitCanvasInWindow) {
                this._context.y = 0;
            }
            else {
                this._context.y = y;
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "canvasX", {
        get: function () {
            return this._context.x;
        },
        set: function (x) {
            if (this.options.fitCanvasInWindow) {
                this._context.x = 0;
            }
            else {
                this._context.x = x;
            }
        },
        enumerable: true,
        configurable: true
    });
    SdlWindow.prototype.getCanvas = function () {
        return this._canvas;
    };
    SdlWindow.prototype.renderFrame = function (ms) {
        this.emit('renderFrame', ms);
        var canvas = this._internalCanvas;
        var width = canvas.width, height = canvas.height;
        var size = this.size;
        var buffer = canvas.toBuffer('raw'); // ARGB32
        // console.time('renderFrame');
        this._context.renderFrame(buffer, width, height);
        // this._context.renderFrame(buffer, width, height);
        // console.timeEnd('renderFrame');
    };
    SdlWindow.prototype.init = function () {
        var sdlOpts = sdl_window_opts_1.getSdlWindowOptions(this.options);
        // Create the window, and store its pointer;
        this._windowPtr = sdl_1.SDL_CreateWindow(sdlOpts.title, sdlOpts.x, sdlOpts.y, sdlOpts.w, sdlOpts.h, sdlOpts.flags);
        // this.windowSurface = SDL_GetWindowSurface(this.windowPtr);
        // Create a SDL Context to handle the abstractions
        this._context = sdl_context_1.createSdlContext2D(this._windowPtr);
        // this._context = createSoftwareSdlContext2D(this._windowPtr);
        this.initSize();
        this.initContextSize();
        this._document = new sdl_document_1.SdlDocument(this);
        this.initEvents();
    };
    SdlWindow.prototype.initCanvasColors = function () {
        var ctx = this._internalCanvas.getContext('2d');
        ctx.fillStyle = '#FFFFFF';
        ctx.strokeStyle = '#000000';
        ctx.fillRect(0, 0, this._internalCanvas.width, this._internalCanvas.height);
        ctx.fillStyle = '#000000';
        ctx.strokeStyle = '#000000';
    };
    SdlWindow.prototype.initWindowEvents = function () {
        var _this = this;
        this.on('sdlEvent', function (event) {
            if (event.type === sdl_1.SDL_EventType.SDL_WINDOWEVENT) {
                var evt = event.window.event;
                if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN) {
                    _this.emit('show');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN) {
                    _this.emit('hide');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_EXPOSED) {
                    // this.triggerWindowSizeChange();
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_MOVED) {
                    _this.emit('move', event.window.data1, event.window.data2);
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED) {
                    _this.triggerWindowSizeChange();
                    _this.emit('resize', event.window.data1, event.window.data2);
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED) {
                    // this._change(event.window.data1, event.window.data2);
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED) {
                    _this.emit('minimize');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED) {
                    _this.emit('maximize');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED) {
                    _this.emit('restore');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER) {
                    _this._hasMouseEnteredWindow = true;
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE) {
                    if (_this._lastMouseEvent) {
                        _this.emit('mouseleave', _this._lastMouseEvent);
                    }
                    _this._hasMouseEnteredWindow = false;
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED) {
                    _this.emit('focus');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST) {
                    _this.emit('blur');
                }
                else if (evt === sdl_1.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE) {
                    _this.close();
                }
            }
        });
    };
    SdlWindow.prototype.initKeyEvents = function () {
        var _this = this;
        this.on('sdlEvent', function (event) {
            if (event.type === sdl_1.SDL_EventType.SDL_KEYDOWN) {
                var domEvent = key_event_1.getCurrentKeyEvent(event, _this);
                _this.emit('keydown', domEvent);
                _this._lastKeyboardEvent = domEvent;
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_KEYUP) {
                var domEvent = key_event_1.getCurrentKeyEvent(event, _this);
                _this.emit('keyup', domEvent);
                _this._lastKeyboardEvent = null;
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_TEXTINPUT) {
                var buf = Buffer.from(event.text.text);
                var str = buf.reinterpretUntilZeros(1).toString();
                var domEvent = key_event_1.getCurrentKeyEvent(event, _this);
                domEvent.key = str;
                domEvent.keyCode = domEvent.charCode = str.codePointAt(0);
                domEvent.ctrlKey = _this._lastKeyboardEvent.ctrlKey;
                domEvent.shiftKey = _this._lastKeyboardEvent.shiftKey;
                domEvent.altKey = _this._lastKeyboardEvent.altKey;
                domEvent.metaKey = _this._lastKeyboardEvent.metaKey;
                _this.emit('keypress', domEvent);
            }
        });
    };
    SdlWindow.prototype.initDragAndDropEvents = function () {
        var _this = this;
        this.on('sdlEvent', function (event) {
            if (event.type === sdl_1.SDL_EventType.SDL_DROPFILE) {
                // this.emit('dropFile', event.drop.file);
                var drop = event.drop;
                var data = { file: event.drop.file };
                _this.emit('drop', data);
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_DROPBEGIN) {
                _this.emit('dropBegin', event.drop.file);
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_DROPCOMPLETE) {
                _this.emit('dropDone', event.drop.file);
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_CLIPBOARDUPDATE) {
                _this.emit('clipboard');
            }
        });
    };
    SdlWindow.prototype.initMouseEvents = function () {
        var _this = this;
        this.on('sdlEvent', function (event) {
            if (event.type === sdl_1.SDL_EventType.SDL_MOUSEMOTION) {
                var domEvent = mouse_event_1.getCurrentMouseEvent(event, _this);
                _this.decorateMouseEvent(domEvent);
                if (_this._hasMouseEnteredWindow) {
                    _this.emit('mouseenter', domEvent);
                    _this._hasMouseEnteredWindow = false;
                }
                _this.emit('mousemove', domEvent);
                _this._lastMouseEvent = domEvent;
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_MOUSEBUTTONDOWN) {
                var domEvent = mouse_event_1.getCurrentMouseEvent(event, _this);
                _this.emit('mousedown', domEvent);
            }
            else if (event.type === sdl_1.SDL_EventType.SDL_MOUSEBUTTONUP) {
                var domEvent = mouse_event_1.getCurrentMouseEvent(event, _this);
                _this.emit('mouseup', domEvent);
                _this.emit('click', domEvent);
            }
        });
    };
    SdlWindow.prototype.decorateMouseEvent = function (event) {
        var castedEvent = event;
        if (this._lastKeyboardEvent) {
            castedEvent.altKey = this._lastKeyboardEvent.altKey;
            castedEvent.ctrlKey = this._lastKeyboardEvent.ctrlKey;
            castedEvent.shiftKey = this._lastKeyboardEvent.shiftKey;
            castedEvent.metaKey = this._lastKeyboardEvent.metaKey;
        }
    };
    SdlWindow.prototype.initEvents = function () {
        this.initWindowEvents();
        this.initMouseEvents();
        this.initKeyEvents();
        this.initDragAndDropEvents();
    };
    SdlWindow.prototype.initContextSize = function () {
        var size = this.size;
        this._context.setSize(size.w, size.h);
    };
    SdlWindow.prototype.initSize = function () {
        this.size = sdl_1.SDL_GetWindowSize(this._windowPtr);
    };
    SdlWindow.prototype.triggerWindowSizeChange = function () {
        this.initSize();
        if (!this.options.scaleCanvasToWindowSize) {
            this.initContextSize();
        }
        var size = this.size;
        this.initCanvasSize(size);
        this.emit('change', size.w, size.h);
    };
    SdlWindow.prototype.grab = function () {
        sdl_1.SDL_SetWindowGrab(this._windowPtr, true);
    };
    SdlWindow.prototype.focus = function () {
        sdl_1.SDL_RaiseWindow(this._windowPtr);
    };
    SdlWindow.prototype.close = function () {
        if (!this.options.closable) {
            return;
        }
        this.destroy();
    };
    SdlWindow.prototype.destroy = function () {
        // this.rendererPtr.destroy();
        sdl_1.SDL_DestroyWindow(this._windowPtr);
        this.emit('_closed');
    };
    SdlWindow.prototype.restore = function () {
        sdl_1.SDL_RestoreWindow(this._windowPtr);
    };
    SdlWindow.prototype.center = function () {
        this.position = [0x2FFF0000, 0x2FFF0000];
    };
    SdlWindow.prototype.setModal = function (win) {
        if (win && win._windowPtr) {
            sdl_1.SDL_SetWindowModalFor(win._windowPtr, this._windowPtr);
        }
    };
    Object.defineProperty(SdlWindow.prototype, "maximize", {
        get: function () {
            /*tslint:disable*/
            return !!(sdl_1.SDL_GetWindowFlags(this._windowPtr) & sdl_1.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED);
            /*tslint:enable*/
        },
        set: function (_maximized) {
            if (!!_maximized) {
                sdl_1.SDL_MaximizeWindow(this._windowPtr);
            }
            else if (this.maximize) {
                this.restore();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "minimize", {
        get: function () {
            /*tslint:disable*/
            return !!(sdl_1.SDL_GetWindowFlags(this._windowPtr) & sdl_1.SDL_WindowFlags.SDL_WINDOW_MINIMIZED);
            /*tslint:enable*/
        },
        set: function (_minimized) {
            if (!!_minimized) {
                sdl_1.SDL_MinimizeWindow(this._windowPtr);
            }
            else if (this.minimize) {
                this.restore();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "fullScreen", {
        get: function () {
            /*tslint:disable*/
            return !!(sdl_1.SDL_GetWindowFlags(this._windowPtr) & sdl_1.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN);
            /*tslint:enable*/
        },
        set: function (full) {
            if (full) {
                sdl_1.SDL_SetWindowFullscreen(this._windowPtr, sdl_1.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP);
            }
            else {
                sdl_1.SDL_SetWindowFullscreen(this._windowPtr, 0);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "bounds", {
        get: function () {
            var position = this.position;
            var size = this.size;
            return {
                x: position.x,
                y: position.y,
                w: size.w,
                h: size.h
            };
        },
        set: function (rect) {
            this.position = rect;
            this.size = rect;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "size", {
        get: function () {
            return this._size;
        },
        set: function (val) {
            this._size = val;
            sdl_1.SDL_SetWindowSize(this._windowPtr, val.w, val.h);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "minimumSize", {
        get: function () {
            return sdl_1.SDL_GetWindowMinimumSize(this._windowPtr);
        },
        set: function (wh) {
            var size = this.minimumSize;
            var w = wh.w >= 0 ? wh.w : (wh[0] >= 0 ? wh[0] : size.w);
            var h = wh.h >= 0 ? wh.h : (wh[1] >= 0 ? wh[1] : size.h);
            sdl_1.SDL_SetWindowMinimumSize(this._windowPtr, w, h);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "maximumSize", {
        get: function () {
            return sdl_1.SDL_GetWindowMaximumSize(this._windowPtr);
        },
        set: function (wh) {
            var size = this.maximumSize;
            var w = wh.w >= 0 ? wh.w : (wh[0] >= 0 ? wh[0] : size.w);
            var h = wh.h >= 0 ? wh.h : (wh[1] >= 0 ? wh[1] : size.h);
            sdl_1.SDL_SetWindowMaximumSize(this._windowPtr, w, h);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "resizable", {
        get: function () {
            /*tslint:disable*/
            return !!(sdl_1.SDL_GetWindowFlags(this._windowPtr) & sdl_1.SDL_WindowFlags.SDL_WINDOW_RESIZABLE);
            /*tslint:enable*/
        },
        set: function (value) {
            sdl_1.SDL_SetWindowResizable(this._windowPtr, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "closable", {
        get: function () {
            return this.options.closable;
        },
        set: function (_closable) {
            this.options.closable = !!_closable;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "position", {
        get: function () {
            return sdl_1.SDL_GetWindowPosition(this._windowPtr);
        },
        set: function (xy) {
            var position = this.position;
            var x = xy.x >= 0 ? xy.x : (xy[0] >= 0 ? xy[0] : position.x);
            var y = xy.y >= 0 ? xy.y : (xy[1] >= 0 ? xy[1] : position.y);
            sdl_1.SDL_SetWindowPosition(this._windowPtr, x, y);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "title", {
        get: function () {
            return sdl_1.SDL_GetWindowTitle(this._windowPtr);
        },
        set: function (title) {
            sdl_1.SDL_SetWindowTitle(this._windowPtr, title);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "border", {
        set: function (border) {
            sdl_1.SDL_SetWindowBordered(this._windowPtr, !!border);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "bordersSize", {
        get: function () {
            return sdl_1.SDL_GetWindowBordersSize(this._windowPtr);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "show", {
        get: function () {
            /*tslint:disable*/
            return !!(sdl_1.SDL_GetWindowFlags(this._windowPtr) & sdl_1.SDL_WindowFlags.SDL_WINDOW_SHOWN);
            /*tslint:enable*/
        },
        set: function (show) {
            if (show) {
                sdl_1.SDL_ShowWindow(this._windowPtr);
            }
            else {
                sdl_1.SDL_HideWindow(this._windowPtr);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "id", {
        get: function () {
            return sdl_1.SDL_GetWindowID(this._windowPtr);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "windowPtr", {
        get: function () {
            return this._windowPtr;
        },
        set: function (value) {
            this._windowPtr = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "hasMouseEnteredWindow", {
        get: function () {
            return this._hasMouseEnteredWindow;
        },
        set: function (value) {
            this._hasMouseEnteredWindow = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "lastMouseEvent", {
        get: function () {
            return this._lastMouseEvent;
        },
        set: function (value) {
            this._lastMouseEvent = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "lastKeyboardEvent", {
        get: function () {
            return this._lastKeyboardEvent;
        },
        set: function (value) {
            this._lastKeyboardEvent = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "context", {
        get: function () {
            return this._context;
        },
        set: function (value) {
            this._context = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "internalCanvas", {
        get: function () {
            return this._internalCanvas;
        },
        set: function (value) {
            this._internalCanvas = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "Blob", {
        get: function () {
            return this._Blob;
        },
        set: function (value) {
            this._Blob = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "URL", {
        get: function () {
            return this._URL;
        },
        set: function (value) {
            this._URL = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "URLSearchParams", {
        get: function () {
            return this._URLSearchParams;
        },
        set: function (value) {
            this._URLSearchParams = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "customElements", {
        get: function () {
            return this._customElements;
        },
        set: function (value) {
            this._customElements = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "defaultStatus", {
        get: function () {
            return this._defaultStatus;
        },
        set: function (value) {
            this._defaultStatus = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "location", {
        get: function () {
            return this._location;
        },
        set: function (value) {
            this._location = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "name", {
        get: function () {
            return this._name;
        },
        set: function (value) {
            this._name = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "offscreenBuffering", {
        get: function () {
            return this._offscreenBuffering;
        },
        set: function (value) {
            this._offscreenBuffering = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onabort", {
        get: function () {
            return this._onabort;
        },
        set: function (value) {
            this._onabort = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onafterprint", {
        get: function () {
            return this._onafterprint;
        },
        set: function (value) {
            this._onafterprint = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onanimationcancel", {
        get: function () {
            return this._onanimationcancel;
        },
        set: function (value) {
            this._onanimationcancel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onanimationend", {
        get: function () {
            return this._onanimationend;
        },
        set: function (value) {
            this._onanimationend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onanimationiteration", {
        get: function () {
            return this._onanimationiteration;
        },
        set: function (value) {
            this._onanimationiteration = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onanimationstart", {
        get: function () {
            return this._onanimationstart;
        },
        set: function (value) {
            this._onanimationstart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onauxclick", {
        get: function () {
            return this._onauxclick;
        },
        set: function (value) {
            this._onauxclick = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onbeforeprint", {
        get: function () {
            return this._onbeforeprint;
        },
        set: function (value) {
            this._onbeforeprint = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onbeforeunload", {
        get: function () {
            return this._onbeforeunload;
        },
        set: function (value) {
            this._onbeforeunload = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onblur", {
        get: function () {
            return this._onblur;
        },
        set: function (value) {
            this._onblur = value;
            this.addEventListener('blur', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oncancel", {
        get: function () {
            return this._oncancel;
        },
        set: function (value) {
            this._oncancel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oncanplay", {
        get: function () {
            return this._oncanplay;
        },
        set: function (value) {
            this._oncanplay = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oncanplaythrough", {
        get: function () {
            return this._oncanplaythrough;
        },
        set: function (value) {
            this._oncanplaythrough = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onchange", {
        get: function () {
            return this._onchange;
        },
        set: function (value) {
            this._onchange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onclick", {
        get: function () {
            return this._onclick;
        },
        set: function (value) {
            this._onclick = value;
            this.addEventListener('click', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onclose", {
        get: function () {
            return this._onclose;
        },
        set: function (value) {
            this.addEventListener('close', value, false);
            this._onclose = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oncompassneedscalibration", {
        get: function () {
            return this._oncompassneedscalibration;
        },
        set: function (value) {
            this._oncompassneedscalibration = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oncontextmenu", {
        get: function () {
            return this._oncontextmenu;
        },
        set: function (value) {
            this._oncontextmenu = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oncuechange", {
        get: function () {
            return this._oncuechange;
        },
        set: function (value) {
            this._oncuechange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondblclick", {
        get: function () {
            return this._ondblclick;
        },
        set: function (value) {
            this._ondblclick = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondevicelight", {
        get: function () {
            return this._ondevicelight;
        },
        set: function (value) {
            this._ondevicelight = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondevicemotion", {
        get: function () {
            return this._ondevicemotion;
        },
        set: function (value) {
            this._ondevicemotion = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondeviceorientation", {
        get: function () {
            return this._ondeviceorientation;
        },
        set: function (value) {
            this._ondeviceorientation = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondrag", {
        get: function () {
            return this._ondrag;
        },
        set: function (value) {
            this._ondrag = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondragend", {
        get: function () {
            return this._ondragend;
        },
        set: function (value) {
            this._ondragend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondragenter", {
        get: function () {
            return this._ondragenter;
        },
        set: function (value) {
            this._ondragenter = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondragexit", {
        get: function () {
            return this._ondragexit;
        },
        set: function (value) {
            this._ondragexit = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondragleave", {
        get: function () {
            return this._ondragleave;
        },
        set: function (value) {
            this._ondragleave = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondragover", {
        get: function () {
            return this._ondragover;
        },
        set: function (value) {
            this._ondragover = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondragstart", {
        get: function () {
            return this._ondragstart;
        },
        set: function (value) {
            this._ondragstart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondrop", {
        get: function () {
            return this._ondrop;
        },
        set: function (value) {
            this._ondrop = value;
            this.addEventListener('drop', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ondurationchange", {
        get: function () {
            return this._ondurationchange;
        },
        set: function (value) {
            this._ondurationchange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onemptied", {
        get: function () {
            return this._onemptied;
        },
        set: function (value) {
            this._onemptied = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onended", {
        get: function () {
            return this._onended;
        },
        set: function (value) {
            this._onended = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onerror", {
        get: function () {
            return this._onerror;
        },
        set: function (value) {
            this._onerror = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onfocus", {
        get: function () {
            return this._onfocus;
        },
        set: function (value) {
            this._onfocus = value;
            this.addEventListener('focus', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ongotpointercapture", {
        get: function () {
            return this._ongotpointercapture;
        },
        set: function (value) {
            this._ongotpointercapture = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onhashchange", {
        get: function () {
            return this._onhashchange;
        },
        set: function (value) {
            this._onhashchange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oninput", {
        get: function () {
            return this._oninput;
        },
        set: function (value) {
            this._oninput = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "oninvalid", {
        get: function () {
            return this._oninvalid;
        },
        set: function (value) {
            this._oninvalid = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onkeydown", {
        get: function () {
            return this._onkeydown;
        },
        set: function (value) {
            this._onkeydown = value;
            this.addEventListener('keydown', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onkeypress", {
        get: function () {
            return this._onkeypress;
        },
        set: function (value) {
            this._onkeypress = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onkeyup", {
        get: function () {
            return this._onkeyup;
        },
        set: function (value) {
            this._onkeyup = value;
            this.addEventListener('keyup', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onlanguagechange", {
        get: function () {
            return this._onlanguagechange;
        },
        set: function (value) {
            this._onlanguagechange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onload", {
        get: function () {
            return this._onload;
        },
        set: function (value) {
            this._onload = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onloadeddata", {
        get: function () {
            return this._onloadeddata;
        },
        set: function (value) {
            this._onloadeddata = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onloadedmetadata", {
        get: function () {
            return this._onloadedmetadata;
        },
        set: function (value) {
            this._onloadedmetadata = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onloadend", {
        get: function () {
            return this._onloadend;
        },
        set: function (value) {
            this._onloadend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onloadstart", {
        get: function () {
            return this._onloadstart;
        },
        set: function (value) {
            this._onloadstart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onlostpointercapture", {
        get: function () {
            return this._onlostpointercapture;
        },
        set: function (value) {
            this._onlostpointercapture = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmessage", {
        get: function () {
            return this._onmessage;
        },
        set: function (value) {
            this._onmessage = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmessageerror", {
        get: function () {
            return this._onmessageerror;
        },
        set: function (value) {
            this._onmessageerror = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmousedown", {
        get: function () {
            return this._onmousedown;
        },
        set: function (value) {
            this._onmousedown = value;
            this.addEventListener('mousedown', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmouseenter", {
        get: function () {
            return this._onmouseenter;
        },
        set: function (value) {
            this._onmouseenter = value;
            this.addEventListener('mouseenter', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmouseleave", {
        get: function () {
            return this._onmouseleave;
        },
        set: function (value) {
            this._onmouseleave = value;
            this.addEventListener('mouseleave', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmousemove", {
        get: function () {
            return this._onmousemove;
        },
        set: function (value) {
            this._onmousemove = value;
            this.addEventListener('mousemove', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmouseout", {
        get: function () {
            return this._onmouseout;
        },
        set: function (value) {
            this._onmouseout = value;
            this.addEventListener('mouseout', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmouseover", {
        get: function () {
            return this._onmouseover;
        },
        set: function (value) {
            this._onmouseover = value;
            this.addEventListener('mouseover', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmouseup", {
        get: function () {
            return this._onmouseup;
        },
        set: function (value) {
            this.addEventListener('mouseup', value, false);
            this._onmouseup = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmousewheel", {
        get: function () {
            return this._onmousewheel;
        },
        set: function (value) {
            this.addEventListener('mousewheel', value, false);
            this._onmousewheel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsgesturechange", {
        get: function () {
            return this._onmsgesturechange;
        },
        set: function (value) {
            this._onmsgesturechange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsgesturedoubletap", {
        get: function () {
            return this._onmsgesturedoubletap;
        },
        set: function (value) {
            this._onmsgesturedoubletap = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsgestureend", {
        get: function () {
            return this._onmsgestureend;
        },
        set: function (value) {
            this._onmsgestureend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsgesturehold", {
        get: function () {
            return this._onmsgesturehold;
        },
        set: function (value) {
            this._onmsgesturehold = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsgesturestart", {
        get: function () {
            return this._onmsgesturestart;
        },
        set: function (value) {
            this._onmsgesturestart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsgesturetap", {
        get: function () {
            return this._onmsgesturetap;
        },
        set: function (value) {
            this._onmsgesturetap = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmsinertiastart", {
        get: function () {
            return this._onmsinertiastart;
        },
        set: function (value) {
            this._onmsinertiastart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointercancel", {
        get: function () {
            return this._onmspointercancel;
        },
        set: function (value) {
            this._onmspointercancel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointerdown", {
        get: function () {
            return this._onmspointerdown;
        },
        set: function (value) {
            this._onmspointerdown = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointerenter", {
        get: function () {
            return this._onmspointerenter;
        },
        set: function (value) {
            this._onmspointerenter = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointerleave", {
        get: function () {
            return this._onmspointerleave;
        },
        set: function (value) {
            this._onmspointerleave = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointermove", {
        get: function () {
            return this._onmspointermove;
        },
        set: function (value) {
            this._onmspointermove = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointerout", {
        get: function () {
            return this._onmspointerout;
        },
        set: function (value) {
            this._onmspointerout = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointerover", {
        get: function () {
            return this._onmspointerover;
        },
        set: function (value) {
            this._onmspointerover = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onmspointerup", {
        get: function () {
            return this._onmspointerup;
        },
        set: function (value) {
            this._onmspointerup = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onoffline", {
        get: function () {
            return this._onoffline;
        },
        set: function (value) {
            this._onoffline = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ononline", {
        get: function () {
            return this._ononline;
        },
        set: function (value) {
            this._ononline = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onorientationchange", {
        get: function () {
            return this._onorientationchange;
        },
        set: function (value) {
            this._onorientationchange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpagehide", {
        get: function () {
            return this._onpagehide;
        },
        set: function (value) {
            this._onpagehide = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpageshow", {
        get: function () {
            return this._onpageshow;
        },
        set: function (value) {
            this._onpageshow = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpause", {
        get: function () {
            return this._onpause;
        },
        set: function (value) {
            this._onpause = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onplay", {
        get: function () {
            return this._onplay;
        },
        set: function (value) {
            this._onplay = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onplaying", {
        get: function () {
            return this._onplaying;
        },
        set: function (value) {
            this._onplaying = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointercancel", {
        get: function () {
            return this._onpointercancel;
        },
        set: function (value) {
            this._onpointercancel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointerdown", {
        get: function () {
            return this._onpointerdown;
        },
        set: function (value) {
            this._onpointerdown = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointerenter", {
        get: function () {
            return this._onpointerenter;
        },
        set: function (value) {
            this._onpointerenter = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointerleave", {
        get: function () {
            return this._onpointerleave;
        },
        set: function (value) {
            this._onpointerleave = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointermove", {
        get: function () {
            return this._onpointermove;
        },
        set: function (value) {
            this._onpointermove = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointerout", {
        get: function () {
            return this._onpointerout;
        },
        set: function (value) {
            this._onpointerout = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointerover", {
        get: function () {
            return this._onpointerover;
        },
        set: function (value) {
            this._onpointerover = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpointerup", {
        get: function () {
            return this._onpointerup;
        },
        set: function (value) {
            this._onpointerup = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onpopstate", {
        get: function () {
            return this._onpopstate;
        },
        set: function (value) {
            this._onpopstate = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onprogress", {
        get: function () {
            return this._onprogress;
        },
        set: function (value) {
            this._onprogress = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onratechange", {
        get: function () {
            return this._onratechange;
        },
        set: function (value) {
            this._onratechange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onreadystatechange", {
        get: function () {
            return this._onreadystatechange;
        },
        set: function (value) {
            this._onreadystatechange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onrejectionhandled", {
        get: function () {
            return this._onrejectionhandled;
        },
        set: function (value) {
            this._onrejectionhandled = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onreset", {
        get: function () {
            return this._onreset;
        },
        set: function (value) {
            this._onreset = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onresize", {
        get: function () {
            return this._onresize;
        },
        set: function (value) {
            this._onresize = value;
            this.addEventListener('resize', value, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onscroll", {
        get: function () {
            return this._onscroll;
        },
        set: function (value) {
            this._onscroll = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onsecuritypolicyviolation", {
        get: function () {
            return this._onsecuritypolicyviolation;
        },
        set: function (value) {
            this._onsecuritypolicyviolation = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onseeked", {
        get: function () {
            return this._onseeked;
        },
        set: function (value) {
            this._onseeked = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onseeking", {
        get: function () {
            return this._onseeking;
        },
        set: function (value) {
            this._onseeking = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onselect", {
        get: function () {
            return this._onselect;
        },
        set: function (value) {
            this._onselect = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onstalled", {
        get: function () {
            return this._onstalled;
        },
        set: function (value) {
            this._onstalled = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onstorage", {
        get: function () {
            return this._onstorage;
        },
        set: function (value) {
            this._onstorage = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onsubmit", {
        get: function () {
            return this._onsubmit;
        },
        set: function (value) {
            this._onsubmit = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onsuspend", {
        get: function () {
            return this._onsuspend;
        },
        set: function (value) {
            this._onsuspend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontimeupdate", {
        get: function () {
            return this._ontimeupdate;
        },
        set: function (value) {
            this._ontimeupdate = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontoggle", {
        get: function () {
            return this._ontoggle;
        },
        set: function (value) {
            this._ontoggle = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontouchcancel", {
        get: function () {
            return this._ontouchcancel;
        },
        set: function (value) {
            this._ontouchcancel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontouchend", {
        get: function () {
            return this._ontouchend;
        },
        set: function (value) {
            this._ontouchend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontouchmove", {
        get: function () {
            return this._ontouchmove;
        },
        set: function (value) {
            this._ontouchmove = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontouchstart", {
        get: function () {
            return this._ontouchstart;
        },
        set: function (value) {
            this._ontouchstart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontransitioncancel", {
        get: function () {
            return this._ontransitioncancel;
        },
        set: function (value) {
            this._ontransitioncancel = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontransitionend", {
        get: function () {
            return this._ontransitionend;
        },
        set: function (value) {
            this._ontransitionend = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontransitionrun", {
        get: function () {
            return this._ontransitionrun;
        },
        set: function (value) {
            this._ontransitionrun = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "ontransitionstart", {
        get: function () {
            return this._ontransitionstart;
        },
        set: function (value) {
            this._ontransitionstart = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onunhandledrejection", {
        get: function () {
            return this._onunhandledrejection;
        },
        set: function (value) {
            this._onunhandledrejection = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onunload", {
        get: function () {
            return this._onunload;
        },
        set: function (value) {
            this._onunload = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvolumechange", {
        get: function () {
            return this._onvolumechange;
        },
        set: function (value) {
            this._onvolumechange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplayactivate", {
        get: function () {
            return this._onvrdisplayactivate;
        },
        set: function (value) {
            this._onvrdisplayactivate = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplayblur", {
        get: function () {
            return this._onvrdisplayblur;
        },
        set: function (value) {
            this._onvrdisplayblur = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplayconnect", {
        get: function () {
            return this._onvrdisplayconnect;
        },
        set: function (value) {
            this._onvrdisplayconnect = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplaydeactivate", {
        get: function () {
            return this._onvrdisplaydeactivate;
        },
        set: function (value) {
            this._onvrdisplaydeactivate = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplaydisconnect", {
        get: function () {
            return this._onvrdisplaydisconnect;
        },
        set: function (value) {
            this._onvrdisplaydisconnect = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplayfocus", {
        get: function () {
            return this._onvrdisplayfocus;
        },
        set: function (value) {
            this._onvrdisplayfocus = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplaypointerrestricted", {
        get: function () {
            return this._onvrdisplaypointerrestricted;
        },
        set: function (value) {
            this._onvrdisplaypointerrestricted = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplaypointerunrestricted", {
        get: function () {
            return this._onvrdisplaypointerunrestricted;
        },
        set: function (value) {
            this._onvrdisplaypointerunrestricted = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onvrdisplaypresentchange", {
        get: function () {
            return this._onvrdisplaypresentchange;
        },
        set: function (value) {
            this._onvrdisplaypresentchange = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onwaiting", {
        get: function () {
            return this._onwaiting;
        },
        set: function (value) {
            this._onwaiting = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "onwheel", {
        get: function () {
            return this._onwheel;
        },
        set: function (ivalue) {
            this._onwheel = ivalue;
            this.addEventListener('wheel', ivalue, false);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "opener", {
        get: function () {
            return this._opener;
        },
        set: function (value) {
            this._opener = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "status", {
        get: function () {
            return this._status;
        },
        set: function (value) {
            this._status = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "canvas", {
        get: function () {
            return this._canvas;
        },
        set: function (value) {
            this._canvas = value;
        },
        enumerable: true,
        configurable: true
    });
    SdlWindow.prototype.createImage = function (src) {
        return this.loadImage(src);
    };
    SdlWindow.prototype.loadImage = function (src) {
        if (src) {
            return loadImage(src);
        }
        else {
            return Promise.resolve(new NodeCanvasImage());
        }
    };
    SdlWindow.prototype.newCanvas = function (window, windowOptions) {
        if (windowOptions && window === undefined) {
            var opts = SdlWindow.windowDefaults();
            var wind = new SdlWindow(opts);
            return new sdl_canvas_1.SdlCanvas(wind);
        }
        else if (typeof window === 'string') {
            var opts = windowOptions || SdlWindow.windowDefaults();
            opts.title = window;
            var wind = new SdlWindow(opts);
            return new sdl_canvas_1.SdlCanvas(wind);
        }
        else {
            return new sdl_canvas_1.SdlCanvas(window);
        }
    };
    SdlWindow.prototype.createCanvas = function () {
        var size = this.size;
        this._internalCanvas = createInternalCanvas(size.w, size.h, 'image');
        this.initCanvasColors();
        this.initCanvasSize(size);
    };
    SdlWindow.prototype.initCanvasSize = function (size) {
        if (this.options.fitCanvasInWindow) {
            this.configureCanvasSize(size.w, size.h);
        }
    };
    Object.defineProperty(SdlWindow.prototype, "applicationCache", {
        get: function () {
            return this._applicationCache;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "caches", {
        get: function () {
            return this._caches;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "clientInformation", {
        get: function () {
            return this._clientInformation;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "closed", {
        get: function () {
            return this._closed;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "console", {
        get: function () {
            return console;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "crypto", {
        get: function () {
            return this._crypto;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "devicePixelRatio", {
        get: function () {
            return this._devicePixelRatio;
        },
        set: function (value) {
            this._devicePixelRatio = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "doNotTrack", {
        get: function () {
            return this._doNotTrack;
        },
        set: function (value) {
            this._doNotTrack = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "document", {
        get: function () {
            return this._document;
        },
        set: function (value) {
            this._document = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "event", {
        get: function () {
            return this._event;
        },
        set: function (value) {
            this._event = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "external", {
        get: function () {
            return this._external;
        },
        set: function (value) {
            this._external = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "frameElement", {
        get: function () {
            return this._frameElement;
        },
        set: function (value) {
            this._frameElement = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "frames", {
        get: function () {
            return this._frames;
        },
        set: function (value) {
            this._frames = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "history", {
        get: function () {
            return this._history;
        },
        set: function (value) {
            this._history = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "indexedDB", {
        get: function () {
            return this._indexedDB;
        },
        set: function (value) {
            this._indexedDB = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "innerHeight", {
        get: function () {
            return this._innerHeight;
        },
        set: function (value) {
            this._innerHeight = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "innerWidth", {
        get: function () {
            return this._innerWidth;
        },
        set: function (value) {
            this._innerWidth = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "isSecureContext", {
        get: function () {
            return this._isSecureContext;
        },
        set: function (value) {
            this._isSecureContext = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "length", {
        get: function () {
            return this._length;
        },
        set: function (value) {
            this._length = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "localStorage", {
        get: function () {
            return this._localStorage;
        },
        set: function (value) {
            this._localStorage = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "locationbar", {
        get: function () {
            return this._locationbar;
        },
        set: function (value) {
            this._locationbar = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "menubar", {
        get: function () {
            return this._menubar;
        },
        set: function (value) {
            this._menubar = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "msContentScript", {
        get: function () {
            return this._msContentScript;
        },
        set: function (value) {
            this._msContentScript = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "navigator", {
        get: function () {
            return this._navigator;
        },
        set: function (value) {
            this._navigator = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "orientation", {
        get: function () {
            return this._orientation;
        },
        set: function (value) {
            this._orientation = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "origin", {
        get: function () {
            return this._origin;
        },
        set: function (value) {
            this._origin = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "outerHeight", {
        get: function () {
            return this._outerHeight;
        },
        set: function (value) {
            this._outerHeight = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "outerWidth", {
        get: function () {
            return this._outerWidth;
        },
        set: function (value) {
            this._outerWidth = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "pageXOffset", {
        get: function () {
            return 0;
        },
        set: function (value) {
            this._pageXOffset = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "pageYOffset", {
        get: function () {
            return 0;
        },
        set: function (value) {
            this._pageYOffset = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "parent", {
        get: function () {
            return this._parent;
        },
        set: function (value) {
            this._parent = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "performance", {
        get: function () {
            return this._performance;
        },
        set: function (value) {
            this._performance = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "personalbar", {
        get: function () {
            return this._personalbar;
        },
        set: function (value) {
            this._personalbar = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "screen", {
        get: function () {
            return this._screen;
        },
        set: function (value) {
            this._screen = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "screenLeft", {
        get: function () {
            return this._screenLeft;
        },
        set: function (value) {
            this._screenLeft = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "screenTop", {
        get: function () {
            return this._screenTop;
        },
        set: function (value) {
            this._screenTop = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "screenX", {
        get: function () {
            return this._screenX;
        },
        set: function (value) {
            this._screenX = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "screenY", {
        get: function () {
            return this._screenY;
        },
        set: function (value) {
            this._screenY = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "scrollX", {
        get: function () {
            return this._scrollX;
        },
        set: function (value) {
            this._scrollX = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "scrollY", {
        get: function () {
            return this._scrollY;
        },
        set: function (value) {
            this._scrollY = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "scrollbars", {
        get: function () {
            return this._scrollbars;
        },
        set: function (value) {
            this._scrollbars = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "self", {
        get: function () {
            return this._self;
        },
        set: function (value) {
            this._self = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "sessionStorage", {
        get: function () {
            return this._sessionStorage;
        },
        set: function (value) {
            this._sessionStorage = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "speechSynthesis", {
        get: function () {
            return this._speechSynthesis;
        },
        set: function (value) {
            this._speechSynthesis = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "statusbar", {
        get: function () {
            return this._statusbar;
        },
        set: function (value) {
            this._statusbar = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "styleMedia", {
        get: function () {
            return this._styleMedia;
        },
        set: function (value) {
            this._styleMedia = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "toolbar", {
        get: function () {
            return this._toolbar;
        },
        set: function (value) {
            this._toolbar = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "top", {
        get: function () {
            return this._top;
        },
        set: function (value) {
            this._top = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SdlWindow.prototype, "window", {
        get: function () {
            return this;
        },
        set: function (value) {
            this._window = value;
        },
        enumerable: true,
        configurable: true
    });
    SdlWindow.windowDefaults = function () {
        return sdl_window_opts_1.sdlWindowDefaults();
    };
    SdlWindow.alert = function (message) {
        messagebox_1.alert(message, null);
    };
    SdlWindow.confirm = function (message) {
        return messagebox_1.confirm(message, null);
    };
    return SdlWindow;
}(events_1.EventEmitter));
exports.SdlWindow = SdlWindow;
//# sourceMappingURL=sdl-window.js.map