/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([["vendors-node_modules_lumino_widgets_dist_index_es6_js"],{

/***/ "../node_modules/@lumino/keyboard/dist/index.es6.js":
/*!**********************************************************!*\
  !*** ../node_modules/@lumino/keyboard/dist/index.es6.js ***!
  \**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"EN_US\": () => (/* binding */ EN_US),\n/* harmony export */   \"KeycodeLayout\": () => (/* binding */ KeycodeLayout),\n/* harmony export */   \"getKeyboardLayout\": () => (/* binding */ getKeyboardLayout),\n/* harmony export */   \"setKeyboardLayout\": () => (/* binding */ setKeyboardLayout)\n/* harmony export */ });\n// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\n/**\n * Get the global application keyboard layout instance.\n *\n * @returns The keyboard layout for use by the application.\n *\n * #### Notes\n * The default keyboard layout is US-English.\n */\nfunction getKeyboardLayout() {\n    return Private.keyboardLayout;\n}\n/**\n * Set the global application keyboard layout instance.\n *\n * @param - The keyboard layout for use by the application.\n *\n * #### Notes\n * The keyboard layout should typically be set on application startup\n * to a layout which is appropriate for the user's system.\n */\nfunction setKeyboardLayout(layout) {\n    Private.keyboardLayout = layout;\n}\n/**\n * A concrete implementation of [[IKeyboardLayout]] based on keycodes.\n *\n * The `keyCode` property of a `'keydown'` event is a browser and OS\n * specific representation of the physical key (not character) which\n * was pressed on a keyboard. While not the most convenient API, it\n * is currently the only one which works reliably on all browsers.\n *\n * This class accepts a user-defined mapping of keycode to key, which\n * allows for reliable shortcuts tailored to the user's system.\n */\nvar KeycodeLayout = /** @class */ (function () {\n    /**\n     * Construct a new keycode layout.\n     *\n     * @param name - The human readable name for the layout.\n     *\n     * @param codes - A mapping of keycode to key value.\n     */\n    function KeycodeLayout(name, codes) {\n        this.name = name;\n        this._codes = codes;\n        this._keys = KeycodeLayout.extractKeys(codes);\n    }\n    /**\n     * Get an array of the key values supported by the layout.\n     *\n     * @returns A new array of the supported key values.\n     */\n    KeycodeLayout.prototype.keys = function () {\n        return Object.keys(this._keys);\n    };\n    /**\n     * Test whether the given key is a valid value for the layout.\n     *\n     * @param key - The user provided key to test for validity.\n     *\n     * @returns `true` if the key is valid, `false` otherwise.\n     */\n    KeycodeLayout.prototype.isValidKey = function (key) {\n        return key in this._keys;\n    };\n    /**\n     * Get the key for a `'keydown'` event.\n     *\n     * @param event - The event object for a `'keydown'` event.\n     *\n     * @returns The associated key value, or an empty string if\n     *   the event does not represent a valid primary key.\n     */\n    KeycodeLayout.prototype.keyForKeydownEvent = function (event) {\n        return this._codes[event.keyCode] || '';\n    };\n    return KeycodeLayout;\n}());\n/**\n * The namespace for the `KeycodeLayout` class statics.\n */\n(function (KeycodeLayout) {\n    /**\n     * Extract the set of keys from a code map.\n     *\n     * @param code - The code map of interest.\n     *\n     * @returns A set of the keys in the code map.\n     */\n    function extractKeys(codes) {\n        var keys = Object.create(null);\n        for (var c in codes) {\n            keys[codes[c]] = true;\n        }\n        return keys;\n    }\n    KeycodeLayout.extractKeys = extractKeys;\n})(KeycodeLayout || (KeycodeLayout = {}));\n/**\n * A keycode-based keyboard layout for US English keyboards.\n *\n * This layout is valid for the following OS/Browser combinations.\n *\n * - Windows\n *   - Chrome\n *   - Firefox\n *   - IE\n *\n * - OSX\n *   - Chrome\n *   - Firefox\n *   - Safari\n *\n * - Linux\n *   - Chrome\n *   - Firefox\n *\n * Other combinations may also work, but are untested.\n */\nvar EN_US = new KeycodeLayout('en-us', {\n    8: 'Backspace',\n    9: 'Tab',\n    13: 'Enter',\n    19: 'Pause',\n    27: 'Escape',\n    32: 'Space',\n    33: 'PageUp',\n    34: 'PageDown',\n    35: 'End',\n    36: 'Home',\n    37: 'ArrowLeft',\n    38: 'ArrowUp',\n    39: 'ArrowRight',\n    40: 'ArrowDown',\n    45: 'Insert',\n    46: 'Delete',\n    48: '0',\n    49: '1',\n    50: '2',\n    51: '3',\n    52: '4',\n    53: '5',\n    54: '6',\n    55: '7',\n    56: '8',\n    57: '9',\n    59: ';',\n    61: '=',\n    65: 'A',\n    66: 'B',\n    67: 'C',\n    68: 'D',\n    69: 'E',\n    70: 'F',\n    71: 'G',\n    72: 'H',\n    73: 'I',\n    74: 'J',\n    75: 'K',\n    76: 'L',\n    77: 'M',\n    78: 'N',\n    79: 'O',\n    80: 'P',\n    81: 'Q',\n    82: 'R',\n    83: 'S',\n    84: 'T',\n    85: 'U',\n    86: 'V',\n    87: 'W',\n    88: 'X',\n    89: 'Y',\n    90: 'Z',\n    93: 'ContextMenu',\n    96: '0',\n    97: '1',\n    98: '2',\n    99: '3',\n    100: '4',\n    101: '5',\n    102: '6',\n    103: '7',\n    104: '8',\n    105: '9',\n    106: '*',\n    107: '+',\n    109: '-',\n    110: '.',\n    111: '/',\n    112: 'F1',\n    113: 'F2',\n    114: 'F3',\n    115: 'F4',\n    116: 'F5',\n    117: 'F6',\n    118: 'F7',\n    119: 'F8',\n    120: 'F9',\n    121: 'F10',\n    122: 'F11',\n    123: 'F12',\n    173: '-',\n    186: ';',\n    187: '=',\n    188: ',',\n    189: '-',\n    190: '.',\n    191: '/',\n    192: '`',\n    219: '[',\n    220: '\\\\',\n    221: ']',\n    222: '\\''\n});\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * The global keyboard layout instance.\n     */\n    Private.keyboardLayout = EN_US;\n})(Private || (Private = {}));\n\n\n//# sourceMappingURL=index.es6.js.map\n\n\n//# sourceURL=webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@lumino/keyboard/dist/index.es6.js?");

/***/ }),

/***/ "../node_modules/@lumino/widgets/dist/index.es6.js":
/*!*********************************************************!*\
  !*** ../node_modules/@lumino/widgets/dist/index.es6.js ***!
  \*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"BoxEngine\": () => (/* binding */ BoxEngine),\n/* harmony export */   \"BoxLayout\": () => (/* binding */ BoxLayout),\n/* harmony export */   \"BoxPanel\": () => (/* binding */ BoxPanel),\n/* harmony export */   \"BoxSizer\": () => (/* binding */ BoxSizer),\n/* harmony export */   \"CommandPalette\": () => (/* binding */ CommandPalette),\n/* harmony export */   \"ContextMenu\": () => (/* binding */ ContextMenu),\n/* harmony export */   \"DockLayout\": () => (/* binding */ DockLayout),\n/* harmony export */   \"DockPanel\": () => (/* binding */ DockPanel),\n/* harmony export */   \"FocusTracker\": () => (/* binding */ FocusTracker),\n/* harmony export */   \"GridLayout\": () => (/* binding */ GridLayout),\n/* harmony export */   \"Layout\": () => (/* binding */ Layout),\n/* harmony export */   \"LayoutItem\": () => (/* binding */ LayoutItem),\n/* harmony export */   \"Menu\": () => (/* binding */ Menu),\n/* harmony export */   \"MenuBar\": () => (/* binding */ MenuBar),\n/* harmony export */   \"Panel\": () => (/* binding */ Panel),\n/* harmony export */   \"PanelLayout\": () => (/* binding */ PanelLayout),\n/* harmony export */   \"ScrollBar\": () => (/* binding */ ScrollBar),\n/* harmony export */   \"SingletonLayout\": () => (/* binding */ SingletonLayout),\n/* harmony export */   \"SplitLayout\": () => (/* binding */ SplitLayout),\n/* harmony export */   \"SplitPanel\": () => (/* binding */ SplitPanel),\n/* harmony export */   \"StackedLayout\": () => (/* binding */ StackedLayout),\n/* harmony export */   \"StackedPanel\": () => (/* binding */ StackedPanel),\n/* harmony export */   \"TabBar\": () => (/* binding */ TabBar),\n/* harmony export */   \"TabPanel\": () => (/* binding */ TabPanel),\n/* harmony export */   \"Title\": () => (/* binding */ Title),\n/* harmony export */   \"Widget\": () => (/* binding */ Widget)\n/* harmony export */ });\n/* harmony import */ var _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lumino/algorithm */ \"webpack/sharing/consume/default/@lumino/algorithm/@lumino/algorithm\");\n/* harmony import */ var _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @lumino/domutils */ \"webpack/sharing/consume/default/@lumino/domutils/@lumino/domutils\");\n/* harmony import */ var _lumino_domutils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @lumino/messaging */ \"webpack/sharing/consume/default/@lumino/messaging/@lumino/messaging\");\n/* harmony import */ var _lumino_messaging__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_lumino_messaging__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _lumino_properties__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @lumino/properties */ \"webpack/sharing/consume/default/@lumino/properties/@lumino/properties\");\n/* harmony import */ var _lumino_properties__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_lumino_properties__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @lumino/signaling */ \"webpack/sharing/consume/default/@lumino/signaling/@lumino/signaling\");\n/* harmony import */ var _lumino_signaling__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_lumino_signaling__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @lumino/coreutils */ \"webpack/sharing/consume/default/@lumino/coreutils/@lumino/coreutils\");\n/* harmony import */ var _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _lumino_commands__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @lumino/commands */ \"webpack/sharing/consume/default/@lumino/commands/@lumino/commands\");\n/* harmony import */ var _lumino_commands__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_lumino_commands__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @lumino/virtualdom */ \"webpack/sharing/consume/default/@lumino/virtualdom/@lumino/virtualdom\");\n/* harmony import */ var _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var _lumino_disposable__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @lumino/disposable */ \"webpack/sharing/consume/default/@lumino/disposable/@lumino/disposable\");\n/* harmony import */ var _lumino_disposable__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_lumino_disposable__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var _lumino_keyboard__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @lumino/keyboard */ \"../node_modules/@lumino/keyboard/dist/index.es6.js\");\n/* harmony import */ var _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @lumino/dragdrop */ \"webpack/sharing/consume/default/@lumino/dragdrop/@lumino/dragdrop\");\n/* harmony import */ var _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__);\n\n\n\n\n\n\n\n\n\n\n\n\n// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\n/**\n * A sizer object for use with the box engine layout functions.\n *\n * #### Notes\n * A box sizer holds the geometry information for an object along an\n * arbitrary layout orientation.\n *\n * For best performance, this class should be treated as a raw data\n * struct. It should not typically be subclassed.\n */\nvar BoxSizer = /** @class */ (function () {\n    function BoxSizer() {\n        /**\n         * The preferred size for the sizer.\n         *\n         * #### Notes\n         * The sizer will be given this initial size subject to its size\n         * bounds. The sizer will not deviate from this size unless such\n         * deviation is required to fit into the available layout space.\n         *\n         * There is no limit to this value, but it will be clamped to the\n         * bounds defined by [[minSize]] and [[maxSize]].\n         *\n         * The default value is `0`.\n         */\n        this.sizeHint = 0;\n        /**\n         * The minimum size of the sizer.\n         *\n         * #### Notes\n         * The sizer will never be sized less than this value, even if\n         * it means the sizer will overflow the available layout space.\n         *\n         * It is assumed that this value lies in the range `[0, Infinity)`\n         * and that it is `<=` to [[maxSize]]. Failure to adhere to this\n         * constraint will yield undefined results.\n         *\n         * The default value is `0`.\n         */\n        this.minSize = 0;\n        /**\n         * The maximum size of the sizer.\n         *\n         * #### Notes\n         * The sizer will never be sized greater than this value, even if\n         * it means the sizer will underflow the available layout space.\n         *\n         * It is assumed that this value lies in the range `[0, Infinity]`\n         * and that it is `>=` to [[minSize]]. Failure to adhere to this\n         * constraint will yield undefined results.\n         *\n         * The default value is `Infinity`.\n         */\n        this.maxSize = Infinity;\n        /**\n         * The stretch factor for the sizer.\n         *\n         * #### Notes\n         * This controls how much the sizer stretches relative to its sibling\n         * sizers when layout space is distributed. A stretch factor of zero\n         * is special and will cause the sizer to only be resized after all\n         * other sizers with a stretch factor greater than zero have been\n         * resized to their limits.\n         *\n         * It is assumed that this value is an integer that lies in the range\n         * `[0, Infinity)`. Failure to adhere to this constraint will yield\n         * undefined results.\n         *\n         * The default value is `1`.\n         */\n        this.stretch = 1;\n        /**\n         * The computed size of the sizer.\n         *\n         * #### Notes\n         * This value is the output of a call to [[boxCalc]]. It represents\n         * the computed size for the object along the layout orientation,\n         * and will always lie in the range `[minSize, maxSize]`.\n         *\n         * This value is output only.\n         *\n         * Changing this value will have no effect.\n         */\n        this.size = 0;\n        /**\n         * An internal storage property for the layout algorithm.\n         *\n         * #### Notes\n         * This value is used as temporary storage by the layout algorithm.\n         *\n         * Changing this value will have no effect.\n         */\n        this.done = false;\n    }\n    return BoxSizer;\n}());\n/**\n * The namespace for the box engine layout functions.\n */\nvar BoxEngine;\n(function (BoxEngine) {\n    /**\n     * Calculate the optimal layout sizes for a sequence of box sizers.\n     *\n     * This distributes the available layout space among the box sizers\n     * according to the following algorithm:\n     *\n     * 1. Initialize the sizers's size to its size hint and compute the\n     *    sums for each of size hint, min size, and max size.\n     *\n     * 2. If the total size hint equals the available space, return.\n     *\n     * 3. If the available space is less than the total min size, set all\n     *    sizers to their min size and return.\n     *\n     * 4. If the available space is greater than the total max size, set\n     *    all sizers to their max size and return.\n     *\n     * 5. If the layout space is less than the total size hint, distribute\n     *    the negative delta as follows:\n     *\n     *    a. Shrink each sizer with a stretch factor greater than zero by\n     *       an amount proportional to the negative space and the sum of\n     *       stretch factors. If the sizer reaches its min size, remove\n     *       it and its stretch factor from the computation.\n     *\n     *    b. If after adjusting all stretch sizers there remains negative\n     *       space, distribute the space equally among the sizers with a\n     *       stretch factor of zero. If a sizer reaches its min size,\n     *       remove it from the computation.\n     *\n     * 6. If the layout space is greater than the total size hint,\n     *    distribute the positive delta as follows:\n     *\n     *    a. Expand each sizer with a stretch factor greater than zero by\n     *       an amount proportional to the postive space and the sum of\n     *       stretch factors. If the sizer reaches its max size, remove\n     *       it and its stretch factor from the computation.\n     *\n     *    b. If after adjusting all stretch sizers there remains positive\n     *       space, distribute the space equally among the sizers with a\n     *       stretch factor of zero. If a sizer reaches its max size,\n     *       remove it from the computation.\n     *\n     * 7. return\n     *\n     * @param sizers - The sizers for a particular layout line.\n     *\n     * @param space - The available layout space for the sizers.\n     *\n     * @returns The delta between the provided available space and the\n     *   actual consumed space. This value will be zero if the sizers\n     *   can be adjusted to fit, negative if the available space is too\n     *   small, and positive if the available space is too large.\n     *\n     * #### Notes\n     * The [[size]] of each sizer is updated with the computed size.\n     *\n     * This function can be called at any time to recompute the layout for\n     * an existing sequence of sizers. The previously computed results will\n     * have no effect on the new output. It is therefore not necessary to\n     * create new sizer objects on each resize event.\n     */\n    function calc(sizers, space) {\n        // Bail early if there is nothing to do.\n        var count = sizers.length;\n        if (count === 0) {\n            return space;\n        }\n        // Setup the size and stretch counters.\n        var totalMin = 0;\n        var totalMax = 0;\n        var totalSize = 0;\n        var totalStretch = 0;\n        var stretchCount = 0;\n        // Setup the sizers and compute the totals.\n        for (var i = 0; i < count; ++i) {\n            var sizer = sizers[i];\n            var min = sizer.minSize;\n            var max = sizer.maxSize;\n            var hint = sizer.sizeHint;\n            sizer.done = false;\n            sizer.size = Math.max(min, Math.min(hint, max));\n            totalSize += sizer.size;\n            totalMin += min;\n            totalMax += max;\n            if (sizer.stretch > 0) {\n                totalStretch += sizer.stretch;\n                stretchCount++;\n            }\n        }\n        // If the space is equal to the total size, return early.\n        if (space === totalSize) {\n            return 0;\n        }\n        // If the space is less than the total min, minimize each sizer.\n        if (space <= totalMin) {\n            for (var i = 0; i < count; ++i) {\n                var sizer = sizers[i];\n                sizer.size = sizer.minSize;\n            }\n            return space - totalMin;\n        }\n        // If the space is greater than the total max, maximize each sizer.\n        if (space >= totalMax) {\n            for (var i = 0; i < count; ++i) {\n                var sizer = sizers[i];\n                sizer.size = sizer.maxSize;\n            }\n            return space - totalMax;\n        }\n        // The loops below perform sub-pixel precision sizing. A near zero\n        // value is used for compares instead of zero to ensure that the\n        // loop terminates when the subdivided space is reasonably small.\n        var nearZero = 0.01;\n        // A counter which is decremented each time a sizer is resized to\n        // its limit. This ensures the loops terminate even if there is\n        // space remaining to distribute.\n        var notDoneCount = count;\n        // Distribute negative delta space.\n        if (space < totalSize) {\n            // Shrink each stretchable sizer by an amount proportional to its\n            // stretch factor. If a sizer reaches its min size it's marked as\n            // done. The loop progresses in phases where each sizer is given\n            // a chance to consume its fair share for the pass, regardless of\n            // whether a sizer before it reached its limit. This continues\n            // until the stretchable sizers or the free space is exhausted.\n            var freeSpace = totalSize - space;\n            while (stretchCount > 0 && freeSpace > nearZero) {\n                var distSpace = freeSpace;\n                var distStretch = totalStretch;\n                for (var i = 0; i < count; ++i) {\n                    var sizer = sizers[i];\n                    if (sizer.done || sizer.stretch === 0) {\n                        continue;\n                    }\n                    var amt = sizer.stretch * distSpace / distStretch;\n                    if (sizer.size - amt <= sizer.minSize) {\n                        freeSpace -= sizer.size - sizer.minSize;\n                        totalStretch -= sizer.stretch;\n                        sizer.size = sizer.minSize;\n                        sizer.done = true;\n                        notDoneCount--;\n                        stretchCount--;\n                    }\n                    else {\n                        freeSpace -= amt;\n                        sizer.size -= amt;\n                    }\n                }\n            }\n            // Distribute any remaining space evenly among the non-stretchable\n            // sizers. This progresses in phases in the same manner as above.\n            while (notDoneCount > 0 && freeSpace > nearZero) {\n                var amt = freeSpace / notDoneCount;\n                for (var i = 0; i < count; ++i) {\n                    var sizer = sizers[i];\n                    if (sizer.done) {\n                        continue;\n                    }\n                    if (sizer.size - amt <= sizer.minSize) {\n                        freeSpace -= sizer.size - sizer.minSize;\n                        sizer.size = sizer.minSize;\n                        sizer.done = true;\n                        notDoneCount--;\n                    }\n                    else {\n                        freeSpace -= amt;\n                        sizer.size -= amt;\n                    }\n                }\n            }\n        }\n        // Distribute positive delta space.\n        else {\n            // Expand each stretchable sizer by an amount proportional to its\n            // stretch factor. If a sizer reaches its max size it's marked as\n            // done. The loop progresses in phases where each sizer is given\n            // a chance to consume its fair share for the pass, regardless of\n            // whether a sizer before it reached its limit. This continues\n            // until the stretchable sizers or the free space is exhausted.\n            var freeSpace = space - totalSize;\n            while (stretchCount > 0 && freeSpace > nearZero) {\n                var distSpace = freeSpace;\n                var distStretch = totalStretch;\n                for (var i = 0; i < count; ++i) {\n                    var sizer = sizers[i];\n                    if (sizer.done || sizer.stretch === 0) {\n                        continue;\n                    }\n                    var amt = sizer.stretch * distSpace / distStretch;\n                    if (sizer.size + amt >= sizer.maxSize) {\n                        freeSpace -= sizer.maxSize - sizer.size;\n                        totalStretch -= sizer.stretch;\n                        sizer.size = sizer.maxSize;\n                        sizer.done = true;\n                        notDoneCount--;\n                        stretchCount--;\n                    }\n                    else {\n                        freeSpace -= amt;\n                        sizer.size += amt;\n                    }\n                }\n            }\n            // Distribute any remaining space evenly among the non-stretchable\n            // sizers. This progresses in phases in the same manner as above.\n            while (notDoneCount > 0 && freeSpace > nearZero) {\n                var amt = freeSpace / notDoneCount;\n                for (var i = 0; i < count; ++i) {\n                    var sizer = sizers[i];\n                    if (sizer.done) {\n                        continue;\n                    }\n                    if (sizer.size + amt >= sizer.maxSize) {\n                        freeSpace -= sizer.maxSize - sizer.size;\n                        sizer.size = sizer.maxSize;\n                        sizer.done = true;\n                        notDoneCount--;\n                    }\n                    else {\n                        freeSpace -= amt;\n                        sizer.size += amt;\n                    }\n                }\n            }\n        }\n        // Indicate that the consumed space equals the available space.\n        return 0;\n    }\n    BoxEngine.calc = calc;\n    /**\n     * Adjust a sizer by a delta and update its neighbors accordingly.\n     *\n     * @param sizers - The sizers which should be adjusted.\n     *\n     * @param index - The index of the sizer to grow.\n     *\n     * @param delta - The amount to adjust the sizer, positive or negative.\n     *\n     * #### Notes\n     * This will adjust the indicated sizer by the specified amount, along\n     * with the sizes of the appropriate neighbors, subject to the limits\n     * specified by each of the sizers.\n     *\n     * This is useful when implementing box layouts where the boundaries\n     * between the sizers are interactively adjustable by the user.\n     */\n    function adjust(sizers, index, delta) {\n        // Bail early when there is nothing to do.\n        if (sizers.length === 0 || delta === 0) {\n            return;\n        }\n        // Dispatch to the proper implementation.\n        if (delta > 0) {\n            growSizer(sizers, index, delta);\n        }\n        else {\n            shrinkSizer(sizers, index, -delta);\n        }\n    }\n    BoxEngine.adjust = adjust;\n    /**\n     * Grow a sizer by a positive delta and adjust neighbors.\n     */\n    function growSizer(sizers, index, delta) {\n        // Compute how much the items to the left can expand.\n        var growLimit = 0;\n        for (var i = 0; i <= index; ++i) {\n            var sizer = sizers[i];\n            growLimit += sizer.maxSize - sizer.size;\n        }\n        // Compute how much the items to the right can shrink.\n        var shrinkLimit = 0;\n        for (var i = index + 1, n = sizers.length; i < n; ++i) {\n            var sizer = sizers[i];\n            shrinkLimit += sizer.size - sizer.minSize;\n        }\n        // Clamp the delta adjustment to the limits.\n        delta = Math.min(delta, growLimit, shrinkLimit);\n        // Grow the sizers to the left by the delta.\n        var grow = delta;\n        for (var i = index; i >= 0 && grow > 0; --i) {\n            var sizer = sizers[i];\n            var limit = sizer.maxSize - sizer.size;\n            if (limit >= grow) {\n                sizer.sizeHint = sizer.size + grow;\n                grow = 0;\n            }\n            else {\n                sizer.sizeHint = sizer.size + limit;\n                grow -= limit;\n            }\n        }\n        // Shrink the sizers to the right by the delta.\n        var shrink = delta;\n        for (var i = index + 1, n = sizers.length; i < n && shrink > 0; ++i) {\n            var sizer = sizers[i];\n            var limit = sizer.size - sizer.minSize;\n            if (limit >= shrink) {\n                sizer.sizeHint = sizer.size - shrink;\n                shrink = 0;\n            }\n            else {\n                sizer.sizeHint = sizer.size - limit;\n                shrink -= limit;\n            }\n        }\n    }\n    /**\n     * Shrink a sizer by a positive delta and adjust neighbors.\n     */\n    function shrinkSizer(sizers, index, delta) {\n        // Compute how much the items to the right can expand.\n        var growLimit = 0;\n        for (var i = index + 1, n = sizers.length; i < n; ++i) {\n            var sizer = sizers[i];\n            growLimit += sizer.maxSize - sizer.size;\n        }\n        // Compute how much the items to the left can shrink.\n        var shrinkLimit = 0;\n        for (var i = 0; i <= index; ++i) {\n            var sizer = sizers[i];\n            shrinkLimit += sizer.size - sizer.minSize;\n        }\n        // Clamp the delta adjustment to the limits.\n        delta = Math.min(delta, growLimit, shrinkLimit);\n        // Grow the sizers to the right by the delta.\n        var grow = delta;\n        for (var i = index + 1, n = sizers.length; i < n && grow > 0; ++i) {\n            var sizer = sizers[i];\n            var limit = sizer.maxSize - sizer.size;\n            if (limit >= grow) {\n                sizer.sizeHint = sizer.size + grow;\n                grow = 0;\n            }\n            else {\n                sizer.sizeHint = sizer.size + limit;\n                grow -= limit;\n            }\n        }\n        // Shrink the sizers to the left by the delta.\n        var shrink = delta;\n        for (var i = index; i >= 0 && shrink > 0; --i) {\n            var sizer = sizers[i];\n            var limit = sizer.size - sizer.minSize;\n            if (limit >= shrink) {\n                sizer.sizeHint = sizer.size - shrink;\n                shrink = 0;\n            }\n            else {\n                sizer.sizeHint = sizer.size - limit;\n                shrink -= limit;\n            }\n        }\n    }\n})(BoxEngine || (BoxEngine = {}));\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n    extendStatics = Object.setPrototypeOf ||\r\n        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n    return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n    extendStatics(d, b);\r\n    function __() { this.constructor = d; }\r\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nvar __assign = function() {\r\n    __assign = Object.assign || function __assign(t) {\r\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n            s = arguments[i];\r\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n        }\r\n        return t;\r\n    };\r\n    return __assign.apply(this, arguments);\r\n};\n\n// Copyright (c) Jupyter Development Team.\n/**\n * An object which holds data related to an object's title.\n *\n * #### Notes\n * A title object is intended to hold the data necessary to display a\n * header for a particular object. A common example is the `TabPanel`,\n * which uses the widget title to populate the tab for a child widget.\n */\nvar Title = /** @class */ (function () {\n    /**\n     * Construct a new title.\n     *\n     * @param options - The options for initializing the title.\n     */\n    function Title(options) {\n        this._label = '';\n        this._caption = '';\n        this._mnemonic = -1;\n        this._iconClass = '';\n        this._iconLabel = '';\n        this._className = '';\n        this._closable = false;\n        this._changed = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(this);\n        this.owner = options.owner;\n        if (options.label !== undefined) {\n            this._label = options.label;\n        }\n        if (options.mnemonic !== undefined) {\n            this._mnemonic = options.mnemonic;\n        }\n        if (options.icon !== undefined) {\n            /* <DEPRECATED> */\n            if (typeof options.icon === \"string\") {\n                // when ._icon is null, the .icon getter will alias .iconClass\n                this._icon = null;\n                this._iconClass = options.icon;\n            }\n            else {\n                /* </DEPRECATED> */\n                this._icon = options.icon;\n                /* <DEPRECATED> */\n            }\n            /* </DEPRECATED> */\n        }\n        /* <DEPRECATED> */\n        else {\n            // if unset, default to aliasing .iconClass\n            this._icon = null;\n        }\n        /* </DEPRECATED> */\n        if (options.iconClass !== undefined) {\n            this._iconClass = options.iconClass;\n        }\n        if (options.iconLabel !== undefined) {\n            this._iconLabel = options.iconLabel;\n        }\n        if (options.iconRenderer !== undefined) {\n            this._icon = options.iconRenderer;\n        }\n        if (options.caption !== undefined) {\n            this._caption = options.caption;\n        }\n        if (options.className !== undefined) {\n            this._className = options.className;\n        }\n        if (options.closable !== undefined) {\n            this._closable = options.closable;\n        }\n        this._dataset = options.dataset || {};\n    }\n    Object.defineProperty(Title.prototype, \"changed\", {\n        /**\n         * A signal emitted when the state of the title changes.\n         */\n        get: function () {\n            return this._changed;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"label\", {\n        /**\n         * Get the label for the title.\n         *\n         * #### Notes\n         * The default value is an empty string.\n         */\n        get: function () {\n            return this._label;\n        },\n        /**\n         * Set the label for the title.\n         */\n        set: function (value) {\n            if (this._label === value) {\n                return;\n            }\n            this._label = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"mnemonic\", {\n        /**\n         * Get the mnemonic index for the title.\n         *\n         * #### Notes\n         * The default value is `-1`.\n         */\n        get: function () {\n            return this._mnemonic;\n        },\n        /**\n         * Set the mnemonic index for the title.\n         */\n        set: function (value) {\n            if (this._mnemonic === value) {\n                return;\n            }\n            this._mnemonic = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"icon\", {\n        /**\n         * Get the icon renderer for the title.\n         *\n         * #### Notes\n         * The default value is undefined.\n         *\n         * DEPRECATED: if set to a string value, the .icon field will function as\n         * an alias for the .iconClass field, for backwards compatibility\n         */\n        get: function () {\n            /* <DEPRECATED> */\n            if (this._icon === null) {\n                // only alias .iconClass if ._icon has been explicitly nulled\n                return this.iconClass;\n            }\n            /* </DEPRECATED> */\n            return this._icon;\n        },\n        /**\n         * Set the icon renderer for the title.\n         *\n         * #### Notes\n         * A renderer is an object that supplies a render and unrender function.\n         *\n         * DEPRECATED: if set to a string value, the .icon field will function as\n         * an alias for the .iconClass field, for backwards compatibility\n         */\n        set: function (value /* </DEPRECATED> */) {\n            /* <DEPRECATED> */\n            if (typeof value === \"string\") {\n                // when ._icon is null, the .icon getter will alias .iconClass\n                this._icon = null;\n                this.iconClass = value;\n            }\n            else {\n                /* </DEPRECATED> */\n                if (this._icon === value) {\n                    return;\n                }\n                this._icon = value;\n                this._changed.emit(undefined);\n                /* <DEPRECATED> */\n            }\n            /* </DEPRECATED> */\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"iconClass\", {\n        /**\n         * Get the icon class name for the title.\n         *\n         * #### Notes\n         * The default value is an empty string.\n         */\n        get: function () {\n            return this._iconClass;\n        },\n        /**\n         * Set the icon class name for the title.\n         *\n         * #### Notes\n         * Multiple class names can be separated with whitespace.\n         */\n        set: function (value) {\n            if (this._iconClass === value) {\n                return;\n            }\n            this._iconClass = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"iconLabel\", {\n        /**\n         * Get the icon label for the title.\n         *\n         * #### Notes\n         * The default value is an empty string.\n         */\n        get: function () {\n            return this._iconLabel;\n        },\n        /**\n         * Set the icon label for the title.\n         *\n         * #### Notes\n         * Multiple class names can be separated with whitespace.\n         */\n        set: function (value) {\n            if (this._iconLabel === value) {\n                return;\n            }\n            this._iconLabel = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"iconRenderer\", {\n        /**\n         * @deprecated Use `icon` instead.\n         */\n        get: function () {\n            return this._icon || undefined;\n        },\n        /**\n         * @deprecated Use `icon` instead.\n         */\n        set: function (value) {\n            this.icon = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"caption\", {\n        /**\n         * Get the caption for the title.\n         *\n         * #### Notes\n         * The default value is an empty string.\n         */\n        get: function () {\n            return this._caption;\n        },\n        /**\n         * Set the caption for the title.\n         */\n        set: function (value) {\n            if (this._caption === value) {\n                return;\n            }\n            this._caption = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"className\", {\n        /**\n         * Get the extra class name for the title.\n         *\n         * #### Notes\n         * The default value is an empty string.\n         */\n        get: function () {\n            return this._className;\n        },\n        /**\n         * Set the extra class name for the title.\n         *\n         * #### Notes\n         * Multiple class names can be separated with whitespace.\n         */\n        set: function (value) {\n            if (this._className === value) {\n                return;\n            }\n            this._className = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"closable\", {\n        /**\n         * Get the closable state for the title.\n         *\n         * #### Notes\n         * The default value is `false`.\n         */\n        get: function () {\n            return this._closable;\n        },\n        /**\n         * Set the closable state for the title.\n         *\n         * #### Notes\n         * This controls the presence of a close icon when applicable.\n         */\n        set: function (value) {\n            if (this._closable === value) {\n                return;\n            }\n            this._closable = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Title.prototype, \"dataset\", {\n        /**\n         * Get the dataset for the title.\n         *\n         * #### Notes\n         * The default value is an empty dataset.\n         */\n        get: function () {\n            return this._dataset;\n        },\n        /**\n         * Set the dataset for the title.\n         *\n         * #### Notes\n         * This controls the data attributes when applicable.\n         */\n        set: function (value) {\n            if (this._dataset === value) {\n                return;\n            }\n            this._dataset = value;\n            this._changed.emit(undefined);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    return Title;\n}());\n\n/**\n * The base class of the lumino widget hierarchy.\n *\n * #### Notes\n * This class will typically be subclassed in order to create a useful\n * widget. However, it can be used directly to host externally created\n * content.\n */\nvar Widget = /** @class */ (function () {\n    /**\n     * Construct a new widget.\n     *\n     * @param options - The options for initializing the widget.\n     */\n    function Widget(options) {\n        if (options === void 0) { options = {}; }\n        this._flags = 0;\n        this._layout = null;\n        this._parent = null;\n        this._disposed = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(this);\n        this.node = Private.createNode(options);\n        this.addClass('lm-Widget');\n        /* <DEPRECATED> */\n        this.addClass('p-Widget');\n        /* </DEPRECATED> */\n    }\n    /**\n     * Dispose of the widget and its descendant widgets.\n     *\n     * #### Notes\n     * It is unsafe to use the widget after it has been disposed.\n     *\n     * All calls made to this method after the first are a no-op.\n     */\n    Widget.prototype.dispose = function () {\n        // Do nothing if the widget is already disposed.\n        if (this.isDisposed) {\n            return;\n        }\n        // Set the disposed flag and emit the disposed signal.\n        this.setFlag(Widget.Flag.IsDisposed);\n        this._disposed.emit(undefined);\n        // Remove or detach the widget if necessary.\n        if (this.parent) {\n            this.parent = null;\n        }\n        else if (this.isAttached) {\n            Widget.detach(this);\n        }\n        // Dispose of the widget layout.\n        if (this._layout) {\n            this._layout.dispose();\n            this._layout = null;\n        }\n        // Clear the extra data associated with the widget.\n        _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal.clearData(this);\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.clearData(this);\n        _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty.clearData(this);\n    };\n    Object.defineProperty(Widget.prototype, \"disposed\", {\n        /**\n         * A signal emitted when the widget is disposed.\n         */\n        get: function () {\n            return this._disposed;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"isDisposed\", {\n        /**\n         * Test whether the widget has been disposed.\n         */\n        get: function () {\n            return this.testFlag(Widget.Flag.IsDisposed);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"isAttached\", {\n        /**\n         * Test whether the widget's node is attached to the DOM.\n         */\n        get: function () {\n            return this.testFlag(Widget.Flag.IsAttached);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"isHidden\", {\n        /**\n         * Test whether the widget is explicitly hidden.\n         */\n        get: function () {\n            return this.testFlag(Widget.Flag.IsHidden);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"isVisible\", {\n        /**\n         * Test whether the widget is visible.\n         *\n         * #### Notes\n         * A widget is visible when it is attached to the DOM, is not\n         * explicitly hidden, and has no explicitly hidden ancestors.\n         */\n        get: function () {\n            return this.testFlag(Widget.Flag.IsVisible);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"title\", {\n        /**\n         * The title object for the widget.\n         *\n         * #### Notes\n         * The title object is used by some container widgets when displaying\n         * the widget alongside some title, such as a tab panel or side bar.\n         *\n         * Since not all widgets will use the title, it is created on demand.\n         *\n         * The `owner` property of the title is set to this widget.\n         */\n        get: function () {\n            return Private.titleProperty.get(this);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"id\", {\n        /**\n         * Get the id of the widget's DOM node.\n         */\n        get: function () {\n            return this.node.id;\n        },\n        /**\n         * Set the id of the widget's DOM node.\n         */\n        set: function (value) {\n            this.node.id = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"dataset\", {\n        /**\n         * The dataset for the widget's DOM node.\n         */\n        get: function () {\n            return this.node.dataset;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"parent\", {\n        /**\n         * Get the parent of the widget.\n         */\n        get: function () {\n            return this._parent;\n        },\n        /**\n         * Set the parent of the widget.\n         *\n         * #### Notes\n         * Children are typically added to a widget by using a layout, which\n         * means user code will not normally set the parent widget directly.\n         *\n         * The widget will be automatically removed from its old parent.\n         *\n         * This is a no-op if there is no effective parent change.\n         */\n        set: function (value) {\n            if (this._parent === value) {\n                return;\n            }\n            if (value && this.contains(value)) {\n                throw new Error('Invalid parent widget.');\n            }\n            if (this._parent && !this._parent.isDisposed) {\n                var msg = new Widget.ChildMessage('child-removed', this);\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this._parent, msg);\n            }\n            this._parent = value;\n            if (this._parent && !this._parent.isDisposed) {\n                var msg = new Widget.ChildMessage('child-added', this);\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this._parent, msg);\n            }\n            if (!this.isDisposed) {\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.ParentChanged);\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Widget.prototype, \"layout\", {\n        /**\n         * Get the layout for the widget.\n         */\n        get: function () {\n            return this._layout;\n        },\n        /**\n         * Set the layout for the widget.\n         *\n         * #### Notes\n         * The layout is single-use only. It cannot be changed after the\n         * first assignment.\n         *\n         * The layout is disposed automatically when the widget is disposed.\n         */\n        set: function (value) {\n            if (this._layout === value) {\n                return;\n            }\n            if (this.testFlag(Widget.Flag.DisallowLayout)) {\n                throw new Error('Cannot set widget layout.');\n            }\n            if (this._layout) {\n                throw new Error('Cannot change widget layout.');\n            }\n            if (value.parent) {\n                throw new Error('Cannot change layout parent.');\n            }\n            this._layout = value;\n            value.parent = this;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Create an iterator over the widget's children.\n     *\n     * @returns A new iterator over the children of the widget.\n     *\n     * #### Notes\n     * The widget must have a populated layout in order to have children.\n     *\n     * If a layout is not installed, the returned iterator will be empty.\n     */\n    Widget.prototype.children = function () {\n        return this._layout ? this._layout.iter() : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Test whether a widget is a descendant of this widget.\n     *\n     * @param widget - The descendant widget of interest.\n     *\n     * @returns `true` if the widget is a descendant, `false` otherwise.\n     */\n    Widget.prototype.contains = function (widget) {\n        for (var value = widget; value; value = value._parent) {\n            if (value === this) {\n                return true;\n            }\n        }\n        return false;\n    };\n    /**\n     * Test whether the widget's DOM node has the given class name.\n     *\n     * @param name - The class name of interest.\n     *\n     * @returns `true` if the node has the class, `false` otherwise.\n     */\n    Widget.prototype.hasClass = function (name) {\n        return this.node.classList.contains(name);\n    };\n    /**\n     * Add a class name to the widget's DOM node.\n     *\n     * @param name - The class name to add to the node.\n     *\n     * #### Notes\n     * If the class name is already added to the node, this is a no-op.\n     *\n     * The class name must not contain whitespace.\n     */\n    Widget.prototype.addClass = function (name) {\n        this.node.classList.add(name);\n    };\n    /**\n     * Remove a class name from the widget's DOM node.\n     *\n     * @param name - The class name to remove from the node.\n     *\n     * #### Notes\n     * If the class name is not yet added to the node, this is a no-op.\n     *\n     * The class name must not contain whitespace.\n     */\n    Widget.prototype.removeClass = function (name) {\n        this.node.classList.remove(name);\n    };\n    /**\n     * Toggle a class name on the widget's DOM node.\n     *\n     * @param name - The class name to toggle on the node.\n     *\n     * @param force - Whether to force add the class (`true`) or force\n     *   remove the class (`false`). If not provided, the presence of\n     *   the class will be toggled from its current state.\n     *\n     * @returns `true` if the class is now present, `false` otherwise.\n     *\n     * #### Notes\n     * The class name must not contain whitespace.\n     */\n    Widget.prototype.toggleClass = function (name, force) {\n        if (force === true) {\n            this.node.classList.add(name);\n            return true;\n        }\n        if (force === false) {\n            this.node.classList.remove(name);\n            return false;\n        }\n        return this.node.classList.toggle(name);\n    };\n    /**\n     * Post an `'update-request'` message to the widget.\n     *\n     * #### Notes\n     * This is a simple convenience method for posting the message.\n     */\n    Widget.prototype.update = function () {\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Widget.Msg.UpdateRequest);\n    };\n    /**\n     * Post a `'fit-request'` message to the widget.\n     *\n     * #### Notes\n     * This is a simple convenience method for posting the message.\n     */\n    Widget.prototype.fit = function () {\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Widget.Msg.FitRequest);\n    };\n    /**\n     * Post an `'activate-request'` message to the widget.\n     *\n     * #### Notes\n     * This is a simple convenience method for posting the message.\n     */\n    Widget.prototype.activate = function () {\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Widget.Msg.ActivateRequest);\n    };\n    /**\n     * Send a `'close-request'` message to the widget.\n     *\n     * #### Notes\n     * This is a simple convenience method for sending the message.\n     */\n    Widget.prototype.close = function () {\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.CloseRequest);\n    };\n    /**\n     * Show the widget and make it visible to its parent widget.\n     *\n     * #### Notes\n     * This causes the [[isHidden]] property to be `false`.\n     *\n     * If the widget is not explicitly hidden, this is a no-op.\n     */\n    Widget.prototype.show = function () {\n        if (!this.testFlag(Widget.Flag.IsHidden)) {\n            return;\n        }\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.BeforeShow);\n        }\n        this.clearFlag(Widget.Flag.IsHidden);\n        this.removeClass('lm-mod-hidden');\n        /* <DEPRECATED> */\n        this.removeClass('p-mod-hidden');\n        /* </DEPRECATED> */\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.AfterShow);\n        }\n        if (this.parent) {\n            var msg = new Widget.ChildMessage('child-shown', this);\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, msg);\n        }\n    };\n    /**\n     * Hide the widget and make it hidden to its parent widget.\n     *\n     * #### Notes\n     * This causes the [[isHidden]] property to be `true`.\n     *\n     * If the widget is explicitly hidden, this is a no-op.\n     */\n    Widget.prototype.hide = function () {\n        if (this.testFlag(Widget.Flag.IsHidden)) {\n            return;\n        }\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.BeforeHide);\n        }\n        this.setFlag(Widget.Flag.IsHidden);\n        this.addClass('lm-mod-hidden');\n        /* <DEPRECATED> */\n        this.addClass('p-mod-hidden');\n        /* </DEPRECATED> */\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.AfterHide);\n        }\n        if (this.parent) {\n            var msg = new Widget.ChildMessage('child-hidden', this);\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, msg);\n        }\n    };\n    /**\n     * Show or hide the widget according to a boolean value.\n     *\n     * @param hidden - `true` to hide the widget, or `false` to show it.\n     *\n     * #### Notes\n     * This is a convenience method for `hide()` and `show()`.\n     */\n    Widget.prototype.setHidden = function (hidden) {\n        if (hidden) {\n            this.hide();\n        }\n        else {\n            this.show();\n        }\n    };\n    /**\n     * Test whether the given widget flag is set.\n     *\n     * #### Notes\n     * This will not typically be called directly by user code.\n     */\n    Widget.prototype.testFlag = function (flag) {\n        return (this._flags & flag) !== 0;\n    };\n    /**\n     * Set the given widget flag.\n     *\n     * #### Notes\n     * This will not typically be called directly by user code.\n     */\n    Widget.prototype.setFlag = function (flag) {\n        this._flags |= flag;\n    };\n    /**\n     * Clear the given widget flag.\n     *\n     * #### Notes\n     * This will not typically be called directly by user code.\n     */\n    Widget.prototype.clearFlag = function (flag) {\n        this._flags &= ~flag;\n    };\n    /**\n     * Process a message sent to the widget.\n     *\n     * @param msg - The message sent to the widget.\n     *\n     * #### Notes\n     * Subclasses may reimplement this method as needed.\n     */\n    Widget.prototype.processMessage = function (msg) {\n        switch (msg.type) {\n            case 'resize':\n                this.notifyLayout(msg);\n                this.onResize(msg);\n                break;\n            case 'update-request':\n                this.notifyLayout(msg);\n                this.onUpdateRequest(msg);\n                break;\n            case 'fit-request':\n                this.notifyLayout(msg);\n                this.onFitRequest(msg);\n                break;\n            case 'before-show':\n                this.notifyLayout(msg);\n                this.onBeforeShow(msg);\n                break;\n            case 'after-show':\n                this.setFlag(Widget.Flag.IsVisible);\n                this.notifyLayout(msg);\n                this.onAfterShow(msg);\n                break;\n            case 'before-hide':\n                this.notifyLayout(msg);\n                this.onBeforeHide(msg);\n                break;\n            case 'after-hide':\n                this.clearFlag(Widget.Flag.IsVisible);\n                this.notifyLayout(msg);\n                this.onAfterHide(msg);\n                break;\n            case 'before-attach':\n                this.notifyLayout(msg);\n                this.onBeforeAttach(msg);\n                break;\n            case 'after-attach':\n                if (!this.isHidden && (!this.parent || this.parent.isVisible)) {\n                    this.setFlag(Widget.Flag.IsVisible);\n                }\n                this.setFlag(Widget.Flag.IsAttached);\n                this.notifyLayout(msg);\n                this.onAfterAttach(msg);\n                break;\n            case 'before-detach':\n                this.notifyLayout(msg);\n                this.onBeforeDetach(msg);\n                break;\n            case 'after-detach':\n                this.clearFlag(Widget.Flag.IsVisible);\n                this.clearFlag(Widget.Flag.IsAttached);\n                this.notifyLayout(msg);\n                this.onAfterDetach(msg);\n                break;\n            case 'activate-request':\n                this.notifyLayout(msg);\n                this.onActivateRequest(msg);\n                break;\n            case 'close-request':\n                this.notifyLayout(msg);\n                this.onCloseRequest(msg);\n                break;\n            case 'child-added':\n                this.notifyLayout(msg);\n                this.onChildAdded(msg);\n                break;\n            case 'child-removed':\n                this.notifyLayout(msg);\n                this.onChildRemoved(msg);\n                break;\n            default:\n                this.notifyLayout(msg);\n                break;\n        }\n    };\n    /**\n     * Invoke the message processing routine of the widget's layout.\n     *\n     * @param msg - The message to dispatch to the layout.\n     *\n     * #### Notes\n     * This is a no-op if the widget does not have a layout.\n     *\n     * This will not typically be called directly by user code.\n     */\n    Widget.prototype.notifyLayout = function (msg) {\n        if (this._layout) {\n            this._layout.processParentMessage(msg);\n        }\n    };\n    /**\n     * A message handler invoked on a `'close-request'` message.\n     *\n     * #### Notes\n     * The default implementation unparents or detaches the widget.\n     */\n    Widget.prototype.onCloseRequest = function (msg) {\n        if (this.parent) {\n            this.parent = null;\n        }\n        else if (this.isAttached) {\n            Widget.detach(this);\n        }\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onResize = function (msg) { };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onUpdateRequest = function (msg) { };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onFitRequest = function (msg) { };\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onActivateRequest = function (msg) { };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onBeforeShow = function (msg) { };\n    /**\n     * A message handler invoked on an `'after-show'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onAfterShow = function (msg) { };\n    /**\n     * A message handler invoked on a `'before-hide'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onBeforeHide = function (msg) { };\n    /**\n     * A message handler invoked on an `'after-hide'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onAfterHide = function (msg) { };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onBeforeAttach = function (msg) { };\n    /**\n     * A message handler invoked on an `'after-attach'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onAfterAttach = function (msg) { };\n    /**\n     * A message handler invoked on a `'before-detach'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onBeforeDetach = function (msg) { };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onAfterDetach = function (msg) { };\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onChildAdded = function (msg) { };\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Widget.prototype.onChildRemoved = function (msg) { };\n    return Widget;\n}());\n/**\n * The namespace for the `Widget` class statics.\n */\n(function (Widget) {\n    /**\n     * An enum of widget bit flags.\n     */\n    var Flag;\n    (function (Flag) {\n        /**\n         * The widget has been disposed.\n         */\n        Flag[Flag[\"IsDisposed\"] = 1] = \"IsDisposed\";\n        /**\n         * The widget is attached to the DOM.\n         */\n        Flag[Flag[\"IsAttached\"] = 2] = \"IsAttached\";\n        /**\n         * The widget is hidden.\n         */\n        Flag[Flag[\"IsHidden\"] = 4] = \"IsHidden\";\n        /**\n         * The widget is visible.\n         */\n        Flag[Flag[\"IsVisible\"] = 8] = \"IsVisible\";\n        /**\n         * A layout cannot be set on the widget.\n         */\n        Flag[Flag[\"DisallowLayout\"] = 16] = \"DisallowLayout\";\n    })(Flag = Widget.Flag || (Widget.Flag = {}));\n    /**\n     * A collection of stateless messages related to widgets.\n     */\n    var Msg;\n    (function (Msg) {\n        /**\n         * A singleton `'before-show'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget before it becomes visible.\n         *\n         * This message is **not** sent when the widget is being attached.\n         */\n        Msg.BeforeShow = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('before-show');\n        /**\n         * A singleton `'after-show'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget after it becomes visible.\n         *\n         * This message is **not** sent when the widget is being attached.\n         */\n        Msg.AfterShow = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('after-show');\n        /**\n         * A singleton `'before-hide'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget before it becomes not-visible.\n         *\n         * This message is **not** sent when the widget is being detached.\n         */\n        Msg.BeforeHide = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('before-hide');\n        /**\n         * A singleton `'after-hide'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget after it becomes not-visible.\n         *\n         * This message is **not** sent when the widget is being detached.\n         */\n        Msg.AfterHide = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('after-hide');\n        /**\n         * A singleton `'before-attach'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget before it is attached.\n         */\n        Msg.BeforeAttach = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('before-attach');\n        /**\n         * A singleton `'after-attach'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget after it is attached.\n         */\n        Msg.AfterAttach = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('after-attach');\n        /**\n         * A singleton `'before-detach'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget before it is detached.\n         */\n        Msg.BeforeDetach = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('before-detach');\n        /**\n         * A singleton `'after-detach'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget after it is detached.\n         */\n        Msg.AfterDetach = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('after-detach');\n        /**\n         * A singleton `'parent-changed'` message.\n         *\n         * #### Notes\n         * This message is sent to a widget when its parent has changed.\n         */\n        Msg.ParentChanged = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message('parent-changed');\n        /**\n         * A singleton conflatable `'update-request'` message.\n         *\n         * #### Notes\n         * This message can be dispatched to supporting widgets in order to\n         * update their content based on the current widget state. Not all\n         * widgets will respond to messages of this type.\n         *\n         * For widgets with a layout, this message will inform the layout to\n         * update the position and size of its child widgets.\n         */\n        Msg.UpdateRequest = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.ConflatableMessage('update-request');\n        /**\n         * A singleton conflatable `'fit-request'` message.\n         *\n         * #### Notes\n         * For widgets with a layout, this message will inform the layout to\n         * recalculate its size constraints to fit the space requirements of\n         * its child widgets, and to update their position and size. Not all\n         * layouts will respond to messages of this type.\n         */\n        Msg.FitRequest = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.ConflatableMessage('fit-request');\n        /**\n         * A singleton conflatable `'activate-request'` message.\n         *\n         * #### Notes\n         * This message should be dispatched to a widget when it should\n         * perform the actions necessary to activate the widget, which\n         * may include focusing its node or descendant node.\n         */\n        Msg.ActivateRequest = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.ConflatableMessage('activate-request');\n        /**\n         * A singleton conflatable `'close-request'` message.\n         *\n         * #### Notes\n         * This message should be dispatched to a widget when it should close\n         * and remove itself from the widget hierarchy.\n         */\n        Msg.CloseRequest = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.ConflatableMessage('close-request');\n    })(Msg = Widget.Msg || (Widget.Msg = {}));\n    /**\n     * A message class for child related messages.\n     */\n    var ChildMessage = /** @class */ (function (_super) {\n        __extends(ChildMessage, _super);\n        /**\n         * Construct a new child message.\n         *\n         * @param type - The message type.\n         *\n         * @param child - The child widget for the message.\n         */\n        function ChildMessage(type, child) {\n            var _this = _super.call(this, type) || this;\n            _this.child = child;\n            return _this;\n        }\n        return ChildMessage;\n    }(_lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message));\n    Widget.ChildMessage = ChildMessage;\n    /**\n     * A message class for `'resize'` messages.\n     */\n    var ResizeMessage = /** @class */ (function (_super) {\n        __extends(ResizeMessage, _super);\n        /**\n         * Construct a new resize message.\n         *\n         * @param width - The **offset width** of the widget, or `-1` if\n         *   the width is not known.\n         *\n         * @param height - The **offset height** of the widget, or `-1` if\n         *   the height is not known.\n         */\n        function ResizeMessage(width, height) {\n            var _this = _super.call(this, 'resize') || this;\n            _this.width = width;\n            _this.height = height;\n            return _this;\n        }\n        return ResizeMessage;\n    }(_lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.Message));\n    Widget.ResizeMessage = ResizeMessage;\n    /**\n     * The namespace for the `ResizeMessage` class statics.\n     */\n    (function (ResizeMessage) {\n        /**\n         * A singleton `'resize'` message with an unknown size.\n         */\n        ResizeMessage.UnknownSize = new ResizeMessage(-1, -1);\n    })(ResizeMessage = Widget.ResizeMessage || (Widget.ResizeMessage = {}));\n    /**\n     * Attach a widget to a host DOM node.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param host - The DOM node to use as the widget's host.\n     *\n     * @param ref - The child of `host` to use as the reference element.\n     *   If this is provided, the widget will be inserted before this\n     *   node in the host. The default is `null`, which will cause the\n     *   widget to be added as the last child of the host.\n     *\n     * #### Notes\n     * This will throw an error if the widget is not a root widget, if\n     * the widget is already attached, or if the host is not attached\n     * to the DOM.\n     */\n    function attach(widget, host, ref) {\n        if (ref === void 0) { ref = null; }\n        if (widget.parent) {\n            throw new Error('Cannot attach a child widget.');\n        }\n        if (widget.isAttached || document.body.contains(widget.node)) {\n            throw new Error('Widget is already attached.');\n        }\n        if (!document.body.contains(host)) {\n            throw new Error('Host is not attached.');\n        }\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        host.insertBefore(widget.node, ref);\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n    }\n    Widget.attach = attach;\n    /**\n     * Detach the widget from its host DOM node.\n     *\n     * @param widget - The widget of interest.\n     *\n     * #### Notes\n     * This will throw an error if the widget is not a root widget,\n     * or if the widget is not attached to the DOM.\n     */\n    function detach(widget) {\n        if (widget.parent) {\n            throw new Error('Cannot detach a child widget.');\n        }\n        if (!widget.isAttached || !document.body.contains(widget.node)) {\n            throw new Error('Widget is not attached.');\n        }\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        widget.node.parentNode.removeChild(widget.node);\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n    }\n    Widget.detach = detach;\n})(Widget || (Widget = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * An attached property for the widget title object.\n     */\n    Private.titleProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'title',\n        create: function (owner) { return new Title({ owner: owner }); },\n    });\n    /**\n     * Create a DOM node for the given widget options.\n     */\n    function createNode(options) {\n        return options.node || document.createElement(options.tag || 'div');\n    }\n    Private.createNode = createNode;\n})(Private || (Private = {}));\n\n// Copyright (c) Jupyter Development Team.\n/**\n * An abstract base class for creating lumino layouts.\n *\n * #### Notes\n * A layout is used to add widgets to a parent and to arrange those\n * widgets within the parent's DOM node.\n *\n * This class implements the base functionality which is required of\n * nearly all layouts. It must be subclassed in order to be useful.\n *\n * Notably, this class does not define a uniform interface for adding\n * widgets to the layout. A subclass should define that API in a way\n * which is meaningful for its intended use.\n */\nvar Layout = /** @class */ (function () {\n    /**\n     * Construct a new layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    function Layout(options) {\n        if (options === void 0) { options = {}; }\n        this._disposed = false;\n        this._parent = null;\n        this._fitPolicy = options.fitPolicy || 'set-min-size';\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     *\n     * #### Notes\n     * This should be reimplemented to clear and dispose of the widgets.\n     *\n     * All reimplementations should call the superclass method.\n     *\n     * This method is called automatically when the parent is disposed.\n     */\n    Layout.prototype.dispose = function () {\n        this._parent = null;\n        this._disposed = true;\n        _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal.clearData(this);\n        _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty.clearData(this);\n    };\n    Object.defineProperty(Layout.prototype, \"isDisposed\", {\n        /**\n         * Test whether the layout is disposed.\n         */\n        get: function () {\n            return this._disposed;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Layout.prototype, \"parent\", {\n        /**\n         * Get the parent widget of the layout.\n         */\n        get: function () {\n            return this._parent;\n        },\n        /**\n         * Set the parent widget of the layout.\n         *\n         * #### Notes\n         * This is set automatically when installing the layout on the parent\n         * widget. The parent widget should not be set directly by user code.\n         */\n        set: function (value) {\n            if (this._parent === value) {\n                return;\n            }\n            if (this._parent) {\n                throw new Error('Cannot change parent widget.');\n            }\n            if (value.layout !== this) {\n                throw new Error('Invalid parent widget.');\n            }\n            this._parent = value;\n            this.init();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Layout.prototype, \"fitPolicy\", {\n        /**\n         * Get the fit policy for the layout.\n         *\n         * #### Notes\n         * The fit policy controls the computed size constraints which are\n         * applied to the parent widget by the layout.\n         *\n         * Some layout implementations may ignore the fit policy.\n         */\n        get: function () {\n            return this._fitPolicy;\n        },\n        /**\n         * Set the fit policy for the layout.\n         *\n         * #### Notes\n         * The fit policy controls the computed size constraints which are\n         * applied to the parent widget by the layout.\n         *\n         * Some layout implementations may ignore the fit policy.\n         *\n         * Changing the fit policy will clear the current size constraint\n         * for the parent widget and then re-fit the parent.\n         */\n        set: function (value) {\n            // Bail if the policy does not change\n            if (this._fitPolicy === value) {\n                return;\n            }\n            // Update the internal policy.\n            this._fitPolicy = value;\n            // Clear the size constraints and schedule a fit of the parent.\n            if (this._parent) {\n                var style = this._parent.node.style;\n                style.minWidth = '';\n                style.minHeight = '';\n                style.maxWidth = '';\n                style.maxHeight = '';\n                this._parent.fit();\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Process a message sent to the parent widget.\n     *\n     * @param msg - The message sent to the parent widget.\n     *\n     * #### Notes\n     * This method is called by the parent widget to process a message.\n     *\n     * Subclasses may reimplement this method as needed.\n     */\n    Layout.prototype.processParentMessage = function (msg) {\n        switch (msg.type) {\n            case 'resize':\n                this.onResize(msg);\n                break;\n            case 'update-request':\n                this.onUpdateRequest(msg);\n                break;\n            case 'fit-request':\n                this.onFitRequest(msg);\n                break;\n            case 'before-show':\n                this.onBeforeShow(msg);\n                break;\n            case 'after-show':\n                this.onAfterShow(msg);\n                break;\n            case 'before-hide':\n                this.onBeforeHide(msg);\n                break;\n            case 'after-hide':\n                this.onAfterHide(msg);\n                break;\n            case 'before-attach':\n                this.onBeforeAttach(msg);\n                break;\n            case 'after-attach':\n                this.onAfterAttach(msg);\n                break;\n            case 'before-detach':\n                this.onBeforeDetach(msg);\n                break;\n            case 'after-detach':\n                this.onAfterDetach(msg);\n                break;\n            case 'child-removed':\n                this.onChildRemoved(msg);\n                break;\n            case 'child-shown':\n                this.onChildShown(msg);\n                break;\n            case 'child-hidden':\n                this.onChildHidden(msg);\n                break;\n        }\n    };\n    /**\n     * Perform layout initialization which requires the parent widget.\n     *\n     * #### Notes\n     * This method is invoked immediately after the layout is installed\n     * on the parent widget.\n     *\n     * The default implementation reparents all of the widgets to the\n     * layout parent widget.\n     *\n     * Subclasses should reimplement this method and attach the child\n     * widget nodes to the parent widget's node.\n     */\n    Layout.prototype.init = function () {\n        var _this = this;\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            widget.parent = _this.parent;\n        });\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     *\n     * #### Notes\n     * The layout should ensure that its widgets are resized according\n     * to the specified layout space, and that they are sent a `'resize'`\n     * message if appropriate.\n     *\n     * The default implementation of this method sends an `UnknownSize`\n     * resize message to all widgets.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onResize = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.ResizeMessage.UnknownSize);\n        });\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     *\n     * #### Notes\n     * The layout should ensure that its widgets are resized according\n     * to the available layout space, and that they are sent a `'resize'`\n     * message if appropriate.\n     *\n     * The default implementation of this method sends an `UnknownSize`\n     * resize message to all widgets.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onUpdateRequest = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.ResizeMessage.UnknownSize);\n        });\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message\n     * to all widgets. It assumes all widget nodes are attached to the\n     * parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onBeforeAttach = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n        });\n    };\n    /**\n     * A message handler invoked on an `'after-attach'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message\n     * to all widgets. It assumes all widget nodes are attached to the\n     * parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onAfterAttach = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n        });\n    };\n    /**\n     * A message handler invoked on a `'before-detach'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message\n     * to all widgets. It assumes all widget nodes are attached to the\n     * parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onBeforeDetach = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n        });\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message\n     * to all widgets. It assumes all widget nodes are attached to the\n     * parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onAfterDetach = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n        });\n    };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message to\n     * all non-hidden widgets. It assumes all widget nodes are attached\n     * to the parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onBeforeShow = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            if (!widget.isHidden) {\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n            }\n        });\n    };\n    /**\n     * A message handler invoked on an `'after-show'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message to\n     * all non-hidden widgets. It assumes all widget nodes are attached\n     * to the parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onAfterShow = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            if (!widget.isHidden) {\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n            }\n        });\n    };\n    /**\n     * A message handler invoked on a `'before-hide'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message to\n     * all non-hidden widgets. It assumes all widget nodes are attached\n     * to the parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onBeforeHide = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            if (!widget.isHidden) {\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n            }\n        });\n    };\n    /**\n     * A message handler invoked on an `'after-hide'` message.\n     *\n     * #### Notes\n     * The default implementation of this method forwards the message to\n     * all non-hidden widgets. It assumes all widget nodes are attached\n     * to the parent widget node.\n     *\n     * This may be reimplemented by subclasses as needed.\n     */\n    Layout.prototype.onAfterHide = function (msg) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) {\n            if (!widget.isHidden) {\n                _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, msg);\n            }\n        });\n    };\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     *\n     * #### Notes\n     * This will remove the child widget from the layout.\n     *\n     * Subclasses should **not** typically reimplement this method.\n     */\n    Layout.prototype.onChildRemoved = function (msg) {\n        this.removeWidget(msg.child);\n    };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Layout.prototype.onFitRequest = function (msg) { };\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Layout.prototype.onChildShown = function (msg) { };\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     *\n     * #### Notes\n     * The default implementation of this handler is a no-op.\n     */\n    Layout.prototype.onChildHidden = function (msg) { };\n    return Layout;\n}());\n/**\n * The namespace for the `Layout` class statics.\n */\n(function (Layout) {\n    /**\n     * Get the horizontal alignment for a widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The horizontal alignment for the widget.\n     *\n     * #### Notes\n     * If the layout width allocated to a widget is larger than its max\n     * width, the horizontal alignment controls how the widget is placed\n     * within the extra horizontal space.\n     *\n     * If the allocated width is less than the widget's max width, the\n     * horizontal alignment has no effect.\n     *\n     * Some layout implementations may ignore horizontal alignment.\n     */\n    function getHorizontalAlignment(widget) {\n        return Private$1.horizontalAlignmentProperty.get(widget);\n    }\n    Layout.getHorizontalAlignment = getHorizontalAlignment;\n    /**\n     * Set the horizontal alignment for a widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the horizontal alignment.\n     *\n     * #### Notes\n     * If the layout width allocated to a widget is larger than its max\n     * width, the horizontal alignment controls how the widget is placed\n     * within the extra horizontal space.\n     *\n     * If the allocated width is less than the widget's max width, the\n     * horizontal alignment has no effect.\n     *\n     * Some layout implementations may ignore horizontal alignment.\n     *\n     * Changing the horizontal alignment will post an `update-request`\n     * message to widget's parent, provided the parent has a layout\n     * installed.\n     */\n    function setHorizontalAlignment(widget, value) {\n        Private$1.horizontalAlignmentProperty.set(widget, value);\n    }\n    Layout.setHorizontalAlignment = setHorizontalAlignment;\n    /**\n     * Get the vertical alignment for a widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The vertical alignment for the widget.\n     *\n     * #### Notes\n     * If the layout height allocated to a widget is larger than its max\n     * height, the vertical alignment controls how the widget is placed\n     * within the extra vertical space.\n     *\n     * If the allocated height is less than the widget's max height, the\n     * vertical alignment has no effect.\n     *\n     * Some layout implementations may ignore vertical alignment.\n     */\n    function getVerticalAlignment(widget) {\n        return Private$1.verticalAlignmentProperty.get(widget);\n    }\n    Layout.getVerticalAlignment = getVerticalAlignment;\n    /**\n     * Set the vertical alignment for a widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the vertical alignment.\n     *\n     * #### Notes\n     * If the layout height allocated to a widget is larger than its max\n     * height, the vertical alignment controls how the widget is placed\n     * within the extra vertical space.\n     *\n     * If the allocated height is less than the widget's max height, the\n     * vertical alignment has no effect.\n     *\n     * Some layout implementations may ignore vertical alignment.\n     *\n     * Changing the horizontal alignment will post an `update-request`\n     * message to widget's parent, provided the parent has a layout\n     * installed.\n     */\n    function setVerticalAlignment(widget, value) {\n        Private$1.verticalAlignmentProperty.set(widget, value);\n    }\n    Layout.setVerticalAlignment = setVerticalAlignment;\n})(Layout || (Layout = {}));\n/**\n * An object which assists in the absolute layout of widgets.\n *\n * #### Notes\n * This class is useful when implementing a layout which arranges its\n * widgets using absolute positioning.\n *\n * This class is used by nearly all of the built-in lumino layouts.\n */\nvar LayoutItem = /** @class */ (function () {\n    /**\n     * Construct a new layout item.\n     *\n     * @param widget - The widget to be managed by the item.\n     *\n     * #### Notes\n     * The widget will be set to absolute positioning.\n     */\n    function LayoutItem(widget) {\n        this._top = NaN;\n        this._left = NaN;\n        this._width = NaN;\n        this._height = NaN;\n        this._minWidth = 0;\n        this._minHeight = 0;\n        this._maxWidth = Infinity;\n        this._maxHeight = Infinity;\n        this._disposed = false;\n        this.widget = widget;\n        this.widget.node.style.position = 'absolute';\n    }\n    /**\n     * Dispose of the the layout item.\n     *\n     * #### Notes\n     * This will reset the positioning of the widget.\n     */\n    LayoutItem.prototype.dispose = function () {\n        // Do nothing if the item is already disposed.\n        if (this._disposed) {\n            return;\n        }\n        // Mark the item as disposed.\n        this._disposed = true;\n        // Reset the widget style.\n        var style = this.widget.node.style;\n        style.position = '';\n        style.top = '';\n        style.left = '';\n        style.width = '';\n        style.height = '';\n    };\n    Object.defineProperty(LayoutItem.prototype, \"minWidth\", {\n        /**\n         * The computed minimum width of the widget.\n         *\n         * #### Notes\n         * This value can be updated by calling the `fit` method.\n         */\n        get: function () {\n            return this._minWidth;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"minHeight\", {\n        /**\n         * The computed minimum height of the widget.\n         *\n         * #### Notes\n         * This value can be updated by calling the `fit` method.\n         */\n        get: function () {\n            return this._minHeight;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"maxWidth\", {\n        /**\n         * The computed maximum width of the widget.\n         *\n         * #### Notes\n         * This value can be updated by calling the `fit` method.\n         */\n        get: function () {\n            return this._maxWidth;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"maxHeight\", {\n        /**\n         * The computed maximum height of the widget.\n         *\n         * #### Notes\n         * This value can be updated by calling the `fit` method.\n         */\n        get: function () {\n            return this._maxHeight;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"isDisposed\", {\n        /**\n         * Whether the layout item is disposed.\n         */\n        get: function () {\n            return this._disposed;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"isHidden\", {\n        /**\n         * Whether the managed widget is hidden.\n         */\n        get: function () {\n            return this.widget.isHidden;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"isVisible\", {\n        /**\n         * Whether the managed widget is visible.\n         */\n        get: function () {\n            return this.widget.isVisible;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(LayoutItem.prototype, \"isAttached\", {\n        /**\n         * Whether the managed widget is attached.\n         */\n        get: function () {\n            return this.widget.isAttached;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Update the computed size limits of the managed widget.\n     */\n    LayoutItem.prototype.fit = function () {\n        var limits = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.sizeLimits(this.widget.node);\n        this._minWidth = limits.minWidth;\n        this._minHeight = limits.minHeight;\n        this._maxWidth = limits.maxWidth;\n        this._maxHeight = limits.maxHeight;\n    };\n    /**\n     * Update the position and size of the managed widget.\n     *\n     * @param left - The left edge position of the layout box.\n     *\n     * @param top - The top edge position of the layout box.\n     *\n     * @param width - The width of the layout box.\n     *\n     * @param height - The height of the layout box.\n     */\n    LayoutItem.prototype.update = function (left, top, width, height) {\n        // Clamp the size to the computed size limits.\n        var clampW = Math.max(this._minWidth, Math.min(width, this._maxWidth));\n        var clampH = Math.max(this._minHeight, Math.min(height, this._maxHeight));\n        // Adjust the left edge for the horizontal alignment, if needed.\n        if (clampW < width) {\n            switch (Layout.getHorizontalAlignment(this.widget)) {\n                case 'left':\n                    break;\n                case 'center':\n                    left += (width - clampW) / 2;\n                    break;\n                case 'right':\n                    left += width - clampW;\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n        }\n        // Adjust the top edge for the vertical alignment, if needed.\n        if (clampH < height) {\n            switch (Layout.getVerticalAlignment(this.widget)) {\n                case 'top':\n                    break;\n                case 'center':\n                    top += (height - clampH) / 2;\n                    break;\n                case 'bottom':\n                    top += height - clampH;\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n        }\n        // Set up the resize variables.\n        var resized = false;\n        var style = this.widget.node.style;\n        // Update the top edge of the widget if needed.\n        if (this._top !== top) {\n            this._top = top;\n            style.top = top + \"px\";\n        }\n        // Update the left edge of the widget if needed.\n        if (this._left !== left) {\n            this._left = left;\n            style.left = left + \"px\";\n        }\n        // Update the width of the widget if needed.\n        if (this._width !== clampW) {\n            resized = true;\n            this._width = clampW;\n            style.width = clampW + \"px\";\n        }\n        // Update the height of the widget if needed.\n        if (this._height !== clampH) {\n            resized = true;\n            this._height = clampH;\n            style.height = clampH + \"px\";\n        }\n        // Send a resize message to the widget if needed.\n        if (resized) {\n            var msg = new Widget.ResizeMessage(clampW, clampH);\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.widget, msg);\n        }\n    };\n    return LayoutItem;\n}());\n/**\n * The namespace for the module implementation details.\n */\nvar Private$1;\n(function (Private) {\n    /**\n     * The attached property for a widget horizontal alignment.\n     */\n    Private.horizontalAlignmentProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'horizontalAlignment',\n        create: function () { return 'center'; },\n        changed: onAlignmentChanged\n    });\n    /**\n     * The attached property for a widget vertical alignment.\n     */\n    Private.verticalAlignmentProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'verticalAlignment',\n        create: function () { return 'top'; },\n        changed: onAlignmentChanged\n    });\n    /**\n     * The change handler for the attached alignment properties.\n     */\n    function onAlignmentChanged(child) {\n        if (child.parent && child.parent.layout) {\n            child.parent.update();\n        }\n    }\n})(Private$1 || (Private$1 = {}));\n\n/**\n * A concrete layout implementation suitable for many use cases.\n *\n * #### Notes\n * This class is suitable as a base class for implementing a variety of\n * layouts, but can also be used directly with standard CSS to layout a\n * collection of widgets.\n */\nvar PanelLayout = /** @class */ (function (_super) {\n    __extends(PanelLayout, _super);\n    function PanelLayout() {\n        var _this = _super !== null && _super.apply(this, arguments) || this;\n        _this._widgets = [];\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     *\n     * #### Notes\n     * This will clear and dispose all widgets in the layout.\n     *\n     * All reimplementations should call the superclass method.\n     *\n     * This method is called automatically when the parent is disposed.\n     */\n    PanelLayout.prototype.dispose = function () {\n        while (this._widgets.length > 0) {\n            this._widgets.pop().dispose();\n        }\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(PanelLayout.prototype, \"widgets\", {\n        /**\n         * A read-only array of the widgets in the layout.\n         */\n        get: function () {\n            return this._widgets;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Create an iterator over the widgets in the layout.\n     *\n     * @returns A new iterator over the widgets in the layout.\n     */\n    PanelLayout.prototype.iter = function () {\n        return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.iter)(this._widgets);\n    };\n    /**\n     * Add a widget to the end of the layout.\n     *\n     * @param widget - The widget to add to the layout.\n     *\n     * #### Notes\n     * If the widget is already contained in the layout, it will be moved.\n     */\n    PanelLayout.prototype.addWidget = function (widget) {\n        this.insertWidget(this._widgets.length, widget);\n    };\n    /**\n     * Insert a widget into the layout at the specified index.\n     *\n     * @param index - The index at which to insert the widget.\n     *\n     * @param widget - The widget to insert into the layout.\n     *\n     * #### Notes\n     * The index will be clamped to the bounds of the widgets.\n     *\n     * If the widget is already added to the layout, it will be moved.\n     *\n     * #### Undefined Behavior\n     * An `index` which is non-integral.\n     */\n    PanelLayout.prototype.insertWidget = function (index, widget) {\n        // Remove the widget from its current parent. This is a no-op\n        // if the widget's parent is already the layout parent widget.\n        widget.parent = this.parent;\n        // Look up the current index of the widget.\n        var i = this._widgets.indexOf(widget);\n        // Clamp the insert index to the array bounds.\n        var j = Math.max(0, Math.min(index, this._widgets.length));\n        // If the widget is not in the array, insert it.\n        if (i === -1) {\n            // Insert the widget into the array.\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._widgets, j, widget);\n            // If the layout is parented, attach the widget to the DOM.\n            if (this.parent) {\n                this.attachWidget(j, widget);\n            }\n            // There is nothing more to do.\n            return;\n        }\n        // Otherwise, the widget exists in the array and should be moved.\n        // Adjust the index if the location is at the end of the array.\n        if (j === this._widgets.length) {\n            j--;\n        }\n        // Bail if there is no effective move.\n        if (i === j) {\n            return;\n        }\n        // Move the widget to the new location.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._widgets, i, j);\n        // If the layout is parented, move the widget in the DOM.\n        if (this.parent) {\n            this.moveWidget(i, j, widget);\n        }\n    };\n    /**\n     * Remove a widget from the layout.\n     *\n     * @param widget - The widget to remove from the layout.\n     *\n     * #### Notes\n     * A widget is automatically removed from the layout when its `parent`\n     * is set to `null`. This method should only be invoked directly when\n     * removing a widget from a layout which has yet to be installed on a\n     * parent widget.\n     *\n     * This method does *not* modify the widget's `parent`.\n     */\n    PanelLayout.prototype.removeWidget = function (widget) {\n        this.removeWidgetAt(this._widgets.indexOf(widget));\n    };\n    /**\n     * Remove the widget at a given index from the layout.\n     *\n     * @param index - The index of the widget to remove.\n     *\n     * #### Notes\n     * A widget is automatically removed from the layout when its `parent`\n     * is set to `null`. This method should only be invoked directly when\n     * removing a widget from a layout which has yet to be installed on a\n     * parent widget.\n     *\n     * This method does *not* modify the widget's `parent`.\n     *\n     * #### Undefined Behavior\n     * An `index` which is non-integral.\n     */\n    PanelLayout.prototype.removeWidgetAt = function (index) {\n        // Remove the widget from the array.\n        var widget = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._widgets, index);\n        // If the layout is parented, detach the widget from the DOM.\n        if (widget && this.parent) {\n            this.detachWidget(index, widget);\n        }\n    };\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    PanelLayout.prototype.init = function () {\n        var _this = this;\n        _super.prototype.init.call(this);\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget, index) {\n            _this.attachWidget(index, widget);\n        });\n    };\n    /**\n     * Attach a widget to the parent's DOM node.\n     *\n     * @param index - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to attach to the parent.\n     *\n     * #### Notes\n     * This method is called automatically by the panel layout at the\n     * appropriate time. It should not be called directly by user code.\n     *\n     * The default implementation adds the widgets's node to the parent's\n     * node at the proper location, and sends the appropriate attach\n     * messages to the widget if the parent is attached to the DOM.\n     *\n     * Subclasses may reimplement this method to control how the widget's\n     * node is added to the parent's node.\n     */\n    PanelLayout.prototype.attachWidget = function (index, widget) {\n        // Look up the next sibling reference node.\n        var ref = this.parent.node.children[index];\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Insert the widget's node before the sibling.\n        this.parent.node.insertBefore(widget.node, ref);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n    };\n    /**\n     * Move a widget in the parent's DOM node.\n     *\n     * @param fromIndex - The previous index of the widget in the layout.\n     *\n     * @param toIndex - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to move in the parent.\n     *\n     * #### Notes\n     * This method is called automatically by the panel layout at the\n     * appropriate time. It should not be called directly by user code.\n     *\n     * The default implementation moves the widget's node to the proper\n     * location in the parent's node and sends the appropriate attach and\n     * detach messages to the widget if the parent is attached to the DOM.\n     *\n     * Subclasses may reimplement this method to control how the widget's\n     * node is moved in the parent's node.\n     */\n    PanelLayout.prototype.moveWidget = function (fromIndex, toIndex, widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` and  message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Look up the next sibling reference node.\n        var ref = this.parent.node.children[toIndex];\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Insert the widget's node before the sibling.\n        this.parent.node.insertBefore(widget.node, ref);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n    };\n    /**\n     * Detach a widget from the parent's DOM node.\n     *\n     * @param index - The previous index of the widget in the layout.\n     *\n     * @param widget - The widget to detach from the parent.\n     *\n     * #### Notes\n     * This method is called automatically by the panel layout at the\n     * appropriate time. It should not be called directly by user code.\n     *\n     * The default implementation removes the widget's node from the\n     * parent's node, and sends the appropriate detach messages to the\n     * widget if the parent is attached to the DOM.\n     *\n     * Subclasses may reimplement this method to control how the widget's\n     * node is removed from the parent's node.\n     */\n    PanelLayout.prototype.detachWidget = function (index, widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n    };\n    return PanelLayout;\n}(Layout));\n\n/**\n * A layout which arranges its widgets in a single row or column.\n */\nvar BoxLayout = /** @class */ (function (_super) {\n    __extends(BoxLayout, _super);\n    /**\n     * Construct a new box layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    function BoxLayout(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this) || this;\n        _this._fixed = 0;\n        _this._spacing = 4;\n        _this._dirty = false;\n        _this._sizers = [];\n        _this._items = [];\n        _this._box = null;\n        _this._alignment = 'start';\n        _this._direction = 'top-to-bottom';\n        if (options.direction !== undefined) {\n            _this._direction = options.direction;\n        }\n        if (options.alignment !== undefined) {\n            _this._alignment = options.alignment;\n        }\n        if (options.spacing !== undefined) {\n            _this._spacing = Private$2.clampSpacing(options.spacing);\n        }\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    BoxLayout.prototype.dispose = function () {\n        // Dispose of the layout items.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this._items, function (item) { item.dispose(); });\n        // Clear the layout state.\n        this._box = null;\n        this._items.length = 0;\n        this._sizers.length = 0;\n        // Dispose of the rest of the layout.\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(BoxLayout.prototype, \"direction\", {\n        /**\n         * Get the layout direction for the box layout.\n         */\n        get: function () {\n            return this._direction;\n        },\n        /**\n         * Set the layout direction for the box layout.\n         */\n        set: function (value) {\n            if (this._direction === value) {\n                return;\n            }\n            this._direction = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.dataset['direction'] = value;\n            this.parent.fit();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(BoxLayout.prototype, \"alignment\", {\n        /**\n         * Get the content alignment for the box layout.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand to fill the\n         * entire box layout.\n         */\n        get: function () {\n            return this._alignment;\n        },\n        /**\n         * Set the content alignment for the box layout.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand to fill the\n         * entire box layout.\n         */\n        set: function (value) {\n            if (this._alignment === value) {\n                return;\n            }\n            this._alignment = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.dataset['alignment'] = value;\n            this.parent.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(BoxLayout.prototype, \"spacing\", {\n        /**\n         * Get the inter-element spacing for the box layout.\n         */\n        get: function () {\n            return this._spacing;\n        },\n        /**\n         * Set the inter-element spacing for the box layout.\n         */\n        set: function (value) {\n            value = Private$2.clampSpacing(value);\n            if (this._spacing === value) {\n                return;\n            }\n            this._spacing = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.fit();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    BoxLayout.prototype.init = function () {\n        this.parent.dataset['direction'] = this.direction;\n        this.parent.dataset['alignment'] = this.alignment;\n        _super.prototype.init.call(this);\n    };\n    /**\n     * Attach a widget to the parent's DOM node.\n     *\n     * @param index - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to attach to the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    BoxLayout.prototype.attachWidget = function (index, widget) {\n        // Create and add a new layout item for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._items, index, new LayoutItem(widget));\n        // Create and add a new sizer for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._sizers, index, new BoxSizer());\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Add the widget's node to the parent.\n        this.parent.node.appendChild(widget.node);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Move a widget in the parent's DOM node.\n     *\n     * @param fromIndex - The previous index of the widget in the layout.\n     *\n     * @param toIndex - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to move in the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    BoxLayout.prototype.moveWidget = function (fromIndex, toIndex, widget) {\n        // Move the layout item for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._items, fromIndex, toIndex);\n        // Move the sizer for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._sizers, fromIndex, toIndex);\n        // Post an update request for the parent widget.\n        this.parent.update();\n    };\n    /**\n     * Detach a widget from the parent's DOM node.\n     *\n     * @param index - The previous index of the widget in the layout.\n     *\n     * @param widget - The widget to detach from the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    BoxLayout.prototype.detachWidget = function (index, widget) {\n        // Remove the layout item for the widget.\n        var item = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._items, index);\n        // Remove the sizer for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._sizers, index);\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Dispose of the layout item.\n        item.dispose();\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     */\n    BoxLayout.prototype.onBeforeShow = function (msg) {\n        _super.prototype.onBeforeShow.call(this, msg);\n        this.parent.update();\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    BoxLayout.prototype.onBeforeAttach = function (msg) {\n        _super.prototype.onBeforeAttach.call(this, msg);\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    BoxLayout.prototype.onChildShown = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    BoxLayout.prototype.onChildHidden = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    BoxLayout.prototype.onResize = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(msg.width, msg.height);\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    BoxLayout.prototype.onUpdateRequest = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(-1, -1);\n        }\n    };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     */\n    BoxLayout.prototype.onFitRequest = function (msg) {\n        if (this.parent.isAttached) {\n            this._fit();\n        }\n    };\n    /**\n     * Fit the layout to the total size required by the widgets.\n     */\n    BoxLayout.prototype._fit = function () {\n        // Compute the visible item count.\n        var nVisible = 0;\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            nVisible += +!this._items[i].isHidden;\n        }\n        // Update the fixed space for the visible items.\n        this._fixed = this._spacing * Math.max(0, nVisible - 1);\n        // Setup the computed minimum size.\n        var horz = Private$2.isHorizontal(this._direction);\n        var minW = horz ? this._fixed : 0;\n        var minH = horz ? 0 : this._fixed;\n        // Update the sizers and computed minimum size.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item and corresponding box sizer.\n            var item = this._items[i];\n            var sizer = this._sizers[i];\n            // If the item is hidden, it should consume zero size.\n            if (item.isHidden) {\n                sizer.minSize = 0;\n                sizer.maxSize = 0;\n                continue;\n            }\n            // Update the size limits for the item.\n            item.fit();\n            // Update the size basis and stretch factor.\n            sizer.sizeHint = BoxLayout.getSizeBasis(item.widget);\n            sizer.stretch = BoxLayout.getStretch(item.widget);\n            // Update the sizer limits and computed min size.\n            if (horz) {\n                sizer.minSize = item.minWidth;\n                sizer.maxSize = item.maxWidth;\n                minW += item.minWidth;\n                minH = Math.max(minH, item.minHeight);\n            }\n            else {\n                sizer.minSize = item.minHeight;\n                sizer.maxSize = item.maxHeight;\n                minH += item.minHeight;\n                minW = Math.max(minW, item.minWidth);\n            }\n        }\n        // Update the box sizing and add it to the computed min size.\n        var box = this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        var style = this.parent.node.style;\n        style.minWidth = minW + \"px\";\n        style.minHeight = minH + \"px\";\n        // Set the dirty flag to ensure only a single update occurs.\n        this._dirty = true;\n        // Notify the ancestor that it should fit immediately. This may\n        // cause a resize of the parent, fulfilling the required update.\n        if (this.parent.parent) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent.parent, Widget.Msg.FitRequest);\n        }\n        // If the dirty flag is still set, the parent was not resized.\n        // Trigger the required update on the parent widget immediately.\n        if (this._dirty) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n        }\n    };\n    /**\n     * Update the layout position and size of the widgets.\n     *\n     * The parent offset dimensions should be `-1` if unknown.\n     */\n    BoxLayout.prototype._update = function (offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Compute the visible item count.\n        var nVisible = 0;\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            nVisible += +!this._items[i].isHidden;\n        }\n        // Bail early if there are no visible items to layout.\n        if (nVisible === 0) {\n            return;\n        }\n        // Measure the parent if the offset dimensions are unknown.\n        if (offsetWidth < 0) {\n            offsetWidth = this.parent.node.offsetWidth;\n        }\n        if (offsetHeight < 0) {\n            offsetHeight = this.parent.node.offsetHeight;\n        }\n        // Ensure the parent box sizing data is computed.\n        if (!this._box) {\n            this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the layout area adjusted for border and padding.\n        var top = this._box.paddingTop;\n        var left = this._box.paddingLeft;\n        var width = offsetWidth - this._box.horizontalSum;\n        var height = offsetHeight - this._box.verticalSum;\n        // Distribute the layout space and adjust the start position.\n        var delta;\n        switch (this._direction) {\n            case 'left-to-right':\n                delta = BoxEngine.calc(this._sizers, Math.max(0, width - this._fixed));\n                break;\n            case 'top-to-bottom':\n                delta = BoxEngine.calc(this._sizers, Math.max(0, height - this._fixed));\n                break;\n            case 'right-to-left':\n                delta = BoxEngine.calc(this._sizers, Math.max(0, width - this._fixed));\n                left += width;\n                break;\n            case 'bottom-to-top':\n                delta = BoxEngine.calc(this._sizers, Math.max(0, height - this._fixed));\n                top += height;\n                break;\n            default:\n                throw 'unreachable';\n        }\n        // Setup the variables for justification and alignment offset.\n        var extra = 0;\n        var offset = 0;\n        // Account for alignment if there is extra layout space.\n        if (delta > 0) {\n            switch (this._alignment) {\n                case 'start':\n                    break;\n                case 'center':\n                    extra = 0;\n                    offset = delta / 2;\n                    break;\n                case 'end':\n                    extra = 0;\n                    offset = delta;\n                    break;\n                case 'justify':\n                    extra = delta / nVisible;\n                    offset = 0;\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n        }\n        // Layout the items using the computed box sizes.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Fetch the computed size for the widget.\n            var size = this._sizers[i].size;\n            // Update the widget geometry and advance the relevant edge.\n            switch (this._direction) {\n                case 'left-to-right':\n                    item.update(left + offset, top, size + extra, height);\n                    left += size + extra + this._spacing;\n                    break;\n                case 'top-to-bottom':\n                    item.update(left, top + offset, width, size + extra);\n                    top += size + extra + this._spacing;\n                    break;\n                case 'right-to-left':\n                    item.update(left - offset - size - extra, top, size + extra, height);\n                    left -= size + extra + this._spacing;\n                    break;\n                case 'bottom-to-top':\n                    item.update(left, top - offset - size - extra, width, size + extra);\n                    top -= size + extra + this._spacing;\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n        }\n    };\n    return BoxLayout;\n}(PanelLayout));\n/**\n * The namespace for the `BoxLayout` class statics.\n */\n(function (BoxLayout) {\n    /**\n     * Get the box layout stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The box layout stretch factor for the widget.\n     */\n    function getStretch(widget) {\n        return Private$2.stretchProperty.get(widget);\n    }\n    BoxLayout.getStretch = getStretch;\n    /**\n     * Set the box layout stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the stretch factor.\n     */\n    function setStretch(widget, value) {\n        Private$2.stretchProperty.set(widget, value);\n    }\n    BoxLayout.setStretch = setStretch;\n    /**\n     * Get the box layout size basis for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The box layout size basis for the widget.\n     */\n    function getSizeBasis(widget) {\n        return Private$2.sizeBasisProperty.get(widget);\n    }\n    BoxLayout.getSizeBasis = getSizeBasis;\n    /**\n     * Set the box layout size basis for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the size basis.\n     */\n    function setSizeBasis(widget, value) {\n        Private$2.sizeBasisProperty.set(widget, value);\n    }\n    BoxLayout.setSizeBasis = setSizeBasis;\n})(BoxLayout || (BoxLayout = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$2;\n(function (Private) {\n    /**\n     * The property descriptor for a widget stretch factor.\n     */\n    Private.stretchProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'stretch',\n        create: function () { return 0; },\n        coerce: function (owner, value) { return Math.max(0, Math.floor(value)); },\n        changed: onChildSizingChanged\n    });\n    /**\n     * The property descriptor for a widget size basis.\n     */\n    Private.sizeBasisProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'sizeBasis',\n        create: function () { return 0; },\n        coerce: function (owner, value) { return Math.max(0, Math.floor(value)); },\n        changed: onChildSizingChanged\n    });\n    /**\n     * Test whether a direction has horizontal orientation.\n     */\n    function isHorizontal(dir) {\n        return dir === 'left-to-right' || dir === 'right-to-left';\n    }\n    Private.isHorizontal = isHorizontal;\n    /**\n     * Clamp a spacing value to an integer >= 0.\n     */\n    function clampSpacing(value) {\n        return Math.max(0, Math.floor(value));\n    }\n    Private.clampSpacing = clampSpacing;\n    /**\n     * The change handler for the attached sizing properties.\n     */\n    function onChildSizingChanged(child) {\n        if (child.parent && child.parent.layout instanceof BoxLayout) {\n            child.parent.fit();\n        }\n    }\n})(Private$2 || (Private$2 = {}));\n\n/**\n * A simple and convenient panel widget class.\n *\n * #### Notes\n * This class is suitable as a base class for implementing a variety of\n * convenience panel widgets, but can also be used directly with CSS to\n * arrange a collection of widgets.\n *\n * This class provides a convenience wrapper around a [[PanelLayout]].\n */\nvar Panel = /** @class */ (function (_super) {\n    __extends(Panel, _super);\n    /**\n     * Construct a new panel.\n     *\n     * @param options - The options for initializing the panel.\n     */\n    function Panel(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this) || this;\n        _this.addClass('lm-Panel');\n        /* <DEPRECATED> */\n        _this.addClass('p-Panel');\n        /* </DEPRECATED> */\n        _this.layout = Private$3.createLayout(options);\n        return _this;\n    }\n    Object.defineProperty(Panel.prototype, \"widgets\", {\n        /**\n         * A read-only array of the widgets in the panel.\n         */\n        get: function () {\n            return this.layout.widgets;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Add a widget to the end of the panel.\n     *\n     * @param widget - The widget to add to the panel.\n     *\n     * #### Notes\n     * If the widget is already contained in the panel, it will be moved.\n     */\n    Panel.prototype.addWidget = function (widget) {\n        this.layout.addWidget(widget);\n    };\n    /**\n     * Insert a widget at the specified index.\n     *\n     * @param index - The index at which to insert the widget.\n     *\n     * @param widget - The widget to insert into to the panel.\n     *\n     * #### Notes\n     * If the widget is already contained in the panel, it will be moved.\n     */\n    Panel.prototype.insertWidget = function (index, widget) {\n        this.layout.insertWidget(index, widget);\n    };\n    return Panel;\n}(Widget));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$3;\n(function (Private) {\n    /**\n     * Create a panel layout for the given panel options.\n     */\n    function createLayout(options) {\n        return options.layout || new PanelLayout();\n    }\n    Private.createLayout = createLayout;\n})(Private$3 || (Private$3 = {}));\n\n/**\n * A panel which arranges its widgets in a single row or column.\n *\n * #### Notes\n * This class provides a convenience wrapper around a [[BoxLayout]].\n */\nvar BoxPanel = /** @class */ (function (_super) {\n    __extends(BoxPanel, _super);\n    /**\n     * Construct a new box panel.\n     *\n     * @param options - The options for initializing the box panel.\n     */\n    function BoxPanel(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, { layout: Private$4.createLayout(options) }) || this;\n        _this.addClass('lm-BoxPanel');\n        /* <DEPRECATED> */\n        _this.addClass('p-BoxPanel');\n        return _this;\n        /* </DEPRECATED> */\n    }\n    Object.defineProperty(BoxPanel.prototype, \"direction\", {\n        /**\n         * Get the layout direction for the box panel.\n         */\n        get: function () {\n            return this.layout.direction;\n        },\n        /**\n         * Set the layout direction for the box panel.\n         */\n        set: function (value) {\n            this.layout.direction = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(BoxPanel.prototype, \"alignment\", {\n        /**\n         * Get the content alignment for the box panel.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand to fill the\n         * entire box layout.\n         */\n        get: function () {\n            return this.layout.alignment;\n        },\n        /**\n         * Set the content alignment for the box panel.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand to fill the\n         * entire box layout.\n         */\n        set: function (value) {\n            this.layout.alignment = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(BoxPanel.prototype, \"spacing\", {\n        /**\n         * Get the inter-element spacing for the box panel.\n         */\n        get: function () {\n            return this.layout.spacing;\n        },\n        /**\n         * Set the inter-element spacing for the box panel.\n         */\n        set: function (value) {\n            this.layout.spacing = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    BoxPanel.prototype.onChildAdded = function (msg) {\n        msg.child.addClass('lm-BoxPanel-child');\n        /* <DEPRECATED> */\n        msg.child.addClass('p-BoxPanel-child');\n        /* </DEPRECATED> */\n    };\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    BoxPanel.prototype.onChildRemoved = function (msg) {\n        msg.child.removeClass('lm-BoxPanel-child');\n        /* <DEPRECATED> */\n        msg.child.removeClass('p-BoxPanel-child');\n        /* </DEPRECATED> */\n    };\n    return BoxPanel;\n}(Panel));\n/**\n * The namespace for the `BoxPanel` class statics.\n */\n(function (BoxPanel) {\n    /**\n     * Get the box panel stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The box panel stretch factor for the widget.\n     */\n    function getStretch(widget) {\n        return BoxLayout.getStretch(widget);\n    }\n    BoxPanel.getStretch = getStretch;\n    /**\n     * Set the box panel stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the stretch factor.\n     */\n    function setStretch(widget, value) {\n        BoxLayout.setStretch(widget, value);\n    }\n    BoxPanel.setStretch = setStretch;\n    /**\n     * Get the box panel size basis for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The box panel size basis for the widget.\n     */\n    function getSizeBasis(widget) {\n        return BoxLayout.getSizeBasis(widget);\n    }\n    BoxPanel.getSizeBasis = getSizeBasis;\n    /**\n     * Set the box panel size basis for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the size basis.\n     */\n    function setSizeBasis(widget, value) {\n        BoxLayout.setSizeBasis(widget, value);\n    }\n    BoxPanel.setSizeBasis = setSizeBasis;\n})(BoxPanel || (BoxPanel = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$4;\n(function (Private) {\n    /**\n     * Create a box layout for the given panel options.\n     */\n    function createLayout(options) {\n        return options.layout || new BoxLayout(options);\n    }\n    Private.createLayout = createLayout;\n})(Private$4 || (Private$4 = {}));\n\n/**\n * A widget which displays command items as a searchable palette.\n */\nvar CommandPalette = /** @class */ (function (_super) {\n    __extends(CommandPalette, _super);\n    /**\n     * Construct a new command palette.\n     *\n     * @param options - The options for initializing the palette.\n     */\n    function CommandPalette(options) {\n        var _this = _super.call(this, { node: Private$5.createNode() }) || this;\n        _this._activeIndex = -1;\n        _this._items = [];\n        _this._results = null;\n        _this.addClass('lm-CommandPalette');\n        /* <DEPRECATED> */\n        _this.addClass('p-CommandPalette');\n        /* </DEPRECATED> */\n        _this.setFlag(Widget.Flag.DisallowLayout);\n        _this.commands = options.commands;\n        _this.renderer = options.renderer || CommandPalette.defaultRenderer;\n        _this.commands.commandChanged.connect(_this._onGenericChange, _this);\n        _this.commands.keyBindingChanged.connect(_this._onGenericChange, _this);\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the widget.\n     */\n    CommandPalette.prototype.dispose = function () {\n        this._items.length = 0;\n        this._results = null;\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(CommandPalette.prototype, \"searchNode\", {\n        /**\n         * The command palette search node.\n         *\n         * #### Notes\n         * This is the node which contains the search-related elements.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-CommandPalette-search')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(CommandPalette.prototype, \"inputNode\", {\n        /**\n         * The command palette input node.\n         *\n         * #### Notes\n         * This is the actual input node for the search area.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-CommandPalette-input')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(CommandPalette.prototype, \"contentNode\", {\n        /**\n         * The command palette content node.\n         *\n         * #### Notes\n         * This is the node which holds the command item nodes.\n         *\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-CommandPalette-content')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(CommandPalette.prototype, \"items\", {\n        /**\n         * A read-only array of the command items in the palette.\n         */\n        get: function () {\n            return this._items;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Add a command item to the command palette.\n     *\n     * @param options - The options for creating the command item.\n     *\n     * @returns The command item added to the palette.\n     */\n    CommandPalette.prototype.addItem = function (options) {\n        // Create a new command item for the options.\n        var item = Private$5.createItem(this.commands, options);\n        // Add the item to the array.\n        this._items.push(item);\n        // Refresh the search results.\n        this.refresh();\n        // Return the item added to the palette.\n        return item;\n    };\n    /**\n     * Adds command items to the command palette.\n     *\n     * @param items - An array of options for creating each command item.\n     *\n     * @returns The command items added to the palette.\n     */\n    CommandPalette.prototype.addItems = function (items) {\n        var _this = this;\n        var newItems = items.map(function (item) { return Private$5.createItem(_this.commands, item); });\n        newItems.forEach(function (item) { return _this._items.push(item); });\n        this.refresh();\n        return newItems;\n    };\n    /**\n     * Remove an item from the command palette.\n     *\n     * @param item - The item to remove from the palette.\n     *\n     * #### Notes\n     * This is a no-op if the item is not in the palette.\n     */\n    CommandPalette.prototype.removeItem = function (item) {\n        this.removeItemAt(this._items.indexOf(item));\n    };\n    /**\n     * Remove the item at a given index from the command palette.\n     *\n     * @param index - The index of the item to remove.\n     *\n     * #### Notes\n     * This is a no-op if the index is out of range.\n     */\n    CommandPalette.prototype.removeItemAt = function (index) {\n        // Remove the item from the array.\n        var item = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._items, index);\n        // Bail if the index is out of range.\n        if (!item) {\n            return;\n        }\n        // Refresh the search results.\n        this.refresh();\n    };\n    /**\n     * Remove all items from the command palette.\n     */\n    CommandPalette.prototype.clearItems = function () {\n        // Bail if there is nothing to remove.\n        if (this._items.length === 0) {\n            return;\n        }\n        // Clear the array of items.\n        this._items.length = 0;\n        // Refresh the search results.\n        this.refresh();\n    };\n    /**\n     * Clear the search results and schedule an update.\n     *\n     * #### Notes\n     * This should be called whenever the search results of the palette\n     * should be updated.\n     *\n     * This is typically called automatically by the palette as needed,\n     * but can be called manually if the input text is programatically\n     * changed.\n     *\n     * The rendered results are updated asynchronously.\n     */\n    CommandPalette.prototype.refresh = function () {\n        this._results = null;\n        if (this.inputNode.value !== '') {\n            var clear = this.node.getElementsByClassName('lm-close-icon')[0];\n            clear.style.display = 'inherit';\n        }\n        else {\n            var clear = this.node.getElementsByClassName('lm-close-icon')[0];\n            clear.style.display = 'none';\n        }\n        this.update();\n    };\n    /**\n     * Handle the DOM events for the command palette.\n     *\n     * @param event - The DOM event sent to the command palette.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the command palette's DOM node.\n     * It should not be called directly by user code.\n     */\n    CommandPalette.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'click':\n                this._evtClick(event);\n                break;\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'input':\n                this.refresh();\n                break;\n            case 'focus':\n            case 'blur':\n                this._toggleFocused();\n                break;\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    CommandPalette.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('click', this);\n        this.node.addEventListener('keydown', this);\n        this.node.addEventListener('input', this);\n        this.node.addEventListener('focus', this, true);\n        this.node.addEventListener('blur', this, true);\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    CommandPalette.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('click', this);\n        this.node.removeEventListener('keydown', this);\n        this.node.removeEventListener('input', this);\n        this.node.removeEventListener('focus', this, true);\n        this.node.removeEventListener('blur', this, true);\n    };\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     */\n    CommandPalette.prototype.onActivateRequest = function (msg) {\n        if (this.isAttached) {\n            var input = this.inputNode;\n            input.focus();\n            input.select();\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    CommandPalette.prototype.onUpdateRequest = function (msg) {\n        // Fetch the current query text and content node.\n        var query = this.inputNode.value;\n        var contentNode = this.contentNode;\n        // Ensure the search results are generated.\n        var results = this._results;\n        if (!results) {\n            // Generate and store the new search results.\n            results = this._results = Private$5.search(this._items, query);\n            // Reset the active index.\n            this._activeIndex = (query ? _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(results, Private$5.canActivate) : -1);\n        }\n        // If there is no query and no results, clear the content.\n        if (!query && results.length === 0) {\n            _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.VirtualDOM.render(null, contentNode);\n            return;\n        }\n        // If the is a query but no results, render the empty message.\n        if (query && results.length === 0) {\n            var content_1 = this.renderer.renderEmptyMessage({ query: query });\n            _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.VirtualDOM.render(content_1, contentNode);\n            return;\n        }\n        // Create the render content for the search results.\n        var renderer = this.renderer;\n        var activeIndex = this._activeIndex;\n        var content = new Array(results.length);\n        for (var i = 0, n = results.length; i < n; ++i) {\n            var result = results[i];\n            if (result.type === 'header') {\n                var indices = result.indices;\n                var category = result.category;\n                content[i] = renderer.renderHeader({ category: category, indices: indices });\n            }\n            else {\n                var item = result.item;\n                var indices = result.indices;\n                var active = i === activeIndex;\n                content[i] = renderer.renderItem({ item: item, indices: indices, active: active });\n            }\n        }\n        // Render the search result content.\n        _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.VirtualDOM.render(content, contentNode);\n        // Adjust the scroll position as needed.\n        if (activeIndex < 0 || activeIndex >= results.length) {\n            contentNode.scrollTop = 0;\n        }\n        else {\n            var element = contentNode.children[activeIndex];\n            _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.scrollIntoViewIfNeeded(contentNode, element);\n        }\n    };\n    /**\n     * Handle the `'click'` event for the command palette.\n     */\n    CommandPalette.prototype._evtClick = function (event) {\n        // Bail if the click is not the left button.\n        if (event.button !== 0) {\n            return;\n        }\n        // Clear input if the target is clear button\n        if (event.target.classList.contains(\"lm-close-icon\")) {\n            this.inputNode.value = '';\n            this.refresh();\n            return;\n        }\n        // Find the index of the item which was clicked.\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this.contentNode.children, function (node) {\n            return node.contains(event.target);\n        });\n        // Bail if the click was not on an item.\n        if (index === -1) {\n            return;\n        }\n        // Kill the event when a content item is clicked.\n        event.preventDefault();\n        event.stopPropagation();\n        // Execute the item if possible.\n        this._execute(index);\n    };\n    /**\n     * Handle the `'keydown'` event for the command palette.\n     */\n    CommandPalette.prototype._evtKeyDown = function (event) {\n        if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {\n            return;\n        }\n        switch (event.keyCode) {\n            case 13: // Enter\n                event.preventDefault();\n                event.stopPropagation();\n                this._execute(this._activeIndex);\n                break;\n            case 38: // Up Arrow\n                event.preventDefault();\n                event.stopPropagation();\n                this._activatePreviousItem();\n                break;\n            case 40: // Down Arrow\n                event.preventDefault();\n                event.stopPropagation();\n                this._activateNextItem();\n                break;\n        }\n    };\n    /**\n     * Activate the next enabled command item.\n     */\n    CommandPalette.prototype._activateNextItem = function () {\n        // Bail if there are no search results.\n        if (!this._results || this._results.length === 0) {\n            return;\n        }\n        // Find the next enabled item index.\n        var ai = this._activeIndex;\n        var n = this._results.length;\n        var start = ai < n - 1 ? ai + 1 : 0;\n        var stop = start === 0 ? n - 1 : start - 1;\n        this._activeIndex = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this._results, Private$5.canActivate, start, stop);\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Activate the previous enabled command item.\n     */\n    CommandPalette.prototype._activatePreviousItem = function () {\n        // Bail if there are no search results.\n        if (!this._results || this._results.length === 0) {\n            return;\n        }\n        // Find the previous enabled item index.\n        var ai = this._activeIndex;\n        var n = this._results.length;\n        var start = ai <= 0 ? n - 1 : ai - 1;\n        var stop = start === n - 1 ? 0 : start + 1;\n        this._activeIndex = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findLastIndex(this._results, Private$5.canActivate, start, stop);\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Execute the command item at the given index, if possible.\n     */\n    CommandPalette.prototype._execute = function (index) {\n        // Bail if there are no search results.\n        if (!this._results) {\n            return;\n        }\n        // Bail if the index is out of range.\n        var part = this._results[index];\n        if (!part) {\n            return;\n        }\n        // Update the search text if the item is a header.\n        if (part.type === 'header') {\n            var input = this.inputNode;\n            input.value = part.category.toLowerCase() + \" \";\n            input.focus();\n            this.refresh();\n            return;\n        }\n        // Bail if item is not enabled.\n        if (!part.item.isEnabled) {\n            return;\n        }\n        // Execute the item.\n        this.commands.execute(part.item.command, part.item.args);\n        // Clear the query text.\n        this.inputNode.value = '';\n        // Refresh the search results.\n        this.refresh();\n    };\n    /**\n     * Toggle the focused modifier based on the input node focus state.\n     */\n    CommandPalette.prototype._toggleFocused = function () {\n        var focused = document.activeElement === this.inputNode;\n        this.toggleClass('lm-mod-focused', focused);\n        /* <DEPRECATED> */\n        this.toggleClass('p-mod-focused', focused);\n        /* </DEPRECATED> */\n    };\n    /**\n     * A signal handler for generic command changes.\n     */\n    CommandPalette.prototype._onGenericChange = function () {\n        this.refresh();\n    };\n    return CommandPalette;\n}(Widget));\n/**\n * The namespace for the `CommandPalette` class statics.\n */\n(function (CommandPalette) {\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    var Renderer = /** @class */ (function () {\n        function Renderer() {\n        }\n        /**\n         * Render the virtual element for a command palette header.\n         *\n         * @param data - The data to use for rendering the header.\n         *\n         * @returns A virtual element representing the header.\n         */\n        Renderer.prototype.renderHeader = function (data) {\n            var content = this.formatHeader(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li({ className: 'lm-CommandPalette-header'\n                    /* <DEPRECATED> */\n                    + ' p-CommandPalette-header'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Render the virtual element for a command palette item.\n         *\n         * @param data - The data to use for rendering the item.\n         *\n         * @returns A virtual element representing the item.\n         */\n        Renderer.prototype.renderItem = function (data) {\n            var className = this.createItemClass(data);\n            var dataset = this.createItemDataset(data);\n            if (data.item.isToggleable) {\n                return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li({\n                    className: className,\n                    dataset: dataset,\n                    role: 'checkbox',\n                    'aria-checked': \"\" + data.item.isToggled\n                }, this.renderItemIcon(data), this.renderItemContent(data), this.renderItemShortcut(data)));\n            }\n            return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li({\n                className: className,\n                dataset: dataset\n            }, this.renderItemIcon(data), this.renderItemContent(data), this.renderItemShortcut(data)));\n        };\n        /**\n         * Render the empty results message for a command palette.\n         *\n         * @param data - The data to use for rendering the message.\n         *\n         * @returns A virtual element representing the message.\n         */\n        Renderer.prototype.renderEmptyMessage = function (data) {\n            var content = this.formatEmptyMessage(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li({\n                className: 'lm-CommandPalette-emptyMessage'\n                    /* <DEPRECATED> */\n                    + ' p-CommandPalette-emptyMessage'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Render the icon for a command palette item.\n         *\n         * @param data - The data to use for rendering the icon.\n         *\n         * @returns A virtual element representing the icon.\n         */\n        Renderer.prototype.renderItemIcon = function (data) {\n            var className = this.createIconClass(data);\n            /* <DEPRECATED> */\n            if (typeof data.item.icon === 'string') {\n                return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, data.item.iconLabel);\n            }\n            /* </DEPRECATED> */\n            // if data.item.icon is undefined, it will be ignored\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, data.item.icon, data.item.iconLabel);\n        };\n        /**\n         * Render the content for a command palette item.\n         *\n         * @param data - The data to use for rendering the content.\n         *\n         * @returns A virtual element representing the content.\n         */\n        Renderer.prototype.renderItemContent = function (data) {\n            return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-CommandPalette-itemContent'\n                    /* <DEPRECATED> */\n                    + ' p-CommandPalette-itemContent'\n                /* </DEPRECATED> */\n            }, this.renderItemLabel(data), this.renderItemCaption(data)));\n        };\n        /**\n         * Render the label for a command palette item.\n         *\n         * @param data - The data to use for rendering the label.\n         *\n         * @returns A virtual element representing the label.\n         */\n        Renderer.prototype.renderItemLabel = function (data) {\n            var content = this.formatItemLabel(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-CommandPalette-itemLabel'\n                    /* <DEPRECATED> */\n                    + ' p-CommandPalette-itemLabel'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Render the caption for a command palette item.\n         *\n         * @param data - The data to use for rendering the caption.\n         *\n         * @returns A virtual element representing the caption.\n         */\n        Renderer.prototype.renderItemCaption = function (data) {\n            var content = this.formatItemCaption(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-CommandPalette-itemCaption'\n                    /* <DEPRECATED> */\n                    + ' p-CommandPalette-itemCaption'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Render the shortcut for a command palette item.\n         *\n         * @param data - The data to use for rendering the shortcut.\n         *\n         * @returns A virtual element representing the shortcut.\n         */\n        Renderer.prototype.renderItemShortcut = function (data) {\n            var content = this.formatItemShortcut(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-CommandPalette-itemShortcut'\n                    /* <DEPRECATED> */\n                    + ' p-CommandPalette-itemShortcut'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Create the class name for the command palette item.\n         *\n         * @param data - The data to use for the class name.\n         *\n         * @returns The full class name for the command palette item.\n         */\n        Renderer.prototype.createItemClass = function (data) {\n            // Set up the initial class name.\n            var name = 'lm-CommandPalette-item';\n            /* <DEPRECATED> */\n            name += ' p-CommandPalette-item';\n            /* </DEPRECATED> */\n            // Add the boolean state classes.\n            if (!data.item.isEnabled) {\n                name += ' lm-mod-disabled';\n                /* <DEPRECATED> */\n                name += ' p-mod-disabled';\n                /* </DEPRECATED> */\n            }\n            if (data.item.isToggled) {\n                name += ' lm-mod-toggled';\n                /* <DEPRECATED> */\n                name += ' p-mod-toggled';\n                /* </DEPRECATED> */\n            }\n            if (data.active) {\n                name += ' lm-mod-active';\n                /* <DEPRECATED> */\n                name += ' p-mod-active';\n                /* </DEPRECATED> */\n            }\n            // Add the extra class.\n            var extra = data.item.className;\n            if (extra) {\n                name += \" \" + extra;\n            }\n            // Return the complete class name.\n            return name;\n        };\n        /**\n         * Create the dataset for the command palette item.\n         *\n         * @param data - The data to use for creating the dataset.\n         *\n         * @returns The dataset for the command palette item.\n         */\n        Renderer.prototype.createItemDataset = function (data) {\n            return __assign(__assign({}, data.item.dataset), { command: data.item.command });\n        };\n        /**\n         * Create the class name for the command item icon.\n         *\n         * @param data - The data to use for the class name.\n         *\n         * @returns The full class name for the item icon.\n         */\n        Renderer.prototype.createIconClass = function (data) {\n            var name = 'lm-CommandPalette-itemIcon';\n            /* <DEPRECATED> */\n            name += ' p-CommandPalette-itemIcon';\n            /* </DEPRECATED> */\n            var extra = data.item.iconClass;\n            return extra ? name + \" \" + extra : name;\n        };\n        /**\n         * Create the render content for the header node.\n         *\n         * @param data - The data to use for the header content.\n         *\n         * @returns The content to add to the header node.\n         */\n        Renderer.prototype.formatHeader = function (data) {\n            if (!data.indices || data.indices.length === 0) {\n                return data.category;\n            }\n            return _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.StringExt.highlight(data.category, data.indices, _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.mark);\n        };\n        /**\n         * Create the render content for the empty message node.\n         *\n         * @param data - The data to use for the empty message content.\n         *\n         * @returns The content to add to the empty message node.\n         */\n        Renderer.prototype.formatEmptyMessage = function (data) {\n            return \"No commands found that match '\" + data.query + \"'\";\n        };\n        /**\n         * Create the render content for the item shortcut node.\n         *\n         * @param data - The data to use for the shortcut content.\n         *\n         * @returns The content to add to the shortcut node.\n         */\n        Renderer.prototype.formatItemShortcut = function (data) {\n            var kb = data.item.keyBinding;\n            return kb ? kb.keys.map(_lumino_commands__WEBPACK_IMPORTED_MODULE_6__.CommandRegistry.formatKeystroke).join(', ') : null;\n        };\n        /**\n         * Create the render content for the item label node.\n         *\n         * @param data - The data to use for the label content.\n         *\n         * @returns The content to add to the label node.\n         */\n        Renderer.prototype.formatItemLabel = function (data) {\n            if (!data.indices || data.indices.length === 0) {\n                return data.item.label;\n            }\n            return _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.StringExt.highlight(data.item.label, data.indices, _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.mark);\n        };\n        /**\n         * Create the render content for the item caption node.\n         *\n         * @param data - The data to use for the caption content.\n         *\n         * @returns The content to add to the caption node.\n         */\n        Renderer.prototype.formatItemCaption = function (data) {\n            return data.item.caption;\n        };\n        return Renderer;\n    }());\n    CommandPalette.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    CommandPalette.defaultRenderer = new Renderer();\n})(CommandPalette || (CommandPalette = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$5;\n(function (Private) {\n    /**\n     * Create the DOM node for a command palette.\n     */\n    function createNode() {\n        var node = document.createElement('div');\n        var search = document.createElement('div');\n        var wrapper = document.createElement('div');\n        var input = document.createElement('input');\n        var content = document.createElement('ul');\n        var clear = document.createElement('button');\n        search.className = 'lm-CommandPalette-search';\n        wrapper.className = 'lm-CommandPalette-wrapper';\n        input.className = 'lm-CommandPalette-input';\n        clear.className = 'lm-close-icon';\n        content.className = 'lm-CommandPalette-content';\n        /* <DEPRECATED> */\n        search.classList.add('p-CommandPalette-search');\n        wrapper.classList.add('p-CommandPalette-wrapper');\n        input.classList.add('p-CommandPalette-input');\n        content.classList.add('p-CommandPalette-content');\n        /* </DEPRECATED> */\n        input.spellcheck = false;\n        wrapper.appendChild(input);\n        wrapper.appendChild(clear);\n        search.appendChild(wrapper);\n        node.appendChild(search);\n        node.appendChild(content);\n        return node;\n    }\n    Private.createNode = createNode;\n    /**\n     * Create a new command item from a command registry and options.\n     */\n    function createItem(commands, options) {\n        return new CommandItem(commands, options);\n    }\n    Private.createItem = createItem;\n    /**\n     * Search an array of command items for fuzzy matches.\n     */\n    function search(items, query) {\n        // Fuzzy match the items for the query.\n        var scores = matchItems(items, query);\n        // Sort the items based on their score.\n        scores.sort(scoreCmp);\n        // Create the results for the search.\n        return createResults(scores);\n    }\n    Private.search = search;\n    /**\n     * Test whether a result item can be activated.\n     */\n    function canActivate(result) {\n        return result.type === 'item' && result.item.isEnabled;\n    }\n    Private.canActivate = canActivate;\n    /**\n     * Normalize a category for a command item.\n     */\n    function normalizeCategory(category) {\n        return category.trim().replace(/\\s+/g, ' ');\n    }\n    /**\n     * Normalize the query text for a fuzzy search.\n     */\n    function normalizeQuery(text) {\n        return text.replace(/\\s+/g, '').toLowerCase();\n    }\n    /**\n     * Perform a fuzzy match on an array of command items.\n     */\n    function matchItems(items, query) {\n        // Normalize the query text to lower case with no whitespace.\n        query = normalizeQuery(query);\n        // Create the array to hold the scores.\n        var scores = [];\n        // Iterate over the items and match against the query.\n        for (var i = 0, n = items.length; i < n; ++i) {\n            // Ignore items which are not visible.\n            var item = items[i];\n            if (!item.isVisible) {\n                continue;\n            }\n            // If the query is empty, all items are matched by default.\n            if (!query) {\n                scores.push({\n                    matchType: 3 /* Default */,\n                    categoryIndices: null,\n                    labelIndices: null,\n                    score: 0, item: item\n                });\n                continue;\n            }\n            // Run the fuzzy search for the item and query.\n            var score = fuzzySearch(item, query);\n            // Ignore the item if it is not a match.\n            if (!score) {\n                continue;\n            }\n            // Penalize disabled items.\n            // TODO - push disabled items all the way down in sort cmp?\n            if (!item.isEnabled) {\n                score.score += 1000;\n            }\n            // Add the score to the results.\n            scores.push(score);\n        }\n        // Return the final array of scores.\n        return scores;\n    }\n    /**\n     * Perform a fuzzy search on a single command item.\n     */\n    function fuzzySearch(item, query) {\n        // Create the source text to be searched.\n        var category = item.category.toLowerCase();\n        var label = item.label.toLowerCase();\n        var source = category + \" \" + label;\n        // Set up the match score and indices array.\n        var score = Infinity;\n        var indices = null;\n        // The regex for search word boundaries\n        var rgx = /\\b\\w/g;\n        // Search the source by word boundary.\n        while (true) {\n            // Find the next word boundary in the source.\n            var rgxMatch = rgx.exec(source);\n            // Break if there is no more source context.\n            if (!rgxMatch) {\n                break;\n            }\n            // Run the string match on the relevant substring.\n            var match = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.StringExt.matchSumOfDeltas(source, query, rgxMatch.index);\n            // Break if there is no match.\n            if (!match) {\n                break;\n            }\n            // Update the match if the score is better.\n            if (match && match.score <= score) {\n                score = match.score;\n                indices = match.indices;\n            }\n        }\n        // Bail if there was no match.\n        if (!indices || score === Infinity) {\n            return null;\n        }\n        // Compute the pivot index between category and label text.\n        var pivot = category.length + 1;\n        // Find the slice index to separate matched indices.\n        var j = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.lowerBound(indices, pivot, function (a, b) { return a - b; });\n        // Extract the matched category and label indices.\n        var categoryIndices = indices.slice(0, j);\n        var labelIndices = indices.slice(j);\n        // Adjust the label indices for the pivot offset.\n        for (var i = 0, n = labelIndices.length; i < n; ++i) {\n            labelIndices[i] -= pivot;\n        }\n        // Handle a pure label match.\n        if (categoryIndices.length === 0) {\n            return {\n                matchType: 0 /* Label */,\n                categoryIndices: null,\n                labelIndices: labelIndices,\n                score: score, item: item\n            };\n        }\n        // Handle a pure category match.\n        if (labelIndices.length === 0) {\n            return {\n                matchType: 1 /* Category */,\n                categoryIndices: categoryIndices,\n                labelIndices: null,\n                score: score, item: item\n            };\n        }\n        // Handle a split match.\n        return {\n            matchType: 2 /* Split */,\n            categoryIndices: categoryIndices,\n            labelIndices: labelIndices,\n            score: score, item: item\n        };\n    }\n    /**\n     * A sort comparison function for a match score.\n     */\n    function scoreCmp(a, b) {\n        // First compare based on the match type\n        var m1 = a.matchType - b.matchType;\n        if (m1 !== 0) {\n            return m1;\n        }\n        // Otherwise, compare based on the match score.\n        var d1 = a.score - b.score;\n        if (d1 !== 0) {\n            return d1;\n        }\n        // Find the match index based on the match type.\n        var i1 = 0;\n        var i2 = 0;\n        switch (a.matchType) {\n            case 0 /* Label */:\n                i1 = a.labelIndices[0];\n                i2 = b.labelIndices[0];\n                break;\n            case 1 /* Category */:\n            case 2 /* Split */:\n                i1 = a.categoryIndices[0];\n                i2 = b.categoryIndices[0];\n                break;\n        }\n        // Compare based on the match index.\n        if (i1 !== i2) {\n            return i1 - i2;\n        }\n        // Otherwise, compare by category.\n        var d2 = a.item.category.localeCompare(b.item.category);\n        if (d2 !== 0) {\n            return d2;\n        }\n        // Otherwise, compare by rank.\n        var r1 = a.item.rank;\n        var r2 = b.item.rank;\n        if (r1 !== r2) {\n            return r1 < r2 ? -1 : 1; // Infinity safe\n        }\n        // Finally, compare by label.\n        return a.item.label.localeCompare(b.item.label);\n    }\n    /**\n     * Create the results from an array of sorted scores.\n     */\n    function createResults(scores) {\n        // Set up an array to track which scores have been visited.\n        var visited = new Array(scores.length);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.fill(visited, false);\n        // Set up the search results array.\n        var results = [];\n        // Iterate over each score in the array.\n        for (var i = 0, n = scores.length; i < n; ++i) {\n            // Ignore a score which has already been processed.\n            if (visited[i]) {\n                continue;\n            }\n            // Extract the current item and indices.\n            var _a = scores[i], item = _a.item, categoryIndices = _a.categoryIndices;\n            // Extract the category for the current item.\n            var category = item.category;\n            // Add the header result for the category.\n            results.push({ type: 'header', category: category, indices: categoryIndices });\n            // Find the rest of the scores with the same category.\n            for (var j = i; j < n; ++j) {\n                // Ignore a score which has already been processed.\n                if (visited[j]) {\n                    continue;\n                }\n                // Extract the data for the current score.\n                var _b = scores[j], item_1 = _b.item, labelIndices = _b.labelIndices;\n                // Ignore an item with a different category.\n                if (item_1.category !== category) {\n                    continue;\n                }\n                // Create the item result for the score.\n                results.push({ type: 'item', item: item_1, indices: labelIndices });\n                // Mark the score as processed.\n                visited[j] = true;\n            }\n        }\n        // Return the final results.\n        return results;\n    }\n    /**\n     * A concrete implementation of `CommandPalette.IItem`.\n     */\n    var CommandItem = /** @class */ (function () {\n        /**\n         * Construct a new command item.\n         */\n        function CommandItem(commands, options) {\n            this._commands = commands;\n            this.category = normalizeCategory(options.category);\n            this.command = options.command;\n            this.args = options.args || _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__.JSONExt.emptyObject;\n            this.rank = options.rank !== undefined ? options.rank : Infinity;\n        }\n        Object.defineProperty(CommandItem.prototype, \"label\", {\n            /**\n             * The display label for the command item.\n             */\n            get: function () {\n                return this._commands.label(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"icon\", {\n            /**\n             * The icon renderer for the command item.\n             */\n            get: function () {\n                return this._commands.icon(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"iconClass\", {\n            /**\n             * The icon class for the command item.\n             */\n            get: function () {\n                return this._commands.iconClass(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"iconLabel\", {\n            /**\n             * The icon label for the command item.\n             */\n            get: function () {\n                return this._commands.iconLabel(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"caption\", {\n            /**\n             * The display caption for the command item.\n             */\n            get: function () {\n                return this._commands.caption(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"className\", {\n            /**\n             * The extra class name for the command item.\n             */\n            get: function () {\n                return this._commands.className(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"dataset\", {\n            /**\n             * The dataset for the command item.\n             */\n            get: function () {\n                return this._commands.dataset(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"isEnabled\", {\n            /**\n             * Whether the command item is enabled.\n             */\n            get: function () {\n                return this._commands.isEnabled(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"isToggled\", {\n            /**\n             * Whether the command item is toggled.\n             */\n            get: function () {\n                return this._commands.isToggled(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"isToggleable\", {\n            /**\n             * Whether the command item is toggleable.\n             */\n            get: function () {\n                return this._commands.isToggleable(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"isVisible\", {\n            /**\n             * Whether the command item is visible.\n             */\n            get: function () {\n                return this._commands.isVisible(this.command, this.args);\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(CommandItem.prototype, \"keyBinding\", {\n            /**\n             * The key binding for the command item.\n             */\n            get: function () {\n                var _a = this, command = _a.command, args = _a.args;\n                return _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findLastValue(this._commands.keyBindings, function (kb) {\n                    return kb.command === command && _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__.JSONExt.deepEqual(kb.args, args);\n                }) || null;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        return CommandItem;\n    }());\n})(Private$5 || (Private$5 = {}));\n\n/**\n * A widget which displays items as a canonical menu.\n */\nvar Menu = /** @class */ (function (_super) {\n    __extends(Menu, _super);\n    /**\n     * Construct a new menu.\n     *\n     * @param options - The options for initializing the menu.\n     */\n    function Menu(options) {\n        var _this = _super.call(this, { node: Private$6.createNode() }) || this;\n        _this._childIndex = -1;\n        _this._activeIndex = -1;\n        _this._openTimerID = 0;\n        _this._closeTimerID = 0;\n        _this._items = [];\n        _this._childMenu = null;\n        _this._parentMenu = null;\n        _this._aboutToClose = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._menuRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this.addClass('lm-Menu');\n        /* <DEPRECATED> */\n        _this.addClass('p-Menu');\n        /* </DEPRECATED> */\n        _this.setFlag(Widget.Flag.DisallowLayout);\n        _this.commands = options.commands;\n        _this.renderer = options.renderer || Menu.defaultRenderer;\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the menu.\n     */\n    Menu.prototype.dispose = function () {\n        this.close();\n        this._items.length = 0;\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(Menu.prototype, \"aboutToClose\", {\n        /**\n         * A signal emitted just before the menu is closed.\n         *\n         * #### Notes\n         * This signal is emitted when the menu receives a `'close-request'`\n         * message, just before it removes itself from the DOM.\n         *\n         * This signal is not emitted if the menu is already detached from\n         * the DOM when it receives the `'close-request'` message.\n         */\n        get: function () {\n            return this._aboutToClose;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"menuRequested\", {\n        /**\n         * A signal emitted when a new menu is requested by the user.\n         *\n         * #### Notes\n         * This signal is emitted whenever the user presses the right or left\n         * arrow keys, and a submenu cannot be opened or closed in response.\n         *\n         * This signal is useful when implementing menu bars in order to open\n         * the next or previous menu in response to a user key press.\n         *\n         * This signal is only emitted for the root menu in a hierarchy.\n         */\n        get: function () {\n            return this._menuRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"parentMenu\", {\n        /**\n         * The parent menu of the menu.\n         *\n         * #### Notes\n         * This is `null` unless the menu is an open submenu.\n         */\n        get: function () {\n            return this._parentMenu;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"childMenu\", {\n        /**\n         * The child menu of the menu.\n         *\n         * #### Notes\n         * This is `null` unless the menu has an open submenu.\n         */\n        get: function () {\n            return this._childMenu;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"rootMenu\", {\n        /**\n         * The root menu of the menu hierarchy.\n         */\n        get: function () {\n            var menu = this;\n            while (menu._parentMenu) {\n                menu = menu._parentMenu;\n            }\n            return menu;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"leafMenu\", {\n        /**\n         * The leaf menu of the menu hierarchy.\n         */\n        get: function () {\n            var menu = this;\n            while (menu._childMenu) {\n                menu = menu._childMenu;\n            }\n            return menu;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"contentNode\", {\n        /**\n         * The menu content node.\n         *\n         * #### Notes\n         * This is the node which holds the menu item nodes.\n         *\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-Menu-content')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"activeItem\", {\n        /**\n         * Get the currently active menu item.\n         */\n        get: function () {\n            return this._items[this._activeIndex] || null;\n        },\n        /**\n         * Set the currently active menu item.\n         *\n         * #### Notes\n         * If the item cannot be activated, the item will be set to `null`.\n         */\n        set: function (value) {\n            this.activeIndex = value ? this._items.indexOf(value) : -1;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"activeIndex\", {\n        /**\n         * Get the index of the currently active menu item.\n         *\n         * #### Notes\n         * This will be `-1` if no menu item is active.\n         */\n        get: function () {\n            return this._activeIndex;\n        },\n        /**\n         * Set the index of the currently active menu item.\n         *\n         * #### Notes\n         * If the item cannot be activated, the index will be set to `-1`.\n         */\n        set: function (value) {\n            // Adjust the value for an out of range index.\n            if (value < 0 || value >= this._items.length) {\n                value = -1;\n            }\n            // Ensure the item can be activated.\n            if (value !== -1 && !Private$6.canActivate(this._items[value])) {\n                value = -1;\n            }\n            // Bail if the index will not change.\n            if (this._activeIndex === value) {\n                return;\n            }\n            // Update the active index.\n            this._activeIndex = value;\n            // schedule an update of the items.\n            this.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Menu.prototype, \"items\", {\n        /**\n         * A read-only array of the menu items in the menu.\n         */\n        get: function () {\n            return this._items;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Activate the next selectable item in the menu.\n     *\n     * #### Notes\n     * If no item is selectable, the index will be set to `-1`.\n     */\n    Menu.prototype.activateNextItem = function () {\n        var n = this._items.length;\n        var ai = this._activeIndex;\n        var start = ai < n - 1 ? ai + 1 : 0;\n        var stop = start === 0 ? n - 1 : start - 1;\n        this.activeIndex = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this._items, Private$6.canActivate, start, stop);\n    };\n    /**\n     * Activate the previous selectable item in the menu.\n     *\n     * #### Notes\n     * If no item is selectable, the index will be set to `-1`.\n     */\n    Menu.prototype.activatePreviousItem = function () {\n        var n = this._items.length;\n        var ai = this._activeIndex;\n        var start = ai <= 0 ? n - 1 : ai - 1;\n        var stop = start === n - 1 ? 0 : start + 1;\n        this.activeIndex = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findLastIndex(this._items, Private$6.canActivate, start, stop);\n    };\n    /**\n     * Trigger the active menu item.\n     *\n     * #### Notes\n     * If the active item is a submenu, it will be opened and the first\n     * item will be activated.\n     *\n     * If the active item is a command, the command will be executed.\n     *\n     * If the menu is not attached, this is a no-op.\n     *\n     * If there is no active item, this is a no-op.\n     */\n    Menu.prototype.triggerActiveItem = function () {\n        // Bail if the menu is not attached.\n        if (!this.isAttached) {\n            return;\n        }\n        // Bail if there is no active item.\n        var item = this.activeItem;\n        if (!item) {\n            return;\n        }\n        // Cancel the pending timers.\n        this._cancelOpenTimer();\n        this._cancelCloseTimer();\n        // If the item is a submenu, open it.\n        if (item.type === 'submenu') {\n            this._openChildMenu(true);\n            return;\n        }\n        // Close the root menu before executing the command.\n        this.rootMenu.close();\n        // Execute the command for the item.\n        var command = item.command, args = item.args;\n        if (this.commands.isEnabled(command, args)) {\n            this.commands.execute(command, args);\n        }\n        else {\n            console.log(\"Command '\" + command + \"' is disabled.\");\n        }\n    };\n    /**\n     * Add a menu item to the end of the menu.\n     *\n     * @param options - The options for creating the menu item.\n     *\n     * @returns The menu item added to the menu.\n     */\n    Menu.prototype.addItem = function (options) {\n        return this.insertItem(this._items.length, options);\n    };\n    /**\n     * Insert a menu item into the menu at the specified index.\n     *\n     * @param index - The index at which to insert the item.\n     *\n     * @param options - The options for creating the menu item.\n     *\n     * @returns The menu item added to the menu.\n     *\n     * #### Notes\n     * The index will be clamped to the bounds of the items.\n     */\n    Menu.prototype.insertItem = function (index, options) {\n        // Close the menu if it's attached.\n        if (this.isAttached) {\n            this.close();\n        }\n        // Reset the active index.\n        this.activeIndex = -1;\n        // Clamp the insert index to the array bounds.\n        var i = Math.max(0, Math.min(index, this._items.length));\n        // Create the item for the options.\n        var item = Private$6.createItem(this, options);\n        // Insert the item into the array.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._items, i, item);\n        // Schedule an update of the items.\n        this.update();\n        // Return the item added to the menu.\n        return item;\n    };\n    /**\n     * Remove an item from the menu.\n     *\n     * @param item - The item to remove from the menu.\n     *\n     * #### Notes\n     * This is a no-op if the item is not in the menu.\n     */\n    Menu.prototype.removeItem = function (item) {\n        this.removeItemAt(this._items.indexOf(item));\n    };\n    /**\n     * Remove the item at a given index from the menu.\n     *\n     * @param index - The index of the item to remove.\n     *\n     * #### Notes\n     * This is a no-op if the index is out of range.\n     */\n    Menu.prototype.removeItemAt = function (index) {\n        // Close the menu if it's attached.\n        if (this.isAttached) {\n            this.close();\n        }\n        // Reset the active index.\n        this.activeIndex = -1;\n        // Remove the item from the array.\n        var item = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._items, index);\n        // Bail if the index is out of range.\n        if (!item) {\n            return;\n        }\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Remove all menu items from the menu.\n     */\n    Menu.prototype.clearItems = function () {\n        // Close the menu if it's attached.\n        if (this.isAttached) {\n            this.close();\n        }\n        // Reset the active index.\n        this.activeIndex = -1;\n        // Bail if there is nothing to remove.\n        if (this._items.length === 0) {\n            return;\n        }\n        // Clear the items.\n        this._items.length = 0;\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Open the menu at the specified location.\n     *\n     * @param x - The client X coordinate of the menu location.\n     *\n     * @param y - The client Y coordinate of the menu location.\n     *\n     * @param options - The additional options for opening the menu.\n     *\n     * #### Notes\n     * The menu will be opened at the given location unless it will not\n     * fully fit on the screen. If it will not fit, it will be adjusted\n     * to fit naturally on the screen.\n     *\n     * This is a no-op if the menu is already attached to the DOM.\n     */\n    Menu.prototype.open = function (x, y, options) {\n        if (options === void 0) { options = {}; }\n        // Bail early if the menu is already attached.\n        if (this.isAttached) {\n            return;\n        }\n        // Extract the position options.\n        var forceX = options.forceX || false;\n        var forceY = options.forceY || false;\n        // Open the menu as a root menu.\n        Private$6.openRootMenu(this, x, y, forceX, forceY);\n        // Activate the menu to accept keyboard input.\n        this.activate();\n    };\n    /**\n     * Handle the DOM events for the menu.\n     *\n     * @param event - The DOM event sent to the menu.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the menu's DOM nodes. It should\n     * not be called directly by user code.\n     */\n    Menu.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'mouseup':\n                this._evtMouseUp(event);\n                break;\n            case 'mousemove':\n                this._evtMouseMove(event);\n                break;\n            case 'mouseenter':\n                this._evtMouseEnter(event);\n                break;\n            case 'mouseleave':\n                this._evtMouseLeave(event);\n                break;\n            case 'mousedown':\n                this._evtMouseDown(event);\n                break;\n            case 'contextmenu':\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    Menu.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('keydown', this);\n        this.node.addEventListener('mouseup', this);\n        this.node.addEventListener('mousemove', this);\n        this.node.addEventListener('mouseenter', this);\n        this.node.addEventListener('mouseleave', this);\n        this.node.addEventListener('contextmenu', this);\n        document.addEventListener('mousedown', this, true);\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    Menu.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('keydown', this);\n        this.node.removeEventListener('mouseup', this);\n        this.node.removeEventListener('mousemove', this);\n        this.node.removeEventListener('mouseenter', this);\n        this.node.removeEventListener('mouseleave', this);\n        this.node.removeEventListener('contextmenu', this);\n        document.removeEventListener('mousedown', this, true);\n    };\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     */\n    Menu.prototype.onActivateRequest = function (msg) {\n        if (this.isAttached) {\n            this.node.focus();\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    Menu.prototype.onUpdateRequest = function (msg) {\n        var items = this._items;\n        var renderer = this.renderer;\n        var activeIndex = this._activeIndex;\n        var collapsedFlags = Private$6.computeCollapsed(items);\n        var content = new Array(items.length);\n        for (var i = 0, n = items.length; i < n; ++i) {\n            var item = items[i];\n            var active = i === activeIndex;\n            var collapsed = collapsedFlags[i];\n            content[i] = renderer.renderItem({ item: item, active: active, collapsed: collapsed });\n        }\n        _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.VirtualDOM.render(content, this.contentNode);\n    };\n    /**\n     * A message handler invoked on a `'close-request'` message.\n     */\n    Menu.prototype.onCloseRequest = function (msg) {\n        // Cancel the pending timers.\n        this._cancelOpenTimer();\n        this._cancelCloseTimer();\n        // Reset the active index.\n        this.activeIndex = -1;\n        // Close any open child menu.\n        var childMenu = this._childMenu;\n        if (childMenu) {\n            this._childIndex = -1;\n            this._childMenu = null;\n            childMenu._parentMenu = null;\n            childMenu.close();\n        }\n        // Remove this menu from its parent and activate the parent.\n        var parentMenu = this._parentMenu;\n        if (parentMenu) {\n            this._parentMenu = null;\n            parentMenu._childIndex = -1;\n            parentMenu._childMenu = null;\n            parentMenu.activate();\n        }\n        // Emit the `aboutToClose` signal if the menu is attached.\n        if (this.isAttached) {\n            this._aboutToClose.emit(undefined);\n        }\n        // Finish closing the menu.\n        _super.prototype.onCloseRequest.call(this, msg);\n    };\n    /**\n     * Handle the `'keydown'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    Menu.prototype._evtKeyDown = function (event) {\n        // A menu handles all keydown events.\n        event.preventDefault();\n        event.stopPropagation();\n        // Fetch the key code for the event.\n        var kc = event.keyCode;\n        // Enter\n        if (kc === 13) {\n            this.triggerActiveItem();\n            return;\n        }\n        // Escape\n        if (kc === 27) {\n            this.close();\n            return;\n        }\n        // Left Arrow\n        if (kc === 37) {\n            if (this._parentMenu) {\n                this.close();\n            }\n            else {\n                this._menuRequested.emit('previous');\n            }\n            return;\n        }\n        // Up Arrow\n        if (kc === 38) {\n            this.activatePreviousItem();\n            return;\n        }\n        // Right Arrow\n        if (kc === 39) {\n            var item = this.activeItem;\n            if (item && item.type === 'submenu') {\n                this.triggerActiveItem();\n            }\n            else {\n                this.rootMenu._menuRequested.emit('next');\n            }\n            return;\n        }\n        // Down Arrow\n        if (kc === 40) {\n            this.activateNextItem();\n            return;\n        }\n        // Get the pressed key character.\n        var key = (0,_lumino_keyboard__WEBPACK_IMPORTED_MODULE_9__.getKeyboardLayout)().keyForKeydownEvent(event);\n        // Bail if the key is not valid.\n        if (!key) {\n            return;\n        }\n        // Search for the next best matching mnemonic item.\n        var start = this._activeIndex + 1;\n        var result = Private$6.findMnemonic(this._items, key, start);\n        // Handle the requested mnemonic based on the search results.\n        // If exactly one mnemonic is matched, that item is triggered.\n        // Otherwise, the next mnemonic is activated if available,\n        // followed by the auto mnemonic if available.\n        if (result.index !== -1 && !result.multiple) {\n            this.activeIndex = result.index;\n            this.triggerActiveItem();\n        }\n        else if (result.index !== -1) {\n            this.activeIndex = result.index;\n        }\n        else if (result.auto !== -1) {\n            this.activeIndex = result.auto;\n        }\n    };\n    /**\n     * Handle the `'mouseup'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    Menu.prototype._evtMouseUp = function (event) {\n        if (event.button !== 0) {\n            return;\n        }\n        event.preventDefault();\n        event.stopPropagation();\n        this.triggerActiveItem();\n    };\n    /**\n     * Handle the `'mousemove'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    Menu.prototype._evtMouseMove = function (event) {\n        // Hit test the item nodes for the item under the mouse.\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this.contentNode.children, function (node) {\n            return _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(node, event.clientX, event.clientY);\n        });\n        // Bail early if the mouse is already over the active index.\n        if (index === this._activeIndex) {\n            return;\n        }\n        // Update and coerce the active index.\n        this.activeIndex = index;\n        index = this.activeIndex;\n        // If the index is the current child index, cancel the timers.\n        if (index === this._childIndex) {\n            this._cancelOpenTimer();\n            this._cancelCloseTimer();\n            return;\n        }\n        // If a child menu is currently open, start the close timer.\n        if (this._childIndex !== -1) {\n            this._startCloseTimer();\n        }\n        // Cancel the open timer to give a full delay for opening.\n        this._cancelOpenTimer();\n        // Bail if the active item is not a valid submenu item.\n        var item = this.activeItem;\n        if (!item || item.type !== 'submenu' || !item.submenu) {\n            return;\n        }\n        // Start the open timer to open the active item submenu.\n        this._startOpenTimer();\n    };\n    /**\n     * Handle the `'mouseenter'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    Menu.prototype._evtMouseEnter = function (event) {\n        // Synchronize the active ancestor items.\n        for (var menu = this._parentMenu; menu; menu = menu._parentMenu) {\n            menu._cancelOpenTimer();\n            menu._cancelCloseTimer();\n            menu.activeIndex = menu._childIndex;\n        }\n    };\n    /**\n     * Handle the `'mouseleave'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    Menu.prototype._evtMouseLeave = function (event) {\n        // Cancel any pending submenu opening.\n        this._cancelOpenTimer();\n        // If there is no open child menu, just reset the active index.\n        if (!this._childMenu) {\n            this.activeIndex = -1;\n            return;\n        }\n        // If the mouse is over the child menu, cancel the close timer.\n        var clientX = event.clientX, clientY = event.clientY;\n        if (_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(this._childMenu.node, clientX, clientY)) {\n            this._cancelCloseTimer();\n            return;\n        }\n        // Otherwise, reset the active index and start the close timer.\n        this.activeIndex = -1;\n        this._startCloseTimer();\n    };\n    /**\n     * Handle the `'mousedown'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the document node.\n     */\n    Menu.prototype._evtMouseDown = function (event) {\n        // Bail if the menu is not a root menu.\n        if (this._parentMenu) {\n            return;\n        }\n        // The mouse button which is pressed is irrelevant. If the press\n        // is not on a menu, the entire hierarchy is closed and the event\n        // is allowed to propagate. This allows other code to act on the\n        // event, such as focusing the clicked element.\n        if (Private$6.hitTestMenus(this, event.clientX, event.clientY)) {\n            event.preventDefault();\n            event.stopPropagation();\n        }\n        else {\n            this.close();\n        }\n    };\n    /**\n     * Open the child menu at the active index immediately.\n     *\n     * If a different child menu is already open, it will be closed,\n     * even if the active item is not a valid submenu.\n     */\n    Menu.prototype._openChildMenu = function (activateFirst) {\n        if (activateFirst === void 0) { activateFirst = false; }\n        // If the item is not a valid submenu, close the child menu.\n        var item = this.activeItem;\n        if (!item || item.type !== 'submenu' || !item.submenu) {\n            this._closeChildMenu();\n            return;\n        }\n        // Do nothing if the child menu will not change.\n        var submenu = item.submenu;\n        if (submenu === this._childMenu) {\n            return;\n        }\n        // Ensure the current child menu is closed.\n        this._closeChildMenu();\n        // Update the private child state.\n        this._childMenu = submenu;\n        this._childIndex = this._activeIndex;\n        // Set the parent menu reference for the child.\n        submenu._parentMenu = this;\n        // Ensure the menu is updated and lookup the item node.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);\n        var itemNode = this.contentNode.children[this._activeIndex];\n        // Open the submenu at the active node.\n        Private$6.openSubmenu(submenu, itemNode);\n        // Activate the first item if desired.\n        if (activateFirst) {\n            submenu.activeIndex = -1;\n            submenu.activateNextItem();\n        }\n        // Activate the child menu.\n        submenu.activate();\n    };\n    /**\n     * Close the child menu immediately.\n     *\n     * This is a no-op if a child menu is not open.\n     */\n    Menu.prototype._closeChildMenu = function () {\n        if (this._childMenu) {\n            this._childMenu.close();\n        }\n    };\n    /**\n     * Start the open timer, unless it is already pending.\n     */\n    Menu.prototype._startOpenTimer = function () {\n        var _this = this;\n        if (this._openTimerID === 0) {\n            this._openTimerID = window.setTimeout(function () {\n                _this._openTimerID = 0;\n                _this._openChildMenu();\n            }, Private$6.TIMER_DELAY);\n        }\n    };\n    /**\n     * Start the close timer, unless it is already pending.\n     */\n    Menu.prototype._startCloseTimer = function () {\n        var _this = this;\n        if (this._closeTimerID === 0) {\n            this._closeTimerID = window.setTimeout(function () {\n                _this._closeTimerID = 0;\n                _this._closeChildMenu();\n            }, Private$6.TIMER_DELAY);\n        }\n    };\n    /**\n     * Cancel the open timer, if the timer is pending.\n     */\n    Menu.prototype._cancelOpenTimer = function () {\n        if (this._openTimerID !== 0) {\n            clearTimeout(this._openTimerID);\n            this._openTimerID = 0;\n        }\n    };\n    /**\n     * Cancel the close timer, if the timer is pending.\n     */\n    Menu.prototype._cancelCloseTimer = function () {\n        if (this._closeTimerID !== 0) {\n            clearTimeout(this._closeTimerID);\n            this._closeTimerID = 0;\n        }\n    };\n    return Menu;\n}(Widget));\n/**\n * The namespace for the `Menu` class statics.\n */\n(function (Menu) {\n    /**\n     * The default implementation of `IRenderer`.\n     *\n     * #### Notes\n     * Subclasses are free to reimplement rendering methods as needed.\n     */\n    var Renderer = /** @class */ (function () {\n        /**\n         * Construct a new renderer.\n         */\n        function Renderer() {\n        }\n        /**\n         * Render the virtual element for a menu item.\n         *\n         * @param data - The data to use for rendering the item.\n         *\n         * @returns A virtual element representing the item.\n         */\n        Renderer.prototype.renderItem = function (data) {\n            var className = this.createItemClass(data);\n            var dataset = this.createItemDataset(data);\n            var aria = this.createItemARIA(data);\n            return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li(__assign({ className: className, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data), this.renderShortcut(data), this.renderSubmenu(data)));\n        };\n        /**\n         * Render the icon element for a menu item.\n         *\n         * @param data - The data to use for rendering the icon.\n         *\n         * @returns A virtual element representing the item icon.\n         */\n        Renderer.prototype.renderIcon = function (data) {\n            var className = this.createIconClass(data);\n            /* <DEPRECATED> */\n            if (typeof data.item.icon === 'string') {\n                return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, data.item.iconLabel);\n            }\n            /* </DEPRECATED> */\n            // if data.item.icon is undefined, it will be ignored\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, data.item.icon, data.item.iconLabel);\n        };\n        /**\n         * Render the label element for a menu item.\n         *\n         * @param data - The data to use for rendering the label.\n         *\n         * @returns A virtual element representing the item label.\n         */\n        Renderer.prototype.renderLabel = function (data) {\n            var content = this.formatLabel(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-Menu-itemLabel'\n                    /* <DEPRECATED> */\n                    + ' p-Menu-itemLabel'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Render the shortcut element for a menu item.\n         *\n         * @param data - The data to use for rendering the shortcut.\n         *\n         * @returns A virtual element representing the item shortcut.\n         */\n        Renderer.prototype.renderShortcut = function (data) {\n            var content = this.formatShortcut(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-Menu-itemShortcut'\n                    /* <DEPRECATED> */\n                    + ' p-Menu-itemShortcut'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Render the submenu icon element for a menu item.\n         *\n         * @param data - The data to use for rendering the submenu icon.\n         *\n         * @returns A virtual element representing the submenu icon.\n         */\n        Renderer.prototype.renderSubmenu = function (data) {\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-Menu-itemSubmenuIcon'\n                    /* <DEPRECATED> */\n                    + ' p-Menu-itemSubmenuIcon'\n                /* </DEPRECATED> */\n            });\n        };\n        /**\n         * Create the class name for the menu item.\n         *\n         * @param data - The data to use for the class name.\n         *\n         * @returns The full class name for the menu item.\n         */\n        Renderer.prototype.createItemClass = function (data) {\n            // Setup the initial class name.\n            var name = 'lm-Menu-item';\n            /* <DEPRECATED> */\n            name += ' p-Menu-item';\n            /* </DEPRECATED> */\n            // Add the boolean state classes.\n            if (!data.item.isEnabled) {\n                name += ' lm-mod-disabled';\n                /* <DEPRECATED> */\n                name += ' p-mod-disabled';\n                /* </DEPRECATED> */\n            }\n            if (data.item.isToggled) {\n                name += ' lm-mod-toggled';\n                /* <DEPRECATED> */\n                name += ' p-mod-toggled';\n                /* </DEPRECATED> */\n            }\n            if (!data.item.isVisible) {\n                name += ' lm-mod-hidden';\n                /* <DEPRECATED> */\n                name += ' p-mod-hidden';\n                /* </DEPRECATED> */\n            }\n            if (data.active) {\n                name += ' lm-mod-active';\n                /* <DEPRECATED> */\n                name += ' p-mod-active';\n                /* </DEPRECATED> */\n            }\n            if (data.collapsed) {\n                name += ' lm-mod-collapsed';\n                /* <DEPRECATED> */\n                name += ' p-mod-collapsed';\n                /* </DEPRECATED> */\n            }\n            // Add the extra class.\n            var extra = data.item.className;\n            if (extra) {\n                name += \" \" + extra;\n            }\n            // Return the complete class name.\n            return name;\n        };\n        /**\n         * Create the dataset for the menu item.\n         *\n         * @param data - The data to use for creating the dataset.\n         *\n         * @returns The dataset for the menu item.\n         */\n        Renderer.prototype.createItemDataset = function (data) {\n            var result;\n            var _a = data.item, type = _a.type, command = _a.command, dataset = _a.dataset;\n            if (type === 'command') {\n                result = __assign(__assign({}, dataset), { type: type, command: command });\n            }\n            else {\n                result = __assign(__assign({}, dataset), { type: type });\n            }\n            return result;\n        };\n        /**\n         * Create the class name for the menu item icon.\n         *\n         * @param data - The data to use for the class name.\n         *\n         * @returns The full class name for the item icon.\n         */\n        Renderer.prototype.createIconClass = function (data) {\n            var name = 'lm-Menu-itemIcon';\n            /* <DEPRECATED> */\n            name += ' p-Menu-itemIcon';\n            /* </DEPRECATED> */\n            var extra = data.item.iconClass;\n            return extra ? name + \" \" + extra : name;\n        };\n        /**\n         * Create the aria attributes for menu item.\n         *\n         * @param data - The data to use for the aria attributes.\n         *\n         * @returns The aria attributes object for the item.\n         */\n        Renderer.prototype.createItemARIA = function (data) {\n            var aria = {};\n            switch (data.item.type) {\n                case 'separator':\n                    aria.role = 'presentation';\n                    break;\n                case 'submenu':\n                    aria['aria-haspopup'] = 'true';\n                    break;\n                default:\n                    aria.role = 'menuitem';\n            }\n            return aria;\n        };\n        /**\n         * Create the render content for the label node.\n         *\n         * @param data - The data to use for the label content.\n         *\n         * @returns The content to add to the label node.\n         */\n        Renderer.prototype.formatLabel = function (data) {\n            // Fetch the label text and mnemonic index.\n            var _a = data.item, label = _a.label, mnemonic = _a.mnemonic;\n            // If the index is out of range, do not modify the label.\n            if (mnemonic < 0 || mnemonic >= label.length) {\n                return label;\n            }\n            // Split the label into parts.\n            var prefix = label.slice(0, mnemonic);\n            var suffix = label.slice(mnemonic + 1);\n            var char = label[mnemonic];\n            // Wrap the mnemonic character in a span.\n            var span = _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.span({\n                className: 'lm-Menu-itemMnemonic'\n                    /* <DEPRECATED> */\n                    + ' p-Menu-itemMnemonic'\n                /* </DEPRECATED> */\n            }, char);\n            // Return the content parts.\n            return [prefix, span, suffix];\n        };\n        /**\n         * Create the render content for the shortcut node.\n         *\n         * @param data - The data to use for the shortcut content.\n         *\n         * @returns The content to add to the shortcut node.\n         */\n        Renderer.prototype.formatShortcut = function (data) {\n            var kb = data.item.keyBinding;\n            return kb ? kb.keys.map(_lumino_commands__WEBPACK_IMPORTED_MODULE_6__.CommandRegistry.formatKeystroke).join(', ') : null;\n        };\n        return Renderer;\n    }());\n    Menu.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    Menu.defaultRenderer = new Renderer();\n})(Menu || (Menu = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$6;\n(function (Private) {\n    /**\n     * The ms delay for opening and closing a submenu.\n     */\n    Private.TIMER_DELAY = 300;\n    /**\n     * The horizontal pixel overlap for an open submenu.\n     */\n    Private.SUBMENU_OVERLAP = 3;\n    /**\n     * Create the DOM node for a menu.\n     */\n    function createNode() {\n        var node = document.createElement('div');\n        var content = document.createElement('ul');\n        content.className = 'lm-Menu-content';\n        /* <DEPRECATED> */\n        content.classList.add('p-Menu-content');\n        /* </DEPRECATED> */\n        node.appendChild(content);\n        content.setAttribute('role', 'menu');\n        node.tabIndex = -1;\n        return node;\n    }\n    Private.createNode = createNode;\n    /**\n     * Test whether a menu item can be activated.\n     */\n    function canActivate(item) {\n        return item.type !== 'separator' && item.isEnabled && item.isVisible;\n    }\n    Private.canActivate = canActivate;\n    /**\n     * Create a new menu item for an owner menu.\n     */\n    function createItem(owner, options) {\n        return new MenuItem(owner.commands, options);\n    }\n    Private.createItem = createItem;\n    /**\n     * Hit test a menu hierarchy starting at the given root.\n     */\n    function hitTestMenus(menu, x, y) {\n        for (var temp = menu; temp; temp = temp.childMenu) {\n            if (_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(temp.node, x, y)) {\n                return true;\n            }\n        }\n        return false;\n    }\n    Private.hitTestMenus = hitTestMenus;\n    /**\n     * Compute which extra separator items should be collapsed.\n     */\n    function computeCollapsed(items) {\n        // Allocate the return array and fill it with `false`.\n        var result = new Array(items.length);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.fill(result, false);\n        // Collapse the leading separators.\n        var k1 = 0;\n        var n = items.length;\n        for (; k1 < n; ++k1) {\n            var item = items[k1];\n            if (!item.isVisible) {\n                continue;\n            }\n            if (item.type !== 'separator') {\n                break;\n            }\n            result[k1] = true;\n        }\n        // Hide the trailing separators.\n        var k2 = n - 1;\n        for (; k2 >= 0; --k2) {\n            var item = items[k2];\n            if (!item.isVisible) {\n                continue;\n            }\n            if (item.type !== 'separator') {\n                break;\n            }\n            result[k2] = true;\n        }\n        // Hide the remaining consecutive separators.\n        var hide = false;\n        while (++k1 < k2) {\n            var item = items[k1];\n            if (!item.isVisible) {\n                continue;\n            }\n            if (item.type !== 'separator') {\n                hide = false;\n            }\n            else if (hide) {\n                result[k1] = true;\n            }\n            else {\n                hide = true;\n            }\n        }\n        // Return the resulting flags.\n        return result;\n    }\n    Private.computeCollapsed = computeCollapsed;\n    /**\n     * Open a menu as a root menu at the target location.\n     */\n    function openRootMenu(menu, x, y, forceX, forceY) {\n        // Ensure the menu is updated before attaching and measuring.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(menu, Widget.Msg.UpdateRequest);\n        // Get the current position and size of the main viewport.\n        var px = window.pageXOffset;\n        var py = window.pageYOffset;\n        var cw = document.documentElement.clientWidth;\n        var ch = document.documentElement.clientHeight;\n        // Compute the maximum allowed height for the menu.\n        var maxHeight = ch - (forceY ? y : 0);\n        // Fetch common variables.\n        var node = menu.node;\n        var style = node.style;\n        // Clear the menu geometry and prepare it for measuring.\n        style.top = '';\n        style.left = '';\n        style.width = '';\n        style.height = '';\n        style.visibility = 'hidden';\n        style.maxHeight = maxHeight + \"px\";\n        // Attach the menu to the document.\n        Widget.attach(menu, document.body);\n        // Measure the size of the menu.\n        var _a = node.getBoundingClientRect(), width = _a.width, height = _a.height;\n        // Adjust the X position of the menu to fit on-screen.\n        if (!forceX && (x + width > px + cw)) {\n            x = px + cw - width;\n        }\n        // Adjust the Y position of the menu to fit on-screen.\n        if (!forceY && (y + height > py + ch)) {\n            if (y > py + ch) {\n                y = py + ch - height;\n            }\n            else {\n                y = y - height;\n            }\n        }\n        // Update the position of the menu to the computed position.\n        style.top = Math.max(0, y) + \"px\";\n        style.left = Math.max(0, x) + \"px\";\n        // Finally, make the menu visible on the screen.\n        style.visibility = '';\n    }\n    Private.openRootMenu = openRootMenu;\n    /**\n     * Open a menu as a submenu using an item node for positioning.\n     */\n    function openSubmenu(submenu, itemNode) {\n        // Ensure the menu is updated before opening.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(submenu, Widget.Msg.UpdateRequest);\n        // Get the current position and size of the main viewport.\n        var px = window.pageXOffset;\n        var py = window.pageYOffset;\n        var cw = document.documentElement.clientWidth;\n        var ch = document.documentElement.clientHeight;\n        // Compute the maximum allowed height for the menu.\n        var maxHeight = ch;\n        // Fetch common variables.\n        var node = submenu.node;\n        var style = node.style;\n        // Clear the menu geometry and prepare it for measuring.\n        style.top = '';\n        style.left = '';\n        style.width = '';\n        style.height = '';\n        style.visibility = 'hidden';\n        style.maxHeight = maxHeight + \"px\";\n        // Attach the menu to the document.\n        Widget.attach(submenu, document.body);\n        // Measure the size of the menu.\n        var _a = node.getBoundingClientRect(), width = _a.width, height = _a.height;\n        // Compute the box sizing for the menu.\n        var box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(submenu.node);\n        // Get the bounding rect for the target item node.\n        var itemRect = itemNode.getBoundingClientRect();\n        // Compute the target X position.\n        var x = itemRect.right - Private.SUBMENU_OVERLAP;\n        // Adjust the X position to fit on the screen.\n        if (x + width > px + cw) {\n            x = itemRect.left + Private.SUBMENU_OVERLAP - width;\n        }\n        // Compute the target Y position.\n        var y = itemRect.top - box.borderTop - box.paddingTop;\n        // Adjust the Y position to fit on the screen.\n        if (y + height > py + ch) {\n            y = itemRect.bottom + box.borderBottom + box.paddingBottom - height;\n        }\n        // Update the position of the menu to the computed position.\n        style.top = Math.max(0, y) + \"px\";\n        style.left = Math.max(0, x) + \"px\";\n        // Finally, make the menu visible on the screen.\n        style.visibility = '';\n    }\n    Private.openSubmenu = openSubmenu;\n    /**\n     * Find the best matching mnemonic item.\n     *\n     * The search starts at the given index and wraps around.\n     */\n    function findMnemonic(items, key, start) {\n        // Setup the result variables.\n        var index = -1;\n        var auto = -1;\n        var multiple = false;\n        // Normalize the key to upper case.\n        var upperKey = key.toUpperCase();\n        // Search the items from the given start index.\n        for (var i = 0, n = items.length; i < n; ++i) {\n            // Compute the wrapped index.\n            var k = (i + start) % n;\n            // Lookup the item\n            var item = items[k];\n            // Ignore items which cannot be activated.\n            if (!canActivate(item)) {\n                continue;\n            }\n            // Ignore items with an empty label.\n            var label = item.label;\n            if (label.length === 0) {\n                continue;\n            }\n            // Lookup the mnemonic index for the label.\n            var mn = item.mnemonic;\n            // Handle a valid mnemonic index.\n            if (mn >= 0 && mn < label.length) {\n                if (label[mn].toUpperCase() === upperKey) {\n                    if (index === -1) {\n                        index = k;\n                    }\n                    else {\n                        multiple = true;\n                    }\n                }\n                continue;\n            }\n            // Finally, handle the auto index if possible.\n            if (auto === -1 && label[0].toUpperCase() === upperKey) {\n                auto = k;\n            }\n        }\n        // Return the search results.\n        return { index: index, multiple: multiple, auto: auto };\n    }\n    Private.findMnemonic = findMnemonic;\n    /**\n     * A concrete implementation of `Menu.IItem`.\n     */\n    var MenuItem = /** @class */ (function () {\n        /**\n         * Construct a new menu item.\n         */\n        function MenuItem(commands, options) {\n            this._commands = commands;\n            this.type = options.type || 'command';\n            this.command = options.command || '';\n            this.args = options.args || _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__.JSONExt.emptyObject;\n            this.submenu = options.submenu || null;\n        }\n        Object.defineProperty(MenuItem.prototype, \"label\", {\n            /**\n             * The display label for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.label(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.label;\n                }\n                return '';\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"mnemonic\", {\n            /**\n             * The mnemonic index for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.mnemonic(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.mnemonic;\n                }\n                return -1;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"icon\", {\n            /**\n             * The icon renderer for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.icon(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.icon;\n                }\n                /* <DEPRECATED> */\n                // alias to icon class if not otherwise defined\n                return this.iconClass;\n                /* </DEPRECATED> */\n                /* <FUTURE>\n                return undefined;\n                </FUTURE> */\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"iconClass\", {\n            /**\n             * The icon class for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.iconClass(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.iconClass;\n                }\n                return '';\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"iconLabel\", {\n            /**\n             * The icon label for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.iconLabel(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.iconLabel;\n                }\n                return '';\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"caption\", {\n            /**\n             * The display caption for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.caption(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.caption;\n                }\n                return '';\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"className\", {\n            /**\n             * The extra class name for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.className(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.className;\n                }\n                return '';\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"dataset\", {\n            /**\n             * The dataset for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.dataset(this.command, this.args);\n                }\n                if (this.type === 'submenu' && this.submenu) {\n                    return this.submenu.title.dataset;\n                }\n                return {};\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"isEnabled\", {\n            /**\n             * Whether the menu item is enabled.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.isEnabled(this.command, this.args);\n                }\n                if (this.type === 'submenu') {\n                    return this.submenu !== null;\n                }\n                return true;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"isToggled\", {\n            /**\n             * Whether the menu item is toggled.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.isToggled(this.command, this.args);\n                }\n                return false;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"isVisible\", {\n            /**\n             * Whether the menu item is visible.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    return this._commands.isVisible(this.command, this.args);\n                }\n                if (this.type === 'submenu') {\n                    return this.submenu !== null;\n                }\n                return true;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(MenuItem.prototype, \"keyBinding\", {\n            /**\n             * The key binding for the menu item.\n             */\n            get: function () {\n                if (this.type === 'command') {\n                    var _a = this, command_1 = _a.command, args_1 = _a.args;\n                    return _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findLastValue(this._commands.keyBindings, function (kb) {\n                        return kb.command === command_1 && _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__.JSONExt.deepEqual(kb.args, args_1);\n                    }) || null;\n                }\n                return null;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        return MenuItem;\n    }());\n})(Private$6 || (Private$6 = {}));\n\n/**\n * An object which implements a universal context menu.\n *\n * #### Notes\n * The items shown in the context menu are determined by CSS selector\n * matching against the DOM hierarchy at the site of the mouse click.\n * This is similar in concept to how keyboard shortcuts are matched\n * in the command registry.\n */\nvar ContextMenu = /** @class */ (function () {\n    /**\n     * Construct a new context menu.\n     *\n     * @param options - The options for initializing the menu.\n     */\n    function ContextMenu(options) {\n        this._idTick = 0;\n        this._items = [];\n        this.menu = new Menu(options);\n    }\n    /**\n     * Add an item to the context menu.\n     *\n     * @param options - The options for creating the item.\n     *\n     * @returns A disposable which will remove the item from the menu.\n     */\n    ContextMenu.prototype.addItem = function (options) {\n        var _this = this;\n        // Create an item from the given options.\n        var item = Private$7.createItem(options, this._idTick++);\n        // Add the item to the internal array.\n        this._items.push(item);\n        // Return a disposable which will remove the item.\n        return new _lumino_disposable__WEBPACK_IMPORTED_MODULE_8__.DisposableDelegate(function () {\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeFirstOf(_this._items, item);\n        });\n    };\n    /**\n     * Open the context menu in response to a `'contextmenu'` event.\n     *\n     * @param event - The `'contextmenu'` event of interest.\n     *\n     * @returns `true` if the menu was opened, or `false` if no items\n     *   matched the event and the menu was not opened.\n     *\n     * #### Notes\n     * This method will populate the context menu with items which match\n     * the propagation path of the event, then open the menu at the mouse\n     * position indicated by the event.\n     */\n    ContextMenu.prototype.open = function (event) {\n        var _this = this;\n        // Clear the current contents of the context menu.\n        this.menu.clearItems();\n        // Bail early if there are no items to match.\n        if (this._items.length === 0) {\n            return false;\n        }\n        // Find the matching items for the event.\n        var items = Private$7.matchItems(this._items, event);\n        // Bail if there are no matching items.\n        if (!items || items.length === 0) {\n            return false;\n        }\n        // Add the filtered items to the menu.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(items, function (item) { _this.menu.addItem(item); });\n        // Open the context menu at the current mouse position.\n        this.menu.open(event.clientX, event.clientY);\n        // Indicate success.\n        return true;\n    };\n    return ContextMenu;\n}());\n/**\n * The namespace for the module implementation details.\n */\nvar Private$7;\n(function (Private) {\n    /**\n     * Create a normalized context menu item from an options object.\n     */\n    function createItem(options, id) {\n        var selector = validateSelector(options.selector);\n        var rank = options.rank !== undefined ? options.rank : Infinity;\n        return __assign(__assign({}, options), { selector: selector, rank: rank, id: id });\n    }\n    Private.createItem = createItem;\n    /**\n     * Find the items which match a context menu event.\n     *\n     * The results are sorted by DOM level, specificity, and rank.\n     */\n    function matchItems(items, event) {\n        // Look up the target of the event.\n        var target = event.target;\n        // Bail if there is no target.\n        if (!target) {\n            return null;\n        }\n        // Look up the current target of the event.\n        var currentTarget = event.currentTarget;\n        // Bail if there is no current target.\n        if (!currentTarget) {\n            return null;\n        }\n        // There are some third party libraries that cause the `target` to\n        // be detached from the DOM before lumino can process the event.\n        // If that happens, search for a new target node by point. If that\n        // node is still dangling, bail.\n        if (!currentTarget.contains(target)) {\n            target = document.elementFromPoint(event.clientX, event.clientY);\n            if (!target || !currentTarget.contains(target)) {\n                return null;\n            }\n        }\n        // Set up the result array.\n        var result = [];\n        // Copy the items array to allow in-place modification.\n        var availableItems = items.slice();\n        // Walk up the DOM hierarchy searching for matches.\n        while (target !== null) {\n            // Set up the match array for this DOM level.\n            var matches = [];\n            // Search the remaining items for matches.\n            for (var i = 0, n = availableItems.length; i < n; ++i) {\n                // Fetch the item.\n                var item = availableItems[i];\n                // Skip items which are already consumed.\n                if (!item) {\n                    continue;\n                }\n                // Skip items which do not match the element.\n                if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Selector.matches(target, item.selector)) {\n                    continue;\n                }\n                // Add the matched item to the result for this DOM level.\n                matches.push(item);\n                // Mark the item as consumed.\n                availableItems[i] = null;\n            }\n            // Sort the matches for this level and add them to the results.\n            if (matches.length !== 0) {\n                matches.sort(itemCmp);\n                result.push.apply(result, matches);\n            }\n            // Stop searching at the limits of the DOM range.\n            if (target === currentTarget) {\n                break;\n            }\n            // Step to the parent DOM level.\n            target = target.parentElement;\n        }\n        // Return the matched and sorted results.\n        return result;\n    }\n    Private.matchItems = matchItems;\n    /**\n     * Validate the selector for a menu item.\n     *\n     * This returns the validated selector, or throws if the selector is\n     * invalid or contains commas.\n     */\n    function validateSelector(selector) {\n        if (selector.indexOf(',') !== -1) {\n            throw new Error(\"Selector cannot contain commas: \" + selector);\n        }\n        if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Selector.isValid(selector)) {\n            throw new Error(\"Invalid selector: \" + selector);\n        }\n        return selector;\n    }\n    /**\n     * A sort comparison function for a context menu item.\n     */\n    function itemCmp(a, b) {\n        // Sort first based on selector specificity.\n        var s1 = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Selector.calculateSpecificity(a.selector);\n        var s2 = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Selector.calculateSpecificity(b.selector);\n        if (s1 !== s2) {\n            return s2 - s1;\n        }\n        // If specificities are equal, sort based on rank.\n        var r1 = a.rank;\n        var r2 = b.rank;\n        if (r1 !== r2) {\n            return r1 < r2 ? -1 : 1; // Infinity-safe\n        }\n        // When all else fails, sort by item id.\n        return a.id - b.id;\n    }\n})(Private$7 || (Private$7 = {}));\n\n/**\n * A widget which displays titles as a single row or column of tabs.\n *\n * #### Notes\n * If CSS transforms are used to rotate nodes for vertically oriented\n * text, then tab dragging will not work correctly. The `tabsMovable`\n * property should be set to `false` when rotating nodes from CSS.\n */\nvar TabBar = /** @class */ (function (_super) {\n    __extends(TabBar, _super);\n    /**\n     * Construct a new tab bar.\n     *\n     * @param options - The options for initializing the tab bar.\n     */\n    function TabBar(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, { node: Private$8.createNode() }) || this;\n        _this._currentIndex = -1;\n        _this._titles = [];\n        _this._titlesEditable = false;\n        _this._previousTitle = null;\n        _this._dragData = null;\n        _this._addButtonEnabled = false;\n        _this._tabMoved = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._currentChanged = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._addRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._tabCloseRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._tabDetachRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._tabActivateRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this.addClass('lm-TabBar');\n        /* <DEPRECATED> */\n        _this.addClass('p-TabBar');\n        /* </DEPRECATED> */\n        _this.contentNode.setAttribute('role', 'tablist');\n        _this.setFlag(Widget.Flag.DisallowLayout);\n        _this.tabsMovable = options.tabsMovable || false;\n        _this.titlesEditable = options.titlesEditable || false;\n        _this.allowDeselect = options.allowDeselect || false;\n        _this.addButtonEnabled = options.addButtonEnabled || false;\n        _this.insertBehavior = options.insertBehavior || 'select-tab-if-needed';\n        _this.name = options.name || '';\n        _this.orientation = options.orientation || 'horizontal';\n        _this.removeBehavior = options.removeBehavior || 'select-tab-after';\n        _this.renderer = options.renderer || TabBar.defaultRenderer;\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the widget.\n     */\n    TabBar.prototype.dispose = function () {\n        this._releaseMouse();\n        this._titles.length = 0;\n        this._previousTitle = null;\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(TabBar.prototype, \"currentChanged\", {\n        /**\n         * A signal emitted when the current tab is changed.\n         *\n         * #### Notes\n         * This signal is emitted when the currently selected tab is changed\n         * either through user or programmatic interaction.\n         *\n         * Notably, this signal is not emitted when the index of the current\n         * tab changes due to tabs being inserted, removed, or moved. It is\n         * only emitted when the actual current tab node is changed.\n         */\n        get: function () {\n            return this._currentChanged;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"tabMoved\", {\n        /**\n         * A signal emitted when a tab is moved by the user.\n         *\n         * #### Notes\n         * This signal is emitted when a tab is moved by user interaction.\n         *\n         * This signal is not emitted when a tab is moved programmatically.\n         */\n        get: function () {\n            return this._tabMoved;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"tabActivateRequested\", {\n        /**\n         * A signal emitted when a tab is clicked by the user.\n         *\n         * #### Notes\n         * If the clicked tab is not the current tab, the clicked tab will be\n         * made current and the `currentChanged` signal will be emitted first.\n         *\n         * This signal is emitted even if the clicked tab is the current tab.\n         */\n        get: function () {\n            return this._tabActivateRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"addRequested\", {\n        /**\n         * A signal emitted when the tab bar add button is clicked.\n         */\n        get: function () {\n            return this._addRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"tabCloseRequested\", {\n        /**\n         * A signal emitted when a tab close icon is clicked.\n         *\n         * #### Notes\n         * This signal is not emitted unless the tab title is `closable`.\n         */\n        get: function () {\n            return this._tabCloseRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"tabDetachRequested\", {\n        /**\n         * A signal emitted when a tab is dragged beyond the detach threshold.\n         *\n         * #### Notes\n         * This signal is emitted when the user drags a tab with the mouse,\n         * and mouse is dragged beyond the detach threshold.\n         *\n         * The consumer of the signal should call `releaseMouse` and remove\n         * the tab in order to complete the detach.\n         *\n         * This signal is only emitted once per drag cycle.\n         */\n        get: function () {\n            return this._tabDetachRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"titlesEditable\", {\n        /**\n         * Whether the titles can be user-edited.\n         *\n         */\n        get: function () {\n            return this._titlesEditable;\n        },\n        /**\n         * Set whether titles can be user edited.\n         *\n         */\n        set: function (value) {\n            this._titlesEditable = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"currentTitle\", {\n        /**\n         * Get the currently selected title.\n         *\n         * #### Notes\n         * This will be `null` if no tab is selected.\n         */\n        get: function () {\n            return this._titles[this._currentIndex] || null;\n        },\n        /**\n         * Set the currently selected title.\n         *\n         * #### Notes\n         * If the title does not exist, the title will be set to `null`.\n         */\n        set: function (value) {\n            this.currentIndex = value ? this._titles.indexOf(value) : -1;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"currentIndex\", {\n        /**\n         * Get the index of the currently selected tab.\n         *\n         * #### Notes\n         * This will be `-1` if no tab is selected.\n         */\n        get: function () {\n            return this._currentIndex;\n        },\n        /**\n         * Set the index of the currently selected tab.\n         *\n         * #### Notes\n         * If the value is out of range, the index will be set to `-1`.\n         */\n        set: function (value) {\n            // Adjust for an out of range index.\n            if (value < 0 || value >= this._titles.length) {\n                value = -1;\n            }\n            // Bail early if the index will not change.\n            if (this._currentIndex === value) {\n                return;\n            }\n            // Look up the previous index and title.\n            var pi = this._currentIndex;\n            var pt = this._titles[pi] || null;\n            // Look up the current index and title.\n            var ci = value;\n            var ct = this._titles[ci] || null;\n            // Update the current index and previous title.\n            this._currentIndex = ci;\n            this._previousTitle = pt;\n            // Schedule an update of the tabs.\n            this.update();\n            // Emit the current changed signal.\n            this._currentChanged.emit({\n                previousIndex: pi, previousTitle: pt,\n                currentIndex: ci, currentTitle: ct\n            });\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"name\", {\n        /**\n         * Get the name of the tab bar.\n         */\n        get: function () {\n            return this._name;\n        },\n        /**\n         * Set the name of the tab bar.\n         */\n        set: function (value) {\n            this._name = value;\n            if (value) {\n                this.contentNode.setAttribute('aria-label', value);\n            }\n            else {\n                this.contentNode.removeAttribute('aria-label');\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"orientation\", {\n        /**\n         * Get the orientation of the tab bar.\n         *\n         * #### Notes\n         * This controls whether the tabs are arranged in a row or column.\n         */\n        get: function () {\n            return this._orientation;\n        },\n        /**\n         * Set the orientation of the tab bar.\n         *\n         * #### Notes\n         * This controls whether the tabs are arranged in a row or column.\n         */\n        set: function (value) {\n            // Do nothing if the orientation does not change.\n            if (this._orientation === value) {\n                return;\n            }\n            // Release the mouse before making any changes.\n            this._releaseMouse();\n            // Toggle the orientation values.\n            this._orientation = value;\n            this.dataset['orientation'] = value;\n            this.contentNode.setAttribute('aria-orientation', value);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"addButtonEnabled\", {\n        /**\n         * Whether the add button is enabled.\n         */\n        get: function () {\n            return this._addButtonEnabled;\n        },\n        /**\n         * Set whether the add button is enabled.\n         */\n        set: function (value) {\n            // Do nothing if the value does not change.\n            if (this._addButtonEnabled === value) {\n                return;\n            }\n            this._addButtonEnabled = value;\n            if (value) {\n                this.addButtonNode.classList.remove('lm-mod-hidden');\n            }\n            else {\n                this.addButtonNode.classList.add('lm-mod-hidden');\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"titles\", {\n        /**\n         * A read-only array of the titles in the tab bar.\n         */\n        get: function () {\n            return this._titles;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"contentNode\", {\n        /**\n         * The tab bar content node.\n         *\n         * #### Notes\n         * This is the node which holds the tab nodes.\n         *\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-TabBar-content')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabBar.prototype, \"addButtonNode\", {\n        /**\n         * The tab bar add button node.\n         *\n         * #### Notes\n         * This is the node which holds the add button.\n         *\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-TabBar-addButton')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Add a tab to the end of the tab bar.\n     *\n     * @param value - The title which holds the data for the tab,\n     *   or an options object to convert to a title.\n     *\n     * @returns The title object added to the tab bar.\n     *\n     * #### Notes\n     * If the title is already added to the tab bar, it will be moved.\n     */\n    TabBar.prototype.addTab = function (value) {\n        return this.insertTab(this._titles.length, value);\n    };\n    /**\n     * Insert a tab into the tab bar at the specified index.\n     *\n     * @param index - The index at which to insert the tab.\n     *\n     * @param value - The title which holds the data for the tab,\n     *   or an options object to convert to a title.\n     *\n     * @returns The title object added to the tab bar.\n     *\n     * #### Notes\n     * The index will be clamped to the bounds of the tabs.\n     *\n     * If the title is already added to the tab bar, it will be moved.\n     */\n    TabBar.prototype.insertTab = function (index, value) {\n        // Release the mouse before making any changes.\n        this._releaseMouse();\n        // Coerce the value to a title.\n        var title = Private$8.asTitle(value);\n        // Look up the index of the title.\n        var i = this._titles.indexOf(title);\n        // Clamp the insert index to the array bounds.\n        var j = Math.max(0, Math.min(index, this._titles.length));\n        // If the title is not in the array, insert it.\n        if (i === -1) {\n            // Insert the title into the array.\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._titles, j, title);\n            // Connect to the title changed signal.\n            title.changed.connect(this._onTitleChanged, this);\n            // Schedule an update of the tabs.\n            this.update();\n            // Adjust the current index for the insert.\n            this._adjustCurrentForInsert(j, title);\n            // Return the title added to the tab bar.\n            return title;\n        }\n        // Otherwise, the title exists in the array and should be moved.\n        // Adjust the index if the location is at the end of the array.\n        if (j === this._titles.length) {\n            j--;\n        }\n        // Bail if there is no effective move.\n        if (i === j) {\n            return title;\n        }\n        // Move the title to the new location.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._titles, i, j);\n        // Schedule an update of the tabs.\n        this.update();\n        // Adjust the current index for the move.\n        this._adjustCurrentForMove(i, j);\n        // Return the title added to the tab bar.\n        return title;\n    };\n    /**\n     * Remove a tab from the tab bar.\n     *\n     * @param title - The title for the tab to remove.\n     *\n     * #### Notes\n     * This is a no-op if the title is not in the tab bar.\n     */\n    TabBar.prototype.removeTab = function (title) {\n        this.removeTabAt(this._titles.indexOf(title));\n    };\n    /**\n     * Remove the tab at a given index from the tab bar.\n     *\n     * @param index - The index of the tab to remove.\n     *\n     * #### Notes\n     * This is a no-op if the index is out of range.\n     */\n    TabBar.prototype.removeTabAt = function (index) {\n        // Release the mouse before making any changes.\n        this._releaseMouse();\n        // Remove the title from the array.\n        var title = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._titles, index);\n        // Bail if the index is out of range.\n        if (!title) {\n            return;\n        }\n        // Disconnect from the title changed signal.\n        title.changed.disconnect(this._onTitleChanged, this);\n        // Clear the previous title if it's being removed.\n        if (title === this._previousTitle) {\n            this._previousTitle = null;\n        }\n        // Schedule an update of the tabs.\n        this.update();\n        // Adjust the current index for the remove.\n        this._adjustCurrentForRemove(index, title);\n    };\n    /**\n     * Remove all tabs from the tab bar.\n     */\n    TabBar.prototype.clearTabs = function () {\n        // Bail if there is nothing to remove.\n        if (this._titles.length === 0) {\n            return;\n        }\n        // Release the mouse before making any changes.\n        this._releaseMouse();\n        // Disconnect from the title changed signals.\n        for (var _i = 0, _a = this._titles; _i < _a.length; _i++) {\n            var title = _a[_i];\n            title.changed.disconnect(this._onTitleChanged, this);\n        }\n        // Get the current index and title.\n        var pi = this.currentIndex;\n        var pt = this.currentTitle;\n        // Reset the current index and previous title.\n        this._currentIndex = -1;\n        this._previousTitle = null;\n        // Clear the title array.\n        this._titles.length = 0;\n        // Schedule an update of the tabs.\n        this.update();\n        // If no tab was selected, there's nothing else to do.\n        if (pi === -1) {\n            return;\n        }\n        // Emit the current changed signal.\n        this._currentChanged.emit({\n            previousIndex: pi, previousTitle: pt,\n            currentIndex: -1, currentTitle: null\n        });\n    };\n    /**\n     * Release the mouse and restore the non-dragged tab positions.\n     *\n     * #### Notes\n     * This will cause the tab bar to stop handling mouse events and to\n     * restore the tabs to their non-dragged positions.\n     */\n    TabBar.prototype.releaseMouse = function () {\n        this._releaseMouse();\n    };\n    /**\n     * Handle the DOM events for the tab bar.\n     *\n     * @param event - The DOM event sent to the tab bar.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the tab bar's DOM node.\n     *\n     * This should not be called directly by user code.\n     */\n    TabBar.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'mousedown':\n                this._evtMouseDown(event);\n                break;\n            case 'mousemove':\n                this._evtMouseMove(event);\n                break;\n            case 'mouseup':\n                this._evtMouseUp(event);\n                break;\n            case 'dblclick':\n                this._evtDblClick(event);\n                break;\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'contextmenu':\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    TabBar.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('mousedown', this);\n        this.node.addEventListener('dblclick', this);\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    TabBar.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('mousedown', this);\n        this.node.removeEventListener('dblclick', this);\n        this._releaseMouse();\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    TabBar.prototype.onUpdateRequest = function (msg) {\n        var titles = this._titles;\n        var renderer = this.renderer;\n        var currentTitle = this.currentTitle;\n        var content = new Array(titles.length);\n        for (var i = 0, n = titles.length; i < n; ++i) {\n            var title = titles[i];\n            var current = title === currentTitle;\n            var zIndex = current ? n : n - i - 1;\n            content[i] = renderer.renderTab({ title: title, current: current, zIndex: zIndex });\n        }\n        _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.VirtualDOM.render(content, this.contentNode);\n    };\n    /**\n     * Handle the `'dblclick'` event for the tab bar.\n     */\n    TabBar.prototype._evtDblClick = function (event) {\n        // Do nothing if titles are not editable\n        if (!this.titlesEditable) {\n            return;\n        }\n        var tabs = this.contentNode.children;\n        // Find the index of the released tab.\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(tabs, function (tab) {\n            return _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(tab, event.clientX, event.clientY);\n        });\n        // Do nothing if the press is not on a tab.\n        if (index === -1) {\n            return;\n        }\n        var title = this.titles[index];\n        var label = tabs[index].querySelector('.lm-TabBar-tabLabel');\n        if (label && label.contains(event.target)) {\n            var value = title.label || '';\n            // Clear the label element\n            var oldValue_1 = label.innerHTML;\n            label.innerHTML = \"\";\n            var input_1 = document.createElement('input');\n            input_1.classList.add('lm-TabBar-tabInput');\n            input_1.value = value;\n            label.appendChild(input_1);\n            var onblur_1 = function () {\n                input_1.removeEventListener('blur', onblur_1);\n                label.innerHTML = oldValue_1;\n            };\n            input_1.addEventListener('dblclick', function (event) { return event.stopPropagation(); });\n            input_1.addEventListener('blur', onblur_1);\n            input_1.addEventListener('keydown', function (event) {\n                if (event.key === 'Enter') {\n                    if (input_1.value !== '') {\n                        title.label = title.caption = input_1.value;\n                    }\n                    onblur_1();\n                }\n                else if (event.key === 'Escape') {\n                    onblur_1();\n                }\n            });\n            input_1.select();\n            input_1.focus();\n            if (label.children.length > 0) {\n                label.children[0].focus();\n            }\n        }\n    };\n    /**\n     * Handle the `'keydown'` event for the tab bar.\n     */\n    TabBar.prototype._evtKeyDown = function (event) {\n        // Stop all input events during drag.\n        event.preventDefault();\n        event.stopPropagation();\n        // Release the mouse if `Escape` is pressed.\n        if (event.keyCode === 27) {\n            this._releaseMouse();\n        }\n    };\n    /**\n     * Handle the `'mousedown'` event for the tab bar.\n     */\n    TabBar.prototype._evtMouseDown = function (event) {\n        // Do nothing if it's not a left or middle mouse press.\n        if (event.button !== 0 && event.button !== 1) {\n            return;\n        }\n        // Do nothing if a drag is in progress.\n        if (this._dragData) {\n            return;\n        }\n        // Check if the add button was clicked.\n        var addButtonClicked = this.addButtonEnabled &&\n            this.addButtonNode.contains(event.target);\n        // Lookup the tab nodes.\n        var tabs = this.contentNode.children;\n        // Find the index of the pressed tab.\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(tabs, function (tab) {\n            return _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(tab, event.clientX, event.clientY);\n        });\n        // Do nothing if the press is not on a tab or the add button.\n        if (index === -1 && !addButtonClicked) {\n            return;\n        }\n        // Pressing on a tab stops the event propagation.\n        event.preventDefault();\n        event.stopPropagation();\n        // Initialize the non-measured parts of the drag data.\n        this._dragData = {\n            tab: tabs[index],\n            index: index,\n            pressX: event.clientX,\n            pressY: event.clientY,\n            tabPos: -1,\n            tabSize: -1,\n            tabPressPos: -1,\n            targetIndex: -1,\n            tabLayout: null,\n            contentRect: null,\n            override: null,\n            dragActive: false,\n            dragAborted: false,\n            detachRequested: false\n        };\n        // Add the document mouse up listener.\n        document.addEventListener('mouseup', this, true);\n        // Do nothing else if the middle button or add button is clicked.\n        if (event.button === 1 || addButtonClicked) {\n            return;\n        }\n        // Do nothing else if the close icon is clicked.\n        var icon = tabs[index].querySelector(this.renderer.closeIconSelector);\n        if (icon && icon.contains(event.target)) {\n            return;\n        }\n        // Add the extra listeners if the tabs are movable.\n        if (this.tabsMovable) {\n            document.addEventListener('mousemove', this, true);\n            document.addEventListener('keydown', this, true);\n            document.addEventListener('contextmenu', this, true);\n        }\n        // Update the current index as appropriate.\n        if (this.allowDeselect && this.currentIndex === index) {\n            this.currentIndex = -1;\n        }\n        else {\n            this.currentIndex = index;\n        }\n        // Do nothing else if there is no current tab.\n        if (this.currentIndex === -1) {\n            return;\n        }\n        // Emit the tab activate request signal.\n        this._tabActivateRequested.emit({\n            index: this.currentIndex, title: this.currentTitle\n        });\n    };\n    /**\n     * Handle the `'mousemove'` event for the tab bar.\n     */\n    TabBar.prototype._evtMouseMove = function (event) {\n        // Do nothing if no drag is in progress.\n        var data = this._dragData;\n        if (!data) {\n            return;\n        }\n        // Suppress the event during a drag.\n        event.preventDefault();\n        event.stopPropagation();\n        // Lookup the tab nodes.\n        var tabs = this.contentNode.children;\n        // Bail early if the drag threshold has not been met.\n        if (!data.dragActive && !Private$8.dragExceeded(data, event)) {\n            return;\n        }\n        // Activate the drag if necessary.\n        if (!data.dragActive) {\n            // Fill in the rest of the drag data measurements.\n            var tabRect = data.tab.getBoundingClientRect();\n            if (this._orientation === 'horizontal') {\n                data.tabPos = data.tab.offsetLeft;\n                data.tabSize = tabRect.width;\n                data.tabPressPos = data.pressX - tabRect.left;\n            }\n            else {\n                data.tabPos = data.tab.offsetTop;\n                data.tabSize = tabRect.height;\n                data.tabPressPos = data.pressY - tabRect.top;\n            }\n            data.tabLayout = Private$8.snapTabLayout(tabs, this._orientation);\n            data.contentRect = this.contentNode.getBoundingClientRect();\n            data.override = _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__.Drag.overrideCursor('default');\n            // Add the dragging style classes.\n            data.tab.classList.add('lm-mod-dragging');\n            this.addClass('lm-mod-dragging');\n            /* <DEPRECATED> */\n            data.tab.classList.add('p-mod-dragging');\n            this.addClass('p-mod-dragging');\n            /* </DEPRECATED> */\n            // Mark the drag as active.\n            data.dragActive = true;\n        }\n        // Emit the detach requested signal if the threshold is exceeded.\n        if (!data.detachRequested && Private$8.detachExceeded(data, event)) {\n            // Only emit the signal once per drag cycle.\n            data.detachRequested = true;\n            // Setup the arguments for the signal.\n            var index = data.index;\n            var clientX = event.clientX;\n            var clientY = event.clientY;\n            var tab = tabs[index];\n            var title = this._titles[index];\n            // Emit the tab detach requested signal.\n            this._tabDetachRequested.emit({ index: index, title: title, tab: tab, clientX: clientX, clientY: clientY });\n            // Bail if the signal handler aborted the drag.\n            if (data.dragAborted) {\n                return;\n            }\n        }\n        // Update the positions of the tabs.\n        Private$8.layoutTabs(tabs, data, event, this._orientation);\n    };\n    /**\n     * Handle the `'mouseup'` event for the document.\n     */\n    TabBar.prototype._evtMouseUp = function (event) {\n        var _this = this;\n        // Do nothing if it's not a left or middle mouse release.\n        if (event.button !== 0 && event.button !== 1) {\n            return;\n        }\n        // Do nothing if no drag is in progress.\n        var data = this._dragData;\n        if (!data) {\n            return;\n        }\n        // Stop the event propagation.\n        event.preventDefault();\n        event.stopPropagation();\n        // Remove the extra mouse event listeners.\n        document.removeEventListener('mousemove', this, true);\n        document.removeEventListener('mouseup', this, true);\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('contextmenu', this, true);\n        // Handle a release when the drag is not active.\n        if (!data.dragActive) {\n            // Clear the drag data.\n            this._dragData = null;\n            // Handle clicking the add button.\n            var addButtonClicked = this.addButtonEnabled &&\n                this.addButtonNode.contains(event.target);\n            if (addButtonClicked) {\n                this._addRequested.emit(undefined);\n                return;\n            }\n            // Lookup the tab nodes.\n            var tabs = this.contentNode.children;\n            // Find the index of the released tab.\n            var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(tabs, function (tab) {\n                return _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(tab, event.clientX, event.clientY);\n            });\n            // Do nothing if the release is not on the original pressed tab.\n            if (index !== data.index) {\n                return;\n            }\n            // Ignore the release if the title is not closable.\n            var title = this._titles[index];\n            if (!title.closable) {\n                return;\n            }\n            // Emit the close requested signal if the middle button is released.\n            if (event.button === 1) {\n                this._tabCloseRequested.emit({ index: index, title: title });\n                return;\n            }\n            // Emit the close requested signal if the close icon was released.\n            var icon = tabs[index].querySelector(this.renderer.closeIconSelector);\n            if (icon && icon.contains(event.target)) {\n                this._tabCloseRequested.emit({ index: index, title: title });\n                return;\n            }\n            // Otherwise, there is nothing left to do.\n            return;\n        }\n        // Do nothing if the left button is not released.\n        if (event.button !== 0) {\n            return;\n        }\n        // Position the tab at its final resting position.\n        Private$8.finalizeTabPosition(data, this._orientation);\n        // Remove the dragging class from the tab so it can be transitioned.\n        data.tab.classList.remove('lm-mod-dragging');\n        /* <DEPRECATED> */\n        data.tab.classList.remove('p-mod-dragging');\n        /* </DEPRECATED> */\n        // Parse the transition duration for releasing the tab.\n        var duration = Private$8.parseTransitionDuration(data.tab);\n        // Complete the release on a timer to allow the tab to transition.\n        setTimeout(function () {\n            // Do nothing if the drag has been aborted.\n            if (data.dragAborted) {\n                return;\n            }\n            // Clear the drag data reference.\n            _this._dragData = null;\n            // Reset the positions of the tabs.\n            Private$8.resetTabPositions(_this.contentNode.children, _this._orientation);\n            // Clear the cursor grab.\n            data.override.dispose();\n            // Remove the remaining dragging style.\n            _this.removeClass('lm-mod-dragging');\n            /* <DEPRECATED> */\n            _this.removeClass('p-mod-dragging');\n            /* </DEPRECATED> */\n            // If the tab was not moved, there is nothing else to do.\n            var i = data.index;\n            var j = data.targetIndex;\n            if (j === -1 || i === j) {\n                return;\n            }\n            // Move the title to the new locations.\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(_this._titles, i, j);\n            // Adjust the current index for the move.\n            _this._adjustCurrentForMove(i, j);\n            // Emit the tab moved signal.\n            _this._tabMoved.emit({\n                fromIndex: i, toIndex: j, title: _this._titles[j]\n            });\n            // Update the tabs immediately to prevent flicker.\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(_this, Widget.Msg.UpdateRequest);\n        }, duration);\n    };\n    /**\n     * Release the mouse and restore the non-dragged tab positions.\n     */\n    TabBar.prototype._releaseMouse = function () {\n        // Do nothing if no drag is in progress.\n        var data = this._dragData;\n        if (!data) {\n            return;\n        }\n        // Clear the drag data reference.\n        this._dragData = null;\n        // Remove the extra mouse listeners.\n        document.removeEventListener('mousemove', this, true);\n        document.removeEventListener('mouseup', this, true);\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('contextmenu', this, true);\n        // Indicate the drag has been aborted. This allows the mouse\n        // event handlers to return early when the drag is canceled.\n        data.dragAborted = true;\n        // If the drag is not active, there's nothing more to do.\n        if (!data.dragActive) {\n            return;\n        }\n        // Reset the tabs to their non-dragged positions.\n        Private$8.resetTabPositions(this.contentNode.children, this._orientation);\n        // Clear the cursor override.\n        data.override.dispose();\n        // Clear the dragging style classes.\n        data.tab.classList.remove('lm-mod-dragging');\n        this.removeClass('lm-mod-dragging');\n        /* <DEPRECATED> */\n        data.tab.classList.remove('p-mod-dragging');\n        this.removeClass('p-mod-dragging');\n        /* </DEPRECATED> */\n    };\n    /**\n     * Adjust the current index for a tab insert operation.\n     *\n     * This method accounts for the tab bar's insertion behavior when\n     * adjusting the current index and emitting the changed signal.\n     */\n    TabBar.prototype._adjustCurrentForInsert = function (i, title) {\n        // Lookup commonly used variables.\n        var ct = this.currentTitle;\n        var ci = this._currentIndex;\n        var bh = this.insertBehavior;\n        // TODO: do we need to do an update to update the aria-selected attribute?\n        // Handle the behavior where the new tab is always selected,\n        // or the behavior where the new tab is selected if needed.\n        if (bh === 'select-tab' || (bh === 'select-tab-if-needed' && ci === -1)) {\n            this._currentIndex = i;\n            this._previousTitle = ct;\n            this._currentChanged.emit({\n                previousIndex: ci, previousTitle: ct,\n                currentIndex: i, currentTitle: title\n            });\n            return;\n        }\n        // Otherwise, silently adjust the current index if needed.\n        if (ci >= i) {\n            this._currentIndex++;\n        }\n    };\n    /**\n     * Adjust the current index for a tab move operation.\n     *\n     * This method will not cause the actual current tab to change.\n     * It silently adjusts the index to account for the given move.\n     */\n    TabBar.prototype._adjustCurrentForMove = function (i, j) {\n        if (this._currentIndex === i) {\n            this._currentIndex = j;\n        }\n        else if (this._currentIndex < i && this._currentIndex >= j) {\n            this._currentIndex++;\n        }\n        else if (this._currentIndex > i && this._currentIndex <= j) {\n            this._currentIndex--;\n        }\n    };\n    /**\n     * Adjust the current index for a tab remove operation.\n     *\n     * This method accounts for the tab bar's remove behavior when\n     * adjusting the current index and emitting the changed signal.\n     */\n    TabBar.prototype._adjustCurrentForRemove = function (i, title) {\n        // Lookup commonly used variables.\n        var ci = this._currentIndex;\n        var bh = this.removeBehavior;\n        // Silently adjust the index if the current tab is not removed.\n        if (ci !== i) {\n            if (ci > i) {\n                this._currentIndex--;\n            }\n            return;\n        }\n        // TODO: do we need to do an update to adjust the aria-selected value?\n        // No tab gets selected if the tab bar is empty.\n        if (this._titles.length === 0) {\n            this._currentIndex = -1;\n            this._currentChanged.emit({\n                previousIndex: i, previousTitle: title,\n                currentIndex: -1, currentTitle: null\n            });\n            return;\n        }\n        // Handle behavior where the next sibling tab is selected.\n        if (bh === 'select-tab-after') {\n            this._currentIndex = Math.min(i, this._titles.length - 1);\n            this._currentChanged.emit({\n                previousIndex: i, previousTitle: title,\n                currentIndex: this._currentIndex, currentTitle: this.currentTitle\n            });\n            return;\n        }\n        // Handle behavior where the previous sibling tab is selected.\n        if (bh === 'select-tab-before') {\n            this._currentIndex = Math.max(0, i - 1);\n            this._currentChanged.emit({\n                previousIndex: i, previousTitle: title,\n                currentIndex: this._currentIndex, currentTitle: this.currentTitle\n            });\n            return;\n        }\n        // Handle behavior where the previous history tab is selected.\n        if (bh === 'select-previous-tab') {\n            if (this._previousTitle) {\n                this._currentIndex = this._titles.indexOf(this._previousTitle);\n                this._previousTitle = null;\n            }\n            else {\n                this._currentIndex = Math.min(i, this._titles.length - 1);\n            }\n            this._currentChanged.emit({\n                previousIndex: i, previousTitle: title,\n                currentIndex: this._currentIndex, currentTitle: this.currentTitle\n            });\n            return;\n        }\n        // Otherwise, no tab gets selected.\n        this._currentIndex = -1;\n        this._currentChanged.emit({\n            previousIndex: i, previousTitle: title,\n            currentIndex: -1, currentTitle: null\n        });\n    };\n    /**\n     * Handle the `changed` signal of a title object.\n     */\n    TabBar.prototype._onTitleChanged = function (sender) {\n        this.update();\n    };\n    return TabBar;\n}(Widget));\n/**\n * The namespace for the `TabBar` class statics.\n */\n(function (TabBar) {\n    /**\n     * The default implementation of `IRenderer`.\n     *\n     * #### Notes\n     * Subclasses are free to reimplement rendering methods as needed.\n     */\n    var Renderer = /** @class */ (function () {\n        /**\n         * Construct a new renderer.\n         */\n        function Renderer() {\n            /**\n             * A selector which matches the close icon node in a tab.\n             */\n            this.closeIconSelector = '.lm-TabBar-tabCloseIcon';\n            this._tabID = 0;\n            this._tabKeys = new WeakMap();\n        }\n        /**\n         * Render the virtual element for a tab.\n         *\n         * @param data - The data to use for rendering the tab.\n         *\n         * @returns A virtual element representing the tab.\n         */\n        Renderer.prototype.renderTab = function (data) {\n            var title = data.title.caption;\n            var key = this.createTabKey(data);\n            var id = key;\n            var style = this.createTabStyle(data);\n            var className = this.createTabClass(data);\n            var dataset = this.createTabDataset(data);\n            var aria = this.createTabARIA(data);\n            if (data.title.closable) {\n                return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li(__assign({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data), this.renderCloseIcon(data)));\n            }\n            else {\n                return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li(__assign({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data)));\n            }\n        };\n        /**\n         * Render the icon element for a tab.\n         *\n         * @param data - The data to use for rendering the tab.\n         *\n         * @returns A virtual element representing the tab icon.\n         */\n        Renderer.prototype.renderIcon = function (data) {\n            var title = data.title;\n            var className = this.createIconClass(data);\n            /* <DEPRECATED> */\n            if (typeof title.icon === 'string') {\n                return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, title.iconLabel);\n            }\n            /* </DEPRECATED> */\n            // if title.icon is undefined, it will be ignored\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, title.icon, title.iconLabel);\n        };\n        /**\n         * Render the label element for a tab.\n         *\n         * @param data - The data to use for rendering the tab.\n         *\n         * @returns A virtual element representing the tab label.\n         */\n        Renderer.prototype.renderLabel = function (data) {\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-TabBar-tabLabel'\n                    /* <DEPRECATED> */\n                    + ' p-TabBar-tabLabel'\n                /* </DEPRECATED> */\n            }, data.title.label);\n        };\n        /**\n         * Render the close icon element for a tab.\n         *\n         * @param data - The data to use for rendering the tab.\n         *\n         * @returns A virtual element representing the tab close icon.\n         */\n        Renderer.prototype.renderCloseIcon = function (data) {\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({\n                className: 'lm-TabBar-tabCloseIcon'\n                    /* <DEPRECATED> */\n                    + ' p-TabBar-tabCloseIcon'\n                /* </DEPRECATED> */\n            });\n        };\n        /**\n         * Create a unique render key for the tab.\n         *\n         * @param data - The data to use for the tab.\n         *\n         * @returns The unique render key for the tab.\n         *\n         * #### Notes\n         * This method caches the key against the tab title the first time\n         * the key is generated. This enables efficient rendering of moved\n         * tabs and avoids subtle hover style artifacts.\n         */\n        Renderer.prototype.createTabKey = function (data) {\n            var key = this._tabKeys.get(data.title);\n            if (key === undefined) {\n                key = \"tab-key-\" + this._tabID++;\n                this._tabKeys.set(data.title, key);\n            }\n            return key;\n        };\n        /**\n         * Create the inline style object for a tab.\n         *\n         * @param data - The data to use for the tab.\n         *\n         * @returns The inline style data for the tab.\n         */\n        Renderer.prototype.createTabStyle = function (data) {\n            return { zIndex: \"\" + data.zIndex };\n        };\n        /**\n         * Create the class name for the tab.\n         *\n         * @param data - The data to use for the tab.\n         *\n         * @returns The full class name for the tab.\n         */\n        Renderer.prototype.createTabClass = function (data) {\n            var name = 'lm-TabBar-tab';\n            /* <DEPRECATED> */\n            name += ' p-TabBar-tab';\n            /* </DEPRECATED> */\n            if (data.title.className) {\n                name += \" \" + data.title.className;\n            }\n            if (data.title.closable) {\n                name += ' lm-mod-closable';\n                /* <DEPRECATED> */\n                name += ' p-mod-closable';\n                /* </DEPRECATED> */\n            }\n            if (data.current) {\n                name += ' lm-mod-current';\n                /* <DEPRECATED> */\n                name += ' p-mod-current';\n                /* </DEPRECATED> */\n            }\n            return name;\n        };\n        /**\n         * Create the dataset for a tab.\n         *\n         * @param data - The data to use for the tab.\n         *\n         * @returns The dataset for the tab.\n         */\n        Renderer.prototype.createTabDataset = function (data) {\n            return data.title.dataset;\n        };\n        /**\n         * Create the ARIA attributes for a tab.\n         *\n         * @param data - The data to use for the tab.\n         *\n         * @returns The ARIA attributes for the tab.\n         */\n        Renderer.prototype.createTabARIA = function (data) {\n            return { role: 'tab', 'aria-selected': data.current.toString() };\n        };\n        /**\n         * Create the class name for the tab icon.\n         *\n         * @param data - The data to use for the tab.\n         *\n         * @returns The full class name for the tab icon.\n         */\n        Renderer.prototype.createIconClass = function (data) {\n            var name = 'lm-TabBar-tabIcon';\n            /* <DEPRECATED> */\n            name += ' p-TabBar-tabIcon';\n            /* </DEPRECATED> */\n            var extra = data.title.iconClass;\n            return extra ? name + \" \" + extra : name;\n        };\n        return Renderer;\n    }());\n    TabBar.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    TabBar.defaultRenderer = new Renderer();\n    /**\n     * A selector which matches the add button node in the tab bar.\n     */\n    TabBar.addButtonSelector = '.lm-TabBar-addButton';\n})(TabBar || (TabBar = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$8;\n(function (Private) {\n    /**\n     * The start drag distance threshold.\n     */\n    Private.DRAG_THRESHOLD = 5;\n    /**\n     * The detach distance threshold.\n     */\n    Private.DETACH_THRESHOLD = 20;\n    /**\n     * Create the DOM node for a tab bar.\n     */\n    function createNode() {\n        var node = document.createElement('div');\n        var content = document.createElement('ul');\n        content.setAttribute('role', 'tablist');\n        content.className = 'lm-TabBar-content';\n        /* <DEPRECATED> */\n        content.classList.add('p-TabBar-content');\n        /* </DEPRECATED> */\n        node.appendChild(content);\n        var add = document.createElement('div');\n        add.className = 'lm-TabBar-addButton lm-mod-hidden';\n        node.appendChild(add);\n        return node;\n    }\n    Private.createNode = createNode;\n    /**\n     * Coerce a title or options into a real title.\n     */\n    function asTitle(value) {\n        return value instanceof Title ? value : new Title(value);\n    }\n    Private.asTitle = asTitle;\n    /**\n     * Parse the transition duration for a tab node.\n     */\n    function parseTransitionDuration(tab) {\n        var style = window.getComputedStyle(tab);\n        return 1000 * (parseFloat(style.transitionDuration) || 0);\n    }\n    Private.parseTransitionDuration = parseTransitionDuration;\n    /**\n     * Get a snapshot of the current tab layout values.\n     */\n    function snapTabLayout(tabs, orientation) {\n        var layout = new Array(tabs.length);\n        for (var i = 0, n = tabs.length; i < n; ++i) {\n            var node = tabs[i];\n            var style = window.getComputedStyle(node);\n            if (orientation === 'horizontal') {\n                layout[i] = {\n                    pos: node.offsetLeft,\n                    size: node.offsetWidth,\n                    margin: parseFloat(style.marginLeft) || 0\n                };\n            }\n            else {\n                layout[i] = {\n                    pos: node.offsetTop,\n                    size: node.offsetHeight,\n                    margin: parseFloat(style.marginTop) || 0\n                };\n            }\n        }\n        return layout;\n    }\n    Private.snapTabLayout = snapTabLayout;\n    /**\n     * Test if the event exceeds the drag threshold.\n     */\n    function dragExceeded(data, event) {\n        var dx = Math.abs(event.clientX - data.pressX);\n        var dy = Math.abs(event.clientY - data.pressY);\n        return dx >= Private.DRAG_THRESHOLD || dy >= Private.DRAG_THRESHOLD;\n    }\n    Private.dragExceeded = dragExceeded;\n    /**\n     * Test if the event exceeds the drag detach threshold.\n     */\n    function detachExceeded(data, event) {\n        var rect = data.contentRect;\n        return ((event.clientX < rect.left - Private.DETACH_THRESHOLD) ||\n            (event.clientX >= rect.right + Private.DETACH_THRESHOLD) ||\n            (event.clientY < rect.top - Private.DETACH_THRESHOLD) ||\n            (event.clientY >= rect.bottom + Private.DETACH_THRESHOLD));\n    }\n    Private.detachExceeded = detachExceeded;\n    /**\n     * Update the relative tab positions and computed target index.\n     */\n    function layoutTabs(tabs, data, event, orientation) {\n        // Compute the orientation-sensitive values.\n        var pressPos;\n        var localPos;\n        var clientPos;\n        var clientSize;\n        if (orientation === 'horizontal') {\n            pressPos = data.pressX;\n            localPos = event.clientX - data.contentRect.left;\n            clientPos = event.clientX;\n            clientSize = data.contentRect.width;\n        }\n        else {\n            pressPos = data.pressY;\n            localPos = event.clientY - data.contentRect.top;\n            clientPos = event.clientY;\n            clientSize = data.contentRect.height;\n        }\n        // Compute the target data.\n        var targetIndex = data.index;\n        var targetPos = localPos - data.tabPressPos;\n        var targetEnd = targetPos + data.tabSize;\n        // Update the relative tab positions.\n        for (var i = 0, n = tabs.length; i < n; ++i) {\n            var pxPos = void 0;\n            var layout = data.tabLayout[i];\n            var threshold = layout.pos + (layout.size >> 1);\n            if (i < data.index && targetPos < threshold) {\n                pxPos = data.tabSize + data.tabLayout[i + 1].margin + \"px\";\n                targetIndex = Math.min(targetIndex, i);\n            }\n            else if (i > data.index && targetEnd > threshold) {\n                pxPos = -data.tabSize - layout.margin + \"px\";\n                targetIndex = Math.max(targetIndex, i);\n            }\n            else if (i === data.index) {\n                var ideal = clientPos - pressPos;\n                var limit = clientSize - (data.tabPos + data.tabSize);\n                pxPos = Math.max(-data.tabPos, Math.min(ideal, limit)) + \"px\";\n            }\n            else {\n                pxPos = '';\n            }\n            if (orientation === 'horizontal') {\n                tabs[i].style.left = pxPos;\n            }\n            else {\n                tabs[i].style.top = pxPos;\n            }\n        }\n        // Update the computed target index.\n        data.targetIndex = targetIndex;\n    }\n    Private.layoutTabs = layoutTabs;\n    /**\n     * Position the drag tab at its final resting relative position.\n     */\n    function finalizeTabPosition(data, orientation) {\n        // Compute the orientation-sensitive client size.\n        var clientSize;\n        if (orientation === 'horizontal') {\n            clientSize = data.contentRect.width;\n        }\n        else {\n            clientSize = data.contentRect.height;\n        }\n        // Compute the ideal final tab position.\n        var ideal;\n        if (data.targetIndex === data.index) {\n            ideal = 0;\n        }\n        else if (data.targetIndex > data.index) {\n            var tgt = data.tabLayout[data.targetIndex];\n            ideal = tgt.pos + tgt.size - data.tabSize - data.tabPos;\n        }\n        else {\n            var tgt = data.tabLayout[data.targetIndex];\n            ideal = tgt.pos - data.tabPos;\n        }\n        // Compute the tab position limit.\n        var limit = clientSize - (data.tabPos + data.tabSize);\n        var final = Math.max(-data.tabPos, Math.min(ideal, limit));\n        // Set the final orientation-sensitive position.\n        if (orientation === 'horizontal') {\n            data.tab.style.left = final + \"px\";\n        }\n        else {\n            data.tab.style.top = final + \"px\";\n        }\n    }\n    Private.finalizeTabPosition = finalizeTabPosition;\n    /**\n     * Reset the relative positions of the given tabs.\n     */\n    function resetTabPositions(tabs, orientation) {\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(tabs, function (tab) {\n            if (orientation === 'horizontal') {\n                tab.style.left = '';\n            }\n            else {\n                tab.style.top = '';\n            }\n        });\n    }\n    Private.resetTabPositions = resetTabPositions;\n})(Private$8 || (Private$8 = {}));\n\n/**\n * A layout which provides a flexible docking arrangement.\n *\n * #### Notes\n * The consumer of this layout is responsible for handling all signals\n * from the generated tab bars and managing the visibility of widgets\n * and tab bars as needed.\n */\nvar DockLayout = /** @class */ (function (_super) {\n    __extends(DockLayout, _super);\n    /**\n     * Construct a new dock layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    function DockLayout(options) {\n        var _this = _super.call(this) || this;\n        _this._spacing = 4;\n        _this._dirty = false;\n        _this._root = null;\n        _this._box = null;\n        _this._items = new Map();\n        _this.renderer = options.renderer;\n        if (options.spacing !== undefined) {\n            _this._spacing = Private$9.clampSpacing(options.spacing);\n        }\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     *\n     * #### Notes\n     * This will clear and dispose all widgets in the layout.\n     */\n    DockLayout.prototype.dispose = function () {\n        // Get an iterator over the widgets in the layout.\n        var widgets = this.iter();\n        // Dispose of the layout items.\n        this._items.forEach(function (item) { item.dispose(); });\n        // Clear the layout state before disposing the widgets.\n        this._box = null;\n        this._root = null;\n        this._items.clear();\n        // Dispose of the widgets contained in the old layout root.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(widgets, function (widget) { widget.dispose(); });\n        // Dispose of the base class.\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(DockLayout.prototype, \"spacing\", {\n        /**\n         * Get the inter-element spacing for the dock layout.\n         */\n        get: function () {\n            return this._spacing;\n        },\n        /**\n         * Set the inter-element spacing for the dock layout.\n         */\n        set: function (value) {\n            value = Private$9.clampSpacing(value);\n            if (this._spacing === value) {\n                return;\n            }\n            this._spacing = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.fit();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockLayout.prototype, \"isEmpty\", {\n        /**\n         * Whether the dock layout is empty.\n         */\n        get: function () {\n            return this._root === null;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Create an iterator over all widgets in the layout.\n     *\n     * @returns A new iterator over the widgets in the layout.\n     *\n     * #### Notes\n     * This iterator includes the generated tab bars.\n     */\n    DockLayout.prototype.iter = function () {\n        return this._root ? this._root.iterAllWidgets() : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Create an iterator over the user widgets in the layout.\n     *\n     * @returns A new iterator over the user widgets in the layout.\n     *\n     * #### Notes\n     * This iterator does not include the generated tab bars.\n     */\n    DockLayout.prototype.widgets = function () {\n        return this._root ? this._root.iterUserWidgets() : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Create an iterator over the selected widgets in the layout.\n     *\n     * @returns A new iterator over the selected user widgets.\n     *\n     * #### Notes\n     * This iterator yields the widgets corresponding to the current tab\n     * of each tab bar in the layout.\n     */\n    DockLayout.prototype.selectedWidgets = function () {\n        return this._root ? this._root.iterSelectedWidgets() : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Create an iterator over the tab bars in the layout.\n     *\n     * @returns A new iterator over the tab bars in the layout.\n     *\n     * #### Notes\n     * This iterator does not include the user widgets.\n     */\n    DockLayout.prototype.tabBars = function () {\n        return this._root ? this._root.iterTabBars() : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Create an iterator over the handles in the layout.\n     *\n     * @returns A new iterator over the handles in the layout.\n     */\n    DockLayout.prototype.handles = function () {\n        return this._root ? this._root.iterHandles() : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Move a handle to the given offset position.\n     *\n     * @param handle - The handle to move.\n     *\n     * @param offsetX - The desired offset X position of the handle.\n     *\n     * @param offsetY - The desired offset Y position of the handle.\n     *\n     * #### Notes\n     * If the given handle is not contained in the layout, this is no-op.\n     *\n     * The handle will be moved as close as possible to the desired\n     * position without violating any of the layout constraints.\n     *\n     * Only one of the coordinates is used depending on the orientation\n     * of the handle. This method accepts both coordinates to make it\n     * easy to invoke from a mouse move event without needing to know\n     * the handle orientation.\n     */\n    DockLayout.prototype.moveHandle = function (handle, offsetX, offsetY) {\n        // Bail early if there is no root or if the handle is hidden.\n        var hidden = handle.classList.contains('lm-mod-hidden');\n        /* <DEPRECATED> */\n        hidden = hidden || handle.classList.contains('p-mod-hidden');\n        /* </DEPRECATED> */\n        if (!this._root || hidden) {\n            return;\n        }\n        // Lookup the split node for the handle.\n        var data = this._root.findSplitNode(handle);\n        if (!data) {\n            return;\n        }\n        // Compute the desired delta movement for the handle.\n        var delta;\n        if (data.node.orientation === 'horizontal') {\n            delta = offsetX - handle.offsetLeft;\n        }\n        else {\n            delta = offsetY - handle.offsetTop;\n        }\n        // Bail if there is no handle movement.\n        if (delta === 0) {\n            return;\n        }\n        // Prevent sibling resizing unless needed.\n        data.node.holdSizes();\n        // Adjust the sizers to reflect the handle movement.\n        BoxEngine.adjust(data.node.sizers, data.index, delta);\n        // Update the layout of the widgets.\n        if (this.parent) {\n            this.parent.update();\n        }\n    };\n    /**\n     * Save the current configuration of the dock layout.\n     *\n     * @returns A new config object for the current layout state.\n     *\n     * #### Notes\n     * The return value can be provided to the `restoreLayout` method\n     * in order to restore the layout to its current configuration.\n     */\n    DockLayout.prototype.saveLayout = function () {\n        // Bail early if there is no root.\n        if (!this._root) {\n            return { main: null };\n        }\n        // Hold the current sizes in the layout tree.\n        this._root.holdAllSizes();\n        // Return the layout config.\n        return { main: this._root.createConfig() };\n    };\n    /**\n     * Restore the layout to a previously saved configuration.\n     *\n     * @param config - The layout configuration to restore.\n     *\n     * #### Notes\n     * Widgets which currently belong to the layout but which are not\n     * contained in the config will be unparented.\n     */\n    DockLayout.prototype.restoreLayout = function (config) {\n        var _this = this;\n        // Create the widget set for validating the config.\n        var widgetSet = new Set();\n        // Normalize the main area config and collect the widgets.\n        var mainConfig;\n        if (config.main) {\n            mainConfig = Private$9.normalizeAreaConfig(config.main, widgetSet);\n        }\n        else {\n            mainConfig = null;\n        }\n        // Create iterators over the old content.\n        var oldWidgets = this.widgets();\n        var oldTabBars = this.tabBars();\n        var oldHandles = this.handles();\n        // Clear the root before removing the old content.\n        this._root = null;\n        // Unparent the old widgets which are not in the new config.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(oldWidgets, function (widget) {\n            if (!widgetSet.has(widget)) {\n                widget.parent = null;\n            }\n        });\n        // Dispose of the old tab bars.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(oldTabBars, function (tabBar) {\n            tabBar.dispose();\n        });\n        // Remove the old handles.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(oldHandles, function (handle) {\n            if (handle.parentNode) {\n                handle.parentNode.removeChild(handle);\n            }\n        });\n        // Reparent the new widgets to the current parent.\n        widgetSet.forEach(function (widget) {\n            widget.parent = _this.parent;\n        });\n        // Create the root node for the new config.\n        if (mainConfig) {\n            this._root = Private$9.realizeAreaConfig(mainConfig, {\n                createTabBar: function () { return _this._createTabBar(); },\n                createHandle: function () { return _this._createHandle(); }\n            });\n        }\n        else {\n            this._root = null;\n        }\n        // If there is no parent, there is nothing more to do.\n        if (!this.parent) {\n            return;\n        }\n        // Attach the new widgets to the parent.\n        widgetSet.forEach(function (widget) {\n            _this.attachWidget(widget);\n        });\n        // Post a fit request to the parent.\n        this.parent.fit();\n    };\n    /**\n     * Add a widget to the dock layout.\n     *\n     * @param widget - The widget to add to the dock layout.\n     *\n     * @param options - The additional options for adding the widget.\n     *\n     * #### Notes\n     * The widget will be moved if it is already contained in the layout.\n     *\n     * An error will be thrown if the reference widget is invalid.\n     */\n    DockLayout.prototype.addWidget = function (widget, options) {\n        if (options === void 0) { options = {}; }\n        // Parse the options.\n        var ref = options.ref || null;\n        var mode = options.mode || 'tab-after';\n        // Find the tab node which holds the reference widget.\n        var refNode = null;\n        if (this._root && ref) {\n            refNode = this._root.findTabNode(ref);\n        }\n        // Throw an error if the reference widget is invalid.\n        if (ref && !refNode) {\n            throw new Error('Reference widget is not in the layout.');\n        }\n        // Reparent the widget to the current layout parent.\n        widget.parent = this.parent;\n        // Insert the widget according to the insert mode.\n        switch (mode) {\n            case 'tab-after':\n                this._insertTab(widget, ref, refNode, true);\n                break;\n            case 'tab-before':\n                this._insertTab(widget, ref, refNode, false);\n                break;\n            case 'split-top':\n                this._insertSplit(widget, ref, refNode, 'vertical', false);\n                break;\n            case 'split-left':\n                this._insertSplit(widget, ref, refNode, 'horizontal', false);\n                break;\n            case 'split-right':\n                this._insertSplit(widget, ref, refNode, 'horizontal', true);\n                break;\n            case 'split-bottom':\n                this._insertSplit(widget, ref, refNode, 'vertical', true);\n                break;\n        }\n        // Do nothing else if there is no parent widget.\n        if (!this.parent) {\n            return;\n        }\n        // Ensure the widget is attached to the parent widget.\n        this.attachWidget(widget);\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Remove a widget from the layout.\n     *\n     * @param widget - The widget to remove from the layout.\n     *\n     * #### Notes\n     * A widget is automatically removed from the layout when its `parent`\n     * is set to `null`. This method should only be invoked directly when\n     * removing a widget from a layout which has yet to be installed on a\n     * parent widget.\n     *\n     * This method does *not* modify the widget's `parent`.\n     */\n    DockLayout.prototype.removeWidget = function (widget) {\n        // Remove the widget from its current layout location.\n        this._removeWidget(widget);\n        // Do nothing else if there is no parent widget.\n        if (!this.parent) {\n            return;\n        }\n        // Detach the widget from the parent widget.\n        this.detachWidget(widget);\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Find the tab area which contains the given client position.\n     *\n     * @param clientX - The client X position of interest.\n     *\n     * @param clientY - The client Y position of interest.\n     *\n     * @returns The geometry of the tab area at the given position, or\n     *   `null` if there is no tab area at the given position.\n     */\n    DockLayout.prototype.hitTestTabAreas = function (clientX, clientY) {\n        // Bail early if hit testing cannot produce valid results.\n        if (!this._root || !this.parent || !this.parent.isVisible) {\n            return null;\n        }\n        // Ensure the parent box sizing data is computed.\n        if (!this._box) {\n            this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        }\n        // Convert from client to local coordinates.\n        var rect = this.parent.node.getBoundingClientRect();\n        var x = clientX - rect.left - this._box.borderLeft;\n        var y = clientY - rect.top - this._box.borderTop;\n        // Find the tab layout node at the local position.\n        var tabNode = this._root.hitTestTabNodes(x, y);\n        // Bail if a tab layout node was not found.\n        if (!tabNode) {\n            return null;\n        }\n        // Extract the data from the tab node.\n        var tabBar = tabNode.tabBar, top = tabNode.top, left = tabNode.left, width = tabNode.width, height = tabNode.height;\n        // Compute the right and bottom edges of the tab area.\n        var borderWidth = this._box.borderLeft + this._box.borderRight;\n        var borderHeight = this._box.borderTop + this._box.borderBottom;\n        var right = rect.width - borderWidth - (left + width);\n        var bottom = rect.height - borderHeight - (top + height);\n        // Return the hit test results.\n        return { tabBar: tabBar, x: x, y: y, top: top, left: left, right: right, bottom: bottom, width: width, height: height };\n    };\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    DockLayout.prototype.init = function () {\n        var _this = this;\n        // Perform superclass initialization.\n        _super.prototype.init.call(this);\n        // Attach each widget to the parent.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) { _this.attachWidget(widget); });\n        // Attach each handle to the parent.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.handles(), function (handle) { _this.parent.node.appendChild(handle); });\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Attach the widget to the layout parent widget.\n     *\n     * @param widget - The widget to attach to the parent.\n     *\n     * #### Notes\n     * This is a no-op if the widget is already attached.\n     */\n    DockLayout.prototype.attachWidget = function (widget) {\n        // Do nothing if the widget is already attached.\n        if (this.parent.node === widget.node.parentNode) {\n            return;\n        }\n        // Create the layout item for the widget.\n        this._items.set(widget, new LayoutItem(widget));\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Add the widget's node to the parent.\n        this.parent.node.appendChild(widget.node);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n    };\n    /**\n     * Detach the widget from the layout parent widget.\n     *\n     * @param widget - The widget to detach from the parent.\n     *\n     * #### Notes\n     * This is a no-op if the widget is not attached.\n     */\n    DockLayout.prototype.detachWidget = function (widget) {\n        // Do nothing if the widget is not attached.\n        if (this.parent.node !== widget.node.parentNode) {\n            return;\n        }\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Delete the layout item for the widget.\n        var item = this._items.get(widget);\n        if (item) {\n            this._items.delete(widget);\n            item.dispose();\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     */\n    DockLayout.prototype.onBeforeShow = function (msg) {\n        _super.prototype.onBeforeShow.call(this, msg);\n        this.parent.update();\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    DockLayout.prototype.onBeforeAttach = function (msg) {\n        _super.prototype.onBeforeAttach.call(this, msg);\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    DockLayout.prototype.onChildShown = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    DockLayout.prototype.onChildHidden = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    DockLayout.prototype.onResize = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(msg.width, msg.height);\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    DockLayout.prototype.onUpdateRequest = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(-1, -1);\n        }\n    };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     */\n    DockLayout.prototype.onFitRequest = function (msg) {\n        if (this.parent.isAttached) {\n            this._fit();\n        }\n    };\n    /**\n     * Remove the specified widget from the layout structure.\n     *\n     * #### Notes\n     * This is a no-op if the widget is not in the layout tree.\n     *\n     * This does not detach the widget from the parent node.\n     */\n    DockLayout.prototype._removeWidget = function (widget) {\n        // Bail early if there is no layout root.\n        if (!this._root) {\n            return;\n        }\n        // Find the tab node which contains the given widget.\n        var tabNode = this._root.findTabNode(widget);\n        // Bail early if the tab node is not found.\n        if (!tabNode) {\n            return;\n        }\n        Private$9.removeAria(widget);\n        // If there are multiple tabs, just remove the widget's tab.\n        if (tabNode.tabBar.titles.length > 1) {\n            tabNode.tabBar.removeTab(widget.title);\n            return;\n        }\n        // Otherwise, the tab node needs to be removed...\n        // Dispose the tab bar.\n        tabNode.tabBar.dispose();\n        // Handle the case where the tab node is the root.\n        if (this._root === tabNode) {\n            this._root = null;\n            return;\n        }\n        // Otherwise, remove the tab node from its parent...\n        // Prevent widget resizing unless needed.\n        this._root.holdAllSizes();\n        // Clear the parent reference on the tab node.\n        var splitNode = tabNode.parent;\n        tabNode.parent = null;\n        // Remove the tab node from its parent split node.\n        var i = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeFirstOf(splitNode.children, tabNode);\n        var handle = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(splitNode.handles, i);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(splitNode.sizers, i);\n        // Remove the handle from its parent DOM node.\n        if (handle.parentNode) {\n            handle.parentNode.removeChild(handle);\n        }\n        // If there are multiple children, just update the handles.\n        if (splitNode.children.length > 1) {\n            splitNode.syncHandles();\n            return;\n        }\n        // Otherwise, the split node also needs to be removed...\n        // Clear the parent reference on the split node.\n        var maybeParent = splitNode.parent;\n        splitNode.parent = null;\n        // Lookup the remaining child node and handle.\n        var childNode = splitNode.children[0];\n        var childHandle = splitNode.handles[0];\n        // Clear the split node data.\n        splitNode.children.length = 0;\n        splitNode.handles.length = 0;\n        splitNode.sizers.length = 0;\n        // Remove the child handle from its parent node.\n        if (childHandle.parentNode) {\n            childHandle.parentNode.removeChild(childHandle);\n        }\n        // Handle the case where the split node is the root.\n        if (this._root === splitNode) {\n            childNode.parent = null;\n            this._root = childNode;\n            return;\n        }\n        // Otherwise, move the child node to the parent node...\n        var parentNode = maybeParent;\n        // Lookup the index of the split node.\n        var j = parentNode.children.indexOf(splitNode);\n        // Handle the case where the child node is a tab node.\n        if (childNode instanceof Private$9.TabLayoutNode) {\n            childNode.parent = parentNode;\n            parentNode.children[j] = childNode;\n            return;\n        }\n        // Remove the split data from the parent.\n        var splitHandle = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(parentNode.handles, j);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(parentNode.children, j);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(parentNode.sizers, j);\n        // Remove the handle from its parent node.\n        if (splitHandle.parentNode) {\n            splitHandle.parentNode.removeChild(splitHandle);\n        }\n        // The child node and the split parent node will have the same\n        // orientation. Merge the grand-children with the parent node.\n        for (var i_1 = 0, n = childNode.children.length; i_1 < n; ++i_1) {\n            var gChild = childNode.children[i_1];\n            var gHandle = childNode.handles[i_1];\n            var gSizer = childNode.sizers[i_1];\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(parentNode.children, j + i_1, gChild);\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(parentNode.handles, j + i_1, gHandle);\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(parentNode.sizers, j + i_1, gSizer);\n            gChild.parent = parentNode;\n        }\n        // Clear the child node.\n        childNode.children.length = 0;\n        childNode.handles.length = 0;\n        childNode.sizers.length = 0;\n        childNode.parent = null;\n        // Sync the handles on the parent node.\n        parentNode.syncHandles();\n    };\n    /**\n     * Insert a widget next to an existing tab.\n     *\n     * #### Notes\n     * This does not attach the widget to the parent widget.\n     */\n    DockLayout.prototype._insertTab = function (widget, ref, refNode, after) {\n        // Do nothing if the tab is inserted next to itself.\n        if (widget === ref) {\n            return;\n        }\n        // Create the root if it does not exist.\n        if (!this._root) {\n            var tabNode = new Private$9.TabLayoutNode(this._createTabBar());\n            tabNode.tabBar.addTab(widget.title);\n            this._root = tabNode;\n            Private$9.addAria(widget, tabNode.tabBar);\n            return;\n        }\n        // Use the first tab node as the ref node if needed.\n        if (!refNode) {\n            refNode = this._root.findFirstTabNode();\n        }\n        // If the widget is not contained in the ref node, ensure it is\n        // removed from the layout and hidden before being added again.\n        if (refNode.tabBar.titles.indexOf(widget.title) === -1) {\n            this._removeWidget(widget);\n            widget.hide();\n        }\n        // Lookup the target index for inserting the tab.\n        var index;\n        if (ref) {\n            index = refNode.tabBar.titles.indexOf(ref.title);\n        }\n        else {\n            index = refNode.tabBar.currentIndex;\n        }\n        // Insert the widget's tab relative to the target index.\n        refNode.tabBar.insertTab(index + (after ? 1 : 0), widget.title);\n        Private$9.addAria(widget, refNode.tabBar);\n    };\n    /**\n     * Insert a widget as a new split area.\n     *\n     * #### Notes\n     * This does not attach the widget to the parent widget.\n     */\n    DockLayout.prototype._insertSplit = function (widget, ref, refNode, orientation, after) {\n        // Do nothing if there is no effective split.\n        if (widget === ref && refNode && refNode.tabBar.titles.length === 1) {\n            return;\n        }\n        // Ensure the widget is removed from the current layout.\n        this._removeWidget(widget);\n        // Create the tab layout node to hold the widget.\n        var tabNode = new Private$9.TabLayoutNode(this._createTabBar());\n        tabNode.tabBar.addTab(widget.title);\n        Private$9.addAria(widget, tabNode.tabBar);\n        // Set the root if it does not exist.\n        if (!this._root) {\n            this._root = tabNode;\n            return;\n        }\n        // If the ref node parent is null, split the root.\n        if (!refNode || !refNode.parent) {\n            // Ensure the root is split with the correct orientation.\n            var root = this._splitRoot(orientation);\n            // Determine the insert index for the new tab node.\n            var i_2 = after ? root.children.length : 0;\n            // Normalize the split node.\n            root.normalizeSizes();\n            // Create the sizer for new tab node.\n            var sizer = Private$9.createSizer(refNode ? 1 : Private$9.GOLDEN_RATIO);\n            // Insert the tab node sized to the golden ratio.\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(root.children, i_2, tabNode);\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(root.sizers, i_2, sizer);\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(root.handles, i_2, this._createHandle());\n            tabNode.parent = root;\n            // Re-normalize the split node to maintain the ratios.\n            root.normalizeSizes();\n            // Finally, synchronize the visibility of the handles.\n            root.syncHandles();\n            return;\n        }\n        // Lookup the split node for the ref widget.\n        var splitNode = refNode.parent;\n        // If the split node already had the correct orientation,\n        // the widget can be inserted into the split node directly.\n        if (splitNode.orientation === orientation) {\n            // Find the index of the ref node.\n            var i_3 = splitNode.children.indexOf(refNode);\n            // Normalize the split node.\n            splitNode.normalizeSizes();\n            // Consume half the space for the insert location.\n            var s = splitNode.sizers[i_3].sizeHint /= 2;\n            // Insert the tab node sized to the other half.\n            var j_1 = i_3 + (after ? 1 : 0);\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(splitNode.children, j_1, tabNode);\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(splitNode.sizers, j_1, Private$9.createSizer(s));\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(splitNode.handles, j_1, this._createHandle());\n            tabNode.parent = splitNode;\n            // Finally, synchronize the visibility of the handles.\n            splitNode.syncHandles();\n            return;\n        }\n        // Remove the ref node from the split node.\n        var i = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeFirstOf(splitNode.children, refNode);\n        // Create a new normalized split node for the children.\n        var childNode = new Private$9.SplitLayoutNode(orientation);\n        childNode.normalized = true;\n        // Add the ref node sized to half the space.\n        childNode.children.push(refNode);\n        childNode.sizers.push(Private$9.createSizer(0.5));\n        childNode.handles.push(this._createHandle());\n        refNode.parent = childNode;\n        // Add the tab node sized to the other half.\n        var j = after ? 1 : 0;\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(childNode.children, j, tabNode);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(childNode.sizers, j, Private$9.createSizer(0.5));\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(childNode.handles, j, this._createHandle());\n        tabNode.parent = childNode;\n        // Synchronize the visibility of the handles.\n        childNode.syncHandles();\n        // Finally, add the new child node to the original split node.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(splitNode.children, i, childNode);\n        childNode.parent = splitNode;\n    };\n    /**\n     * Ensure the root is a split node with the given orientation.\n     */\n    DockLayout.prototype._splitRoot = function (orientation) {\n        // Bail early if the root already meets the requirements.\n        var oldRoot = this._root;\n        if (oldRoot instanceof Private$9.SplitLayoutNode) {\n            if (oldRoot.orientation === orientation) {\n                return oldRoot;\n            }\n        }\n        // Create a new root node with the specified orientation.\n        var newRoot = this._root = new Private$9.SplitLayoutNode(orientation);\n        // Add the old root to the new root.\n        if (oldRoot) {\n            newRoot.children.push(oldRoot);\n            newRoot.sizers.push(Private$9.createSizer(0));\n            newRoot.handles.push(this._createHandle());\n            oldRoot.parent = newRoot;\n        }\n        // Return the new root as a convenience.\n        return newRoot;\n    };\n    /**\n     * Fit the layout to the total size required by the widgets.\n     */\n    DockLayout.prototype._fit = function () {\n        // Set up the computed minimum size.\n        var minW = 0;\n        var minH = 0;\n        // Update the size limits for the layout tree.\n        if (this._root) {\n            var limits = this._root.fit(this._spacing, this._items);\n            minW = limits.minWidth;\n            minH = limits.minHeight;\n        }\n        // Update the box sizing and add it to the computed min size.\n        var box = this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        var style = this.parent.node.style;\n        style.minWidth = minW + \"px\";\n        style.minHeight = minH + \"px\";\n        // Set the dirty flag to ensure only a single update occurs.\n        this._dirty = true;\n        // Notify the ancestor that it should fit immediately. This may\n        // cause a resize of the parent, fulfilling the required update.\n        if (this.parent.parent) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent.parent, Widget.Msg.FitRequest);\n        }\n        // If the dirty flag is still set, the parent was not resized.\n        // Trigger the required update on the parent widget immediately.\n        if (this._dirty) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n        }\n    };\n    /**\n     * Update the layout position and size of the widgets.\n     *\n     * The parent offset dimensions should be `-1` if unknown.\n     */\n    DockLayout.prototype._update = function (offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Bail early if there is no root layout node.\n        if (!this._root) {\n            return;\n        }\n        // Measure the parent if the offset dimensions are unknown.\n        if (offsetWidth < 0) {\n            offsetWidth = this.parent.node.offsetWidth;\n        }\n        if (offsetHeight < 0) {\n            offsetHeight = this.parent.node.offsetHeight;\n        }\n        // Ensure the parent box sizing data is computed.\n        if (!this._box) {\n            this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the actual layout bounds adjusted for border and padding.\n        var x = this._box.paddingTop;\n        var y = this._box.paddingLeft;\n        var width = offsetWidth - this._box.horizontalSum;\n        var height = offsetHeight - this._box.verticalSum;\n        // Update the geometry of the layout tree.\n        this._root.update(x, y, width, height, this._spacing, this._items);\n    };\n    /**\n     * Create a new tab bar for use by the dock layout.\n     *\n     * #### Notes\n     * The tab bar will be attached to the parent if it exists.\n     */\n    DockLayout.prototype._createTabBar = function () {\n        // Create the tab bar using the renderer.\n        var tabBar = this.renderer.createTabBar();\n        // Enforce necessary tab bar behavior.\n        tabBar.orientation = 'horizontal';\n        // Reparent and attach the tab bar to the parent if possible.\n        if (this.parent) {\n            tabBar.parent = this.parent;\n            this.attachWidget(tabBar);\n        }\n        // Return the initialized tab bar.\n        return tabBar;\n    };\n    /**\n     * Create a new handle for the dock layout.\n     *\n     * #### Notes\n     * The handle will be attached to the parent if it exists.\n     */\n    DockLayout.prototype._createHandle = function () {\n        // Create the handle using the renderer.\n        var handle = this.renderer.createHandle();\n        // Initialize the handle layout behavior.\n        var style = handle.style;\n        style.position = 'absolute';\n        style.top = '0';\n        style.left = '0';\n        style.width = '0';\n        style.height = '0';\n        // Attach the handle to the parent if it exists.\n        if (this.parent) {\n            this.parent.node.appendChild(handle);\n        }\n        // Return the initialized handle.\n        return handle;\n    };\n    return DockLayout;\n}(Layout));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$9;\n(function (Private) {\n    /**\n     * A fraction used for sizing root panels; ~= `1 / golden_ratio`.\n     */\n    Private.GOLDEN_RATIO = 0.618;\n    /**\n     * Clamp a spacing value to an integer >= 0.\n     */\n    function clampSpacing(value) {\n        return Math.max(0, Math.floor(value));\n    }\n    Private.clampSpacing = clampSpacing;\n    /**\n     * Create a box sizer with an initial size hint.\n     */\n    function createSizer(hint) {\n        var sizer = new BoxSizer();\n        sizer.sizeHint = hint;\n        sizer.size = hint;\n        return sizer;\n    }\n    Private.createSizer = createSizer;\n    /**\n     * Normalize an area config object and collect the visited widgets.\n     */\n    function normalizeAreaConfig(config, widgetSet) {\n        var result;\n        if (config.type === 'tab-area') {\n            result = normalizeTabAreaConfig(config, widgetSet);\n        }\n        else {\n            result = normalizeSplitAreaConfig(config, widgetSet);\n        }\n        return result;\n    }\n    Private.normalizeAreaConfig = normalizeAreaConfig;\n    /**\n     * Convert a normalized area config into a layout tree.\n     */\n    function realizeAreaConfig(config, renderer) {\n        var node;\n        if (config.type === 'tab-area') {\n            node = realizeTabAreaConfig(config, renderer);\n        }\n        else {\n            node = realizeSplitAreaConfig(config, renderer);\n        }\n        return node;\n    }\n    Private.realizeAreaConfig = realizeAreaConfig;\n    /**\n     * A layout node which holds the data for a tabbed area.\n     */\n    var TabLayoutNode = /** @class */ (function () {\n        /**\n         * Construct a new tab layout node.\n         *\n         * @param tabBar - The tab bar to use for the layout node.\n         */\n        function TabLayoutNode(tabBar) {\n            /**\n             * The parent of the layout node.\n             */\n            this.parent = null;\n            this._top = 0;\n            this._left = 0;\n            this._width = 0;\n            this._height = 0;\n            var tabSizer = new BoxSizer();\n            var widgetSizer = new BoxSizer();\n            tabSizer.stretch = 0;\n            widgetSizer.stretch = 1;\n            this.tabBar = tabBar;\n            this.sizers = [tabSizer, widgetSizer];\n        }\n        Object.defineProperty(TabLayoutNode.prototype, \"top\", {\n            /**\n             * The most recent value for the `top` edge of the layout box.\n             */\n            get: function () {\n                return this._top;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(TabLayoutNode.prototype, \"left\", {\n            /**\n             * The most recent value for the `left` edge of the layout box.\n             */\n            get: function () {\n                return this._left;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(TabLayoutNode.prototype, \"width\", {\n            /**\n             * The most recent value for the `width` of the layout box.\n             */\n            get: function () {\n                return this._width;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        Object.defineProperty(TabLayoutNode.prototype, \"height\", {\n            /**\n             * The most recent value for the `height` of the layout box.\n             */\n            get: function () {\n                return this._height;\n            },\n            enumerable: true,\n            configurable: true\n        });\n        /**\n         * Create an iterator for all widgets in the layout tree.\n         */\n        TabLayoutNode.prototype.iterAllWidgets = function () {\n            return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.chain)((0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.once)(this.tabBar), this.iterUserWidgets());\n        };\n        /**\n         * Create an iterator for the user widgets in the layout tree.\n         */\n        TabLayoutNode.prototype.iterUserWidgets = function () {\n            return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this.tabBar.titles, function (title) { return title.owner; });\n        };\n        /**\n         * Create an iterator for the selected widgets in the layout tree.\n         */\n        TabLayoutNode.prototype.iterSelectedWidgets = function () {\n            var title = this.tabBar.currentTitle;\n            return title ? (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.once)(title.owner) : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n        };\n        /**\n         * Create an iterator for the tab bars in the layout tree.\n         */\n        TabLayoutNode.prototype.iterTabBars = function () {\n            return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.once)(this.tabBar);\n        };\n        /**\n         * Create an iterator for the handles in the layout tree.\n         */\n        TabLayoutNode.prototype.iterHandles = function () {\n            return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n        };\n        /**\n         * Find the tab layout node which contains the given widget.\n         */\n        TabLayoutNode.prototype.findTabNode = function (widget) {\n            return this.tabBar.titles.indexOf(widget.title) !== -1 ? this : null;\n        };\n        /**\n         * Find the split layout node which contains the given handle.\n         */\n        TabLayoutNode.prototype.findSplitNode = function (handle) {\n            return null;\n        };\n        /**\n         * Find the first tab layout node in a layout tree.\n         */\n        TabLayoutNode.prototype.findFirstTabNode = function () {\n            return this;\n        };\n        /**\n         * Find the tab layout node which contains the local point.\n         */\n        TabLayoutNode.prototype.hitTestTabNodes = function (x, y) {\n            if (x < this._left || x >= this._left + this._width) {\n                return null;\n            }\n            if (y < this._top || y >= this._top + this._height) {\n                return null;\n            }\n            return this;\n        };\n        /**\n         * Create a configuration object for the layout tree.\n         */\n        TabLayoutNode.prototype.createConfig = function () {\n            var widgets = this.tabBar.titles.map(function (title) { return title.owner; });\n            var currentIndex = this.tabBar.currentIndex;\n            return { type: 'tab-area', widgets: widgets, currentIndex: currentIndex };\n        };\n        /**\n         * Recursively hold all of the sizes in the layout tree.\n         *\n         * This ignores the sizers of tab layout nodes.\n         */\n        TabLayoutNode.prototype.holdAllSizes = function () {\n            return;\n        };\n        /**\n         * Fit the layout tree.\n         */\n        TabLayoutNode.prototype.fit = function (spacing, items) {\n            // Set up the limit variables.\n            var minWidth = 0;\n            var minHeight = 0;\n            var maxWidth = Infinity;\n            var maxHeight = Infinity;\n            // Lookup the tab bar layout item.\n            var tabBarItem = items.get(this.tabBar);\n            // Lookup the widget layout item.\n            var current = this.tabBar.currentTitle;\n            var widgetItem = current ? items.get(current.owner) : undefined;\n            // Lookup the tab bar and widget sizers.\n            var _a = this.sizers, tabBarSizer = _a[0], widgetSizer = _a[1];\n            // Update the tab bar limits.\n            if (tabBarItem) {\n                tabBarItem.fit();\n            }\n            // Update the widget limits.\n            if (widgetItem) {\n                widgetItem.fit();\n            }\n            // Update the results and sizer for the tab bar.\n            if (tabBarItem && !tabBarItem.isHidden) {\n                minWidth = Math.max(minWidth, tabBarItem.minWidth);\n                minHeight += tabBarItem.minHeight;\n                tabBarSizer.minSize = tabBarItem.minHeight;\n                tabBarSizer.maxSize = tabBarItem.maxHeight;\n            }\n            else {\n                tabBarSizer.minSize = 0;\n                tabBarSizer.maxSize = 0;\n            }\n            // Update the results and sizer for the current widget.\n            if (widgetItem && !widgetItem.isHidden) {\n                minWidth = Math.max(minWidth, widgetItem.minWidth);\n                minHeight += widgetItem.minHeight;\n                widgetSizer.minSize = widgetItem.minHeight;\n                widgetSizer.maxSize = Infinity;\n            }\n            else {\n                widgetSizer.minSize = 0;\n                widgetSizer.maxSize = Infinity;\n            }\n            // Return the computed size limits for the layout node.\n            return { minWidth: minWidth, minHeight: minHeight, maxWidth: maxWidth, maxHeight: maxHeight };\n        };\n        /**\n         * Update the layout tree.\n         */\n        TabLayoutNode.prototype.update = function (left, top, width, height, spacing, items) {\n            // Update the layout box values.\n            this._top = top;\n            this._left = left;\n            this._width = width;\n            this._height = height;\n            // Lookup the tab bar layout item.\n            var tabBarItem = items.get(this.tabBar);\n            // Lookup the widget layout item.\n            var current = this.tabBar.currentTitle;\n            var widgetItem = current ? items.get(current.owner) : undefined;\n            // Distribute the layout space to the sizers.\n            BoxEngine.calc(this.sizers, height);\n            // Update the tab bar item using the computed size.\n            if (tabBarItem && !tabBarItem.isHidden) {\n                var size = this.sizers[0].size;\n                tabBarItem.update(left, top, width, size);\n                top += size;\n            }\n            // Layout the widget using the computed size.\n            if (widgetItem && !widgetItem.isHidden) {\n                var size = this.sizers[1].size;\n                widgetItem.update(left, top, width, size);\n            }\n        };\n        return TabLayoutNode;\n    }());\n    Private.TabLayoutNode = TabLayoutNode;\n    /**\n     * A layout node which holds the data for a split area.\n     */\n    var SplitLayoutNode = /** @class */ (function () {\n        /**\n         * Construct a new split layout node.\n         *\n         * @param orientation - The orientation of the node.\n         */\n        function SplitLayoutNode(orientation) {\n            /**\n             * The parent of the layout node.\n             */\n            this.parent = null;\n            /**\n             * Whether the sizers have been normalized.\n             */\n            this.normalized = false;\n            /**\n             * The child nodes for the split node.\n             */\n            this.children = [];\n            /**\n             * The box sizers for the layout children.\n             */\n            this.sizers = [];\n            /**\n             * The handles for the layout children.\n             */\n            this.handles = [];\n            this.orientation = orientation;\n        }\n        /**\n         * Create an iterator for all widgets in the layout tree.\n         */\n        SplitLayoutNode.prototype.iterAllWidgets = function () {\n            var children = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this.children, function (child) { return child.iterAllWidgets(); });\n            return new _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ChainIterator(children);\n        };\n        /**\n         * Create an iterator for the user widgets in the layout tree.\n         */\n        SplitLayoutNode.prototype.iterUserWidgets = function () {\n            var children = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this.children, function (child) { return child.iterUserWidgets(); });\n            return new _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ChainIterator(children);\n        };\n        /**\n         * Create an iterator for the selected widgets in the layout tree.\n         */\n        SplitLayoutNode.prototype.iterSelectedWidgets = function () {\n            var children = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this.children, function (child) { return child.iterSelectedWidgets(); });\n            return new _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ChainIterator(children);\n        };\n        /**\n         * Create an iterator for the tab bars in the layout tree.\n         */\n        SplitLayoutNode.prototype.iterTabBars = function () {\n            var children = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this.children, function (child) { return child.iterTabBars(); });\n            return new _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ChainIterator(children);\n        };\n        /**\n         * Create an iterator for the handles in the layout tree.\n         */\n        SplitLayoutNode.prototype.iterHandles = function () {\n            var children = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this.children, function (child) { return child.iterHandles(); });\n            return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.chain)(this.handles, new _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ChainIterator(children));\n        };\n        /**\n         * Find the tab layout node which contains the given widget.\n         */\n        SplitLayoutNode.prototype.findTabNode = function (widget) {\n            for (var i = 0, n = this.children.length; i < n; ++i) {\n                var result = this.children[i].findTabNode(widget);\n                if (result) {\n                    return result;\n                }\n            }\n            return null;\n        };\n        /**\n         * Find the split layout node which contains the given handle.\n         */\n        SplitLayoutNode.prototype.findSplitNode = function (handle) {\n            var index = this.handles.indexOf(handle);\n            if (index !== -1) {\n                return { index: index, node: this };\n            }\n            for (var i = 0, n = this.children.length; i < n; ++i) {\n                var result = this.children[i].findSplitNode(handle);\n                if (result) {\n                    return result;\n                }\n            }\n            return null;\n        };\n        /**\n         * Find the first tab layout node in a layout tree.\n         */\n        SplitLayoutNode.prototype.findFirstTabNode = function () {\n            if (this.children.length === 0) {\n                return null;\n            }\n            return this.children[0].findFirstTabNode();\n        };\n        /**\n         * Find the tab layout node which contains the local point.\n         */\n        SplitLayoutNode.prototype.hitTestTabNodes = function (x, y) {\n            for (var i = 0, n = this.children.length; i < n; ++i) {\n                var result = this.children[i].hitTestTabNodes(x, y);\n                if (result) {\n                    return result;\n                }\n            }\n            return null;\n        };\n        /**\n         * Create a configuration object for the layout tree.\n         */\n        SplitLayoutNode.prototype.createConfig = function () {\n            var orientation = this.orientation;\n            var sizes = this.createNormalizedSizes();\n            var children = this.children.map(function (child) { return child.createConfig(); });\n            return { type: 'split-area', orientation: orientation, children: children, sizes: sizes };\n        };\n        /**\n         * Sync the visibility and orientation of the handles.\n         */\n        SplitLayoutNode.prototype.syncHandles = function () {\n            var _this = this;\n            (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.handles, function (handle, i) {\n                handle.setAttribute('data-orientation', _this.orientation);\n                if (i === _this.handles.length - 1) {\n                    handle.classList.add('lm-mod-hidden');\n                    /* <DEPRECATED> */\n                    handle.classList.add('p-mod-hidden');\n                    /* </DEPRECATED> */\n                }\n                else {\n                    handle.classList.remove('lm-mod-hidden');\n                    /* <DEPRECATED> */\n                    handle.classList.remove('p-mod-hidden');\n                    /* </DEPRECATED> */\n                }\n            });\n        };\n        /**\n         * Hold the current sizes of the box sizers.\n         *\n         * This sets the size hint of each sizer to its current size.\n         */\n        SplitLayoutNode.prototype.holdSizes = function () {\n            (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.sizers, function (sizer) { sizer.sizeHint = sizer.size; });\n        };\n        /**\n         * Recursively hold all of the sizes in the layout tree.\n         *\n         * This ignores the sizers of tab layout nodes.\n         */\n        SplitLayoutNode.prototype.holdAllSizes = function () {\n            (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.children, function (child) { return child.holdAllSizes(); });\n            this.holdSizes();\n        };\n        /**\n         * Normalize the sizes of the split layout node.\n         */\n        SplitLayoutNode.prototype.normalizeSizes = function () {\n            // Bail early if the sizers are empty.\n            var n = this.sizers.length;\n            if (n === 0) {\n                return;\n            }\n            // Hold the current sizes of the sizers.\n            this.holdSizes();\n            // Compute the sum of the sizes.\n            var sum = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.reduce)(this.sizers, function (v, sizer) { return v + sizer.sizeHint; }, 0);\n            // Normalize the sizes based on the sum.\n            if (sum === 0) {\n                (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.sizers, function (sizer) {\n                    sizer.size = sizer.sizeHint = 1 / n;\n                });\n            }\n            else {\n                (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.sizers, function (sizer) {\n                    sizer.size = sizer.sizeHint /= sum;\n                });\n            }\n            // Mark the sizes as normalized.\n            this.normalized = true;\n        };\n        /**\n         * Snap the normalized sizes of the split layout node.\n         */\n        SplitLayoutNode.prototype.createNormalizedSizes = function () {\n            // Bail early if the sizers are empty.\n            var n = this.sizers.length;\n            if (n === 0) {\n                return [];\n            }\n            // Grab the current sizes of the sizers.\n            var sizes = this.sizers.map(function (sizer) { return sizer.size; });\n            // Compute the sum of the sizes.\n            var sum = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.reduce)(sizes, function (v, size) { return v + size; }, 0);\n            // Normalize the sizes based on the sum.\n            if (sum === 0) {\n                (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(sizes, function (size, i) { sizes[i] = 1 / n; });\n            }\n            else {\n                (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(sizes, function (size, i) { sizes[i] = size / sum; });\n            }\n            // Return the normalized sizes.\n            return sizes;\n        };\n        /**\n         * Fit the layout tree.\n         */\n        SplitLayoutNode.prototype.fit = function (spacing, items) {\n            // Compute the required fixed space.\n            var horizontal = this.orientation === 'horizontal';\n            var fixed = Math.max(0, this.children.length - 1) * spacing;\n            // Set up the limit variables.\n            var minWidth = horizontal ? fixed : 0;\n            var minHeight = horizontal ? 0 : fixed;\n            var maxWidth = Infinity;\n            var maxHeight = Infinity;\n            // Fit the children and update the limits.\n            for (var i = 0, n = this.children.length; i < n; ++i) {\n                var limits = this.children[i].fit(spacing, items);\n                if (horizontal) {\n                    minHeight = Math.max(minHeight, limits.minHeight);\n                    minWidth += limits.minWidth;\n                    this.sizers[i].minSize = limits.minWidth;\n                }\n                else {\n                    minWidth = Math.max(minWidth, limits.minWidth);\n                    minHeight += limits.minHeight;\n                    this.sizers[i].minSize = limits.minHeight;\n                }\n            }\n            // Return the computed limits for the layout node.\n            return { minWidth: minWidth, minHeight: minHeight, maxWidth: maxWidth, maxHeight: maxHeight };\n        };\n        /**\n         * Update the layout tree.\n         */\n        SplitLayoutNode.prototype.update = function (left, top, width, height, spacing, items) {\n            // Compute the available layout space.\n            var horizontal = this.orientation === 'horizontal';\n            var fixed = Math.max(0, this.children.length - 1) * spacing;\n            var space = Math.max(0, (horizontal ? width : height) - fixed);\n            // De-normalize the sizes if needed.\n            if (this.normalized) {\n                (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.sizers, function (sizer) { sizer.sizeHint *= space; });\n                this.normalized = false;\n            }\n            // Distribute the layout space to the sizers.\n            BoxEngine.calc(this.sizers, space);\n            // Update the geometry of the child nodes and handles.\n            for (var i = 0, n = this.children.length; i < n; ++i) {\n                var child = this.children[i];\n                var size = this.sizers[i].size;\n                var handleStyle = this.handles[i].style;\n                if (horizontal) {\n                    child.update(left, top, size, height, spacing, items);\n                    left += size;\n                    handleStyle.top = top + \"px\";\n                    handleStyle.left = left + \"px\";\n                    handleStyle.width = spacing + \"px\";\n                    handleStyle.height = height + \"px\";\n                    left += spacing;\n                }\n                else {\n                    child.update(left, top, width, size, spacing, items);\n                    top += size;\n                    handleStyle.top = top + \"px\";\n                    handleStyle.left = left + \"px\";\n                    handleStyle.width = width + \"px\";\n                    handleStyle.height = spacing + \"px\";\n                    top += spacing;\n                }\n            }\n        };\n        return SplitLayoutNode;\n    }());\n    Private.SplitLayoutNode = SplitLayoutNode;\n    function addAria(widget, tabBar) {\n        widget.node.setAttribute('role', 'tabpanel');\n        var renderer = tabBar.renderer;\n        if (renderer instanceof TabBar.Renderer) {\n            var tabId = renderer.createTabKey({ title: widget.title, current: false, zIndex: 0 });\n            widget.node.setAttribute('aria-labelledby', tabId);\n        }\n    }\n    Private.addAria = addAria;\n    function removeAria(widget) {\n        widget.node.removeAttribute('role');\n        widget.node.removeAttribute('aria-labelledby');\n    }\n    Private.removeAria = removeAria;\n    /**\n     * Normalize a tab area config and collect the visited widgets.\n     */\n    function normalizeTabAreaConfig(config, widgetSet) {\n        // Bail early if there is no content.\n        if (config.widgets.length === 0) {\n            return null;\n        }\n        // Setup the filtered widgets array.\n        var widgets = [];\n        // Filter the config for unique widgets.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(config.widgets, function (widget) {\n            if (!widgetSet.has(widget)) {\n                widgetSet.add(widget);\n                widgets.push(widget);\n            }\n        });\n        // Bail if there are no effective widgets.\n        if (widgets.length === 0) {\n            return null;\n        }\n        // Normalize the current index.\n        var index = config.currentIndex;\n        if (index !== -1 && (index < 0 || index >= widgets.length)) {\n            index = 0;\n        }\n        // Return a normalized config object.\n        return { type: 'tab-area', widgets: widgets, currentIndex: index };\n    }\n    /**\n     * Normalize a split area config and collect the visited widgets.\n     */\n    function normalizeSplitAreaConfig(config, widgetSet) {\n        // Set up the result variables.\n        var orientation = config.orientation;\n        var children = [];\n        var sizes = [];\n        // Normalize the config children.\n        for (var i = 0, n = config.children.length; i < n; ++i) {\n            // Normalize the child config.\n            var child = normalizeAreaConfig(config.children[i], widgetSet);\n            // Ignore an empty child.\n            if (!child) {\n                continue;\n            }\n            // Add the child or hoist its content as appropriate.\n            if (child.type === 'tab-area' || child.orientation !== orientation) {\n                children.push(child);\n                sizes.push(Math.abs(config.sizes[i] || 0));\n            }\n            else {\n                children.push.apply(children, child.children);\n                sizes.push.apply(sizes, child.sizes);\n            }\n        }\n        // Bail if there are no effective children.\n        if (children.length === 0) {\n            return null;\n        }\n        // If there is only one effective child, return that child.\n        if (children.length === 1) {\n            return children[0];\n        }\n        // Return a normalized config object.\n        return { type: 'split-area', orientation: orientation, children: children, sizes: sizes };\n    }\n    /**\n     * Convert a normalized tab area config into a layout tree.\n     */\n    function realizeTabAreaConfig(config, renderer) {\n        // Create the tab bar for the layout node.\n        var tabBar = renderer.createTabBar();\n        // Hide each widget and add it to the tab bar.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(config.widgets, function (widget) {\n            widget.hide();\n            tabBar.addTab(widget.title);\n            Private.addAria(widget, tabBar);\n        });\n        // Set the current index of the tab bar.\n        tabBar.currentIndex = config.currentIndex;\n        // Return the new tab layout node.\n        return new TabLayoutNode(tabBar);\n    }\n    /**\n     * Convert a normalized split area config into a layout tree.\n     */\n    function realizeSplitAreaConfig(config, renderer) {\n        // Create the split layout node.\n        var node = new SplitLayoutNode(config.orientation);\n        // Add each child to the layout node.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(config.children, function (child, i) {\n            // Create the child data for the layout node.\n            var childNode = realizeAreaConfig(child, renderer);\n            var sizer = createSizer(config.sizes[i]);\n            var handle = renderer.createHandle();\n            // Add the child data to the layout node.\n            node.children.push(childNode);\n            node.handles.push(handle);\n            node.sizers.push(sizer);\n            // Update the parent for the child node.\n            childNode.parent = node;\n        });\n        // Synchronize the handle state for the layout node.\n        node.syncHandles();\n        // Normalize the sizes for the layout node.\n        node.normalizeSizes();\n        // Return the new layout node.\n        return node;\n    }\n})(Private$9 || (Private$9 = {}));\n\n/**\n * A widget which provides a flexible docking area for widgets.\n */\nvar DockPanel = /** @class */ (function (_super) {\n    __extends(DockPanel, _super);\n    /**\n     * Construct a new dock panel.\n     *\n     * @param options - The options for initializing the panel.\n     */\n    function DockPanel(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this) || this;\n        _this._drag = null;\n        _this._tabsMovable = true;\n        _this._tabsConstrained = false;\n        _this._addButtonEnabled = false;\n        _this._pressData = null;\n        _this._layoutModified = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._addRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this.addClass('lm-DockPanel');\n        /* <DEPRECATED> */\n        _this.addClass('p-DockPanel');\n        /* </DEPRECATED> */\n        _this._mode = options.mode || 'multiple-document';\n        _this._renderer = options.renderer || DockPanel.defaultRenderer;\n        _this._edges = options.edges || Private$a.DEFAULT_EDGES;\n        if (options.tabsMovable !== undefined) {\n            _this._tabsMovable = options.tabsMovable;\n        }\n        if (options.tabsConstrained !== undefined) {\n            _this._tabsConstrained = options.tabsConstrained;\n        }\n        if (options.addButtonEnabled !== undefined) {\n            _this._addButtonEnabled = options.addButtonEnabled;\n        }\n        // Toggle the CSS mode attribute.\n        _this.dataset['mode'] = _this._mode;\n        // Create the delegate renderer for the layout.\n        var renderer = {\n            createTabBar: function () { return _this._createTabBar(); },\n            createHandle: function () { return _this._createHandle(); }\n        };\n        // Set up the dock layout for the panel.\n        _this.layout = new DockLayout({ renderer: renderer, spacing: options.spacing });\n        // Set up the overlay drop indicator.\n        _this.overlay = options.overlay || new DockPanel.Overlay();\n        _this.node.appendChild(_this.overlay.node);\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the panel.\n     */\n    DockPanel.prototype.dispose = function () {\n        // Ensure the mouse is released.\n        this._releaseMouse();\n        // Hide the overlay.\n        this.overlay.hide(0);\n        // Cancel a drag if one is in progress.\n        if (this._drag) {\n            this._drag.dispose();\n        }\n        // Dispose of the base class.\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(DockPanel.prototype, \"layoutModified\", {\n        /**\n         * A signal emitted when the layout configuration is modified.\n         *\n         * #### Notes\n         * This signal is emitted whenever the current layout configuration\n         * may have changed.\n         *\n         * This signal is emitted asynchronously in a collapsed fashion, so\n         * that multiple synchronous modifications results in only a single\n         * emit of the signal.\n         */\n        get: function () {\n            return this._layoutModified;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"addRequested\", {\n        /**\n         * A signal emitted when the add button on a tab bar is clicked.\n         *\n         */\n        get: function () {\n            return this._addRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"renderer\", {\n        /**\n         * The renderer used by the dock panel.\n         */\n        get: function () {\n            return this.layout.renderer;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"spacing\", {\n        /**\n         * Get the spacing between the widgets.\n         */\n        get: function () {\n            return this.layout.spacing;\n        },\n        /**\n         * Set the spacing between the widgets.\n         */\n        set: function (value) {\n            this.layout.spacing = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"mode\", {\n        /**\n         * Get the mode for the dock panel.\n         */\n        get: function () {\n            return this._mode;\n        },\n        /**\n         * Set the mode for the dock panel.\n         *\n         * #### Notes\n         * Changing the mode is a destructive operation with respect to the\n         * panel's layout configuration. If layout state must be preserved,\n         * save the current layout config before changing the mode.\n         */\n        set: function (value) {\n            // Bail early if the mode does not change.\n            if (this._mode === value) {\n                return;\n            }\n            // Update the internal mode.\n            this._mode = value;\n            // Toggle the CSS mode attribute.\n            this.dataset['mode'] = value;\n            // Get the layout for the panel.\n            var layout = this.layout;\n            // Configure the layout for the specified mode.\n            switch (value) {\n                case 'multiple-document':\n                    (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(layout.tabBars(), function (tabBar) { tabBar.show(); });\n                    break;\n                case 'single-document':\n                    layout.restoreLayout(Private$a.createSingleDocumentConfig(this));\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n            // Schedule an emit of the layout modified signal.\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"tabsMovable\", {\n        /**\n         * Whether the tabs can be dragged / moved at runtime.\n         */\n        get: function () {\n            return this._tabsMovable;\n        },\n        /**\n         * Enable / Disable draggable / movable tabs.\n         */\n        set: function (value) {\n            this._tabsMovable = value;\n            (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.tabBars(), function (tabbar) { tabbar.tabsMovable = value; });\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"tabsConstrained\", {\n        /**\n         * Whether the tabs are constrained to their source dock panel\n         */\n        get: function () {\n            return this._tabsConstrained;\n        },\n        /**\n         * Constrain/Allow tabs to be dragged outside of this dock panel\n         */\n        set: function (value) {\n            this._tabsConstrained = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"addButtonEnabled\", {\n        /**\n         * Whether the add buttons for each tab bar are enabled.\n         */\n        get: function () {\n            return this._addButtonEnabled;\n        },\n        /**\n         * Set whether the add buttons for each tab bar are enabled.\n         */\n        set: function (value) {\n            this._addButtonEnabled = value;\n            (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this.tabBars(), function (tabbar) { tabbar.addButtonEnabled = value; });\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(DockPanel.prototype, \"isEmpty\", {\n        /**\n         * Whether the dock panel is empty.\n         */\n        get: function () {\n            return this.layout.isEmpty;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Create an iterator over the user widgets in the panel.\n     *\n     * @returns A new iterator over the user widgets in the panel.\n     *\n     * #### Notes\n     * This iterator does not include the generated tab bars.\n     */\n    DockPanel.prototype.widgets = function () {\n        return this.layout.widgets();\n    };\n    /**\n     * Create an iterator over the selected widgets in the panel.\n     *\n     * @returns A new iterator over the selected user widgets.\n     *\n     * #### Notes\n     * This iterator yields the widgets corresponding to the current tab\n     * of each tab bar in the panel.\n     */\n    DockPanel.prototype.selectedWidgets = function () {\n        return this.layout.selectedWidgets();\n    };\n    /**\n     * Create an iterator over the tab bars in the panel.\n     *\n     * @returns A new iterator over the tab bars in the panel.\n     *\n     * #### Notes\n     * This iterator does not include the user widgets.\n     */\n    DockPanel.prototype.tabBars = function () {\n        return this.layout.tabBars();\n    };\n    /**\n     * Create an iterator over the handles in the panel.\n     *\n     * @returns A new iterator over the handles in the panel.\n     */\n    DockPanel.prototype.handles = function () {\n        return this.layout.handles();\n    };\n    /**\n     * Select a specific widget in the dock panel.\n     *\n     * @param widget - The widget of interest.\n     *\n     * #### Notes\n     * This will make the widget the current widget in its tab area.\n     */\n    DockPanel.prototype.selectWidget = function (widget) {\n        // Find the tab bar which contains the widget.\n        var tabBar = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.find)(this.tabBars(), function (bar) {\n            return bar.titles.indexOf(widget.title) !== -1;\n        });\n        // Throw an error if no tab bar is found.\n        if (!tabBar) {\n            throw new Error('Widget is not contained in the dock panel.');\n        }\n        // Ensure the widget is the current widget.\n        tabBar.currentTitle = widget.title;\n    };\n    /**\n     * Activate a specified widget in the dock panel.\n     *\n     * @param widget - The widget of interest.\n     *\n     * #### Notes\n     * This will select and activate the given widget.\n     */\n    DockPanel.prototype.activateWidget = function (widget) {\n        this.selectWidget(widget);\n        widget.activate();\n    };\n    /**\n     * Save the current layout configuration of the dock panel.\n     *\n     * @returns A new config object for the current layout state.\n     *\n     * #### Notes\n     * The return value can be provided to the `restoreLayout` method\n     * in order to restore the layout to its current configuration.\n     */\n    DockPanel.prototype.saveLayout = function () {\n        return this.layout.saveLayout();\n    };\n    /**\n     * Restore the layout to a previously saved configuration.\n     *\n     * @param config - The layout configuration to restore.\n     *\n     * #### Notes\n     * Widgets which currently belong to the layout but which are not\n     * contained in the config will be unparented.\n     *\n     * The dock panel automatically reverts to `'multiple-document'`\n     * mode when a layout config is restored.\n     */\n    DockPanel.prototype.restoreLayout = function (config) {\n        // Reset the mode.\n        this._mode = 'multiple-document';\n        // Restore the layout.\n        this.layout.restoreLayout(config);\n        // Flush the message loop on IE and Edge to prevent flicker.\n        if (_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Platform.IS_EDGE || _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Platform.IS_IE) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.flush();\n        }\n        // Schedule an emit of the layout modified signal.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n    };\n    /**\n     * Add a widget to the dock panel.\n     *\n     * @param widget - The widget to add to the dock panel.\n     *\n     * @param options - The additional options for adding the widget.\n     *\n     * #### Notes\n     * If the panel is in single document mode, the options are ignored\n     * and the widget is always added as tab in the hidden tab bar.\n     */\n    DockPanel.prototype.addWidget = function (widget, options) {\n        if (options === void 0) { options = {}; }\n        // Add the widget to the layout.\n        if (this._mode === 'single-document') {\n            this.layout.addWidget(widget);\n        }\n        else {\n            this.layout.addWidget(widget, options);\n        }\n        // Schedule an emit of the layout modified signal.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n    };\n    /**\n     * Process a message sent to the widget.\n     *\n     * @param msg - The message sent to the widget.\n     */\n    DockPanel.prototype.processMessage = function (msg) {\n        if (msg.type === 'layout-modified') {\n            this._layoutModified.emit(undefined);\n        }\n        else {\n            _super.prototype.processMessage.call(this, msg);\n        }\n    };\n    /**\n     * Handle the DOM events for the dock panel.\n     *\n     * @param event - The DOM event sent to the panel.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the panel's DOM node. It should\n     * not be called directly by user code.\n     */\n    DockPanel.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'lm-dragenter':\n                this._evtDragEnter(event);\n                break;\n            case 'lm-dragleave':\n                this._evtDragLeave(event);\n                break;\n            case 'lm-dragover':\n                this._evtDragOver(event);\n                break;\n            case 'lm-drop':\n                this._evtDrop(event);\n                break;\n            case 'mousedown':\n                this._evtMouseDown(event);\n                break;\n            case 'mousemove':\n                this._evtMouseMove(event);\n                break;\n            case 'mouseup':\n                this._evtMouseUp(event);\n                break;\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'contextmenu':\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    DockPanel.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('lm-dragenter', this);\n        this.node.addEventListener('lm-dragleave', this);\n        this.node.addEventListener('lm-dragover', this);\n        this.node.addEventListener('lm-drop', this);\n        this.node.addEventListener('mousedown', this);\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    DockPanel.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('lm-dragenter', this);\n        this.node.removeEventListener('lm-dragleave', this);\n        this.node.removeEventListener('lm-dragover', this);\n        this.node.removeEventListener('lm-drop', this);\n        this.node.removeEventListener('mousedown', this);\n        this._releaseMouse();\n    };\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    DockPanel.prototype.onChildAdded = function (msg) {\n        // Ignore the generated tab bars.\n        if (Private$a.isGeneratedTabBarProperty.get(msg.child)) {\n            return;\n        }\n        // Add the widget class to the child.\n        msg.child.addClass('lm-DockPanel-widget');\n        /* <DEPRECATED> */\n        msg.child.addClass('p-DockPanel-widget');\n        /* </DEPRECATED> */\n    };\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    DockPanel.prototype.onChildRemoved = function (msg) {\n        // Ignore the generated tab bars.\n        if (Private$a.isGeneratedTabBarProperty.get(msg.child)) {\n            return;\n        }\n        // Remove the widget class from the child.\n        msg.child.removeClass('lm-DockPanel-widget');\n        /* <DEPRECATED> */\n        msg.child.removeClass('p-DockPanel-widget');\n        /* </DEPRECATED> */\n        // Schedule an emit of the layout modified signal.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n    };\n    /**\n     * Handle the `'lm-dragenter'` event for the dock panel.\n     */\n    DockPanel.prototype._evtDragEnter = function (event) {\n        // If the factory mime type is present, mark the event as\n        // handled in order to get the rest of the drag events.\n        if (event.mimeData.hasData('application/vnd.lumino.widget-factory')) {\n            event.preventDefault();\n            event.stopPropagation();\n        }\n    };\n    /**\n     * Handle the `'lm-dragleave'` event for the dock panel.\n     */\n    DockPanel.prototype._evtDragLeave = function (event) {\n        // Mark the event as handled.\n        event.preventDefault();\n        event.stopPropagation();\n        // The new target might be a descendant, so we might still handle the drop.\n        // Hide asynchronously so that if a lm-dragover event bubbles up to us, the\n        // hide is cancelled by the lm-dragover handler's show overlay logic.\n        this.overlay.hide(1);\n    };\n    /**\n     * Handle the `'lm-dragover'` event for the dock panel.\n     */\n    DockPanel.prototype._evtDragOver = function (event) {\n        // Mark the event as handled.\n        event.preventDefault();\n        event.stopPropagation();\n        // Show the drop indicator overlay and update the drop\n        // action based on the drop target zone under the mouse.\n        if ((this._tabsConstrained && event.source !== this) || this._showOverlay(event.clientX, event.clientY) === 'invalid') {\n            event.dropAction = 'none';\n        }\n        else {\n            event.dropAction = event.proposedAction;\n        }\n    };\n    /**\n     * Handle the `'lm-drop'` event for the dock panel.\n     */\n    DockPanel.prototype._evtDrop = function (event) {\n        // Mark the event as handled.\n        event.preventDefault();\n        event.stopPropagation();\n        // Hide the drop indicator overlay.\n        this.overlay.hide(0);\n        // Bail if the proposed action is to do nothing.\n        if (event.proposedAction === 'none') {\n            event.dropAction = 'none';\n            return;\n        }\n        // Find the drop target under the mouse.\n        var clientX = event.clientX, clientY = event.clientY;\n        var _a = Private$a.findDropTarget(this, clientX, clientY, this._edges), zone = _a.zone, target = _a.target;\n        // Bail if the drop zone is invalid.\n        if (zone === 'invalid') {\n            event.dropAction = 'none';\n            return;\n        }\n        // Bail if the factory mime type has invalid data.\n        var mimeData = event.mimeData;\n        var factory = mimeData.getData('application/vnd.lumino.widget-factory');\n        if (typeof factory !== 'function') {\n            event.dropAction = 'none';\n            return;\n        }\n        // Bail if the factory does not produce a widget.\n        var widget = factory();\n        if (!(widget instanceof Widget)) {\n            event.dropAction = 'none';\n            return;\n        }\n        // Bail if the widget is an ancestor of the dock panel.\n        if (widget.contains(this)) {\n            event.dropAction = 'none';\n            return;\n        }\n        // Find the reference widget for the drop target.\n        var ref = target ? Private$a.getDropRef(target.tabBar) : null;\n        // Add the widget according to the indicated drop zone.\n        switch (zone) {\n            case 'root-all':\n                this.addWidget(widget);\n                break;\n            case 'root-top':\n                this.addWidget(widget, { mode: 'split-top' });\n                break;\n            case 'root-left':\n                this.addWidget(widget, { mode: 'split-left' });\n                break;\n            case 'root-right':\n                this.addWidget(widget, { mode: 'split-right' });\n                break;\n            case 'root-bottom':\n                this.addWidget(widget, { mode: 'split-bottom' });\n                break;\n            case 'widget-all':\n                this.addWidget(widget, { mode: 'tab-after', ref: ref });\n                break;\n            case 'widget-top':\n                this.addWidget(widget, { mode: 'split-top', ref: ref });\n                break;\n            case 'widget-left':\n                this.addWidget(widget, { mode: 'split-left', ref: ref });\n                break;\n            case 'widget-right':\n                this.addWidget(widget, { mode: 'split-right', ref: ref });\n                break;\n            case 'widget-bottom':\n                this.addWidget(widget, { mode: 'split-bottom', ref: ref });\n                break;\n            case 'widget-tab':\n                this.addWidget(widget, { mode: 'tab-after', ref: ref });\n                break;\n            default:\n                throw 'unreachable';\n        }\n        // Accept the proposed drop action.\n        event.dropAction = event.proposedAction;\n        // Activate the dropped widget.\n        this.activateWidget(widget);\n    };\n    /**\n     * Handle the `'keydown'` event for the dock panel.\n     */\n    DockPanel.prototype._evtKeyDown = function (event) {\n        // Stop input events during drag.\n        event.preventDefault();\n        event.stopPropagation();\n        // Release the mouse if `Escape` is pressed.\n        if (event.keyCode === 27) {\n            // Finalize the mouse release.\n            this._releaseMouse();\n            // Schedule an emit of the layout modified signal.\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n        }\n    };\n    /**\n     * Handle the `'mousedown'` event for the dock panel.\n     */\n    DockPanel.prototype._evtMouseDown = function (event) {\n        // Do nothing if the left mouse button is not pressed.\n        if (event.button !== 0) {\n            return;\n        }\n        // Find the handle which contains the mouse target, if any.\n        var layout = this.layout;\n        var target = event.target;\n        var handle = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.find)(layout.handles(), function (handle) { return handle.contains(target); });\n        if (!handle) {\n            return;\n        }\n        // Stop the event when a handle is pressed.\n        event.preventDefault();\n        event.stopPropagation();\n        // Add the extra document listeners.\n        document.addEventListener('keydown', this, true);\n        document.addEventListener('mouseup', this, true);\n        document.addEventListener('mousemove', this, true);\n        document.addEventListener('contextmenu', this, true);\n        // Compute the offset deltas for the handle press.\n        var rect = handle.getBoundingClientRect();\n        var deltaX = event.clientX - rect.left;\n        var deltaY = event.clientY - rect.top;\n        // Override the cursor and store the press data.\n        var style = window.getComputedStyle(handle);\n        var override = _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__.Drag.overrideCursor(style.cursor);\n        this._pressData = { handle: handle, deltaX: deltaX, deltaY: deltaY, override: override };\n    };\n    /**\n     * Handle the `'mousemove'` event for the dock panel.\n     */\n    DockPanel.prototype._evtMouseMove = function (event) {\n        // Bail early if no drag is in progress.\n        if (!this._pressData) {\n            return;\n        }\n        // Stop the event when dragging a handle.\n        event.preventDefault();\n        event.stopPropagation();\n        // Compute the desired offset position for the handle.\n        var rect = this.node.getBoundingClientRect();\n        var xPos = event.clientX - rect.left - this._pressData.deltaX;\n        var yPos = event.clientY - rect.top - this._pressData.deltaY;\n        // Set the handle as close to the desired position as possible.\n        var layout = this.layout;\n        layout.moveHandle(this._pressData.handle, xPos, yPos);\n    };\n    /**\n     * Handle the `'mouseup'` event for the dock panel.\n     */\n    DockPanel.prototype._evtMouseUp = function (event) {\n        // Do nothing if the left mouse button is not released.\n        if (event.button !== 0) {\n            return;\n        }\n        // Stop the event when releasing a handle.\n        event.preventDefault();\n        event.stopPropagation();\n        // Finalize the mouse release.\n        this._releaseMouse();\n        // Schedule an emit of the layout modified signal.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n    };\n    /**\n     * Release the mouse grab for the dock panel.\n     */\n    DockPanel.prototype._releaseMouse = function () {\n        // Bail early if no drag is in progress.\n        if (!this._pressData) {\n            return;\n        }\n        // Clear the override cursor.\n        this._pressData.override.dispose();\n        this._pressData = null;\n        // Remove the extra document listeners.\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('mouseup', this, true);\n        document.removeEventListener('mousemove', this, true);\n        document.removeEventListener('contextmenu', this, true);\n    };\n    /**\n     * Show the overlay indicator at the given client position.\n     *\n     * Returns the drop zone at the specified client position.\n     *\n     * #### Notes\n     * If the position is not over a valid zone, the overlay is hidden.\n     */\n    DockPanel.prototype._showOverlay = function (clientX, clientY) {\n        // Find the dock target for the given client position.\n        var _a = Private$a.findDropTarget(this, clientX, clientY, this._edges), zone = _a.zone, target = _a.target;\n        // If the drop zone is invalid, hide the overlay and bail.\n        if (zone === 'invalid') {\n            this.overlay.hide(100);\n            return zone;\n        }\n        // Setup the variables needed to compute the overlay geometry.\n        var top;\n        var left;\n        var right;\n        var bottom;\n        var box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.node); // TODO cache this?\n        var rect = this.node.getBoundingClientRect();\n        // Compute the overlay geometry based on the dock zone.\n        switch (zone) {\n            case 'root-all':\n                top = box.paddingTop;\n                left = box.paddingLeft;\n                right = box.paddingRight;\n                bottom = box.paddingBottom;\n                break;\n            case 'root-top':\n                top = box.paddingTop;\n                left = box.paddingLeft;\n                right = box.paddingRight;\n                bottom = rect.height * Private$a.GOLDEN_RATIO;\n                break;\n            case 'root-left':\n                top = box.paddingTop;\n                left = box.paddingLeft;\n                right = rect.width * Private$a.GOLDEN_RATIO;\n                bottom = box.paddingBottom;\n                break;\n            case 'root-right':\n                top = box.paddingTop;\n                left = rect.width * Private$a.GOLDEN_RATIO;\n                right = box.paddingRight;\n                bottom = box.paddingBottom;\n                break;\n            case 'root-bottom':\n                top = rect.height * Private$a.GOLDEN_RATIO;\n                left = box.paddingLeft;\n                right = box.paddingRight;\n                bottom = box.paddingBottom;\n                break;\n            case 'widget-all':\n                top = target.top;\n                left = target.left;\n                right = target.right;\n                bottom = target.bottom;\n                break;\n            case 'widget-top':\n                top = target.top;\n                left = target.left;\n                right = target.right;\n                bottom = target.bottom + target.height / 2;\n                break;\n            case 'widget-left':\n                top = target.top;\n                left = target.left;\n                right = target.right + target.width / 2;\n                bottom = target.bottom;\n                break;\n            case 'widget-right':\n                top = target.top;\n                left = target.left + target.width / 2;\n                right = target.right;\n                bottom = target.bottom;\n                break;\n            case 'widget-bottom':\n                top = target.top + target.height / 2;\n                left = target.left;\n                right = target.right;\n                bottom = target.bottom;\n                break;\n            case 'widget-tab':\n                var tabHeight = target.tabBar.node.getBoundingClientRect().height;\n                top = target.top;\n                left = target.left;\n                right = target.right;\n                bottom = target.bottom + target.height - tabHeight;\n                break;\n            default:\n                throw 'unreachable';\n        }\n        // Show the overlay with the computed geometry.\n        this.overlay.show({ top: top, left: left, right: right, bottom: bottom });\n        // Finally, return the computed drop zone.\n        return zone;\n    };\n    /**\n     * Create a new tab bar for use by the panel.\n     */\n    DockPanel.prototype._createTabBar = function () {\n        // Create the tab bar.\n        var tabBar = this._renderer.createTabBar();\n        // Set the generated tab bar property for the tab bar.\n        Private$a.isGeneratedTabBarProperty.set(tabBar, true);\n        // Hide the tab bar when in single document mode.\n        if (this._mode === 'single-document') {\n            tabBar.hide();\n        }\n        // Enforce necessary tab bar behavior.\n        // TODO do we really want to enforce *all* of these?\n        tabBar.tabsMovable = this._tabsMovable;\n        tabBar.allowDeselect = false;\n        tabBar.addButtonEnabled = this._addButtonEnabled;\n        tabBar.removeBehavior = 'select-previous-tab';\n        tabBar.insertBehavior = 'select-tab-if-needed';\n        // Connect the signal handlers for the tab bar.\n        tabBar.tabMoved.connect(this._onTabMoved, this);\n        tabBar.currentChanged.connect(this._onCurrentChanged, this);\n        tabBar.tabCloseRequested.connect(this._onTabCloseRequested, this);\n        tabBar.tabDetachRequested.connect(this._onTabDetachRequested, this);\n        tabBar.tabActivateRequested.connect(this._onTabActivateRequested, this);\n        tabBar.addRequested.connect(this._onTabAddRequested, this);\n        // Return the initialized tab bar.\n        return tabBar;\n    };\n    /**\n     * Create a new handle for use by the panel.\n     */\n    DockPanel.prototype._createHandle = function () {\n        return this._renderer.createHandle();\n    };\n    /**\n     * Handle the `tabMoved` signal from a tab bar.\n     */\n    DockPanel.prototype._onTabMoved = function () {\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n    };\n    /**\n     * Handle the `currentChanged` signal from a tab bar.\n     */\n    DockPanel.prototype._onCurrentChanged = function (sender, args) {\n        // Extract the previous and current title from the args.\n        var previousTitle = args.previousTitle, currentTitle = args.currentTitle;\n        // Hide the previous widget.\n        if (previousTitle) {\n            previousTitle.owner.hide();\n        }\n        // Show the current widget.\n        if (currentTitle) {\n            currentTitle.owner.show();\n        }\n        // Flush the message loop on IE and Edge to prevent flicker.\n        if (_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Platform.IS_EDGE || _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Platform.IS_IE) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.flush();\n        }\n        // Schedule an emit of the layout modified signal.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.postMessage(this, Private$a.LayoutModified);\n    };\n    /**\n     * Handle the `addRequested` signal from a tab bar.\n     */\n    DockPanel.prototype._onTabAddRequested = function (sender) {\n        this._addRequested.emit(sender);\n    };\n    /**\n     * Handle the `tabActivateRequested` signal from a tab bar.\n     */\n    DockPanel.prototype._onTabActivateRequested = function (sender, args) {\n        args.title.owner.activate();\n    };\n    /**\n     * Handle the `tabCloseRequested` signal from a tab bar.\n     */\n    DockPanel.prototype._onTabCloseRequested = function (sender, args) {\n        args.title.owner.close();\n    };\n    /**\n     * Handle the `tabDetachRequested` signal from a tab bar.\n     */\n    DockPanel.prototype._onTabDetachRequested = function (sender, args) {\n        var _this = this;\n        // Do nothing if a drag is already in progress.\n        if (this._drag) {\n            return;\n        }\n        // Release the tab bar's hold on the mouse.\n        sender.releaseMouse();\n        // Extract the data from the args.\n        var title = args.title, tab = args.tab, clientX = args.clientX, clientY = args.clientY;\n        // Setup the mime data for the drag operation.\n        var mimeData = new _lumino_coreutils__WEBPACK_IMPORTED_MODULE_5__.MimeData();\n        var factory = function () { return title.owner; };\n        mimeData.setData('application/vnd.lumino.widget-factory', factory);\n        // Create the drag image for the drag operation.\n        var dragImage = tab.cloneNode(true);\n        // Create the drag object to manage the drag-drop operation.\n        this._drag = new _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__.Drag({\n            mimeData: mimeData, dragImage: dragImage,\n            proposedAction: 'move',\n            supportedActions: 'move',\n            source: this\n        });\n        // Hide the tab node in the original tab.\n        tab.classList.add('lm-mod-hidden');\n        /* <DEPRECATED> */\n        tab.classList.add('p-mod-hidden');\n        // Create the cleanup callback.\n        var cleanup = (function () {\n            _this._drag = null;\n            tab.classList.remove('lm-mod-hidden');\n            /* <DEPRECATED> */\n            tab.classList.remove('p-mod-hidden');\n        });\n        // Start the drag operation and cleanup when done.\n        this._drag.start(clientX, clientY).then(cleanup);\n    };\n    return DockPanel;\n}(Widget));\n/**\n * The namespace for the `DockPanel` class statics.\n */\n(function (DockPanel) {\n    /**\n     * A concrete implementation of `IOverlay`.\n     *\n     * This is the default overlay implementation for a dock panel.\n     */\n    var Overlay = /** @class */ (function () {\n        /**\n         * Construct a new overlay.\n         */\n        function Overlay() {\n            this._timer = -1;\n            this._hidden = true;\n            this.node = document.createElement('div');\n            this.node.classList.add('lm-DockPanel-overlay');\n            this.node.classList.add('lm-mod-hidden');\n            /* <DEPRECATED> */\n            this.node.classList.add('p-DockPanel-overlay');\n            this.node.classList.add('p-mod-hidden');\n            this.node.style.position = 'absolute';\n        }\n        /**\n         * Show the overlay using the given overlay geometry.\n         *\n         * @param geo - The desired geometry for the overlay.\n         */\n        Overlay.prototype.show = function (geo) {\n            // Update the position of the overlay.\n            var style = this.node.style;\n            style.top = geo.top + \"px\";\n            style.left = geo.left + \"px\";\n            style.right = geo.right + \"px\";\n            style.bottom = geo.bottom + \"px\";\n            // Clear any pending hide timer.\n            clearTimeout(this._timer);\n            this._timer = -1;\n            // If the overlay is already visible, we're done.\n            if (!this._hidden) {\n                return;\n            }\n            // Clear the hidden flag.\n            this._hidden = false;\n            // Finally, show the overlay.\n            this.node.classList.remove('lm-mod-hidden');\n            /* <DEPRECATED> */\n            this.node.classList.remove('p-mod-hidden');\n        };\n        /**\n         * Hide the overlay node.\n         *\n         * @param delay - The delay (in ms) before hiding the overlay.\n         *   A delay value <= 0 will hide the overlay immediately.\n         */\n        Overlay.prototype.hide = function (delay) {\n            var _this = this;\n            // Do nothing if the overlay is already hidden.\n            if (this._hidden) {\n                return;\n            }\n            // Hide immediately if the delay is <= 0.\n            if (delay <= 0) {\n                clearTimeout(this._timer);\n                this._timer = -1;\n                this._hidden = true;\n                this.node.classList.add('lm-mod-hidden');\n                /* <DEPRECATED> */\n                this.node.classList.add('p-mod-hidden');\n                return;\n            }\n            // Do nothing if a hide is already pending.\n            if (this._timer !== -1) {\n                return;\n            }\n            // Otherwise setup the hide timer.\n            this._timer = window.setTimeout(function () {\n                _this._timer = -1;\n                _this._hidden = true;\n                _this.node.classList.add('lm-mod-hidden');\n                /* <DEPRECATED> */\n                _this.node.classList.add('p-mod-hidden');\n            }, delay);\n        };\n        return Overlay;\n    }());\n    DockPanel.Overlay = Overlay;\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    var Renderer = /** @class */ (function () {\n        function Renderer() {\n        }\n        /**\n         * Create a new tab bar for use with a dock panel.\n         *\n         * @returns A new tab bar for a dock panel.\n         */\n        Renderer.prototype.createTabBar = function () {\n            var bar = new TabBar();\n            bar.addClass('lm-DockPanel-tabBar');\n            /* <DEPRECATED> */\n            bar.addClass('p-DockPanel-tabBar');\n            /* </DEPRECATED> */\n            return bar;\n        };\n        /**\n         * Create a new handle node for use with a dock panel.\n         *\n         * @returns A new handle node for a dock panel.\n         */\n        Renderer.prototype.createHandle = function () {\n            var handle = document.createElement('div');\n            handle.className = 'lm-DockPanel-handle';\n            /* <DEPRECATED> */\n            handle.classList.add('p-DockPanel-handle');\n            return handle;\n        };\n        return Renderer;\n    }());\n    DockPanel.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    DockPanel.defaultRenderer = new Renderer();\n})(DockPanel || (DockPanel = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$a;\n(function (Private) {\n    /**\n     * A fraction used for sizing root panels; ~= `1 / golden_ratio`.\n     */\n    Private.GOLDEN_RATIO = 0.618;\n    /**\n     * The default sizes for the edge drop zones, in pixels.\n     */\n    Private.DEFAULT_EDGES = {\n        /**\n         * The size of the top edge dock zone for the root panel, in pixels.\n         * This is different from the others to distinguish between the top\n         * tab bar and the top root zone.\n         */\n        top: 12,\n        /**\n         * The size of the edge dock zone for the root panel, in pixels.\n         */\n        right: 40,\n        /**\n         * The size of the edge dock zone for the root panel, in pixels.\n         */\n        bottom: 40,\n        /**\n         * The size of the edge dock zone for the root panel, in pixels.\n         */\n        left: 40\n    };\n    /**\n     * A singleton `'layout-modified'` conflatable message.\n     */\n    Private.LayoutModified = new _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.ConflatableMessage('layout-modified');\n    /**\n     * An attached property used to track generated tab bars.\n     */\n    Private.isGeneratedTabBarProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'isGeneratedTabBar',\n        create: function () { return false; }\n    });\n    /**\n     * Create a single document config for the widgets in a dock panel.\n     */\n    function createSingleDocumentConfig(panel) {\n        // Return an empty config if the panel is empty.\n        if (panel.isEmpty) {\n            return { main: null };\n        }\n        // Get a flat array of the widgets in the panel.\n        var widgets = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.toArray)(panel.widgets());\n        // Get the first selected widget in the panel.\n        var selected = panel.selectedWidgets().next();\n        // Compute the current index for the new config.\n        var currentIndex = selected ? widgets.indexOf(selected) : -1;\n        // Return the single document config.\n        return { main: { type: 'tab-area', widgets: widgets, currentIndex: currentIndex } };\n    }\n    Private.createSingleDocumentConfig = createSingleDocumentConfig;\n    /**\n     * Find the drop target at the given client position.\n     */\n    function findDropTarget(panel, clientX, clientY, edges) {\n        // Bail if the mouse is not over the dock panel.\n        if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(panel.node, clientX, clientY)) {\n            return { zone: 'invalid', target: null };\n        }\n        // Look up the layout for the panel.\n        var layout = panel.layout;\n        // If the layout is empty, indicate the entire root drop zone.\n        if (layout.isEmpty) {\n            return { zone: 'root-all', target: null };\n        }\n        // Test the edge zones when in multiple document mode.\n        if (panel.mode === 'multiple-document') {\n            // Get the client rect for the dock panel.\n            var panelRect = panel.node.getBoundingClientRect();\n            // Compute the distance to each edge of the panel.\n            var pl = clientX - panelRect.left + 1;\n            var pt = clientY - panelRect.top + 1;\n            var pr = panelRect.right - clientX;\n            var pb = panelRect.bottom - clientY;\n            // Find the minimum distance to an edge.\n            var pd = Math.min(pt, pr, pb, pl);\n            // Return a root zone if the mouse is within an edge.\n            switch (pd) {\n                case pt:\n                    if (pt < edges.top) {\n                        return { zone: 'root-top', target: null };\n                    }\n                    break;\n                case pr:\n                    if (pr < edges.right) {\n                        return { zone: 'root-right', target: null };\n                    }\n                    break;\n                case pb:\n                    if (pb < edges.bottom) {\n                        return { zone: 'root-bottom', target: null };\n                    }\n                    break;\n                case pl:\n                    if (pl < edges.left) {\n                        return { zone: 'root-left', target: null };\n                    }\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n        }\n        // Hit test the dock layout at the given client position.\n        var target = layout.hitTestTabAreas(clientX, clientY);\n        // Bail if no target area was found.\n        if (!target) {\n            return { zone: 'invalid', target: null };\n        }\n        // Return the whole tab area when in single document mode.\n        if (panel.mode === 'single-document') {\n            return { zone: 'widget-all', target: target };\n        }\n        // Compute the distance to each edge of the tab area.\n        var al = target.x - target.left + 1;\n        var at = target.y - target.top + 1;\n        var ar = target.left + target.width - target.x;\n        var ab = target.top + target.height - target.y;\n        var tabHeight = target.tabBar.node.getBoundingClientRect().height;\n        if (at < tabHeight) {\n            return { zone: 'widget-tab', target: target };\n        }\n        // Get the X and Y edge sizes for the area.\n        var rx = Math.round(target.width / 3);\n        var ry = Math.round(target.height / 3);\n        // If the mouse is not within an edge, indicate the entire area.\n        if (al > rx && ar > rx && at > ry && ab > ry) {\n            return { zone: 'widget-all', target: target };\n        }\n        // Scale the distances by the slenderness ratio.\n        al /= rx;\n        at /= ry;\n        ar /= rx;\n        ab /= ry;\n        // Find the minimum distance to the area edge.\n        var ad = Math.min(al, at, ar, ab);\n        // Find the widget zone for the area edge.\n        var zone;\n        switch (ad) {\n            case al:\n                zone = 'widget-left';\n                break;\n            case at:\n                zone = 'widget-top';\n                break;\n            case ar:\n                zone = 'widget-right';\n                break;\n            case ab:\n                zone = 'widget-bottom';\n                break;\n            default:\n                throw 'unreachable';\n        }\n        // Return the final drop target.\n        return { zone: zone, target: target };\n    }\n    Private.findDropTarget = findDropTarget;\n    /**\n     * Get the drop reference widget for a tab bar.\n     */\n    function getDropRef(tabBar) {\n        if (tabBar.titles.length === 0) {\n            return null;\n        }\n        if (tabBar.currentTitle) {\n            return tabBar.currentTitle.owner;\n        }\n        return tabBar.titles[tabBar.titles.length - 1].owner;\n    }\n    Private.getDropRef = getDropRef;\n})(Private$a || (Private$a = {}));\n\n// Copyright (c) Jupyter Development Team.\n/**\n * A class which tracks focus among a set of widgets.\n *\n * This class is useful when code needs to keep track of the most\n * recently focused widget(s) among a set of related widgets.\n */\nvar FocusTracker = /** @class */ (function () {\n    /**\n     * Construct a new focus tracker.\n     */\n    function FocusTracker() {\n        this._counter = 0;\n        this._widgets = [];\n        this._activeWidget = null;\n        this._currentWidget = null;\n        this._numbers = new Map();\n        this._nodes = new Map();\n        this._activeChanged = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(this);\n        this._currentChanged = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(this);\n    }\n    /**\n     * Dispose of the resources held by the tracker.\n     */\n    FocusTracker.prototype.dispose = function () {\n        var _this = this;\n        // Do nothing if the tracker is already disposed.\n        if (this._counter < 0) {\n            return;\n        }\n        // Mark the tracker as disposed.\n        this._counter = -1;\n        // Clear the connections for the tracker.\n        _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal.clearData(this);\n        // Remove all event listeners.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this._widgets, function (w) {\n            w.node.removeEventListener('focus', _this, true);\n            w.node.removeEventListener('blur', _this, true);\n        });\n        // Clear the internal data structures.\n        this._activeWidget = null;\n        this._currentWidget = null;\n        this._nodes.clear();\n        this._numbers.clear();\n        this._widgets.length = 0;\n    };\n    Object.defineProperty(FocusTracker.prototype, \"currentChanged\", {\n        /**\n         * A signal emitted when the current widget has changed.\n         */\n        get: function () {\n            return this._currentChanged;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(FocusTracker.prototype, \"activeChanged\", {\n        /**\n         * A signal emitted when the active widget has changed.\n         */\n        get: function () {\n            return this._activeChanged;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(FocusTracker.prototype, \"isDisposed\", {\n        /**\n         * A flag indicating whether the tracker is disposed.\n         */\n        get: function () {\n            return this._counter < 0;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(FocusTracker.prototype, \"currentWidget\", {\n        /**\n         * The current widget in the tracker.\n         *\n         * #### Notes\n         * The current widget is the widget among the tracked widgets which\n         * has the *descendant node* which has most recently been focused.\n         *\n         * The current widget will not be updated if the node loses focus. It\n         * will only be updated when a different tracked widget gains focus.\n         *\n         * If the current widget is removed from the tracker, the previous\n         * current widget will be restored.\n         *\n         * This behavior is intended to follow a user's conceptual model of\n         * a semantically \"current\" widget, where the \"last thing of type X\"\n         * to be interacted with is the \"current instance of X\", regardless\n         * of whether that instance still has focus.\n         */\n        get: function () {\n            return this._currentWidget;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(FocusTracker.prototype, \"activeWidget\", {\n        /**\n         * The active widget in the tracker.\n         *\n         * #### Notes\n         * The active widget is the widget among the tracked widgets which\n         * has the *descendant node* which is currently focused.\n         */\n        get: function () {\n            return this._activeWidget;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(FocusTracker.prototype, \"widgets\", {\n        /**\n         * A read only array of the widgets being tracked.\n         */\n        get: function () {\n            return this._widgets;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Get the focus number for a particular widget in the tracker.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The focus number for the given widget, or `-1` if the\n     *   widget has not had focus since being added to the tracker, or\n     *   is not contained by the tracker.\n     *\n     * #### Notes\n     * The focus number indicates the relative order in which the widgets\n     * have gained focus. A widget with a larger number has gained focus\n     * more recently than a widget with a smaller number.\n     *\n     * The `currentWidget` will always have the largest focus number.\n     *\n     * All widgets start with a focus number of `-1`, which indicates that\n     * the widget has not been focused since being added to the tracker.\n     */\n    FocusTracker.prototype.focusNumber = function (widget) {\n        var n = this._numbers.get(widget);\n        return n === undefined ? -1 : n;\n    };\n    /**\n     * Test whether the focus tracker contains a given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns `true` if the widget is tracked, `false` otherwise.\n     */\n    FocusTracker.prototype.has = function (widget) {\n        return this._numbers.has(widget);\n    };\n    /**\n     * Add a widget to the focus tracker.\n     *\n     * @param widget - The widget of interest.\n     *\n     * #### Notes\n     * A widget will be automatically removed from the tracker if it\n     * is disposed after being added.\n     *\n     * If the widget is already tracked, this is a no-op.\n     */\n    FocusTracker.prototype.add = function (widget) {\n        // Do nothing if the widget is already tracked.\n        if (this._numbers.has(widget)) {\n            return;\n        }\n        // Test whether the widget has focus.\n        var focused = widget.node.contains(document.activeElement);\n        // Set up the initial focus number.\n        var n = focused ? this._counter++ : -1;\n        // Add the widget to the internal data structures.\n        this._widgets.push(widget);\n        this._numbers.set(widget, n);\n        this._nodes.set(widget.node, widget);\n        // Set up the event listeners. The capturing phase must be used\n        // since the 'focus' and 'blur' events don't bubble and Firefox\n        // doesn't support the 'focusin' or 'focusout' events.\n        widget.node.addEventListener('focus', this, true);\n        widget.node.addEventListener('blur', this, true);\n        // Connect the disposed signal handler.\n        widget.disposed.connect(this._onWidgetDisposed, this);\n        // Set the current and active widgets if needed.\n        if (focused) {\n            this._setWidgets(widget, widget);\n        }\n    };\n    /**\n     * Remove a widget from the focus tracker.\n     *\n     * #### Notes\n     * If the widget is the `currentWidget`, the previous current widget\n     * will become the new `currentWidget`.\n     *\n     * A widget will be automatically removed from the tracker if it\n     * is disposed after being added.\n     *\n     * If the widget is not tracked, this is a no-op.\n     */\n    FocusTracker.prototype.remove = function (widget) {\n        var _this = this;\n        // Bail early if the widget is not tracked.\n        if (!this._numbers.has(widget)) {\n            return;\n        }\n        // Disconnect the disposed signal handler.\n        widget.disposed.disconnect(this._onWidgetDisposed, this);\n        // Remove the event listeners.\n        widget.node.removeEventListener('focus', this, true);\n        widget.node.removeEventListener('blur', this, true);\n        // Remove the widget from the internal data structures.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeFirstOf(this._widgets, widget);\n        this._nodes.delete(widget.node);\n        this._numbers.delete(widget);\n        // Bail early if the widget is not the current widget.\n        if (this._currentWidget !== widget) {\n            return;\n        }\n        // Filter the widgets for those which have had focus.\n        var valid = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.filter)(this._widgets, function (w) { return _this._numbers.get(w) !== -1; });\n        // Get the valid widget with the max focus number.\n        var previous = (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.max)(valid, function (first, second) {\n            var a = _this._numbers.get(first);\n            var b = _this._numbers.get(second);\n            return a - b;\n        }) || null;\n        // Set the current and active widgets.\n        this._setWidgets(previous, null);\n    };\n    /**\n     * Handle the DOM events for the focus tracker.\n     *\n     * @param event - The DOM event sent to the panel.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the tracked nodes. It should\n     * not be called directly by user code.\n     */\n    FocusTracker.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'focus':\n                this._evtFocus(event);\n                break;\n            case 'blur':\n                this._evtBlur(event);\n                break;\n        }\n    };\n    /**\n     * Set the current and active widgets for the tracker.\n     */\n    FocusTracker.prototype._setWidgets = function (current, active) {\n        // Swap the current widget.\n        var oldCurrent = this._currentWidget;\n        this._currentWidget = current;\n        // Swap the active widget.\n        var oldActive = this._activeWidget;\n        this._activeWidget = active;\n        // Emit the `currentChanged` signal if needed.\n        if (oldCurrent !== current) {\n            this._currentChanged.emit({ oldValue: oldCurrent, newValue: current });\n        }\n        // Emit the `activeChanged` signal if needed.\n        if (oldActive !== active) {\n            this._activeChanged.emit({ oldValue: oldActive, newValue: active });\n        }\n    };\n    /**\n     * Handle the `'focus'` event for a tracked widget.\n     */\n    FocusTracker.prototype._evtFocus = function (event) {\n        // Find the widget which gained focus, which is known to exist.\n        var widget = this._nodes.get(event.currentTarget);\n        // Update the focus number if necessary.\n        if (widget !== this._currentWidget) {\n            this._numbers.set(widget, this._counter++);\n        }\n        // Set the current and active widgets.\n        this._setWidgets(widget, widget);\n    };\n    /**\n     * Handle the `'blur'` event for a tracked widget.\n     */\n    FocusTracker.prototype._evtBlur = function (event) {\n        // Find the widget which lost focus, which is known to exist.\n        var widget = this._nodes.get(event.currentTarget);\n        // Get the node which being focused after this blur.\n        var focusTarget = event.relatedTarget;\n        // If no other node is being focused, clear the active widget.\n        if (!focusTarget) {\n            this._setWidgets(this._currentWidget, null);\n            return;\n        }\n        // Bail if the focus widget is not changing.\n        if (widget.node.contains(focusTarget)) {\n            return;\n        }\n        // If no tracked widget is being focused, clear the active widget.\n        if (!(0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.find)(this._widgets, function (w) { return w.node.contains(focusTarget); })) {\n            this._setWidgets(this._currentWidget, null);\n            return;\n        }\n    };\n    /**\n     * Handle the `disposed` signal for a tracked widget.\n     */\n    FocusTracker.prototype._onWidgetDisposed = function (sender) {\n        this.remove(sender);\n    };\n    return FocusTracker;\n}());\n\n/**\n * A layout which arranges its widgets in a grid.\n */\nvar GridLayout = /** @class */ (function (_super) {\n    __extends(GridLayout, _super);\n    /**\n     * Construct a new grid layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    function GridLayout(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, options) || this;\n        _this._dirty = false;\n        _this._rowSpacing = 4;\n        _this._columnSpacing = 4;\n        _this._items = [];\n        _this._rowStarts = [];\n        _this._columnStarts = [];\n        _this._rowSizers = [new BoxSizer()];\n        _this._columnSizers = [new BoxSizer()];\n        _this._box = null;\n        if (options.rowCount !== undefined) {\n            Private$b.reallocSizers(_this._rowSizers, options.rowCount);\n        }\n        if (options.columnCount !== undefined) {\n            Private$b.reallocSizers(_this._columnSizers, options.columnCount);\n        }\n        if (options.rowSpacing !== undefined) {\n            _this._rowSpacing = Private$b.clampValue(options.rowSpacing);\n        }\n        if (options.columnSpacing !== undefined) {\n            _this._columnSpacing = Private$b.clampValue(options.columnSpacing);\n        }\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    GridLayout.prototype.dispose = function () {\n        // Dispose of the widgets and layout items.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this._items, function (item) {\n            var widget = item.widget;\n            item.dispose();\n            widget.dispose();\n        });\n        // Clear the layout state.\n        this._box = null;\n        this._items.length = 0;\n        this._rowStarts.length = 0;\n        this._rowSizers.length = 0;\n        this._columnStarts.length = 0;\n        this._columnSizers.length = 0;\n        // Dispose of the rest of the layout.\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(GridLayout.prototype, \"rowCount\", {\n        /**\n         * Get the number of rows in the layout.\n         */\n        get: function () {\n            return this._rowSizers.length;\n        },\n        /**\n         * Set the number of rows in the layout.\n         *\n         * #### Notes\n         * The minimum row count is `1`.\n         */\n        set: function (value) {\n            // Do nothing if the row count does not change.\n            if (value === this.rowCount) {\n                return;\n            }\n            // Reallocate the row sizers.\n            Private$b.reallocSizers(this._rowSizers, value);\n            // Schedule a fit of the parent.\n            if (this.parent) {\n                this.parent.fit();\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(GridLayout.prototype, \"columnCount\", {\n        /**\n         * Get the number of columns in the layout.\n         */\n        get: function () {\n            return this._columnSizers.length;\n        },\n        /**\n         * Set the number of columns in the layout.\n         *\n         * #### Notes\n         * The minimum column count is `1`.\n         */\n        set: function (value) {\n            // Do nothing if the column count does not change.\n            if (value === this.columnCount) {\n                return;\n            }\n            // Reallocate the column sizers.\n            Private$b.reallocSizers(this._columnSizers, value);\n            // Schedule a fit of the parent.\n            if (this.parent) {\n                this.parent.fit();\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(GridLayout.prototype, \"rowSpacing\", {\n        /**\n         * Get the row spacing for the layout.\n         */\n        get: function () {\n            return this._rowSpacing;\n        },\n        /**\n         * Set the row spacing for the layout.\n         */\n        set: function (value) {\n            // Clamp the spacing to the allowed range.\n            value = Private$b.clampValue(value);\n            // Bail if the spacing does not change\n            if (this._rowSpacing === value) {\n                return;\n            }\n            // Update the internal spacing.\n            this._rowSpacing = value;\n            // Schedule a fit of the parent.\n            if (this.parent) {\n                this.parent.fit();\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(GridLayout.prototype, \"columnSpacing\", {\n        /**\n         * Get the column spacing for the layout.\n         */\n        get: function () {\n            return this._columnSpacing;\n        },\n        /**\n         * Set the col spacing for the layout.\n         */\n        set: function (value) {\n            // Clamp the spacing to the allowed range.\n            value = Private$b.clampValue(value);\n            // Bail if the spacing does not change\n            if (this._columnSpacing === value) {\n                return;\n            }\n            // Update the internal spacing.\n            this._columnSpacing = value;\n            // Schedule a fit of the parent.\n            if (this.parent) {\n                this.parent.fit();\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Get the stretch factor for a specific row.\n     *\n     * @param index - The row index of interest.\n     *\n     * @returns The stretch factor for the row.\n     *\n     * #### Notes\n     * This returns `-1` if the index is out of range.\n     */\n    GridLayout.prototype.rowStretch = function (index) {\n        var sizer = this._rowSizers[index];\n        return sizer ? sizer.stretch : -1;\n    };\n    /**\n     * Set the stretch factor for a specific row.\n     *\n     * @param index - The row index of interest.\n     *\n     * @param value - The stretch factor for the row.\n     *\n     * #### Notes\n     * This is a no-op if the index is out of range.\n     */\n    GridLayout.prototype.setRowStretch = function (index, value) {\n        // Look up the row sizer.\n        var sizer = this._rowSizers[index];\n        // Bail if the index is out of range.\n        if (!sizer) {\n            return;\n        }\n        // Clamp the value to the allowed range.\n        value = Private$b.clampValue(value);\n        // Bail if the stretch does not change.\n        if (sizer.stretch === value) {\n            return;\n        }\n        // Update the sizer stretch.\n        sizer.stretch = value;\n        // Schedule an update of the parent.\n        if (this.parent) {\n            this.parent.update();\n        }\n    };\n    /**\n     * Get the stretch factor for a specific column.\n     *\n     * @param index - The column index of interest.\n     *\n     * @returns The stretch factor for the column.\n     *\n     * #### Notes\n     * This returns `-1` if the index is out of range.\n     */\n    GridLayout.prototype.columnStretch = function (index) {\n        var sizer = this._columnSizers[index];\n        return sizer ? sizer.stretch : -1;\n    };\n    /**\n     * Set the stretch factor for a specific column.\n     *\n     * @param index - The column index of interest.\n     *\n     * @param value - The stretch factor for the column.\n     *\n     * #### Notes\n     * This is a no-op if the index is out of range.\n     */\n    GridLayout.prototype.setColumnStretch = function (index, value) {\n        // Look up the column sizer.\n        var sizer = this._columnSizers[index];\n        // Bail if the index is out of range.\n        if (!sizer) {\n            return;\n        }\n        // Clamp the value to the allowed range.\n        value = Private$b.clampValue(value);\n        // Bail if the stretch does not change.\n        if (sizer.stretch === value) {\n            return;\n        }\n        // Update the sizer stretch.\n        sizer.stretch = value;\n        // Schedule an update of the parent.\n        if (this.parent) {\n            this.parent.update();\n        }\n    };\n    /**\n     * Create an iterator over the widgets in the layout.\n     *\n     * @returns A new iterator over the widgets in the layout.\n     */\n    GridLayout.prototype.iter = function () {\n        return (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.map)(this._items, function (item) { return item.widget; });\n    };\n    /**\n     * Add a widget to the grid layout.\n     *\n     * @param widget - The widget to add to the layout.\n     *\n     * #### Notes\n     * If the widget is already contained in the layout, this is no-op.\n     */\n    GridLayout.prototype.addWidget = function (widget) {\n        // Look up the index for the widget.\n        var i = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this._items, function (it) { return it.widget === widget; });\n        // Bail if the widget is already in the layout.\n        if (i !== -1) {\n            return;\n        }\n        // Add the widget to the layout.\n        this._items.push(new LayoutItem(widget));\n        // Attach the widget to the parent.\n        if (this.parent) {\n            this.attachWidget(widget);\n        }\n    };\n    /**\n     * Remove a widget from the grid layout.\n     *\n     * @param widget - The widget to remove from the layout.\n     *\n     * #### Notes\n     * A widget is automatically removed from the layout when its `parent`\n     * is set to `null`. This method should only be invoked directly when\n     * removing a widget from a layout which has yet to be installed on a\n     * parent widget.\n     *\n     * This method does *not* modify the widget's `parent`.\n     */\n    GridLayout.prototype.removeWidget = function (widget) {\n        // Look up the index for the widget.\n        var i = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this._items, function (it) { return it.widget === widget; });\n        // Bail if the widget is not in the layout.\n        if (i === -1) {\n            return;\n        }\n        // Remove the widget from the layout.\n        var item = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._items, i);\n        // Detach the widget from the parent.\n        if (this.parent) {\n            this.detachWidget(widget);\n        }\n        // Dispose the layout item.\n        item.dispose();\n    };\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    GridLayout.prototype.init = function () {\n        var _this = this;\n        _super.prototype.init.call(this);\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) { _this.attachWidget(widget); });\n    };\n    /**\n     * Attach a widget to the parent's DOM node.\n     *\n     * @param widget - The widget to attach to the parent.\n     */\n    GridLayout.prototype.attachWidget = function (widget) {\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Add the widget's node to the parent.\n        this.parent.node.appendChild(widget.node);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Detach a widget from the parent's DOM node.\n     *\n     * @param widget - The widget to detach from the parent.\n     */\n    GridLayout.prototype.detachWidget = function (widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     */\n    GridLayout.prototype.onBeforeShow = function (msg) {\n        _super.prototype.onBeforeShow.call(this, msg);\n        this.parent.update();\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    GridLayout.prototype.onBeforeAttach = function (msg) {\n        _super.prototype.onBeforeAttach.call(this, msg);\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    GridLayout.prototype.onChildShown = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    GridLayout.prototype.onChildHidden = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    GridLayout.prototype.onResize = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(msg.width, msg.height);\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    GridLayout.prototype.onUpdateRequest = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(-1, -1);\n        }\n    };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     */\n    GridLayout.prototype.onFitRequest = function (msg) {\n        if (this.parent.isAttached) {\n            this._fit();\n        }\n    };\n    /**\n     * Fit the layout to the total size required by the widgets.\n     */\n    GridLayout.prototype._fit = function () {\n        // Reset the min sizes of the sizers.\n        for (var i = 0, n = this.rowCount; i < n; ++i) {\n            this._rowSizers[i].minSize = 0;\n        }\n        for (var i = 0, n = this.columnCount; i < n; ++i) {\n            this._columnSizers[i].minSize = 0;\n        }\n        // Filter for the visible layout items.\n        var items = this._items.filter(function (it) { return !it.isHidden; });\n        // Fit the layout items.\n        for (var i = 0, n = items.length; i < n; ++i) {\n            items[i].fit();\n        }\n        // Get the max row and column index.\n        var maxRow = this.rowCount - 1;\n        var maxCol = this.columnCount - 1;\n        // Sort the items by row span.\n        items.sort(Private$b.rowSpanCmp);\n        // Update the min sizes of the row sizers.\n        for (var i = 0, n = items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = items[i];\n            // Get the row bounds for the item.\n            var config = GridLayout.getCellConfig(item.widget);\n            var r1 = Math.min(config.row, maxRow);\n            var r2 = Math.min(config.row + config.rowSpan - 1, maxRow);\n            // Distribute the minimum height to the sizers as needed.\n            Private$b.distributeMin(this._rowSizers, r1, r2, item.minHeight);\n        }\n        // Sort the items by column span.\n        items.sort(Private$b.columnSpanCmp);\n        // Update the min sizes of the column sizers.\n        for (var i = 0, n = items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = items[i];\n            // Get the column bounds for the item.\n            var config = GridLayout.getCellConfig(item.widget);\n            var c1 = Math.min(config.column, maxCol);\n            var c2 = Math.min(config.column + config.columnSpan - 1, maxCol);\n            // Distribute the minimum width to the sizers as needed.\n            Private$b.distributeMin(this._columnSizers, c1, c2, item.minWidth);\n        }\n        // If no size constraint is needed, just update the parent.\n        if (this.fitPolicy === 'set-no-constraint') {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n            return;\n        }\n        // Set up the computed min size.\n        var minH = maxRow * this._rowSpacing;\n        var minW = maxCol * this._columnSpacing;\n        // Add the sizer minimums to the computed min size.\n        for (var i = 0, n = this.rowCount; i < n; ++i) {\n            minH += this._rowSizers[i].minSize;\n        }\n        for (var i = 0, n = this.columnCount; i < n; ++i) {\n            minW += this._columnSizers[i].minSize;\n        }\n        // Update the box sizing and add it to the computed min size.\n        var box = this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        var style = this.parent.node.style;\n        style.minWidth = minW + \"px\";\n        style.minHeight = minH + \"px\";\n        // Set the dirty flag to ensure only a single update occurs.\n        this._dirty = true;\n        // Notify the ancestor that it should fit immediately. This may\n        // cause a resize of the parent, fulfilling the required update.\n        if (this.parent.parent) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent.parent, Widget.Msg.FitRequest);\n        }\n        // If the dirty flag is still set, the parent was not resized.\n        // Trigger the required update on the parent widget immediately.\n        if (this._dirty) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n        }\n    };\n    /**\n     * Update the layout position and size of the widgets.\n     *\n     * The parent offset dimensions should be `-1` if unknown.\n     */\n    GridLayout.prototype._update = function (offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Measure the parent if the offset dimensions are unknown.\n        if (offsetWidth < 0) {\n            offsetWidth = this.parent.node.offsetWidth;\n        }\n        if (offsetHeight < 0) {\n            offsetHeight = this.parent.node.offsetHeight;\n        }\n        // Ensure the parent box sizing data is computed.\n        if (!this._box) {\n            this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the layout area adjusted for border and padding.\n        var top = this._box.paddingTop;\n        var left = this._box.paddingLeft;\n        var width = offsetWidth - this._box.horizontalSum;\n        var height = offsetHeight - this._box.verticalSum;\n        // Get the max row and column index.\n        var maxRow = this.rowCount - 1;\n        var maxCol = this.columnCount - 1;\n        // Compute the total fixed row and column space.\n        var fixedRowSpace = maxRow * this._rowSpacing;\n        var fixedColSpace = maxCol * this._columnSpacing;\n        // Distribute the available space to the box sizers.\n        BoxEngine.calc(this._rowSizers, Math.max(0, height - fixedRowSpace));\n        BoxEngine.calc(this._columnSizers, Math.max(0, width - fixedColSpace));\n        // Update the row start positions.\n        for (var i = 0, pos = top, n = this.rowCount; i < n; ++i) {\n            this._rowStarts[i] = pos;\n            pos += this._rowSizers[i].size + this._rowSpacing;\n        }\n        // Update the column start positions.\n        for (var i = 0, pos = left, n = this.columnCount; i < n; ++i) {\n            this._columnStarts[i] = pos;\n            pos += this._columnSizers[i].size + this._columnSpacing;\n        }\n        // Update the geometry of the layout items.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Fetch the cell bounds for the widget.\n            var config = GridLayout.getCellConfig(item.widget);\n            var r1 = Math.min(config.row, maxRow);\n            var c1 = Math.min(config.column, maxCol);\n            var r2 = Math.min(config.row + config.rowSpan - 1, maxRow);\n            var c2 = Math.min(config.column + config.columnSpan - 1, maxCol);\n            // Compute the cell geometry.\n            var x = this._columnStarts[c1];\n            var y = this._rowStarts[r1];\n            var w = this._columnStarts[c2] + this._columnSizers[c2].size - x;\n            var h = this._rowStarts[r2] + this._rowSizers[r2].size - y;\n            // Update the geometry of the layout item.\n            item.update(x, y, w, h);\n        }\n    };\n    return GridLayout;\n}(Layout));\n/**\n * The namespace for the `GridLayout` class statics.\n */\n(function (GridLayout) {\n    /**\n     * Get the cell config for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The cell config for the widget.\n     */\n    function getCellConfig(widget) {\n        return Private$b.cellConfigProperty.get(widget);\n    }\n    GridLayout.getCellConfig = getCellConfig;\n    /**\n     * Set the cell config for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the cell config.\n     */\n    function setCellConfig(widget, value) {\n        Private$b.cellConfigProperty.set(widget, Private$b.normalizeConfig(value));\n    }\n    GridLayout.setCellConfig = setCellConfig;\n})(GridLayout || (GridLayout = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$b;\n(function (Private) {\n    /**\n     * The property descriptor for the widget cell config.\n     */\n    Private.cellConfigProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'cellConfig',\n        create: function () { return ({ row: 0, column: 0, rowSpan: 1, columnSpan: 1 }); },\n        changed: onChildCellConfigChanged\n    });\n    /**\n     * Normalize a partial cell config object.\n     */\n    function normalizeConfig(config) {\n        var row = Math.max(0, Math.floor(config.row || 0));\n        var column = Math.max(0, Math.floor(config.column || 0));\n        var rowSpan = Math.max(1, Math.floor(config.rowSpan || 0));\n        var columnSpan = Math.max(1, Math.floor(config.columnSpan || 0));\n        return { row: row, column: column, rowSpan: rowSpan, columnSpan: columnSpan };\n    }\n    Private.normalizeConfig = normalizeConfig;\n    /**\n     * Clamp a value to an integer >= 0.\n     */\n    function clampValue(value) {\n        return Math.max(0, Math.floor(value));\n    }\n    Private.clampValue = clampValue;\n    /**\n     * A sort comparison function for row spans.\n     */\n    function rowSpanCmp(a, b) {\n        var c1 = Private.cellConfigProperty.get(a.widget);\n        var c2 = Private.cellConfigProperty.get(b.widget);\n        return c1.rowSpan - c2.rowSpan;\n    }\n    Private.rowSpanCmp = rowSpanCmp;\n    /**\n     * A sort comparison function for column spans.\n     */\n    function columnSpanCmp(a, b) {\n        var c1 = Private.cellConfigProperty.get(a.widget);\n        var c2 = Private.cellConfigProperty.get(b.widget);\n        return c1.columnSpan - c2.columnSpan;\n    }\n    Private.columnSpanCmp = columnSpanCmp;\n    /**\n     * Reallocate the box sizers for the given grid dimensions.\n     */\n    function reallocSizers(sizers, count) {\n        // Coerce the count to the valid range.\n        count = Math.max(1, Math.floor(count));\n        // Add the missing sizers.\n        while (sizers.length < count) {\n            sizers.push(new BoxSizer());\n        }\n        // Remove the extra sizers.\n        if (sizers.length > count) {\n            sizers.length = count;\n        }\n    }\n    Private.reallocSizers = reallocSizers;\n    /**\n     * Distribute a min size constraint across a range of sizers.\n     */\n    function distributeMin(sizers, i1, i2, minSize) {\n        // Sanity check the indices.\n        if (i2 < i1) {\n            return;\n        }\n        // Handle the simple case of no cell span.\n        if (i1 === i2) {\n            var sizer = sizers[i1];\n            sizer.minSize = Math.max(sizer.minSize, minSize);\n            return;\n        }\n        // Compute the total current min size of the span.\n        var totalMin = 0;\n        for (var i = i1; i <= i2; ++i) {\n            totalMin += sizers[i].minSize;\n        }\n        // Do nothing if the total is greater than the required.\n        if (totalMin >= minSize) {\n            return;\n        }\n        // Compute the portion of the space to allocate to each sizer.\n        var portion = (minSize - totalMin) / (i2 - i1 + 1);\n        // Add the portion to each sizer.\n        for (var i = i1; i <= i2; ++i) {\n            sizers[i].minSize += portion;\n        }\n    }\n    Private.distributeMin = distributeMin;\n    /**\n     * The change handler for the child cell config property.\n     */\n    function onChildCellConfigChanged(child) {\n        if (child.parent && child.parent.layout instanceof GridLayout) {\n            child.parent.fit();\n        }\n    }\n})(Private$b || (Private$b = {}));\n\n/**\n * A widget which displays menus as a canonical menu bar.\n */\nvar MenuBar = /** @class */ (function (_super) {\n    __extends(MenuBar, _super);\n    /**\n     * Construct a new menu bar.\n     *\n     * @param options - The options for initializing the menu bar.\n     */\n    function MenuBar(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, { node: Private$c.createNode() }) || this;\n        _this._activeIndex = -1;\n        _this._menus = [];\n        _this._childMenu = null;\n        _this.addClass('lm-MenuBar');\n        /* <DEPRECATED> */\n        _this.addClass('p-MenuBar');\n        /* </DEPRECATED> */\n        _this.setFlag(Widget.Flag.DisallowLayout);\n        _this.renderer = options.renderer || MenuBar.defaultRenderer;\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the widget.\n     */\n    MenuBar.prototype.dispose = function () {\n        this._closeChildMenu();\n        this._menus.length = 0;\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(MenuBar.prototype, \"childMenu\", {\n        /**\n         * The child menu of the menu bar.\n         *\n         * #### Notes\n         * This will be `null` if the menu bar does not have an open menu.\n         */\n        get: function () {\n            return this._childMenu;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(MenuBar.prototype, \"contentNode\", {\n        /**\n         * Get the menu bar content node.\n         *\n         * #### Notes\n         * This is the node which holds the menu title nodes.\n         *\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-MenuBar-content')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(MenuBar.prototype, \"activeMenu\", {\n        /**\n         * Get the currently active menu.\n         */\n        get: function () {\n            return this._menus[this._activeIndex] || null;\n        },\n        /**\n         * Set the currently active menu.\n         *\n         * #### Notes\n         * If the menu does not exist, the menu will be set to `null`.\n         */\n        set: function (value) {\n            this.activeIndex = value ? this._menus.indexOf(value) : -1;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(MenuBar.prototype, \"activeIndex\", {\n        /**\n         * Get the index of the currently active menu.\n         *\n         * #### Notes\n         * This will be `-1` if no menu is active.\n         */\n        get: function () {\n            return this._activeIndex;\n        },\n        /**\n         * Set the index of the currently active menu.\n         *\n         * #### Notes\n         * If the menu cannot be activated, the index will be set to `-1`.\n         */\n        set: function (value) {\n            // Adjust the value for an out of range index.\n            if (value < 0 || value >= this._menus.length) {\n                value = -1;\n            }\n            // Bail early if the index will not change.\n            if (this._activeIndex === value) {\n                return;\n            }\n            // Update the active index.\n            this._activeIndex = value;\n            // Schedule an update of the items.\n            this.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(MenuBar.prototype, \"menus\", {\n        /**\n         * A read-only array of the menus in the menu bar.\n         */\n        get: function () {\n            return this._menus;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Open the active menu and activate its first menu item.\n     *\n     * #### Notes\n     * If there is no active menu, this is a no-op.\n     */\n    MenuBar.prototype.openActiveMenu = function () {\n        // Bail early if there is no active item.\n        if (this._activeIndex === -1) {\n            return;\n        }\n        // Open the child menu.\n        this._openChildMenu();\n        // Activate the first item in the child menu.\n        if (this._childMenu) {\n            this._childMenu.activeIndex = -1;\n            this._childMenu.activateNextItem();\n        }\n    };\n    /**\n     * Add a menu to the end of the menu bar.\n     *\n     * @param menu - The menu to add to the menu bar.\n     *\n     * #### Notes\n     * If the menu is already added to the menu bar, it will be moved.\n     */\n    MenuBar.prototype.addMenu = function (menu) {\n        this.insertMenu(this._menus.length, menu);\n    };\n    /**\n     * Insert a menu into the menu bar at the specified index.\n     *\n     * @param index - The index at which to insert the menu.\n     *\n     * @param menu - The menu to insert into the menu bar.\n     *\n     * #### Notes\n     * The index will be clamped to the bounds of the menus.\n     *\n     * If the menu is already added to the menu bar, it will be moved.\n     */\n    MenuBar.prototype.insertMenu = function (index, menu) {\n        // Close the child menu before making changes.\n        this._closeChildMenu();\n        // Look up the index of the menu.\n        var i = this._menus.indexOf(menu);\n        // Clamp the insert index to the array bounds.\n        var j = Math.max(0, Math.min(index, this._menus.length));\n        // If the menu is not in the array, insert it.\n        if (i === -1) {\n            // Insert the menu into the array.\n            _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._menus, j, menu);\n            // Add the styling class to the menu.\n            menu.addClass('lm-MenuBar-menu');\n            /* <DEPRECATED> */\n            menu.addClass('p-MenuBar-menu');\n            /* </DEPRECATED> */\n            // Connect to the menu signals.\n            menu.aboutToClose.connect(this._onMenuAboutToClose, this);\n            menu.menuRequested.connect(this._onMenuMenuRequested, this);\n            menu.title.changed.connect(this._onTitleChanged, this);\n            // Schedule an update of the items.\n            this.update();\n            // There is nothing more to do.\n            return;\n        }\n        // Otherwise, the menu exists in the array and should be moved.\n        // Adjust the index if the location is at the end of the array.\n        if (j === this._menus.length) {\n            j--;\n        }\n        // Bail if there is no effective move.\n        if (i === j) {\n            return;\n        }\n        // Move the menu to the new locations.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._menus, i, j);\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Remove a menu from the menu bar.\n     *\n     * @param menu - The menu to remove from the menu bar.\n     *\n     * #### Notes\n     * This is a no-op if the menu is not in the menu bar.\n     */\n    MenuBar.prototype.removeMenu = function (menu) {\n        this.removeMenuAt(this._menus.indexOf(menu));\n    };\n    /**\n     * Remove the menu at a given index from the menu bar.\n     *\n     * @param index - The index of the menu to remove.\n     *\n     * #### Notes\n     * This is a no-op if the index is out of range.\n     */\n    MenuBar.prototype.removeMenuAt = function (index) {\n        // Close the child menu before making changes.\n        this._closeChildMenu();\n        // Remove the menu from the array.\n        var menu = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._menus, index);\n        // Bail if the index is out of range.\n        if (!menu) {\n            return;\n        }\n        // Disconnect from the menu signals.\n        menu.aboutToClose.disconnect(this._onMenuAboutToClose, this);\n        menu.menuRequested.disconnect(this._onMenuMenuRequested, this);\n        menu.title.changed.disconnect(this._onTitleChanged, this);\n        // Remove the styling class from the menu.\n        menu.removeClass('lm-MenuBar-menu');\n        /* <DEPRECATED> */\n        menu.removeClass('p-MenuBar-menu');\n        /* </DEPRECATED> */\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Remove all menus from the menu bar.\n     */\n    MenuBar.prototype.clearMenus = function () {\n        // Bail if there is nothing to remove.\n        if (this._menus.length === 0) {\n            return;\n        }\n        // Close the child menu before making changes.\n        this._closeChildMenu();\n        // Disconnect from the menu signals and remove the styling class.\n        for (var _i = 0, _a = this._menus; _i < _a.length; _i++) {\n            var menu = _a[_i];\n            menu.aboutToClose.disconnect(this._onMenuAboutToClose, this);\n            menu.menuRequested.disconnect(this._onMenuMenuRequested, this);\n            menu.title.changed.disconnect(this._onTitleChanged, this);\n            menu.removeClass('lm-MenuBar-menu');\n            /* <DEPRECATED> */\n            menu.removeClass('p-MenuBar-menu');\n            /* </DEPRECATED> */\n        }\n        // Clear the menus array.\n        this._menus.length = 0;\n        // Schedule an update of the items.\n        this.update();\n    };\n    /**\n     * Handle the DOM events for the menu bar.\n     *\n     * @param event - The DOM event sent to the menu bar.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the menu bar's DOM nodes. It\n     * should not be called directly by user code.\n     */\n    MenuBar.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'mousedown':\n                this._evtMouseDown(event);\n                break;\n            case 'mousemove':\n                this._evtMouseMove(event);\n                break;\n            case 'mouseleave':\n                this._evtMouseLeave(event);\n                break;\n            case 'contextmenu':\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    MenuBar.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('keydown', this);\n        this.node.addEventListener('mousedown', this);\n        this.node.addEventListener('mousemove', this);\n        this.node.addEventListener('mouseleave', this);\n        this.node.addEventListener('contextmenu', this);\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    MenuBar.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('keydown', this);\n        this.node.removeEventListener('mousedown', this);\n        this.node.removeEventListener('mousemove', this);\n        this.node.removeEventListener('mouseleave', this);\n        this.node.removeEventListener('contextmenu', this);\n        this._closeChildMenu();\n    };\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     */\n    MenuBar.prototype.onActivateRequest = function (msg) {\n        if (this.isAttached) {\n            this.node.focus();\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    MenuBar.prototype.onUpdateRequest = function (msg) {\n        var menus = this._menus;\n        var renderer = this.renderer;\n        var activeIndex = this._activeIndex;\n        var content = new Array(menus.length);\n        for (var i = 0, n = menus.length; i < n; ++i) {\n            var title = menus[i].title;\n            var active = i === activeIndex;\n            content[i] = renderer.renderItem({ title: title, active: active });\n        }\n        _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.VirtualDOM.render(content, this.contentNode);\n    };\n    /**\n     * Handle the `'keydown'` event for the menu bar.\n     */\n    MenuBar.prototype._evtKeyDown = function (event) {\n        // A menu bar handles all keydown events.\n        event.preventDefault();\n        event.stopPropagation();\n        // Fetch the key code for the event.\n        var kc = event.keyCode;\n        // Enter, Up Arrow, Down Arrow\n        if (kc === 13 || kc === 38 || kc === 40) {\n            this.openActiveMenu();\n            return;\n        }\n        // Escape\n        if (kc === 27) {\n            this._closeChildMenu();\n            this.activeIndex = -1;\n            this.node.blur();\n            return;\n        }\n        // Left Arrow\n        if (kc === 37) {\n            var i = this._activeIndex;\n            var n = this._menus.length;\n            this.activeIndex = i === 0 ? n - 1 : i - 1;\n            return;\n        }\n        // Right Arrow\n        if (kc === 39) {\n            var i = this._activeIndex;\n            var n = this._menus.length;\n            this.activeIndex = i === n - 1 ? 0 : i + 1;\n            return;\n        }\n        // Get the pressed key character.\n        var key = (0,_lumino_keyboard__WEBPACK_IMPORTED_MODULE_9__.getKeyboardLayout)().keyForKeydownEvent(event);\n        // Bail if the key is not valid.\n        if (!key) {\n            return;\n        }\n        // Search for the next best matching mnemonic item.\n        var start = this._activeIndex + 1;\n        var result = Private$c.findMnemonic(this._menus, key, start);\n        // Handle the requested mnemonic based on the search results.\n        // If exactly one mnemonic is matched, that menu is opened.\n        // Otherwise, the next mnemonic is activated if available,\n        // followed by the auto mnemonic if available.\n        if (result.index !== -1 && !result.multiple) {\n            this.activeIndex = result.index;\n            this.openActiveMenu();\n        }\n        else if (result.index !== -1) {\n            this.activeIndex = result.index;\n        }\n        else if (result.auto !== -1) {\n            this.activeIndex = result.auto;\n        }\n    };\n    /**\n     * Handle the `'mousedown'` event for the menu bar.\n     */\n    MenuBar.prototype._evtMouseDown = function (event) {\n        // Bail if the mouse press was not on the menu bar. This can occur\n        // when the document listener is installed for an active menu bar.\n        if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(this.node, event.clientX, event.clientY)) {\n            return;\n        }\n        // Stop the propagation of the event. Immediate propagation is\n        // also stopped so that an open menu does not handle the event.\n        event.preventDefault();\n        event.stopPropagation();\n        event.stopImmediatePropagation();\n        // Check if the mouse is over one of the menu items.\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this.contentNode.children, function (node) {\n            return _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(node, event.clientX, event.clientY);\n        });\n        // If the press was not on an item, close the child menu.\n        if (index === -1) {\n            this._closeChildMenu();\n            return;\n        }\n        // If the press was not the left mouse button, do nothing further.\n        if (event.button !== 0) {\n            return;\n        }\n        // Otherwise, toggle the open state of the child menu.\n        if (this._childMenu) {\n            this._closeChildMenu();\n            this.activeIndex = index;\n        }\n        else {\n            this.activeIndex = index;\n            this._openChildMenu();\n        }\n    };\n    /**\n     * Handle the `'mousemove'` event for the menu bar.\n     */\n    MenuBar.prototype._evtMouseMove = function (event) {\n        // Check if the mouse is over one of the menu items.\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(this.contentNode.children, function (node) {\n            return _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(node, event.clientX, event.clientY);\n        });\n        // Bail early if the active index will not change.\n        if (index === this._activeIndex) {\n            return;\n        }\n        // Bail early if a child menu is open and the mouse is not over\n        // an item. This allows the child menu to be kept open when the\n        // mouse is over the empty part of the menu bar.\n        if (index === -1 && this._childMenu) {\n            return;\n        }\n        // Update the active index to the hovered item.\n        this.activeIndex = index;\n        // Open the new menu if a menu is already open.\n        if (this._childMenu) {\n            this._openChildMenu();\n        }\n    };\n    /**\n     * Handle the `'mouseleave'` event for the menu bar.\n     */\n    MenuBar.prototype._evtMouseLeave = function (event) {\n        // Reset the active index if there is no open menu.\n        if (!this._childMenu) {\n            this.activeIndex = -1;\n        }\n    };\n    /**\n     * Open the child menu at the active index immediately.\n     *\n     * If a different child menu is already open, it will be closed,\n     * even if there is no active menu.\n     */\n    MenuBar.prototype._openChildMenu = function () {\n        // If there is no active menu, close the current menu.\n        var newMenu = this.activeMenu;\n        if (!newMenu) {\n            this._closeChildMenu();\n            return;\n        }\n        // Bail if there is no effective menu change.\n        var oldMenu = this._childMenu;\n        if (oldMenu === newMenu) {\n            return;\n        }\n        // Swap the internal menu reference.\n        this._childMenu = newMenu;\n        // Close the current menu, or setup for the new menu.\n        if (oldMenu) {\n            oldMenu.close();\n        }\n        else {\n            this.addClass('lm-mod-active');\n            /* <DEPRECATED> */\n            this.addClass('p-mod-active');\n            /* </DEPRECATED> */\n            document.addEventListener('mousedown', this, true);\n        }\n        // Ensure the menu bar is updated and look up the item node.\n        _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);\n        var itemNode = this.contentNode.children[this._activeIndex];\n        // Get the positioning data for the new menu.\n        var _a = itemNode.getBoundingClientRect(), left = _a.left, bottom = _a.bottom;\n        // Open the new menu at the computed location.\n        newMenu.open(left, bottom, { forceX: true, forceY: true });\n    };\n    /**\n     * Close the child menu immediately.\n     *\n     * This is a no-op if a child menu is not open.\n     */\n    MenuBar.prototype._closeChildMenu = function () {\n        // Bail if no child menu is open.\n        if (!this._childMenu) {\n            return;\n        }\n        // Remove the active class from the menu bar.\n        this.removeClass('lm-mod-active');\n        /* <DEPRECATED> */\n        this.removeClass('p-mod-active');\n        /* </DEPRECATED> */\n        // Remove the document listeners.\n        document.removeEventListener('mousedown', this, true);\n        // Clear the internal menu reference.\n        var menu = this._childMenu;\n        this._childMenu = null;\n        // Close the menu.\n        menu.close();\n        // Reset the active index.\n        this.activeIndex = -1;\n    };\n    /**\n     * Handle the `aboutToClose` signal of a menu.\n     */\n    MenuBar.prototype._onMenuAboutToClose = function (sender) {\n        // Bail if the sender is not the child menu.\n        if (sender !== this._childMenu) {\n            return;\n        }\n        // Remove the active class from the menu bar.\n        this.removeClass('lm-mod-active');\n        /* <DEPRECATED> */\n        this.removeClass('p-mod-active');\n        /* </DEPRECATED> */\n        // Remove the document listeners.\n        document.removeEventListener('mousedown', this, true);\n        // Clear the internal menu reference.\n        this._childMenu = null;\n        // Reset the active index.\n        this.activeIndex = -1;\n    };\n    /**\n     * Handle the `menuRequested` signal of a child menu.\n     */\n    MenuBar.prototype._onMenuMenuRequested = function (sender, args) {\n        // Bail if the sender is not the child menu.\n        if (sender !== this._childMenu) {\n            return;\n        }\n        // Look up the active index and menu count.\n        var i = this._activeIndex;\n        var n = this._menus.length;\n        // Active the next requested index.\n        switch (args) {\n            case 'next':\n                this.activeIndex = i === n - 1 ? 0 : i + 1;\n                break;\n            case 'previous':\n                this.activeIndex = i === 0 ? n - 1 : i - 1;\n                break;\n        }\n        // Open the active menu.\n        this.openActiveMenu();\n    };\n    /**\n     * Handle the `changed` signal of a title object.\n     */\n    MenuBar.prototype._onTitleChanged = function () {\n        this.update();\n    };\n    return MenuBar;\n}(Widget));\n/**\n * The namespace for the `MenuBar` class statics.\n */\n(function (MenuBar) {\n    /**\n     * The default implementation of `IRenderer`.\n     *\n     * #### Notes\n     * Subclasses are free to reimplement rendering methods as needed.\n     */\n    var Renderer = /** @class */ (function () {\n        /**\n         * Construct a new renderer.\n         */\n        function Renderer() {\n        }\n        /**\n         * Render the virtual element for a menu bar item.\n         *\n         * @param data - The data to use for rendering the item.\n         *\n         * @returns A virtual element representing the item.\n         */\n        Renderer.prototype.renderItem = function (data) {\n            var className = this.createItemClass(data);\n            var dataset = this.createItemDataset(data);\n            var aria = this.createItemARIA(data);\n            return (_lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.li(__assign({ className: className, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data)));\n        };\n        /**\n         * Render the icon element for a menu bar item.\n         *\n         * @param data - The data to use for rendering the icon.\n         *\n         * @returns A virtual element representing the item icon.\n         */\n        Renderer.prototype.renderIcon = function (data) {\n            var className = this.createIconClass(data);\n            /* <DEPRECATED> */\n            if (typeof data.title.icon === 'string') {\n                return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, data.title.iconLabel);\n            }\n            /* </DEPRECATED> */\n            // if data.title.icon is undefined, it will be ignored\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: className }, data.title.icon, data.title.iconLabel);\n        };\n        /**\n         * Render the label element for a menu item.\n         *\n         * @param data - The data to use for rendering the label.\n         *\n         * @returns A virtual element representing the item label.\n         */\n        Renderer.prototype.renderLabel = function (data) {\n            var content = this.formatLabel(data);\n            return _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.div({ className: 'lm-MenuBar-itemLabel'\n                    /* <DEPRECATED> */\n                    + ' p-MenuBar-itemLabel'\n                /* </DEPRECATED> */\n            }, content);\n        };\n        /**\n         * Create the class name for the menu bar item.\n         *\n         * @param data - The data to use for the class name.\n         *\n         * @returns The full class name for the menu item.\n         */\n        Renderer.prototype.createItemClass = function (data) {\n            var name = 'lm-MenuBar-item';\n            /* <DEPRECATED> */\n            name += ' p-MenuBar-item';\n            /* </DEPRECATED> */\n            if (data.title.className) {\n                name += \" \" + data.title.className;\n            }\n            if (data.active) {\n                name += ' lm-mod-active';\n                /* <DEPRECATED> */\n                name += ' p-mod-active';\n                /* </DEPRECATED> */\n            }\n            return name;\n        };\n        /**\n         * Create the dataset for a menu bar item.\n         *\n         * @param data - The data to use for the item.\n         *\n         * @returns The dataset for the menu bar item.\n         */\n        Renderer.prototype.createItemDataset = function (data) {\n            return data.title.dataset;\n        };\n        /**\n         * Create the aria attributes for menu bar item.\n         *\n         * @param data - The data to use for the aria attributes.\n         *\n         * @returns The aria attributes object for the item.\n         */\n        Renderer.prototype.createItemARIA = function (data) {\n            return { role: 'menuitem', 'aria-haspopup': 'true' };\n        };\n        /**\n         * Create the class name for the menu bar item icon.\n         *\n         * @param data - The data to use for the class name.\n         *\n         * @returns The full class name for the item icon.\n         */\n        Renderer.prototype.createIconClass = function (data) {\n            var name = 'lm-MenuBar-itemIcon';\n            /* <DEPRECATED> */\n            name += ' p-MenuBar-itemIcon';\n            /* </DEPRECATED> */\n            var extra = data.title.iconClass;\n            return extra ? name + \" \" + extra : name;\n        };\n        /**\n         * Create the render content for the label node.\n         *\n         * @param data - The data to use for the label content.\n         *\n         * @returns The content to add to the label node.\n         */\n        Renderer.prototype.formatLabel = function (data) {\n            // Fetch the label text and mnemonic index.\n            var _a = data.title, label = _a.label, mnemonic = _a.mnemonic;\n            // If the index is out of range, do not modify the label.\n            if (mnemonic < 0 || mnemonic >= label.length) {\n                return label;\n            }\n            // Split the label into parts.\n            var prefix = label.slice(0, mnemonic);\n            var suffix = label.slice(mnemonic + 1);\n            var char = label[mnemonic];\n            // Wrap the mnemonic character in a span.\n            var span = _lumino_virtualdom__WEBPACK_IMPORTED_MODULE_7__.h.span({\n                className: 'lm-MenuBar-itemMnemonic'\n                    /* <DEPRECATED> */\n                    + ' p-MenuBar-itemMnemonic'\n                /* </DEPRECATED> */\n            }, char);\n            // Return the content parts.\n            return [prefix, span, suffix];\n        };\n        return Renderer;\n    }());\n    MenuBar.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    MenuBar.defaultRenderer = new Renderer();\n})(MenuBar || (MenuBar = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$c;\n(function (Private) {\n    /**\n     * Create the DOM node for a menu bar.\n     */\n    function createNode() {\n        var node = document.createElement('div');\n        var content = document.createElement('ul');\n        content.className = 'lm-MenuBar-content';\n        /* <DEPRECATED> */\n        content.classList.add('p-MenuBar-content');\n        /* </DEPRECATED> */\n        node.appendChild(content);\n        content.setAttribute('role', 'menubar');\n        node.tabIndex = 0;\n        return node;\n    }\n    Private.createNode = createNode;\n    /**\n     * Find the best matching mnemonic item.\n     *\n     * The search starts at the given index and wraps around.\n     */\n    function findMnemonic(menus, key, start) {\n        // Setup the result variables.\n        var index = -1;\n        var auto = -1;\n        var multiple = false;\n        // Normalize the key to upper case.\n        var upperKey = key.toUpperCase();\n        // Search the items from the given start index.\n        for (var i = 0, n = menus.length; i < n; ++i) {\n            // Compute the wrapped index.\n            var k = (i + start) % n;\n            // Look up the menu title.\n            var title = menus[k].title;\n            // Ignore titles with an empty label.\n            if (title.label.length === 0) {\n                continue;\n            }\n            // Look up the mnemonic index for the label.\n            var mn = title.mnemonic;\n            // Handle a valid mnemonic index.\n            if (mn >= 0 && mn < title.label.length) {\n                if (title.label[mn].toUpperCase() === upperKey) {\n                    if (index === -1) {\n                        index = k;\n                    }\n                    else {\n                        multiple = true;\n                    }\n                }\n                continue;\n            }\n            // Finally, handle the auto index if possible.\n            if (auto === -1 && title.label[0].toUpperCase() === upperKey) {\n                auto = k;\n            }\n        }\n        // Return the search results.\n        return { index: index, multiple: multiple, auto: auto };\n    }\n    Private.findMnemonic = findMnemonic;\n})(Private$c || (Private$c = {}));\n\n/**\n * A widget which implements a canonical scroll bar.\n */\nvar ScrollBar = /** @class */ (function (_super) {\n    __extends(ScrollBar, _super);\n    /**\n     * Construct a new scroll bar.\n     *\n     * @param options - The options for initializing the scroll bar.\n     */\n    function ScrollBar(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, { node: Private$d.createNode() }) || this;\n        /**\n         * A timeout callback for repeating the mouse press.\n         */\n        _this._onRepeat = function () {\n            // Clear the repeat timer id.\n            _this._repeatTimer = -1;\n            // Bail if the mouse has been released.\n            if (!_this._pressData) {\n                return;\n            }\n            // Look up the part that was pressed.\n            var part = _this._pressData.part;\n            // Bail if the thumb was pressed.\n            if (part === 'thumb') {\n                return;\n            }\n            // Schedule the timer for another repeat.\n            _this._repeatTimer = window.setTimeout(_this._onRepeat, 20);\n            // Get the current mouse position.\n            var mouseX = _this._pressData.mouseX;\n            var mouseY = _this._pressData.mouseY;\n            // Handle a decrement button repeat.\n            if (part === 'decrement') {\n                // Bail if the mouse is not over the button.\n                if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(_this.decrementNode, mouseX, mouseY)) {\n                    return;\n                }\n                // Emit the step requested signal.\n                _this._stepRequested.emit('decrement');\n                // Finished.\n                return;\n            }\n            // Handle an increment button repeat.\n            if (part === 'increment') {\n                // Bail if the mouse is not over the button.\n                if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(_this.incrementNode, mouseX, mouseY)) {\n                    return;\n                }\n                // Emit the step requested signal.\n                _this._stepRequested.emit('increment');\n                // Finished.\n                return;\n            }\n            // Handle a track repeat.\n            if (part === 'track') {\n                // Bail if the mouse is not over the track.\n                if (!_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(_this.trackNode, mouseX, mouseY)) {\n                    return;\n                }\n                // Fetch the thumb node.\n                var thumbNode = _this.thumbNode;\n                // Bail if the mouse is over the thumb.\n                if (_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.hitTest(thumbNode, mouseX, mouseY)) {\n                    return;\n                }\n                // Fetch the client rect for the thumb.\n                var thumbRect = thumbNode.getBoundingClientRect();\n                // Determine the direction for the page request.\n                var dir = void 0;\n                if (_this._orientation === 'horizontal') {\n                    dir = mouseX < thumbRect.left ? 'decrement' : 'increment';\n                }\n                else {\n                    dir = mouseY < thumbRect.top ? 'decrement' : 'increment';\n                }\n                // Emit the page requested signal.\n                _this._pageRequested.emit(dir);\n                // Finished.\n                return;\n            }\n        };\n        _this._value = 0;\n        _this._page = 10;\n        _this._maximum = 100;\n        _this._repeatTimer = -1;\n        _this._pressData = null;\n        _this._thumbMoved = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._stepRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._pageRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this.addClass('lm-ScrollBar');\n        /* <DEPRECATED> */\n        _this.addClass('p-ScrollBar');\n        /* </DEPRECATED> */\n        _this.setFlag(Widget.Flag.DisallowLayout);\n        // Set the orientation.\n        _this._orientation = options.orientation || 'vertical';\n        _this.dataset['orientation'] = _this._orientation;\n        // Parse the rest of the options.\n        if (options.maximum !== undefined) {\n            _this._maximum = Math.max(0, options.maximum);\n        }\n        if (options.page !== undefined) {\n            _this._page = Math.max(0, options.page);\n        }\n        if (options.value !== undefined) {\n            _this._value = Math.max(0, Math.min(options.value, _this._maximum));\n        }\n        return _this;\n    }\n    Object.defineProperty(ScrollBar.prototype, \"thumbMoved\", {\n        /**\n         * A signal emitted when the user moves the scroll thumb.\n         *\n         * #### Notes\n         * The payload is the current value of the scroll bar.\n         */\n        get: function () {\n            return this._thumbMoved;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"stepRequested\", {\n        /**\n         * A signal emitted when the user clicks a step button.\n         *\n         * #### Notes\n         * The payload is whether a decrease or increase is requested.\n         */\n        get: function () {\n            return this._stepRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"pageRequested\", {\n        /**\n         * A signal emitted when the user clicks the scroll track.\n         *\n         * #### Notes\n         * The payload is whether a decrease or increase is requested.\n         */\n        get: function () {\n            return this._pageRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"orientation\", {\n        /**\n         * Get the orientation of the scroll bar.\n         */\n        get: function () {\n            return this._orientation;\n        },\n        /**\n         * Set the orientation of the scroll bar.\n         */\n        set: function (value) {\n            // Do nothing if the orientation does not change.\n            if (this._orientation === value) {\n                return;\n            }\n            // Release the mouse before making changes.\n            this._releaseMouse();\n            // Update the internal orientation.\n            this._orientation = value;\n            this.dataset['orientation'] = value;\n            // Schedule an update the scroll bar.\n            this.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"value\", {\n        /**\n         * Get the current value of the scroll bar.\n         */\n        get: function () {\n            return this._value;\n        },\n        /**\n         * Set the current value of the scroll bar.\n         *\n         * #### Notes\n         * The value will be clamped to the range `[0, maximum]`.\n         */\n        set: function (value) {\n            // Clamp the value to the allowable range.\n            value = Math.max(0, Math.min(value, this._maximum));\n            // Do nothing if the value does not change.\n            if (this._value === value) {\n                return;\n            }\n            // Update the internal value.\n            this._value = value;\n            // Schedule an update the scroll bar.\n            this.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"page\", {\n        /**\n         * Get the page size of the scroll bar.\n         *\n         * #### Notes\n         * The page size is the amount of visible content in the scrolled\n         * region, expressed in data units. It determines the size of the\n         * scroll bar thumb.\n         */\n        get: function () {\n            return this._page;\n        },\n        /**\n         * Set the page size of the scroll bar.\n         *\n         * #### Notes\n         * The page size will be clamped to the range `[0, Infinity]`.\n         */\n        set: function (value) {\n            // Clamp the page size to the allowable range.\n            value = Math.max(0, value);\n            // Do nothing if the value does not change.\n            if (this._page === value) {\n                return;\n            }\n            // Update the internal page size.\n            this._page = value;\n            // Schedule an update the scroll bar.\n            this.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"maximum\", {\n        /**\n         * Get the maximum value of the scroll bar.\n         */\n        get: function () {\n            return this._maximum;\n        },\n        /**\n         * Set the maximum value of the scroll bar.\n         *\n         * #### Notes\n         * The max size will be clamped to the range `[0, Infinity]`.\n         */\n        set: function (value) {\n            // Clamp the value to the allowable range.\n            value = Math.max(0, value);\n            // Do nothing if the value does not change.\n            if (this._maximum === value) {\n                return;\n            }\n            // Update the internal values.\n            this._maximum = value;\n            // Clamp the current value to the new range.\n            this._value = Math.min(this._value, value);\n            // Schedule an update the scroll bar.\n            this.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"decrementNode\", {\n        /**\n         * The scroll bar decrement button node.\n         *\n         * #### Notes\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-ScrollBar-button')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"incrementNode\", {\n        /**\n         * The scroll bar increment button node.\n         *\n         * #### Notes\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-ScrollBar-button')[1];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"trackNode\", {\n        /**\n         * The scroll bar track node.\n         *\n         * #### Notes\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-ScrollBar-track')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(ScrollBar.prototype, \"thumbNode\", {\n        /**\n         * The scroll bar thumb node.\n         *\n         * #### Notes\n         * Modifying this node directly can lead to undefined behavior.\n         */\n        get: function () {\n            return this.node.getElementsByClassName('lm-ScrollBar-thumb')[0];\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Handle the DOM events for the scroll bar.\n     *\n     * @param event - The DOM event sent to the scroll bar.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the scroll bar's DOM node.\n     *\n     * This should not be called directly by user code.\n     */\n    ScrollBar.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'mousedown':\n                this._evtMouseDown(event);\n                break;\n            case 'mousemove':\n                this._evtMouseMove(event);\n                break;\n            case 'mouseup':\n                this._evtMouseUp(event);\n                break;\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'contextmenu':\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    };\n    /**\n     * A method invoked on a 'before-attach' message.\n     */\n    ScrollBar.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('mousedown', this);\n        this.update();\n    };\n    /**\n     * A method invoked on an 'after-detach' message.\n     */\n    ScrollBar.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('mousedown', this);\n        this._releaseMouse();\n    };\n    /**\n     * A method invoked on an 'update-request' message.\n     */\n    ScrollBar.prototype.onUpdateRequest = function (msg) {\n        // Convert the value and page into percentages.\n        var value = this._value * 100 / this._maximum;\n        var page = this._page * 100 / (this._page + this._maximum);\n        // Clamp the value and page to the relevant range.\n        value = Math.max(0, Math.min(value, 100));\n        page = Math.max(0, Math.min(page, 100));\n        // Fetch the thumb style.\n        var thumbStyle = this.thumbNode.style;\n        // Update the thumb style for the current orientation.\n        if (this._orientation === 'horizontal') {\n            thumbStyle.top = '';\n            thumbStyle.height = '';\n            thumbStyle.left = value + \"%\";\n            thumbStyle.width = page + \"%\";\n            thumbStyle.transform = \"translate(\" + -value + \"%, 0%)\";\n        }\n        else {\n            thumbStyle.left = '';\n            thumbStyle.width = '';\n            thumbStyle.top = value + \"%\";\n            thumbStyle.height = page + \"%\";\n            thumbStyle.transform = \"translate(0%, \" + -value + \"%)\";\n        }\n    };\n    /**\n     * Handle the `'keydown'` event for the scroll bar.\n     */\n    ScrollBar.prototype._evtKeyDown = function (event) {\n        // Stop all input events during drag.\n        event.preventDefault();\n        event.stopPropagation();\n        // Ignore anything except the `Escape` key.\n        if (event.keyCode !== 27) {\n            return;\n        }\n        // Fetch the previous scroll value.\n        var value = this._pressData ? this._pressData.value : -1;\n        // Release the mouse.\n        this._releaseMouse();\n        // Restore the old scroll value if possible.\n        if (value !== -1) {\n            this._moveThumb(value);\n        }\n    };\n    /**\n     * Handle the `'mousedown'` event for the scroll bar.\n     */\n    ScrollBar.prototype._evtMouseDown = function (event) {\n        // Do nothing if it's not a left mouse press.\n        if (event.button !== 0) {\n            return;\n        }\n        // Send an activate request to the scroll bar. This can be\n        // used by message hooks to activate something relevant.\n        this.activate();\n        // Do nothing if the mouse is already captured.\n        if (this._pressData) {\n            return;\n        }\n        // Find the pressed scroll bar part.\n        var part = Private$d.findPart(this, event.target);\n        // Do nothing if the part is not of interest.\n        if (!part) {\n            return;\n        }\n        // Stop the event propagation.\n        event.preventDefault();\n        event.stopPropagation();\n        // Override the mouse cursor.\n        var override = _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__.Drag.overrideCursor('default');\n        // Set up the press data.\n        this._pressData = {\n            part: part, override: override,\n            delta: -1, value: -1,\n            mouseX: event.clientX,\n            mouseY: event.clientY\n        };\n        // Add the extra event listeners.\n        document.addEventListener('mousemove', this, true);\n        document.addEventListener('mouseup', this, true);\n        document.addEventListener('keydown', this, true);\n        document.addEventListener('contextmenu', this, true);\n        // Handle a thumb press.\n        if (part === 'thumb') {\n            // Fetch the thumb node.\n            var thumbNode = this.thumbNode;\n            // Fetch the client rect for the thumb.\n            var thumbRect = thumbNode.getBoundingClientRect();\n            // Update the press data delta for the current orientation.\n            if (this._orientation === 'horizontal') {\n                this._pressData.delta = event.clientX - thumbRect.left;\n            }\n            else {\n                this._pressData.delta = event.clientY - thumbRect.top;\n            }\n            // Add the active class to the thumb node.\n            thumbNode.classList.add('lm-mod-active');\n            /* <DEPRECATED> */\n            thumbNode.classList.add('p-mod-active');\n            /* </DEPRECATED> */\n            // Store the current value in the press data.\n            this._pressData.value = this._value;\n            // Finished.\n            return;\n        }\n        // Handle a track press.\n        if (part === 'track') {\n            // Fetch the client rect for the thumb.\n            var thumbRect = this.thumbNode.getBoundingClientRect();\n            // Determine the direction for the page request.\n            var dir = void 0;\n            if (this._orientation === 'horizontal') {\n                dir = event.clientX < thumbRect.left ? 'decrement' : 'increment';\n            }\n            else {\n                dir = event.clientY < thumbRect.top ? 'decrement' : 'increment';\n            }\n            // Start the repeat timer.\n            this._repeatTimer = window.setTimeout(this._onRepeat, 350);\n            // Emit the page requested signal.\n            this._pageRequested.emit(dir);\n            // Finished.\n            return;\n        }\n        // Handle a decrement button press.\n        if (part === 'decrement') {\n            // Add the active class to the decrement node.\n            this.decrementNode.classList.add('lm-mod-active');\n            /* <DEPRECATED> */\n            this.decrementNode.classList.add('p-mod-active');\n            /* </DEPRECATED> */\n            // Start the repeat timer.\n            this._repeatTimer = window.setTimeout(this._onRepeat, 350);\n            // Emit the step requested signal.\n            this._stepRequested.emit('decrement');\n            // Finished.\n            return;\n        }\n        // Handle an increment button press.\n        if (part === 'increment') {\n            // Add the active class to the increment node.\n            this.incrementNode.classList.add('lm-mod-active');\n            /* <DEPRECATED> */\n            this.incrementNode.classList.add('p-mod-active');\n            /* </DEPRECATED> */\n            // Start the repeat timer.\n            this._repeatTimer = window.setTimeout(this._onRepeat, 350);\n            // Emit the step requested signal.\n            this._stepRequested.emit('increment');\n            // Finished.\n            return;\n        }\n    };\n    /**\n     * Handle the `'mousemove'` event for the scroll bar.\n     */\n    ScrollBar.prototype._evtMouseMove = function (event) {\n        // Do nothing if no drag is in progress.\n        if (!this._pressData) {\n            return;\n        }\n        // Stop the event propagation.\n        event.preventDefault();\n        event.stopPropagation();\n        // Update the mouse position.\n        this._pressData.mouseX = event.clientX;\n        this._pressData.mouseY = event.clientY;\n        // Bail if the thumb is not being dragged.\n        if (this._pressData.part !== 'thumb') {\n            return;\n        }\n        // Get the client rect for the thumb and track.\n        var thumbRect = this.thumbNode.getBoundingClientRect();\n        var trackRect = this.trackNode.getBoundingClientRect();\n        // Fetch the scroll geometry based on the orientation.\n        var trackPos;\n        var trackSpan;\n        if (this._orientation === 'horizontal') {\n            trackPos = event.clientX - trackRect.left - this._pressData.delta;\n            trackSpan = trackRect.width - thumbRect.width;\n        }\n        else {\n            trackPos = event.clientY - trackRect.top - this._pressData.delta;\n            trackSpan = trackRect.height - thumbRect.height;\n        }\n        // Compute the desired value from the scroll geometry.\n        var value = trackSpan === 0 ? 0 : trackPos * this._maximum / trackSpan;\n        // Move the thumb to the computed value.\n        this._moveThumb(value);\n    };\n    /**\n     * Handle the `'mouseup'` event for the scroll bar.\n     */\n    ScrollBar.prototype._evtMouseUp = function (event) {\n        // Do nothing if it's not a left mouse release.\n        if (event.button !== 0) {\n            return;\n        }\n        // Stop the event propagation.\n        event.preventDefault();\n        event.stopPropagation();\n        // Release the mouse.\n        this._releaseMouse();\n    };\n    /**\n     * Release the mouse and restore the node states.\n     */\n    ScrollBar.prototype._releaseMouse = function () {\n        // Bail if there is no press data.\n        if (!this._pressData) {\n            return;\n        }\n        // Clear the repeat timer.\n        clearTimeout(this._repeatTimer);\n        this._repeatTimer = -1;\n        // Clear the press data.\n        this._pressData.override.dispose();\n        this._pressData = null;\n        // Remove the extra event listeners.\n        document.removeEventListener('mousemove', this, true);\n        document.removeEventListener('mouseup', this, true);\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('contextmenu', this, true);\n        // Remove the active classes from the nodes.\n        this.thumbNode.classList.remove('lm-mod-active');\n        this.decrementNode.classList.remove('lm-mod-active');\n        this.incrementNode.classList.remove('lm-mod-active');\n        /* <DEPRECATED> */\n        this.thumbNode.classList.remove('p-mod-active');\n        this.decrementNode.classList.remove('p-mod-active');\n        this.incrementNode.classList.remove('p-mod-active');\n        /* </DEPRECATED> */\n    };\n    /**\n     * Move the thumb to the specified position.\n     */\n    ScrollBar.prototype._moveThumb = function (value) {\n        // Clamp the value to the allowed range.\n        value = Math.max(0, Math.min(value, this._maximum));\n        // Bail if the value does not change.\n        if (this._value === value) {\n            return;\n        }\n        // Update the internal value.\n        this._value = value;\n        // Schedule an update of the scroll bar.\n        this.update();\n        // Emit the thumb moved signal.\n        this._thumbMoved.emit(value);\n    };\n    return ScrollBar;\n}(Widget));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$d;\n(function (Private) {\n    /**\n     * Create the DOM node for a scroll bar.\n     */\n    function createNode() {\n        var node = document.createElement('div');\n        var decrement = document.createElement('div');\n        var increment = document.createElement('div');\n        var track = document.createElement('div');\n        var thumb = document.createElement('div');\n        decrement.className = 'lm-ScrollBar-button';\n        increment.className = 'lm-ScrollBar-button';\n        decrement.dataset['action'] = 'decrement';\n        increment.dataset['action'] = 'increment';\n        track.className = 'lm-ScrollBar-track';\n        thumb.className = 'lm-ScrollBar-thumb';\n        /* <DEPRECATED> */\n        decrement.classList.add('p-ScrollBar-button');\n        increment.classList.add('p-ScrollBar-button');\n        track.classList.add('p-ScrollBar-track');\n        thumb.classList.add('p-ScrollBar-thumb');\n        /* </DEPRECATED> */\n        track.appendChild(thumb);\n        node.appendChild(decrement);\n        node.appendChild(track);\n        node.appendChild(increment);\n        return node;\n    }\n    Private.createNode = createNode;\n    /**\n     * Find the scroll bar part which contains the given target.\n     */\n    function findPart(scrollBar, target) {\n        // Test the thumb.\n        if (scrollBar.thumbNode.contains(target)) {\n            return 'thumb';\n        }\n        // Test the track.\n        if (scrollBar.trackNode.contains(target)) {\n            return 'track';\n        }\n        // Test the decrement button.\n        if (scrollBar.decrementNode.contains(target)) {\n            return 'decrement';\n        }\n        // Test the increment button.\n        if (scrollBar.incrementNode.contains(target)) {\n            return 'increment';\n        }\n        // Indicate no match.\n        return null;\n    }\n    Private.findPart = findPart;\n})(Private$d || (Private$d = {}));\n\n/**\n * A concrete layout implementation which holds a single widget.\n *\n * #### Notes\n * This class is useful for creating simple container widgets which\n * hold a single child. The child should be positioned with CSS.\n */\nvar SingletonLayout = /** @class */ (function (_super) {\n    __extends(SingletonLayout, _super);\n    function SingletonLayout() {\n        var _this = _super !== null && _super.apply(this, arguments) || this;\n        _this._widget = null;\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    SingletonLayout.prototype.dispose = function () {\n        if (this._widget) {\n            var widget = this._widget;\n            this._widget = null;\n            widget.dispose();\n        }\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(SingletonLayout.prototype, \"widget\", {\n        /**\n         * Get the child widget for the layout.\n         */\n        get: function () {\n            return this._widget;\n        },\n        /**\n         * Set the child widget for the layout.\n         *\n         * #### Notes\n         * Setting the child widget will cause the old child widget to be\n         * automatically disposed. If that is not desired, set the parent\n         * of the old child to `null` before assigning a new child.\n         */\n        set: function (widget) {\n            // Remove the widget from its current parent. This is a no-op\n            // if the widget's parent is already the layout parent widget.\n            if (widget) {\n                widget.parent = this.parent;\n            }\n            // Bail early if the widget does not change.\n            if (this._widget === widget) {\n                return;\n            }\n            // Dispose of the old child widget.\n            if (this._widget) {\n                this._widget.dispose();\n            }\n            // Update the internal widget.\n            this._widget = widget;\n            // Attach the new child widget if needed.\n            if (this.parent && widget) {\n                this.attachWidget(widget);\n            }\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Create an iterator over the widgets in the layout.\n     *\n     * @returns A new iterator over the widgets in the layout.\n     */\n    SingletonLayout.prototype.iter = function () {\n        return this._widget ? (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.once)(this._widget) : (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.empty)();\n    };\n    /**\n     * Remove a widget from the layout.\n     *\n     * @param widget - The widget to remove from the layout.\n     *\n     * #### Notes\n     * A widget is automatically removed from the layout when its `parent`\n     * is set to `null`. This method should only be invoked directly when\n     * removing a widget from a layout which has yet to be installed on a\n     * parent widget.\n     *\n     * This method does *not* modify the widget's `parent`.\n     */\n    SingletonLayout.prototype.removeWidget = function (widget) {\n        // Bail early if the widget does not exist in the layout.\n        if (this._widget !== widget) {\n            return;\n        }\n        // Clear the internal widget.\n        this._widget = null;\n        // If the layout is parented, detach the widget from the DOM.\n        if (this.parent) {\n            this.detachWidget(widget);\n        }\n    };\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    SingletonLayout.prototype.init = function () {\n        var _this = this;\n        _super.prototype.init.call(this);\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this, function (widget) { _this.attachWidget(widget); });\n    };\n    /**\n     * Attach a widget to the parent's DOM node.\n     *\n     * @param index - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to attach to the parent.\n     *\n     * #### Notes\n     * This method is called automatically by the single layout at the\n     * appropriate time. It should not be called directly by user code.\n     *\n     * The default implementation adds the widgets's node to the parent's\n     * node at the proper location, and sends the appropriate attach\n     * messages to the widget if the parent is attached to the DOM.\n     *\n     * Subclasses may reimplement this method to control how the widget's\n     * node is added to the parent's node.\n     */\n    SingletonLayout.prototype.attachWidget = function (widget) {\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Add the widget's node to the parent.\n        this.parent.node.appendChild(widget.node);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n    };\n    /**\n     * Detach a widget from the parent's DOM node.\n     *\n     * @param widget - The widget to detach from the parent.\n     *\n     * #### Notes\n     * This method is called automatically by the single layout at the\n     * appropriate time. It should not be called directly by user code.\n     *\n     * The default implementation removes the widget's node from the\n     * parent's node, and sends the appropriate detach messages to the\n     * widget if the parent is attached to the DOM.\n     *\n     * Subclasses may reimplement this method to control how the widget's\n     * node is removed from the parent's node.\n     */\n    SingletonLayout.prototype.detachWidget = function (widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n    };\n    return SingletonLayout;\n}(Layout));\n\n/**\n * A layout which arranges its widgets into resizable sections.\n */\nvar SplitLayout = /** @class */ (function (_super) {\n    __extends(SplitLayout, _super);\n    /**\n     * Construct a new split layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    function SplitLayout(options) {\n        var _this = _super.call(this) || this;\n        _this._fixed = 0;\n        _this._spacing = 4;\n        _this._dirty = false;\n        _this._hasNormedSizes = false;\n        _this._sizers = [];\n        _this._items = [];\n        _this._handles = [];\n        _this._box = null;\n        _this._alignment = 'start';\n        _this._orientation = 'horizontal';\n        _this.renderer = options.renderer;\n        if (options.orientation !== undefined) {\n            _this._orientation = options.orientation;\n        }\n        if (options.alignment !== undefined) {\n            _this._alignment = options.alignment;\n        }\n        if (options.spacing !== undefined) {\n            _this._spacing = Private$e.clampSpacing(options.spacing);\n        }\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    SplitLayout.prototype.dispose = function () {\n        // Dispose of the layout items.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this._items, function (item) { item.dispose(); });\n        // Clear the layout state.\n        this._box = null;\n        this._items.length = 0;\n        this._sizers.length = 0;\n        this._handles.length = 0;\n        // Dispose of the rest of the layout.\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(SplitLayout.prototype, \"orientation\", {\n        /**\n         * Get the layout orientation for the split layout.\n         */\n        get: function () {\n            return this._orientation;\n        },\n        /**\n         * Set the layout orientation for the split layout.\n         */\n        set: function (value) {\n            if (this._orientation === value) {\n                return;\n            }\n            this._orientation = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.dataset['orientation'] = value;\n            this.parent.fit();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitLayout.prototype, \"alignment\", {\n        /**\n         * Get the content alignment for the split layout.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand  to fill the\n         * entire split layout.\n         */\n        get: function () {\n            return this._alignment;\n        },\n        /**\n         * Set the content alignment for the split layout.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand  to fill the\n         * entire split layout.\n         */\n        set: function (value) {\n            if (this._alignment === value) {\n                return;\n            }\n            this._alignment = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.dataset['alignment'] = value;\n            this.parent.update();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitLayout.prototype, \"spacing\", {\n        /**\n         * Get the inter-element spacing for the split layout.\n         */\n        get: function () {\n            return this._spacing;\n        },\n        /**\n         * Set the inter-element spacing for the split layout.\n         */\n        set: function (value) {\n            value = Private$e.clampSpacing(value);\n            if (this._spacing === value) {\n                return;\n            }\n            this._spacing = value;\n            if (!this.parent) {\n                return;\n            }\n            this.parent.fit();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitLayout.prototype, \"handles\", {\n        /**\n         * A read-only array of the split handles in the layout.\n         */\n        get: function () {\n            return this._handles;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Get the relative sizes of the widgets in the layout.\n     *\n     * @returns A new array of the relative sizes of the widgets.\n     *\n     * #### Notes\n     * The returned sizes reflect the sizes of the widgets normalized\n     * relative to their siblings.\n     *\n     * This method **does not** measure the DOM nodes.\n     */\n    SplitLayout.prototype.relativeSizes = function () {\n        return Private$e.normalize(this._sizers.map(function (sizer) { return sizer.size; }));\n    };\n    /**\n     * Set the relative sizes for the widgets in the layout.\n     *\n     * @param sizes - The relative sizes for the widgets in the panel.\n     *\n     * #### Notes\n     * Extra values are ignored, too few will yield an undefined layout.\n     *\n     * The actual geometry of the DOM nodes is updated asynchronously.\n     */\n    SplitLayout.prototype.setRelativeSizes = function (sizes) {\n        // Copy the sizes and pad with zeros as needed.\n        var n = this._sizers.length;\n        var temp = sizes.slice(0, n);\n        while (temp.length < n) {\n            temp.push(0);\n        }\n        // Normalize the padded sizes.\n        var normed = Private$e.normalize(temp);\n        // Apply the normalized sizes to the sizers.\n        for (var i = 0; i < n; ++i) {\n            var sizer = this._sizers[i];\n            sizer.sizeHint = normed[i];\n            sizer.size = normed[i];\n        }\n        // Set the flag indicating the sizes are normalized.\n        this._hasNormedSizes = true;\n        // Trigger an update of the parent widget.\n        if (this.parent) {\n            this.parent.update();\n        }\n    };\n    /**\n     * Move the offset position of a split handle.\n     *\n     * @param index - The index of the handle of the interest.\n     *\n     * @param position - The desired offset position of the handle.\n     *\n     * #### Notes\n     * The position is relative to the offset parent.\n     *\n     * This will move the handle as close as possible to the desired\n     * position. The sibling widgets will be adjusted as necessary.\n     */\n    SplitLayout.prototype.moveHandle = function (index, position) {\n        // Bail if the index is invalid or the handle is hidden.\n        var handle = this._handles[index];\n        if (!handle || handle.classList.contains('lm-mod-hidden')) {\n            return;\n        }\n        // Compute the desired delta movement for the handle.\n        var delta;\n        if (this._orientation === 'horizontal') {\n            delta = position - handle.offsetLeft;\n        }\n        else {\n            delta = position - handle.offsetTop;\n        }\n        // Bail if there is no handle movement.\n        if (delta === 0) {\n            return;\n        }\n        // Prevent widget resizing unless needed.\n        for (var _i = 0, _a = this._sizers; _i < _a.length; _i++) {\n            var sizer = _a[_i];\n            if (sizer.size > 0) {\n                sizer.sizeHint = sizer.size;\n            }\n        }\n        // Adjust the sizers to reflect the handle movement.\n        BoxEngine.adjust(this._sizers, index, delta);\n        // Update the layout of the widgets.\n        if (this.parent) {\n            this.parent.update();\n        }\n    };\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    SplitLayout.prototype.init = function () {\n        this.parent.dataset['orientation'] = this.orientation;\n        this.parent.dataset['alignment'] = this.alignment;\n        _super.prototype.init.call(this);\n    };\n    /**\n     * Attach a widget to the parent's DOM node.\n     *\n     * @param index - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to attach to the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    SplitLayout.prototype.attachWidget = function (index, widget) {\n        // Create the item, handle, and sizer for the new widget.\n        var item = new LayoutItem(widget);\n        var handle = Private$e.createHandle(this.renderer);\n        var average = Private$e.averageSize(this._sizers);\n        var sizer = Private$e.createSizer(average);\n        // Insert the item, handle, and sizer into the internal arrays.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._items, index, item);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._sizers, index, sizer);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._handles, index, handle);\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Add the widget and handle nodes to the parent.\n        this.parent.node.appendChild(widget.node);\n        this.parent.node.appendChild(handle);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Move a widget in the parent's DOM node.\n     *\n     * @param fromIndex - The previous index of the widget in the layout.\n     *\n     * @param toIndex - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to move in the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    SplitLayout.prototype.moveWidget = function (fromIndex, toIndex, widget) {\n        // Move the item, sizer, and handle for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._items, fromIndex, toIndex);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._sizers, fromIndex, toIndex);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._handles, fromIndex, toIndex);\n        // Post a fit request to the parent to show/hide last handle.\n        this.parent.fit();\n    };\n    /**\n     * Detach a widget from the parent's DOM node.\n     *\n     * @param index - The previous index of the widget in the layout.\n     *\n     * @param widget - The widget to detach from the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    SplitLayout.prototype.detachWidget = function (index, widget) {\n        // Remove the item, handle, and sizer for the widget.\n        var item = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._items, index);\n        var handle = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._handles, index);\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._sizers, index);\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget and handle nodes from the parent.\n        this.parent.node.removeChild(widget.node);\n        this.parent.node.removeChild(handle);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Dispose of the layout item.\n        item.dispose();\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     */\n    SplitLayout.prototype.onBeforeShow = function (msg) {\n        _super.prototype.onBeforeShow.call(this, msg);\n        this.parent.update();\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    SplitLayout.prototype.onBeforeAttach = function (msg) {\n        _super.prototype.onBeforeAttach.call(this, msg);\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    SplitLayout.prototype.onChildShown = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    SplitLayout.prototype.onChildHidden = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    SplitLayout.prototype.onResize = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(msg.width, msg.height);\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    SplitLayout.prototype.onUpdateRequest = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(-1, -1);\n        }\n    };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     */\n    SplitLayout.prototype.onFitRequest = function (msg) {\n        if (this.parent.isAttached) {\n            this._fit();\n        }\n    };\n    /**\n     * Fit the layout to the total size required by the widgets.\n     */\n    SplitLayout.prototype._fit = function () {\n        // Update the handles and track the visible widget count.\n        var nVisible = 0;\n        var lastHandleIndex = -1;\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            if (this._items[i].isHidden) {\n                this._handles[i].classList.add('lm-mod-hidden');\n                /* <DEPRECATED> */\n                this._handles[i].classList.add('p-mod-hidden');\n                /* </DEPRECATED> */\n            }\n            else {\n                this._handles[i].classList.remove('lm-mod-hidden');\n                /* <DEPRECATED> */\n                this._handles[i].classList.remove('p-mod-hidden');\n                /* </DEPRECATED> */\n                lastHandleIndex = i;\n                nVisible++;\n            }\n        }\n        // Hide the handle for the last visible widget.\n        if (lastHandleIndex !== -1) {\n            this._handles[lastHandleIndex].classList.add('lm-mod-hidden');\n            /* <DEPRECATED> */\n            this._handles[lastHandleIndex].classList.add('p-mod-hidden');\n            /* </DEPRECATED> */\n        }\n        // Update the fixed space for the visible items.\n        this._fixed = this._spacing * Math.max(0, nVisible - 1);\n        // Setup the computed minimum size.\n        var horz = this._orientation === 'horizontal';\n        var minW = horz ? this._fixed : 0;\n        var minH = horz ? 0 : this._fixed;\n        // Update the sizers and computed size limits.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item and corresponding box sizer.\n            var item = this._items[i];\n            var sizer = this._sizers[i];\n            // Prevent resizing unless necessary.\n            if (sizer.size > 0) {\n                sizer.sizeHint = sizer.size;\n            }\n            // If the item is hidden, it should consume zero size.\n            if (item.isHidden) {\n                sizer.minSize = 0;\n                sizer.maxSize = 0;\n                continue;\n            }\n            // Update the size limits for the item.\n            item.fit();\n            // Update the stretch factor.\n            sizer.stretch = SplitLayout.getStretch(item.widget);\n            // Update the sizer limits and computed min size.\n            if (horz) {\n                sizer.minSize = item.minWidth;\n                sizer.maxSize = item.maxWidth;\n                minW += item.minWidth;\n                minH = Math.max(minH, item.minHeight);\n            }\n            else {\n                sizer.minSize = item.minHeight;\n                sizer.maxSize = item.maxHeight;\n                minH += item.minHeight;\n                minW = Math.max(minW, item.minWidth);\n            }\n        }\n        // Update the box sizing and add it to the computed min size.\n        var box = this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        var style = this.parent.node.style;\n        style.minWidth = minW + \"px\";\n        style.minHeight = minH + \"px\";\n        // Set the dirty flag to ensure only a single update occurs.\n        this._dirty = true;\n        // Notify the ancestor that it should fit immediately. This may\n        // cause a resize of the parent, fulfilling the required update.\n        if (this.parent.parent) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent.parent, Widget.Msg.FitRequest);\n        }\n        // If the dirty flag is still set, the parent was not resized.\n        // Trigger the required update on the parent widget immediately.\n        if (this._dirty) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n        }\n    };\n    /**\n     * Update the layout position and size of the widgets.\n     *\n     * The parent offset dimensions should be `-1` if unknown.\n     */\n    SplitLayout.prototype._update = function (offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Compute the visible item count.\n        var nVisible = 0;\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            nVisible += +!this._items[i].isHidden;\n        }\n        // Bail early if there are no visible items to layout.\n        if (nVisible === 0) {\n            return;\n        }\n        // Measure the parent if the offset dimensions are unknown.\n        if (offsetWidth < 0) {\n            offsetWidth = this.parent.node.offsetWidth;\n        }\n        if (offsetHeight < 0) {\n            offsetHeight = this.parent.node.offsetHeight;\n        }\n        // Ensure the parent box sizing data is computed.\n        if (!this._box) {\n            this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the actual layout bounds adjusted for border and padding.\n        var top = this._box.paddingTop;\n        var left = this._box.paddingLeft;\n        var width = offsetWidth - this._box.horizontalSum;\n        var height = offsetHeight - this._box.verticalSum;\n        // Compute the adjusted layout space.\n        var space;\n        var horz = this._orientation === 'horizontal';\n        if (horz) {\n            space = Math.max(0, width - this._fixed);\n        }\n        else {\n            space = Math.max(0, height - this._fixed);\n        }\n        // Scale the size hints if they are normalized.\n        if (this._hasNormedSizes) {\n            for (var _i = 0, _a = this._sizers; _i < _a.length; _i++) {\n                var sizer = _a[_i];\n                sizer.sizeHint *= space;\n            }\n            this._hasNormedSizes = false;\n        }\n        // Distribute the layout space to the box sizers.\n        var delta = BoxEngine.calc(this._sizers, space);\n        // Set up the variables for justification and alignment offset.\n        var extra = 0;\n        var offset = 0;\n        // Account for alignment if there is extra layout space.\n        if (delta > 0) {\n            switch (this._alignment) {\n                case 'start':\n                    break;\n                case 'center':\n                    extra = 0;\n                    offset = delta / 2;\n                    break;\n                case 'end':\n                    extra = 0;\n                    offset = delta;\n                    break;\n                case 'justify':\n                    extra = delta / nVisible;\n                    offset = 0;\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n        }\n        // Layout the items using the computed box sizes.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Fetch the computed size for the widget.\n            var size = this._sizers[i].size;\n            // Fetch the style for the handle.\n            var handleStyle = this._handles[i].style;\n            // Update the widget and handle, and advance the relevant edge.\n            if (horz) {\n                item.update(left + offset, top, size + extra, height);\n                left += size + extra;\n                handleStyle.top = top + \"px\";\n                handleStyle.left = left + offset + \"px\";\n                handleStyle.width = this._spacing + \"px\";\n                handleStyle.height = height + \"px\";\n                left += this._spacing;\n            }\n            else {\n                item.update(left, top + offset, width, size + extra);\n                top += size + extra;\n                handleStyle.top = top + offset + \"px\";\n                handleStyle.left = left + \"px\";\n                handleStyle.width = width + \"px\";\n                handleStyle.height = this._spacing + \"px\";\n                top += this._spacing;\n            }\n        }\n    };\n    return SplitLayout;\n}(PanelLayout));\n/**\n * The namespace for the `SplitLayout` class statics.\n */\n(function (SplitLayout) {\n    /**\n     * Get the split layout stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The split layout stretch factor for the widget.\n     */\n    function getStretch(widget) {\n        return Private$e.stretchProperty.get(widget);\n    }\n    SplitLayout.getStretch = getStretch;\n    /**\n     * Set the split layout stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the stretch factor.\n     */\n    function setStretch(widget, value) {\n        Private$e.stretchProperty.set(widget, value);\n    }\n    SplitLayout.setStretch = setStretch;\n})(SplitLayout || (SplitLayout = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$e;\n(function (Private) {\n    /**\n     * The property descriptor for a widget stretch factor.\n     */\n    Private.stretchProperty = new _lumino_properties__WEBPACK_IMPORTED_MODULE_3__.AttachedProperty({\n        name: 'stretch',\n        create: function () { return 0; },\n        coerce: function (owner, value) { return Math.max(0, Math.floor(value)); },\n        changed: onChildSizingChanged\n    });\n    /**\n     * Create a new box sizer with the given size hint.\n     */\n    function createSizer(size) {\n        var sizer = new BoxSizer();\n        sizer.sizeHint = Math.floor(size);\n        return sizer;\n    }\n    Private.createSizer = createSizer;\n    /**\n     * Create a new split handle node using the given renderer.\n     */\n    function createHandle(renderer) {\n        var handle = renderer.createHandle();\n        handle.style.position = 'absolute';\n        return handle;\n    }\n    Private.createHandle = createHandle;\n    /**\n     * Clamp a spacing value to an integer >= 0.\n     */\n    function clampSpacing(value) {\n        return Math.max(0, Math.floor(value));\n    }\n    Private.clampSpacing = clampSpacing;\n    /**\n     * Compute the average size of an array of box sizers.\n     */\n    function averageSize(sizers) {\n        return sizers.reduce(function (v, s) { return v + s.size; }, 0) / sizers.length || 0;\n    }\n    Private.averageSize = averageSize;\n    /**\n     * Normalize an array of values.\n     */\n    function normalize(values) {\n        var n = values.length;\n        if (n === 0) {\n            return [];\n        }\n        var sum = values.reduce(function (a, b) { return a + Math.abs(b); }, 0);\n        return sum === 0 ? values.map(function (v) { return 1 / n; }) : values.map(function (v) { return v / sum; });\n    }\n    Private.normalize = normalize;\n    /**\n     * The change handler for the attached sizing properties.\n     */\n    function onChildSizingChanged(child) {\n        if (child.parent && child.parent.layout instanceof SplitLayout) {\n            child.parent.fit();\n        }\n    }\n})(Private$e || (Private$e = {}));\n\n/**\n * A panel which arranges its widgets into resizable sections.\n *\n * #### Notes\n * This class provides a convenience wrapper around a [[SplitLayout]].\n */\nvar SplitPanel = /** @class */ (function (_super) {\n    __extends(SplitPanel, _super);\n    /**\n     * Construct a new split panel.\n     *\n     * @param options - The options for initializing the split panel.\n     */\n    function SplitPanel(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, { layout: Private$f.createLayout(options) }) || this;\n        _this._pressData = null;\n        _this.addClass('lm-SplitPanel');\n        /* <DEPRECATED> */\n        _this.addClass('p-SplitPanel');\n        return _this;\n        /* </DEPRECATED> */\n    }\n    /**\n     * Dispose of the resources held by the panel.\n     */\n    SplitPanel.prototype.dispose = function () {\n        this._releaseMouse();\n        _super.prototype.dispose.call(this);\n    };\n    Object.defineProperty(SplitPanel.prototype, \"orientation\", {\n        /**\n         * Get the layout orientation for the split panel.\n         */\n        get: function () {\n            return this.layout.orientation;\n        },\n        /**\n         * Set the layout orientation for the split panel.\n         */\n        set: function (value) {\n            this.layout.orientation = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitPanel.prototype, \"alignment\", {\n        /**\n         * Get the content alignment for the split panel.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand to fill the\n         * entire split panel.\n         */\n        get: function () {\n            return this.layout.alignment;\n        },\n        /**\n         * Set the content alignment for the split panel.\n         *\n         * #### Notes\n         * This is the alignment of the widgets in the layout direction.\n         *\n         * The alignment has no effect if the widgets can expand to fill the\n         * entire split panel.\n         */\n        set: function (value) {\n            this.layout.alignment = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitPanel.prototype, \"spacing\", {\n        /**\n         * Get the inter-element spacing for the split panel.\n         */\n        get: function () {\n            return this.layout.spacing;\n        },\n        /**\n         * Set the inter-element spacing for the split panel.\n         */\n        set: function (value) {\n            this.layout.spacing = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitPanel.prototype, \"renderer\", {\n        /**\n         * The renderer used by the split panel.\n         */\n        get: function () {\n            return this.layout.renderer;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SplitPanel.prototype, \"handles\", {\n        /**\n         * A read-only array of the split handles in the panel.\n         */\n        get: function () {\n            return this.layout.handles;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Get the relative sizes of the widgets in the panel.\n     *\n     * @returns A new array of the relative sizes of the widgets.\n     *\n     * #### Notes\n     * The returned sizes reflect the sizes of the widgets normalized\n     * relative to their siblings.\n     *\n     * This method **does not** measure the DOM nodes.\n     */\n    SplitPanel.prototype.relativeSizes = function () {\n        return this.layout.relativeSizes();\n    };\n    /**\n     * Set the relative sizes for the widgets in the panel.\n     *\n     * @param sizes - The relative sizes for the widgets in the panel.\n     *\n     * #### Notes\n     * Extra values are ignored, too few will yield an undefined layout.\n     *\n     * The actual geometry of the DOM nodes is updated asynchronously.\n     */\n    SplitPanel.prototype.setRelativeSizes = function (sizes) {\n        this.layout.setRelativeSizes(sizes);\n    };\n    /**\n     * Handle the DOM events for the split panel.\n     *\n     * @param event - The DOM event sent to the panel.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the panel's DOM node. It should\n     * not be called directly by user code.\n     */\n    SplitPanel.prototype.handleEvent = function (event) {\n        switch (event.type) {\n            case 'mousedown':\n                this._evtMouseDown(event);\n                break;\n            case 'mousemove':\n                this._evtMouseMove(event);\n                break;\n            case 'mouseup':\n                this._evtMouseUp(event);\n                break;\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'contextmenu':\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    SplitPanel.prototype.onBeforeAttach = function (msg) {\n        this.node.addEventListener('mousedown', this);\n    };\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    SplitPanel.prototype.onAfterDetach = function (msg) {\n        this.node.removeEventListener('mousedown', this);\n        this._releaseMouse();\n    };\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    SplitPanel.prototype.onChildAdded = function (msg) {\n        msg.child.addClass('lm-SplitPanel-child');\n        /* <DEPRECATED> */\n        msg.child.addClass('p-SplitPanel-child');\n        /* </DEPRECATED> */\n        this._releaseMouse();\n    };\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    SplitPanel.prototype.onChildRemoved = function (msg) {\n        msg.child.removeClass('lm-SplitPanel-child');\n        /* <DEPRECATED> */\n        msg.child.removeClass('p-SplitPanel-child');\n        /* </DEPRECATED> */\n        this._releaseMouse();\n    };\n    /**\n     * Handle the `'keydown'` event for the split panel.\n     */\n    SplitPanel.prototype._evtKeyDown = function (event) {\n        // Stop input events during drag.\n        event.preventDefault();\n        event.stopPropagation();\n        // Release the mouse if `Escape` is pressed.\n        if (event.keyCode === 27) {\n            this._releaseMouse();\n        }\n    };\n    /**\n     * Handle the `'mousedown'` event for the split panel.\n     */\n    SplitPanel.prototype._evtMouseDown = function (event) {\n        // Do nothing if the left mouse button is not pressed.\n        if (event.button !== 0) {\n            return;\n        }\n        // Find the handle which contains the mouse target, if any.\n        var layout = this.layout;\n        var index = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.findFirstIndex(layout.handles, function (handle) {\n            return handle.contains(event.target);\n        });\n        // Bail early if the mouse press was not on a handle.\n        if (index === -1) {\n            return;\n        }\n        // Stop the event when a split handle is pressed.\n        event.preventDefault();\n        event.stopPropagation();\n        // Add the extra document listeners.\n        document.addEventListener('mouseup', this, true);\n        document.addEventListener('mousemove', this, true);\n        document.addEventListener('keydown', this, true);\n        document.addEventListener('contextmenu', this, true);\n        // Compute the offset delta for the handle press.\n        var delta;\n        var handle = layout.handles[index];\n        var rect = handle.getBoundingClientRect();\n        if (layout.orientation === 'horizontal') {\n            delta = event.clientX - rect.left;\n        }\n        else {\n            delta = event.clientY - rect.top;\n        }\n        // Override the cursor and store the press data.\n        var style = window.getComputedStyle(handle);\n        var override = _lumino_dragdrop__WEBPACK_IMPORTED_MODULE_10__.Drag.overrideCursor(style.cursor);\n        this._pressData = { index: index, delta: delta, override: override };\n    };\n    /**\n     * Handle the `'mousemove'` event for the split panel.\n     */\n    SplitPanel.prototype._evtMouseMove = function (event) {\n        // Stop the event when dragging a split handle.\n        event.preventDefault();\n        event.stopPropagation();\n        // Compute the desired offset position for the handle.\n        var pos;\n        var layout = this.layout;\n        var rect = this.node.getBoundingClientRect();\n        if (layout.orientation === 'horizontal') {\n            pos = event.clientX - rect.left - this._pressData.delta;\n        }\n        else {\n            pos = event.clientY - rect.top - this._pressData.delta;\n        }\n        // Move the handle as close to the desired position as possible.\n        layout.moveHandle(this._pressData.index, pos);\n    };\n    /**\n     * Handle the `'mouseup'` event for the split panel.\n     */\n    SplitPanel.prototype._evtMouseUp = function (event) {\n        // Do nothing if the left mouse button is not released.\n        if (event.button !== 0) {\n            return;\n        }\n        // Stop the event when releasing a handle.\n        event.preventDefault();\n        event.stopPropagation();\n        // Finalize the mouse release.\n        this._releaseMouse();\n    };\n    /**\n     * Release the mouse grab for the split panel.\n     */\n    SplitPanel.prototype._releaseMouse = function () {\n        // Bail early if no drag is in progress.\n        if (!this._pressData) {\n            return;\n        }\n        // Clear the override cursor.\n        this._pressData.override.dispose();\n        this._pressData = null;\n        // Remove the extra document listeners.\n        document.removeEventListener('mouseup', this, true);\n        document.removeEventListener('mousemove', this, true);\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('contextmenu', this, true);\n    };\n    return SplitPanel;\n}(Panel));\n/**\n * The namespace for the `SplitPanel` class statics.\n */\n(function (SplitPanel) {\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    var Renderer = /** @class */ (function () {\n        function Renderer() {\n        }\n        /**\n         * Create a new handle for use with a split panel.\n         *\n         * @returns A new handle element for a split panel.\n         */\n        Renderer.prototype.createHandle = function () {\n            var handle = document.createElement('div');\n            handle.className = 'lm-SplitPanel-handle';\n            /* <DEPRECATED> */\n            handle.classList.add('p-SplitPanel-handle');\n            /* </DEPRECATED> */\n            return handle;\n        };\n        return Renderer;\n    }());\n    SplitPanel.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    SplitPanel.defaultRenderer = new Renderer();\n    /**\n     * Get the split panel stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @returns The split panel stretch factor for the widget.\n     */\n    function getStretch(widget) {\n        return SplitLayout.getStretch(widget);\n    }\n    SplitPanel.getStretch = getStretch;\n    /**\n     * Set the split panel stretch factor for the given widget.\n     *\n     * @param widget - The widget of interest.\n     *\n     * @param value - The value for the stretch factor.\n     */\n    function setStretch(widget, value) {\n        SplitLayout.setStretch(widget, value);\n    }\n    SplitPanel.setStretch = setStretch;\n})(SplitPanel || (SplitPanel = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$f;\n(function (Private) {\n    /**\n     * Create a split layout for the given panel options.\n     */\n    function createLayout(options) {\n        return options.layout || new SplitLayout({\n            renderer: options.renderer || SplitPanel.defaultRenderer,\n            orientation: options.orientation,\n            alignment: options.alignment,\n            spacing: options.spacing\n        });\n    }\n    Private.createLayout = createLayout;\n})(Private$f || (Private$f = {}));\n\n/**\n * A layout where visible widgets are stacked atop one another.\n *\n * #### Notes\n * The Z-order of the visible widgets follows their layout order.\n */\nvar StackedLayout = /** @class */ (function (_super) {\n    __extends(StackedLayout, _super);\n    function StackedLayout() {\n        var _this = _super !== null && _super.apply(this, arguments) || this;\n        _this._dirty = false;\n        _this._items = [];\n        _this._box = null;\n        return _this;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    StackedLayout.prototype.dispose = function () {\n        // Dispose of the layout items.\n        (0,_lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.each)(this._items, function (item) { item.dispose(); });\n        // Clear the layout state.\n        this._box = null;\n        this._items.length = 0;\n        // Dispose of the rest of the layout.\n        _super.prototype.dispose.call(this);\n    };\n    /**\n     * Attach a widget to the parent's DOM node.\n     *\n     * @param index - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to attach to the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    StackedLayout.prototype.attachWidget = function (index, widget) {\n        // Create and add a new layout item for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.insert(this._items, index, new LayoutItem(widget));\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        }\n        // Add the widget's node to the parent.\n        this.parent.node.appendChild(widget.node);\n        // Send an `'after-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);\n        }\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * Move a widget in the parent's DOM node.\n     *\n     * @param fromIndex - The previous index of the widget in the layout.\n     *\n     * @param toIndex - The current index of the widget in the layout.\n     *\n     * @param widget - The widget to move in the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    StackedLayout.prototype.moveWidget = function (fromIndex, toIndex, widget) {\n        // Move the layout item for the widget.\n        _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.move(this._items, fromIndex, toIndex);\n        // Post an update request for the parent widget.\n        this.parent.update();\n    };\n    /**\n     * Detach a widget from the parent's DOM node.\n     *\n     * @param index - The previous index of the widget in the layout.\n     *\n     * @param widget - The widget to detach from the parent.\n     *\n     * #### Notes\n     * This is a reimplementation of the superclass method.\n     */\n    StackedLayout.prototype.detachWidget = function (index, widget) {\n        // Remove the layout item for the widget.\n        var item = _lumino_algorithm__WEBPACK_IMPORTED_MODULE_0__.ArrayExt.removeAt(this._items, index);\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        }\n        // Remove the widget's node from the parent.\n        this.parent.node.removeChild(widget.node);\n        // Send an `'after-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Reset the z-index for the widget.\n        item.widget.node.style.zIndex = '';\n        // Dispose of the layout item.\n        item.dispose();\n        // Post a fit request for the parent widget.\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'before-show'` message.\n     */\n    StackedLayout.prototype.onBeforeShow = function (msg) {\n        _super.prototype.onBeforeShow.call(this, msg);\n        this.parent.update();\n    };\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    StackedLayout.prototype.onBeforeAttach = function (msg) {\n        _super.prototype.onBeforeAttach.call(this, msg);\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    StackedLayout.prototype.onChildShown = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    StackedLayout.prototype.onChildHidden = function (msg) {\n        this.parent.fit();\n    };\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    StackedLayout.prototype.onResize = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(msg.width, msg.height);\n        }\n    };\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    StackedLayout.prototype.onUpdateRequest = function (msg) {\n        if (this.parent.isVisible) {\n            this._update(-1, -1);\n        }\n    };\n    /**\n     * A message handler invoked on a `'fit-request'` message.\n     */\n    StackedLayout.prototype.onFitRequest = function (msg) {\n        if (this.parent.isAttached) {\n            this._fit();\n        }\n    };\n    /**\n     * Fit the layout to the total size required by the widgets.\n     */\n    StackedLayout.prototype._fit = function () {\n        // Set up the computed minimum size.\n        var minW = 0;\n        var minH = 0;\n        // Update the computed minimum size.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Update the size limits for the item.\n            item.fit();\n            // Update the computed minimum size.\n            minW = Math.max(minW, item.minWidth);\n            minH = Math.max(minH, item.minHeight);\n        }\n        // Update the box sizing and add it to the computed min size.\n        var box = this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        var style = this.parent.node.style;\n        style.minWidth = minW + \"px\";\n        style.minHeight = minH + \"px\";\n        // Set the dirty flag to ensure only a single update occurs.\n        this._dirty = true;\n        // Notify the ancestor that it should fit immediately. This may\n        // cause a resize of the parent, fulfilling the required update.\n        if (this.parent.parent) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent.parent, Widget.Msg.FitRequest);\n        }\n        // If the dirty flag is still set, the parent was not resized.\n        // Trigger the required update on the parent widget immediately.\n        if (this._dirty) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n        }\n    };\n    /**\n     * Update the layout position and size of the widgets.\n     *\n     * The parent offset dimensions should be `-1` if unknown.\n     */\n    StackedLayout.prototype._update = function (offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Compute the visible item count.\n        var nVisible = 0;\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            nVisible += +!this._items[i].isHidden;\n        }\n        // Bail early if there are no visible items to layout.\n        if (nVisible === 0) {\n            return;\n        }\n        // Measure the parent if the offset dimensions are unknown.\n        if (offsetWidth < 0) {\n            offsetWidth = this.parent.node.offsetWidth;\n        }\n        if (offsetHeight < 0) {\n            offsetHeight = this.parent.node.offsetHeight;\n        }\n        // Ensure the parent box sizing data is computed.\n        if (!this._box) {\n            this._box = _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the actual layout bounds adjusted for border and padding.\n        var top = this._box.paddingTop;\n        var left = this._box.paddingLeft;\n        var width = offsetWidth - this._box.horizontalSum;\n        var height = offsetHeight - this._box.verticalSum;\n        // Update the widget stacking order and layout geometry.\n        for (var i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            var item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Set the z-index for the widget.\n            item.widget.node.style.zIndex = \"\" + i;\n            // Update the item geometry.\n            item.update(left, top, width, height);\n        }\n    };\n    return StackedLayout;\n}(PanelLayout));\n\n/**\n * A panel where visible widgets are stacked atop one another.\n *\n * #### Notes\n * This class provides a convenience wrapper around a [[StackedLayout]].\n */\nvar StackedPanel = /** @class */ (function (_super) {\n    __extends(StackedPanel, _super);\n    /**\n     * Construct a new stacked panel.\n     *\n     * @param options - The options for initializing the panel.\n     */\n    function StackedPanel(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this, { layout: Private$g.createLayout(options) }) || this;\n        _this._widgetRemoved = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this.addClass('lm-StackedPanel');\n        /* <DEPRECATED> */\n        _this.addClass('p-StackedPanel');\n        return _this;\n        /* </DEPRECATED> */\n    }\n    Object.defineProperty(StackedPanel.prototype, \"widgetRemoved\", {\n        /**\n         * A signal emitted when a widget is removed from a stacked panel.\n         */\n        get: function () {\n            return this._widgetRemoved;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    StackedPanel.prototype.onChildAdded = function (msg) {\n        msg.child.addClass('lm-StackedPanel-child');\n        /* <DEPRECATED> */\n        msg.child.addClass('p-StackedPanel-child');\n        /* </DEPRECATED> */\n    };\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    StackedPanel.prototype.onChildRemoved = function (msg) {\n        msg.child.removeClass('lm-StackedPanel-child');\n        /* <DEPRECATED> */\n        msg.child.removeClass('p-StackedPanel-child');\n        /* </DEPRECATED> */\n        this._widgetRemoved.emit(msg.child);\n    };\n    return StackedPanel;\n}(Panel));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$g;\n(function (Private) {\n    /**\n     * Create a stacked layout for the given panel options.\n     */\n    function createLayout(options) {\n        return options.layout || new StackedLayout();\n    }\n    Private.createLayout = createLayout;\n})(Private$g || (Private$g = {}));\n\n/**\n * A widget which combines a `TabBar` and a `StackedPanel`.\n *\n * #### Notes\n * This is a simple panel which handles the common case of a tab bar\n * placed next to a content area. The selected tab controls the widget\n * which is shown in the content area.\n *\n * For use cases which require more control than is provided by this\n * panel, the `TabBar` widget may be used independently.\n */\nvar TabPanel = /** @class */ (function (_super) {\n    __extends(TabPanel, _super);\n    /**\n     * Construct a new tab panel.\n     *\n     * @param options - The options for initializing the tab panel.\n     */\n    function TabPanel(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this) || this;\n        _this._currentChanged = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this._addRequested = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_4__.Signal(_this);\n        _this.addClass('lm-TabPanel');\n        /* <DEPRECATED> */\n        _this.addClass('p-TabPanel');\n        /* </DEPRECATED> */\n        // Create the tab bar and stacked panel.\n        _this.tabBar = new TabBar(options);\n        _this.tabBar.addClass('lm-TabPanel-tabBar');\n        _this.stackedPanel = new StackedPanel();\n        _this.stackedPanel.addClass('lm-TabPanel-stackedPanel');\n        /* <DEPRECATED> */\n        _this.tabBar.addClass('p-TabPanel-tabBar');\n        _this.stackedPanel.addClass('p-TabPanel-stackedPanel');\n        /* </DEPRECATED> */\n        // Connect the tab bar signal handlers.\n        _this.tabBar.tabMoved.connect(_this._onTabMoved, _this);\n        _this.tabBar.currentChanged.connect(_this._onCurrentChanged, _this);\n        _this.tabBar.tabCloseRequested.connect(_this._onTabCloseRequested, _this);\n        _this.tabBar.tabActivateRequested.connect(_this._onTabActivateRequested, _this);\n        _this.tabBar.addRequested.connect(_this._onTabAddRequested, _this);\n        // Connect the stacked panel signal handlers.\n        _this.stackedPanel.widgetRemoved.connect(_this._onWidgetRemoved, _this);\n        // Get the data related to the placement.\n        _this._tabPlacement = options.tabPlacement || 'top';\n        var direction = Private$h.directionFromPlacement(_this._tabPlacement);\n        var orientation = Private$h.orientationFromPlacement(_this._tabPlacement);\n        // Configure the tab bar for the placement.\n        _this.tabBar.orientation = orientation;\n        _this.tabBar.dataset['placement'] = _this._tabPlacement;\n        // Create the box layout.\n        var layout = new BoxLayout({ direction: direction, spacing: 0 });\n        // Set the stretch factors for the child widgets.\n        BoxLayout.setStretch(_this.tabBar, 0);\n        BoxLayout.setStretch(_this.stackedPanel, 1);\n        // Add the child widgets to the layout.\n        layout.addWidget(_this.tabBar);\n        layout.addWidget(_this.stackedPanel);\n        // Install the layout on the tab panel.\n        _this.layout = layout;\n        return _this;\n    }\n    Object.defineProperty(TabPanel.prototype, \"currentChanged\", {\n        /**\n         * A signal emitted when the current tab is changed.\n         *\n         * #### Notes\n         * This signal is emitted when the currently selected tab is changed\n         * either through user or programmatic interaction.\n         *\n         * Notably, this signal is not emitted when the index of the current\n         * tab changes due to tabs being inserted, removed, or moved. It is\n         * only emitted when the actual current tab node is changed.\n         */\n        get: function () {\n            return this._currentChanged;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"currentIndex\", {\n        /**\n         * Get the index of the currently selected tab.\n         *\n         * #### Notes\n         * This will be `-1` if no tab is selected.\n         */\n        get: function () {\n            return this.tabBar.currentIndex;\n        },\n        /**\n         * Set the index of the currently selected tab.\n         *\n         * #### Notes\n         * If the index is out of range, it will be set to `-1`.\n         */\n        set: function (value) {\n            this.tabBar.currentIndex = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"currentWidget\", {\n        /**\n         * Get the currently selected widget.\n         *\n         * #### Notes\n         * This will be `null` if there is no selected tab.\n         */\n        get: function () {\n            var title = this.tabBar.currentTitle;\n            return title ? title.owner : null;\n        },\n        /**\n         * Set the currently selected widget.\n         *\n         * #### Notes\n         * If the widget is not in the panel, it will be set to `null`.\n         */\n        set: function (value) {\n            this.tabBar.currentTitle = value ? value.title : null;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"tabsMovable\", {\n        /**\n         * Get the whether the tabs are movable by the user.\n         *\n         * #### Notes\n         * Tabs can always be moved programmatically.\n         */\n        get: function () {\n            return this.tabBar.tabsMovable;\n        },\n        /**\n         * Set the whether the tabs are movable by the user.\n         *\n         * #### Notes\n         * Tabs can always be moved programmatically.\n         */\n        set: function (value) {\n            this.tabBar.tabsMovable = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"addButtonEnabled\", {\n        /**\n         * Get the whether the add button is enabled.\n         *\n         */\n        get: function () {\n            return this.tabBar.addButtonEnabled;\n        },\n        /**\n         * Set the whether the add button is enabled.\n         *\n         */\n        set: function (value) {\n            this.tabBar.addButtonEnabled = value;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"tabPlacement\", {\n        /**\n         * Get the tab placement for the tab panel.\n         *\n         * #### Notes\n         * This controls the position of the tab bar relative to the content.\n         */\n        get: function () {\n            return this._tabPlacement;\n        },\n        /**\n         * Set the tab placement for the tab panel.\n         *\n         * #### Notes\n         * This controls the position of the tab bar relative to the content.\n         */\n        set: function (value) {\n            // Bail if the placement does not change.\n            if (this._tabPlacement === value) {\n                return;\n            }\n            // Update the internal value.\n            this._tabPlacement = value;\n            // Get the values related to the placement.\n            var direction = Private$h.directionFromPlacement(value);\n            var orientation = Private$h.orientationFromPlacement(value);\n            // Configure the tab bar for the placement.\n            this.tabBar.orientation = orientation;\n            this.tabBar.dataset['placement'] = value;\n            // Update the layout direction.\n            this.layout.direction = direction;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"addRequested\", {\n        /**\n         * A signal emitted when the add button on a tab bar is clicked.\n         *\n         */\n        get: function () {\n            return this._addRequested;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(TabPanel.prototype, \"widgets\", {\n        /**\n         * A read-only array of the widgets in the panel.\n         */\n        get: function () {\n            return this.stackedPanel.widgets;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Add a widget to the end of the tab panel.\n     *\n     * @param widget - The widget to add to the tab panel.\n     *\n     * #### Notes\n     * If the widget is already contained in the panel, it will be moved.\n     *\n     * The widget's `title` is used to populate the tab.\n     */\n    TabPanel.prototype.addWidget = function (widget) {\n        this.insertWidget(this.widgets.length, widget);\n    };\n    /**\n     * Insert a widget into the tab panel at a specified index.\n     *\n     * @param index - The index at which to insert the widget.\n     *\n     * @param widget - The widget to insert into to the tab panel.\n     *\n     * #### Notes\n     * If the widget is already contained in the panel, it will be moved.\n     *\n     * The widget's `title` is used to populate the tab.\n     */\n    TabPanel.prototype.insertWidget = function (index, widget) {\n        if (widget !== this.currentWidget) {\n            widget.hide();\n        }\n        this.stackedPanel.insertWidget(index, widget);\n        this.tabBar.insertTab(index, widget.title);\n        widget.node.setAttribute('role', 'tabpanel');\n        var renderer = this.tabBar.renderer;\n        if (renderer instanceof TabBar.Renderer) {\n            var tabId = renderer.createTabKey({ title: widget.title, current: false, zIndex: 0 });\n            widget.node.setAttribute('aria-labelledby', tabId);\n        }\n    };\n    /**\n     * Handle the `currentChanged` signal from the tab bar.\n     */\n    TabPanel.prototype._onCurrentChanged = function (sender, args) {\n        // Extract the previous and current title from the args.\n        var previousIndex = args.previousIndex, previousTitle = args.previousTitle, currentIndex = args.currentIndex, currentTitle = args.currentTitle;\n        // Extract the widgets from the titles.\n        var previousWidget = previousTitle ? previousTitle.owner : null;\n        var currentWidget = currentTitle ? currentTitle.owner : null;\n        // Hide the previous widget.\n        if (previousWidget) {\n            previousWidget.hide();\n        }\n        // Show the current widget.\n        if (currentWidget) {\n            currentWidget.show();\n        }\n        // Emit the `currentChanged` signal for the tab panel.\n        this._currentChanged.emit({\n            previousIndex: previousIndex, previousWidget: previousWidget, currentIndex: currentIndex, currentWidget: currentWidget\n        });\n        // Flush the message loop on IE and Edge to prevent flicker.\n        if (_lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Platform.IS_EDGE || _lumino_domutils__WEBPACK_IMPORTED_MODULE_1__.Platform.IS_IE) {\n            _lumino_messaging__WEBPACK_IMPORTED_MODULE_2__.MessageLoop.flush();\n        }\n    };\n    /**\n     * Handle the `tabAddRequested` signal from the tab bar.\n     */\n    TabPanel.prototype._onTabAddRequested = function (sender, args) {\n        this._addRequested.emit(sender);\n    };\n    /**\n     * Handle the `tabActivateRequested` signal from the tab bar.\n     */\n    TabPanel.prototype._onTabActivateRequested = function (sender, args) {\n        args.title.owner.activate();\n    };\n    /**\n     * Handle the `tabCloseRequested` signal from the tab bar.\n     */\n    TabPanel.prototype._onTabCloseRequested = function (sender, args) {\n        args.title.owner.close();\n    };\n    /**\n     * Handle the `tabMoved` signal from the tab bar.\n     */\n    TabPanel.prototype._onTabMoved = function (sender, args) {\n        this.stackedPanel.insertWidget(args.toIndex, args.title.owner);\n    };\n    /**\n     * Handle the `widgetRemoved` signal from the stacked panel.\n     */\n    TabPanel.prototype._onWidgetRemoved = function (sender, widget) {\n        widget.node.removeAttribute('role');\n        widget.node.removeAttribute('aria-labelledby');\n        this.tabBar.removeTab(widget.title);\n    };\n    return TabPanel;\n}(Widget));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$h;\n(function (Private) {\n    /**\n     * Convert a tab placement to tab bar orientation.\n     */\n    function orientationFromPlacement(plc) {\n        return placementToOrientationMap[plc];\n    }\n    Private.orientationFromPlacement = orientationFromPlacement;\n    /**\n     * Convert a tab placement to a box layout direction.\n     */\n    function directionFromPlacement(plc) {\n        return placementToDirectionMap[plc];\n    }\n    Private.directionFromPlacement = directionFromPlacement;\n    /**\n     * A mapping of tab placement to tab bar orientation.\n     */\n    var placementToOrientationMap = {\n        'top': 'horizontal',\n        'left': 'vertical',\n        'right': 'vertical',\n        'bottom': 'horizontal'\n    };\n    /**\n     * A mapping of tab placement to box layout direction.\n     */\n    var placementToDirectionMap = {\n        'top': 'top-to-bottom',\n        'left': 'left-to-right',\n        'right': 'right-to-left',\n        'bottom': 'bottom-to-top'\n    };\n})(Private$h || (Private$h = {}));\n\n\n//# sourceMappingURL=index.es6.js.map\n\n\n//# sourceURL=webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@lumino/widgets/dist/index.es6.js?");

/***/ })

}]);