{"version":3,"file":"index.umd.cjs","names":["Private","Private","Private","Private","Private","JSONExt","Private","Private","Private","Private","Widget","UUID","SplitPanel","JSONExt","DockPanel","MimeData","TabPanel","PWidget","d3Select","Widget","HTMLWidget","Utility","DockPanel","PWidget","d3Select","PSplitPanel","PTabPanel","factory","global","exports","__defProp","target","__getOwnPropDesc","__getOwnPropNames","__hasOwnProp","err","fn","res","mod","cb","name","all","no_symbols","from","keys","i","n","key","to","except","k","desc","PKG_NAME","PKG_VERSION","BUILD_VERSION","index_es6_exports","ArrayExt","StringExt","objects","object","value","index","result","empty","vmin","vmax","stop","start","step","length","Private$18","it","first","initial","second","accumulator","next","sorted","visited","graph","edge","edges","fromNode","toNode","children","node","child","count","item","iters","obj","tuple","init_index_es6","array","span","j","d","begin","half","middle","a","b","options","fromIndex","toIndex","delta","pivot","indices","query","source","score","last","require_dist","module","this$1","a1","a2","firstValue","secondValue","subvalue","mime","data","v","id","plugin","Private","plugins","force","required","t","optional","services","service","error","kind","promises","pluginId","manifest","downstream","token","reason","s","p","dependencies","trace","dep","acc","newEdges","oldSize","previousSize","packagesOfInterest","poi","algorithm","candidate","collection","resolve","reject","description","buffer","crypto","bytes","lut","getRandomValues","import_dist","sender","Private$17","slot","thisArg","args","receiver","old","handler","receivers","receiversForSender","signal","senders","sendersForReceiver","connection","dirtySet","schedule","connections","set","DisposableSet","items","ObservableDisposableSet","ClipboardExt","body","event","text","ElementExt","style","element","bt","bl","br","bb","pt","pl","pr","pb","minWidth","minHeight","maxWidth","maxHeight","rect","clientX","clientY","ar","area","er","Platform","Selector","selector","Private$16","proto","elem","matches","c","match","re","NEGATION_RE","ID_RE","CLASS_RE","ATTR_RE","PSEUDO_ELEM_RE","PSEDUO_CLASS_RE","TYPE_RE","IGNORE_RE","Private$15","KeycodeLayout","codes","modifierKeys","keySet","EN_US","CommandRegistry","Private$14","cmd","binding","keystroke","exact","hasPartial","partial","permission","keydownEvents","executionAllowed","newArgs","command","word","msg1","msg2","alt","ctrl","shift","mods","parts","separator","layout","distance","specificity","bindings","sqm","td","sp","MAC_DISPLAY","WIN_DISPLAY","dfault","bindKeys","userKeys","targ","curr","dist","clone","bubbles","cancelable","values","Private$13","ref","_ref","prev","_node","list","LinkedList","type","MessageLoop","pending","rejected","resolved","hooks","messageHooks","hook","msg","messageQueue","posted","flushGuard","sentinel","Private$12","map","owner","oldValue","newValue","create","coerce","compare","changed","Drag","f","Private$11","action","prevTarget","currTarget","prevElem","currElem","parent","drag","cursor","doc","actionTable","supportedTable","supported","lastElementEventSearch","root","transform","lastElementSearch","bbox","x","y","offsetX","offsetY","r","top","left","right","bottom","dl","dt","dr","db","dsw","dsh","shouldScroll","dragEvent","\"none\"","\"copy\"","\"link\"","\"move\"","overrideCursorID","scrollTarget","backdropScrollOrigin","backdrop","content","tag","attrs","renderer","arg","h","VirtualDOM","Private$10","oldContent","host","newContent","before","oldKeyed","oldCopy","newCount","oldVNode","newVNode","newKey","pair","oldKey","oldNode","_sentinel","specialAttrs","oldAttrs","newAttrs","dataset","oldDataset","newDataset","elemStyle","oldStyle","newStyle","keyMap","vNode","BoxEngine","sizers","space","totalMin","totalMax","totalSize","totalStretch","stretchCount","sizer","min","max","hint","nearZero","notDoneCount","freeSpace","distSpace","distStretch","amt","growLimit","shrinkLimit","grow","limit","shrink","Widget$1","Private$j","widget","hidden","flag","\"Display\"","\"Scale\"","\"ContentVisibility\"","Widget","\"IsDisposed\"","\"IsAttached\"","\"IsHidden\"","\"IsVisible\"","\"DisallowLayout\"","width","height","ResizeMessage","Private$i","limits","clampW","clampH","resized","Utils","Utils$1","SplitLayout","\"orientation\"","\"alignment\"","Private$h","temp","sizes","normed","update","handle","position","average","handleStyle","isHorizontal","size","nVisible","lastHandleIndex","horz","minW","minH","box","offsetWidth","offsetHeight","extra","offset","fullOffset","sum","oldTitle","expanded","newTitle","Private$g","title","titleStyle","Private$f","Private$e","override","pos","Private$d","isHidden","widgetSizes","newSize","widgetToCollapse","sz","idx","currentSize","handled","keyCode","direction","newIndex","aData","collapser","label","BoxLayout","\"direction\"","Private$c","dir","Private$b","CommandPalette","Private$a","newItems","clear","results","input","contentNode","activeIndex","category","active","ai","part","focused","className","kb","search","wrapper","commands","scores","rgx","rgxMatch","categoryIndices","labelIndices","m1","d1","i1","i2","d2","r1","r2","Menu","Private$9","menu","forceX","forceY","horizontalAlignment","collapsedFlags","collapsed","childMenu","parentMenu","kc","submenu","itemNode","activateFirst","aria","mnemonic","prefix","suffix","char","transientWindowDataCache","transientCacheCounter","k1","k2","hide","windowData","px","py","cw","ch","itemRect","auto","multiple","upperKey","mn","others","groupByTarget","sortBySelector","Private$8","rank","currentTarget","availableItems","s1","s2","ARROW_KEYS","TabBar","Private$7","pi","ci","ct","indexIsValid","tabs","titles","currentTitle","tabHandlingTabindex","current","zIndex","tabIndex","tab","elemTabindex","_c","focusedElement","focusable","focusedIndex","nextFocused","addButtonClicked","icon","closeIconPressed","tabRect","isTouch","duration","bh","request","runID","propertyName","add","orientation","dx","dy","pressPos","localPos","clientPos","clientSize","targetIndex","targetPos","targetEnd","pxPos","threshold","ideal","tgt","final","widgets","bar","widgetSet","mainConfig","config","Private$6","oldWidgets","oldTabBars","oldHandles","tabBar","mode","refNode","tabNode","borderWidth","borderHeight","existingWidget","splitNode","maybeParent","childNode","childHandle","parentNode","splitHandle","gChild","gHandle","gSizer","after","merge","sibling","oldRoot","newRoot","document","tabSizer","widgetSizer","tabBarItem","widgetItem","tabBarSizer","horizontal","fixed","spacing","tabId","DockPanel$1","Private$5","\"mode\"","zone","deltaX","deltaY","xPos","yPos","tabHeight","previousTitle","mimeData","dragImage","geo","delay","panel","selected","panelRect","al","at","ab","rx","ry","ad","GridLayout","Private$4","maxRow","maxCol","c1","c2","fixedRowSpace","fixedColSpace","w","minSize","portion","MenuBar","Private$3","menus","tabFocusIndex","totalMenuSize","isVisible","overflowMenuTitle","overflowMenuItems","screenSize","itemMenus","newMenu","oldMenu","Private$2","decrement","increment","track","thumb","\"action\"","scrollBar","Private$1","\"placement\"","previousWidget","currentWidget","placementToOrientationMap","plc","placementToDirectionMap","Msg","wa","other","_hpcc_js_common","closable","ext","lparam","WidgetAdapterArray","callback","intervalHandle","retVal","\"_renderer\"","deserialize","loc","canClose","pad","titleOrOptions","addMode","defaultSize","lookup","defaults","containerWidth","containerHeight","totalSpace","availWidth","availHeight","usedSpace","flexCount","pixelSizes","remainingSpace","flexSize","ratio","childW","childH","_","domNode","context","tabBars","refit","tabsCount","_orientation","opts","widgetExt","padding","found"],"sources":["../src/__package__.ts","../../../node_modules/@lumino/algorithm/dist/index.es6.js","../../../node_modules/@lumino/coreutils/dist/index.js","../../../node_modules/@lumino/signaling/dist/index.es6.js","../../../node_modules/@lumino/disposable/dist/index.es6.js","../../../node_modules/@lumino/domutils/dist/index.es6.js","../../../node_modules/@lumino/keyboard/dist/index.es6.js","../../../node_modules/@lumino/commands/dist/index.es6.js","../../../node_modules/@lumino/collections/dist/index.es6.js","../../../node_modules/@lumino/messaging/dist/index.es6.js","../../../node_modules/@lumino/properties/dist/index.es6.js","../../../node_modules/@lumino/dragdrop/dist/index.es6.js","../../../node_modules/@lumino/virtualdom/dist/index.es6.js","../../../node_modules/@lumino/widgets/dist/index.es6.js","../src/phosphor-shim.ts","../src/WidgetAdapter.ts","../src/BasePanel.ts","../src/PDockPanel.ts","../src/DockPanel.ts","../src/SplitPanel.ts","../src/TabPanel.ts"],"sourcesContent":["export const PKG_NAME = \"@hpcc-js/phosphor\";\nexport const PKG_VERSION = \"3.10.5\";\nexport const BUILD_VERSION = \"3.38.1\";\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 * The namespace for array-specific algorithms.\n */\nvar ArrayExt;\n(function (ArrayExt) {\n    /**\n     * Find the index of the first occurrence of a value in an array.\n     *\n     * @param array - The array-like object to search.\n     *\n     * @param value - The value to locate in the array. Values are\n     *   compared using strict `===` equality.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the first occurrence of the value, or `-1`\n     *   if the value is not found.\n     *\n     * #### Notes\n     * If `stop < start` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = ['one', 'two', 'three', 'four', 'one'];\n     * ArrayExt.firstIndexOf(data, 'red');        // -1\n     * ArrayExt.firstIndexOf(data, 'one');        // 0\n     * ArrayExt.firstIndexOf(data, 'one', 1);     // 4\n     * ArrayExt.firstIndexOf(data, 'two', 2);     // -1\n     * ArrayExt.firstIndexOf(data, 'two', 2, 1);  // 1\n     * ```\n     */\n    function firstIndexOf(array, value, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return -1;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let span;\n        if (stop < start) {\n            span = stop + 1 + (n - start);\n        }\n        else {\n            span = stop - start + 1;\n        }\n        for (let i = 0; i < span; ++i) {\n            let j = (start + i) % n;\n            if (array[j] === value) {\n                return j;\n            }\n        }\n        return -1;\n    }\n    ArrayExt.firstIndexOf = firstIndexOf;\n    /**\n     * Find the index of the last occurrence of a value in an array.\n     *\n     * @param array - The array-like object to search.\n     *\n     * @param value - The value to locate in the array. Values are\n     *   compared using strict `===` equality.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the last occurrence of the value, or `-1`\n     *   if the value is not found.\n     *\n     * #### Notes\n     * If `start < stop` the search will wrap at the front of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = ['one', 'two', 'three', 'four', 'one'];\n     * ArrayExt.lastIndexOf(data, 'red');        // -1\n     * ArrayExt.lastIndexOf(data, 'one');        // 4\n     * ArrayExt.lastIndexOf(data, 'one', 1);     // 0\n     * ArrayExt.lastIndexOf(data, 'two', 0);     // -1\n     * ArrayExt.lastIndexOf(data, 'two', 0, 1);  // 1\n     * ```\n     */\n    function lastIndexOf(array, value, start = -1, stop = 0) {\n        let n = array.length;\n        if (n === 0) {\n            return -1;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let span;\n        if (start < stop) {\n            span = start + 1 + (n - stop);\n        }\n        else {\n            span = start - stop + 1;\n        }\n        for (let i = 0; i < span; ++i) {\n            let j = (start - i + n) % n;\n            if (array[j] === value) {\n                return j;\n            }\n        }\n        return -1;\n    }\n    ArrayExt.lastIndexOf = lastIndexOf;\n    /**\n     * Find the index of the first value which matches a predicate.\n     *\n     * @param array - The array-like object to search.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the first matching value, or `-1` if no\n     *   matching value is found.\n     *\n     * #### Notes\n     * If `stop < start` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * Modifying the length of the array while searching.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * let data = [1, 2, 3, 4, 3, 2, 1];\n     * ArrayExt.findFirstIndex(data, isEven);       // 1\n     * ArrayExt.findFirstIndex(data, isEven, 4);    // 5\n     * ArrayExt.findFirstIndex(data, isEven, 6);    // -1\n     * ArrayExt.findFirstIndex(data, isEven, 6, 5); // 1\n     * ```\n     */\n    function findFirstIndex(array, fn, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return -1;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let span;\n        if (stop < start) {\n            span = stop + 1 + (n - start);\n        }\n        else {\n            span = stop - start + 1;\n        }\n        for (let i = 0; i < span; ++i) {\n            let j = (start + i) % n;\n            if (fn(array[j], j)) {\n                return j;\n            }\n        }\n        return -1;\n    }\n    ArrayExt.findFirstIndex = findFirstIndex;\n    /**\n     * Find the index of the last value which matches a predicate.\n     *\n     * @param array - The array-like object to search.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the last matching value, or `-1` if no\n     *   matching value is found.\n     *\n     * #### Notes\n     * If `start < stop` the search will wrap at the front of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * Modifying the length of the array while searching.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * let data = [1, 2, 3, 4, 3, 2, 1];\n     * ArrayExt.findLastIndex(data, isEven);        // 5\n     * ArrayExt.findLastIndex(data, isEven, 4);     // 3\n     * ArrayExt.findLastIndex(data, isEven, 0);     // -1\n     * ArrayExt.findLastIndex(data, isEven, 0, 1);  // 5\n     * ```\n     */\n    function findLastIndex(array, fn, start = -1, stop = 0) {\n        let n = array.length;\n        if (n === 0) {\n            return -1;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let d;\n        if (start < stop) {\n            d = start + 1 + (n - stop);\n        }\n        else {\n            d = start - stop + 1;\n        }\n        for (let i = 0; i < d; ++i) {\n            let j = (start - i + n) % n;\n            if (fn(array[j], j)) {\n                return j;\n            }\n        }\n        return -1;\n    }\n    ArrayExt.findLastIndex = findLastIndex;\n    /**\n     * Find the first value which matches a predicate.\n     *\n     * @param array - The array-like object to search.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The first matching value, or `undefined` if no matching\n     *   value is found.\n     *\n     * #### Notes\n     * If `stop < start` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * Modifying the length of the array while searching.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * let data = [1, 2, 3, 4, 3, 2, 1];\n     * ArrayExt.findFirstValue(data, isEven);       // 2\n     * ArrayExt.findFirstValue(data, isEven, 2);    // 4\n     * ArrayExt.findFirstValue(data, isEven, 6);    // undefined\n     * ArrayExt.findFirstValue(data, isEven, 6, 5); // 2\n     * ```\n     */\n    function findFirstValue(array, fn, start = 0, stop = -1) {\n        let index = findFirstIndex(array, fn, start, stop);\n        return index !== -1 ? array[index] : undefined;\n    }\n    ArrayExt.findFirstValue = findFirstValue;\n    /**\n     * Find the last value which matches a predicate.\n     *\n     * @param object - The array-like object to search.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The last matching value, or `undefined` if no matching\n     *   value is found.\n     *\n     * #### Notes\n     * If `start < stop` the search will wrap at the front of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * Modifying the length of the array while searching.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * let data = [1, 2, 3, 4, 3, 2, 1];\n     * ArrayExt.findLastValue(data, isEven);        // 2\n     * ArrayExt.findLastValue(data, isEven, 4);     // 4\n     * ArrayExt.findLastValue(data, isEven, 0);     // undefined\n     * ArrayExt.findLastValue(data, isEven, 0, 1);  // 2\n     * ```\n     */\n    function findLastValue(array, fn, start = -1, stop = 0) {\n        let index = findLastIndex(array, fn, start, stop);\n        return index !== -1 ? array[index] : undefined;\n    }\n    ArrayExt.findLastValue = findLastValue;\n    /**\n     * Find the index of the first element which compares `>=` to a value.\n     *\n     * @param array - The sorted array-like object to search.\n     *\n     * @param value - The value to locate in the array.\n     *\n     * @param fn - The 3-way comparison function to apply to the values.\n     *   It should return `< 0` if an element is less than a value, `0` if\n     *   an element is equal to a value, or `> 0` if an element is greater\n     *   than a value.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the first element which compares `>=` to the\n     *   value, or `length` if there is no such element. If the computed\n     *   index for `stop` is less than `start`, then the computed index\n     *   for `start` is returned.\n     *\n     * #### Notes\n     * The array must already be sorted in ascending order according to\n     * the comparison function.\n     *\n     * #### Complexity\n     * Logarithmic.\n     *\n     * #### Undefined Behavior\n     * Searching a range which is not sorted in ascending order.\n     *\n     * A `start` or `stop` which is non-integral.\n     *\n     * Modifying the length of the array while searching.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function numberCmp(a: number, b: number): number {\n     *   return a - b;\n     * }\n     *\n     * let data = [0, 3, 4, 7, 7, 9];\n     * ArrayExt.lowerBound(data, 0, numberCmp);   // 0\n     * ArrayExt.lowerBound(data, 6, numberCmp);   // 3\n     * ArrayExt.lowerBound(data, 7, numberCmp);   // 3\n     * ArrayExt.lowerBound(data, -1, numberCmp);  // 0\n     * ArrayExt.lowerBound(data, 10, numberCmp);  // 6\n     * ```\n     */\n    function lowerBound(array, value, fn, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return 0;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let begin = start;\n        let span = stop - start + 1;\n        while (span > 0) {\n            let half = span >> 1;\n            let middle = begin + half;\n            if (fn(array[middle], value) < 0) {\n                begin = middle + 1;\n                span -= half + 1;\n            }\n            else {\n                span = half;\n            }\n        }\n        return begin;\n    }\n    ArrayExt.lowerBound = lowerBound;\n    /**\n     * Find the index of the first element which compares `>` than a value.\n     *\n     * @param array - The sorted array-like object to search.\n     *\n     * @param value - The value to locate in the array.\n     *\n     * @param fn - The 3-way comparison function to apply to the values.\n     *   It should return `< 0` if an element is less than a value, `0` if\n     *   an element is equal to a value, or `> 0` if an element is greater\n     *   than a value.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the first element which compares `>` than the\n     *   value, or `length` if there is no such element. If the computed\n     *   index for `stop` is less than `start`, then the computed index\n     *   for `start` is returned.\n     *\n     * #### Notes\n     * The array must already be sorted in ascending order according to\n     * the comparison function.\n     *\n     * #### Complexity\n     * Logarithmic.\n     *\n     * #### Undefined Behavior\n     * Searching a range which is not sorted in ascending order.\n     *\n     * A `start` or `stop` which is non-integral.\n     *\n     * Modifying the length of the array while searching.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function numberCmp(a: number, b: number): number {\n     *   return a - b;\n     * }\n     *\n     * let data = [0, 3, 4, 7, 7, 9];\n     * ArrayExt.upperBound(data, 0, numberCmp);   // 1\n     * ArrayExt.upperBound(data, 6, numberCmp);   // 3\n     * ArrayExt.upperBound(data, 7, numberCmp);   // 5\n     * ArrayExt.upperBound(data, -1, numberCmp);  // 0\n     * ArrayExt.upperBound(data, 10, numberCmp);  // 6\n     * ```\n     */\n    function upperBound(array, value, fn, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return 0;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let begin = start;\n        let span = stop - start + 1;\n        while (span > 0) {\n            let half = span >> 1;\n            let middle = begin + half;\n            if (fn(array[middle], value) > 0) {\n                span = half;\n            }\n            else {\n                begin = middle + 1;\n                span -= half + 1;\n            }\n        }\n        return begin;\n    }\n    ArrayExt.upperBound = upperBound;\n    /**\n     * Test whether two arrays are shallowly equal.\n     *\n     * @param a - The first array-like object to compare.\n     *\n     * @param b - The second array-like object to compare.\n     *\n     * @param fn - The comparison function to apply to the elements. It\n     *   should return `true` if the elements are \"equal\". The default\n     *   compares elements using strict `===` equality.\n     *\n     * @returns Whether the two arrays are shallowly equal.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * Modifying the length of the arrays while comparing.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let d1 = [0, 3, 4, 7, 7, 9];\n     * let d2 = [0, 3, 4, 7, 7, 9];\n     * let d3 = [42];\n     * ArrayExt.shallowEqual(d1, d2);  // true\n     * ArrayExt.shallowEqual(d2, d3);  // false\n     * ```\n     */\n    function shallowEqual(a, b, fn) {\n        // Check for object identity first.\n        if (a === b) {\n            return true;\n        }\n        // Bail early if the lengths are different.\n        if (a.length !== b.length) {\n            return false;\n        }\n        // Compare each element for equality.\n        for (let i = 0, n = a.length; i < n; ++i) {\n            if (fn ? !fn(a[i], b[i]) : a[i] !== b[i]) {\n                return false;\n            }\n        }\n        // The array are shallowly equal.\n        return true;\n    }\n    ArrayExt.shallowEqual = shallowEqual;\n    /**\n     * Create a slice of an array subject to an optional step.\n     *\n     * @param array - The array-like object of interest.\n     *\n     * @param options - The options for configuring the slice.\n     *\n     * @returns A new array with the specified values.\n     *\n     * @throws An exception if the slice `step` is `0`.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start`, `stop`, or `step` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 3, 4, 7, 7, 9];\n     * ArrayExt.slice(data);                         // [0, 3, 4, 7, 7, 9]\n     * ArrayExt.slice(data, { start: 2 });           // [4, 7, 7, 9]\n     * ArrayExt.slice(data, { start: 0, stop: 4 });  // [0, 3, 4, 7]\n     * ArrayExt.slice(data, { step: 2 });            // [0, 4, 7]\n     * ArrayExt.slice(data, { step: -1 });           // [9, 7, 7, 4, 3, 0]\n     * ```\n     */\n    function slice(array, options = {}) {\n        // Extract the options.\n        let { start, stop, step } = options;\n        // Set up the `step` value.\n        if (step === undefined) {\n            step = 1;\n        }\n        // Validate the step size.\n        if (step === 0) {\n            throw new Error('Slice `step` cannot be zero.');\n        }\n        // Look up the length of the array.\n        let n = array.length;\n        // Set up the `start` value.\n        if (start === undefined) {\n            start = step < 0 ? n - 1 : 0;\n        }\n        else if (start < 0) {\n            start = Math.max(start + n, step < 0 ? -1 : 0);\n        }\n        else if (start >= n) {\n            start = step < 0 ? n - 1 : n;\n        }\n        // Set up the `stop` value.\n        if (stop === undefined) {\n            stop = step < 0 ? -1 : n;\n        }\n        else if (stop < 0) {\n            stop = Math.max(stop + n, step < 0 ? -1 : 0);\n        }\n        else if (stop >= n) {\n            stop = step < 0 ? n - 1 : n;\n        }\n        // Compute the slice length.\n        let length;\n        if ((step < 0 && stop >= start) || (step > 0 && start >= stop)) {\n            length = 0;\n        }\n        else if (step < 0) {\n            length = Math.floor((stop - start + 1) / step + 1);\n        }\n        else {\n            length = Math.floor((stop - start - 1) / step + 1);\n        }\n        // Compute the sliced result.\n        let result = [];\n        for (let i = 0; i < length; ++i) {\n            result[i] = array[start + i * step];\n        }\n        // Return the result.\n        return result;\n    }\n    ArrayExt.slice = slice;\n    /**\n     * Move an element in an array from one index to another.\n     *\n     * @param array - The mutable array-like object of interest.\n     *\n     * @param fromIndex - The index of the element to move. Negative\n     *   values are taken as an offset from the end of the array.\n     *\n     * @param toIndex - The target index of the element. Negative\n     *   values are taken as an offset from the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `fromIndex` or `toIndex` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 1, 2, 3, 4];\n     * ArrayExt.move(data, 1, 2);  // [0, 2, 1, 3, 4]\n     * ArrayExt.move(data, 4, 2);  // [0, 2, 4, 1, 3]\n     * ```\n     */\n    function move(array, fromIndex, toIndex) {\n        let n = array.length;\n        if (n <= 1) {\n            return;\n        }\n        if (fromIndex < 0) {\n            fromIndex = Math.max(0, fromIndex + n);\n        }\n        else {\n            fromIndex = Math.min(fromIndex, n - 1);\n        }\n        if (toIndex < 0) {\n            toIndex = Math.max(0, toIndex + n);\n        }\n        else {\n            toIndex = Math.min(toIndex, n - 1);\n        }\n        if (fromIndex === toIndex) {\n            return;\n        }\n        let value = array[fromIndex];\n        let d = fromIndex < toIndex ? 1 : -1;\n        for (let i = fromIndex; i !== toIndex; i += d) {\n            array[i] = array[i + d];\n        }\n        array[toIndex] = value;\n    }\n    ArrayExt.move = move;\n    /**\n     * Reverse an array in-place.\n     *\n     * @param array - The mutable array-like object of interest.\n     *\n     * @param start - The index of the first element in the range to be\n     *   reversed, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   reversed, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or  `stop` index which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 1, 2, 3, 4];\n     * ArrayExt.reverse(data, 1, 3);  // [0, 3, 2, 1, 4]\n     * ArrayExt.reverse(data, 3);     // [0, 3, 2, 4, 1]\n     * ArrayExt.reverse(data);        // [1, 4, 2, 3, 0]\n     * ```\n     */\n    function reverse(array, start = 0, stop = -1) {\n        let n = array.length;\n        if (n <= 1) {\n            return;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        while (start < stop) {\n            let a = array[start];\n            let b = array[stop];\n            array[start++] = b;\n            array[stop--] = a;\n        }\n    }\n    ArrayExt.reverse = reverse;\n    /**\n     * Rotate the elements of an array in-place.\n     *\n     * @param array - The mutable array-like object of interest.\n     *\n     * @param delta - The amount of rotation to apply to the elements. A\n     *   positive value will rotate the elements to the left. A negative\n     *   value will rotate the elements to the right.\n     *\n     * @param start - The index of the first element in the range to be\n     *   rotated, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   rotated, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `delta`, `start`, or `stop` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 1, 2, 3, 4];\n     * ArrayExt.rotate(data, 2);        // [2, 3, 4, 0, 1]\n     * ArrayExt.rotate(data, -2);       // [0, 1, 2, 3, 4]\n     * ArrayExt.rotate(data, 10);       // [0, 1, 2, 3, 4]\n     * ArrayExt.rotate(data, 9);        // [4, 0, 1, 2, 3]\n     * ArrayExt.rotate(data, 2, 1, 3);  // [4, 2, 0, 1, 3]\n     * ```\n     */\n    function rotate(array, delta, start = 0, stop = -1) {\n        let n = array.length;\n        if (n <= 1) {\n            return;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        if (start >= stop) {\n            return;\n        }\n        let length = stop - start + 1;\n        if (delta > 0) {\n            delta = delta % length;\n        }\n        else if (delta < 0) {\n            delta = ((delta % length) + length) % length;\n        }\n        if (delta === 0) {\n            return;\n        }\n        let pivot = start + delta;\n        reverse(array, start, pivot - 1);\n        reverse(array, pivot, stop);\n        reverse(array, start, stop);\n    }\n    ArrayExt.rotate = rotate;\n    /**\n     * Fill an array with a static value.\n     *\n     * @param array - The mutable array-like object to fill.\n     *\n     * @param value - The static value to use to fill the array.\n     *\n     * @param start - The index of the first element in the range to be\n     *   filled, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   filled, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * #### Notes\n     * If `stop < start` the fill will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * A `start` or `stop` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = ['one', 'two', 'three', 'four'];\n     * ArrayExt.fill(data, 'r');        // ['r', 'r', 'r', 'r']\n     * ArrayExt.fill(data, 'g', 1);     // ['r', 'g', 'g', 'g']\n     * ArrayExt.fill(data, 'b', 2, 3);  // ['r', 'g', 'b', 'b']\n     * ArrayExt.fill(data, 'z', 3, 1);  // ['z', 'z', 'b', 'z']\n     * ```\n     */\n    function fill(array, value, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let span;\n        if (stop < start) {\n            span = stop + 1 + (n - start);\n        }\n        else {\n            span = stop - start + 1;\n        }\n        for (let i = 0; i < span; ++i) {\n            array[(start + i) % n] = value;\n        }\n    }\n    ArrayExt.fill = fill;\n    /**\n     * Insert a value into an array at a specific index.\n     *\n     * @param array - The array of interest.\n     *\n     * @param index - The index at which to insert the value. Negative\n     *   values are taken as an offset from the end of the array.\n     *\n     * @param value - The value to set at the specified index.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * An `index` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 1, 2];\n     * ArrayExt.insert(data, 0, -1);  // [-1, 0, 1, 2]\n     * ArrayExt.insert(data, 2, 12);  // [-1, 0, 12, 1, 2]\n     * ArrayExt.insert(data, -1, 7);  // [-1, 0, 12, 1, 7, 2]\n     * ArrayExt.insert(data, 6, 19);  // [-1, 0, 12, 1, 7, 2, 19]\n     * ```\n     */\n    function insert(array, index, value) {\n        let n = array.length;\n        if (index < 0) {\n            index = Math.max(0, index + n);\n        }\n        else {\n            index = Math.min(index, n);\n        }\n        for (let i = n; i > index; --i) {\n            array[i] = array[i - 1];\n        }\n        array[index] = value;\n    }\n    ArrayExt.insert = insert;\n    /**\n     * Remove and return a value at a specific index in an array.\n     *\n     * @param array - The array of interest.\n     *\n     * @param index - The index of the value to remove. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The value at the specified index, or `undefined` if the\n     *   index is out of range.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Undefined Behavior\n     * An `index` which is non-integral.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 12, 23, 39, 14, 12, 75];\n     * ArrayExt.removeAt(data, 2);   // 23\n     * ArrayExt.removeAt(data, -2);  // 12\n     * ArrayExt.removeAt(data, 10);  // undefined;\n     * ```\n     */\n    function removeAt(array, index) {\n        let n = array.length;\n        if (index < 0) {\n            index += n;\n        }\n        if (index < 0 || index >= n) {\n            return undefined;\n        }\n        let value = array[index];\n        for (let i = index + 1; i < n; ++i) {\n            array[i - 1] = array[i];\n        }\n        array.length = n - 1;\n        return value;\n    }\n    ArrayExt.removeAt = removeAt;\n    /**\n     * Remove the first occurrence of a value from an array.\n     *\n     * @param array - The array of interest.\n     *\n     * @param value - The value to remove from the array. Values are\n     *   compared using strict `===` equality.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the removed value, or `-1` if the value\n     *   is not contained in the array.\n     *\n     * #### Notes\n     * If `stop < start` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 12, 23, 39, 14, 12, 75];\n     * ArrayExt.removeFirstOf(data, 12);        // 1\n     * ArrayExt.removeFirstOf(data, 17);        // -1\n     * ArrayExt.removeFirstOf(data, 39, 3);     // -1\n     * ArrayExt.removeFirstOf(data, 39, 3, 2);  // 2\n     * ```\n     */\n    function removeFirstOf(array, value, start = 0, stop = -1) {\n        let index = firstIndexOf(array, value, start, stop);\n        if (index !== -1) {\n            removeAt(array, index);\n        }\n        return index;\n    }\n    ArrayExt.removeFirstOf = removeFirstOf;\n    /**\n     * Remove the last occurrence of a value from an array.\n     *\n     * @param array - The array of interest.\n     *\n     * @param value - The value to remove from the array. Values are\n     *   compared using strict `===` equality.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The index of the removed value, or `-1` if the value\n     *   is not contained in the array.\n     *\n     * #### Notes\n     * If `start < stop` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [0, 12, 23, 39, 14, 12, 75];\n     * ArrayExt.removeLastOf(data, 12);        // 5\n     * ArrayExt.removeLastOf(data, 17);        // -1\n     * ArrayExt.removeLastOf(data, 39, 2);     // -1\n     * ArrayExt.removeLastOf(data, 39, 2, 3);  // 3\n     * ```\n     */\n    function removeLastOf(array, value, start = -1, stop = 0) {\n        let index = lastIndexOf(array, value, start, stop);\n        if (index !== -1) {\n            removeAt(array, index);\n        }\n        return index;\n    }\n    ArrayExt.removeLastOf = removeLastOf;\n    /**\n     * Remove all occurrences of a value from an array.\n     *\n     * @param array - The array of interest.\n     *\n     * @param value - The value to remove from the array. Values are\n     *   compared using strict `===` equality.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The number of elements removed from the array.\n     *\n     * #### Notes\n     * If `stop < start` the search will conceptually wrap at the end of\n     * the array, however the array will be traversed front-to-back.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * let data = [14, 12, 23, 39, 14, 12, 19, 14];\n     * ArrayExt.removeAllOf(data, 12);        // 2\n     * ArrayExt.removeAllOf(data, 17);        // 0\n     * ArrayExt.removeAllOf(data, 14, 1, 4);  // 1\n     * ```\n     */\n    function removeAllOf(array, value, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return 0;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let count = 0;\n        for (let i = 0; i < n; ++i) {\n            if (start <= stop && i >= start && i <= stop && array[i] === value) {\n                count++;\n            }\n            else if (stop < start &&\n                (i <= stop || i >= start) &&\n                array[i] === value) {\n                count++;\n            }\n            else if (count > 0) {\n                array[i - count] = array[i];\n            }\n        }\n        if (count > 0) {\n            array.length = n - count;\n        }\n        return count;\n    }\n    ArrayExt.removeAllOf = removeAllOf;\n    /**\n     * Remove the first occurrence of a value which matches a predicate.\n     *\n     * @param array - The array of interest.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The removed `{ index, value }`, which will be `-1` and\n     *   `undefined` if the value is not contained in the array.\n     *\n     * #### Notes\n     * If `stop < start` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * let data = [0, 12, 23, 39, 14, 12, 75];\n     * ArrayExt.removeFirstWhere(data, isEven);     // { index: 0, value: 0 }\n     * ArrayExt.removeFirstWhere(data, isEven, 2);  // { index: 3, value: 14 }\n     * ArrayExt.removeFirstWhere(data, isEven, 4);  // { index: -1, value: undefined }\n     * ```\n     */\n    function removeFirstWhere(array, fn, start = 0, stop = -1) {\n        let value;\n        let index = findFirstIndex(array, fn, start, stop);\n        if (index !== -1) {\n            value = removeAt(array, index);\n        }\n        return { index, value };\n    }\n    ArrayExt.removeFirstWhere = removeFirstWhere;\n    /**\n     * Remove the last occurrence of a value which matches a predicate.\n     *\n     * @param array - The array of interest.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The removed `{ index, value }`, which will be `-1` and\n     *   `undefined` if the value is not contained in the array.\n     *\n     * #### Notes\n     * If `start < stop` the search will wrap at the end of the array.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * let data = [0, 12, 23, 39, 14, 12, 75];\n     * ArrayExt.removeLastWhere(data, isEven);        // { index: 5, value: 12 }\n     * ArrayExt.removeLastWhere(data, isEven, 2);     // { index: 1, value: 12 }\n     * ArrayExt.removeLastWhere(data, isEven, 2, 1);  // { index: -1, value: undefined }\n     * ```\n     */\n    function removeLastWhere(array, fn, start = -1, stop = 0) {\n        let value;\n        let index = findLastIndex(array, fn, start, stop);\n        if (index !== -1) {\n            value = removeAt(array, index);\n        }\n        return { index, value };\n    }\n    ArrayExt.removeLastWhere = removeLastWhere;\n    /**\n     * Remove all occurrences of values which match a predicate.\n     *\n     * @param array - The array of interest.\n     *\n     * @param fn - The predicate function to apply to the values.\n     *\n     * @param start - The index of the first element in the range to be\n     *   searched, inclusive. The default value is `0`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @param stop - The index of the last element in the range to be\n     *   searched, inclusive. The default value is `-1`. Negative values\n     *   are taken as an offset from the end of the array.\n     *\n     * @returns The number of elements removed from the array.\n     *\n     * #### Notes\n     * If `stop < start` the search will conceptually wrap at the end of\n     * the array, however the array will be traversed front-to-back.\n     *\n     * #### Complexity\n     * Linear.\n     *\n     * #### Example\n     * ```typescript\n     * import { ArrayExt } from '@lumino/algorithm';\n     *\n     * function isEven(value: number): boolean {\n     *   return value % 2 === 0;\n     * }\n     *\n     * function isNegative(value: number): boolean {\n     *   return value < 0;\n     * }\n     *\n     * let data = [0, 12, -13, -9, 23, 39, 14, -15, 12, 75];\n     * ArrayExt.removeAllWhere(data, isEven);            // 4\n     * ArrayExt.removeAllWhere(data, isNegative, 0, 3);  // 2\n     * ```\n     */\n    function removeAllWhere(array, fn, start = 0, stop = -1) {\n        let n = array.length;\n        if (n === 0) {\n            return 0;\n        }\n        if (start < 0) {\n            start = Math.max(0, start + n);\n        }\n        else {\n            start = Math.min(start, n - 1);\n        }\n        if (stop < 0) {\n            stop = Math.max(0, stop + n);\n        }\n        else {\n            stop = Math.min(stop, n - 1);\n        }\n        let count = 0;\n        for (let i = 0; i < n; ++i) {\n            if (start <= stop && i >= start && i <= stop && fn(array[i], i)) {\n                count++;\n            }\n            else if (stop < start && (i <= stop || i >= start) && fn(array[i], i)) {\n                count++;\n            }\n            else if (count > 0) {\n                array[i - count] = array[i];\n            }\n        }\n        if (count > 0) {\n            array.length = n - count;\n        }\n        return count;\n    }\n    ArrayExt.removeAllWhere = removeAllWhere;\n})(ArrayExt || (ArrayExt = {}));\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 * Chain together several iterables.\n *\n * @deprecated\n *\n * @param objects - The iterable objects of interest.\n *\n * @returns An iterator which yields the values of the iterables\n *   in the order in which they are supplied.\n *\n * #### Example\n * ```typescript\n * import { chain } from '@lumino/algorithm';\n *\n * let data1 = [1, 2, 3];\n * let data2 = [4, 5, 6];\n *\n * let stream = chain(data1, data2);\n *\n * Array.from(stream);  // [1, 2, 3, 4, 5, 6]\n * ```\n */\nfunction* chain(...objects) {\n    for (const object of objects) {\n        yield* object;\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 * Create an empty iterator.\n *\n * @returns A new iterator which yields nothing.\n *\n * #### Example\n * ```typescript\n * import { empty } from '@lumino/algorithm';\n *\n * let stream = empty<number>();\n *\n * Array.from(stream);  // []\n * ```\n */\n// eslint-disable-next-line require-yield\nfunction* empty() {\n    return;\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 * Enumerate an iterable object.\n *\n * @param object - The iterable object of interest.\n *\n * @param start - The starting enum value. The default is `0`.\n *\n * @returns An iterator which yields the enumerated values.\n *\n * #### Example\n * ```typescript\n * import { enumerate } from '@lumino/algorithm';\n *\n * let data = ['foo', 'bar', 'baz'];\n *\n * let stream = enumerate(data, 1);\n *\n * Array.from(stream);  // [[1, 'foo'], [2, 'bar'], [3, 'baz']]\n * ```\n */\nfunction* enumerate(object, start = 0) {\n    for (const value of object) {\n        yield [start++, value];\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 * Filter an iterable for values which pass a test.\n *\n * @param object - The iterable object of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n *\n * @returns An iterator which yields the values which pass the test.\n *\n * #### Example\n * ```typescript\n * import { filter } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = filter(data, value => value % 2 === 0);\n *\n * Array.from(stream);  // [2, 4, 6]\n * ```\n */\nfunction* filter(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        if (fn(value, index++)) {\n            yield value;\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 * Find the first value in an iterable which matches a predicate.\n *\n * @param object - The iterable object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @returns The first matching value, or `undefined` if no matching\n *   value is found.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { find } from '@lumino/algorithm';\n *\n * interface IAnimal { species: string, name: string };\n *\n * function isCat(value: IAnimal): boolean {\n *   return value.species === 'cat';\n * }\n *\n * let data: IAnimal[] = [\n *   { species: 'dog', name: 'spot' },\n *   { species: 'cat', name: 'fluffy' },\n *   { species: 'alligator', name: 'pocho' }\n * ];\n *\n * find(data, isCat).name;  // 'fluffy'\n * ```\n */\nfunction find(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        if (fn(value, index++)) {\n            return value;\n        }\n    }\n    return undefined;\n}\n/**\n * Find the index of the first value which matches a predicate.\n *\n * @param object - The iterable object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @returns The index of the first matching value, or `-1` if no\n *   matching value is found.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { findIndex } from '@lumino/algorithm';\n *\n * interface IAnimal { species: string, name: string };\n *\n * function isCat(value: IAnimal): boolean {\n *   return value.species === 'cat';\n * }\n *\n * let data: IAnimal[] = [\n *   { species: 'dog', name: 'spot' },\n *   { species: 'cat', name: 'fluffy' },\n *   { species: 'alligator', name: 'pocho' }\n * ];\n *\n * findIndex(data, isCat);  // 1\n * ```\n */\nfunction findIndex(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        if (fn(value, index++)) {\n            return index - 1;\n        }\n    }\n    return -1;\n}\n/**\n * Find the minimum value in an iterable.\n *\n * @param object - The iterable object to search.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n *   It should return `< 0` if the first value is less than the second.\n *   `0` if the values are equivalent, or `> 0` if the first value is\n *   greater than the second.\n *\n * @returns The minimum value in the iterable. If multiple values are\n *   equivalent to the minimum, the left-most value is returned. If\n *   the iterable is empty, this returns `undefined`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { min } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n *   return a - b;\n * }\n *\n * min([7, 4, 0, 3, 9, 4], numberCmp);  // 0\n * ```\n */\nfunction min(object, fn) {\n    let result = undefined;\n    for (const value of object) {\n        if (result === undefined) {\n            result = value;\n            continue;\n        }\n        if (fn(value, result) < 0) {\n            result = value;\n        }\n    }\n    return result;\n}\n/**\n * Find the maximum value in an iterable.\n *\n * @param object - The iterable object to search.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n *   It should return `< 0` if the first value is less than the second.\n *   `0` if the values are equivalent, or `> 0` if the first value is\n *   greater than the second.\n *\n * @returns The maximum value in the iterable. If multiple values are\n *   equivalent to the maximum, the left-most value is returned. If\n *   the iterable is empty, this returns `undefined`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { max } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n *   return a - b;\n * }\n *\n * max([7, 4, 0, 3, 9, 4], numberCmp);  // 9\n * ```\n */\nfunction max(object, fn) {\n    let result = undefined;\n    for (const value of object) {\n        if (result === undefined) {\n            result = value;\n            continue;\n        }\n        if (fn(value, result) > 0) {\n            result = value;\n        }\n    }\n    return result;\n}\n/**\n * Find the minimum and maximum values in an iterable.\n *\n * @param object - The iterable object to search.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n *   It should return `< 0` if the first value is less than the second.\n *   `0` if the values are equivalent, or `> 0` if the first value is\n *   greater than the second.\n *\n * @returns A 2-tuple of the `[min, max]` values in the iterable. If\n *   multiple values are equivalent, the left-most values are returned.\n *   If the iterable is empty, this returns `undefined`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { minmax } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n *   return a - b;\n * }\n *\n * minmax([7, 4, 0, 3, 9, 4], numberCmp);  // [0, 9]\n * ```\n */\nfunction minmax(object, fn) {\n    let empty = true;\n    let vmin;\n    let vmax;\n    for (const value of object) {\n        if (empty) {\n            vmin = value;\n            vmax = value;\n            empty = false;\n        }\n        else if (fn(value, vmin) < 0) {\n            vmin = value;\n        }\n        else if (fn(value, vmax) > 0) {\n            vmax = value;\n        }\n    }\n    return empty ? undefined : [vmin, vmax];\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 * Create an array from an iterable of values.\n *\n * @deprecated\n *\n * @param object - The iterable object of interest.\n *\n * @returns A new array of values from the given object.\n *\n * #### Example\n * ```typescript\n * import { toArray } from '@lumino/algorithm';\n *\n * let stream = [1, 2, 3, 4, 5, 6][Symbol.iterator]();\n *\n * toArray(stream);  // [1, 2, 3, 4, 5, 6];\n * ```\n */\nfunction toArray(object) {\n    return Array.from(object);\n}\n/**\n * Create an object from an iterable of key/value pairs.\n *\n * @param object - The iterable object of interest.\n *\n * @returns A new object mapping keys to values.\n *\n * #### Example\n * ```typescript\n * import { toObject } from '@lumino/algorithm';\n *\n * let data: [string, number][] = [['one', 1], ['two', 2], ['three', 3]];\n *\n * toObject(data);  // { one: 1, two: 2, three: 3 }\n * ```\n */\nfunction toObject(object) {\n    const result = {};\n    for (const [key, value] of object) {\n        result[key] = value;\n    }\n    return result;\n}\n/**\n * Invoke a function for each value in an iterable.\n *\n * @deprecated\n *\n * @param object - The iterable object of interest.\n *\n * @param fn - The callback function to invoke for each value.\n *\n * #### Notes\n * Iteration can be terminated early by returning `false` from the\n * callback function.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { each } from '@lumino/algorithm';\n *\n * let data = [5, 7, 0, -2, 9];\n *\n * each(data, value => { console.log(value); });\n * ```\n */\nfunction each(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        if (false === fn(value, index++)) {\n            return;\n        }\n    }\n}\n/**\n * Test whether all values in an iterable satisfy a predicate.\n *\n * @param object - The iterable object of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n *\n * @returns `true` if all values pass the test, `false` otherwise.\n *\n * #### Notes\n * Iteration terminates on the first `false` predicate result.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { every } from '@lumino/algorithm';\n *\n * let data = [5, 7, 1];\n *\n * every(data, value => value % 2 === 0);  // false\n * every(data, value => value % 2 === 1);  // true\n * ```\n */\nfunction every(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        if (false === fn(value, index++)) {\n            return false;\n        }\n    }\n    return true;\n}\n/**\n * Test whether any value in an iterable satisfies a predicate.\n *\n * @param object - The iterable object of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n *\n * @returns `true` if any value passes the test, `false` otherwise.\n *\n * #### Notes\n * Iteration terminates on the first `true` predicate result.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { some } from '@lumino/algorithm';\n *\n * let data = [5, 7, 1];\n *\n * some(data, value => value === 7);  // true\n * some(data, value => value === 3);  // false\n * ```\n */\nfunction some(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        if (fn(value, index++)) {\n            return true;\n        }\n    }\n    return false;\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 * Transform the values of an iterable with a mapping function.\n *\n * @param object - The iterable object of interest.\n *\n * @param fn - The mapping function to invoke for each value.\n *\n * @returns An iterator which yields the transformed values.\n *\n * #### Example\n * ```typescript\n * import { map } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3];\n *\n * let stream = map(data, value => value * 2);\n *\n * Array.from(stream);  // [2, 4, 6]\n * ```\n */\nfunction* map(object, fn) {\n    let index = 0;\n    for (const value of object) {\n        yield fn(value, index++);\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 * Create an iterator of evenly spaced values.\n *\n * @param start - The starting value for the range, inclusive.\n *\n * @param stop - The stopping value for the range, exclusive.\n *\n * @param step - The distance between each value.\n *\n * @returns An iterator which produces evenly spaced values.\n *\n * #### Notes\n * In the single argument form of `range(stop)`, `start` defaults to\n * `0` and `step` defaults to `1`.\n *\n * In the two argument form of `range(start, stop)`, `step` defaults\n * to `1`.\n *\n * #### Example\n * ```typescript\n * import { range } from '@lumino/algorithm';\n *\n * let stream = range(2, 4);\n *\n * Array.from(stream);  // [2, 3]\n * ```\n */\nfunction* range(start, stop, step) {\n    if (stop === undefined) {\n        stop = start;\n        start = 0;\n        step = 1;\n    }\n    else if (step === undefined) {\n        step = 1;\n    }\n    const length = Private.rangeLength(start, stop, step);\n    for (let index = 0; index < length; index++) {\n        yield start + step * index;\n    }\n}\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * Compute the effective length of a range.\n     *\n     * @param start - The starting value for the range, inclusive.\n     *\n     * @param stop - The stopping value for the range, exclusive.\n     *\n     * @param step - The distance between each value.\n     *\n     * @returns The number of steps need to traverse the range.\n     */\n    function rangeLength(start, stop, step) {\n        if (step === 0) {\n            return Infinity;\n        }\n        if (start > stop && step > 0) {\n            return 0;\n        }\n        if (start < stop && step < 0) {\n            return 0;\n        }\n        return Math.ceil((stop - start) / step);\n    }\n    Private.rangeLength = rangeLength;\n})(Private || (Private = {}));\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|----------------------------------------------------------------------------*/\nfunction reduce(object, fn, initial) {\n    // Setup the iterator and fetch the first value.\n    const it = object[Symbol.iterator]();\n    let index = 0;\n    let first = it.next();\n    // An empty iterator and no initial value is an error.\n    if (first.done && initial === undefined) {\n        throw new TypeError('Reduce of empty iterable with no initial value.');\n    }\n    // If the iterator is empty, return the initial value.\n    if (first.done) {\n        return initial;\n    }\n    // If the iterator has a single item and no initial value, the\n    // reducer is not invoked and the first item is the return value.\n    let second = it.next();\n    if (second.done && initial === undefined) {\n        return first.value;\n    }\n    // If iterator has a single item and an initial value is provided,\n    // the reducer is invoked and that result is the return value.\n    if (second.done) {\n        return fn(initial, first.value, index++);\n    }\n    // Setup the initial accumlated value.\n    let accumulator;\n    if (initial === undefined) {\n        accumulator = fn(first.value, second.value, index++);\n    }\n    else {\n        accumulator = fn(fn(initial, first.value, index++), second.value, index++);\n    }\n    // Iterate the rest of the values, updating the accumulator.\n    let next;\n    while (!(next = it.next()).done) {\n        accumulator = fn(accumulator, next.value, index++);\n    }\n    // Return the final accumulated value.\n    return accumulator;\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 * Create an iterator which repeats a value a number of times.\n *\n * @deprecated\n *\n * @param value - The value to repeat.\n *\n * @param count - The number of times to repeat the value.\n *\n * @returns A new iterator which repeats the specified value.\n *\n * #### Example\n * ```typescript\n * import { repeat } from '@lumino/algorithm';\n *\n * let stream = repeat(7, 3);\n *\n * Array.from(stream);  // [7, 7, 7]\n * ```\n */\nfunction* repeat(value, count) {\n    while (0 < count--) {\n        yield value;\n    }\n}\n/**\n * Create an iterator which yields a value a single time.\n *\n * @deprecated\n *\n * @param value - The value to wrap in an iterator.\n *\n * @returns A new iterator which yields the value a single time.\n *\n * #### Example\n * ```typescript\n * import { once } from '@lumino/algorithm';\n *\n * let stream = once(7);\n *\n * Array.from(stream);  // [7]\n * ```\n */\nfunction* once(value) {\n    yield value;\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 * Create an iterator for a retroable object.\n *\n * @param object - The retroable or array-like object of interest.\n *\n * @returns An iterator which traverses the object's values in reverse.\n *\n * #### Example\n * ```typescript\n * import { retro } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = retro(data);\n *\n * Array.from(stream);  // [6, 5, 4, 3, 2, 1]\n * ```\n */\nfunction* retro(object) {\n    if (typeof object.retro === 'function') {\n        yield* object.retro();\n    }\n    else {\n        for (let index = object.length - 1; index > -1; index--) {\n            yield object[index];\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 * Topologically sort an iterable of edges.\n *\n * @param edges - The iterable object of edges to sort.\n *   An edge is represented as a 2-tuple of `[fromNode, toNode]`.\n *\n * @returns The topologically sorted array of nodes.\n *\n * #### Notes\n * If a cycle is present in the graph, the cycle will be ignored and\n * the return value will be only approximately sorted.\n *\n * #### Example\n * ```typescript\n * import { topologicSort } from '@lumino/algorithm';\n *\n * let data = [\n *   ['d', 'e'],\n *   ['c', 'd'],\n *   ['a', 'b'],\n *   ['b', 'c']\n * ];\n *\n * topologicSort(data);  // ['a', 'b', 'c', 'd', 'e']\n * ```\n */\nfunction topologicSort(edges) {\n    // Setup the shared sorting state.\n    let sorted = [];\n    let visited = new Set();\n    let graph = new Map();\n    // Add the edges to the graph.\n    for (const edge of edges) {\n        addEdge(edge);\n    }\n    // Visit each node in the graph.\n    for (const [k] of graph) {\n        visit(k);\n    }\n    // Return the sorted results.\n    return sorted;\n    // Add an edge to the graph.\n    function addEdge(edge) {\n        let [fromNode, toNode] = edge;\n        let children = graph.get(toNode);\n        if (children) {\n            children.push(fromNode);\n        }\n        else {\n            graph.set(toNode, [fromNode]);\n        }\n    }\n    // Recursively visit the node.\n    function visit(node) {\n        if (visited.has(node)) {\n            return;\n        }\n        visited.add(node);\n        let children = graph.get(node);\n        if (children) {\n            for (const child of children) {\n                visit(child);\n            }\n        }\n        sorted.push(node);\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 * Iterate over an iterable using a stepped increment.\n *\n * @param object - The iterable object of interest.\n *\n * @param step - The distance to step on each iteration. A value\n *   of less than `1` will behave the same as a value of `1`.\n *\n * @returns An iterator which traverses the iterable step-wise.\n *\n * #### Example\n * ```typescript\n * import { stride } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = stride(data, 2);\n *\n * Array.from(stream);  // [1, 3, 5];\n * ```\n */\nfunction* stride(object, step) {\n    let count = 0;\n    for (const value of object) {\n        if (0 === count++ % step) {\n            yield value;\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 * The namespace for string-specific algorithms.\n */\nvar StringExt;\n(function (StringExt) {\n    /**\n     * Find the indices of characters in a source text.\n     *\n     * @param source - The source text which should be searched.\n     *\n     * @param query - The characters to locate in the source text.\n     *\n     * @param start - The index to start the search.\n     *\n     * @returns The matched indices, or `null` if there is no match.\n     *\n     * #### Complexity\n     * Linear on `sourceText`.\n     *\n     * #### Notes\n     * In order for there to be a match, all of the characters in `query`\n     * **must** appear in `source` in the order given by `query`.\n     *\n     * Characters are matched using strict `===` equality.\n     */\n    function findIndices(source, query, start = 0) {\n        let indices = new Array(query.length);\n        for (let i = 0, j = start, n = query.length; i < n; ++i, ++j) {\n            j = source.indexOf(query[i], j);\n            if (j === -1) {\n                return null;\n            }\n            indices[i] = j;\n        }\n        return indices;\n    }\n    StringExt.findIndices = findIndices;\n    /**\n     * A string matcher which uses a sum-of-squares algorithm.\n     *\n     * @param source - The source text which should be searched.\n     *\n     * @param query - The characters to locate in the source text.\n     *\n     * @param start - The index to start the search.\n     *\n     * @returns The match result, or `null` if there is no match.\n     *   A lower `score` represents a stronger match.\n     *\n     * #### Complexity\n     * Linear on `sourceText`.\n     *\n     * #### Notes\n     * This scoring algorithm uses a sum-of-squares approach to determine\n     * the score. In order for there to be a match, all of the characters\n     * in `query` **must** appear in `source` in order. The index of each\n     * matching character is squared and added to the score. This means\n     * that early and consecutive character matches are preferred, while\n     * late matches are heavily penalized.\n     */\n    function matchSumOfSquares(source, query, start = 0) {\n        let indices = findIndices(source, query, start);\n        if (!indices) {\n            return null;\n        }\n        let score = 0;\n        for (let i = 0, n = indices.length; i < n; ++i) {\n            let j = indices[i] - start;\n            score += j * j;\n        }\n        return { score, indices };\n    }\n    StringExt.matchSumOfSquares = matchSumOfSquares;\n    /**\n     * A string matcher which uses a sum-of-deltas algorithm.\n     *\n     * @param source - The source text which should be searched.\n     *\n     * @param query - The characters to locate in the source text.\n     *\n     * @param start - The index to start the search.\n     *\n     * @returns The match result, or `null` if there is no match.\n     *   A lower `score` represents a stronger match.\n     *\n     * #### Complexity\n     * Linear on `sourceText`.\n     *\n     * #### Notes\n     * This scoring algorithm uses a sum-of-deltas approach to determine\n     * the score. In order for there to be a match, all of the characters\n     * in `query` **must** appear in `source` in order. The delta between\n     * the indices are summed to create the score. This means that groups\n     * of matched characters are preferred, while fragmented matches are\n     * penalized.\n     */\n    function matchSumOfDeltas(source, query, start = 0) {\n        let indices = findIndices(source, query, start);\n        if (!indices) {\n            return null;\n        }\n        let score = 0;\n        let last = start - 1;\n        for (let i = 0, n = indices.length; i < n; ++i) {\n            let j = indices[i];\n            score += j - last - 1;\n            last = j;\n        }\n        return { score, indices };\n    }\n    StringExt.matchSumOfDeltas = matchSumOfDeltas;\n    /**\n     * Highlight the matched characters of a source text.\n     *\n     * @param source - The text which should be highlighted.\n     *\n     * @param indices - The indices of the matched characters. They must\n     *   appear in increasing order and must be in bounds of the source.\n     *\n     * @param fn - The function to apply to the matched chunks.\n     *\n     * @returns An array of unmatched and highlighted chunks.\n     */\n    function highlight(source, indices, fn) {\n        // Set up the result array.\n        let result = [];\n        // Set up the counter variables.\n        let k = 0;\n        let last = 0;\n        let n = indices.length;\n        // Iterator over each index.\n        while (k < n) {\n            // Set up the chunk indices.\n            let i = indices[k];\n            let j = indices[k];\n            // Advance the right chunk index until it's non-contiguous.\n            while (++k < n && indices[k] === j + 1) {\n                j++;\n            }\n            // Extract the unmatched text.\n            if (last < i) {\n                result.push(source.slice(last, i));\n            }\n            // Extract and highlight the matched text.\n            if (i < j + 1) {\n                result.push(fn(source.slice(i, j + 1)));\n            }\n            // Update the last visited index.\n            last = j + 1;\n        }\n        // Extract any remaining unmatched text.\n        if (last < source.length) {\n            result.push(source.slice(last));\n        }\n        // Return the highlighted result.\n        return result;\n    }\n    StringExt.highlight = highlight;\n    /**\n     * A 3-way string comparison function.\n     *\n     * @param a - The first string of interest.\n     *\n     * @param b - The second string of interest.\n     *\n     * @returns `-1` if `a < b`, else `1` if `a > b`, else `0`.\n     */\n    function cmp(a, b) {\n        return a < b ? -1 : a > b ? 1 : 0;\n    }\n    StringExt.cmp = cmp;\n})(StringExt || (StringExt = {}));\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 * Take a fixed number of items from an iterable.\n *\n * @param object - The iterable object of interest.\n *\n * @param count - The number of items to take from the iterable.\n *\n * @returns An iterator which yields the specified number of items\n *   from the source iterable.\n *\n * #### Notes\n * The returned iterator will exhaust early if the source iterable\n * contains an insufficient number of items.\n *\n * #### Example\n * ```typescript\n * import { take } from '@lumino/algorithm';\n *\n * let stream = take([5, 4, 3, 2, 1, 0, -1], 3);\n *\n * Array.from(stream);  // [5, 4, 3]\n * ```\n */\nfunction* take(object, count) {\n    if (count < 1) {\n        return;\n    }\n    const it = object[Symbol.iterator]();\n    let item;\n    while (0 < count-- && !(item = it.next()).done) {\n        yield item.value;\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 * Iterate several iterables in lockstep.\n *\n * @param objects - The iterable objects of interest.\n *\n * @returns An iterator which yields successive tuples of values where\n *   each value is taken in turn from the provided iterables. It will\n *   be as long as the shortest provided iterable.\n *\n * #### Example\n * ```typescript\n * import { zip } from '@lumino/algorithm';\n *\n * let data1 = [1, 2, 3];\n * let data2 = [4, 5, 6];\n *\n * let stream = zip(data1, data2);\n *\n * Array.from(stream);  // [[1, 4], [2, 5], [3, 6]]\n * ```\n */\nfunction* zip(...objects) {\n    const iters = objects.map(obj => obj[Symbol.iterator]());\n    let tuple = iters.map(it => it.next());\n    for (; every(tuple, item => !item.done); tuple = iters.map(it => it.next())) {\n        yield tuple.map(item => item.value);\n    }\n}\n\nexport { ArrayExt, StringExt, chain, each, empty, enumerate, every, filter, find, findIndex, map, max, min, minmax, once, range, reduce, repeat, retro, some, stride, take, toArray, toObject, topologicSort, zip };\n//# sourceMappingURL=index.es6.js.map\n","(function (global, factory) {\n    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@lumino/algorithm')) :\n    typeof define === 'function' && define.amd ? define(['exports', '@lumino/algorithm'], factory) :\n    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lumino_coreutils = {}, global.lumino_algorithm));\n})(this, (function (exports, algorithm) { 'use strict';\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     * The namespace for JSON-specific functions.\n     */\n    exports.JSONExt = void 0;\n    (function (JSONExt) {\n        /**\n         * A shared frozen empty JSONObject\n         */\n        JSONExt.emptyObject = Object.freeze({});\n        /**\n         * A shared frozen empty JSONArray\n         */\n        JSONExt.emptyArray = Object.freeze([]);\n        /**\n         * Test whether a JSON value is a primitive.\n         *\n         * @param value - The JSON value of interest.\n         *\n         * @returns `true` if the value is a primitive,`false` otherwise.\n         */\n        function isPrimitive(value) {\n            return (value === null ||\n                typeof value === 'boolean' ||\n                typeof value === 'number' ||\n                typeof value === 'string');\n        }\n        JSONExt.isPrimitive = isPrimitive;\n        function isArray(value) {\n            return Array.isArray(value);\n        }\n        JSONExt.isArray = isArray;\n        function isObject(value) {\n            return !isPrimitive(value) && !isArray(value);\n        }\n        JSONExt.isObject = isObject;\n        /**\n         * Compare two JSON values for deep equality.\n         *\n         * @param first - The first JSON value of interest.\n         *\n         * @param second - The second JSON value of interest.\n         *\n         * @returns `true` if the values are equivalent, `false` otherwise.\n         */\n        function deepEqual(first, second) {\n            // Check referential and primitive equality first.\n            if (first === second) {\n                return true;\n            }\n            // If one is a primitive, the `===` check ruled out the other.\n            if (isPrimitive(first) || isPrimitive(second)) {\n                return false;\n            }\n            // Test whether they are arrays.\n            let a1 = isArray(first);\n            let a2 = isArray(second);\n            // Bail if the types are different.\n            if (a1 !== a2) {\n                return false;\n            }\n            // If they are both arrays, compare them.\n            if (a1 && a2) {\n                return deepArrayEqual(first, second);\n            }\n            // At this point, they must both be objects.\n            return deepObjectEqual(first, second);\n        }\n        JSONExt.deepEqual = deepEqual;\n        /**\n         * Create a deep copy of a JSON value.\n         *\n         * @param value - The JSON value to copy.\n         *\n         * @returns A deep copy of the given JSON value.\n         */\n        function deepCopy(value) {\n            // Do nothing for primitive values.\n            if (isPrimitive(value)) {\n                return value;\n            }\n            // Deep copy an array.\n            if (isArray(value)) {\n                return deepArrayCopy(value);\n            }\n            // Deep copy an object.\n            return deepObjectCopy(value);\n        }\n        JSONExt.deepCopy = deepCopy;\n        /**\n         * Compare two JSON arrays for deep equality.\n         */\n        function deepArrayEqual(first, second) {\n            // Check referential equality first.\n            if (first === second) {\n                return true;\n            }\n            // Test the arrays for equal length.\n            if (first.length !== second.length) {\n                return false;\n            }\n            // Compare the values for equality.\n            for (let i = 0, n = first.length; i < n; ++i) {\n                if (!deepEqual(first[i], second[i])) {\n                    return false;\n                }\n            }\n            // At this point, the arrays are equal.\n            return true;\n        }\n        /**\n         * Compare two JSON objects for deep equality.\n         */\n        function deepObjectEqual(first, second) {\n            // Check referential equality first.\n            if (first === second) {\n                return true;\n            }\n            // Check for the first object's keys in the second object.\n            for (let key in first) {\n                if (first[key] !== undefined && !(key in second)) {\n                    return false;\n                }\n            }\n            // Check for the second object's keys in the first object.\n            for (let key in second) {\n                if (second[key] !== undefined && !(key in first)) {\n                    return false;\n                }\n            }\n            // Compare the values for equality.\n            for (let key in first) {\n                // Get the values.\n                let firstValue = first[key];\n                let secondValue = second[key];\n                // If both are undefined, ignore the key.\n                if (firstValue === undefined && secondValue === undefined) {\n                    continue;\n                }\n                // If only one value is undefined, the objects are not equal.\n                if (firstValue === undefined || secondValue === undefined) {\n                    return false;\n                }\n                // Compare the values.\n                if (!deepEqual(firstValue, secondValue)) {\n                    return false;\n                }\n            }\n            // At this point, the objects are equal.\n            return true;\n        }\n        /**\n         * Create a deep copy of a JSON array.\n         */\n        function deepArrayCopy(value) {\n            let result = new Array(value.length);\n            for (let i = 0, n = value.length; i < n; ++i) {\n                result[i] = deepCopy(value[i]);\n            }\n            return result;\n        }\n        /**\n         * Create a deep copy of a JSON object.\n         */\n        function deepObjectCopy(value) {\n            let result = {};\n            for (let key in value) {\n                // Ignore undefined values.\n                let subvalue = value[key];\n                if (subvalue === undefined) {\n                    continue;\n                }\n                result[key] = deepCopy(subvalue);\n            }\n            return result;\n        }\n    })(exports.JSONExt || (exports.JSONExt = {}));\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     * An object which stores MIME data for general application use.\n     *\n     * #### Notes\n     * This class does not attempt to enforce \"correctness\" of MIME types\n     * and their associated data. Since this class is designed to transfer\n     * arbitrary data and objects within the same application, it assumes\n     * that the user provides correct and accurate data.\n     */\n    class MimeData {\n        constructor() {\n            this._types = [];\n            this._values = [];\n        }\n        /**\n         * Get an array of the MIME types contained within the dataset.\n         *\n         * @returns A new array of the MIME types, in order of insertion.\n         */\n        types() {\n            return this._types.slice();\n        }\n        /**\n         * Test whether the dataset has an entry for the given type.\n         *\n         * @param mime - The MIME type of interest.\n         *\n         * @returns `true` if the dataset contains a value for the given\n         *   MIME type, `false` otherwise.\n         */\n        hasData(mime) {\n            return this._types.indexOf(mime) !== -1;\n        }\n        /**\n         * Get the data value for the given MIME type.\n         *\n         * @param mime - The MIME type of interest.\n         *\n         * @returns The value for the given MIME type, or `undefined` if\n         *   the dataset does not contain a value for the type.\n         */\n        getData(mime) {\n            let i = this._types.indexOf(mime);\n            return i !== -1 ? this._values[i] : undefined;\n        }\n        /**\n         * Set the data value for the given MIME type.\n         *\n         * @param mime - The MIME type of interest.\n         *\n         * @param data - The data value for the given MIME type.\n         *\n         * #### Notes\n         * This will overwrite any previous entry for the MIME type.\n         */\n        setData(mime, data) {\n            this.clearData(mime);\n            this._types.push(mime);\n            this._values.push(data);\n        }\n        /**\n         * Remove the data entry for the given MIME type.\n         *\n         * @param mime - The MIME type of interest.\n         *\n         * #### Notes\n         * This is a no-op if there is no entry for the given MIME type.\n         */\n        clearData(mime) {\n            let i = this._types.indexOf(mime);\n            if (i !== -1) {\n                this._types.splice(i, 1);\n                this._values.splice(i, 1);\n            }\n        }\n        /**\n         * Remove all data entries from the dataset.\n         */\n        clear() {\n            this._types.length = 0;\n            this._values.length = 0;\n        }\n    }\n\n    // Copyright (c) Jupyter Development Team.\n    // Distributed under the terms of the Modified BSD License.\n    /**\n     * Plugin registry.\n     */\n    class PluginRegistry {\n        constructor(options = {}) {\n            this._application = null;\n            this._validatePlugin = () => true;\n            this._plugins = new Map();\n            this._services = new Map();\n            if (options.validatePlugin) {\n                console.info('Plugins may be rejected by the custom validation plugin method.');\n                this._validatePlugin = options.validatePlugin;\n            }\n        }\n        /**\n         * The application object.\n         *\n         * It will be provided as first argument to the\n         * plugins activation and deactivation functions.\n         *\n         * It can only be set once.\n         *\n         * By default, it is `null`.\n         */\n        get application() {\n            return this._application;\n        }\n        set application(v) {\n            if (this._application !== null) {\n                throw Error('PluginRegistry.application is already set. It cannot be overridden.');\n            }\n            this._application = v;\n        }\n        /**\n         * The list of all the deferred plugins.\n         */\n        get deferredPlugins() {\n            return Array.from(this._plugins)\n                .filter(([id, plugin]) => plugin.autoStart === 'defer')\n                .map(([id, plugin]) => id);\n        }\n        /**\n         * Get a plugin description.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @returns The plugin description.\n         */\n        getPluginDescription(id) {\n            var _a, _b;\n            return (_b = (_a = this._plugins.get(id)) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : '';\n        }\n        /**\n         * Test whether a plugin is registered with the application.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @returns `true` if the plugin is registered, `false` otherwise.\n         */\n        hasPlugin(id) {\n            return this._plugins.has(id);\n        }\n        /**\n         * Test whether a plugin is activated with the application.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @returns `true` if the plugin is activated, `false` otherwise.\n         */\n        isPluginActivated(id) {\n            var _a, _b;\n            return (_b = (_a = this._plugins.get(id)) === null || _a === void 0 ? void 0 : _a.activated) !== null && _b !== void 0 ? _b : false;\n        }\n        /**\n         * List the IDs of the plugins registered with the application.\n         *\n         * @returns A new array of the registered plugin IDs.\n         */\n        listPlugins() {\n            return Array.from(this._plugins.keys());\n        }\n        /**\n         * Register a plugin with the application.\n         *\n         * @param plugin - The plugin to register.\n         *\n         * #### Notes\n         * An error will be thrown if a plugin with the same ID is already\n         * registered, or if the plugin has a circular dependency.\n         *\n         * If the plugin provides a service which has already been provided\n         * by another plugin, the new service will override the old service.\n         */\n        registerPlugin(plugin) {\n            // Throw an error if the plugin ID is already registered.\n            if (this._plugins.has(plugin.id)) {\n                throw new TypeError(`Plugin '${plugin.id}' is already registered.`);\n            }\n            if (!this._validatePlugin(plugin)) {\n                throw new Error(`Plugin '${plugin.id}' is not valid.`);\n            }\n            // Create the normalized plugin data.\n            const data = Private.createPluginData(plugin);\n            // Ensure the plugin does not cause a cyclic dependency.\n            Private.ensureNoCycle(data, this._plugins, this._services);\n            // Add the service token to the service map.\n            if (data.provides) {\n                this._services.set(data.provides, data.id);\n            }\n            // Add the plugin to the plugin map.\n            this._plugins.set(data.id, data);\n        }\n        /**\n         * Register multiple plugins with the application.\n         *\n         * @param plugins - The plugins to register.\n         *\n         * #### Notes\n         * This calls `registerPlugin()` for each of the given plugins.\n         */\n        registerPlugins(plugins) {\n            for (const plugin of plugins) {\n                this.registerPlugin(plugin);\n            }\n        }\n        /**\n         * Deregister a plugin with the application.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @param force - Whether to deregister the plugin even if it is active.\n         */\n        deregisterPlugin(id, force) {\n            const plugin = this._plugins.get(id);\n            if (!plugin) {\n                return;\n            }\n            if (plugin.activated && !force) {\n                throw new Error(`Plugin '${id}' is still active.`);\n            }\n            this._plugins.delete(id);\n        }\n        /**\n         * Activate the plugin with the given ID.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @returns A promise which resolves when the plugin is activated\n         *   or rejects with an error if it cannot be activated.\n         */\n        async activatePlugin(id) {\n            // Reject the promise if the plugin is not registered.\n            const plugin = this._plugins.get(id);\n            if (!plugin) {\n                throw new ReferenceError(`Plugin '${id}' is not registered.`);\n            }\n            // Resolve immediately if the plugin is already activated.\n            if (plugin.activated) {\n                return;\n            }\n            // Return the pending resolver promise if it exists.\n            if (plugin.promise) {\n                return plugin.promise;\n            }\n            // Resolve the required services for the plugin.\n            const required = plugin.requires.map(t => this.resolveRequiredService(t));\n            // Resolve the optional services for the plugin.\n            const optional = plugin.optional.map(t => this.resolveOptionalService(t));\n            // Setup the resolver promise for the plugin.\n            plugin.promise = Promise.all([...required, ...optional])\n                .then(services => plugin.activate.apply(undefined, [this.application, ...services]))\n                .then(service => {\n                plugin.service = service;\n                plugin.activated = true;\n                plugin.promise = null;\n            })\n                .catch(error => {\n                plugin.promise = null;\n                throw error;\n            });\n            // Return the pending resolver promise.\n            return plugin.promise;\n        }\n        /**\n         * Activate all the deferred plugins.\n         *\n         * @returns A promise which will resolve when each plugin is activated\n         * or rejects with an error if one cannot be activated.\n         */\n        async activatePlugins(kind, options = {}) {\n            switch (kind) {\n                case 'defer': {\n                    const promises = this.deferredPlugins\n                        .filter(pluginId => this._plugins.get(pluginId).autoStart)\n                        .map(pluginId => {\n                        return this.activatePlugin(pluginId);\n                    });\n                    await Promise.all(promises);\n                    break;\n                }\n                case 'startUp': {\n                    // Collect the ids of the startup plugins.\n                    const startups = Private.collectStartupPlugins(this._plugins, options);\n                    // Generate the activation promises.\n                    const promises = startups.map(async (id) => {\n                        try {\n                            return await this.activatePlugin(id);\n                        }\n                        catch (error) {\n                            console.error(`Plugin '${id}' failed to activate.`, error);\n                        }\n                    });\n                    await Promise.all(promises);\n                    break;\n                }\n            }\n        }\n        /**\n         * Deactivate the plugin and its downstream dependents if and only if the\n         * plugin and its dependents all support `deactivate`.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @returns A list of IDs of downstream plugins deactivated with this one.\n         */\n        async deactivatePlugin(id) {\n            // Reject the promise if the plugin is not registered.\n            const plugin = this._plugins.get(id);\n            if (!plugin) {\n                throw new ReferenceError(`Plugin '${id}' is not registered.`);\n            }\n            // Bail early if the plugin is not activated.\n            if (!plugin.activated) {\n                return [];\n            }\n            // Check that this plugin can deactivate.\n            if (!plugin.deactivate) {\n                throw new TypeError(`Plugin '${id}'#deactivate() method missing`);\n            }\n            // Find the optimal deactivation order for plugins downstream of this one.\n            const manifest = Private.findDependents(id, this._plugins, this._services);\n            const downstream = manifest.map(id => this._plugins.get(id));\n            // Check that all downstream plugins can deactivate.\n            for (const plugin of downstream) {\n                if (!plugin.deactivate) {\n                    throw new TypeError(`Plugin ${plugin.id}#deactivate() method missing (depends on ${id})`);\n                }\n            }\n            // Deactivate all downstream plugins.\n            for (const plugin of downstream) {\n                const services = [...plugin.requires, ...plugin.optional].map(service => {\n                    const id = this._services.get(service);\n                    return id ? this._plugins.get(id).service : null;\n                });\n                // Await deactivation so the next plugins only receive active services.\n                await plugin.deactivate(this.application, ...services);\n                plugin.service = null;\n                plugin.activated = false;\n            }\n            // Remove plugin ID and return manifest of deactivated plugins.\n            manifest.pop();\n            return manifest;\n        }\n        /**\n         * Resolve a required service of a given type.\n         *\n         * @param token - The token for the service type of interest.\n         *\n         * @returns A promise which resolves to an instance of the requested\n         *   service, or rejects with an error if it cannot be resolved.\n         *\n         * #### Notes\n         * Services are singletons. The same instance will be returned each\n         * time a given service token is resolved.\n         *\n         * If the plugin which provides the service has not been activated,\n         * resolving the service will automatically activate the plugin.\n         *\n         * User code will not typically call this method directly. Instead,\n         * the required services for the user's plugins will be resolved\n         * automatically when the plugin is activated.\n         */\n        async resolveRequiredService(token) {\n            // Reject the promise if there is no provider for the type.\n            const id = this._services.get(token);\n            if (!id) {\n                throw new TypeError(`No provider for: ${token.name}.`);\n            }\n            // Activate the plugin if necessary.\n            const plugin = this._plugins.get(id);\n            if (!plugin.activated) {\n                await this.activatePlugin(id);\n            }\n            return plugin.service;\n        }\n        /**\n         * Resolve an optional service of a given type.\n         *\n         * @param token - The token for the service type of interest.\n         *\n         * @returns A promise which resolves to an instance of the requested\n         *   service, or `null` if it cannot be resolved.\n         *\n         * #### Notes\n         * Services are singletons. The same instance will be returned each\n         * time a given service token is resolved.\n         *\n         * If the plugin which provides the service has not been activated,\n         * resolving the service will automatically activate the plugin.\n         *\n         * User code will not typically call this method directly. Instead,\n         * the optional services for the user's plugins will be resolved\n         * automatically when the plugin is activated.\n         */\n        async resolveOptionalService(token) {\n            // Resolve with `null` if there is no provider for the type.\n            const id = this._services.get(token);\n            if (!id) {\n                return null;\n            }\n            // Activate the plugin if necessary.\n            const plugin = this._plugins.get(id);\n            if (!plugin.activated) {\n                try {\n                    await this.activatePlugin(id);\n                }\n                catch (reason) {\n                    console.error(reason);\n                    return null;\n                }\n            }\n            return plugin.service;\n        }\n    }\n    /**\n     * The namespace for the module implementation details.\n     */\n    var Private;\n    (function (Private) {\n        class PluginData {\n            constructor(plugin) {\n                var _a, _b, _c, _d;\n                this._activated = false;\n                this._promise = null;\n                this._service = null;\n                this.id = plugin.id;\n                this.description = (_a = plugin.description) !== null && _a !== void 0 ? _a : '';\n                this.activate = plugin.activate;\n                this.deactivate = (_b = plugin.deactivate) !== null && _b !== void 0 ? _b : null;\n                this.provides = (_c = plugin.provides) !== null && _c !== void 0 ? _c : null;\n                this.autoStart = (_d = plugin.autoStart) !== null && _d !== void 0 ? _d : false;\n                this.requires = plugin.requires ? plugin.requires.slice() : [];\n                this.optional = plugin.optional ? plugin.optional.slice() : [];\n            }\n            /**\n             * Whether the plugin has been activated.\n             */\n            get activated() {\n                return this._activated;\n            }\n            set activated(a) {\n                this._activated = a;\n            }\n            /**\n             * The resolved service for the plugin, or `null`.\n             */\n            get service() {\n                return this._service;\n            }\n            set service(s) {\n                this._service = s;\n            }\n            /**\n             * The pending resolver promise, or `null`.\n             */\n            get promise() {\n                return this._promise;\n            }\n            set promise(p) {\n                this._promise = p;\n            }\n        }\n        /**\n         * Create a normalized plugin data object for the given plugin.\n         */\n        function createPluginData(plugin) {\n            return new PluginData(plugin);\n        }\n        Private.createPluginData = createPluginData;\n        /**\n         * Ensure no cycle is present in the plugin resolution graph.\n         *\n         * If a cycle is detected, an error will be thrown.\n         */\n        function ensureNoCycle(plugin, plugins, services) {\n            const dependencies = [...plugin.requires, ...plugin.optional];\n            const visit = (token) => {\n                if (token === plugin.provides) {\n                    return true;\n                }\n                const id = services.get(token);\n                if (!id) {\n                    return false;\n                }\n                const visited = plugins.get(id);\n                const dependencies = [...visited.requires, ...visited.optional];\n                if (dependencies.length === 0) {\n                    return false;\n                }\n                trace.push(id);\n                if (dependencies.some(visit)) {\n                    return true;\n                }\n                trace.pop();\n                return false;\n            };\n            // Bail early if there cannot be a cycle.\n            if (!plugin.provides || dependencies.length === 0) {\n                return;\n            }\n            // Setup a stack to trace service resolution.\n            const trace = [plugin.id];\n            // Throw an exception if a cycle is present.\n            if (dependencies.some(visit)) {\n                throw new ReferenceError(`Cycle detected: ${trace.join(' -> ')}.`);\n            }\n        }\n        Private.ensureNoCycle = ensureNoCycle;\n        /**\n         * Find dependents in deactivation order.\n         *\n         * @param id - The ID of the plugin of interest.\n         *\n         * @param plugins - The map containing all plugins.\n         *\n         * @param services - The map containing all services.\n         *\n         * @returns A list of dependent plugin IDs in order of deactivation\n         *\n         * #### Notes\n         * The final item of the returned list is always the plugin of interest.\n         */\n        function findDependents(id, plugins, services) {\n            const edges = new Array();\n            const add = (id) => {\n                const plugin = plugins.get(id);\n                // FIXME In the case of missing optional dependencies, we may consider\n                // deactivating and reactivating the plugin without the missing service.\n                const dependencies = [...plugin.requires, ...plugin.optional];\n                edges.push(...dependencies.reduce((acc, dep) => {\n                    const service = services.get(dep);\n                    if (service) {\n                        // An edge is oriented from dependent to provider.\n                        acc.push([id, service]);\n                    }\n                    return acc;\n                }, []));\n            };\n            for (const id of plugins.keys()) {\n                add(id);\n            }\n            // Filter edges\n            // - Get all packages that dependent on the package to be deactivated\n            const newEdges = edges.filter(edge => edge[1] === id);\n            let oldSize = 0;\n            while (newEdges.length > oldSize) {\n                const previousSize = newEdges.length;\n                // Get all packages that dependent on packages that will be deactivated\n                const packagesOfInterest = new Set(newEdges.map(edge => edge[0]));\n                for (const poi of packagesOfInterest) {\n                    edges\n                        .filter(edge => edge[1] === poi)\n                        .forEach(edge => {\n                        // We check it is not already included to deal with circular dependencies\n                        if (!newEdges.includes(edge)) {\n                            newEdges.push(edge);\n                        }\n                    });\n                }\n                oldSize = previousSize;\n            }\n            const sorted = algorithm.topologicSort(newEdges);\n            const index = sorted.findIndex(candidate => candidate === id);\n            if (index === -1) {\n                return [id];\n            }\n            return sorted.slice(0, index + 1);\n        }\n        Private.findDependents = findDependents;\n        /**\n         * Collect the IDs of the plugins to activate on startup.\n         */\n        function collectStartupPlugins(plugins, options) {\n            // Create a set to hold the plugin IDs.\n            const collection = new Set();\n            // Collect the auto-start (non deferred) plugins.\n            for (const id of plugins.keys()) {\n                if (plugins.get(id).autoStart === true) {\n                    collection.add(id);\n                }\n            }\n            // Add the startup plugins.\n            if (options.startPlugins) {\n                for (const id of options.startPlugins) {\n                    collection.add(id);\n                }\n            }\n            // Remove the ignored plugins.\n            if (options.ignorePlugins) {\n                for (const id of options.ignorePlugins) {\n                    collection.delete(id);\n                }\n            }\n            // Return the collected startup plugins.\n            return Array.from(collection);\n        }\n        Private.collectStartupPlugins = collectStartupPlugins;\n    })(Private || (Private = {}));\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 class which wraps a promise into a delegate object.\n     *\n     * #### Notes\n     * This class is useful when the logic to resolve or reject a promise\n     * cannot be defined at the point where the promise is created.\n     */\n    class PromiseDelegate {\n        /**\n         * Construct a new promise delegate.\n         */\n        constructor() {\n            this.promise = new Promise((resolve, reject) => {\n                this._resolve = resolve;\n                this._reject = reject;\n            });\n        }\n        /**\n         * Resolve the wrapped promise with the given value.\n         *\n         * @param value - The value to use for resolving the promise.\n         */\n        resolve(value) {\n            let resolve = this._resolve;\n            resolve(value);\n        }\n        /**\n         * Reject the wrapped promise with the given value.\n         *\n         * @reason - The reason for rejecting the promise.\n         */\n        reject(reason) {\n            let reject = this._reject;\n            reject(reason);\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 runtime object which captures compile-time type information.\n     *\n     * #### Notes\n     * A token captures the compile-time type of an interface or class in\n     * an object which can be used at runtime in a type-safe fashion.\n     */\n    class Token {\n        /**\n         * Construct a new token.\n         *\n         * @param name - A human readable name for the token.\n         * @param description - Token purpose description for documentation.\n         */\n        constructor(name, description) {\n            this.name = name;\n            this.description = description !== null && description !== void 0 ? description : '';\n            this._tokenStructuralPropertyT = null;\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    // Fallback\n    function fallbackRandomValues(buffer) {\n        let value = 0;\n        for (let i = 0, n = buffer.length; i < n; ++i) {\n            if (i % 4 === 0) {\n                value = (Math.random() * 0xffffffff) >>> 0;\n            }\n            buffer[i] = value & 0xff;\n            value >>>= 8;\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     * The namespace for random number related functionality.\n     */\n    exports.Random = void 0;\n    (function (Random) {\n        /**\n         * A function which generates random bytes.\n         *\n         * @param buffer - The `Uint8Array` to fill with random bytes.\n         *\n         * #### Notes\n         * A cryptographically strong random number generator will be used if\n         * available. Otherwise, `Math.random` will be used as a fallback for\n         * randomness.\n         *\n         * The following RNGs are supported, listed in order of precedence:\n         *   - `window.crypto.getRandomValues`\n         *   - `window.msCrypto.getRandomValues`\n         *   - `require('crypto').randomFillSync\n         *   - `require('crypto').randomBytes\n         *   - `Math.random`\n         */\n        Random.getRandomValues = (() => {\n            // Look up the crypto module if available.\n            const crypto = (typeof window !== 'undefined' && (window.crypto || window.msCrypto)) ||\n                null;\n            // Modern browsers and IE 11\n            if (crypto && typeof crypto.getRandomValues === 'function') {\n                return function getRandomValues(buffer) {\n                    return crypto.getRandomValues(buffer);\n                };\n            }\n            // Fallback\n            return fallbackRandomValues;\n        })();\n    })(exports.Random || (exports.Random = {}));\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 function which creates a function that generates UUID v4 identifiers.\n     *\n     * @returns A new function that creates a UUID v4 string.\n     *\n     * #### Notes\n     * This implementation complies with RFC 4122.\n     *\n     * This uses `Random.getRandomValues()` for random bytes, which in\n     * turn will use the underlying `crypto` module of the platform if\n     * it is available. The fallback for randomness is `Math.random`.\n     */\n    function uuid4Factory(getRandomValues) {\n        // Create a 16 byte array to hold the random values.\n        const bytes = new Uint8Array(16);\n        // Create a look up table from bytes to hex strings.\n        const lut = new Array(256);\n        // Pad the single character hex digits with a leading zero.\n        for (let i = 0; i < 16; ++i) {\n            lut[i] = '0' + i.toString(16);\n        }\n        // Populate the rest of the hex digits.\n        for (let i = 16; i < 256; ++i) {\n            lut[i] = i.toString(16);\n        }\n        // Return a function which generates the UUID.\n        return function uuid4() {\n            // Get a new batch of random values.\n            getRandomValues(bytes);\n            // Set the UUID version number to 4.\n            bytes[6] = 0x40 | (bytes[6] & 0x0f);\n            // Set the clock sequence bit to the RFC spec.\n            bytes[8] = 0x80 | (bytes[8] & 0x3f);\n            // Assemble the UUID string.\n            return (lut[bytes[0]] +\n                lut[bytes[1]] +\n                lut[bytes[2]] +\n                lut[bytes[3]] +\n                '-' +\n                lut[bytes[4]] +\n                lut[bytes[5]] +\n                '-' +\n                lut[bytes[6]] +\n                lut[bytes[7]] +\n                '-' +\n                lut[bytes[8]] +\n                lut[bytes[9]] +\n                '-' +\n                lut[bytes[10]] +\n                lut[bytes[11]] +\n                lut[bytes[12]] +\n                lut[bytes[13]] +\n                lut[bytes[14]] +\n                lut[bytes[15]]);\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     * The namespace for UUID related functionality.\n     */\n    exports.UUID = void 0;\n    (function (UUID) {\n        /**\n         * A function which generates UUID v4 identifiers.\n         *\n         * @returns A new UUID v4 string.\n         *\n         * #### Notes\n         * This implementation complies with RFC 4122.\n         *\n         * This uses `Random.getRandomValues()` for random bytes, which in\n         * turn will use the underlying `crypto` module of the platform if\n         * it is available. The fallback for randomness is `Math.random`.\n         */\n        UUID.uuid4 = uuid4Factory(exports.Random.getRandomValues);\n    })(exports.UUID || (exports.UUID = {}));\n\n    exports.MimeData = MimeData;\n    exports.PluginRegistry = PluginRegistry;\n    exports.PromiseDelegate = PromiseDelegate;\n    exports.Token = Token;\n\n}));\n//# sourceMappingURL=index.js.map\n","import { find, ArrayExt } from '@lumino/algorithm';\nimport { PromiseDelegate } from '@lumino/coreutils';\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 * @packageDocumentation\n * @module signaling\n */\n/**\n * A concrete implementation of `ISignal`.\n *\n * #### Example\n * ```typescript\n * import { ISignal, Signal } from '@lumino/signaling';\n *\n * class SomeClass {\n *\n *   constructor(name: string) {\n *     this.name = name;\n *   }\n *\n *   readonly name: string;\n *\n *   get valueChanged: ISignal<this, number> {\n *     return this._valueChanged;\n *   }\n *\n *   get value(): number {\n *     return this._value;\n *   }\n *\n *   set value(value: number) {\n *     if (value === this._value) {\n *       return;\n *     }\n *     this._value = value;\n *     this._valueChanged.emit(value);\n *   }\n *\n *   private _value = 0;\n *   private _valueChanged = new Signal<this, number>(this);\n * }\n *\n * function logger(sender: SomeClass, value: number): void {\n *   console.log(sender.name, value);\n * }\n *\n * let m1 = new SomeClass('foo');\n * let m2 = new SomeClass('bar');\n *\n * m1.valueChanged.connect(logger);\n * m2.valueChanged.connect(logger);\n *\n * m1.value = 42;  // logs: foo 42\n * m2.value = 17;  // logs: bar 17\n * ```\n */\nclass Signal {\n    /**\n     * Construct a new signal.\n     *\n     * @param sender - The sender which owns the signal.\n     */\n    constructor(sender) {\n        this.sender = sender;\n    }\n    /**\n     * Connect a slot to the signal.\n     *\n     * @param slot - The slot to invoke when the signal is emitted.\n     *\n     * @param thisArg - The `this` context for the slot. If provided,\n     *   this must be a non-primitive object.\n     *\n     * @returns `true` if the connection succeeds, `false` otherwise.\n     */\n    connect(slot, thisArg) {\n        return Private.connect(this, slot, thisArg);\n    }\n    /**\n     * Disconnect a slot from the signal.\n     *\n     * @param slot - The slot to disconnect from the signal.\n     *\n     * @param thisArg - The `this` context for the slot. If provided,\n     *   this must be a non-primitive object.\n     *\n     * @returns `true` if the connection is removed, `false` otherwise.\n     */\n    disconnect(slot, thisArg) {\n        return Private.disconnect(this, slot, thisArg);\n    }\n    /**\n     * Emit the signal and invoke the connected slots.\n     *\n     * @param args - The args to pass to the connected slots.\n     *\n     * #### Notes\n     * Slots are invoked synchronously in connection order.\n     *\n     * Exceptions thrown by connected slots will be caught and logged.\n     */\n    emit(args) {\n        Private.emit(this, args);\n    }\n}\n/**\n * The namespace for the `Signal` class statics.\n */\n(function (Signal) {\n    /**\n     * Remove all connections between a sender and receiver.\n     *\n     * @param sender - The sender object of interest.\n     *\n     * @param receiver - The receiver object of interest.\n     *\n     * #### Notes\n     * If a `thisArg` is provided when connecting a signal, that object\n     * is considered the receiver. Otherwise, the `slot` is considered\n     * the receiver.\n     */\n    function disconnectBetween(sender, receiver) {\n        Private.disconnectBetween(sender, receiver);\n    }\n    Signal.disconnectBetween = disconnectBetween;\n    /**\n     * Remove all connections where the given object is the sender.\n     *\n     * @param sender - The sender object of interest.\n     */\n    function disconnectSender(sender) {\n        Private.disconnectSender(sender);\n    }\n    Signal.disconnectSender = disconnectSender;\n    /**\n     * Remove all connections where the given object is the receiver.\n     *\n     * @param receiver - The receiver object of interest.\n     *\n     * #### Notes\n     * If a `thisArg` is provided when connecting a signal, that object\n     * is considered the receiver. Otherwise, the `slot` is considered\n     * the receiver.\n     */\n    function disconnectReceiver(receiver) {\n        Private.disconnectReceiver(receiver);\n    }\n    Signal.disconnectReceiver = disconnectReceiver;\n    /**\n     * Remove all connections where an object is the sender or receiver.\n     *\n     * @param object - The object of interest.\n     *\n     * #### Notes\n     * If a `thisArg` is provided when connecting a signal, that object\n     * is considered the receiver. Otherwise, the `slot` is considered\n     * the receiver.\n     */\n    function disconnectAll(object) {\n        Private.disconnectAll(object);\n    }\n    Signal.disconnectAll = disconnectAll;\n    /**\n     * Clear all signal data associated with the given object.\n     *\n     * @param object - The object for which the data should be cleared.\n     *\n     * #### Notes\n     * This removes all signal connections and any other signal data\n     * associated with the object.\n     */\n    function clearData(object) {\n        Private.disconnectAll(object);\n    }\n    Signal.clearData = clearData;\n    /**\n     * Get the signal exception handler.\n     *\n     * @returns The current exception handler.\n     *\n     * #### Notes\n     * The default exception handler is `console.error`.\n     */\n    function getExceptionHandler() {\n        return Private.exceptionHandler;\n    }\n    Signal.getExceptionHandler = getExceptionHandler;\n    /**\n     * Set the signal exception handler.\n     *\n     * @param handler - The function to use as the exception handler.\n     *\n     * @returns The old exception handler.\n     *\n     * #### Notes\n     * The exception handler is invoked when a slot throws an exception.\n     */\n    function setExceptionHandler(handler) {\n        let old = Private.exceptionHandler;\n        Private.exceptionHandler = handler;\n        return old;\n    }\n    Signal.setExceptionHandler = setExceptionHandler;\n})(Signal || (Signal = {}));\n/**\n * A concrete implementation of `IStream`.\n *\n * #### Example\n * ```typescript\n * import { IStream, Stream } from '@lumino/signaling';\n *\n * class SomeClass {\n *\n *   constructor(name: string) {\n *     this.name = name;\n *   }\n *\n *   readonly name: string;\n *\n *   get pings(): IStream<this, string> {\n *     return this._pings;\n *   }\n *\n *   ping(value: string) {\n *     this._pings.emit(value);\n *   }\n *\n *   private _pings = new Stream<this, string>(this);\n * }\n *\n * let m1 = new SomeClass('foo');\n *\n * m1.pings.connect((_, value: string) => {\n *   console.log('connect', value);\n * });\n *\n * void (async () => {\n *   for await (const ping of m1.pings) {\n *     console.log('iterator', ping);\n *   }\n * })();\n *\n * m1.ping('alpha');  // logs: connect alpha\n *                    // logs: iterator alpha\n * m1.ping('beta');   // logs: connect beta\n *                    // logs: iterator beta\n * ```\n */\nclass Stream extends Signal {\n    constructor() {\n        super(...arguments);\n        this._pending = new PromiseDelegate();\n    }\n    /**\n     * Return an async iterator that yields every emission.\n     */\n    async *[Symbol.asyncIterator]() {\n        let pending = this._pending;\n        while (true) {\n            try {\n                const { args, next } = await pending.promise;\n                pending = next;\n                yield args;\n            }\n            catch (_) {\n                return; // Any promise rejection stops the iterator.\n            }\n        }\n    }\n    /**\n     * Emit the signal, invoke the connected slots, and yield the emission.\n     *\n     * @param args - The args to pass to the connected slots.\n     */\n    emit(args) {\n        const pending = this._pending;\n        const next = (this._pending = new PromiseDelegate());\n        pending.resolve({ args, next });\n        super.emit(args);\n    }\n    /**\n     * Stop the stream's async iteration.\n     */\n    stop() {\n        this._pending.promise.catch(() => undefined);\n        this._pending.reject('stop');\n        this._pending = new PromiseDelegate();\n    }\n}\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * The signal exception handler function.\n     */\n    Private.exceptionHandler = (err) => {\n        console.error(err);\n    };\n    /**\n     * Connect a slot to a signal.\n     *\n     * @param signal - The signal of interest.\n     *\n     * @param slot - The slot to invoke when the signal is emitted.\n     *\n     * @param thisArg - The `this` context for the slot. If provided,\n     *   this must be a non-primitive object.\n     *\n     * @returns `true` if the connection succeeds, `false` otherwise.\n     */\n    function connect(signal, slot, thisArg) {\n        // Coerce a `null` `thisArg` to `undefined`.\n        thisArg = thisArg || undefined;\n        // Ensure the sender's array of receivers is created.\n        let receivers = receiversForSender.get(signal.sender);\n        if (!receivers) {\n            receivers = [];\n            receiversForSender.set(signal.sender, receivers);\n        }\n        // Bail if a matching connection already exists.\n        if (findConnection(receivers, signal, slot, thisArg)) {\n            return false;\n        }\n        // Choose the best object for the receiver.\n        let receiver = thisArg || slot;\n        // Ensure the receiver's array of senders is created.\n        let senders = sendersForReceiver.get(receiver);\n        if (!senders) {\n            senders = [];\n            sendersForReceiver.set(receiver, senders);\n        }\n        // Create a new connection and add it to the end of each array.\n        let connection = { signal, slot, thisArg };\n        receivers.push(connection);\n        senders.push(connection);\n        // Indicate a successful connection.\n        return true;\n    }\n    Private.connect = connect;\n    /**\n     * Disconnect a slot from a signal.\n     *\n     * @param signal - The signal of interest.\n     *\n     * @param slot - The slot to disconnect from the signal.\n     *\n     * @param thisArg - The `this` context for the slot. If provided,\n     *   this must be a non-primitive object.\n     *\n     * @returns `true` if the connection is removed, `false` otherwise.\n     */\n    function disconnect(signal, slot, thisArg) {\n        // Coerce a `null` `thisArg` to `undefined`.\n        thisArg = thisArg || undefined;\n        // Lookup the list of receivers, and bail if none exist.\n        let receivers = receiversForSender.get(signal.sender);\n        if (!receivers || receivers.length === 0) {\n            return false;\n        }\n        // Bail if no matching connection exits.\n        let connection = findConnection(receivers, signal, slot, thisArg);\n        if (!connection) {\n            return false;\n        }\n        // Choose the best object for the receiver.\n        let receiver = thisArg || slot;\n        // Lookup the array of senders, which is now known to exist.\n        let senders = sendersForReceiver.get(receiver);\n        // Clear the connection and schedule cleanup of the arrays.\n        connection.signal = null;\n        scheduleCleanup(receivers);\n        scheduleCleanup(senders);\n        // Indicate a successful disconnection.\n        return true;\n    }\n    Private.disconnect = disconnect;\n    /**\n     * Remove all connections between a sender and receiver.\n     *\n     * @param sender - The sender object of interest.\n     *\n     * @param receiver - The receiver object of interest.\n     */\n    function disconnectBetween(sender, receiver) {\n        // If there are no receivers, there is nothing to do.\n        let receivers = receiversForSender.get(sender);\n        if (!receivers || receivers.length === 0) {\n            return;\n        }\n        // If there are no senders, there is nothing to do.\n        let senders = sendersForReceiver.get(receiver);\n        if (!senders || senders.length === 0) {\n            return;\n        }\n        // Clear each connection between the sender and receiver.\n        for (const connection of senders) {\n            // Skip connections which have already been cleared.\n            if (!connection.signal) {\n                continue;\n            }\n            // Clear the connection if it matches the sender.\n            if (connection.signal.sender === sender) {\n                connection.signal = null;\n            }\n        }\n        // Schedule a cleanup of the senders and receivers.\n        scheduleCleanup(receivers);\n        scheduleCleanup(senders);\n    }\n    Private.disconnectBetween = disconnectBetween;\n    /**\n     * Remove all connections where the given object is the sender.\n     *\n     * @param sender - The sender object of interest.\n     */\n    function disconnectSender(sender) {\n        // If there are no receivers, there is nothing to do.\n        let receivers = receiversForSender.get(sender);\n        if (!receivers || receivers.length === 0) {\n            return;\n        }\n        // Clear each receiver connection.\n        for (const connection of receivers) {\n            // Skip connections which have already been cleared.\n            if (!connection.signal) {\n                continue;\n            }\n            // Choose the best object for the receiver.\n            let receiver = connection.thisArg || connection.slot;\n            // Clear the connection.\n            connection.signal = null;\n            // Cleanup the array of senders, which is now known to exist.\n            scheduleCleanup(sendersForReceiver.get(receiver));\n        }\n        // Schedule a cleanup of the receivers.\n        scheduleCleanup(receivers);\n    }\n    Private.disconnectSender = disconnectSender;\n    /**\n     * Remove all connections where the given object is the receiver.\n     *\n     * @param receiver - The receiver object of interest.\n     */\n    function disconnectReceiver(receiver) {\n        // If there are no senders, there is nothing to do.\n        let senders = sendersForReceiver.get(receiver);\n        if (!senders || senders.length === 0) {\n            return;\n        }\n        // Clear each sender connection.\n        for (const connection of senders) {\n            // Skip connections which have already been cleared.\n            if (!connection.signal) {\n                continue;\n            }\n            // Lookup the sender for the connection.\n            let sender = connection.signal.sender;\n            // Clear the connection.\n            connection.signal = null;\n            // Cleanup the array of receivers, which is now known to exist.\n            scheduleCleanup(receiversForSender.get(sender));\n        }\n        // Schedule a cleanup of the list of senders.\n        scheduleCleanup(senders);\n    }\n    Private.disconnectReceiver = disconnectReceiver;\n    /**\n     * Remove all connections where an object is the sender or receiver.\n     *\n     * @param object - The object of interest.\n     */\n    function disconnectAll(object) {\n        // Remove all connections where the given object is the sender.\n        disconnectSender(object);\n        // Remove all connections where the given object is the receiver.\n        disconnectReceiver(object);\n    }\n    Private.disconnectAll = disconnectAll;\n    /**\n     * Emit a signal and invoke its connected slots.\n     *\n     * @param signal - The signal of interest.\n     *\n     * @param args - The args to pass to the connected slots.\n     *\n     * #### Notes\n     * Slots are invoked synchronously in connection order.\n     *\n     * Exceptions thrown by connected slots will be caught and logged.\n     */\n    function emit(signal, args) {\n        // If there are no receivers, there is nothing to do.\n        let receivers = receiversForSender.get(signal.sender);\n        if (!receivers || receivers.length === 0) {\n            return;\n        }\n        // Invoke the slots for connections with a matching signal.\n        // Any connections added during emission are not invoked.\n        for (let i = 0, n = receivers.length; i < n; ++i) {\n            let connection = receivers[i];\n            if (connection.signal === signal) {\n                invokeSlot(connection, args);\n            }\n        }\n    }\n    Private.emit = emit;\n    /**\n     * A weak mapping of sender to array of receiver connections.\n     */\n    const receiversForSender = new WeakMap();\n    /**\n     * A weak mapping of receiver to array of sender connections.\n     */\n    const sendersForReceiver = new WeakMap();\n    /**\n     * A set of connection arrays which are pending cleanup.\n     */\n    const dirtySet = new Set();\n    /**\n     * A function to schedule an event loop callback.\n     */\n    const schedule = (() => {\n        let ok = typeof requestAnimationFrame === 'function';\n        return ok ? requestAnimationFrame : setImmediate;\n    })();\n    /**\n     * Find a connection which matches the given parameters.\n     */\n    function findConnection(connections, signal, slot, thisArg) {\n        return find(connections, connection => connection.signal === signal &&\n            connection.slot === slot &&\n            connection.thisArg === thisArg);\n    }\n    /**\n     * Invoke a slot with the given parameters.\n     *\n     * The connection is assumed to be valid.\n     *\n     * Exceptions in the slot will be caught and logged.\n     */\n    function invokeSlot(connection, args) {\n        let { signal, slot, thisArg } = connection;\n        try {\n            slot.call(thisArg, signal.sender, args);\n        }\n        catch (err) {\n            Private.exceptionHandler(err);\n        }\n    }\n    /**\n     * Schedule a cleanup of a connection array.\n     *\n     * This will add the array to the dirty set and schedule a deferred\n     * cleanup of the array contents. On cleanup, any connection with a\n     * `null` signal will be removed from the array.\n     */\n    function scheduleCleanup(array) {\n        if (dirtySet.size === 0) {\n            schedule(cleanupDirtySet);\n        }\n        dirtySet.add(array);\n    }\n    /**\n     * Cleanup the connection lists in the dirty set.\n     *\n     * This function should only be invoked asynchronously, when the\n     * stack frame is guaranteed to not be on the path of user code.\n     */\n    function cleanupDirtySet() {\n        dirtySet.forEach(cleanupConnections);\n        dirtySet.clear();\n    }\n    /**\n     * Cleanup the dirty connections in a connections array.\n     *\n     * This will remove any connection with a `null` signal.\n     *\n     * This function should only be invoked asynchronously, when the\n     * stack frame is guaranteed to not be on the path of user code.\n     */\n    function cleanupConnections(connections) {\n        ArrayExt.removeAllWhere(connections, isDeadConnection);\n    }\n    /**\n     * Test whether a connection is dead.\n     *\n     * A dead connection has a `null` signal.\n     */\n    function isDeadConnection(connection) {\n        return connection.signal === null;\n    }\n})(Private || (Private = {}));\n\nexport { Signal, Stream };\n//# sourceMappingURL=index.es6.js.map\n","import { Signal } from '@lumino/signaling';\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 * @packageDocumentation\n * @module disposable\n */\n/**\n * A disposable object which delegates to a callback function.\n */\nclass DisposableDelegate {\n    /**\n     * Construct a new disposable delegate.\n     *\n     * @param fn - The callback function to invoke on dispose.\n     */\n    constructor(fn) {\n        this._fn = fn;\n    }\n    /**\n     * Test whether the delegate has been disposed.\n     */\n    get isDisposed() {\n        return !this._fn;\n    }\n    /**\n     * Dispose of the delegate and invoke the callback function.\n     */\n    dispose() {\n        if (!this._fn) {\n            return;\n        }\n        let fn = this._fn;\n        this._fn = null;\n        fn();\n    }\n}\n/**\n * An observable disposable object which delegates to a callback function.\n */\nclass ObservableDisposableDelegate extends DisposableDelegate {\n    constructor() {\n        super(...arguments);\n        this._disposed = new Signal(this);\n    }\n    /**\n     * A signal emitted when the delegate is disposed.\n     */\n    get disposed() {\n        return this._disposed;\n    }\n    /**\n     * Dispose of the delegate and invoke the callback function.\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        super.dispose();\n        this._disposed.emit(undefined);\n        Signal.clearData(this);\n    }\n}\n/**\n * An object which manages a collection of disposable items.\n */\nclass DisposableSet {\n    constructor() {\n        this._isDisposed = false;\n        this._items = new Set();\n    }\n    /**\n     * Test whether the set has been disposed.\n     */\n    get isDisposed() {\n        return this._isDisposed;\n    }\n    /**\n     * Dispose of the set and the items it contains.\n     *\n     * #### Notes\n     * Items are disposed in the order they are added to the set.\n     */\n    dispose() {\n        if (this._isDisposed) {\n            return;\n        }\n        this._isDisposed = true;\n        this._items.forEach(item => {\n            item.dispose();\n        });\n        this._items.clear();\n    }\n    /**\n     * Test whether the set contains a specific item.\n     *\n     * @param item - The item of interest.\n     *\n     * @returns `true` if the set contains the item, `false` otherwise.\n     */\n    contains(item) {\n        return this._items.has(item);\n    }\n    /**\n     * Add a disposable item to the set.\n     *\n     * @param item - The item to add to the set.\n     *\n     * #### Notes\n     * If the item is already contained in the set, this is a no-op.\n     */\n    add(item) {\n        this._items.add(item);\n    }\n    /**\n     * Remove a disposable item from the set.\n     *\n     * @param item - The item to remove from the set.\n     *\n     * #### Notes\n     * If the item is not contained in the set, this is a no-op.\n     */\n    remove(item) {\n        this._items.delete(item);\n    }\n    /**\n     * Remove all items from the set.\n     */\n    clear() {\n        this._items.clear();\n    }\n}\n/**\n * The namespace for the `DisposableSet` class statics.\n */\n(function (DisposableSet) {\n    /**\n     * Create a disposable set from an iterable of items.\n     *\n     * @param items - The iterable object of interest.\n     *\n     * @returns A new disposable initialized with the given items.\n     */\n    function from(items) {\n        let set = new DisposableSet();\n        for (const item of items) {\n            set.add(item);\n        }\n        return set;\n    }\n    DisposableSet.from = from;\n})(DisposableSet || (DisposableSet = {}));\n/**\n * An observable object which manages a collection of disposable items.\n */\nclass ObservableDisposableSet extends DisposableSet {\n    constructor() {\n        super(...arguments);\n        this._disposed = new Signal(this);\n    }\n    /**\n     * A signal emitted when the set is disposed.\n     */\n    get disposed() {\n        return this._disposed;\n    }\n    /**\n     * Dispose of the set and the items it contains.\n     *\n     * #### Notes\n     * Items are disposed in the order they are added to the set.\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        super.dispose();\n        this._disposed.emit(undefined);\n        Signal.clearData(this);\n    }\n}\n/**\n * The namespace for the `ObservableDisposableSet` class statics.\n */\n(function (ObservableDisposableSet) {\n    /**\n     * Create an observable disposable set from an iterable of items.\n     *\n     * @param items - The iterable object of interest.\n     *\n     * @returns A new disposable initialized with the given items.\n     */\n    function from(items) {\n        let set = new ObservableDisposableSet();\n        for (const item of items) {\n            set.add(item);\n        }\n        return set;\n    }\n    ObservableDisposableSet.from = from;\n})(ObservableDisposableSet || (ObservableDisposableSet = {}));\n\nexport { DisposableDelegate, DisposableSet, ObservableDisposableDelegate, ObservableDisposableSet };\n//# sourceMappingURL=index.es6.js.map\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2019, 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 * The namespace for clipboard related functionality.\n */\nvar ClipboardExt;\n(function (ClipboardExt) {\n    /**\n     * Copy text to the system clipboard.\n     *\n     * @param text - The text to copy to the clipboard.\n     */\n    function copyText(text) {\n        // Fetch the document body.\n        const body = document.body;\n        // Set up the clipboard event listener.\n        const handler = (event) => {\n            // Stop the event propagation.\n            event.preventDefault();\n            event.stopPropagation();\n            // Set the clipboard data.\n            event.clipboardData.setData('text', text);\n            // Remove the event listener.\n            body.removeEventListener('copy', handler, true);\n        };\n        // Add the event listener.\n        body.addEventListener('copy', handler, true);\n        // Trigger the event.\n        document.execCommand('copy');\n    }\n    ClipboardExt.copyText = copyText;\n})(ClipboardExt || (ClipboardExt = {}));\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 * The namespace for element related utilities.\n */\nvar ElementExt;\n(function (ElementExt) {\n    /**\n     * Compute the box sizing for an element.\n     *\n     * @param element - The element of interest.\n     *\n     * @returns The box sizing data for the specified element.\n     */\n    function boxSizing(element) {\n        let style = window.getComputedStyle(element);\n        let bt = parseFloat(style.borderTopWidth) || 0;\n        let bl = parseFloat(style.borderLeftWidth) || 0;\n        let br = parseFloat(style.borderRightWidth) || 0;\n        let bb = parseFloat(style.borderBottomWidth) || 0;\n        let pt = parseFloat(style.paddingTop) || 0;\n        let pl = parseFloat(style.paddingLeft) || 0;\n        let pr = parseFloat(style.paddingRight) || 0;\n        let pb = parseFloat(style.paddingBottom) || 0;\n        let hs = bl + pl + pr + br;\n        let vs = bt + pt + pb + bb;\n        return {\n            borderTop: bt,\n            borderLeft: bl,\n            borderRight: br,\n            borderBottom: bb,\n            paddingTop: pt,\n            paddingLeft: pl,\n            paddingRight: pr,\n            paddingBottom: pb,\n            horizontalSum: hs,\n            verticalSum: vs\n        };\n    }\n    ElementExt.boxSizing = boxSizing;\n    /**\n     * Compute the size limits for an element.\n     *\n     * @param element - The element of interest.\n     *\n     * @returns The size limit data for the specified element.\n     */\n    function sizeLimits(element) {\n        let style = window.getComputedStyle(element);\n        let minWidth = parseFloat(style.minWidth) || 0;\n        let minHeight = parseFloat(style.minHeight) || 0;\n        let maxWidth = parseFloat(style.maxWidth) || Infinity;\n        let maxHeight = parseFloat(style.maxHeight) || Infinity;\n        maxWidth = Math.max(minWidth, maxWidth);\n        maxHeight = Math.max(minHeight, maxHeight);\n        return { minWidth, minHeight, maxWidth, maxHeight };\n    }\n    ElementExt.sizeLimits = sizeLimits;\n    /**\n     * Test whether a client position lies within an element.\n     *\n     * @param element - The DOM element of interest.\n     *\n     * @param clientX - The client X coordinate of interest.\n     *\n     * @param clientY - The client Y coordinate of interest.\n     *\n     * @returns Whether the point is within the given element.\n     */\n    function hitTest(element, clientX, clientY) {\n        let rect = element.getBoundingClientRect();\n        return (clientX >= rect.left &&\n            clientX < rect.right &&\n            clientY >= rect.top &&\n            clientY < rect.bottom);\n    }\n    ElementExt.hitTest = hitTest;\n    /**\n     * Vertically scroll an element into view if needed.\n     *\n     * @param area - The scroll area element.\n     *\n     * @param element - The element of interest.\n     *\n     * #### Notes\n     * This follows the \"nearest\" behavior of the native `scrollIntoView`\n     * method, which is not supported by all browsers.\n     * https://drafts.csswg.org/cssom-view/#element-scrolling-members\n     *\n     * If the element fully covers the visible area or is fully contained\n     * within the visible area, no scrolling will take place. Otherwise,\n     * the nearest edges of the area and element are aligned.\n     */\n    function scrollIntoViewIfNeeded(area, element) {\n        let ar = area.getBoundingClientRect();\n        let er = element.getBoundingClientRect();\n        if (er.top <= ar.top && er.bottom >= ar.bottom) {\n            return;\n        }\n        if (er.top < ar.top && er.height <= ar.height) {\n            area.scrollTop -= ar.top - er.top;\n            return;\n        }\n        if (er.bottom > ar.bottom && er.height >= ar.height) {\n            area.scrollTop -= ar.top - er.top;\n            return;\n        }\n        if (er.top < ar.top && er.height > ar.height) {\n            area.scrollTop -= ar.bottom - er.bottom;\n            return;\n        }\n        if (er.bottom > ar.bottom && er.height < ar.height) {\n            area.scrollTop -= ar.bottom - er.bottom;\n            return;\n        }\n    }\n    ElementExt.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;\n})(ElementExt || (ElementExt = {}));\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 * The namespace for platform related utilities.\n */\nvar Platform;\n(function (Platform) {\n    /**\n     * A flag indicating whether the platform is Mac.\n     */\n    Platform.IS_MAC = !!navigator.platform.match(/Mac/i);\n    /**\n     * A flag indicating whether the platform is Windows.\n     */\n    Platform.IS_WIN = !!navigator.platform.match(/Win/i);\n    /**\n     * A flag indicating whether the browser is IE.\n     */\n    Platform.IS_IE = /Trident/.test(navigator.userAgent);\n    /**\n     * A flag indicating whether the browser is Edge.\n     */\n    Platform.IS_EDGE = /Edge/.test(navigator.userAgent);\n    /**\n     * Test whether the `accel` key is pressed.\n     *\n     * @param event - The keyboard or mouse event of interest.\n     *\n     * @returns Whether the `accel` key is pressed.\n     *\n     * #### Notes\n     * On Mac the `accel` key is the command key. On all other\n     * platforms the `accel` key is the control key.\n     */\n    function accelKey(event) {\n        return Platform.IS_MAC ? event.metaKey : event.ctrlKey;\n    }\n    Platform.accelKey = accelKey;\n})(Platform || (Platform = {}));\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 * The namespace for selector related utilities.\n */\nvar Selector;\n(function (Selector) {\n    /**\n     * Calculate the specificity of a single CSS selector.\n     *\n     * @param selector - The CSS selector of interest.\n     *\n     * @returns The specificity of the selector.\n     *\n     * #### Undefined Behavior\n     * The selector is invalid.\n     *\n     * #### Notes\n     * This is based on https://www.w3.org/TR/css3-selectors/#specificity\n     *\n     * A larger number represents a more specific selector.\n     *\n     * The smallest possible specificity is `0`.\n     *\n     * The result is represented as a hex number `0x<aa><bb><cc>` where\n     * each component is the count of the respective selector clause.\n     *\n     * If the selector contains commas, only the first clause is used.\n     *\n     * The computed result is cached, so subsequent calculations for the\n     * same selector are extremely fast.\n     */\n    function calculateSpecificity(selector) {\n        if (selector in Private.specificityCache) {\n            return Private.specificityCache[selector];\n        }\n        let result = Private.calculateSingle(selector);\n        return (Private.specificityCache[selector] = result);\n    }\n    Selector.calculateSpecificity = calculateSpecificity;\n    /**\n     * Test whether a selector is a valid CSS selector.\n     *\n     * @param selector - The CSS selector of interest.\n     *\n     * @returns `true` if the selector is valid, `false` otherwise.\n     *\n     * #### Notes\n     * The computed result is cached, so subsequent tests for the same\n     * selector are extremely fast.\n     */\n    function isValid(selector) {\n        if (selector in Private.validityCache) {\n            return Private.validityCache[selector];\n        }\n        let result = true;\n        try {\n            Private.testElem.querySelector(selector);\n        }\n        catch (err) {\n            result = false;\n        }\n        return (Private.validityCache[selector] = result);\n    }\n    Selector.isValid = isValid;\n    /**\n     * Test whether an element matches a CSS selector.\n     *\n     * @param element - The element of interest.\n     *\n     * @param selector - The valid CSS selector of interest.\n     *\n     * @returns `true` if the element is a match, `false` otherwise.\n     *\n     * #### Notes\n     * This function uses the builtin browser capabilities when possible,\n     * falling back onto a document query otherwise.\n     */\n    function matches(element, selector) {\n        return Private.protoMatchFunc.call(element, selector);\n    }\n    Selector.matches = matches;\n})(Selector || (Selector = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * A cache of computed selector specificity values.\n     */\n    Private.specificityCache = Object.create(null);\n    /**\n     * A cache of computed selector validity.\n     */\n    Private.validityCache = Object.create(null);\n    /**\n     * An empty element for testing selector validity.\n     */\n    Private.testElem = document.createElement('div');\n    /**\n     * A cross-browser CSS selector matching prototype function.\n     */\n    Private.protoMatchFunc = (() => {\n        let proto = Element.prototype;\n        return (proto.matches ||\n            proto.matchesSelector ||\n            proto.mozMatchesSelector ||\n            proto.msMatchesSelector ||\n            proto.oMatchesSelector ||\n            proto.webkitMatchesSelector ||\n            function (selector) {\n                let elem = this;\n                let matches = elem.ownerDocument\n                    ? elem.ownerDocument.querySelectorAll(selector)\n                    : [];\n                return Array.prototype.indexOf.call(matches, elem) !== -1;\n            });\n    })();\n    /**\n     * Calculate the specificity of a single selector.\n     *\n     * The behavior is undefined if the selector is invalid.\n     */\n    function calculateSingle(selector) {\n        // Ignore anything after the first comma.\n        selector = selector.split(',', 1)[0];\n        // Setup the aggregate counters.\n        let a = 0;\n        let b = 0;\n        let c = 0;\n        // Apply a regex to the front of the selector. If it succeeds, that\n        // portion of the selector is removed. Returns a success/fail flag.\n        function match(re) {\n            let match = selector.match(re);\n            if (match === null) {\n                return false;\n            }\n            selector = selector.slice(match[0].length);\n            return true;\n        }\n        // Replace the negation pseudo-class (which is ignored),\n        // but keep its inner content (which is not ignored).\n        selector = selector.replace(NEGATION_RE, ' $1 ');\n        // Continue matching until the selector is consumed.\n        while (selector.length > 0) {\n            // Match an ID selector.\n            if (match(ID_RE)) {\n                a++;\n                continue;\n            }\n            // Match a class selector.\n            if (match(CLASS_RE)) {\n                b++;\n                continue;\n            }\n            // Match an attribute selector.\n            if (match(ATTR_RE)) {\n                b++;\n                continue;\n            }\n            // Match a pseudo-element selector. This is done before matching\n            // a pseudo-class since this regex overlaps with that regex.\n            if (match(PSEUDO_ELEM_RE)) {\n                c++;\n                continue;\n            }\n            // Match a pseudo-class selector.\n            if (match(PSEDUO_CLASS_RE)) {\n                b++;\n                continue;\n            }\n            // Match a plain type selector.\n            if (match(TYPE_RE)) {\n                c++;\n                continue;\n            }\n            // Finally, match any ignored characters.\n            if (match(IGNORE_RE)) {\n                continue;\n            }\n            // At this point, the selector is assumed to be invalid.\n            return 0;\n        }\n        // Clamp each component to a reasonable base.\n        a = Math.min(a, 0xff);\n        b = Math.min(b, 0xff);\n        c = Math.min(c, 0xff);\n        // Combine the components into a single result.\n        return (a << 16) | (b << 8) | c;\n    }\n    Private.calculateSingle = calculateSingle;\n    /**\n     * A regex which matches an ID selector at string start.\n     */\n    const ID_RE = /^#[^\\s\\+>~#\\.\\[:]+/;\n    /**\n     * A regex which matches a class selector at string start.\n     */\n    const CLASS_RE = /^\\.[^\\s\\+>~#\\.\\[:]+/;\n    /**\n     * A regex which matches an attribute selector at string start.\n     */\n    const ATTR_RE = /^\\[[^\\]]+\\]/;\n    /**\n     * A regex which matches a type selector at string start.\n     */\n    const TYPE_RE = /^[^\\s\\+>~#\\.\\[:]+/;\n    /**\n     * A regex which matches a pseudo-element selector at string start.\n     */\n    const PSEUDO_ELEM_RE = /^(::[^\\s\\+>~#\\.\\[:]+|:first-line|:first-letter|:before|:after)/;\n    /**\n     * A regex which matches a pseudo-class selector at string start.\n     */\n    const PSEDUO_CLASS_RE = /^:[^\\s\\+>~#\\.\\[:]+/;\n    /**\n     * A regex which matches ignored characters at string start.\n     */\n    const IGNORE_RE = /^[\\s\\+>~\\*]+/;\n    /**\n     * A regex which matches the negation pseudo-class globally.\n     */\n    const NEGATION_RE = /:not\\(([^\\)]+)\\)/g;\n})(Private || (Private = {}));\n\nexport { ClipboardExt, ElementExt, Platform, Selector };\n//# sourceMappingURL=index.es6.js.map\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 * @packageDocumentation\n * @module keyboard\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 layout 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 {@link 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 */\nclass KeycodeLayout {\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     * @param modifierKeys - Array of modifier key names\n     */\n    constructor(name, codes, modifierKeys = []) {\n        this.name = name;\n        this._codes = codes;\n        this._keys = KeycodeLayout.extractKeys(codes);\n        this._modifierKeys = KeycodeLayout.convertToKeySet(modifierKeys);\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    keys() {\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    isValidKey(key) {\n        return key in this._keys;\n    }\n    /**\n     * Test whether the given key is a modifier key.\n     *\n     * @param key - The user provided key.\n     *\n     * @returns `true` if the key is a modifier key, `false` otherwise.\n     */\n    isModifierKey(key) {\n        return key in this._modifierKeys;\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    keyForKeydownEvent(event) {\n        return this._codes[event.keyCode] || '';\n    }\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 codes - The code map of interest.\n     *\n     * @returns A set of the keys in the code map.\n     */\n    function extractKeys(codes) {\n        let keys = Object.create(null);\n        for (let c in codes) {\n            keys[codes[c]] = true;\n        }\n        return keys;\n    }\n    KeycodeLayout.extractKeys = extractKeys;\n    /**\n     * Convert array of keys to a key set.\n     *\n     * @param keys - The array that needs to be converted\n     *\n     * @returns A set of the keys in the array.\n     */\n    function convertToKeySet(keys) {\n        let keySet = Object(null);\n        for (let i = 0, n = keys.length; i < n; ++i) {\n            keySet[keys[i]] = true;\n        }\n        return keySet;\n    }\n    KeycodeLayout.convertToKeySet = convertToKeySet;\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 */\nconst EN_US = new KeycodeLayout('en-us', {\n    8: 'Backspace',\n    9: 'Tab',\n    13: 'Enter',\n    16: 'Shift',\n    17: 'Ctrl',\n    18: 'Alt',\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    91: 'Meta',\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    224: 'Meta' // firefox\n}, ['Shift', 'Ctrl', 'Alt', 'Meta'] // modifier keys\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\nexport { EN_US, KeycodeLayout, getKeyboardLayout, setKeyboardLayout };\n//# sourceMappingURL=index.es6.js.map\n","import { ArrayExt } from '@lumino/algorithm';\nimport { JSONExt } from '@lumino/coreutils';\nimport { DisposableDelegate } from '@lumino/disposable';\nimport { Platform, Selector } from '@lumino/domutils';\nimport { getKeyboardLayout } from '@lumino/keyboard';\nimport { Signal } from '@lumino/signaling';\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 * @packageDocumentation\n * @module commands\n */\n/**\n * An object which manages a collection of commands.\n *\n * #### Notes\n * A command registry can be used to populate a variety of action-based\n * widgets, such as command palettes, menus, and toolbars.\n */\nclass CommandRegistry {\n    constructor() {\n        this._timerID = 0;\n        this._timerModifierID = 0;\n        this._replaying = false;\n        this._keystrokes = [];\n        this._keydownEvents = [];\n        this._keyBindings = [];\n        this._exactKeyMatch = null;\n        this._commands = new Map();\n        this._commandChanged = new Signal(this);\n        this._commandExecuted = new Signal(this);\n        this._keyBindingChanged = new Signal(this);\n        this._holdKeyBindingPromises = new Map();\n    }\n    /**\n     * A signal emitted when a command has changed.\n     *\n     * #### Notes\n     * This signal is useful for visual representations of commands which\n     * need to refresh when the state of a relevant command has changed.\n     */\n    get commandChanged() {\n        return this._commandChanged;\n    }\n    /**\n     * A signal emitted when a command has executed.\n     *\n     * #### Notes\n     * Care should be taken when consuming this signal. The command system is used\n     * by many components for many user actions. Handlers registered with this\n     * signal must return quickly to ensure the overall application remains responsive.\n     */\n    get commandExecuted() {\n        return this._commandExecuted;\n    }\n    /**\n     * A signal emitted when a key binding is changed.\n     */\n    get keyBindingChanged() {\n        return this._keyBindingChanged;\n    }\n    /**\n     * A read-only array of the key bindings in the registry.\n     */\n    get keyBindings() {\n        return this._keyBindings;\n    }\n    /**\n     * List the ids of the registered commands.\n     *\n     * @returns A new array of the registered command ids.\n     */\n    listCommands() {\n        return Array.from(this._commands.keys());\n    }\n    /**\n     * Test whether a specific command is registered.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @returns `true` if the command is registered, `false` otherwise.\n     */\n    hasCommand(id) {\n        return this._commands.has(id);\n    }\n    /**\n     * Add a command to the registry.\n     *\n     * @param id - The unique id of the command.\n     *\n     * @param options - The options for the command.\n     *\n     * @returns A disposable which will remove the command.\n     *\n     * @throws An error if the given `id` is already registered.\n     */\n    addCommand(id, options) {\n        // Throw an error if the id is already registered.\n        if (this._commands.has(id)) {\n            throw new Error(`Command '${id}' already registered.`);\n        }\n        // Add the command to the registry.\n        this._commands.set(id, Private.createCommand(options));\n        // Emit the `commandChanged` signal.\n        this._commandChanged.emit({ id, type: 'added' });\n        // Return a disposable which will remove the command.\n        return new DisposableDelegate(() => {\n            // Remove the command from the registry.\n            this._commands.delete(id);\n            // Emit the `commandChanged` signal.\n            this._commandChanged.emit({ id, type: 'removed' });\n        });\n    }\n    /**\n     * Notify listeners that the state of a command has changed.\n     *\n     * @param id - The id of the command which has changed. If more than\n     *   one command has changed, this argument should be omitted.\n     *\n     * @throws An error if the given `id` is not registered.\n     *\n     * #### Notes\n     * This method should be called by the command author whenever the\n     * application state changes such that the results of the command\n     * metadata functions may have changed.\n     *\n     * This will cause the `commandChanged` signal to be emitted.\n     */\n    notifyCommandChanged(id) {\n        if (id !== undefined && !this._commands.has(id)) {\n            throw new Error(`Command '${id}' is not registered.`);\n        }\n        this._commandChanged.emit({ id, type: id ? 'changed' : 'many-changed' });\n    }\n    /**\n     * Get the description for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The description for the command.\n     */\n    describedBy(id, args = JSONExt.emptyObject) {\n        var _a;\n        let cmd = this._commands.get(id);\n        return Promise.resolve((_a = cmd === null || cmd === void 0 ? void 0 : cmd.describedBy.call(undefined, args)) !== null && _a !== void 0 ? _a : { args: null });\n    }\n    /**\n     * Get the display label for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The display label for the command, or an empty string\n     *   if the command is not registered.\n     */\n    label(id, args = JSONExt.emptyObject) {\n        var _a;\n        let cmd = this._commands.get(id);\n        return (_a = cmd === null || cmd === void 0 ? void 0 : cmd.label.call(undefined, args)) !== null && _a !== void 0 ? _a : '';\n    }\n    /**\n     * Get the mnemonic index for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The mnemonic index for the command, or `-1` if the\n     *   command is not registered.\n     */\n    mnemonic(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.mnemonic.call(undefined, args) : -1;\n    }\n    /**\n     * Get the icon renderer for a specific command.\n     *\n     * DEPRECATED: if set to a string value, the .icon field will\n     * function as an alias for the .iconClass field, for backwards\n     * compatibility. In the future when this is removed, the default\n     * return type will become undefined.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The icon renderer for the command or `undefined`.\n     */\n    icon(id, args = JSONExt.emptyObject) {\n        var _a;\n        return (_a = this._commands.get(id)) === null || _a === void 0 ? void 0 : _a.icon.call(undefined, args);\n    }\n    /**\n     * Get the icon class for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The icon class for the command, or an empty string if\n     *   the command is not registered.\n     */\n    iconClass(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.iconClass.call(undefined, args) : '';\n    }\n    /**\n     * Get the icon label for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The icon label for the command, or an empty string if\n     *   the command is not registered.\n     */\n    iconLabel(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.iconLabel.call(undefined, args) : '';\n    }\n    /**\n     * Get the short form caption for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The caption for the command, or an empty string if the\n     *   command is not registered.\n     */\n    caption(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.caption.call(undefined, args) : '';\n    }\n    /**\n     * Get the usage help text for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The usage text for the command, or an empty string if\n     *   the command is not registered.\n     */\n    usage(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.usage.call(undefined, args) : '';\n    }\n    /**\n     * Get the extra class name for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The class name for the command, or an empty string if\n     *   the command is not registered.\n     */\n    className(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.className.call(undefined, args) : '';\n    }\n    /**\n     * Get the dataset for a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns The dataset for the command, or an empty dataset if\n     *   the command is not registered.\n     */\n    dataset(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.dataset.call(undefined, args) : {};\n    }\n    /**\n     * Test whether a specific command is enabled.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns A boolean indicating whether the command is enabled,\n     *   or `false` if the command is not registered.\n     */\n    isEnabled(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.isEnabled.call(undefined, args) : false;\n    }\n    /**\n     * Test whether a specific command is toggled.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns A boolean indicating whether the command is toggled,\n     *   or `false` if the command is not registered.\n     */\n    isToggled(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.isToggled.call(undefined, args) : false;\n    }\n    /**\n     * Test whether a specific command is toggleable.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns A boolean indicating whether the command is toggleable,\n     *   or `false` if the command is not registered.\n     */\n    isToggleable(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.isToggleable : false;\n    }\n    /**\n     * Test whether a specific command is visible.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns A boolean indicating whether the command is visible,\n     *   or `false` if the command is not registered.\n     */\n    isVisible(id, args = JSONExt.emptyObject) {\n        let cmd = this._commands.get(id);\n        return cmd ? cmd.isVisible.call(undefined, args) : false;\n    }\n    /**\n     * Execute a specific command.\n     *\n     * @param id - The id of the command of interest.\n     *\n     * @param args - The arguments for the command.\n     *\n     * @returns A promise which resolves with the result of the command.\n     *\n     * #### Notes\n     * The promise will reject if the command throws an exception,\n     * or if the command is not registered.\n     */\n    execute(id, args = JSONExt.emptyObject) {\n        // Reject if the command is not registered.\n        let cmd = this._commands.get(id);\n        if (!cmd) {\n            return Promise.reject(new Error(`Command '${id}' not registered.`));\n        }\n        // Execute the command and reject if an exception is thrown.\n        let value;\n        try {\n            value = cmd.execute.call(undefined, args);\n        }\n        catch (err) {\n            value = Promise.reject(err);\n        }\n        // Create the return promise which resolves the result.\n        let result = Promise.resolve(value);\n        // Emit the command executed signal.\n        this._commandExecuted.emit({ id, args, result });\n        // Return the result promise to the caller.\n        return result;\n    }\n    /**\n     * Add a key binding to the registry.\n     *\n     * @param options - The options for creating the key binding.\n     *\n     * @returns A disposable which removes the added key binding.\n     *\n     * #### Notes\n     * If multiple key bindings are registered for the same sequence, the\n     * binding with the highest selector specificity is executed first. A\n     * tie is broken by using the most recently added key binding.\n     *\n     * Ambiguous key bindings are resolved with a timeout. As an example,\n     * suppose two key bindings are registered: one with the key sequence\n     * `['Ctrl D']`, and another with `['Ctrl D', 'Ctrl W']`. If the user\n     * presses `Ctrl D`, the first binding cannot be immediately executed\n     * since the user may intend to complete the chord with `Ctrl W`. For\n     * such cases, a timer is used to allow the chord to be completed. If\n     * the chord is not completed before the timeout, the first binding\n     * is executed.\n     */\n    addKeyBinding(options) {\n        // Create the binding for the given options.\n        let binding = Private.createKeyBinding(options);\n        // Add the key binding to the bindings array.\n        this._keyBindings.push(binding);\n        // Emit the `bindingChanged` signal.\n        this._keyBindingChanged.emit({ binding, type: 'added' });\n        // Return a disposable which will remove the binding.\n        return new DisposableDelegate(() => {\n            // Remove the binding from the array.\n            ArrayExt.removeFirstOf(this._keyBindings, binding);\n            // Emit the `bindingChanged` signal.\n            this._keyBindingChanged.emit({ binding, type: 'removed' });\n        });\n    }\n    /**\n     * Process a `'keydown'` event and invoke a matching key binding.\n     *\n     * @param event - The event object for a `'keydown'` event.\n     *\n     * #### Notes\n     * This should be called in response to a `'keydown'` event in order\n     * to invoke the command for the best matching key binding.\n     *\n     * The registry **does not** install its own listener for `'keydown'`\n     * events. This allows the application full control over the nodes\n     * and phase for which the registry processes `'keydown'` events.\n     *\n     * When the keydown event is processed, if the event target or any of its\n     * ancestor nodes has a `data-lm-suppress-shortcuts` attribute, its keydown\n     * events will not invoke commands.\n     */\n    processKeydownEvent(event) {\n        // Bail immediately if playing back keystrokes.\n        if (event.defaultPrevented || this._replaying) {\n            return;\n        }\n        // Get the normalized keystroke for the event.\n        const keystroke = CommandRegistry.keystrokeForKeydownEvent(event);\n        // If the keystroke is not valid for the keyboard layout, replay\n        // any suppressed events and clear the pending state.\n        if (!keystroke) {\n            this._replayKeydownEvents();\n            this._clearPendingState();\n            return;\n        }\n        // Check that only mod key(s) have been pressed.\n        if (CommandRegistry.isModifierKeyPressed(event)) {\n            // Find the exact match for the modifier keys.\n            let { exact } = Private.matchKeyBinding(this._keyBindings, [keystroke], event);\n            if (exact) {\n                // If the mod keys match an exact shortcut, start a dedicated timer.\n                event.preventDefault();\n                event.stopPropagation();\n                this._startModifierTimer(exact);\n            }\n            else {\n                // Otherwise stop potential existing timer.\n                this._clearModifierTimer();\n            }\n            return;\n        }\n        // Add the keystroke to the current key sequence.\n        this._keystrokes.push(keystroke);\n        // Find the exact and partial matches for the key sequence.\n        const { exact, partial } = Private.matchKeyBinding(this._keyBindings, this._keystrokes, event);\n        // Whether there is any partial match.\n        const hasPartial = partial.length !== 0;\n        // If there is no exact match and no partial match, replay\n        // any suppressed events and clear the pending state.\n        if (!exact && !hasPartial) {\n            this._replayKeydownEvents();\n            this._clearPendingState();\n            return;\n        }\n        // Stop propagation of the event. If there is only a partial match,\n        // the event will be replayed if a final exact match never occurs.\n        if ((exact === null || exact === void 0 ? void 0 : exact.preventDefault) || partial.some(match => match.preventDefault)) {\n            event.preventDefault();\n            event.stopPropagation();\n        }\n        // Store the event for possible playback in the future and for\n        // the use in execution hold check.\n        this._keydownEvents.push(event);\n        // If there is an exact match but no partial match, the exact match\n        // can be dispatched immediately. The pending state is cleared so\n        // the next key press starts from the default state.\n        if (exact && !hasPartial) {\n            this._executeKeyBinding(exact);\n            this._clearPendingState();\n            return;\n        }\n        // If there is both an exact match and a partial match, the exact\n        // match is stored for future dispatch in case the timer expires\n        // before a more specific match is triggered.\n        if (exact) {\n            this._exactKeyMatch = exact;\n        }\n        // (Re)start the timer to dispatch the most recent exact match\n        // in case the partial match fails to result in an exact match.\n        this._startTimer();\n    }\n    /**\n     * Delay the execution of any command matched against the given 'keydown' event\n     * until the `permission` to execute is granted.\n     *\n     * @param event - The event object for a `'keydown'` event.\n     * @param permission - The promise with value indicating whether to proceed with the execution.\n     *\n     * ### Note\n     * This enables the caller of `processKeydownEvent` to asynchronously prevent the\n     * execution of the command based on external events.\n     */\n    holdKeyBindingExecution(event, permission) {\n        this._holdKeyBindingPromises.set(event, permission);\n    }\n    /**\n     * Process a ``keyup`` event to clear the timer on the modifier, if it exists.\n     *\n     * @param event - The event object for a `'keydown'` event.\n     */\n    processKeyupEvent(event) {\n        this._clearModifierTimer();\n    }\n    /**\n     * Start or restart the timeout on the modifier keys.\n     *\n     * This timeout will end only if the keys are hold.\n     */\n    _startModifierTimer(exact) {\n        this._clearModifierTimer();\n        this._timerModifierID = window.setTimeout(() => {\n            this._executeKeyBinding(exact);\n        }, Private.modifierkeyTimeOut);\n    }\n    /**\n     * Clear the timeout on modifier keys.\n     */\n    _clearModifierTimer() {\n        if (this._timerModifierID !== 0) {\n            clearTimeout(this._timerModifierID);\n            this._timerModifierID = 0;\n        }\n    }\n    /**\n     * Start or restart the pending timeout.\n     */\n    _startTimer() {\n        this._clearTimer();\n        this._timerID = window.setTimeout(() => {\n            this._onPendingTimeout();\n        }, Private.CHORD_TIMEOUT);\n    }\n    /**\n     * Clear the pending timeout.\n     */\n    _clearTimer() {\n        if (this._timerID !== 0) {\n            clearTimeout(this._timerID);\n            this._timerID = 0;\n        }\n    }\n    /**\n     * Replay the keydown events which were suppressed.\n     */\n    _replayKeydownEvents() {\n        if (this._keydownEvents.length === 0) {\n            return;\n        }\n        this._replaying = true;\n        this._keydownEvents.forEach(Private.replayKeyEvent);\n        this._replaying = false;\n    }\n    /**\n     * Execute the command for the given key binding.\n     *\n     * If the command is missing or disabled, a warning will be logged.\n     *\n     * The execution will not proceed if any of the events leading to\n     * the keybinding matching were held with the permission resolving to false.\n     */\n    async _executeKeyBinding(binding) {\n        if (this._holdKeyBindingPromises.size !== 0) {\n            // Copy keydown events list to ensure it is available in async code.\n            const keydownEvents = [...this._keydownEvents];\n            // Wait until all hold requests on execution are lifted.\n            const executionAllowed = (await Promise.race([\n                Promise.all(keydownEvents.map(async (event) => { var _a; return (_a = this._holdKeyBindingPromises.get(event)) !== null && _a !== void 0 ? _a : Promise.resolve(true); })),\n                new Promise(resolve => {\n                    setTimeout(() => resolve([false]), Private.KEYBINDING_HOLD_TIMEOUT);\n                })\n            ])).every(Boolean);\n            // Clear the hold requests.\n            this._holdKeyBindingPromises.clear();\n            // Do not proceed with the execution if any of the hold requests did not get the permission to proceed.\n            if (!executionAllowed) {\n                return;\n            }\n        }\n        let { command, args } = binding;\n        let newArgs = {\n            _luminoEvent: { type: 'keybinding', keys: binding.keys },\n            ...args\n        };\n        if (!this.hasCommand(command) || !this.isEnabled(command, newArgs)) {\n            let word = this.hasCommand(command) ? 'enabled' : 'registered';\n            let keys = binding.keys.join(', ');\n            let msg1 = `Cannot execute key binding '${keys}':`;\n            let msg2 = `command '${command}' is not ${word}.`;\n            console.warn(`${msg1} ${msg2}`);\n            return;\n        }\n        await this.execute(command, newArgs);\n    }\n    /**\n     * Clear the internal pending state.\n     */\n    _clearPendingState() {\n        this._clearTimer();\n        this._clearModifierTimer();\n        this._exactKeyMatch = null;\n        this._keystrokes.length = 0;\n        this._keydownEvents.length = 0;\n    }\n    /**\n     * Handle the partial match timeout.\n     */\n    _onPendingTimeout() {\n        this._timerID = 0;\n        if (this._exactKeyMatch) {\n            this._executeKeyBinding(this._exactKeyMatch);\n        }\n        else {\n            this._replayKeydownEvents();\n        }\n        this._clearPendingState();\n    }\n}\n/**\n * The namespace for the `CommandRegistry` class statics.\n */\n(function (CommandRegistry) {\n    /**\n     * Parse a keystroke into its constituent components.\n     *\n     * @param keystroke - The keystroke of interest.\n     *\n     * @returns The parsed components of the keystroke.\n     *\n     * #### Notes\n     * The keystroke should be of the form:\n     *   `[<modifier 1> [<modifier 2> [<modifier N> ]]]<primary key>`\n     *\n     * The supported modifiers are: `Accel`, `Alt`, `Cmd`, `Ctrl`, and\n     * `Shift`. The `Accel` modifier is translated to `Cmd` on Mac and\n     * `Ctrl` on all other platforms.\n     *\n     * The parsing is tolerant and will not throw exceptions. Notably:\n     *   - Duplicate modifiers are ignored.\n     *   - Extra primary keys are ignored.\n     *   - The order of modifiers and primary key is irrelevant.\n     *   - The keystroke parts should be separated by whitespace.\n     *   - The keystroke is case sensitive.\n     */\n    function parseKeystroke(keystroke) {\n        let key = '';\n        let alt = false;\n        let cmd = false;\n        let ctrl = false;\n        let shift = false;\n        for (let token of keystroke.split(/\\s+/)) {\n            if (token === 'Accel') {\n                if (Platform.IS_MAC) {\n                    cmd = true;\n                }\n                else {\n                    ctrl = true;\n                }\n            }\n            else if (token === 'Alt') {\n                alt = true;\n            }\n            else if (token === 'Cmd') {\n                cmd = true;\n            }\n            else if (token === 'Ctrl') {\n                ctrl = true;\n            }\n            else if (token === 'Shift') {\n                shift = true;\n            }\n            else if (token.length > 0) {\n                key = token;\n            }\n        }\n        return { cmd, ctrl, alt, shift, key };\n    }\n    CommandRegistry.parseKeystroke = parseKeystroke;\n    /**\n     * Normalize a keystroke into a canonical representation.\n     *\n     * @param keystroke - The keystroke of interest.\n     *\n     * @returns The normalized representation of the keystroke.\n     *\n     * #### Notes\n     * This normalizes the keystroke by removing duplicate modifiers and\n     * extra primary keys, and assembling the parts in a canonical order.\n     *\n     * The `Cmd` modifier is ignored on non-Mac platforms.\n     */\n    function normalizeKeystroke(keystroke) {\n        let mods = '';\n        let parts = parseKeystroke(keystroke);\n        if (parts.ctrl) {\n            mods += 'Ctrl ';\n        }\n        if (parts.alt) {\n            mods += 'Alt ';\n        }\n        if (parts.shift) {\n            mods += 'Shift ';\n        }\n        if (parts.cmd && Platform.IS_MAC) {\n            mods += 'Cmd ';\n        }\n        if (!parts.key) {\n            return mods.trim();\n        }\n        return mods + parts.key;\n    }\n    CommandRegistry.normalizeKeystroke = normalizeKeystroke;\n    /**\n     * Get the platform-specific normalized keys for an options object.\n     *\n     * @param options - The options for the key binding.\n     *\n     * @returns Array of combined, normalized keys.\n     */\n    function normalizeKeys(options) {\n        let keys;\n        if (Platform.IS_WIN) {\n            keys = options.winKeys || options.keys;\n        }\n        else if (Platform.IS_MAC) {\n            keys = options.macKeys || options.keys;\n        }\n        else {\n            keys = options.linuxKeys || options.keys;\n        }\n        return keys.map(normalizeKeystroke);\n    }\n    CommandRegistry.normalizeKeys = normalizeKeys;\n    /**\n     * Format keystrokes for display on the local system.\n     *\n     * If a list of keystrokes is provided, it will be displayed as\n     * a comma-separated string\n     *\n     * @param keystroke The keystrokes to format\n     * @returns The keystrokes representation\n     */\n    function formatKeystroke(keystroke) {\n        return typeof keystroke === 'string'\n            ? formatSingleKey(keystroke)\n            : keystroke.map(formatSingleKey).join(', ');\n        function formatSingleKey(key) {\n            let mods = [];\n            let separator = Platform.IS_MAC ? ' ' : '+';\n            let parts = parseKeystroke(key);\n            if (parts.ctrl) {\n                mods.push('Ctrl');\n            }\n            if (parts.alt) {\n                mods.push('Alt');\n            }\n            if (parts.shift) {\n                mods.push('Shift');\n            }\n            if (Platform.IS_MAC && parts.cmd) {\n                mods.push('Cmd');\n            }\n            mods.push(parts.key);\n            return mods.map(Private.formatKey).join(separator);\n        }\n    }\n    CommandRegistry.formatKeystroke = formatKeystroke;\n    /**\n     * Check if `'keydown'` event is caused by pressing a modifier key that should be ignored.\n     *\n     * @param event - The event object for a `'keydown'` event.\n     *\n     * @returns `true` if modifier key was pressed, `false` otherwise.\n     */\n    function isModifierKeyPressed(event) {\n        let layout = getKeyboardLayout();\n        let key = layout.keyForKeydownEvent(event);\n        return layout.isModifierKey(key);\n    }\n    CommandRegistry.isModifierKeyPressed = isModifierKeyPressed;\n    /**\n     * Create a normalized keystroke for a `'keydown'` event.\n     *\n     * @param event - The event object for a `'keydown'` event.\n     *\n     * @returns A normalized keystroke, or an empty string if the event\n     *   does not represent a valid keystroke for the given layout.\n     */\n    function keystrokeForKeydownEvent(event) {\n        let layout = getKeyboardLayout();\n        let key = layout.keyForKeydownEvent(event);\n        let mods = [];\n        if (event.ctrlKey) {\n            mods.push('Ctrl');\n        }\n        if (event.altKey) {\n            mods.push('Alt');\n        }\n        if (event.shiftKey) {\n            mods.push('Shift');\n        }\n        if (event.metaKey && Platform.IS_MAC) {\n            mods.push('Cmd');\n        }\n        if (!layout.isModifierKey(key)) {\n            mods.push(key);\n        }\n        // for purely modifier key strings\n        return mods.join(' ');\n    }\n    CommandRegistry.keystrokeForKeydownEvent = keystrokeForKeydownEvent;\n})(CommandRegistry || (CommandRegistry = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * The timeout in ms for triggering a key binding chord.\n     */\n    Private.CHORD_TIMEOUT = 1000;\n    /**\n     * The timeout in ms for stopping the hold on keybinding execution.\n     */\n    Private.KEYBINDING_HOLD_TIMEOUT = 1000;\n    /**\n     * The timeout in ms for triggering a modifer key binding.\n     */\n    Private.modifierkeyTimeOut = 500;\n    /**\n     * Create a normalized command from an options object.\n     */\n    function createCommand(options) {\n        return {\n            execute: options.execute,\n            describedBy: asFunc(typeof options.describedBy === 'function'\n                ? options.describedBy\n                : { args: null, ...options.describedBy }, () => {\n                return { args: null };\n            }),\n            label: asFunc(options.label, emptyStringFunc),\n            mnemonic: asFunc(options.mnemonic, negativeOneFunc),\n            icon: asFunc(options.icon, undefinedFunc),\n            iconClass: asFunc(options.iconClass, emptyStringFunc),\n            iconLabel: asFunc(options.iconLabel, emptyStringFunc),\n            caption: asFunc(options.caption, emptyStringFunc),\n            usage: asFunc(options.usage, emptyStringFunc),\n            className: asFunc(options.className, emptyStringFunc),\n            dataset: asFunc(options.dataset, emptyDatasetFunc),\n            isEnabled: options.isEnabled || trueFunc,\n            isToggled: options.isToggled || falseFunc,\n            isToggleable: options.isToggleable || !!options.isToggled,\n            isVisible: options.isVisible || trueFunc\n        };\n    }\n    Private.createCommand = createCommand;\n    /**\n     * Create a key binding object from key binding options.\n     */\n    function createKeyBinding(options) {\n        var _a;\n        return {\n            keys: CommandRegistry.normalizeKeys(options),\n            selector: validateSelector(options),\n            command: options.command,\n            args: options.args || JSONExt.emptyObject,\n            preventDefault: (_a = options.preventDefault) !== null && _a !== void 0 ? _a : true\n        };\n    }\n    Private.createKeyBinding = createKeyBinding;\n    /**\n     * Find the key bindings which match a key sequence.\n     *\n     * This returns a match result which contains the best exact matching\n     * binding, and a flag which indicates if there are partial matches.\n     */\n    function matchKeyBinding(bindings, keys, event) {\n        // The current best exact match.\n        let exact = null;\n        // Partial matches.\n        let partial = [];\n        // The match distance for the exact match.\n        let distance = Infinity;\n        // The specificity for the exact match.\n        let specificity = 0;\n        // Iterate over the bindings and search for the best match.\n        for (let i = 0, n = bindings.length; i < n; ++i) {\n            // Lookup the current binding.\n            let binding = bindings[i];\n            // Check whether the key binding sequence is a match.\n            let sqm = matchSequence(binding.keys, keys);\n            // If there is no match, the binding is ignored.\n            if (sqm === 0 /* SequenceMatch.None */) {\n                continue;\n            }\n            // If it is a partial match and no other partial match has been\n            // found, ensure the selector matches and set the partial flag.\n            if (sqm === 2 /* SequenceMatch.Partial */) {\n                if (targetDistance(binding.selector, event) !== -1) {\n                    partial.push(binding);\n                }\n                continue;\n            }\n            // Ignore the match if the selector doesn't match, or if the\n            // matched node is farther away than the current best match.\n            let td = targetDistance(binding.selector, event);\n            if (td === -1 || td > distance) {\n                continue;\n            }\n            // Get the specificity for the selector.\n            let sp = Selector.calculateSpecificity(binding.selector);\n            // Update the best match if this match is stronger.\n            if (!exact || td < distance || sp >= specificity) {\n                exact = binding;\n                distance = td;\n                specificity = sp;\n            }\n        }\n        // Return the match result.\n        return { exact, partial };\n    }\n    Private.matchKeyBinding = matchKeyBinding;\n    /**\n     * Replay a keyboard event.\n     *\n     * This synthetically dispatches a clone of the keyboard event.\n     */\n    function replayKeyEvent(event) {\n        event.target.dispatchEvent(cloneKeyboardEvent(event));\n    }\n    Private.replayKeyEvent = replayKeyEvent;\n    function formatKey(key) {\n        if (Platform.IS_MAC) {\n            return MAC_DISPLAY.hasOwnProperty(key) ? MAC_DISPLAY[key] : key;\n        }\n        else {\n            return WIN_DISPLAY.hasOwnProperty(key) ? WIN_DISPLAY[key] : key;\n        }\n    }\n    Private.formatKey = formatKey;\n    const MAC_DISPLAY = {\n        Backspace: '⌫',\n        Tab: '⇥',\n        Enter: '⏎',\n        Shift: '⇧',\n        Ctrl: '⌃',\n        Alt: '⌥',\n        Escape: '⎋',\n        PageUp: '⇞',\n        PageDown: '⇟',\n        End: '↘',\n        Home: '↖',\n        ArrowLeft: '←',\n        ArrowUp: '↑',\n        ArrowRight: '→',\n        ArrowDown: '↓',\n        Delete: '⌦',\n        Cmd: '⌘'\n    };\n    const WIN_DISPLAY = {\n        Escape: 'Esc',\n        PageUp: 'Page Up',\n        PageDown: 'Page Down',\n        ArrowLeft: 'Left',\n        ArrowUp: 'Up',\n        ArrowRight: 'Right',\n        ArrowDown: 'Down',\n        Delete: 'Del'\n    };\n    /**\n     * A singleton empty string function.\n     */\n    const emptyStringFunc = () => '';\n    /**\n     * A singleton `-1` number function\n     */\n    const negativeOneFunc = () => -1;\n    /**\n     * A singleton true boolean function.\n     */\n    const trueFunc = () => true;\n    /**\n     * A singleton false boolean function.\n     */\n    const falseFunc = () => false;\n    /**\n     * A singleton empty dataset function.\n     */\n    const emptyDatasetFunc = () => ({});\n    /**\n     * A singleton undefined function\n     */\n    const undefinedFunc = () => undefined;\n    /**\n     * Cast a value or command func to a command func.\n     */\n    function asFunc(value, dfault) {\n        if (value === undefined) {\n            return dfault;\n        }\n        if (typeof value === 'function') {\n            return value;\n        }\n        return () => value;\n    }\n    /**\n     * Validate the selector for an options object.\n     *\n     * This returns the validated selector, or throws if the selector is\n     * invalid or contains commas.\n     */\n    function validateSelector(options) {\n        if (options.selector.indexOf(',') !== -1) {\n            throw new Error(`Selector cannot contain commas: ${options.selector}`);\n        }\n        if (!Selector.isValid(options.selector)) {\n            throw new Error(`Invalid selector: ${options.selector}`);\n        }\n        return options.selector;\n    }\n    /**\n     * Test whether a key binding sequence matches a key sequence.\n     *\n     * Returns a `SequenceMatch` value indicating the type of match.\n     */\n    function matchSequence(bindKeys, userKeys) {\n        if (bindKeys.length < userKeys.length) {\n            return 0 /* SequenceMatch.None */;\n        }\n        for (let i = 0, n = userKeys.length; i < n; ++i) {\n            if (bindKeys[i] !== userKeys[i]) {\n                return 0 /* SequenceMatch.None */;\n            }\n        }\n        if (bindKeys.length > userKeys.length) {\n            return 2 /* SequenceMatch.Partial */;\n        }\n        return 1 /* SequenceMatch.Exact */;\n    }\n    /**\n     * Find the distance from the target node to the first matching node.\n     *\n     * This traverses the event path from `target` to `currentTarget` and\n     * computes the distance from `target` to the first node which matches\n     * the CSS selector. If no match is found, `-1` is returned.\n     */\n    function targetDistance(selector, event) {\n        let targ = event.target;\n        let curr = event.currentTarget;\n        for (let dist = 0; targ !== null; targ = targ.parentElement, ++dist) {\n            if (targ.hasAttribute('data-lm-suppress-shortcuts')) {\n                return -1;\n            }\n            if (Selector.matches(targ, selector)) {\n                return dist;\n            }\n            if (targ === curr) {\n                return -1;\n            }\n        }\n        return -1;\n    }\n    /**\n     * Clone a keyboard event.\n     */\n    function cloneKeyboardEvent(event) {\n        // A custom event is required because Chrome nulls out the\n        // `keyCode` field in user-generated `KeyboardEvent` types.\n        let clone = document.createEvent('Event');\n        let bubbles = event.bubbles || true;\n        let cancelable = event.cancelable || true;\n        clone.initEvent(event.type || 'keydown', bubbles, cancelable);\n        clone.key = event.key || '';\n        clone.keyCode = event.keyCode || 0;\n        clone.which = event.keyCode || 0;\n        clone.ctrlKey = event.ctrlKey || false;\n        clone.altKey = event.altKey || false;\n        clone.shiftKey = event.shiftKey || false;\n        clone.metaKey = event.metaKey || false;\n        clone.view = event.view || window;\n        return clone;\n    }\n})(Private || (Private = {}));\n\nexport { CommandRegistry };\n//# sourceMappingURL=index.es6.js.map\n","/**\n * A generic doubly-linked list.\n */\nclass LinkedList {\n    constructor() {\n        this._first = null;\n        this._last = null;\n        this._size = 0;\n    }\n    /**\n     * Whether the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    get isEmpty() {\n        return this._size === 0;\n    }\n    /**\n     * The size of the list.\n     *\n     * #### Complexity\n     * `O(1)`\n     *\n     * #### Notes\n     * This is equivalent to `length`.\n     */\n    get size() {\n        return this._size;\n    }\n    /**\n     * The length of the list.\n     *\n     * #### Complexity\n     * Constant.\n     *\n     * #### Notes\n     * This is equivalent to `size`.\n     *\n     * This property is deprecated.\n     */\n    get length() {\n        return this._size;\n    }\n    /**\n     * The first value in the list.\n     *\n     * This is `undefined` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    get first() {\n        return this._first ? this._first.value : undefined;\n    }\n    /**\n     * The last value in the list.\n     *\n     * This is `undefined` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    get last() {\n        return this._last ? this._last.value : undefined;\n    }\n    /**\n     * The first node in the list.\n     *\n     * This is `null` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    get firstNode() {\n        return this._first;\n    }\n    /**\n     * The last node in the list.\n     *\n     * This is `null` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    get lastNode() {\n        return this._last;\n    }\n    /**\n     * Create an iterator over the values in the list.\n     *\n     * @returns A new iterator starting with the first value.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    *[Symbol.iterator]() {\n        let node = this._first;\n        while (node) {\n            yield node.value;\n            node = node.next;\n        }\n    }\n    /**\n     * Create a reverse iterator over the values in the list.\n     *\n     * @returns A new iterator starting with the last value.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    *retro() {\n        let node = this._last;\n        while (node) {\n            yield node.value;\n            node = node.prev;\n        }\n    }\n    /**\n     * Create an iterator over the nodes in the list.\n     *\n     * @returns A new iterator starting with the first node.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    *nodes() {\n        let node = this._first;\n        while (node) {\n            yield node;\n            node = node.next;\n        }\n    }\n    /**\n     * Create a reverse iterator over the nodes in the list.\n     *\n     * @returns A new iterator starting with the last node.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    *retroNodes() {\n        let node = this._last;\n        while (node) {\n            yield node;\n            node = node.prev;\n        }\n    }\n    /**\n     * Assign new values to the list, replacing all current values.\n     *\n     * @param values - The values to assign to the list.\n     *\n     * #### Complexity\n     * Linear.\n     */\n    assign(values) {\n        this.clear();\n        for (const value of values) {\n            this.addLast(value);\n        }\n    }\n    /**\n     * Add a value to the end of the list.\n     *\n     * @param value - The value to add to the end of the list.\n     *\n     * #### Complexity\n     * Constant.\n     *\n     * #### Notes\n     * This is equivalent to `addLast`.\n     */\n    push(value) {\n        this.addLast(value);\n    }\n    /**\n     * Remove and return the value at the end of the list.\n     *\n     * @returns The removed value, or `undefined` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     *\n     * #### Notes\n     * This is equivalent to `removeLast`.\n     */\n    pop() {\n        return this.removeLast();\n    }\n    /**\n     * Add a value to the beginning of the list.\n     *\n     * @param value - The value to add to the beginning of the list.\n     *\n     * #### Complexity\n     * Constant.\n     *\n     * #### Notes\n     * This is equivalent to `addFirst`.\n     */\n    shift(value) {\n        this.addFirst(value);\n    }\n    /**\n     * Remove and return the value at the beginning of the list.\n     *\n     * @returns The removed value, or `undefined` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     *\n     * #### Notes\n     * This is equivalent to `removeFirst`.\n     */\n    unshift() {\n        return this.removeFirst();\n    }\n    /**\n     * Add a value to the beginning of the list.\n     *\n     * @param value - The value to add to the beginning of the list.\n     *\n     * @returns The list node which holds the value.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    addFirst(value) {\n        let node = new Private.LinkedListNode(this, value);\n        if (!this._first) {\n            this._first = node;\n            this._last = node;\n        }\n        else {\n            node.next = this._first;\n            this._first.prev = node;\n            this._first = node;\n        }\n        this._size++;\n        return node;\n    }\n    /**\n     * Add a value to the end of the list.\n     *\n     * @param value - The value to add to the end of the list.\n     *\n     * @returns The list node which holds the value.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    addLast(value) {\n        let node = new Private.LinkedListNode(this, value);\n        if (!this._last) {\n            this._first = node;\n            this._last = node;\n        }\n        else {\n            node.prev = this._last;\n            this._last.next = node;\n            this._last = node;\n        }\n        this._size++;\n        return node;\n    }\n    /**\n     * Insert a value before a specific node in the list.\n     *\n     * @param value - The value to insert before the reference node.\n     *\n     * @param ref - The reference node of interest. If this is `null`,\n     *   the value will be added to the beginning of the list.\n     *\n     * @returns The list node which holds the value.\n     *\n     * #### Notes\n     * The reference node must be owned by the list.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    insertBefore(value, ref) {\n        if (!ref || ref === this._first) {\n            return this.addFirst(value);\n        }\n        if (!(ref instanceof Private.LinkedListNode) || ref.list !== this) {\n            throw new Error('Reference node is not owned by the list.');\n        }\n        let node = new Private.LinkedListNode(this, value);\n        let _ref = ref;\n        let prev = _ref.prev;\n        node.next = _ref;\n        node.prev = prev;\n        _ref.prev = node;\n        prev.next = node;\n        this._size++;\n        return node;\n    }\n    /**\n     * Insert a value after a specific node in the list.\n     *\n     * @param value - The value to insert after the reference node.\n     *\n     * @param ref - The reference node of interest. If this is `null`,\n     *   the value will be added to the end of the list.\n     *\n     * @returns The list node which holds the value.\n     *\n     * #### Notes\n     * The reference node must be owned by the list.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    insertAfter(value, ref) {\n        if (!ref || ref === this._last) {\n            return this.addLast(value);\n        }\n        if (!(ref instanceof Private.LinkedListNode) || ref.list !== this) {\n            throw new Error('Reference node is not owned by the list.');\n        }\n        let node = new Private.LinkedListNode(this, value);\n        let _ref = ref;\n        let next = _ref.next;\n        node.next = next;\n        node.prev = _ref;\n        _ref.next = node;\n        next.prev = node;\n        this._size++;\n        return node;\n    }\n    /**\n     * Remove and return the value at the beginning of the list.\n     *\n     * @returns The removed value, or `undefined` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    removeFirst() {\n        let node = this._first;\n        if (!node) {\n            return undefined;\n        }\n        if (node === this._last) {\n            this._first = null;\n            this._last = null;\n        }\n        else {\n            this._first = node.next;\n            this._first.prev = null;\n        }\n        node.list = null;\n        node.next = null;\n        node.prev = null;\n        this._size--;\n        return node.value;\n    }\n    /**\n     * Remove and return the value at the end of the list.\n     *\n     * @returns The removed value, or `undefined` if the list is empty.\n     *\n     * #### Complexity\n     * Constant.\n     */\n    removeLast() {\n        let node = this._last;\n        if (!node) {\n            return undefined;\n        }\n        if (node === this._first) {\n            this._first = null;\n            this._last = null;\n        }\n        else {\n            this._last = node.prev;\n            this._last.next = null;\n        }\n        node.list = null;\n        node.next = null;\n        node.prev = null;\n        this._size--;\n        return node.value;\n    }\n    /**\n     * Remove a specific node from the list.\n     *\n     * @param node - The node to remove from the list.\n     *\n     * #### Complexity\n     * Constant.\n     *\n     * #### Notes\n     * The node must be owned by the list.\n     */\n    removeNode(node) {\n        if (!(node instanceof Private.LinkedListNode) || node.list !== this) {\n            throw new Error('Node is not owned by the list.');\n        }\n        let _node = node;\n        if (_node === this._first && _node === this._last) {\n            this._first = null;\n            this._last = null;\n        }\n        else if (_node === this._first) {\n            this._first = _node.next;\n            this._first.prev = null;\n        }\n        else if (_node === this._last) {\n            this._last = _node.prev;\n            this._last.next = null;\n        }\n        else {\n            _node.next.prev = _node.prev;\n            _node.prev.next = _node.next;\n        }\n        _node.list = null;\n        _node.next = null;\n        _node.prev = null;\n        this._size--;\n    }\n    /**\n     * Remove all values from the list.\n     *\n     * #### Complexity\n     * Linear.\n     */\n    clear() {\n        let node = this._first;\n        while (node) {\n            let next = node.next;\n            node.list = null;\n            node.prev = null;\n            node.next = null;\n            node = next;\n        }\n        this._first = null;\n        this._last = null;\n        this._size = 0;\n    }\n}\n/**\n * The namespace for the `LinkedList` class statics.\n */\n(function (LinkedList) {\n    /**\n     * Create a linked list from an iterable of values.\n     *\n     * @param values - The iterable object of interest.\n     *\n     * @returns A new linked list initialized with the given values.\n     *\n     * #### Complexity\n     * Linear.\n     */\n    function from(values) {\n        let list = new LinkedList();\n        list.assign(values);\n        return list;\n    }\n    LinkedList.from = from;\n})(LinkedList || (LinkedList = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * The internal linked list node implementation.\n     */\n    class LinkedListNode {\n        /**\n         * Construct a new linked list node.\n         *\n         * @param list - The list which owns the node.\n         *\n         * @param value - The value for the link.\n         */\n        constructor(list, value) {\n            /**\n             * The linked list which created and owns the node.\n             */\n            this.list = null;\n            /**\n             * The next node in the list.\n             */\n            this.next = null;\n            /**\n             * The previous node in the list.\n             */\n            this.prev = null;\n            this.list = list;\n            this.value = value;\n        }\n    }\n    Private.LinkedListNode = LinkedListNode;\n})(Private || (Private = {}));\n\nexport { LinkedList };\n//# sourceMappingURL=index.es6.js.map\n","import { every, retro, some, ArrayExt } from '@lumino/algorithm';\nimport { LinkedList } from '@lumino/collections';\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 * @packageDocumentation\n * @module messaging\n */\n/**\n * A message which can be delivered to a message handler.\n *\n * #### Notes\n * This class may be subclassed to create complex message types.\n */\nclass Message {\n    /**\n     * Construct a new message.\n     *\n     * @param type - The type of the message.\n     */\n    constructor(type) {\n        this.type = type;\n    }\n    /**\n     * Test whether the message is conflatable.\n     *\n     * #### Notes\n     * Message conflation is an advanced topic. Most message types will\n     * not make use of this feature.\n     *\n     * If a conflatable message is posted to a handler while another\n     * conflatable message of the same `type` has already been posted\n     * to the handler, the `conflate()` method of the existing message\n     * will be invoked. If that method returns `true`, the new message\n     * will not be enqueued. This allows messages to be compressed, so\n     * that only a single instance of the message type is processed per\n     * cycle, no matter how many times messages of that type are posted.\n     *\n     * Custom message types may reimplement this property.\n     *\n     * The default implementation is always `false`.\n     */\n    get isConflatable() {\n        return false;\n    }\n    /**\n     * Conflate this message with another message of the same `type`.\n     *\n     * @param other - A conflatable message of the same `type`.\n     *\n     * @returns `true` if the message was successfully conflated, or\n     *   `false` otherwise.\n     *\n     * #### Notes\n     * Message conflation is an advanced topic. Most message types will\n     * not make use of this feature.\n     *\n     * This method is called automatically by the message loop when the\n     * given message is posted to the handler paired with this message.\n     * This message will already be enqueued and conflatable, and the\n     * given message will have the same `type` and also be conflatable.\n     *\n     * This method should merge the state of the other message into this\n     * message as needed so that when this message is finally delivered\n     * to the handler, it receives the most up-to-date information.\n     *\n     * If this method returns `true`, it signals that the other message\n     * was successfully conflated and that message will not be enqueued.\n     *\n     * If this method returns `false`, the other message will be enqueued\n     * for normal delivery.\n     *\n     * Custom message types may reimplement this method.\n     *\n     * The default implementation always returns `false`.\n     */\n    conflate(other) {\n        return false;\n    }\n}\n/**\n * A convenience message class which conflates automatically.\n *\n * #### Notes\n * Message conflation is an advanced topic. Most user code will not\n * make use of this class.\n *\n * This message class is useful for creating message instances which\n * should be conflated, but which have no state other than `type`.\n *\n * If conflation of stateful messages is required, a custom `Message`\n * subclass should be created.\n */\nclass ConflatableMessage extends Message {\n    /**\n     * Test whether the message is conflatable.\n     *\n     * #### Notes\n     * This property is always `true`.\n     */\n    get isConflatable() {\n        return true;\n    }\n    /**\n     * Conflate this message with another message of the same `type`.\n     *\n     * #### Notes\n     * This method always returns `true`.\n     */\n    conflate(other) {\n        return true;\n    }\n}\n/**\n * The namespace for the global singleton message loop.\n */\nvar MessageLoop;\n(function (MessageLoop) {\n    /**\n     * A function that cancels the pending loop task; `null` if unavailable.\n     */\n    let pending = null;\n    /**\n     * Schedules a function for invocation as soon as possible asynchronously.\n     *\n     * @param fn The function to invoke when called back.\n     *\n     * @returns An anonymous function that will unschedule invocation if possible.\n     */\n    const schedule = (resolved => (fn) => {\n        let rejected = false;\n        resolved.then(() => !rejected && fn());\n        return () => {\n            rejected = true;\n        };\n    })(Promise.resolve());\n    /**\n     * Send a message to a message handler to process immediately.\n     *\n     * @param handler - The handler which should process the message.\n     *\n     * @param msg - The message to deliver to the handler.\n     *\n     * #### Notes\n     * The message will first be sent through any installed message hooks\n     * for the handler. If the message passes all hooks, it will then be\n     * delivered to the `processMessage` method of the handler.\n     *\n     * The message will not be conflated with pending posted messages.\n     *\n     * Exceptions in hooks and handlers will be caught and logged.\n     */\n    function sendMessage(handler, msg) {\n        // Lookup the message hooks for the handler.\n        let hooks = messageHooks.get(handler);\n        // Handle the common case of no installed hooks.\n        if (!hooks || hooks.length === 0) {\n            invokeHandler(handler, msg);\n            return;\n        }\n        // Invoke the message hooks starting with the newest first.\n        let passed = every(retro(hooks), hook => {\n            return hook ? invokeHook(hook, handler, msg) : true;\n        });\n        // Invoke the handler if the message passes all hooks.\n        if (passed) {\n            invokeHandler(handler, msg);\n        }\n    }\n    MessageLoop.sendMessage = sendMessage;\n    /**\n     * Post a message to a message handler to process in the future.\n     *\n     * @param handler - The handler which should process the message.\n     *\n     * @param msg - The message to post to the handler.\n     *\n     * #### Notes\n     * The message will be conflated with the pending posted messages for\n     * the handler, if possible. If the message is not conflated, it will\n     * be queued for normal delivery on the next cycle of the event loop.\n     *\n     * Exceptions in hooks and handlers will be caught and logged.\n     */\n    function postMessage(handler, msg) {\n        // Handle the common case of a non-conflatable message.\n        if (!msg.isConflatable) {\n            enqueueMessage(handler, msg);\n            return;\n        }\n        // Conflate the message with an existing message if possible.\n        let conflated = some(messageQueue, posted => {\n            if (posted.handler !== handler) {\n                return false;\n            }\n            if (!posted.msg) {\n                return false;\n            }\n            if (posted.msg.type !== msg.type) {\n                return false;\n            }\n            if (!posted.msg.isConflatable) {\n                return false;\n            }\n            return posted.msg.conflate(msg);\n        });\n        // Enqueue the message if it was not conflated.\n        if (!conflated) {\n            enqueueMessage(handler, msg);\n        }\n    }\n    MessageLoop.postMessage = postMessage;\n    /**\n     * Install a message hook for a message handler.\n     *\n     * @param handler - The message handler of interest.\n     *\n     * @param hook - The message hook to install.\n     *\n     * #### Notes\n     * A message hook is invoked before a message is delivered to the\n     * handler. If the hook returns `false`, no other hooks will be\n     * invoked and the message will not be delivered to the handler.\n     *\n     * The most recently installed message hook is executed first.\n     *\n     * If the hook is already installed, this is a no-op.\n     */\n    function installMessageHook(handler, hook) {\n        // Look up the hooks for the handler.\n        let hooks = messageHooks.get(handler);\n        // Bail early if the hook is already installed.\n        if (hooks && hooks.indexOf(hook) !== -1) {\n            return;\n        }\n        // Add the hook to the end, so it will be the first to execute.\n        if (!hooks) {\n            messageHooks.set(handler, [hook]);\n        }\n        else {\n            hooks.push(hook);\n        }\n    }\n    MessageLoop.installMessageHook = installMessageHook;\n    /**\n     * Remove an installed message hook for a message handler.\n     *\n     * @param handler - The message handler of interest.\n     *\n     * @param hook - The message hook to remove.\n     *\n     * #### Notes\n     * It is safe to call this function while the hook is executing.\n     *\n     * If the hook is not installed, this is a no-op.\n     */\n    function removeMessageHook(handler, hook) {\n        // Lookup the hooks for the handler.\n        let hooks = messageHooks.get(handler);\n        // Bail early if the hooks do not exist.\n        if (!hooks) {\n            return;\n        }\n        // Lookup the index of the hook and bail if not found.\n        let i = hooks.indexOf(hook);\n        if (i === -1) {\n            return;\n        }\n        // Clear the hook and schedule a cleanup of the array.\n        hooks[i] = null;\n        scheduleCleanup(hooks);\n    }\n    MessageLoop.removeMessageHook = removeMessageHook;\n    /**\n     * Clear all message data associated with a message handler.\n     *\n     * @param handler - The message handler of interest.\n     *\n     * #### Notes\n     * This will clear all posted messages and hooks for the handler.\n     */\n    function clearData(handler) {\n        // Lookup the hooks for the handler.\n        let hooks = messageHooks.get(handler);\n        // Clear all messsage hooks for the handler.\n        if (hooks && hooks.length > 0) {\n            ArrayExt.fill(hooks, null);\n            scheduleCleanup(hooks);\n        }\n        // Clear all posted messages for the handler.\n        for (const posted of messageQueue) {\n            if (posted.handler === handler) {\n                posted.handler = null;\n                posted.msg = null;\n            }\n        }\n    }\n    MessageLoop.clearData = clearData;\n    /**\n     * Process the pending posted messages in the queue immediately.\n     *\n     * #### Notes\n     * This function is useful when posted messages must be processed immediately.\n     *\n     * This function should normally not be needed, but it may be\n     * required to work around certain browser idiosyncrasies.\n     *\n     * Recursing into this function is a no-op.\n     */\n    function flush() {\n        // Bail if recursion is detected or if there is no pending task.\n        if (flushGuard || pending === null) {\n            return;\n        }\n        // Unschedule the pending loop task.\n        pending();\n        pending = null;\n        // Run the message loop within the recursion guard.\n        flushGuard = true;\n        runMessageLoop();\n        flushGuard = false;\n    }\n    MessageLoop.flush = flush;\n    /**\n     * Get the message loop exception handler.\n     *\n     * @returns The current exception handler.\n     *\n     * #### Notes\n     * The default exception handler is `console.error`.\n     */\n    function getExceptionHandler() {\n        return exceptionHandler;\n    }\n    MessageLoop.getExceptionHandler = getExceptionHandler;\n    /**\n     * Set the message loop exception handler.\n     *\n     * @param handler - The function to use as the exception handler.\n     *\n     * @returns The old exception handler.\n     *\n     * #### Notes\n     * The exception handler is invoked when a message handler or a\n     * message hook throws an exception.\n     */\n    function setExceptionHandler(handler) {\n        let old = exceptionHandler;\n        exceptionHandler = handler;\n        return old;\n    }\n    MessageLoop.setExceptionHandler = setExceptionHandler;\n    /**\n     * The queue of posted message pairs.\n     */\n    const messageQueue = new LinkedList();\n    /**\n     * A mapping of handler to array of installed message hooks.\n     */\n    const messageHooks = new WeakMap();\n    /**\n     * A set of message hook arrays which are pending cleanup.\n     */\n    const dirtySet = new Set();\n    /**\n     * The message loop exception handler.\n     */\n    let exceptionHandler = (err) => {\n        console.error(err);\n    };\n    /**\n     * A guard flag to prevent flush recursion.\n     */\n    let flushGuard = false;\n    /**\n     * Invoke a message hook with the specified handler and message.\n     *\n     * Returns the result of the hook, or `true` if the hook throws.\n     *\n     * Exceptions in the hook will be caught and logged.\n     */\n    function invokeHook(hook, handler, msg) {\n        let result = true;\n        try {\n            if (typeof hook === 'function') {\n                result = hook(handler, msg);\n            }\n            else {\n                result = hook.messageHook(handler, msg);\n            }\n        }\n        catch (err) {\n            exceptionHandler(err);\n        }\n        return result;\n    }\n    /**\n     * Invoke a message handler with the specified message.\n     *\n     * Exceptions in the handler will be caught and logged.\n     */\n    function invokeHandler(handler, msg) {\n        try {\n            handler.processMessage(msg);\n        }\n        catch (err) {\n            exceptionHandler(err);\n        }\n    }\n    /**\n     * Add a message to the end of the message queue.\n     *\n     * This will automatically schedule a run of the message loop.\n     */\n    function enqueueMessage(handler, msg) {\n        // Add the posted message to the queue.\n        messageQueue.addLast({ handler, msg });\n        // Bail if a loop task is already pending.\n        if (pending !== null) {\n            return;\n        }\n        // Schedule a run of the message loop.\n        pending = schedule(runMessageLoop);\n    }\n    /**\n     * Run an iteration of the message loop.\n     *\n     * This will process all pending messages in the queue. If a message\n     * is added to the queue while the message loop is running, it will\n     * be processed on the next cycle of the loop.\n     */\n    function runMessageLoop() {\n        // Clear the task so the next loop can be scheduled.\n        pending = null;\n        // If the message queue is empty, there is nothing else to do.\n        if (messageQueue.isEmpty) {\n            return;\n        }\n        // Add a sentinel value to the end of the queue. The queue will\n        // only be processed up to the sentinel. Messages posted during\n        // this cycle will execute on the next cycle.\n        let sentinel = { handler: null, msg: null };\n        messageQueue.addLast(sentinel);\n        // Enter the message loop.\n        // eslint-disable-next-line no-constant-condition\n        while (true) {\n            // Remove the first posted message in the queue.\n            let posted = messageQueue.removeFirst();\n            // If the value is the sentinel, exit the loop.\n            if (posted === sentinel) {\n                return;\n            }\n            // Dispatch the message if it has not been cleared.\n            if (posted.handler && posted.msg) {\n                sendMessage(posted.handler, posted.msg);\n            }\n        }\n    }\n    /**\n     * Schedule a cleanup of a message hooks array.\n     *\n     * This will add the array to the dirty set and schedule a deferred\n     * cleanup of the array contents. On cleanup, any `null` hook will\n     * be removed from the array.\n     */\n    function scheduleCleanup(hooks) {\n        if (dirtySet.size === 0) {\n            schedule(cleanupDirtySet);\n        }\n        dirtySet.add(hooks);\n    }\n    /**\n     * Cleanup the message hook arrays in the dirty set.\n     *\n     * This function should only be invoked asynchronously, when the\n     * stack frame is guaranteed to not be on the path of user code.\n     */\n    function cleanupDirtySet() {\n        dirtySet.forEach(cleanupHooks);\n        dirtySet.clear();\n    }\n    /**\n     * Cleanup the dirty hooks in a message hooks array.\n     *\n     * This will remove any `null` hook from the array.\n     *\n     * This function should only be invoked asynchronously, when the\n     * stack frame is guaranteed to not be on the path of user code.\n     */\n    function cleanupHooks(hooks) {\n        ArrayExt.removeAllWhere(hooks, isNull);\n    }\n    /**\n     * Test whether a value is `null`.\n     */\n    function isNull(value) {\n        return value === null;\n    }\n})(MessageLoop || (MessageLoop = {}));\n\nexport { ConflatableMessage, Message, MessageLoop };\n//# sourceMappingURL=index.es6.js.map\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 * @packageDocumentation\n * @module properties\n */\n/**\n * A class which attaches a value to an external object.\n *\n * #### Notes\n * Attached properties are used to extend the state of an object with\n * semantic data from an unrelated class. They also encapsulate value\n * creation, coercion, and notification.\n *\n * Because attached property values are stored in a hash table, which\n * in turn is stored in a WeakMap keyed on the owner object, there is\n * non-trivial storage overhead involved in their use. The pattern is\n * therefore best used for the storage of rare data.\n */\nclass AttachedProperty {\n    /**\n     * Construct a new attached property.\n     *\n     * @param options - The options for initializing the property.\n     */\n    constructor(options) {\n        this._pid = Private.nextPID();\n        this.name = options.name;\n        this._create = options.create;\n        this._coerce = options.coerce || null;\n        this._compare = options.compare || null;\n        this._changed = options.changed || null;\n    }\n    /**\n     * Get the current value of the property for a given owner.\n     *\n     * @param owner - The property owner of interest.\n     *\n     * @returns The current value of the property.\n     *\n     * #### Notes\n     * If the value has not yet been set, the default value will be\n     * computed and assigned as the current value of the property.\n     */\n    get(owner) {\n        let value;\n        let map = Private.ensureMap(owner);\n        if (this._pid in map) {\n            value = map[this._pid];\n        }\n        else {\n            value = map[this._pid] = this._createValue(owner);\n        }\n        return value;\n    }\n    /**\n     * Set the current value of the property for a given owner.\n     *\n     * @param owner - The property owner of interest.\n     *\n     * @param value - The value for the property.\n     *\n     * #### Notes\n     * If the value has not yet been set, the default value will be\n     * computed and used as the previous value for the comparison.\n     */\n    set(owner, value) {\n        let oldValue;\n        let map = Private.ensureMap(owner);\n        if (this._pid in map) {\n            oldValue = map[this._pid];\n        }\n        else {\n            oldValue = map[this._pid] = this._createValue(owner);\n        }\n        let newValue = this._coerceValue(owner, value);\n        this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));\n    }\n    /**\n     * Explicitly coerce the current property value for a given owner.\n     *\n     * @param owner - The property owner of interest.\n     *\n     * #### Notes\n     * If the value has not yet been set, the default value will be\n     * computed and used as the previous value for the comparison.\n     */\n    coerce(owner) {\n        let oldValue;\n        let map = Private.ensureMap(owner);\n        if (this._pid in map) {\n            oldValue = map[this._pid];\n        }\n        else {\n            oldValue = map[this._pid] = this._createValue(owner);\n        }\n        let newValue = this._coerceValue(owner, oldValue);\n        this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));\n    }\n    /**\n     * Get or create the default value for the given owner.\n     */\n    _createValue(owner) {\n        let create = this._create;\n        return create(owner);\n    }\n    /**\n     * Coerce the value for the given owner.\n     */\n    _coerceValue(owner, value) {\n        let coerce = this._coerce;\n        return coerce ? coerce(owner, value) : value;\n    }\n    /**\n     * Compare the old value and new value for equality.\n     */\n    _compareValue(oldValue, newValue) {\n        let compare = this._compare;\n        return compare ? compare(oldValue, newValue) : oldValue === newValue;\n    }\n    /**\n     * Run the change notification if the given values are different.\n     */\n    _maybeNotify(owner, oldValue, newValue) {\n        let changed = this._changed;\n        if (changed && !this._compareValue(oldValue, newValue)) {\n            changed(owner, oldValue, newValue);\n        }\n    }\n}\n/**\n * The namespace for the `AttachedProperty` class statics.\n */\n(function (AttachedProperty) {\n    /**\n     * Clear the stored property data for the given owner.\n     *\n     * @param owner - The property owner of interest.\n     *\n     * #### Notes\n     * This will clear all property values for the owner, but it will\n     * **not** run the change notification for any of the properties.\n     */\n    function clearData(owner) {\n        Private.ownerData.delete(owner);\n    }\n    AttachedProperty.clearData = clearData;\n})(AttachedProperty || (AttachedProperty = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * A weak mapping of property owner to property map.\n     */\n    Private.ownerData = new WeakMap();\n    /**\n     * A function which computes successive unique property ids.\n     */\n    Private.nextPID = (() => {\n        let id = 0;\n        return () => {\n            let rand = Math.random();\n            let stem = `${rand}`.slice(2);\n            return `pid-${stem}-${id++}`;\n        };\n    })();\n    /**\n     * Lookup the data map for the property owner.\n     *\n     * This will create the map if one does not already exist.\n     */\n    function ensureMap(owner) {\n        let map = Private.ownerData.get(owner);\n        if (map) {\n            return map;\n        }\n        map = Object.create(null);\n        Private.ownerData.set(owner, map);\n        return map;\n    }\n    Private.ensureMap = ensureMap;\n})(Private || (Private = {}));\n\nexport { AttachedProperty };\n//# sourceMappingURL=index.es6.js.map\n","import { DisposableDelegate } from '@lumino/disposable';\n\n/**\n * An object which manages a drag-drop operation.\n *\n * A drag object dispatches four different events to drop targets:\n *\n * - `'lm-dragenter'` - Dispatched when the mouse enters the target\n *   element. This event must be canceled in order to receive any\n *   of the other events.\n *\n * - `'lm-dragover'` - Dispatched when the mouse moves over the drop\n *   target. It must cancel the event and set the `dropAction` to one\n *   of the supported actions in order to receive drop events.\n *\n * - `'lm-dragleave'` - Dispatched when the mouse leaves the target\n *   element. This includes moving the mouse into child elements.\n *\n * - `'lm-drop'`- Dispatched when the mouse is released over the target\n *   element when the target indicates an appropriate drop action. If\n *   the event is canceled, the indicated drop action is returned to\n *   the initiator through the resolved promise.\n *\n * A drag operation can be terminated at any time by pressing `Escape`\n * or by disposing the drag object.\n *\n * A drag object has the ability to automatically scroll a scrollable\n * element when the mouse is hovered near one of its edges. To enable\n * this, add the `data-lm-dragscroll` attribute to any element which\n * the drag object should consider for scrolling.\n *\n * #### Notes\n * This class is designed to be used when dragging and dropping custom\n * data *within* a single application. It is *not* a replacement for\n * the native drag-drop API. Instead, it provides an API which allows\n * drag operations to be initiated programmatically and enables the\n * transfer of arbitrary non-string objects; features which are not\n * possible with the native drag-drop API.\n */\nclass Drag {\n    /**\n     * Construct a new drag object.\n     *\n     * @param options - The options for initializing the drag.\n     */\n    constructor(options) {\n        /**\n         * The scroll loop handler function.\n         */\n        this._onScrollFrame = () => {\n            // Bail early if there is no scroll target.\n            if (!this._scrollTarget) {\n                return;\n            }\n            // Unpack the scroll target.\n            let { element, edge, distance } = this._scrollTarget;\n            // Calculate the scroll delta using nonlinear acceleration.\n            let d = Private.SCROLL_EDGE_SIZE - distance;\n            let f = Math.pow(d / Private.SCROLL_EDGE_SIZE, 2);\n            let s = Math.max(1, Math.round(f * Private.SCROLL_EDGE_SIZE));\n            // Scroll the element in the specified direction.\n            switch (edge) {\n                case 'top':\n                    element.scrollTop -= s;\n                    break;\n                case 'left':\n                    element.scrollLeft -= s;\n                    break;\n                case 'right':\n                    element.scrollLeft += s;\n                    break;\n                case 'bottom':\n                    element.scrollTop += s;\n                    break;\n            }\n            // Request the next cycle of the scroll loop.\n            requestAnimationFrame(this._onScrollFrame);\n        };\n        this._disposed = false;\n        this._dropAction = 'none';\n        this._override = null;\n        this._currentTarget = null;\n        this._currentElement = null;\n        this._promise = null;\n        this._scrollTarget = null;\n        this._resolve = null;\n        this.document = options.document || document;\n        this.mimeData = options.mimeData;\n        this.dragImage = options.dragImage || null;\n        this.proposedAction = options.proposedAction || 'copy';\n        this.supportedActions = options.supportedActions || 'all';\n        this.source = options.source || null;\n    }\n    /**\n     * Dispose of the resources held by the drag object.\n     *\n     * #### Notes\n     * This will cancel the drag operation if it is active.\n     */\n    dispose() {\n        // Do nothing if the drag object is already disposed.\n        if (this._disposed) {\n            return;\n        }\n        this._disposed = true;\n        // If there is a current target, dispatch a drag leave event.\n        if (this._currentTarget) {\n            let event = new PointerEvent('pointerup', {\n                bubbles: true,\n                cancelable: true,\n                clientX: -1,\n                clientY: -1\n            });\n            Private.dispatchDragLeave(this, this._currentTarget, null, event);\n        }\n        // Finalize the drag object with `'none'`.\n        this._finalize('none');\n    }\n    /**\n     * Test whether the drag object is disposed.\n     */\n    get isDisposed() {\n        return this._disposed;\n    }\n    /**\n     * Start the drag operation at the specified client position.\n     *\n     * @param clientX - The client X position for the drag start.\n     *\n     * @param clientY - The client Y position for the drag start.\n     *\n     * @returns A promise which resolves to the result of the drag.\n     *\n     * #### Notes\n     * If the drag has already been started, the promise created by the\n     * first call to `start` is returned.\n     *\n     * If the drag operation has ended, or if the drag object has been\n     * disposed, the returned promise will resolve to `'none'`.\n     *\n     * The drag object will be automatically disposed when drag operation\n     * completes. This means `Drag` objects are for single-use only.\n     *\n     * This method assumes the left mouse button is already held down.\n     */\n    start(clientX, clientY) {\n        // If the drag object is already disposed, resolve to `none`.\n        if (this._disposed) {\n            return Promise.resolve('none');\n        }\n        // If the drag has already been started, return the promise.\n        if (this._promise) {\n            return this._promise;\n        }\n        // Install the document listeners for the drag object.\n        this._addListeners();\n        // Attach the drag image at the specified client position.\n        this._attachDragImage(clientX, clientY);\n        // Create the promise which will be resolved on completion.\n        this._promise = new Promise(resolve => {\n            this._resolve = resolve;\n        });\n        // Trigger a fake move event to kick off the drag operation.\n        let event = new PointerEvent('pointermove', {\n            bubbles: true,\n            cancelable: true,\n            clientX,\n            clientY\n        });\n        document.dispatchEvent(event);\n        // Return the pending promise for the drag operation.\n        return this._promise;\n    }\n    /**\n     * Handle the DOM events for the drag operation.\n     *\n     * @param event - The DOM event sent to the drag object.\n     *\n     * #### Notes\n     * This method implements the DOM `EventListener` interface and is\n     * called in response to events on the document. It should not be\n     * called directly by user code.\n     */\n    handleEvent(event) {\n        switch (event.type) {\n            case 'pointermove':\n                this._evtPointerMove(event);\n                break;\n            case 'pointerup':\n                this._evtPointerUp(event);\n                break;\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            default:\n                // Stop all other events during drag-drop.\n                event.preventDefault();\n                event.stopPropagation();\n                break;\n        }\n    }\n    /**\n     * Move the drag image element to the specified location.\n     *\n     * This is a no-op if there is no drag image element.\n     */\n    moveDragImage(clientX, clientY) {\n        if (!this.dragImage) {\n            return;\n        }\n        let style = this.dragImage.style;\n        style.transform = `translate(${clientX}px, ${clientY}px)`;\n    }\n    /**\n     * Handle the `'pointermove'` event for the drag object.\n     */\n    _evtPointerMove(event) {\n        // Stop all input events during drag-drop.\n        event.preventDefault();\n        event.stopPropagation();\n        // Update the current target node and dispatch enter/leave events.\n        this._updateCurrentTarget(event);\n        // Update the drag scroll element.\n        this._updateDragScroll(event);\n        // Move the drag image to the specified client position. This is\n        // performed *after* dispatching to prevent unnecessary reflows.\n        this.moveDragImage(event.clientX, event.clientY);\n    }\n    /**\n     * Handle the `'pointerup'` event for the drag object.\n     */\n    _evtPointerUp(event) {\n        // Stop all input events during drag-drop.\n        event.preventDefault();\n        event.stopPropagation();\n        // Do nothing if the left button is not released.\n        if (event.button !== 0) {\n            return;\n        }\n        // Update the current target node and dispatch enter/leave events.\n        // This prevents a subtle issue where the DOM mutates under the\n        // cursor after the last move event but before the drop event.\n        this._updateCurrentTarget(event);\n        // If there is no current target, finalize with `'none'`.\n        if (!this._currentTarget) {\n            this._finalize('none');\n            return;\n        }\n        // If the last drop action was `'none'`, dispatch a leave event\n        // to the current target and finalize the drag with `'none'`.\n        if (this._dropAction === 'none') {\n            Private.dispatchDragLeave(this, this._currentTarget, null, event);\n            this._finalize('none');\n            return;\n        }\n        // Dispatch the drop event at the current target and finalize\n        // with the resulting drop action.\n        let action = Private.dispatchDrop(this, this._currentTarget, event);\n        this._finalize(action);\n    }\n    /**\n     * Handle the `'keydown'` event for the drag object.\n     */\n    _evtKeyDown(event) {\n        // Stop all input events during drag-drop.\n        event.preventDefault();\n        event.stopPropagation();\n        // Cancel the drag if `Escape` is pressed.\n        if (event.keyCode === 27) {\n            this.dispose();\n        }\n    }\n    /**\n     * Add the document event listeners for the drag object.\n     */\n    _addListeners() {\n        document.addEventListener('pointerdown', this, true);\n        document.addEventListener('pointermove', this, true);\n        document.addEventListener('pointerup', this, true);\n        document.addEventListener('pointerenter', this, true);\n        document.addEventListener('pointerleave', this, true);\n        document.addEventListener('pointerover', this, true);\n        document.addEventListener('pointerout', this, true);\n        document.addEventListener('keydown', this, true);\n        document.addEventListener('keyup', this, true);\n        document.addEventListener('keypress', this, true);\n        document.addEventListener('contextmenu', this, true);\n    }\n    /**\n     * Remove the document event listeners for the drag object.\n     */\n    _removeListeners() {\n        document.removeEventListener('pointerdown', this, true);\n        document.removeEventListener('pointermove', this, true);\n        document.removeEventListener('pointerup', this, true);\n        document.removeEventListener('pointerenter', this, true);\n        document.removeEventListener('pointerleave', this, true);\n        document.removeEventListener('pointerover', this, true);\n        document.removeEventListener('pointerout', this, true);\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('keyup', this, true);\n        document.removeEventListener('keypress', this, true);\n        document.removeEventListener('contextmenu', this, true);\n    }\n    /**\n     * Update the drag scroll element under the mouse.\n     */\n    _updateDragScroll(event) {\n        // Find the scroll target under the mouse.\n        let target = Private.findScrollTarget(event);\n        // Bail if there is nothing to scroll.\n        if (!this._scrollTarget && !target) {\n            return;\n        }\n        // Start the scroll loop if needed.\n        if (!this._scrollTarget) {\n            setTimeout(this._onScrollFrame, 500);\n        }\n        // Update the scroll target.\n        this._scrollTarget = target;\n    }\n    /**\n     * Update the current target node using the given mouse event.\n     */\n    _updateCurrentTarget(event) {\n        // Fetch common local state.\n        let prevTarget = this._currentTarget;\n        let currTarget = this._currentTarget;\n        let prevElem = this._currentElement;\n        // Find the current indicated element at the given position.\n        let currElem = Private.findElementBehindBackdrop(event, this.document);\n        // Update the current element reference.\n        this._currentElement = currElem;\n        // If the indicated element changes from the previous iteration,\n        // and is different from the current target, dispatch the exit\n        // event to the target.\n        if (currElem !== prevElem && currElem !== currTarget) {\n            Private.dispatchDragExit(this, currTarget, currElem, event);\n        }\n        // If the indicated element changes from the previous iteration,\n        // and is different from the current target, dispatch the enter\n        // event and compute the new target element.\n        if (currElem !== prevElem && currElem !== currTarget) {\n            currTarget = Private.dispatchDragEnter(this, currElem, currTarget, event);\n        }\n        // If the current target element has changed, update the current\n        // target reference and dispatch the leave event to the old target.\n        if (currTarget !== prevTarget) {\n            this._currentTarget = currTarget;\n            Private.dispatchDragLeave(this, prevTarget, currTarget, event);\n        }\n        // Dispatch the drag over event and update the drop action.\n        let action = Private.dispatchDragOver(this, currTarget, event);\n        this._setDropAction(action);\n    }\n    /**\n     * Attach the drag image element at the specified location.\n     *\n     * This is a no-op if there is no drag image element.\n     */\n    _attachDragImage(clientX, clientY) {\n        if (!this.dragImage) {\n            return;\n        }\n        this.dragImage.classList.add('lm-mod-drag-image');\n        let style = this.dragImage.style;\n        style.pointerEvents = 'none';\n        style.position = 'fixed';\n        style.transform = `translate(${clientX}px, ${clientY}px)`;\n        const body = this.document instanceof Document\n            ? this.document.body\n            : this.document.firstElementChild;\n        body.appendChild(this.dragImage);\n    }\n    /**\n     * Detach the drag image element from the DOM.\n     *\n     * This is a no-op if there is no drag image element.\n     */\n    _detachDragImage() {\n        if (!this.dragImage) {\n            return;\n        }\n        let parent = this.dragImage.parentNode;\n        if (!parent) {\n            return;\n        }\n        parent.removeChild(this.dragImage);\n    }\n    /**\n     * Set the internal drop action state and update the drag cursor.\n     */\n    _setDropAction(action) {\n        action = Private.validateAction(action, this.supportedActions);\n        if (this._override && this._dropAction === action) {\n            return;\n        }\n        switch (action) {\n            case 'none':\n                this._dropAction = action;\n                this._override = Drag.overrideCursor('no-drop', this.document);\n                break;\n            case 'copy':\n                this._dropAction = action;\n                this._override = Drag.overrideCursor('copy', this.document);\n                break;\n            case 'link':\n                this._dropAction = action;\n                this._override = Drag.overrideCursor('alias', this.document);\n                break;\n            case 'move':\n                this._dropAction = action;\n                this._override = Drag.overrideCursor('move', this.document);\n                break;\n        }\n    }\n    /**\n     * Finalize the drag operation and resolve the drag promise.\n     */\n    _finalize(action) {\n        // Store the resolve function as a temp variable.\n        let resolve = this._resolve;\n        // Remove the document event listeners.\n        this._removeListeners();\n        // Detach the drag image.\n        this._detachDragImage();\n        // Dispose of the cursor override.\n        if (this._override) {\n            this._override.dispose();\n            this._override = null;\n        }\n        // Clear the mime data.\n        this.mimeData.clear();\n        // Clear the rest of the internal drag state.\n        this._disposed = true;\n        this._dropAction = 'none';\n        this._currentTarget = null;\n        this._currentElement = null;\n        this._scrollTarget = null;\n        this._promise = null;\n        this._resolve = null;\n        // Finally, resolve the promise to the given drop action.\n        if (resolve) {\n            resolve(action);\n        }\n    }\n}\n/**\n * The namespace for the `Drag` class statics.\n */\n(function (Drag) {\n    /**\n     * A custom event used for drag-drop operations.\n     *\n     * #### Notes\n     * In order to receive `'lm-dragover'`, `'lm-dragleave'`, or `'lm-drop'`\n     * events, a drop target must cancel the `'lm-dragenter'` event by\n     * calling the event's `preventDefault()` method.\n     */\n    class Event extends DragEvent {\n        constructor(event, options) {\n            super(options.type, {\n                bubbles: true,\n                cancelable: true,\n                altKey: event.altKey,\n                button: event.button,\n                clientX: event.clientX,\n                clientY: event.clientY,\n                ctrlKey: event.ctrlKey,\n                detail: 0,\n                metaKey: event.metaKey,\n                relatedTarget: options.related,\n                screenX: event.screenX,\n                screenY: event.screenY,\n                shiftKey: event.shiftKey,\n                view: window\n            });\n            const { drag } = options;\n            this.dropAction = 'none';\n            this.mimeData = drag.mimeData;\n            this.proposedAction = drag.proposedAction;\n            this.supportedActions = drag.supportedActions;\n            this.source = drag.source;\n        }\n    }\n    Drag.Event = Event;\n    /**\n     * Override the cursor icon for the entire document.\n     *\n     * @param cursor - The string representing the cursor style.\n     *\n     * @returns A disposable which will clear the override when disposed.\n     *\n     * #### Notes\n     * The most recent call to `overrideCursor` takes precedence.\n     * Disposing an old override has no effect on the current override.\n     *\n     * This utility function is used by the `Drag` class to override the\n     * mouse cursor during a drag-drop operation, but it can also be used\n     * by other classes to fix the cursor icon during normal mouse drags.\n     *\n     * #### Example\n     * ```typescript\n     * import { Drag } from '@lumino/dragdrop';\n     *\n     * // Force the cursor to be 'wait' for the entire document.\n     * let override = Drag.overrideCursor('wait');\n     *\n     * // Clear the override by disposing the return value.\n     * override.dispose();\n     * ```\n     */\n    function overrideCursor(cursor, doc = document) {\n        return Private.overrideCursor(cursor, doc);\n    }\n    Drag.overrideCursor = overrideCursor;\n})(Drag || (Drag = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * The size of a drag scroll edge, in pixels.\n     */\n    Private.SCROLL_EDGE_SIZE = 20;\n    /**\n     * Validate the given action is one of the supported actions.\n     *\n     * Returns the given action or `'none'` if the action is unsupported.\n     */\n    function validateAction(action, supported) {\n        return actionTable[action] & supportedTable[supported] ? action : 'none';\n    }\n    Private.validateAction = validateAction;\n    /**\n     * Find the event target using pointer position if given, or otherwise\n     * the central position of the backdrop.\n     */\n    function findElementBehindBackdrop(event, root = document) {\n        if (event) {\n            // Check if we already cached element for this event.\n            if (lastElementEventSearch && event == lastElementEventSearch.event) {\n                return lastElementEventSearch.element;\n            }\n            Private.cursorBackdrop.style.zIndex = '-1000';\n            const element = root.elementFromPoint(event.clientX, event.clientY);\n            Private.cursorBackdrop.style.zIndex = '';\n            lastElementEventSearch = { event, element };\n            return element;\n        }\n        else {\n            const transform = Private.cursorBackdrop.style.transform;\n            if (lastElementSearch && transform === lastElementSearch.transform) {\n                return lastElementSearch.element;\n            }\n            const bbox = Private.cursorBackdrop.getBoundingClientRect();\n            Private.cursorBackdrop.style.zIndex = '-1000';\n            const element = root.elementFromPoint(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n            Private.cursorBackdrop.style.zIndex = '';\n            lastElementSearch = { transform, element };\n            return element;\n        }\n    }\n    Private.findElementBehindBackdrop = findElementBehindBackdrop;\n    let lastElementEventSearch = null;\n    let lastElementSearch = null;\n    /**\n     * Find the drag scroll target under the mouse, if any.\n     */\n    function findScrollTarget(event) {\n        // Look up the client mouse position.\n        let x = event.clientX;\n        let y = event.clientY;\n        // Get the element under the mouse.\n        let element = findElementBehindBackdrop(event);\n        // Search for a scrollable target based on the mouse position.\n        // The null assert in third clause of for-loop is required due to:\n        // https://github.com/Microsoft/TypeScript/issues/14143\n        for (; element; element = element.parentElement) {\n            // Ignore elements which are not marked as scrollable.\n            if (!element.hasAttribute('data-lm-dragscroll')) {\n                continue;\n            }\n            // Set up the coordinate offsets for the element.\n            let offsetX = 0;\n            let offsetY = 0;\n            if (element === document.body) {\n                offsetX = window.pageXOffset;\n                offsetY = window.pageYOffset;\n            }\n            // Get the element bounds in viewport coordinates.\n            let r = element.getBoundingClientRect();\n            let top = r.top + offsetY;\n            let left = r.left + offsetX;\n            let right = left + r.width;\n            let bottom = top + r.height;\n            // Skip the element if it's not under the mouse.\n            if (x < left || x >= right || y < top || y >= bottom) {\n                continue;\n            }\n            // Compute the distance to each edge.\n            let dl = x - left + 1;\n            let dt = y - top + 1;\n            let dr = right - x;\n            let db = bottom - y;\n            // Find the smallest of the edge distances.\n            let distance = Math.min(dl, dt, dr, db);\n            // Skip the element if the mouse is not within a scroll edge.\n            if (distance > Private.SCROLL_EDGE_SIZE) {\n                continue;\n            }\n            // Set up the edge result variable.\n            let edge;\n            // Find the edge for the computed distance.\n            switch (distance) {\n                case db:\n                    edge = 'bottom';\n                    break;\n                case dt:\n                    edge = 'top';\n                    break;\n                case dr:\n                    edge = 'right';\n                    break;\n                case dl:\n                    edge = 'left';\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n            // Compute how much the element can scroll in width and height.\n            let dsw = element.scrollWidth - element.clientWidth;\n            let dsh = element.scrollHeight - element.clientHeight;\n            // Determine if the element should be scrolled for the edge.\n            let shouldScroll;\n            switch (edge) {\n                case 'top':\n                    shouldScroll = dsh > 0 && element.scrollTop > 0;\n                    break;\n                case 'left':\n                    shouldScroll = dsw > 0 && element.scrollLeft > 0;\n                    break;\n                case 'right':\n                    shouldScroll = dsw > 0 && element.scrollLeft < dsw;\n                    break;\n                case 'bottom':\n                    shouldScroll = dsh > 0 && element.scrollTop < dsh;\n                    break;\n                default:\n                    throw 'unreachable';\n            }\n            // Skip the element if it should not be scrolled.\n            if (!shouldScroll) {\n                continue;\n            }\n            // Return the drag scroll target.\n            return { element, edge, distance };\n        }\n        // No drag scroll target was found.\n        return null;\n    }\n    Private.findScrollTarget = findScrollTarget;\n    /**\n     * Dispatch a drag enter event to the indicated element.\n     *\n     * @param drag - The drag object associated with the action.\n     *\n     * @param currElem - The currently indicated element, or `null`. This\n     *   is the \"immediate user selection\" from the whatwg spec.\n     *\n     * @param currTarget - The current drag target element, or `null`. This\n     *   is the \"current target element\" from the whatwg spec.\n     *\n     * @param event - The mouse event related to the action.\n     *\n     * @returns The element to use as the current drag target. This is the\n     *   \"current target element\" from the whatwg spec, and may be `null`.\n     *\n     * #### Notes\n     * This largely implements the drag enter portion of the whatwg spec:\n     * https://html.spec.whatwg.org/multipage/interaction.html#drag-and-drop-processing-model\n     */\n    function dispatchDragEnter(drag, currElem, currTarget, event) {\n        // If the current element is null, return null as the new target.\n        if (!currElem) {\n            return null;\n        }\n        // Dispatch a drag enter event to the current element.\n        let dragEvent = new Drag.Event(event, {\n            drag,\n            related: currTarget,\n            type: 'lm-dragenter'\n        });\n        let canceled = !currElem.dispatchEvent(dragEvent);\n        // If the event was canceled, use the current element as the new target.\n        if (canceled) {\n            return currElem;\n        }\n        // If the current element is the document body, keep the original target.\n        const body = drag.document instanceof Document\n            ? drag.document.body\n            : drag.document.firstElementChild;\n        if (currElem === body) {\n            return currTarget;\n        }\n        // Dispatch a drag enter event on the document body.\n        dragEvent = new Drag.Event(event, {\n            drag,\n            related: currTarget,\n            type: 'lm-dragenter'\n        });\n        body.dispatchEvent(dragEvent);\n        // Ignore the event cancellation, and use the body as the new target.\n        return body;\n    }\n    Private.dispatchDragEnter = dispatchDragEnter;\n    /**\n     * Dispatch a drag exit event to the indicated element.\n     *\n     * @param drag - The drag object associated with the action.\n     *\n     * @param prevTarget - The previous target element, or `null`. This\n     *   is the previous \"current target element\" from the whatwg spec.\n     *\n     * @param currTarget - The current drag target element, or `null`. This\n     *   is the \"current target element\" from the whatwg spec.\n     *\n     * @param event - The mouse event related to the action.\n     *\n     * #### Notes\n     * This largely implements the drag exit portion of the whatwg spec:\n     * https://html.spec.whatwg.org/multipage/interaction.html#drag-and-drop-processing-model\n     */\n    function dispatchDragExit(drag, prevTarget, currTarget, event) {\n        // If the previous target is null, do nothing.\n        if (!prevTarget) {\n            return;\n        }\n        // Dispatch the drag exit event to the previous target.\n        let dragEvent = new Drag.Event(event, {\n            drag,\n            related: currTarget,\n            type: 'lm-dragexit'\n        });\n        prevTarget.dispatchEvent(dragEvent);\n    }\n    Private.dispatchDragExit = dispatchDragExit;\n    /**\n     * Dispatch a drag leave event to the indicated element.\n     *\n     * @param drag - The drag object associated with the action.\n     *\n     * @param prevTarget - The previous target element, or `null`. This\n     *   is the previous \"current target element\" from the whatwg spec.\n     *\n     * @param currTarget - The current drag target element, or `null`. This\n     *   is the \"current target element\" from the whatwg spec.\n     *\n     * @param event - The mouse event related to the action.\n     *\n     * #### Notes\n     * This largely implements the drag leave portion of the whatwg spec:\n     * https://html.spec.whatwg.org/multipage/interaction.html#drag-and-drop-processing-model\n     */\n    function dispatchDragLeave(drag, prevTarget, currTarget, event) {\n        // If the previous target is null, do nothing.\n        if (!prevTarget) {\n            return;\n        }\n        // Dispatch the drag leave event to the previous target.\n        let dragEvent = new Drag.Event(event, {\n            drag,\n            related: currTarget,\n            type: 'lm-dragleave'\n        });\n        prevTarget.dispatchEvent(dragEvent);\n    }\n    Private.dispatchDragLeave = dispatchDragLeave;\n    /**\n     * Dispatch a drag over event to the indicated element.\n     *\n     * @param drag - The drag object associated with the action.\n     *\n     * @param currTarget - The current drag target element, or `null`. This\n     *   is the \"current target element\" from the whatwg spec.\n     *\n     * @param event - The mouse event related to the action.\n     *\n     * @returns The `DropAction` result of the drag over event.\n     *\n     * #### Notes\n     * This largely implements the drag over portion of the whatwg spec:\n     * https://html.spec.whatwg.org/multipage/interaction.html#drag-and-drop-processing-model\n     */\n    function dispatchDragOver(drag, currTarget, event) {\n        // If there is no current target, the drop action is none.\n        if (!currTarget) {\n            return 'none';\n        }\n        // Dispatch the drag over event to the current target.\n        let dragEvent = new Drag.Event(event, {\n            drag,\n            related: null,\n            type: 'lm-dragover'\n        });\n        let canceled = !currTarget.dispatchEvent(dragEvent);\n        // If the event was canceled, return the drop action result.\n        if (canceled) {\n            return dragEvent.dropAction;\n        }\n        // Otherwise, the effective drop action is none.\n        return 'none';\n    }\n    Private.dispatchDragOver = dispatchDragOver;\n    /**\n     * Dispatch a drop event to the indicated element.\n     *\n     * @param drag - The drag object associated with the action.\n     *\n     * @param currTarget - The current drag target element, or `null`. This\n     *   is the \"current target element\" from the whatwg spec.\n     *\n     * @param event - The mouse event related to the action.\n     *\n     * @returns The `DropAction` result of the drop event.\n     *\n     * #### Notes\n     * This largely implements the drag over portion of the whatwg spec:\n     * https://html.spec.whatwg.org/multipage/interaction.html#drag-and-drop-processing-model\n     */\n    function dispatchDrop(drag, currTarget, event) {\n        // If there is no current target, the drop action is none.\n        if (!currTarget) {\n            return 'none';\n        }\n        // Dispatch the drop event to the current target.\n        let dragEvent = new Drag.Event(event, {\n            drag,\n            related: null,\n            type: 'lm-drop'\n        });\n        let canceled = !currTarget.dispatchEvent(dragEvent);\n        // If the event was canceled, return the drop action result.\n        if (canceled) {\n            return dragEvent.dropAction;\n        }\n        // Otherwise, the effective drop action is none.\n        return 'none';\n    }\n    Private.dispatchDrop = dispatchDrop;\n    /**\n     * A lookup table from drop action to bit value.\n     */\n    const actionTable = {\n        none: 0x0,\n        copy: 0x1,\n        link: 0x2,\n        move: 0x4\n    };\n    /**\n     * A lookup table from supported action to drop action bit mask.\n     */\n    const supportedTable = {\n        none: actionTable['none'],\n        copy: actionTable['copy'],\n        link: actionTable['link'],\n        move: actionTable['move'],\n        'copy-link': actionTable['copy'] | actionTable['link'],\n        'copy-move': actionTable['copy'] | actionTable['move'],\n        'link-move': actionTable['link'] | actionTable['move'],\n        all: actionTable['copy'] | actionTable['link'] | actionTable['move']\n    };\n    /**\n     * Implementation of `Drag.overrideCursor`.\n     */\n    function overrideCursor(cursor, doc = document) {\n        let id = ++overrideCursorID;\n        const body = doc instanceof Document\n            ? doc.body\n            : doc.firstElementChild;\n        if (!Private.cursorBackdrop.isConnected) {\n            // Hide the backdrop until the pointer moves to avoid issues with\n            // native double click detection, used in e.g. datagrid editing.\n            Private.cursorBackdrop.style.transform = 'scale(0)';\n            body.appendChild(Private.cursorBackdrop);\n            resetBackdropScroll();\n            document.addEventListener('pointermove', alignBackdrop, {\n                capture: true,\n                passive: true\n            });\n            Private.cursorBackdrop.addEventListener('scroll', propagateBackdropScroll, {\n                capture: true,\n                passive: true\n            });\n        }\n        Private.cursorBackdrop.style.cursor = cursor;\n        return new DisposableDelegate(() => {\n            if (id === overrideCursorID && Private.cursorBackdrop.isConnected) {\n                document.removeEventListener('pointermove', alignBackdrop, true);\n                Private.cursorBackdrop.removeEventListener('scroll', propagateBackdropScroll, true);\n                // Removing the element from the DOM also releases the pointer capture.\n                body.removeChild(Private.cursorBackdrop);\n            }\n        });\n    }\n    Private.overrideCursor = overrideCursor;\n    /**\n     * Move cursor backdrop to match cursor position.\n     */\n    function alignBackdrop(event) {\n        if (!Private.cursorBackdrop) {\n            return;\n        }\n        Private.cursorBackdrop.style.transform = `translate(${event.clientX}px, ${event.clientY}px)`;\n        // Capture the pointer to the cursor backdrop, ensuring that the cursor\n        // override and any other pointer listeners on the document are respected\n        // even if the pointer drifts over an iframe. When the backdrop element is\n        // removed from the DOM when the override dispose is called, any pointer\n        // capture is released.\n        try {\n            if (!Private.cursorBackdrop.hasPointerCapture(event.pointerId)) {\n                Private.cursorBackdrop.setPointerCapture(event.pointerId);\n            }\n        }\n        catch (e) {\n            // Ignore errors in pointer capture to guard defensively against failures,\n            // e.g., older browsers or synthetic events in tests that don't have\n            // active pointers.\n        }\n    }\n    /**\n     * Propagate the scroll event from the backdrop element to the scroll target.\n     * The scroll target is defined by presence of `data-lm-dragscroll` attribute.\n     */\n    function propagateBackdropScroll(_event) {\n        if (!Private.cursorBackdrop) {\n            return;\n        }\n        // Get the element under behind the centre of the cursor backdrop\n        // (essentially behind the cursor, but possibly a few pixels off).\n        let element = findElementBehindBackdrop();\n        if (!element) {\n            return;\n        }\n        // Find scroll target.\n        const scrollTarget = element.closest('[data-lm-dragscroll]');\n        if (!scrollTarget) {\n            return;\n        }\n        // Apply the scroll delta to the correct target.\n        scrollTarget.scrollTop += Private.cursorBackdrop.scrollTop - backdropScrollOrigin;\n        scrollTarget.scrollLeft += Private.cursorBackdrop.scrollLeft - backdropScrollOrigin;\n        // Center the scroll position.\n        resetBackdropScroll();\n    }\n    /**\n     * Reset the backdrop scroll to allow further scrolling.\n     */\n    function resetBackdropScroll() {\n        Private.cursorBackdrop.scrollTop = backdropScrollOrigin;\n        Private.cursorBackdrop.scrollLeft = backdropScrollOrigin;\n    }\n    /**\n     * The center of the backdrop node scroll area.\n     */\n    const backdropScrollOrigin = 500;\n    /**\n     * Create cursor backdrop node.\n     */\n    function createCursorBackdrop() {\n        const backdrop = document.createElement('div');\n        backdrop.classList.add('lm-cursor-backdrop');\n        return backdrop;\n    }\n    /**\n     * The internal id for the active cursor override.\n     */\n    let overrideCursorID = 0;\n    /**\n     * A backdrop node overriding pointer cursor.\n     *\n     * #### Notes\n     * We use a backdrop node rather than setting the cursor directly on the body\n     * because setting it on body requires more extensive style recalculation for\n     * reliable application of the cursor, this is the cursor not being overriden\n     * when over child elements with another style like `cursor: other!important`.\n     */\n    Private.cursorBackdrop = createCursorBackdrop();\n})(Private || (Private = {}));\n\nexport { Drag };\n//# sourceMappingURL=index.es6.js.map\n","import { ArrayExt } from '@lumino/algorithm';\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 * @packageDocumentation\n * @module virtualdom\n */\n/**\n * A virtual node which represents plain text content.\n *\n * #### Notes\n * User code will not typically create a `VirtualText` node directly.\n * Instead, the `h()` function will be used to create an element tree.\n */\nclass VirtualText {\n    /**\n     * Construct a new virtual text node.\n     *\n     * @param content - The text content for the node.\n     */\n    constructor(content) {\n        /**\n         * The type of the node.\n         *\n         * This value can be used as a type guard for discriminating the\n         * `VirtualNode` union type.\n         */\n        this.type = 'text';\n        this.content = content;\n    }\n}\n/**\n * A virtual node which represents an HTML element.\n *\n * #### Notes\n * User code will not typically create a `VirtualElement` node directly.\n * Instead, the `h()` function will be used to create an element tree.\n */\nclass VirtualElement {\n    /**\n     * Construct a new virtual element node.\n     *\n     * @param tag - The element tag name.\n     *\n     * @param attrs - The element attributes.\n     *\n     * @param children - The element children.\n     *\n     * @param renderer - An optional custom renderer for the element.\n     */\n    constructor(tag, attrs, children, renderer) {\n        /**\n         * The type of the node.\n         *\n         * This value can be used as a type guard for discriminating the\n         * `VirtualNode` union type.\n         */\n        this.type = 'element';\n        this.tag = tag;\n        this.attrs = attrs;\n        this.children = children;\n        this.renderer = renderer;\n    }\n}\n/**\n * DEPRECATED - use VirtualElement with a defined renderer param instead.\n * This class is provided as a backwards compatibility shim\n *\n * A \"pass thru\" virtual node whose children are managed by a render and an\n * unrender callback. The intent of this flavor of virtual node is to make\n * it easy to blend other kinds of virtualdom (eg React) into Phosphor's\n * virtualdom.\n *\n * #### Notes\n * User code will not typically create a `VirtualElementPass` node directly.\n * Instead, the `hpass()` function will be used to create an element tree.\n */\nclass VirtualElementPass extends VirtualElement {\n    /**\n     * DEPRECATED - use VirtualElement with a defined renderer param instead\n     *\n     * Construct a new virtual element pass thru node.\n     *\n     * @param tag - the tag of the parent element of this node. Once the parent\n     * element is rendered, it will be passed as an argument to\n     * renderer.render\n     *\n     * @param attrs - attributes that will assigned to the\n     * parent element\n     *\n     * @param renderer - an object with render and unrender\n     * functions, each of which should take a single argument of type\n     * HTMLElement and return nothing. If null, the parent element\n     * will be rendered barren without any children.\n     */\n    constructor(tag, attrs, renderer) {\n        super(tag, attrs, [], renderer || undefined);\n    }\n}\nfunction h(tag) {\n    let attrs = {};\n    let renderer;\n    let children = [];\n    for (let i = 1, n = arguments.length; i < n; ++i) {\n        // eslint-disable-next-line prefer-rest-params\n        let arg = arguments[i];\n        if (typeof arg === 'string') {\n            children.push(new VirtualText(arg));\n        }\n        else if (arg instanceof VirtualText) {\n            children.push(arg);\n        }\n        else if (arg instanceof VirtualElement) {\n            children.push(arg);\n        }\n        else if (arg instanceof Array) {\n            extend(children, arg);\n        }\n        else if ((i === 1 || i === 2) && arg && typeof arg === 'object') {\n            if ('render' in arg) {\n                renderer = arg;\n            }\n            else {\n                attrs = arg;\n            }\n        }\n    }\n    return new VirtualElement(tag, attrs, children, renderer);\n    function extend(array, values) {\n        for (let child of values) {\n            if (typeof child === 'string') {\n                array.push(new VirtualText(child));\n            }\n            else if (child instanceof VirtualText) {\n                array.push(child);\n            }\n            else if (child instanceof VirtualElement) {\n                array.push(child);\n            }\n        }\n    }\n}\n/**\n * The namespace for the `h` function statics.\n */\n(function (h) {\n    h.a = h.bind(undefined, 'a');\n    h.abbr = h.bind(undefined, 'abbr');\n    h.address = h.bind(undefined, 'address');\n    h.area = h.bind(undefined, 'area');\n    h.article = h.bind(undefined, 'article');\n    h.aside = h.bind(undefined, 'aside');\n    h.audio = h.bind(undefined, 'audio');\n    h.b = h.bind(undefined, 'b');\n    h.bdi = h.bind(undefined, 'bdi');\n    h.bdo = h.bind(undefined, 'bdo');\n    h.blockquote = h.bind(undefined, 'blockquote');\n    h.br = h.bind(undefined, 'br');\n    h.button = h.bind(undefined, 'button');\n    h.canvas = h.bind(undefined, 'canvas');\n    h.caption = h.bind(undefined, 'caption');\n    h.cite = h.bind(undefined, 'cite');\n    h.code = h.bind(undefined, 'code');\n    h.col = h.bind(undefined, 'col');\n    h.colgroup = h.bind(undefined, 'colgroup');\n    h.data = h.bind(undefined, 'data');\n    h.datalist = h.bind(undefined, 'datalist');\n    h.dd = h.bind(undefined, 'dd');\n    h.del = h.bind(undefined, 'del');\n    h.dfn = h.bind(undefined, 'dfn');\n    h.div = h.bind(undefined, 'div');\n    h.dl = h.bind(undefined, 'dl');\n    h.dt = h.bind(undefined, 'dt');\n    h.em = h.bind(undefined, 'em');\n    h.embed = h.bind(undefined, 'embed');\n    h.fieldset = h.bind(undefined, 'fieldset');\n    h.figcaption = h.bind(undefined, 'figcaption');\n    h.figure = h.bind(undefined, 'figure');\n    h.footer = h.bind(undefined, 'footer');\n    h.form = h.bind(undefined, 'form');\n    h.h1 = h.bind(undefined, 'h1');\n    h.h2 = h.bind(undefined, 'h2');\n    h.h3 = h.bind(undefined, 'h3');\n    h.h4 = h.bind(undefined, 'h4');\n    h.h5 = h.bind(undefined, 'h5');\n    h.h6 = h.bind(undefined, 'h6');\n    h.header = h.bind(undefined, 'header');\n    h.hr = h.bind(undefined, 'hr');\n    h.i = h.bind(undefined, 'i');\n    h.iframe = h.bind(undefined, 'iframe');\n    h.img = h.bind(undefined, 'img');\n    h.input = h.bind(undefined, 'input');\n    h.ins = h.bind(undefined, 'ins');\n    h.kbd = h.bind(undefined, 'kbd');\n    h.label = h.bind(undefined, 'label');\n    h.legend = h.bind(undefined, 'legend');\n    h.li = h.bind(undefined, 'li');\n    h.main = h.bind(undefined, 'main');\n    h.map = h.bind(undefined, 'map');\n    h.mark = h.bind(undefined, 'mark');\n    h.meter = h.bind(undefined, 'meter');\n    h.nav = h.bind(undefined, 'nav');\n    h.noscript = h.bind(undefined, 'noscript');\n    h.object = h.bind(undefined, 'object');\n    h.ol = h.bind(undefined, 'ol');\n    h.optgroup = h.bind(undefined, 'optgroup');\n    h.option = h.bind(undefined, 'option');\n    h.output = h.bind(undefined, 'output');\n    h.p = h.bind(undefined, 'p');\n    h.param = h.bind(undefined, 'param');\n    h.pre = h.bind(undefined, 'pre');\n    h.progress = h.bind(undefined, 'progress');\n    h.q = h.bind(undefined, 'q');\n    h.rp = h.bind(undefined, 'rp');\n    h.rt = h.bind(undefined, 'rt');\n    h.ruby = h.bind(undefined, 'ruby');\n    h.s = h.bind(undefined, 's');\n    h.samp = h.bind(undefined, 'samp');\n    h.section = h.bind(undefined, 'section');\n    h.select = h.bind(undefined, 'select');\n    h.small = h.bind(undefined, 'small');\n    h.source = h.bind(undefined, 'source');\n    h.span = h.bind(undefined, 'span');\n    h.strong = h.bind(undefined, 'strong');\n    h.sub = h.bind(undefined, 'sub');\n    h.summary = h.bind(undefined, 'summary');\n    h.sup = h.bind(undefined, 'sup');\n    h.table = h.bind(undefined, 'table');\n    h.tbody = h.bind(undefined, 'tbody');\n    h.td = h.bind(undefined, 'td');\n    h.textarea = h.bind(undefined, 'textarea');\n    h.tfoot = h.bind(undefined, 'tfoot');\n    h.th = h.bind(undefined, 'th');\n    h.thead = h.bind(undefined, 'thead');\n    h.time = h.bind(undefined, 'time');\n    h.title = h.bind(undefined, 'title');\n    h.tr = h.bind(undefined, 'tr');\n    h.track = h.bind(undefined, 'track');\n    h.u = h.bind(undefined, 'u');\n    h.ul = h.bind(undefined, 'ul');\n    h.var_ = h.bind(undefined, 'var');\n    h.video = h.bind(undefined, 'video');\n    h.wbr = h.bind(undefined, 'wbr');\n})(h || (h = {}));\nfunction hpass(tag) {\n    let attrs = {};\n    let renderer = null;\n    if (arguments.length === 2) {\n        // eslint-disable-next-line prefer-rest-params\n        const arg = arguments[1];\n        if ('render' in arg) {\n            renderer = arg;\n        }\n        else {\n            attrs = arg;\n        }\n    }\n    else if (arguments.length === 3) {\n        // eslint-disable-next-line prefer-rest-params\n        attrs = arguments[1];\n        // eslint-disable-next-line prefer-rest-params\n        renderer = arguments[2];\n    }\n    else if (arguments.length > 3) {\n        throw new Error('hpass() should be called with 1, 2, or 3 arguments');\n    }\n    return new VirtualElementPass(tag, attrs, renderer);\n}\n/**\n * The namespace for the virtual DOM rendering functions.\n */\nvar VirtualDOM;\n(function (VirtualDOM) {\n    function realize(node) {\n        return Private.createDOMNode(node);\n    }\n    VirtualDOM.realize = realize;\n    /**\n     * Render virtual DOM content into a host element.\n     *\n     * @param content - The virtual DOM content to render.\n     *\n     * @param host - The host element for the rendered content.\n     *\n     * #### Notes\n     * This renders the delta from the previous rendering. It assumes that\n     * the content of the host element is not manipulated by external code.\n     *\n     * Providing `null` content will clear the rendering.\n     *\n     * Externally modifying the provided content or the host element will\n     * result in undefined rendering behavior.\n     */\n    function render(content, host) {\n        let oldContent = Private.hostMap.get(host) || [];\n        let newContent = Private.asContentArray(content);\n        Private.hostMap.set(host, newContent);\n        Private.updateContent(host, oldContent, newContent);\n    }\n    VirtualDOM.render = render;\n})(VirtualDOM || (VirtualDOM = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\n(function (Private) {\n    /**\n     * A weak mapping of host element to virtual DOM content.\n     */\n    Private.hostMap = new WeakMap();\n    /**\n     * Cast a content value to a content array.\n     */\n    function asContentArray(value) {\n        if (!value) {\n            return [];\n        }\n        if (value instanceof Array) {\n            return value;\n        }\n        return [value];\n    }\n    Private.asContentArray = asContentArray;\n    function createDOMNode(node) {\n        // eslint-disable-next-line prefer-rest-params\n        let host = arguments[1] || null;\n        // eslint-disable-next-line prefer-rest-params\n        const before = arguments[2] || null;\n        if (host) {\n            host.insertBefore(createDOMNode(node), before);\n        }\n        else {\n            // Create a text node for a virtual text node.\n            if (node.type === 'text') {\n                return document.createTextNode(node.content);\n            }\n            // Create the HTML element with the specified tag.\n            host = document.createElement(node.tag);\n            // Add the attributes for the new element.\n            addAttrs(host, node.attrs);\n            if (node.renderer) {\n                node.renderer.render(host, {\n                    attrs: node.attrs,\n                    children: node.children\n                });\n                return host;\n            }\n            // Recursively populate the element with child content.\n            for (let i = 0, n = node.children.length; i < n; ++i) {\n                createDOMNode(node.children[i], host);\n            }\n        }\n        return host;\n    }\n    Private.createDOMNode = createDOMNode;\n    /**\n     * Update a host element with the delta of the virtual content.\n     *\n     * This is the core \"diff\" algorithm. There is no explicit \"patch\"\n     * phase. The host is patched at each step as the diff progresses.\n     */\n    function updateContent(host, oldContent, newContent) {\n        // Bail early if the content is identical.\n        if (oldContent === newContent) {\n            return;\n        }\n        // Collect the old keyed elems into a mapping.\n        let oldKeyed = collectKeys(host, oldContent);\n        // Create a copy of the old content which can be modified in-place.\n        let oldCopy = oldContent.slice();\n        // Update the host with the new content. The diff always proceeds\n        // forward and never modifies a previously visited index. The old\n        // copy array is modified in-place to reflect the changes made to\n        // the host children. This causes the stale nodes to be pushed to\n        // the end of the host node and removed at the end of the loop.\n        let currElem = host.firstChild;\n        let newCount = newContent.length;\n        for (let i = 0; i < newCount; ++i) {\n            // If the old content is exhausted, create a new node.\n            if (i >= oldCopy.length) {\n                createDOMNode(newContent[i], host);\n                continue;\n            }\n            // Lookup the old and new virtual nodes.\n            let oldVNode = oldCopy[i];\n            let newVNode = newContent[i];\n            // If both elements are identical, there is nothing to do.\n            if (oldVNode === newVNode) {\n                currElem = currElem.nextSibling;\n                continue;\n            }\n            // Handle the simplest case of in-place text update first.\n            if (oldVNode.type === 'text' && newVNode.type === 'text') {\n                // Avoid spurious updates for performance.\n                if (currElem.textContent !== newVNode.content) {\n                    currElem.textContent = newVNode.content;\n                }\n                currElem = currElem.nextSibling;\n                continue;\n            }\n            // If the old or new node is a text node, the other node is now\n            // known to be an element node, so create and insert a new node.\n            if (oldVNode.type === 'text' || newVNode.type === 'text') {\n                ArrayExt.insert(oldCopy, i, newVNode);\n                createDOMNode(newVNode, host, currElem);\n                continue;\n            }\n            // If the old XOR new node has a custom renderer,\n            // create and insert a new node.\n            if (!oldVNode.renderer != !newVNode.renderer) {\n                ArrayExt.insert(oldCopy, i, newVNode);\n                createDOMNode(newVNode, host, currElem);\n                continue;\n            }\n            // At this point, both nodes are known to be element nodes.\n            // If the new elem is keyed, move an old keyed elem to the proper\n            // location before proceeding with the diff. The search can start\n            // at the current index, since the unmatched old keyed elems are\n            // pushed forward in the old copy array.\n            let newKey = newVNode.attrs.key;\n            if (newKey && newKey in oldKeyed) {\n                let pair = oldKeyed[newKey];\n                if (pair.vNode !== oldVNode) {\n                    ArrayExt.move(oldCopy, oldCopy.indexOf(pair.vNode, i + 1), i);\n                    host.insertBefore(pair.element, currElem);\n                    oldVNode = pair.vNode;\n                    currElem = pair.element;\n                }\n            }\n            // If both elements are identical, there is nothing to do.\n            if (oldVNode === newVNode) {\n                currElem = currElem.nextSibling;\n                continue;\n            }\n            // If the old elem is keyed and does not match the new elem key,\n            // create a new node. This is necessary since the old keyed elem\n            // may be matched at a later point in the diff.\n            let oldKey = oldVNode.attrs.key;\n            if (oldKey && oldKey !== newKey) {\n                ArrayExt.insert(oldCopy, i, newVNode);\n                createDOMNode(newVNode, host, currElem);\n                continue;\n            }\n            // If the tags are different, create a new node.\n            if (oldVNode.tag !== newVNode.tag) {\n                ArrayExt.insert(oldCopy, i, newVNode);\n                createDOMNode(newVNode, host, currElem);\n                continue;\n            }\n            // At this point, the element can be updated in-place.\n            // Update the element attributes.\n            updateAttrs(currElem, oldVNode.attrs, newVNode.attrs);\n            // Update the element content.\n            if (newVNode.renderer) {\n                newVNode.renderer.render(currElem, {\n                    attrs: newVNode.attrs,\n                    children: newVNode.children\n                });\n            }\n            else {\n                updateContent(currElem, oldVNode.children, newVNode.children);\n            }\n            // Step to the next sibling element.\n            currElem = currElem.nextSibling;\n        }\n        // Cleanup stale DOM\n        removeContent(host, oldCopy, newCount, true);\n    }\n    Private.updateContent = updateContent;\n    /**\n     * Handle cleanup of stale vdom and its associated DOM. The host node is\n     * traversed recursively (in depth-first order), and any explicit cleanup\n     * required by a child node is carried out when it is visited (eg if a node\n     * has a custom renderer, the renderer.unrender function will be called).\n     * Once the subtree beneath each child of host has been completely visited,\n     * that child will be removed via a call to host.removeChild.\n     */\n    function removeContent(host, oldContent, newCount, _sentinel) {\n        // Dispose of the old nodes pushed to the end of the host.\n        for (let i = oldContent.length - 1; i >= newCount; --i) {\n            const oldNode = oldContent[i];\n            const child = (_sentinel ? host.lastChild : host.childNodes[i]);\n            // recursively clean up host children\n            if (oldNode.type === 'text') ;\n            else if (oldNode.renderer && oldNode.renderer.unrender) {\n                oldNode.renderer.unrender(child, {\n                    attrs: oldNode.attrs,\n                    children: oldNode.children\n                });\n            }\n            else {\n                removeContent(child, oldNode.children, 0, false);\n            }\n            if (_sentinel) {\n                host.removeChild(child);\n            }\n        }\n    }\n    /**\n     * A set of special-cased attribute names.\n     */\n    const specialAttrs = {\n        key: true,\n        className: true,\n        htmlFor: true,\n        dataset: true,\n        style: true\n    };\n    /**\n     * Add element attributes to a newly created HTML element.\n     */\n    function addAttrs(element, attrs) {\n        // Add the inline event listeners and node attributes.\n        for (let name in attrs) {\n            if (name in specialAttrs) {\n                continue;\n            }\n            if (name.substr(0, 2) === 'on') {\n                element[name] = attrs[name];\n            }\n            else {\n                element.setAttribute(name, attrs[name]);\n            }\n        }\n        // Add the element `class` attribute.\n        if (attrs.className !== undefined) {\n            element.setAttribute('class', attrs.className);\n        }\n        // Add the element `for` attribute.\n        if (attrs.htmlFor !== undefined) {\n            element.setAttribute('for', attrs.htmlFor);\n        }\n        // Add the dataset values.\n        if (attrs.dataset) {\n            addDataset(element, attrs.dataset);\n        }\n        // Add the inline styles.\n        if (attrs.style) {\n            addStyle(element, attrs.style);\n        }\n    }\n    /**\n     * Update the element attributes of an HTML element.\n     */\n    function updateAttrs(element, oldAttrs, newAttrs) {\n        // Do nothing if the attrs are the same object.\n        if (oldAttrs === newAttrs) {\n            return;\n        }\n        // Setup the strongly typed loop variable.\n        let name;\n        // Remove attributes and listeners which no longer exist.\n        for (name in oldAttrs) {\n            if (name in specialAttrs || name in newAttrs) {\n                continue;\n            }\n            if (name.substr(0, 2) === 'on') {\n                element[name] = null;\n            }\n            else {\n                element.removeAttribute(name);\n            }\n        }\n        // Add and update new and existing attributes and listeners.\n        for (name in newAttrs) {\n            if (name in specialAttrs || oldAttrs[name] === newAttrs[name]) {\n                continue;\n            }\n            if (name.substr(0, 2) === 'on') {\n                element[name] = newAttrs[name];\n            }\n            else {\n                element.setAttribute(name, newAttrs[name]);\n            }\n        }\n        // Update the element `class` attribute.\n        if (oldAttrs.className !== newAttrs.className) {\n            if (newAttrs.className !== undefined) {\n                element.setAttribute('class', newAttrs.className);\n            }\n            else {\n                element.removeAttribute('class');\n            }\n        }\n        // Add the element `for` attribute.\n        if (oldAttrs.htmlFor !== newAttrs.htmlFor) {\n            if (newAttrs.htmlFor !== undefined) {\n                element.setAttribute('for', newAttrs.htmlFor);\n            }\n            else {\n                element.removeAttribute('for');\n            }\n        }\n        // Update the dataset values.\n        if (oldAttrs.dataset !== newAttrs.dataset) {\n            updateDataset(element, oldAttrs.dataset || {}, newAttrs.dataset || {});\n        }\n        // Update the inline styles.\n        if (oldAttrs.style !== newAttrs.style) {\n            updateStyle(element, oldAttrs.style || {}, newAttrs.style || {});\n        }\n    }\n    /**\n     * Add dataset values to a newly created HTML element.\n     */\n    function addDataset(element, dataset) {\n        for (let name in dataset) {\n            element.setAttribute(`data-${name}`, dataset[name]);\n        }\n    }\n    /**\n     * Update the dataset values of an HTML element.\n     */\n    function updateDataset(element, oldDataset, newDataset) {\n        for (let name in oldDataset) {\n            if (!(name in newDataset)) {\n                element.removeAttribute(`data-${name}`);\n            }\n        }\n        for (let name in newDataset) {\n            if (oldDataset[name] !== newDataset[name]) {\n                element.setAttribute(`data-${name}`, newDataset[name]);\n            }\n        }\n    }\n    /**\n     * Add inline style values to a newly created HTML element.\n     */\n    function addStyle(element, style) {\n        let elemStyle = element.style;\n        let name;\n        for (name in style) {\n            elemStyle[name] = style[name];\n        }\n    }\n    /**\n     * Update the inline style values of an HTML element.\n     */\n    function updateStyle(element, oldStyle, newStyle) {\n        let elemStyle = element.style;\n        let name;\n        for (name in oldStyle) {\n            if (!(name in newStyle)) {\n                elemStyle[name] = '';\n            }\n        }\n        for (name in newStyle) {\n            if (oldStyle[name] !== newStyle[name]) {\n                elemStyle[name] = newStyle[name];\n            }\n        }\n    }\n    /**\n     * Collect a mapping of keyed elements for the host content.\n     */\n    function collectKeys(host, content) {\n        let node = host.firstChild;\n        let keyMap = Object.create(null);\n        for (let vNode of content) {\n            if (vNode.type === 'element' && vNode.attrs.key) {\n                keyMap[vNode.attrs.key] = { vNode, element: node };\n            }\n            node = node.nextSibling;\n        }\n        return keyMap;\n    }\n})(Private || (Private = {}));\n\nexport { VirtualDOM, VirtualElement, VirtualElementPass, VirtualText, h, hpass };\n//# sourceMappingURL=index.es6.js.map\n","import { ArrayExt, StringExt, empty, find, max } from '@lumino/algorithm';\nimport { UUID, JSONExt, MimeData } from '@lumino/coreutils';\nimport { ElementExt, Selector, Platform } from '@lumino/domutils';\nimport { Message, ConflatableMessage, MessageLoop } from '@lumino/messaging';\nimport { AttachedProperty } from '@lumino/properties';\nimport { Signal } from '@lumino/signaling';\nimport { Drag } from '@lumino/dragdrop';\nimport { CommandRegistry } from '@lumino/commands';\nimport { VirtualDOM, h } from '@lumino/virtualdom';\nimport { DisposableDelegate } from '@lumino/disposable';\nimport { getKeyboardLayout } from '@lumino/keyboard';\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 */\nclass BoxSizer {\n    constructor() {\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 {@link minSize} and {@link 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 {@link 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 {@link 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 {@link BoxEngine.calc}. 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}\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 {@link BoxSizer.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        let count = sizers.length;\n        if (count === 0) {\n            return space;\n        }\n        // Setup the size and stretch counters.\n        let totalMin = 0;\n        let totalMax = 0;\n        let totalSize = 0;\n        let totalStretch = 0;\n        let stretchCount = 0;\n        // Setup the sizers and compute the totals.\n        for (let i = 0; i < count; ++i) {\n            let sizer = sizers[i];\n            let min = sizer.minSize;\n            let max = sizer.maxSize;\n            let 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 (let i = 0; i < count; ++i) {\n                let 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 (let i = 0; i < count; ++i) {\n                let 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        let 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        let 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            let freeSpace = totalSize - space;\n            while (stretchCount > 0 && freeSpace > nearZero) {\n                let distSpace = freeSpace;\n                let distStretch = totalStretch;\n                for (let i = 0; i < count; ++i) {\n                    let sizer = sizers[i];\n                    if (sizer.done || sizer.stretch === 0) {\n                        continue;\n                    }\n                    let 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                let amt = freeSpace / notDoneCount;\n                for (let i = 0; i < count; ++i) {\n                    let 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            let freeSpace = space - totalSize;\n            while (stretchCount > 0 && freeSpace > nearZero) {\n                let distSpace = freeSpace;\n                let distStretch = totalStretch;\n                for (let i = 0; i < count; ++i) {\n                    let sizer = sizers[i];\n                    if (sizer.done || sizer.stretch === 0) {\n                        continue;\n                    }\n                    let 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                let amt = freeSpace / notDoneCount;\n                for (let i = 0; i < count; ++i) {\n                    let 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        let growLimit = 0;\n        for (let i = 0; i <= index; ++i) {\n            let sizer = sizers[i];\n            growLimit += sizer.maxSize - sizer.size;\n        }\n        // Compute how much the items to the right can shrink.\n        let shrinkLimit = 0;\n        for (let i = index + 1, n = sizers.length; i < n; ++i) {\n            let 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        let grow = delta;\n        for (let i = index; i >= 0 && grow > 0; --i) {\n            let sizer = sizers[i];\n            let 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        let shrink = delta;\n        for (let i = index + 1, n = sizers.length; i < n && shrink > 0; ++i) {\n            let sizer = sizers[i];\n            let 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        let growLimit = 0;\n        for (let i = index + 1, n = sizers.length; i < n; ++i) {\n            let sizer = sizers[i];\n            growLimit += sizer.maxSize - sizer.size;\n        }\n        // Compute how much the items to the left can shrink.\n        let shrinkLimit = 0;\n        for (let i = 0; i <= index; ++i) {\n            let 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        let grow = delta;\n        for (let i = index + 1, n = sizers.length; i < n && grow > 0; ++i) {\n            let sizer = sizers[i];\n            let 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        let shrink = delta;\n        for (let i = index; i >= 0 && shrink > 0; --i) {\n            let sizer = sizers[i];\n            let 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/**\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 *\n * It is the responsibility of the owner to call the title disposal.\n */\nclass Title {\n    /**\n     * Construct a new title.\n     *\n     * @param options - The options for initializing the title.\n     */\n    constructor(options) {\n        this._label = '';\n        this._caption = '';\n        this._mnemonic = -1;\n        this._icon = undefined;\n        this._iconClass = '';\n        this._iconLabel = '';\n        this._className = '';\n        this._closable = false;\n        this._changed = new Signal(this);\n        this._isDisposed = false;\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            this._icon = options.icon;\n        }\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.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    /**\n     * A signal emitted when the state of the title changes.\n     */\n    get changed() {\n        return this._changed;\n    }\n    /**\n     * Get the label for the title.\n     *\n     * #### Notes\n     * The default value is an empty string.\n     */\n    get label() {\n        return this._label;\n    }\n    /**\n     * Set the label for the title.\n     */\n    set label(value) {\n        if (this._label === value) {\n            return;\n        }\n        this._label = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the mnemonic index for the title.\n     *\n     * #### Notes\n     * The default value is `-1`.\n     */\n    get mnemonic() {\n        return this._mnemonic;\n    }\n    /**\n     * Set the mnemonic index for the title.\n     */\n    set mnemonic(value) {\n        if (this._mnemonic === value) {\n            return;\n        }\n        this._mnemonic = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the icon renderer for the title.\n     *\n     * #### Notes\n     * The default value is undefined.\n     */\n    get icon() {\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    set icon(value) {\n        if (this._icon === value) {\n            return;\n        }\n        this._icon = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the icon class name for the title.\n     *\n     * #### Notes\n     * The default value is an empty string.\n     */\n    get iconClass() {\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 iconClass(value) {\n        if (this._iconClass === value) {\n            return;\n        }\n        this._iconClass = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the icon label for the title.\n     *\n     * #### Notes\n     * The default value is an empty string.\n     */\n    get iconLabel() {\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 iconLabel(value) {\n        if (this._iconLabel === value) {\n            return;\n        }\n        this._iconLabel = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the caption for the title.\n     *\n     * #### Notes\n     * The default value is an empty string.\n     */\n    get caption() {\n        return this._caption;\n    }\n    /**\n     * Set the caption for the title.\n     */\n    set caption(value) {\n        if (this._caption === value) {\n            return;\n        }\n        this._caption = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the extra class name for the title.\n     *\n     * #### Notes\n     * The default value is an empty string.\n     */\n    get className() {\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 className(value) {\n        if (this._className === value) {\n            return;\n        }\n        this._className = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the closable state for the title.\n     *\n     * #### Notes\n     * The default value is `false`.\n     */\n    get closable() {\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 closable(value) {\n        if (this._closable === value) {\n            return;\n        }\n        this._closable = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Get the dataset for the title.\n     *\n     * #### Notes\n     * The default value is an empty dataset.\n     */\n    get dataset() {\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 dataset(value) {\n        if (this._dataset === value) {\n            return;\n        }\n        this._dataset = value;\n        this._changed.emit(undefined);\n    }\n    /**\n     * Test whether the title has been disposed.\n     */\n    get isDisposed() {\n        return this._isDisposed;\n    }\n    /**\n     * Dispose of the resources held by the title.\n     *\n     * #### Notes\n     * It is the responsibility of the owner to call the title disposal.\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        this._isDisposed = true;\n        Signal.clearData(this);\n    }\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 */\nclass Widget {\n    /**\n     * Construct a new widget.\n     *\n     * @param options - The options for initializing the widget.\n     */\n    constructor(options = {}) {\n        this._flags = 0;\n        this._layout = null;\n        this._parent = null;\n        this._disposed = new Signal(this);\n        this._hiddenMode = Widget.HiddenMode.Display;\n        this.node = Private$j.createNode(options);\n        this.addClass('lm-Widget');\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    dispose() {\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        // Dispose the title\n        this.title.dispose();\n        // Clear the extra data associated with the widget.\n        Signal.clearData(this);\n        MessageLoop.clearData(this);\n        AttachedProperty.clearData(this);\n    }\n    /**\n     * A signal emitted when the widget is disposed.\n     */\n    get disposed() {\n        return this._disposed;\n    }\n    /**\n     * Test whether the widget has been disposed.\n     */\n    get isDisposed() {\n        return this.testFlag(Widget.Flag.IsDisposed);\n    }\n    /**\n     * Test whether the widget's node is attached to the DOM.\n     */\n    get isAttached() {\n        return this.testFlag(Widget.Flag.IsAttached);\n    }\n    /**\n     * Test whether the widget is explicitly hidden.\n     *\n     * #### Notes\n     * You should prefer `!{@link isVisible}` over `{@link isHidden}` if you want to know if the\n     * widget is hidden as this does not test if the widget is hidden because one of its ancestors is hidden.\n     */\n    get isHidden() {\n        return this.testFlag(Widget.Flag.IsHidden);\n    }\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     * Since 2.7.0, this does not rely on the {@link Widget.Flag.IsVisible} flag.\n     * It recursively checks the visibility of all parent widgets.\n     */\n    get isVisible() {\n        // eslint-disable-next-line @typescript-eslint/no-this-alias\n        let parent = this;\n        do {\n            if (parent.isHidden || !parent.isAttached) {\n                return false;\n            }\n            parent = parent.parent;\n        } while (parent != null);\n        return true;\n    }\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 title() {\n        return Private$j.titleProperty.get(this);\n    }\n    /**\n     * Get the id of the widget's DOM node.\n     */\n    get id() {\n        return this.node.id;\n    }\n    /**\n     * Set the id of the widget's DOM node.\n     */\n    set id(value) {\n        this.node.id = value;\n    }\n    /**\n     * The dataset for the widget's DOM node.\n     */\n    get dataset() {\n        return this.node.dataset;\n    }\n    /**\n     * Get the method for hiding the widget.\n     */\n    get hiddenMode() {\n        return this._hiddenMode;\n    }\n    /**\n     * Set the method for hiding the widget.\n     */\n    set hiddenMode(value) {\n        if (this._hiddenMode === value) {\n            return;\n        }\n        if (this.isHidden) {\n            // Reset styles set by previous mode.\n            this._toggleHidden(false);\n        }\n        if (value == Widget.HiddenMode.Scale) {\n            this.node.style.willChange = 'transform';\n        }\n        else {\n            this.node.style.willChange = 'auto';\n        }\n        this._hiddenMode = value;\n        if (this.isHidden) {\n            // Set styles for new mode.\n            this._toggleHidden(true);\n        }\n    }\n    /**\n     * Get the parent of the widget.\n     */\n    get parent() {\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 parent(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            let msg = new Widget.ChildMessage('child-removed', this);\n            MessageLoop.sendMessage(this._parent, msg);\n        }\n        this._parent = value;\n        if (this._parent && !this._parent.isDisposed) {\n            let msg = new Widget.ChildMessage('child-added', this);\n            MessageLoop.sendMessage(this._parent, msg);\n        }\n        if (!this.isDisposed) {\n            MessageLoop.sendMessage(this, Widget.Msg.ParentChanged);\n        }\n    }\n    /**\n     * Get the layout for the widget.\n     */\n    get layout() {\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 layout(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    /**\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    *children() {\n        if (this._layout) {\n            yield* this._layout;\n        }\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    contains(widget) {\n        for (let 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    hasClass(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    addClass(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    removeClass(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    toggleClass(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    update() {\n        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    fit() {\n        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    activate() {\n        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    close() {\n        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 {@link isHidden} property to be `false`.\n     *\n     * If the widget is not explicitly hidden, this is a no-op.\n     */\n    show() {\n        if (!this.testFlag(Widget.Flag.IsHidden)) {\n            return;\n        }\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            MessageLoop.sendMessage(this, Widget.Msg.BeforeShow);\n        }\n        this.clearFlag(Widget.Flag.IsHidden);\n        this._toggleHidden(false);\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            MessageLoop.sendMessage(this, Widget.Msg.AfterShow);\n        }\n        if (this.parent) {\n            let msg = new Widget.ChildMessage('child-shown', this);\n            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 {@link isHidden} property to be `true`.\n     *\n     * If the widget is explicitly hidden, this is a no-op.\n     */\n    hide() {\n        if (this.testFlag(Widget.Flag.IsHidden)) {\n            return;\n        }\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            MessageLoop.sendMessage(this, Widget.Msg.BeforeHide);\n        }\n        this.setFlag(Widget.Flag.IsHidden);\n        this._toggleHidden(true);\n        if (this.isAttached && (!this.parent || this.parent.isVisible)) {\n            MessageLoop.sendMessage(this, Widget.Msg.AfterHide);\n        }\n        if (this.parent) {\n            let msg = new Widget.ChildMessage('child-hidden', this);\n            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    setHidden(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     * Since 2.7.0, {@link Widget.Flag.IsVisible} is deprecated.\n     * It will be removed in a future version.\n     */\n    testFlag(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     * Since 2.7.0, {@link Widget.Flag.IsVisible} is deprecated.\n     * It will be removed in a future version.\n     */\n    setFlag(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     * Since 2.7.0, {@link Widget.Flag.IsVisible} is deprecated.\n     * It will be removed in a future version.\n     */\n    clearFlag(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    processMessage(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    notifyLayout(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    onCloseRequest(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    onResize(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    onUpdateRequest(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    onFitRequest(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    onActivateRequest(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    onBeforeShow(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    onAfterShow(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    onBeforeHide(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    onAfterHide(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    onBeforeAttach(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    onAfterAttach(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    onBeforeDetach(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    onAfterDetach(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    onChildAdded(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    onChildRemoved(msg) { }\n    _toggleHidden(hidden) {\n        if (hidden) {\n            switch (this._hiddenMode) {\n                case Widget.HiddenMode.Display:\n                    this.addClass('lm-mod-hidden');\n                    break;\n                case Widget.HiddenMode.Scale:\n                    this.node.style.transform = 'scale(0)';\n                    this.node.setAttribute('aria-hidden', 'true');\n                    break;\n                case Widget.HiddenMode.ContentVisibility:\n                    // @ts-expect-error content-visibility unknown by DOM lib types\n                    this.node.style.contentVisibility = 'hidden';\n                    this.node.style.zIndex = '-1';\n                    // Set opacity to 0 so that the widget's box (e.g. borders or\n                    // background) does not shine through despite the content being\n                    // skipped by `content-visibility`.\n                    this.node.style.opacity = '0';\n                    break;\n            }\n        }\n        else {\n            switch (this._hiddenMode) {\n                case Widget.HiddenMode.Display:\n                    this.removeClass('lm-mod-hidden');\n                    break;\n                case Widget.HiddenMode.Scale:\n                    this.node.style.transform = '';\n                    this.node.removeAttribute('aria-hidden');\n                    break;\n                case Widget.HiddenMode.ContentVisibility:\n                    // @ts-expect-error content-visibility unknown by DOM lib types\n                    this.node.style.contentVisibility = '';\n                    this.node.style.zIndex = '';\n                    this.node.style.opacity = '';\n                    break;\n            }\n        }\n    }\n}\n/**\n * The namespace for the `Widget` class statics.\n */\n(function (Widget) {\n    (function (HiddenMode) {\n        /**\n         * Set a `lm-mod-hidden` CSS class to hide the widget using `display:none`\n         * CSS from the standard Lumino CSS.\n         */\n        HiddenMode[HiddenMode[\"Display\"] = 0] = \"Display\";\n        /**\n         * Hide the widget by setting the `transform` to `'scale(0)'`.\n         */\n        HiddenMode[HiddenMode[\"Scale\"] = 1] = \"Scale\";\n        /**\n         *Hide the widget by setting the `content-visibility` to `'hidden'`.\n         */\n        HiddenMode[HiddenMode[\"ContentVisibility\"] = 2] = \"ContentVisibility\";\n    })(Widget.HiddenMode || (Widget.HiddenMode = {}));\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         * @deprecated since 2.7.0, apply that flag consistently was not reliable\n         * so it was dropped in favor of a recursive check of the visibility of all parents.\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    })(Widget.Flag || (Widget.Flag = {}));\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 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 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 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 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 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 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 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 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 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 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 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 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 ConflatableMessage('close-request');\n    })(Widget.Msg || (Widget.Msg = {}));\n    /**\n     * A message class for child related messages.\n     */\n    class ChildMessage extends Message {\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        constructor(type, child) {\n            super(type);\n            this.child = child;\n        }\n    }\n    Widget.ChildMessage = ChildMessage;\n    /**\n     * A message class for `'resize'` messages.\n     */\n    class ResizeMessage extends Message {\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        constructor(width, height) {\n            super('resize');\n            this.width = width;\n            this.height = height;\n        }\n    }\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 = null) {\n        if (widget.parent) {\n            throw new Error('Cannot attach a child widget.');\n        }\n        if (widget.isAttached || widget.node.isConnected) {\n            throw new Error('Widget is already attached.');\n        }\n        if (!host.isConnected) {\n            throw new Error('Host is not attached.');\n        }\n        MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);\n        host.insertBefore(widget.node, ref);\n        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 || !widget.node.isConnected) {\n            throw new Error('Widget is not attached.');\n        }\n        MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);\n        widget.node.parentNode.removeChild(widget.node);\n        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$j;\n(function (Private) {\n    /**\n     * An attached property for the widget title object.\n     */\n    Private.titleProperty = new AttachedProperty({\n        name: 'title',\n        create: owner => new Title({ 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$j || (Private$j = {}));\n\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 */\nclass Layout {\n    /**\n     * Construct a new layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    constructor(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    dispose() {\n        this._parent = null;\n        this._disposed = true;\n        Signal.clearData(this);\n        AttachedProperty.clearData(this);\n    }\n    /**\n     * Test whether the layout is disposed.\n     */\n    get isDisposed() {\n        return this._disposed;\n    }\n    /**\n     * Get the parent widget of the layout.\n     */\n    get parent() {\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 parent(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    /**\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 fitPolicy() {\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 fitPolicy(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            let style = this._parent.node.style;\n            style.minWidth = '';\n            style.minHeight = '';\n            style.maxWidth = '';\n            style.maxHeight = '';\n            this._parent.fit();\n        }\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    processParentMessage(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    init() {\n        for (const widget of this) {\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    onResize(msg) {\n        for (const widget of this) {\n            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    onUpdateRequest(msg) {\n        for (const widget of this) {\n            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    onBeforeAttach(msg) {\n        for (const widget of this) {\n            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    onAfterAttach(msg) {\n        for (const widget of this) {\n            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    onBeforeDetach(msg) {\n        for (const widget of this) {\n            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    onAfterDetach(msg) {\n        for (const widget of this) {\n            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    onBeforeShow(msg) {\n        for (const widget of this) {\n            if (!widget.isHidden) {\n                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    onAfterShow(msg) {\n        for (const widget of this) {\n            if (!widget.isHidden) {\n                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    onBeforeHide(msg) {\n        for (const widget of this) {\n            if (!widget.isHidden) {\n                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    onAfterHide(msg) {\n        for (const widget of this) {\n            if (!widget.isHidden) {\n                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    onChildRemoved(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    onFitRequest(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    onChildShown(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    onChildHidden(msg) { }\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$i.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$i.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$i.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$i.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 */\nclass LayoutItem {\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     * The widget will use strict CSS containment.\n     */\n    constructor(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        this.widget.node.style.contain = 'strict';\n    }\n    /**\n     * Dispose of the the layout item.\n     *\n     * #### Notes\n     * This will reset the positioning of the widget.\n     */\n    dispose() {\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        let style = this.widget.node.style;\n        style.position = '';\n        style.top = '';\n        style.left = '';\n        style.width = '';\n        style.height = '';\n        style.contain = '';\n    }\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 minWidth() {\n        return this._minWidth;\n    }\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 minHeight() {\n        return this._minHeight;\n    }\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 maxWidth() {\n        return this._maxWidth;\n    }\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 maxHeight() {\n        return this._maxHeight;\n    }\n    /**\n     * Whether the layout item is disposed.\n     */\n    get isDisposed() {\n        return this._disposed;\n    }\n    /**\n     * Whether the managed widget is hidden.\n     */\n    get isHidden() {\n        return this.widget.isHidden;\n    }\n    /**\n     * Whether the managed widget is visible.\n     */\n    get isVisible() {\n        return this.widget.isVisible;\n    }\n    /**\n     * Whether the managed widget is attached.\n     */\n    get isAttached() {\n        return this.widget.isAttached;\n    }\n    /**\n     * Update the computed size limits of the managed widget.\n     */\n    fit() {\n        let limits = 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    update(left, top, width, height) {\n        // Clamp the size to the computed size limits.\n        let clampW = Math.max(this._minWidth, Math.min(width, this._maxWidth));\n        let 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        let resized = false;\n        let 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            let msg = new Widget.ResizeMessage(clampW, clampH);\n            MessageLoop.sendMessage(this.widget, msg);\n        }\n    }\n}\n/**\n * The namespace for the module implementation details.\n */\nvar Private$i;\n(function (Private) {\n    /**\n     * The attached property for a widget horizontal alignment.\n     */\n    Private.horizontalAlignmentProperty = new AttachedProperty({\n        name: 'horizontalAlignment',\n        create: () => 'center',\n        changed: onAlignmentChanged\n    });\n    /**\n     * The attached property for a widget vertical alignment.\n     */\n    Private.verticalAlignmentProperty = new AttachedProperty({\n        name: 'verticalAlignment',\n        create: () => '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$i || (Private$i = {}));\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 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 */\nclass PanelLayout extends Layout {\n    constructor() {\n        super(...arguments);\n        this._widgets = [];\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    dispose() {\n        while (this._widgets.length > 0) {\n            this._widgets.pop().dispose();\n        }\n        super.dispose();\n    }\n    /**\n     * A read-only array of the widgets in the layout.\n     */\n    get widgets() {\n        return this._widgets;\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    *[Symbol.iterator]() {\n        yield* 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    addWidget(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    insertWidget(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        let i = this._widgets.indexOf(widget);\n        // Clamp the insert index to the array bounds.\n        let 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            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        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    removeWidget(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    removeWidgetAt(index) {\n        // Remove the widget from the array.\n        let widget = 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    init() {\n        super.init();\n        let index = 0;\n        for (const widget of this) {\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    attachWidget(index, widget) {\n        // Look up the next sibling reference node.\n        let ref = this.parent.node.children[index];\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    moveWidget(fromIndex, toIndex, widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Look up the next sibling reference node.\n        let ref = this.parent.node.children[toIndex];\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    detachWidget(index, widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n    }\n}\n\n/*\n * Copyright (c) Jupyter Development Team.\n * Distributed under the terms of the Modified BSD License.\n */\nvar Utils;\n(function (Utils) {\n    /**\n     * Clamp a dimension value to an integer >= 0.\n     */\n    function clampDimension(value) {\n        return Math.max(0, Math.floor(value));\n    }\n    Utils.clampDimension = clampDimension;\n    /**\n     * Whether a pointer event came from touch input.\n     */\n    function isTouchEvent(event) {\n        return 'pointerType' in event && event.pointerType === 'touch';\n    }\n    Utils.isTouchEvent = isTouchEvent;\n})(Utils || (Utils = {}));\nvar Utils$1 = Utils;\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 layout which arranges its widgets into resizable sections.\n */\nclass SplitLayout extends PanelLayout {\n    /**\n     * Construct a new split layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    constructor(options) {\n        super();\n        this.widgetOffset = 0;\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 = Utils.clampDimension(options.spacing);\n        }\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    dispose() {\n        // Dispose of the layout items.\n        for (const item of this._items) {\n            item.dispose();\n        }\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.dispose();\n    }\n    /**\n     * Get the layout orientation for the split layout.\n     */\n    get orientation() {\n        return this._orientation;\n    }\n    /**\n     * Set the layout orientation for the split layout.\n     */\n    set orientation(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    /**\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 alignment() {\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 alignment(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    /**\n     * Get the inter-element spacing for the split layout.\n     */\n    get spacing() {\n        return this._spacing;\n    }\n    /**\n     * Set the inter-element spacing for the split layout.\n     */\n    set spacing(value) {\n        value = Utils.clampDimension(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    /**\n     * A read-only array of the split handles in the layout.\n     */\n    get handles() {\n        return this._handles;\n    }\n    /**\n     * Get the absolute sizes of the widgets in the layout.\n     *\n     * @returns A new array of the absolute sizes of the widgets.\n     *\n     * This method **does not** measure the DOM nodes.\n     */\n    absoluteSizes() {\n        return this._sizers.map(sizer => sizer.size);\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    relativeSizes() {\n        return Private$h.normalize(this._sizers.map(sizer => 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     * @param update - Update the layout after setting relative sizes.\n     * Default is True.\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    setRelativeSizes(sizes, update = true) {\n        // Copy the sizes and pad with zeros as needed.\n        let n = this._sizers.length;\n        let temp = sizes.slice(0, n);\n        while (temp.length < n) {\n            temp.push(0);\n        }\n        // Normalize the padded sizes.\n        let normed = Private$h.normalize(temp);\n        // Apply the normalized sizes to the sizers.\n        for (let i = 0; i < n; ++i) {\n            let 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 (update && 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    moveHandle(index, position) {\n        // Bail if the index is invalid or the handle is hidden.\n        let 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        let 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 (let sizer of this._sizers) {\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    init() {\n        this.parent.dataset['orientation'] = this.orientation;\n        this.parent.dataset['alignment'] = this.alignment;\n        super.init();\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    attachWidget(index, widget) {\n        // Create the item, handle, and sizer for the new widget.\n        let item = new LayoutItem(widget);\n        let handle = Private$h.createHandle(this.renderer);\n        let average = Private$h.averageSize(this._sizers);\n        let sizer = Private$h.createSizer(average);\n        // Insert the item, handle, and sizer into the internal arrays.\n        ArrayExt.insert(this._items, index, item);\n        ArrayExt.insert(this._sizers, index, sizer);\n        ArrayExt.insert(this._handles, index, handle);\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    moveWidget(fromIndex, toIndex, widget) {\n        // Move the item, sizer, and handle for the widget.\n        ArrayExt.move(this._items, fromIndex, toIndex);\n        ArrayExt.move(this._sizers, fromIndex, toIndex);\n        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    detachWidget(index, widget) {\n        // Remove the item, handle, and sizer for the widget.\n        let item = ArrayExt.removeAt(this._items, index);\n        let handle = ArrayExt.removeAt(this._handles, index);\n        ArrayExt.removeAt(this._sizers, index);\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    onBeforeShow(msg) {\n        super.onBeforeShow(msg);\n        this.parent.update();\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(msg) {\n        super.onBeforeAttach(msg);\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    onChildShown(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    onChildHidden(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    onResize(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    onUpdateRequest(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    onFitRequest(msg) {\n        if (this.parent.isAttached) {\n            this._fit();\n        }\n    }\n    /**\n     * Update the item position.\n     *\n     * @param i Item index\n     * @param isHorizontal Whether the layout is horizontal or not\n     * @param left Left position in pixels\n     * @param top Top position in pixels\n     * @param height Item height\n     * @param width Item width\n     * @param size Item size\n     */\n    updateItemPosition(i, isHorizontal, left, top, height, width, size) {\n        const item = this._items[i];\n        if (item.isHidden) {\n            return;\n        }\n        // Fetch the style for the handle.\n        let handleStyle = this._handles[i].style;\n        // Update the widget and handle, and advance the relevant edge.\n        if (isHorizontal) {\n            left += this.widgetOffset;\n            item.update(left, top, size, height);\n            left += size;\n            handleStyle.top = `${top}px`;\n            handleStyle.left = `${left}px`;\n            handleStyle.width = `${this._spacing}px`;\n            handleStyle.height = `${height}px`;\n        }\n        else {\n            top += this.widgetOffset;\n            item.update(left, top, width, size);\n            top += size;\n            handleStyle.top = `${top}px`;\n            handleStyle.left = `${left}px`;\n            handleStyle.width = `${width}px`;\n            handleStyle.height = `${this._spacing}px`;\n        }\n    }\n    /**\n     * Fit the layout to the total size required by the widgets.\n     */\n    _fit() {\n        // Update the handles and track the visible widget count.\n        let nVisible = 0;\n        let lastHandleIndex = -1;\n        for (let 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            }\n            else {\n                this._handles[i].classList.remove('lm-mod-hidden');\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        }\n        // Update the fixed space for the visible items.\n        this._fixed =\n            this._spacing * Math.max(0, nVisible - 1) +\n                this.widgetOffset * this._items.length;\n        // Setup the computed minimum size.\n        let horz = this._orientation === 'horizontal';\n        let minW = horz ? this._fixed : 0;\n        let minH = horz ? 0 : this._fixed;\n        // Update the sizers and computed size limits.\n        for (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item and corresponding box sizer.\n            let item = this._items[i];\n            let 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        let box = (this._box = ElementExt.boxSizing(this.parent.node));\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        let 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            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            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    _update(offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Compute the visible item count.\n        let nVisible = 0;\n        for (let 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 && this.widgetOffset === 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 = ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the actual layout bounds adjusted for border and padding.\n        let top = this._box.paddingTop;\n        let left = this._box.paddingLeft;\n        let width = offsetWidth - this._box.horizontalSum;\n        let height = offsetHeight - this._box.verticalSum;\n        // Set up the variables for justification and alignment offset.\n        let extra = 0;\n        let offset = 0;\n        let horz = this._orientation === 'horizontal';\n        if (nVisible > 0) {\n            // Compute the adjusted layout space.\n            let space;\n            if (horz) {\n                // left += this.widgetOffset;\n                space = Math.max(0, width - this._fixed);\n            }\n            else {\n                // top += this.widgetOffset;\n                space = Math.max(0, height - this._fixed);\n            }\n            // Scale the size hints if they are normalized.\n            if (this._hasNormedSizes) {\n                for (let sizer of this._sizers) {\n                    sizer.sizeHint *= space;\n                }\n                this._hasNormedSizes = false;\n            }\n            // Distribute the layout space to the box sizers.\n            let delta = BoxEngine.calc(this._sizers, space);\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        }\n        // Layout the items using the computed box sizes.\n        for (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            const item = this._items[i];\n            // Fetch the computed size for the widget.\n            const size = item.isHidden ? 0 : this._sizers[i].size + extra;\n            this.updateItemPosition(i, horz, horz ? left + offset : left, horz ? top : top + offset, height, width, size);\n            const fullOffset = this.widgetOffset +\n                (this._handles[i].classList.contains('lm-mod-hidden')\n                    ? 0\n                    : this._spacing);\n            if (horz) {\n                left += size + fullOffset;\n            }\n            else {\n                top += size + fullOffset;\n            }\n        }\n    }\n}\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$h.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$h.stretchProperty.set(widget, value);\n    }\n    SplitLayout.setStretch = setStretch;\n})(SplitLayout || (SplitLayout = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$h;\n(function (Private) {\n    /**\n     * The property descriptor for a widget stretch factor.\n     */\n    Private.stretchProperty = new AttachedProperty({\n        name: 'stretch',\n        create: () => 0,\n        coerce: (owner, value) => 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        let 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        let handle = renderer.createHandle();\n        handle.style.position = 'absolute';\n        // Do not use size containment to allow the handle to fill the available space\n        handle.style.contain = 'style';\n        return handle;\n    }\n    Private.createHandle = createHandle;\n    /**\n     * Compute the average size of an array of box sizers.\n     */\n    function averageSize(sizers) {\n        return sizers.reduce((v, s) => 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        let n = values.length;\n        if (n === 0) {\n            return [];\n        }\n        let sum = values.reduce((a, b) => a + Math.abs(b), 0);\n        return sum === 0 ? values.map(v => 1 / n) : values.map(v => 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$h || (Private$h = {}));\n\n/*\n * Copyright (c) Jupyter Development Team.\n * Distributed under the terms of the Modified BSD License.\n */\n/**\n * A layout which arranges its widgets into collapsible resizable sections.\n */\nclass AccordionLayout extends SplitLayout {\n    /**\n     * Construct a new accordion layout.\n     *\n     * @param options - The options for initializing the layout.\n     *\n     * #### Notes\n     * The default orientation will be vertical.\n     *\n     * Titles must be rotated for horizontal accordion panel using CSS: see accordionpanel.css\n     */\n    constructor(options) {\n        super({ ...options, orientation: options.orientation || 'vertical' });\n        this._titles = [];\n        this.titleSpace = options.titleSpace || 22;\n    }\n    /**\n     * The section title height or width depending on the orientation.\n     */\n    get titleSpace() {\n        return this.widgetOffset;\n    }\n    set titleSpace(value) {\n        value = Utils$1.clampDimension(value);\n        if (this.widgetOffset === value) {\n            return;\n        }\n        this.widgetOffset = value;\n        if (!this.parent) {\n            return;\n        }\n        this.parent.fit();\n    }\n    /**\n     * A read-only array of the section titles in the panel.\n     */\n    get titles() {\n        return this._titles;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        // Clear the layout state.\n        this._titles.length = 0;\n        // Dispose of the rest of the layout.\n        super.dispose();\n    }\n    updateTitle(index, widget) {\n        const oldTitle = this._titles[index];\n        const expanded = oldTitle.classList.contains('lm-mod-expanded');\n        const newTitle = Private$g.createTitle(this.renderer, widget.title, expanded);\n        this._titles[index] = newTitle;\n        // Add the title node to the parent before the widget.\n        this.parent.node.replaceChild(newTitle, oldTitle);\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    insertWidget(index, widget) {\n        if (!widget.id) {\n            widget.id = `id-${UUID.uuid4()}`;\n        }\n        super.insertWidget(index, 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    attachWidget(index, widget) {\n        const title = Private$g.createTitle(this.renderer, widget.title, !widget.isHidden);\n        ArrayExt.insert(this._titles, index, title);\n        // Add the title node to the parent before the widget.\n        this.parent.node.appendChild(title);\n        widget.node.setAttribute('role', 'region');\n        widget.node.setAttribute('aria-labelledby', title.id);\n        super.attachWidget(index, widget);\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    moveWidget(fromIndex, toIndex, widget) {\n        ArrayExt.move(this._titles, fromIndex, toIndex);\n        super.moveWidget(fromIndex, toIndex, widget);\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    detachWidget(index, widget) {\n        const title = ArrayExt.removeAt(this._titles, index);\n        this.parent.node.removeChild(title);\n        super.detachWidget(index, widget);\n    }\n    /**\n     * Update the item position.\n     *\n     * @param i Item index\n     * @param isHorizontal Whether the layout is horizontal or not\n     * @param left Left position in pixels\n     * @param top Top position in pixels\n     * @param height Item height\n     * @param width Item width\n     * @param size Item size\n     */\n    updateItemPosition(i, isHorizontal, left, top, height, width, size) {\n        const titleStyle = this._titles[i].style;\n        // Titles must be rotated for horizontal accordion panel using CSS: see accordionpanel.css\n        titleStyle.top = `${top}px`;\n        titleStyle.left = `${left}px`;\n        titleStyle.height = `${this.widgetOffset}px`;\n        if (isHorizontal) {\n            titleStyle.width = `${height}px`;\n        }\n        else {\n            titleStyle.width = `${width}px`;\n        }\n        super.updateItemPosition(i, isHorizontal, left, top, height, width, size);\n    }\n}\nvar Private$g;\n(function (Private) {\n    /**\n     * Create the title HTML element.\n     *\n     * @param renderer Accordion renderer\n     * @param data Widget title\n     * @returns Title HTML element\n     */\n    function createTitle(renderer, data, expanded = true) {\n        const title = renderer.createSectionTitle(data);\n        title.style.position = 'absolute';\n        title.style.contain = 'strict';\n        title.setAttribute('aria-label', `${data.label} Section`);\n        title.setAttribute('aria-expanded', expanded ? 'true' : 'false');\n        title.setAttribute('aria-controls', data.owner.id);\n        if (expanded) {\n            title.classList.add('lm-mod-expanded');\n        }\n        return title;\n    }\n    Private.createTitle = createTitle;\n})(Private$g || (Private$g = {}));\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 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 {@link PanelLayout}.\n */\nclass Panel extends Widget {\n    /**\n     * Construct a new panel.\n     *\n     * @param options - The options for initializing the panel.\n     */\n    constructor(options = {}) {\n        super();\n        this.addClass('lm-Panel');\n        this.layout = Private$f.createLayout(options);\n    }\n    /**\n     * A read-only array of the widgets in the panel.\n     */\n    get widgets() {\n        return this.layout.widgets;\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    addWidget(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    insertWidget(index, widget) {\n        this.layout.insertWidget(index, widget);\n    }\n}\n/**\n * The namespace for the module implementation details.\n */\nvar Private$f;\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$f || (Private$f = {}));\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 panel which arranges its widgets into resizable sections.\n *\n * #### Notes\n * This class provides a convenience wrapper around a {@link SplitLayout}.\n */\nclass SplitPanel extends Panel {\n    /**\n     * Construct a new split panel.\n     *\n     * @param options - The options for initializing the split panel.\n     */\n    constructor(options = {}) {\n        super({ layout: Private$e.createLayout(options) });\n        this._handleMoved = new Signal(this);\n        this._pressData = null;\n        this.addClass('lm-SplitPanel');\n    }\n    /**\n     * Dispose of the resources held by the panel.\n     */\n    dispose() {\n        this._releaseMouse();\n        super.dispose();\n    }\n    /**\n     * Get the layout orientation for the split panel.\n     */\n    get orientation() {\n        return this.layout.orientation;\n    }\n    /**\n     * Set the layout orientation for the split panel.\n     */\n    set orientation(value) {\n        this.layout.orientation = value;\n    }\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 alignment() {\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 alignment(value) {\n        this.layout.alignment = value;\n    }\n    /**\n     * Get the inter-element spacing for the split panel.\n     */\n    get spacing() {\n        return this.layout.spacing;\n    }\n    /**\n     * Set the inter-element spacing for the split panel.\n     */\n    set spacing(value) {\n        this.layout.spacing = value;\n    }\n    /**\n     * The renderer used by the split panel.\n     */\n    get renderer() {\n        return this.layout.renderer;\n    }\n    /**\n     * A signal emitted when a split handle has moved.\n     */\n    get handleMoved() {\n        return this._handleMoved;\n    }\n    /**\n     * A read-only array of the split handles in the panel.\n     */\n    get handles() {\n        return this.layout.handles;\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    relativeSizes() {\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     * @param update - Update the layout after setting relative sizes.\n     * Default is True.\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    setRelativeSizes(sizes, update = true) {\n        this.layout.setRelativeSizes(sizes, update);\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    handleEvent(event) {\n        switch (event.type) {\n            case 'pointerdown':\n                this._evtPointerDown(event);\n                break;\n            case 'pointermove':\n                this._evtPointerMove(event);\n                break;\n            case 'pointerup':\n                this._evtPointerUp(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    onBeforeAttach(msg) {\n        this.node.addEventListener('pointerdown', this);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(msg) {\n        this.node.removeEventListener('pointerdown', this);\n        this._releaseMouse();\n    }\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    onChildAdded(msg) {\n        msg.child.addClass('lm-SplitPanel-child');\n        this._releaseMouse();\n    }\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    onChildRemoved(msg) {\n        msg.child.removeClass('lm-SplitPanel-child');\n        this._releaseMouse();\n    }\n    /**\n     * Handle the `'keydown'` event for the split panel.\n     */\n    _evtKeyDown(event) {\n        // Stop input events during drag.\n        if (this._pressData) {\n            event.preventDefault();\n            event.stopPropagation();\n        }\n        // Release the mouse if `Escape` is pressed.\n        if (event.keyCode === 27) {\n            this._releaseMouse();\n        }\n    }\n    /**\n     * Handle the `'pointerdown'` event for the split panel.\n     */\n    _evtPointerDown(event) {\n        // Do nothing if the primary button is not pressed.\n        if (event.button !== 0) {\n            return;\n        }\n        // Find the handle which contains the target, if any.\n        let layout = this.layout;\n        let index = ArrayExt.findFirstIndex(layout.handles, 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('pointerup', this, true);\n        document.addEventListener('pointermove', this, true);\n        document.addEventListener('keydown', this, true);\n        document.addEventListener('contextmenu', this, true);\n        // Compute the offset delta for the handle press.\n        let delta;\n        let handle = layout.handles[index];\n        let 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        let style = window.getComputedStyle(handle);\n        let override = Drag.overrideCursor(style.cursor);\n        this._pressData = { index, delta, override };\n    }\n    /**\n     * Handle the `'pointermove'` event for the split panel.\n     */\n    _evtPointerMove(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        let pos;\n        let layout = this.layout;\n        let 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 `'pointerup'` event for the split panel.\n     */\n    _evtPointerUp(event) {\n        // Do nothing if the primary 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    _releaseMouse() {\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        // Emit the handle moved signal.\n        this._handleMoved.emit();\n        // Remove the extra document listeners.\n        document.removeEventListener('keydown', this, true);\n        document.removeEventListener('pointerup', this, true);\n        document.removeEventListener('pointermove', this, true);\n        document.removeEventListener('contextmenu', this, true);\n    }\n}\n/**\n * The namespace for the `SplitPanel` class statics.\n */\n(function (SplitPanel) {\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    class Renderer {\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        createHandle() {\n            let handle = document.createElement('div');\n            handle.className = 'lm-SplitPanel-handle';\n            return handle;\n        }\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$e;\n(function (Private) {\n    /**\n     * Create a split layout for the given panel options.\n     */\n    function createLayout(options) {\n        return (options.layout ||\n            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$e || (Private$e = {}));\n\n// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/**\n * A panel which arranges its widgets into resizable sections separated by a title widget.\n *\n * #### Notes\n * This class provides a convenience wrapper around {@link AccordionLayout}.\n *\n * See also the related [example](../../examples/accordionpanel/index.html) and\n * its [source](https://github.com/jupyterlab/lumino/tree/main/examples/example-accordionpanel).\n */\nclass AccordionPanel extends SplitPanel {\n    /**\n     * Construct a new accordion panel.\n     *\n     * @param options - The options for initializing the accordion panel.\n     *\n     */\n    constructor(options = {}) {\n        super({ ...options, layout: Private$d.createLayout(options) });\n        this._widgetSizesCache = new WeakMap();\n        this._expansionToggled = new Signal(this);\n        this.addClass('lm-AccordionPanel');\n    }\n    /**\n     * The renderer used by the accordion panel.\n     */\n    get renderer() {\n        return this.layout.renderer;\n    }\n    /**\n     * The section title space.\n     *\n     * This is the height if the panel is vertical and the width if it is\n     * horizontal.\n     */\n    get titleSpace() {\n        return this.layout.titleSpace;\n    }\n    set titleSpace(value) {\n        this.layout.titleSpace = value;\n    }\n    /**\n     * A read-only array of the section titles in the panel.\n     */\n    get titles() {\n        return this.layout.titles;\n    }\n    /**\n     * A signal emitted when a widget of the AccordionPanel is collapsed or expanded.\n     */\n    get expansionToggled() {\n        return this._expansionToggled;\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    addWidget(widget) {\n        super.addWidget(widget);\n        widget.title.changed.connect(this._onTitleChanged, this);\n    }\n    /**\n     * Collapse the widget at position `index`.\n     *\n     * #### Notes\n     * If no widget is found for `index`, this will bail.\n     *\n     * @param index Widget index\n     */\n    collapse(index) {\n        const widget = this.layout.widgets[index];\n        if (widget && !widget.isHidden) {\n            this._toggleExpansion(index);\n        }\n    }\n    /**\n     * Expand the widget at position `index`.\n     *\n     * #### Notes\n     * If no widget is found for `index`, this will bail.\n     *\n     * @param index Widget index\n     */\n    expand(index) {\n        const widget = this.layout.widgets[index];\n        if (widget && widget.isHidden) {\n            this._toggleExpansion(index);\n        }\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    insertWidget(index, widget) {\n        super.insertWidget(index, widget);\n        widget.title.changed.connect(this._onTitleChanged, this);\n    }\n    /**\n     * Handle the DOM events for the accordion 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    handleEvent(event) {\n        super.handleEvent(event);\n        switch (event.type) {\n            case 'click':\n                this._evtClick(event);\n                break;\n            case 'keydown':\n                this._eventKeyDown(event);\n                break;\n        }\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(msg) {\n        this.node.addEventListener('click', this);\n        this.node.addEventListener('keydown', this);\n        super.onBeforeAttach(msg);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(msg) {\n        super.onAfterDetach(msg);\n        this.node.removeEventListener('click', this);\n        this.node.removeEventListener('keydown', this);\n    }\n    /**\n     * Handle the `changed` signal of a title object.\n     */\n    _onTitleChanged(sender) {\n        const index = ArrayExt.findFirstIndex(this.widgets, widget => {\n            return widget.contains(sender.owner);\n        });\n        if (index >= 0) {\n            this.layout.updateTitle(index, sender.owner);\n            this.update();\n        }\n    }\n    /**\n     * Compute the size of widgets in this panel on the title click event.\n     * On closing, the size of the widget is cached and we will try to expand\n     * the last opened widget.\n     * On opening, we will use the cached size if it is available to restore the\n     * widget.\n     * In both cases, if we can not compute the size of widgets, we will let\n     * `SplitLayout` decide.\n     *\n     * @param index - The index of widget to be opened of closed\n     *\n     * @returns Relative size of widgets in this panel, if this size can\n     * not be computed, return `undefined`\n     */\n    _computeWidgetSize(index) {\n        const layout = this.layout;\n        const widget = layout.widgets[index];\n        if (!widget) {\n            return undefined;\n        }\n        const isHidden = widget.isHidden;\n        const widgetSizes = layout.absoluteSizes();\n        const delta = (isHidden ? -1 : 1) * this.spacing;\n        const totalSize = widgetSizes.reduce((prev, curr) => prev + curr);\n        let newSize = [...widgetSizes];\n        if (!isHidden) {\n            // Hide the widget\n            const currentSize = widgetSizes[index];\n            this._widgetSizesCache.set(widget, currentSize);\n            newSize[index] = 0;\n            const widgetToCollapse = newSize.map(sz => sz > 0).lastIndexOf(true);\n            if (widgetToCollapse === -1) {\n                // All widget are closed, let the `SplitLayout` compute widget sizes.\n                return undefined;\n            }\n            newSize[widgetToCollapse] =\n                widgetSizes[widgetToCollapse] + currentSize + delta;\n        }\n        else {\n            // Show the widget\n            const previousSize = this._widgetSizesCache.get(widget);\n            if (!previousSize) {\n                // Previous size is unavailable, let the `SplitLayout` compute widget sizes.\n                return undefined;\n            }\n            newSize[index] += previousSize;\n            const widgetToCollapse = newSize\n                .map(sz => sz - previousSize > 0)\n                .lastIndexOf(true);\n            if (widgetToCollapse === -1) {\n                // Can not reduce the size of one widget, reduce all opened widgets\n                // proportionally with its size.\n                newSize.forEach((_, idx) => {\n                    if (idx !== index) {\n                        newSize[idx] -=\n                            (widgetSizes[idx] / totalSize) * (previousSize - delta);\n                    }\n                });\n            }\n            else {\n                newSize[widgetToCollapse] -= previousSize - delta;\n            }\n        }\n        return newSize.map(sz => sz / (totalSize + delta));\n    }\n    /**\n     * Handle the `'click'` event for the accordion panel\n     */\n    _evtClick(event) {\n        const target = event.target;\n        if (target) {\n            const index = ArrayExt.findFirstIndex(this.titles, title => {\n                return title.contains(target);\n            });\n            if (index >= 0) {\n                event.preventDefault();\n                event.stopPropagation();\n                this._toggleExpansion(index);\n            }\n        }\n    }\n    /**\n     * Handle the `'keydown'` event for the accordion panel.\n     */\n    _eventKeyDown(event) {\n        if (event.defaultPrevented) {\n            return;\n        }\n        const target = event.target;\n        let handled = false;\n        if (target) {\n            const index = ArrayExt.findFirstIndex(this.titles, title => {\n                return title.contains(target);\n            });\n            if (index >= 0) {\n                const keyCode = event.keyCode.toString();\n                // If Space or Enter is pressed on title, emulate click event\n                if (event.key.match(/Space|Enter/) || keyCode.match(/13|32/)) {\n                    target.click();\n                    handled = true;\n                }\n                else if (this.orientation === 'horizontal'\n                    ? event.key.match(/ArrowLeft|ArrowRight/) || keyCode.match(/37|39/)\n                    : event.key.match(/ArrowUp|ArrowDown/) || keyCode.match(/38|40/)) {\n                    // If Up or Down (for vertical) / Left or Right (for horizontal) is pressed on title, loop on titles\n                    const direction = event.key.match(/ArrowLeft|ArrowUp/) || keyCode.match(/37|38/)\n                        ? -1\n                        : 1;\n                    const length = this.titles.length;\n                    const newIndex = (index + length + direction) % length;\n                    this.titles[newIndex].focus();\n                    handled = true;\n                }\n                else if (event.key === 'End' || keyCode === '35') {\n                    // If End is pressed on title, focus on the last title\n                    this.titles[this.titles.length - 1].focus();\n                    handled = true;\n                }\n                else if (event.key === 'Home' || keyCode === '36') {\n                    // If Home is pressed on title, focus on the first title\n                    this.titles[0].focus();\n                    handled = true;\n                }\n            }\n            if (handled) {\n                event.preventDefault();\n            }\n        }\n    }\n    _toggleExpansion(index) {\n        const title = this.titles[index];\n        const widget = this.layout.widgets[index];\n        const newSize = this._computeWidgetSize(index);\n        if (newSize) {\n            this.setRelativeSizes(newSize, false);\n        }\n        if (widget.isHidden) {\n            title.classList.add('lm-mod-expanded');\n            title.setAttribute('aria-expanded', 'true');\n            widget.show();\n        }\n        else {\n            title.classList.remove('lm-mod-expanded');\n            title.setAttribute('aria-expanded', 'false');\n            widget.hide();\n        }\n        // Emit the expansion state signal.\n        this._expansionToggled.emit(index);\n    }\n}\n/**\n * The namespace for the `AccordionPanel` class statics.\n */\n(function (AccordionPanel) {\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    class Renderer extends SplitPanel.Renderer {\n        constructor() {\n            super();\n            /**\n             * A selector which matches any title node in the accordion.\n             */\n            this.titleClassName = 'lm-AccordionPanel-title';\n            this._titleID = 0;\n            this._titleKeys = new WeakMap();\n            this._uuid = ++Renderer._nInstance;\n        }\n        /**\n         * Render the collapse indicator for a section title.\n         *\n         * @param data - The data to use for rendering the section title.\n         *\n         * @returns A element representing the collapse indicator.\n         */\n        createCollapseIcon(data) {\n            return document.createElement('span');\n        }\n        /**\n         * Render the element for a section title.\n         *\n         * @param data - The data to use for rendering the section title.\n         *\n         * @returns A element representing the section title.\n         */\n        createSectionTitle(data) {\n            const handle = document.createElement('h3');\n            handle.setAttribute('tabindex', '0');\n            handle.id = this.createTitleKey(data);\n            handle.className = this.titleClassName;\n            for (const aData in data.dataset) {\n                handle.dataset[aData] = data.dataset[aData];\n            }\n            const collapser = handle.appendChild(this.createCollapseIcon(data));\n            collapser.className = 'lm-AccordionPanel-titleCollapser';\n            const label = handle.appendChild(document.createElement('span'));\n            label.className = 'lm-AccordionPanel-titleLabel';\n            label.textContent = data.label;\n            label.title = data.caption || data.label;\n            return handle;\n        }\n        /**\n         * Create a unique render key for the title.\n         *\n         * @param data - The data to use for the title.\n         *\n         * @returns The unique render key for the title.\n         *\n         * #### Notes\n         * This method caches the key against the section title the first time\n         * the key is generated.\n         */\n        createTitleKey(data) {\n            let key = this._titleKeys.get(data);\n            if (key === undefined) {\n                key = `title-key-${this._uuid}-${this._titleID++}`;\n                this._titleKeys.set(data, key);\n            }\n            return key;\n        }\n    }\n    Renderer._nInstance = 0;\n    AccordionPanel.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    AccordionPanel.defaultRenderer = new Renderer();\n})(AccordionPanel || (AccordionPanel = {}));\nvar Private$d;\n(function (Private) {\n    /**\n     * Create an accordion layout for the given panel options.\n     *\n     * @param options Panel options\n     * @returns Panel layout\n     */\n    function createLayout(options) {\n        return (options.layout ||\n            new AccordionLayout({\n                renderer: options.renderer || AccordionPanel.defaultRenderer,\n                orientation: options.orientation,\n                alignment: options.alignment,\n                spacing: options.spacing,\n                titleSpace: options.titleSpace\n            }));\n    }\n    Private.createLayout = createLayout;\n})(Private$d || (Private$d = {}));\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 layout which arranges its widgets in a single row or column.\n */\nclass BoxLayout extends PanelLayout {\n    /**\n     * Construct a new box layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    constructor(options = {}) {\n        super();\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 = Utils$1.clampDimension(options.spacing);\n        }\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    dispose() {\n        // Dispose of the layout items.\n        for (const item of this._items) {\n            item.dispose();\n        }\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.dispose();\n    }\n    /**\n     * Get the layout direction for the box layout.\n     */\n    get direction() {\n        return this._direction;\n    }\n    /**\n     * Set the layout direction for the box layout.\n     */\n    set direction(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    /**\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 alignment() {\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 alignment(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    /**\n     * Get the inter-element spacing for the box layout.\n     */\n    get spacing() {\n        return this._spacing;\n    }\n    /**\n     * Set the inter-element spacing for the box layout.\n     */\n    set spacing(value) {\n        value = Utils$1.clampDimension(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    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    init() {\n        this.parent.dataset['direction'] = this.direction;\n        this.parent.dataset['alignment'] = this.alignment;\n        super.init();\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    attachWidget(index, widget) {\n        // Create and add a new layout item for the widget.\n        ArrayExt.insert(this._items, index, new LayoutItem(widget));\n        // Create and add a new sizer for the widget.\n        ArrayExt.insert(this._sizers, index, new BoxSizer());\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    moveWidget(fromIndex, toIndex, widget) {\n        // Move the layout item for the widget.\n        ArrayExt.move(this._items, fromIndex, toIndex);\n        // Move the sizer for the widget.\n        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    detachWidget(index, widget) {\n        // Remove the layout item for the widget.\n        let item = ArrayExt.removeAt(this._items, index);\n        // Remove the sizer for the widget.\n        ArrayExt.removeAt(this._sizers, index);\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    onBeforeShow(msg) {\n        super.onBeforeShow(msg);\n        this.parent.update();\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(msg) {\n        super.onBeforeAttach(msg);\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    onChildShown(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    onChildHidden(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    onResize(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    onUpdateRequest(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    onFitRequest(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    _fit() {\n        // Compute the visible item count.\n        let nVisible = 0;\n        for (let 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        let horz = Private$c.isHorizontal(this._direction);\n        let minW = horz ? this._fixed : 0;\n        let minH = horz ? 0 : this._fixed;\n        // Update the sizers and computed minimum size.\n        for (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item and corresponding box sizer.\n            let item = this._items[i];\n            let 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        let box = (this._box = ElementExt.boxSizing(this.parent.node));\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        let 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            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            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    _update(offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Compute the visible item count.\n        let nVisible = 0;\n        for (let 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 = ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the layout area adjusted for border and padding.\n        let top = this._box.paddingTop;\n        let left = this._box.paddingLeft;\n        let width = offsetWidth - this._box.horizontalSum;\n        let height = offsetHeight - this._box.verticalSum;\n        // Distribute the layout space and adjust the start position.\n        let 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        let extra = 0;\n        let 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 (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            let item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Fetch the computed size for the widget.\n            let 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}\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$c.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$c.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$c.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$c.sizeBasisProperty.set(widget, value);\n    }\n    BoxLayout.setSizeBasis = setSizeBasis;\n})(BoxLayout || (BoxLayout = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$c;\n(function (Private) {\n    /**\n     * The property descriptor for a widget stretch factor.\n     */\n    Private.stretchProperty = new AttachedProperty({\n        name: 'stretch',\n        create: () => 0,\n        coerce: (owner, value) => 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 AttachedProperty({\n        name: 'sizeBasis',\n        create: () => 0,\n        coerce: (owner, value) => 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$c || (Private$c = {}));\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 panel which arranges its widgets in a single row or column.\n *\n * #### Notes\n * This class provides a convenience wrapper around a {@link BoxLayout}.\n */\nclass BoxPanel extends Panel {\n    /**\n     * Construct a new box panel.\n     *\n     * @param options - The options for initializing the box panel.\n     */\n    constructor(options = {}) {\n        super({ layout: Private$b.createLayout(options) });\n        this.addClass('lm-BoxPanel');\n    }\n    /**\n     * Get the layout direction for the box panel.\n     */\n    get direction() {\n        return this.layout.direction;\n    }\n    /**\n     * Set the layout direction for the box panel.\n     */\n    set direction(value) {\n        this.layout.direction = value;\n    }\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 alignment() {\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 alignment(value) {\n        this.layout.alignment = value;\n    }\n    /**\n     * Get the inter-element spacing for the box panel.\n     */\n    get spacing() {\n        return this.layout.spacing;\n    }\n    /**\n     * Set the inter-element spacing for the box panel.\n     */\n    set spacing(value) {\n        this.layout.spacing = value;\n    }\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    onChildAdded(msg) {\n        msg.child.addClass('lm-BoxPanel-child');\n    }\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    onChildRemoved(msg) {\n        msg.child.removeClass('lm-BoxPanel-child');\n    }\n}\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$b;\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$b || (Private$b = {}));\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 widget which displays command items as a searchable palette.\n */\nclass CommandPalette extends Widget {\n    /**\n     * Construct a new command palette.\n     *\n     * @param options - The options for initializing the palette.\n     */\n    constructor(options) {\n        super({ node: Private$a.createNode() });\n        this._activeIndex = -1;\n        this._itemTriggered = new Signal(this);\n        this._items = [];\n        this._results = null;\n        this.addClass('lm-CommandPalette');\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    }\n    /**\n     * Dispose of the resources held by the widget.\n     */\n    dispose() {\n        this._items.length = 0;\n        this._results = null;\n        super.dispose();\n    }\n    /**\n     * A signal emitted when the user triggers a command item.\n     *\n     * #### Notes\n     * This signal is emitted when an enabled item is clicked, or when\n     * `Enter` is pressed while an enabled item is active. It is not\n     * emitted for a header, or for a command which is executed by other\n     * means, such as a key binding or a menu.\n     *\n     * The signal is emitted before the command is executed and before\n     * the query text is cleared.\n     */\n    get itemTriggered() {\n        return this._itemTriggered;\n    }\n    /**\n     * The command palette search node.\n     *\n     * #### Notes\n     * This is the node which contains the search-related elements.\n     */\n    get searchNode() {\n        return this.node.getElementsByClassName('lm-CommandPalette-search')[0];\n    }\n    /**\n     * The command palette input node.\n     *\n     * #### Notes\n     * This is the actual input node for the search area.\n     */\n    get inputNode() {\n        return this.node.getElementsByClassName('lm-CommandPalette-input')[0];\n    }\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 contentNode() {\n        return this.node.getElementsByClassName('lm-CommandPalette-content')[0];\n    }\n    /**\n     * A read-only array of the command items in the palette.\n     */\n    get items() {\n        return this._items;\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    addItem(options) {\n        // Create a new command item for the options.\n        let item = Private$a.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    addItems(items) {\n        const newItems = items.map(item => Private$a.createItem(this.commands, item));\n        newItems.forEach(item => 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    removeItem(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    removeItemAt(index) {\n        // Remove the item from the array.\n        let item = 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    clearItems() {\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    refresh() {\n        this._results = null;\n        if (this.inputNode.value !== '') {\n            let clear = this.node.getElementsByClassName('lm-close-icon')[0];\n            clear.style.display = 'inherit';\n        }\n        else {\n            let 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    handleEvent(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     * Create the search results for a query.\n     *\n     * @param query - The raw text of the search input.\n     *\n     * @returns The search results, in display order.\n     *\n     * #### Notes\n     * The default implementation of this method returns the results of\n     * `CommandPalette.search()` for the palette items.\n     *\n     * The palette renders every returned result, so the results should\n     * not include items which are not visible. Triggering a header result\n     * replaces the query with the header category.\n     *\n     * The results are cached until `refresh()` is called. A subclass\n     * which uses external state should call `refresh()` when that state\n     * changes.\n     *\n     * A subclass may reimplement this method as needed.\n     */\n    search(query) {\n        return CommandPalette.search(this.items, query);\n    }\n    /**\n     * Get the index of the result to activate for new search results.\n     *\n     * @param query - The raw text of the search input.\n     *\n     * @param results - The search results returned by `search()`.\n     *\n     * @returns The index of the result to activate, or `-1` for none.\n     *\n     * #### Notes\n     * The default implementation of this method returns the index of the\n     * first enabled item when the query is not empty, and `-1` otherwise.\n     *\n     * The returned index should refer to an enabled item result.\n     *\n     * A subclass may reimplement this method as needed.\n     */\n    initialActiveIndex(query, results) {\n        return query ? ArrayExt.findFirstIndex(results, Private$a.canActivate) : -1;\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(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    onAfterDetach(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 `'after-show'` message.\n     */\n    onAfterShow(msg) {\n        this.update();\n        super.onAfterShow(msg);\n    }\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     */\n    onActivateRequest(msg) {\n        if (this.isAttached) {\n            let input = this.inputNode;\n            input.focus();\n            input.select();\n        }\n    }\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    onUpdateRequest(msg) {\n        if (!this.isVisible) {\n            // Ensure to clear the content if the widget is hidden\n            VirtualDOM.render(null, this.contentNode);\n            return;\n        }\n        // Fetch the current query text and content node.\n        let query = this.inputNode.value;\n        let contentNode = this.contentNode;\n        // Ensure the search results are generated.\n        let results = this._results;\n        if (!results) {\n            // Generate and store the new search results.\n            results = this._results = this.search(query);\n            // Reset the active index.\n            this._activeIndex = this.initialActiveIndex(query, results);\n        }\n        // If there is no query and no results, clear the content.\n        if (!query && results.length === 0) {\n            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            let content = this.renderer.renderEmptyMessage({ query });\n            VirtualDOM.render(content, contentNode);\n            return;\n        }\n        // Create the render content for the search results.\n        let renderer = this.renderer;\n        let activeIndex = this._activeIndex;\n        let content = new Array(results.length);\n        for (let i = 0, n = results.length; i < n; ++i) {\n            let result = results[i];\n            if (result.type === 'header') {\n                let indices = result.indices;\n                let category = result.category;\n                content[i] = renderer.renderHeader({ category, indices });\n            }\n            else {\n                let item = result.item;\n                let indices = result.indices;\n                let active = i === activeIndex;\n                content[i] = renderer.renderItem({ item, indices, active });\n            }\n        }\n        // Render the search result content.\n        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            let element = contentNode.children[activeIndex];\n            ElementExt.scrollIntoViewIfNeeded(contentNode, element);\n        }\n    }\n    /**\n     * Handle the `'click'` event for the command palette.\n     */\n    _evtClick(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        let index = ArrayExt.findFirstIndex(this.contentNode.children, 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    _evtKeyDown(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    _activateNextItem() {\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        let ai = this._activeIndex;\n        let n = this._results.length;\n        let start = ai < n - 1 ? ai + 1 : 0;\n        let stop = start === 0 ? n - 1 : start - 1;\n        this._activeIndex = ArrayExt.findFirstIndex(this._results, Private$a.canActivate, start, stop);\n        // Schedule an update of the items.\n        this.update();\n    }\n    /**\n     * Activate the previous enabled command item.\n     */\n    _activatePreviousItem() {\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        let ai = this._activeIndex;\n        let n = this._results.length;\n        let start = ai <= 0 ? n - 1 : ai - 1;\n        let stop = start === n - 1 ? 0 : start + 1;\n        this._activeIndex = ArrayExt.findLastIndex(this._results, Private$a.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    _execute(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        let 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            let 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        // Emit the item triggered signal before the execution.\n        this._itemTriggered.emit(part.item);\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    _toggleFocused() {\n        let focused = document.activeElement === this.inputNode;\n        this.toggleClass('lm-mod-focused', focused);\n    }\n    /**\n     * A signal handler for generic command changes.\n     */\n    _onGenericChange() {\n        this.refresh();\n    }\n}\n/**\n * The namespace for the `CommandPalette` class statics.\n */\n(function (CommandPalette) {\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    class Renderer {\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        renderHeader(data) {\n            let content = this.formatHeader(data);\n            return h.li({ className: 'lm-CommandPalette-header' }, 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        renderItem(data) {\n            let className = this.createItemClass(data);\n            let dataset = this.createItemDataset(data);\n            if (data.item.isToggleable) {\n                return h.li({\n                    className,\n                    dataset,\n                    role: 'menuitemcheckbox',\n                    'aria-checked': `${data.item.isToggled}`\n                }, this.renderItemIcon(data), this.renderItemContent(data), this.renderItemShortcut(data));\n            }\n            return h.li({\n                className,\n                dataset,\n                role: 'menuitem'\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        renderEmptyMessage(data) {\n            let content = this.formatEmptyMessage(data);\n            return h.li({ className: 'lm-CommandPalette-emptyMessage' }, 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        renderItemIcon(data) {\n            let className = this.createIconClass(data);\n            // If data.item.icon is undefined, it will be ignored.\n            return h.div({ 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        renderItemContent(data) {\n            return h.div({ className: 'lm-CommandPalette-itemContent' }, 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        renderItemLabel(data) {\n            let content = this.formatItemLabel(data);\n            return h.div({ className: 'lm-CommandPalette-itemLabel' }, 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        renderItemCaption(data) {\n            let content = this.formatItemCaption(data);\n            return h.div({ className: 'lm-CommandPalette-itemCaption' }, 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        renderItemShortcut(data) {\n            let content = this.formatItemShortcut(data);\n            return h.div({ className: 'lm-CommandPalette-itemShortcut' }, 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        createItemClass(data) {\n            // Set up the initial class name.\n            let name = 'lm-CommandPalette-item';\n            // Add the boolean state classes.\n            if (!data.item.isEnabled) {\n                name += ' lm-mod-disabled';\n            }\n            if (data.item.isToggled) {\n                name += ' lm-mod-toggled';\n            }\n            if (data.active) {\n                name += ' lm-mod-active';\n            }\n            // Add the extra class.\n            let 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        createItemDataset(data) {\n            return { ...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        createIconClass(data) {\n            let name = 'lm-CommandPalette-itemIcon';\n            let 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        formatHeader(data) {\n            if (!data.indices || data.indices.length === 0) {\n                return data.category;\n            }\n            return StringExt.highlight(data.category, data.indices, 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        formatEmptyMessage(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        formatItemShortcut(data) {\n            let kb = data.item.keyBinding;\n            return kb ? CommandRegistry.formatKeystroke(kb.keys) : 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        formatItemLabel(data) {\n            if (!data.indices || data.indices.length === 0) {\n                return data.item.label;\n            }\n            return StringExt.highlight(data.item.label, data.indices, 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        formatItemCaption(data) {\n            return data.item.caption;\n        }\n    }\n    CommandPalette.Renderer = Renderer;\n    /**\n     * The default `Renderer` instance.\n     */\n    CommandPalette.defaultRenderer = new Renderer();\n    /**\n     * Search an array of command items for fuzzy matches.\n     *\n     * @param items - The command items to search.\n     *\n     * @param query - The query text to match against the items.\n     *\n     * @returns The search results for the query.\n     *\n     * #### Notes\n     * Items which are not visible are excluded. Whitespace in the query\n     * is ignored. An empty query matches all items, ordered by category,\n     * rank, and label. Otherwise, the matched items are ordered by match\n     * quality.\n     *\n     * Each run of items which share a category is preceded by a header\n     * result for that category.\n     *\n     * This function is used by the default implementation of the protected\n     * `search()` method of a command palette. A subclass can use it to\n     * compose the default results with custom results.\n     */\n    function search(items, query) {\n        return Private$a.search(items, query);\n    }\n    CommandPalette.search = search;\n})(CommandPalette || (CommandPalette = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$a;\n(function (Private) {\n    /**\n     * Create the DOM node for a command palette.\n     */\n    function createNode() {\n        let node = document.createElement('div');\n        let search = document.createElement('div');\n        let wrapper = document.createElement('div');\n        let input = document.createElement('input');\n        let content = document.createElement('ul');\n        let 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        content.setAttribute('role', 'menu');\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        let 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        let scores = [];\n        // Iterate over the items and match against the query.\n        for (let i = 0, n = items.length; i < n; ++i) {\n            // Ignore items which are not visible.\n            let 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 /* MatchType.Default */,\n                    categoryIndices: null,\n                    labelIndices: null,\n                    score: 0,\n                    item\n                });\n                continue;\n            }\n            // Run the fuzzy search for the item and query.\n            let 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        let category = item.category.toLowerCase();\n        let label = item.label.toLowerCase();\n        let source = `${category} ${label}`;\n        // Set up the match score and indices array.\n        let score = Infinity;\n        let indices = null;\n        // The regex for search word boundaries\n        let rgx = /\\b\\w/g;\n        // Search the source by word boundary.\n        // eslint-disable-next-line no-constant-condition\n        while (true) {\n            // Find the next word boundary in the source.\n            let 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            let match = 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.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        let pivot = category.length + 1;\n        // Find the slice index to separate matched indices.\n        let j = ArrayExt.lowerBound(indices, pivot, (a, b) => a - b);\n        // Extract the matched category and label indices.\n        let categoryIndices = indices.slice(0, j);\n        let labelIndices = indices.slice(j);\n        // Adjust the label indices for the pivot offset.\n        for (let 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 /* MatchType.Label */,\n                categoryIndices: null,\n                labelIndices,\n                score,\n                item\n            };\n        }\n        // Handle a pure category match.\n        if (labelIndices.length === 0) {\n            return {\n                matchType: 1 /* MatchType.Category */,\n                categoryIndices,\n                labelIndices: null,\n                score,\n                item\n            };\n        }\n        // Handle a split match.\n        return {\n            matchType: 2 /* MatchType.Split */,\n            categoryIndices,\n            labelIndices,\n            score,\n            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        let m1 = a.matchType - b.matchType;\n        if (m1 !== 0) {\n            return m1;\n        }\n        // Otherwise, compare based on the match score.\n        let d1 = a.score - b.score;\n        if (d1 !== 0) {\n            return d1;\n        }\n        // Find the match index based on the match type.\n        let i1 = 0;\n        let i2 = 0;\n        switch (a.matchType) {\n            case 0 /* MatchType.Label */:\n                i1 = a.labelIndices[0];\n                i2 = b.labelIndices[0];\n                break;\n            case 1 /* MatchType.Category */:\n            case 2 /* MatchType.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        let d2 = a.item.category.localeCompare(b.item.category);\n        if (d2 !== 0) {\n            return d2;\n        }\n        // Otherwise, compare by rank.\n        let r1 = a.item.rank;\n        let 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 the search results array.\n        let results = [];\n        // Iterate over each score in the array.\n        for (let i = 0, n = scores.length; i < n; ++i) {\n            // Extract the current item and indices.\n            let { item, categoryIndices, labelIndices } = scores[i];\n            // Extract the category for the current item.\n            let category = item.category;\n            // Is this the same category as the preceding result?\n            if (i === 0 || category !== scores[i - 1].item.category) {\n                // Add the header result for the category.\n                results.push({ type: 'header', category, indices: categoryIndices });\n            }\n            // Create the item result for the score.\n            results.push({ type: 'item', item, indices: labelIndices });\n        }\n        // Return the final results.\n        return results;\n    }\n    /**\n     * A concrete implementation of `CommandPalette.IItem`.\n     */\n    class CommandItem {\n        /**\n         * Construct a new command item.\n         */\n        constructor(commands, options) {\n            this._commands = commands;\n            this.category = normalizeCategory(options.category);\n            this.command = options.command;\n            this.args = options.args || JSONExt.emptyObject;\n            this.rank = options.rank !== undefined ? options.rank : Infinity;\n        }\n        /**\n         * The display label for the command item.\n         */\n        get label() {\n            return this._commands.label(this.command, this.args);\n        }\n        /**\n         * The icon renderer for the command item.\n         */\n        get icon() {\n            return this._commands.icon(this.command, this.args);\n        }\n        /**\n         * The icon class for the command item.\n         */\n        get iconClass() {\n            return this._commands.iconClass(this.command, this.args);\n        }\n        /**\n         * The icon label for the command item.\n         */\n        get iconLabel() {\n            return this._commands.iconLabel(this.command, this.args);\n        }\n        /**\n         * The display caption for the command item.\n         */\n        get caption() {\n            return this._commands.caption(this.command, this.args);\n        }\n        /**\n         * The extra class name for the command item.\n         */\n        get className() {\n            return this._commands.className(this.command, this.args);\n        }\n        /**\n         * The dataset for the command item.\n         */\n        get dataset() {\n            return this._commands.dataset(this.command, this.args);\n        }\n        /**\n         * Whether the command item is enabled.\n         */\n        get isEnabled() {\n            return this._commands.isEnabled(this.command, this.args);\n        }\n        /**\n         * Whether the command item is toggled.\n         */\n        get isToggled() {\n            return this._commands.isToggled(this.command, this.args);\n        }\n        /**\n         * Whether the command item is toggleable.\n         */\n        get isToggleable() {\n            return this._commands.isToggleable(this.command, this.args);\n        }\n        /**\n         * Whether the command item is visible.\n         */\n        get isVisible() {\n            return this._commands.isVisible(this.command, this.args);\n        }\n        /**\n         * The key binding for the command item.\n         */\n        get keyBinding() {\n            let { command, args } = this;\n            return (ArrayExt.findLastValue(this._commands.keyBindings, kb => {\n                return kb.command === command && JSONExt.deepEqual(kb.args, args);\n            }) || null);\n        }\n    }\n})(Private$a || (Private$a = {}));\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 widget which displays items as a canonical menu.\n */\nclass Menu extends Widget {\n    /**\n     * Construct a new menu.\n     *\n     * @param options - The options for initializing the menu.\n     */\n    constructor(options) {\n        super({ node: Private$9.createNode() });\n        this._childIndex = -1;\n        this._activeIndex = -1;\n        this._openTimerID = 0;\n        this._closeTimerID = 0;\n        this._pendingTouchActivation = false;\n        this._items = [];\n        this._childMenu = null;\n        this._parentMenu = null;\n        this._aboutToClose = new Signal(this);\n        this._menuRequested = new Signal(this);\n        this.addClass('lm-Menu');\n        this.setFlag(Widget.Flag.DisallowLayout);\n        this.commands = options.commands;\n        this.renderer = options.renderer || Menu.defaultRenderer;\n    }\n    /**\n     * Dispose of the resources held by the menu.\n     */\n    dispose() {\n        this.close();\n        this._items.length = 0;\n        super.dispose();\n    }\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 aboutToClose() {\n        return this._aboutToClose;\n    }\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 menuRequested() {\n        return this._menuRequested;\n    }\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 parentMenu() {\n        return this._parentMenu;\n    }\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 childMenu() {\n        return this._childMenu;\n    }\n    /**\n     * The root menu of the menu hierarchy.\n     */\n    get rootMenu() {\n        // eslint-disable-next-line @typescript-eslint/no-this-alias\n        let menu = this;\n        while (menu._parentMenu) {\n            menu = menu._parentMenu;\n        }\n        return menu;\n    }\n    /**\n     * The leaf menu of the menu hierarchy.\n     */\n    get leafMenu() {\n        // eslint-disable-next-line @typescript-eslint/no-this-alias\n        let menu = this;\n        while (menu._childMenu) {\n            menu = menu._childMenu;\n        }\n        return menu;\n    }\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 contentNode() {\n        return this.node.getElementsByClassName('lm-Menu-content')[0];\n    }\n    /**\n     * Get the currently active menu item.\n     */\n    get activeItem() {\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 activeItem(value) {\n        this.activeIndex = value ? this._items.indexOf(value) : -1;\n    }\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 activeIndex() {\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 activeIndex(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$9.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        // Make active element in focus\n        if (this._activeIndex >= 0 &&\n            this.contentNode.childNodes[this._activeIndex]) {\n            this.contentNode.childNodes[this._activeIndex].focus();\n        }\n        // schedule an update of the items.\n        this.update();\n    }\n    /**\n     * A read-only array of the menu items in the menu.\n     */\n    get items() {\n        return this._items;\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    activateNextItem() {\n        let n = this._items.length;\n        let ai = this._activeIndex;\n        let start = ai < n - 1 ? ai + 1 : 0;\n        let stop = start === 0 ? n - 1 : start - 1;\n        this.activeIndex = ArrayExt.findFirstIndex(this._items, Private$9.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    activatePreviousItem() {\n        let n = this._items.length;\n        let ai = this._activeIndex;\n        let start = ai <= 0 ? n - 1 : ai - 1;\n        let stop = start === n - 1 ? 0 : start + 1;\n        this.activeIndex = ArrayExt.findLastIndex(this._items, Private$9.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    triggerActiveItem() {\n        // Bail if the menu is not attached.\n        if (!this.isAttached) {\n            return;\n        }\n        // Bail if there is no active item.\n        let 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        let { command, args } = item;\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    addItem(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    insertItem(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        let i = Math.max(0, Math.min(index, this._items.length));\n        // Create the item for the options.\n        let item = Private$9.createItem(this, options);\n        // Insert the item into the array.\n        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    removeItem(item) {\n        let index = this._items.indexOf(item);\n        if (index === -1) {\n            return;\n        }\n        this.removeItemAt(index);\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    removeItemAt(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        let item = 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    clearItems() {\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     * The menu will be attached under the `host` element in the DOM\n     * (or `document.body` if `host` is `null`) and before the `ref`\n     * element (or as the last child of `host` if `ref` is `null`).\n     * The menu may be displayed outside of the `host` element\n     * following the rules of CSS absolute positioning.\n     *\n     * This is a no-op if the menu is already attached to the DOM.\n     */\n    open(x, y, options = {}) {\n        var _a, _b, _c;\n        // Bail early if the menu is already attached.\n        if (this.isAttached) {\n            return;\n        }\n        // Extract the menu options.\n        let forceX = options.forceX || false;\n        let forceY = options.forceY || false;\n        const host = (_a = options.host) !== null && _a !== void 0 ? _a : null;\n        const ref = (_b = options.ref) !== null && _b !== void 0 ? _b : null;\n        const horizontalAlignment = (_c = options.horizontalAlignment) !== null && _c !== void 0 ? _c : (document.documentElement.dir === 'rtl' ? 'right' : 'left');\n        // Open the menu as a root menu.\n        Private$9.openRootMenu(this, x, y, forceX, forceY, horizontalAlignment, host, ref);\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    handleEvent(event) {\n        switch (event.type) {\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'click':\n                this._evtClick(event);\n                break;\n            case 'pointerup':\n                this._evtPointerUp(event);\n                break;\n            case 'pointermove':\n                this._evtPointerMove(event);\n                break;\n            case 'pointerenter':\n                this._evtPointerEnter(event);\n                break;\n            case 'pointerleave':\n                this._evtPointerLeave(event);\n                break;\n            case 'pointerdown':\n                this._evtPointerDown(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    onBeforeAttach(msg) {\n        this.node.addEventListener('keydown', this);\n        this.node.addEventListener('click', this);\n        this.node.addEventListener('pointerup', this);\n        this.node.addEventListener('pointermove', this);\n        this.node.addEventListener('pointerenter', this);\n        this.node.addEventListener('pointerleave', this);\n        this.node.addEventListener('contextmenu', this);\n        document.addEventListener('pointerdown', this, true);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(msg) {\n        this.node.removeEventListener('keydown', this);\n        this.node.removeEventListener('click', this);\n        this.node.removeEventListener('pointerup', this);\n        this.node.removeEventListener('pointermove', this);\n        this.node.removeEventListener('pointerenter', this);\n        this.node.removeEventListener('pointerleave', this);\n        this.node.removeEventListener('contextmenu', this);\n        document.removeEventListener('pointerdown', this, true);\n        this._pendingTouchActivation = false;\n    }\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     */\n    onActivateRequest(msg) {\n        if (this.isAttached) {\n            this.node.focus();\n        }\n    }\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    onUpdateRequest(msg) {\n        let items = this._items;\n        let renderer = this.renderer;\n        let activeIndex = this._activeIndex;\n        let collapsedFlags = Private$9.computeCollapsed(items);\n        let content = new Array(items.length);\n        for (let i = 0, n = items.length; i < n; ++i) {\n            let item = items[i];\n            let active = i === activeIndex;\n            let collapsed = collapsedFlags[i];\n            content[i] = renderer.renderItem({\n                item,\n                active,\n                collapsed,\n                onfocus: () => {\n                    this.activeIndex = i;\n                }\n            });\n        }\n        VirtualDOM.render(content, this.contentNode);\n    }\n    /**\n     * A message handler invoked on a `'close-request'` message.\n     */\n    onCloseRequest(msg) {\n        // Cancel the pending timers.\n        this._cancelOpenTimer();\n        this._cancelCloseTimer();\n        // Reset the active index.\n        this.activeIndex = -1;\n        this._pendingTouchActivation = false;\n        // Close any open child menu.\n        let 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        let 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.onCloseRequest(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    _evtKeyDown(event) {\n        // A menu handles all keydown events.\n        event.preventDefault();\n        event.stopPropagation();\n        // Fetch the key code for the event.\n        let 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            let 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        let key = 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        let start = this._activeIndex + 1;\n        let result = Private$9.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 `'pointerup'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    _evtPointerUp(event) {\n        if (event.button !== 0) {\n            return;\n        }\n        if (Utils$1.isTouchEvent(event)) {\n            this._pendingTouchActivation = this._activateItemFromEvent(event);\n            event.stopPropagation();\n            return;\n        }\n        event.preventDefault();\n        event.stopPropagation();\n        this._activateItemFromEvent(event);\n        this.triggerActiveItem();\n    }\n    /**\n     * Handle the `'click'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    _evtClick(event) {\n        if (!this._pendingTouchActivation) {\n            return;\n        }\n        this._pendingTouchActivation = false;\n        event.preventDefault();\n        event.stopPropagation();\n        if (!this._activateItemFromEvent(event)) {\n            return;\n        }\n        this.triggerActiveItem();\n    }\n    /**\n     * Handle the `'pointermove'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    _evtPointerMove(event) {\n        if (Utils$1.isTouchEvent(event)) {\n            return;\n        }\n        // Hit test the item nodes for the item under the mouse.\n        let index = ArrayExt.findFirstIndex(this.contentNode.children, node => {\n            return 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        let 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 `'pointerenter'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    _evtPointerEnter(event) {\n        if (Utils$1.isTouchEvent(event)) {\n            return;\n        }\n        // Synchronize the active ancestor items.\n        for (let menu = this._parentMenu; menu; menu = menu._parentMenu) {\n            menu._cancelOpenTimer();\n            menu._cancelCloseTimer();\n            menu.activeIndex = menu._childIndex;\n        }\n    }\n    /**\n     * Handle the `'pointerleave'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the menu node.\n     */\n    _evtPointerLeave(event) {\n        if (Utils$1.isTouchEvent(event)) {\n            return;\n        }\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        let { clientX, clientY } = event;\n        if (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 `'pointerdown'` event for the menu.\n     *\n     * #### Notes\n     * This listener is attached to the document node.\n     */\n    _evtPointerDown(event) {\n        this._pendingTouchActivation = false;\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$9.hitTestMenus(this, event.clientX, event.clientY)) {\n            if (!Utils$1.isTouchEvent(event)) {\n                event.preventDefault();\n            }\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    _openChildMenu(activateFirst = false) {\n        // If the item is not a valid submenu, close the child menu.\n        let 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        let submenu = item.submenu;\n        if (submenu === this._childMenu) {\n            return;\n        }\n        // Prior to any DOM modifications save window data\n        Menu.saveWindowData();\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        MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);\n        let itemNode = this.contentNode.children[this._activeIndex];\n        // Open the submenu at the active node.\n        Private$9.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     * Activate the menu item under an event.\n     */\n    _activateItemFromEvent(event) {\n        let index = ArrayExt.findFirstIndex(this.contentNode.children, node => {\n            return ElementExt.hitTest(node, event.clientX, event.clientY);\n        });\n        if (index === -1) {\n            return false;\n        }\n        this.activeIndex = index;\n        return 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    _closeChildMenu() {\n        if (this._childMenu) {\n            this._childMenu.close();\n        }\n    }\n    /**\n     * Start the open timer, unless it is already pending.\n     */\n    _startOpenTimer() {\n        if (this._openTimerID === 0) {\n            this._openTimerID = window.setTimeout(() => {\n                this._openTimerID = 0;\n                this._openChildMenu();\n            }, Private$9.TIMER_DELAY);\n        }\n    }\n    /**\n     * Start the close timer, unless it is already pending.\n     */\n    _startCloseTimer() {\n        if (this._closeTimerID === 0) {\n            this._closeTimerID = window.setTimeout(() => {\n                this._closeTimerID = 0;\n                this._closeChildMenu();\n            }, Private$9.TIMER_DELAY);\n        }\n    }\n    /**\n     * Cancel the open timer, if the timer is pending.\n     */\n    _cancelOpenTimer() {\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    _cancelCloseTimer() {\n        if (this._closeTimerID !== 0) {\n            clearTimeout(this._closeTimerID);\n            this._closeTimerID = 0;\n        }\n    }\n    /**\n     * Save window data used for menu positioning in transient cache.\n     *\n     * In order to avoid layout trashing it is recommended to invoke this\n     * method immediately prior to opening the menu and any DOM modifications\n     * (like closing previously visible menu, or adding a class to menu widget).\n     *\n     * The transient cache will be released upon `open()` call.\n     */\n    static saveWindowData() {\n        Private$9.saveWindowData();\n    }\n}\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    class Renderer {\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        renderItem(data) {\n            let className = this.createItemClass(data);\n            let dataset = this.createItemDataset(data);\n            let aria = this.createItemARIA(data);\n            return h.li({\n                className,\n                dataset,\n                tabindex: '0',\n                onfocus: data.onfocus,\n                ...aria\n            }, 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        renderIcon(data) {\n            let className = this.createIconClass(data);\n            // If data.item.icon is undefined, it will be ignored.\n            return h.div({ 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        renderLabel(data) {\n            let content = this.formatLabel(data);\n            return h.div({ className: 'lm-Menu-itemLabel' }, 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        renderShortcut(data) {\n            let content = this.formatShortcut(data);\n            return h.div({ className: 'lm-Menu-itemShortcut' }, 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        renderSubmenu(data) {\n            return h.div({ className: 'lm-Menu-itemSubmenuIcon' });\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        createItemClass(data) {\n            // Setup the initial class name.\n            let name = 'lm-Menu-item';\n            // Add the boolean state classes.\n            if (!data.item.isEnabled) {\n                name += ' lm-mod-disabled';\n            }\n            if (data.item.isToggled) {\n                name += ' lm-mod-toggled';\n            }\n            if (!data.item.isVisible) {\n                name += ' lm-mod-hidden';\n            }\n            if (data.active) {\n                name += ' lm-mod-active';\n            }\n            if (data.collapsed) {\n                name += ' lm-mod-collapsed';\n            }\n            // Add the extra class.\n            let 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        createItemDataset(data) {\n            let result;\n            let { type, command, dataset } = data.item;\n            if (type === 'command') {\n                result = { ...dataset, type, command };\n            }\n            else {\n                result = { ...dataset, 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        createIconClass(data) {\n            let name = 'lm-Menu-itemIcon';\n            let 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        createItemARIA(data) {\n            let aria = {};\n            switch (data.item.type) {\n                case 'separator':\n                    aria.role = 'presentation';\n                    break;\n                case 'submenu':\n                    aria['aria-haspopup'] = 'true';\n                    if (!data.item.isEnabled) {\n                        aria['aria-disabled'] = 'true';\n                    }\n                    break;\n                default:\n                    if (!data.item.isEnabled) {\n                        aria['aria-disabled'] = 'true';\n                    }\n                    if (data.item.isToggleable || data.item.isToggled) {\n                        aria.role = 'menuitemcheckbox';\n                        aria['aria-checked'] = `${data.item.isToggled}`;\n                    }\n                    else {\n                        aria.role = 'menuitem';\n                    }\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        formatLabel(data) {\n            // Fetch the label text and mnemonic index.\n            let { label, mnemonic } = data.item;\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            let prefix = label.slice(0, mnemonic);\n            let suffix = label.slice(mnemonic + 1);\n            let char = label[mnemonic];\n            // Wrap the mnemonic character in a span.\n            let span = h.span({ className: 'lm-Menu-itemMnemonic' }, 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        formatShortcut(data) {\n            let kb = data.item.keyBinding;\n            return kb ? CommandRegistry.formatKeystroke(kb.keys) : null;\n        }\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$9;\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    let transientWindowDataCache = null;\n    let transientCacheCounter = 0;\n    function getWindowData() {\n        // if transient cache is in use, take one from it\n        if (transientCacheCounter > 0) {\n            transientCacheCounter--;\n            return transientWindowDataCache;\n        }\n        return _getWindowData();\n    }\n    /**\n     * Store window data in transient cache.\n     *\n     * The transient cache will be released upon `getWindowData()` call.\n     * If this function is called multiple times, the cache will be\n     * retained until as many calls to `getWindowData()` were made.\n     *\n     * Note: should be called before any DOM modifications.\n     */\n    function saveWindowData() {\n        transientWindowDataCache = _getWindowData();\n        transientCacheCounter++;\n    }\n    Private.saveWindowData = saveWindowData;\n    /**\n     * Create the DOM node for a menu.\n     */\n    function createNode() {\n        let node = document.createElement('div');\n        let content = document.createElement('ul');\n        content.className = 'lm-Menu-content';\n        node.appendChild(content);\n        content.setAttribute('role', 'menu');\n        node.tabIndex = 0;\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 (let temp = menu; temp; temp = temp.childMenu) {\n            if (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        let result = new Array(items.length);\n        ArrayExt.fill(result, false);\n        // Collapse the leading separators.\n        let k1 = 0;\n        let n = items.length;\n        for (; k1 < n; ++k1) {\n            let 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        let k2 = n - 1;\n        for (; k2 >= 0; --k2) {\n            let 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        let hide = false;\n        while (++k1 < k2) {\n            let 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    function _getWindowData() {\n        return {\n            pageXOffset: window.pageXOffset,\n            pageYOffset: window.pageYOffset,\n            clientWidth: document.documentElement.clientWidth,\n            clientHeight: document.documentElement.clientHeight\n        };\n    }\n    /**\n     * Open a menu as a root menu at the target location.\n     */\n    function openRootMenu(menu, x, y, forceX, forceY, horizontalAlignment, host, ref) {\n        // Get the current position and size of the main viewport.\n        const windowData = getWindowData();\n        let px = windowData.pageXOffset;\n        let py = windowData.pageYOffset;\n        let cw = windowData.clientWidth;\n        let ch = windowData.clientHeight;\n        // Ensure the menu is updated before attaching and measuring.\n        MessageLoop.sendMessage(menu, Widget.Msg.UpdateRequest);\n        // Compute the maximum allowed height for the menu.\n        let maxHeight = ch - (forceY ? y : 0);\n        // Fetch common variables.\n        let node = menu.node;\n        let style = node.style;\n        // Clear the menu geometry and prepare it for measuring.\n        style.opacity = '0';\n        style.maxHeight = `${maxHeight}px`;\n        // Attach the menu to the document.\n        Widget.attach(menu, host || document.body, ref);\n        // Measure the size of the menu.\n        let { width, height } = node.getBoundingClientRect();\n        // align the menu to the right of the target if requested or language is RTL\n        if (horizontalAlignment === 'right') {\n            x -= width;\n        }\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.transform = `translate(${Math.max(0, x)}px, ${Math.max(0, y)}px`;\n        // Finally, make the menu visible on the screen.\n        style.opacity = '1';\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        // Get the current position and size of the main viewport.\n        const windowData = getWindowData();\n        let px = windowData.pageXOffset;\n        let py = windowData.pageYOffset;\n        let cw = windowData.clientWidth;\n        let ch = windowData.clientHeight;\n        // Ensure the menu is updated before opening.\n        MessageLoop.sendMessage(submenu, Widget.Msg.UpdateRequest);\n        // Compute the maximum allowed height for the menu.\n        let maxHeight = ch;\n        // Fetch common variables.\n        let node = submenu.node;\n        let style = node.style;\n        // Clear the menu geometry and prepare it for measuring.\n        style.opacity = '0';\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        let { width, height } = node.getBoundingClientRect();\n        // Compute the box sizing for the menu.\n        let box = ElementExt.boxSizing(submenu.node);\n        // Get the bounding rect for the target item node.\n        let itemRect = itemNode.getBoundingClientRect();\n        // Compute the target X position.\n        let 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        let 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.transform = `translate(${Math.max(0, x)}px, ${Math.max(0, y)}px`;\n        // Finally, make the menu visible on the screen.\n        style.opacity = '1';\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        let index = -1;\n        let auto = -1;\n        let multiple = false;\n        // Normalize the key to upper case.\n        let upperKey = key.toUpperCase();\n        // Search the items from the given start index.\n        for (let i = 0, n = items.length; i < n; ++i) {\n            // Compute the wrapped index.\n            let k = (i + start) % n;\n            // Lookup the item\n            let 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            let label = item.label;\n            if (label.length === 0) {\n                continue;\n            }\n            // Lookup the mnemonic index for the label.\n            let 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, multiple, auto };\n    }\n    Private.findMnemonic = findMnemonic;\n    /**\n     * A concrete implementation of `Menu.IItem`.\n     */\n    class MenuItem {\n        /**\n         * Construct a new menu item.\n         */\n        constructor(commands, options) {\n            this._commands = commands;\n            this.type = options.type || 'command';\n            this.command = options.command || '';\n            this.args = options.args || JSONExt.emptyObject;\n            this.submenu = options.submenu || null;\n        }\n        /**\n         * The display label for the menu item.\n         */\n        get label() {\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        /**\n         * The mnemonic index for the menu item.\n         */\n        get mnemonic() {\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        /**\n         * The icon renderer for the menu item.\n         */\n        get icon() {\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            return undefined;\n        }\n        /**\n         * The icon class for the menu item.\n         */\n        get iconClass() {\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        /**\n         * The icon label for the menu item.\n         */\n        get iconLabel() {\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        /**\n         * The display caption for the menu item.\n         */\n        get caption() {\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        /**\n         * The extra class name for the menu item.\n         */\n        get className() {\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        /**\n         * The dataset for the menu item.\n         */\n        get dataset() {\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        /**\n         * Whether the menu item is enabled.\n         */\n        get isEnabled() {\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        /**\n         * Whether the menu item is toggled.\n         */\n        get isToggled() {\n            if (this.type === 'command') {\n                return this._commands.isToggled(this.command, this.args);\n            }\n            return false;\n        }\n        /**\n         * Whether the menu item is toggleable.\n         */\n        get isToggleable() {\n            if (this.type === 'command') {\n                return this._commands.isToggleable(this.command, this.args);\n            }\n            return false;\n        }\n        /**\n         * Whether the menu item is visible.\n         */\n        get isVisible() {\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        /**\n         * The key binding for the menu item.\n         */\n        get keyBinding() {\n            if (this.type === 'command') {\n                let { command, args } = this;\n                return (ArrayExt.findLastValue(this._commands.keyBindings, kb => {\n                    return kb.command === command && JSONExt.deepEqual(kb.args, args);\n                }) || null);\n            }\n            return null;\n        }\n    }\n})(Private$9 || (Private$9 = {}));\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 * 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 */\nclass ContextMenu {\n    /**\n     * Construct a new context menu.\n     *\n     * @param options - The options for initializing the menu.\n     */\n    constructor(options) {\n        this._groupByTarget = true;\n        this._idTick = 0;\n        this._items = [];\n        this._sortBySelector = true;\n        const { groupByTarget, sortBySelector, ...others } = options;\n        this.menu = new Menu(others);\n        this._groupByTarget = groupByTarget !== false;\n        this._sortBySelector = sortBySelector !== false;\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    addItem(options) {\n        // Create an item from the given options.\n        let item = Private$8.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 DisposableDelegate(() => {\n            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    open(event) {\n        // Prior to any DOM modifications update the window data.\n        Menu.saveWindowData();\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        let items = Private$8.matchItems(this._items, event, this._groupByTarget, this._sortBySelector);\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        for (const item of items) {\n            this.menu.addItem(item);\n        }\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}\n/**\n * The namespace for the module implementation details.\n */\nvar Private$8;\n(function (Private) {\n    /**\n     * Create a normalized context menu item from an options object.\n     */\n    function createItem(options, id) {\n        let selector = validateSelector(options.selector);\n        let rank = options.rank !== undefined ? options.rank : Infinity;\n        return { ...options, selector, rank, 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, groupByTarget, sortBySelector) {\n        // Look up the target of the event.\n        let 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        let 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        let result = [];\n        // Copy the items array to allow in-place modification.\n        let 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            let matches = [];\n            // Search the remaining items for matches.\n            for (let i = 0, n = availableItems.length; i < n; ++i) {\n                // Fetch the item.\n                let 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 (!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                if (groupByTarget) {\n                    matches.sort(sortBySelector ? itemCmp : itemCmpRank);\n                }\n                result.push(...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        if (!groupByTarget) {\n            result.sort(sortBySelector ? itemCmp : itemCmpRank);\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 (!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 by ranks.\n     */\n    function itemCmpRank(a, b) {\n        // Sort based on rank.\n        let r1 = a.rank;\n        let 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    /**\n     * A sort comparison function for a context menu item by selectors and ranks.\n     */\n    function itemCmp(a, b) {\n        // Sort first based on selector specificity.\n        let s1 = Selector.calculateSpecificity(a.selector);\n        let s2 = Selector.calculateSpecificity(b.selector);\n        if (s1 !== s2) {\n            return s2 - s1;\n        }\n        // If specificities are equal\n        return itemCmpRank(a, b);\n    }\n})(Private$8 || (Private$8 = {}));\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|----------------------------------------------------------------------------*/\nconst ARROW_KEYS = [\n    'ArrowLeft',\n    'ArrowUp',\n    'ArrowRight',\n    'ArrowDown',\n    'Home',\n    'End'\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 */\nclass TabBar extends Widget {\n    /**\n     * Construct a new tab bar.\n     *\n     * @param options - The options for initializing the tab bar.\n     */\n    constructor(options = {}) {\n        super({ node: Private$7.createNode() });\n        this._currentIndex = -1;\n        this._titles = [];\n        this._titlesEditable = false;\n        this._previousTitle = null;\n        this._dragData = null;\n        this._tabSizeFrozen = false;\n        this._frozenTabWidths = null;\n        this._unfreezeRunID = 0;\n        this._unfreezeFallbackTimerID = 0;\n        this._unfreezeTransitionListener = null;\n        this._pendingTouchCloseRequest = null;\n        this._addButtonEnabled = false;\n        this._tabMoved = new Signal(this);\n        this._currentChanged = new Signal(this);\n        this._addRequested = new Signal(this);\n        this._tabCloseRequested = new Signal(this);\n        this._tabDetachRequested = new Signal(this);\n        this._tabActivateRequested = new Signal(this);\n        this.addClass('lm-TabBar');\n        this.contentNode.setAttribute('role', 'tablist');\n        this.setFlag(Widget.Flag.DisallowLayout);\n        this._document = options.document || document;\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    }\n    /**\n     * Dispose of the resources held by the widget.\n     */\n    dispose() {\n        this._releaseMouse();\n        this._titles.length = 0;\n        this._previousTitle = null;\n        super.dispose();\n    }\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 currentChanged() {\n        return this._currentChanged;\n    }\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 tabMoved() {\n        return this._tabMoved;\n    }\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 tabActivateRequested() {\n        return this._tabActivateRequested;\n    }\n    /**\n     * A signal emitted when the tab bar add button is clicked.\n     */\n    get addRequested() {\n        return this._addRequested;\n    }\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 tabCloseRequested() {\n        return this._tabCloseRequested;\n    }\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 tabDetachRequested() {\n        return this._tabDetachRequested;\n    }\n    /**\n     * The document to use with the tab bar.\n     *\n     * The default is the global `document` instance.\n     */\n    get document() {\n        return this._document;\n    }\n    /**\n     * Whether the titles can be user-edited.\n     *\n     */\n    get titlesEditable() {\n        return this._titlesEditable;\n    }\n    /**\n     * Set whether titles can be user edited.\n     *\n     */\n    set titlesEditable(value) {\n        this._titlesEditable = value;\n    }\n    /**\n     * Get the currently selected title.\n     *\n     * #### Notes\n     * This will be `null` if no tab is selected.\n     */\n    get currentTitle() {\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 currentTitle(value) {\n        this.currentIndex = value ? this._titles.indexOf(value) : -1;\n    }\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 currentIndex() {\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 currentIndex(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        let pi = this._currentIndex;\n        let pt = this._titles[pi] || null;\n        // Look up the current index and title.\n        let ci = value;\n        let 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,\n            previousTitle: pt,\n            currentIndex: ci,\n            currentTitle: ct\n        });\n    }\n    /**\n     * Get the name of the tab bar.\n     */\n    get name() {\n        return this._name;\n    }\n    /**\n     * Set the name of the tab bar.\n     */\n    set name(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    /**\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 orientation() {\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 orientation(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    /**\n     * Whether the add button is enabled.\n     */\n    get addButtonEnabled() {\n        return this._addButtonEnabled;\n    }\n    /**\n     * Set whether the add button is enabled.\n     */\n    set addButtonEnabled(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    /**\n     * A read-only array of the titles in the tab bar.\n     */\n    get titles() {\n        return this._titles;\n    }\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 contentNode() {\n        return this.node.getElementsByClassName('lm-TabBar-content')[0];\n    }\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 addButtonNode() {\n        return this.node.getElementsByClassName('lm-TabBar-addButton')[0];\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    addTab(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    insertTab(index, value) {\n        // Release the mouse before making any changes.\n        this._releaseMouse();\n        // Coerce the value to a title.\n        let title = Private$7.asTitle(value);\n        // Look up the index of the title.\n        let i = this._titles.indexOf(title);\n        // Clamp the insert index to the array bounds.\n        let 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            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        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    removeTab(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    removeTabAt(index) {\n        let indexIsValid = index >= 0 && index < this._titles.length;\n        if (this._tabSizeFrozen) {\n            if (indexIsValid) {\n                // Capture the widths of all tabs that will remain.\n                let tabs = this.contentNode.children;\n                this._frozenTabWidths = [];\n                for (let i = 0, n = tabs.length; i < n; ++i) {\n                    if (i !== index) {\n                        this._frozenTabWidths.push(tabs[i].offsetWidth);\n                    }\n                }\n            }\n            else {\n                this._frozenTabWidths = null;\n            }\n        }\n        // Release the mouse before making any changes.\n        this._releaseMouse();\n        // Remove the title from the array.\n        let title = 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    clearTabs() {\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 (let title of this._titles) {\n            title.changed.disconnect(this._onTitleChanged, this);\n        }\n        // Get the current index and title.\n        let pi = this.currentIndex;\n        let 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,\n            previousTitle: pt,\n            currentIndex: -1,\n            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    releaseMouse() {\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    handleEvent(event) {\n        switch (event.type) {\n            case 'pointerdown':\n                this._evtPointerDown(event);\n                break;\n            case 'pointermove':\n                this._evtPointerMove(event);\n                break;\n            case 'pointerup':\n                this._evtPointerUp(event);\n                break;\n            case 'pointerleave':\n                this._evtPointerLeave(event);\n                break;\n            case 'click':\n                this._evtClick(event);\n                break;\n            case 'dblclick':\n                this._evtDblClick(event);\n                break;\n            case 'keydown':\n                event.eventPhase === Event.CAPTURING_PHASE\n                    ? this._evtKeyDownCapturing(event)\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    onBeforeAttach(msg) {\n        this.node.addEventListener('pointerdown', this);\n        this.node.addEventListener('pointerleave', this);\n        this.node.addEventListener('click', this);\n        this.node.addEventListener('dblclick', this);\n        this.node.addEventListener('keydown', this);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(msg) {\n        this.node.removeEventListener('pointerdown', this);\n        this.node.removeEventListener('pointerleave', this);\n        this.node.removeEventListener('click', this);\n        this.node.removeEventListener('dblclick', this);\n        this.node.removeEventListener('keydown', this);\n        this._clearUnfreezeTransitionState();\n        this._clearTabSizeFreezeState();\n        this._pendingTouchCloseRequest = null;\n        this._releaseMouse();\n    }\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    onUpdateRequest(msg) {\n        var _a;\n        let titles = this._titles;\n        let renderer = this.renderer;\n        let currentTitle = this.currentTitle;\n        let content = new Array(titles.length);\n        // Keep the tabindex=\"0\" attribute to the tab which handled it before the update.\n        // If the add button handles it, no need to do anything. If no element of the tab\n        // bar handles it, set it on the current or the first tab to ensure one element\n        // handles it after update.\n        const tabHandlingTabindex = (_a = this._getCurrentTabindex()) !== null && _a !== void 0 ? _a : (this._currentIndex > -1 ? this._currentIndex : 0);\n        for (let i = 0, n = titles.length; i < n; ++i) {\n            let title = titles[i];\n            let current = title === currentTitle;\n            let zIndex = current ? n : n - i - 1;\n            let tabIndex = tabHandlingTabindex === i ? 0 : -1;\n            content[i] = renderer.renderTab({ title, current, zIndex, tabIndex });\n        }\n        VirtualDOM.render(content, this.contentNode);\n        if (this._tabSizeFrozen) {\n            let tabs = this.contentNode.children;\n            if (this._frozenTabWidths &&\n                this._frozenTabWidths.length === tabs.length) {\n                for (let i = 0, n = tabs.length; i < n; ++i) {\n                    this._setFrozenTabSize(tabs[i], this._frozenTabWidths[i]);\n                }\n                this._frozenTabWidths = null;\n            }\n            else {\n                this._frozenTabWidths = null;\n                for (let i = 0, n = tabs.length; i < n; ++i) {\n                    let tab = tabs[i];\n                    this._setFrozenTabSize(tab, tab.offsetWidth);\n                }\n            }\n        }\n    }\n    /**\n     * Get the index of the tab which handles tabindex=\"0\".\n     * If the add button handles tabindex=\"0\", -1 is returned.\n     * If none of the previous handles tabindex=\"0\", null is returned.\n     */\n    _getCurrentTabindex() {\n        let index = null;\n        const elemTabindex = this.contentNode.querySelector('li[tabindex=\"0\"]');\n        if (elemTabindex) {\n            index = [...this.contentNode.children].indexOf(elemTabindex);\n        }\n        else if (this._addButtonEnabled &&\n            this.addButtonNode.getAttribute('tabindex') === '0') {\n            index = -1;\n        }\n        return index;\n    }\n    /**\n     * Handle the `'dblclick'` event for the tab bar.\n     */\n    _evtDblClick(event) {\n        // Do nothing if titles are not editable\n        if (!this.titlesEditable) {\n            return;\n        }\n        let tabs = this.contentNode.children;\n        // Find the index of the targeted tab.\n        let index = ArrayExt.findFirstIndex(tabs, tab => {\n            return 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        let title = this.titles[index];\n        let label = tabs[index].querySelector('.lm-TabBar-tabLabel');\n        if (label && label.contains(event.target)) {\n            let value = title.label || '';\n            // Clear the label element\n            let oldValue = label.innerHTML;\n            label.innerHTML = '';\n            let input = document.createElement('input');\n            input.classList.add('lm-TabBar-tabInput');\n            input.value = value;\n            label.appendChild(input);\n            let onblur = () => {\n                input.removeEventListener('blur', onblur);\n                label.innerHTML = oldValue;\n                this.node.addEventListener('keydown', this);\n            };\n            input.addEventListener('dblclick', (event) => event.stopPropagation());\n            input.addEventListener('blur', onblur);\n            input.addEventListener('keydown', (event) => {\n                if (event.key === 'Enter') {\n                    if (input.value !== '') {\n                        title.label = title.caption = input.value;\n                    }\n                    onblur();\n                }\n                else if (event.key === 'Escape') {\n                    onblur();\n                }\n            });\n            this.node.removeEventListener('keydown', this);\n            input.select();\n            input.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 at capturing phase.\n     */\n    _evtKeyDownCapturing(event) {\n        if (event.eventPhase !== Event.CAPTURING_PHASE) {\n            return;\n        }\n        // Stop all input events during drag.\n        event.preventDefault();\n        event.stopPropagation();\n        // Release the mouse if `Escape` is pressed.\n        if (event.key === 'Escape') {\n            this._releaseMouse();\n        }\n    }\n    /**\n     * Handle the `'keydown'` event for the tab bar at target phase.\n     */\n    _evtKeyDown(event) {\n        var _a, _b, _c;\n        // Allow for navigation using tab key\n        if (event.key === 'Tab' || event.eventPhase === Event.CAPTURING_PHASE) {\n            return;\n        }\n        // Check if Enter or Spacebar key has been pressed and open that tab\n        if (event.key === 'Enter' ||\n            event.key === 'Spacebar' ||\n            event.key === ' ') {\n            // Get focus element that is in focus by the tab key\n            const focusedElement = document.activeElement;\n            // Test first if the focus is on the add button node\n            if (this.addButtonEnabled &&\n                this.addButtonNode.contains(focusedElement)) {\n                event.preventDefault();\n                event.stopPropagation();\n                this._addRequested.emit();\n            }\n            else {\n                const index = ArrayExt.findFirstIndex(this.contentNode.children, tab => tab.contains(focusedElement));\n                if (index >= 0) {\n                    event.preventDefault();\n                    event.stopPropagation();\n                    this.currentIndex = index;\n                }\n            }\n            // Handle the arrow keys to switch tabs.\n        }\n        else if (ARROW_KEYS.includes(event.key)) {\n            // Create a list of all focusable elements in the tab bar.\n            const focusable = [...this.contentNode.children];\n            if (this.addButtonEnabled) {\n                focusable.push(this.addButtonNode);\n            }\n            // If the tab bar contains only one element, nothing to do.\n            if (focusable.length <= 1) {\n                return;\n            }\n            event.preventDefault();\n            event.stopPropagation();\n            // Get the current focused element.\n            let focusedIndex = focusable.indexOf(document.activeElement);\n            if (focusedIndex === -1) {\n                focusedIndex = this._currentIndex;\n            }\n            // Find the next element to focus on.\n            let nextFocused;\n            if ((event.key === 'ArrowRight' && this._orientation === 'horizontal') ||\n                (event.key === 'ArrowDown' && this._orientation === 'vertical')) {\n                nextFocused = (_a = focusable[focusedIndex + 1]) !== null && _a !== void 0 ? _a : focusable[0];\n            }\n            else if ((event.key === 'ArrowLeft' && this._orientation === 'horizontal') ||\n                (event.key === 'ArrowUp' && this._orientation === 'vertical')) {\n                nextFocused =\n                    (_b = focusable[focusedIndex - 1]) !== null && _b !== void 0 ? _b : focusable[focusable.length - 1];\n            }\n            else if (event.key === 'Home') {\n                nextFocused = focusable[0];\n            }\n            else if (event.key === 'End') {\n                nextFocused = focusable[focusable.length - 1];\n            }\n            // Change the focused element and the tabindex value.\n            if (nextFocused) {\n                (_c = focusable[focusedIndex]) === null || _c === void 0 ? void 0 : _c.setAttribute('tabindex', '-1');\n                nextFocused === null || nextFocused === void 0 ? void 0 : nextFocused.setAttribute('tabindex', '0');\n                nextFocused.focus();\n            }\n        }\n    }\n    /**\n     * Handle the `'pointerdown'` event for the tab bar.\n     */\n    _evtPointerDown(event) {\n        this._pendingTouchCloseRequest = null;\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        // Do nothing if a title editable input was clicked.\n        if (event.target.classList.contains('lm-TabBar-tabInput')) {\n            return;\n        }\n        // Check if the add button was clicked.\n        let addButtonClicked = this.addButtonEnabled &&\n            this.addButtonNode.contains(event.target);\n        // Lookup the tab nodes.\n        let tabs = this.contentNode.children;\n        // Find the index of the pressed tab.\n        let index = ArrayExt.findFirstIndex(tabs, tab => {\n            return 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        // Check if the close icon was pressed.\n        let icon = index !== -1\n            ? tabs[index].querySelector(this.renderer.closeIconSelector)\n            : null;\n        let closeIconPressed = !!icon && icon.contains(event.target);\n        // Pressing on a tab stops the event propagation.\n        if (!closeIconPressed || !Utils$1.isTouchEvent(event)) {\n            event.preventDefault();\n        }\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 pointer up listener.\n        this.document.addEventListener('pointerup', 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        if (closeIconPressed) {\n            return;\n        }\n        // Add the extra listeners if the tabs are movable.\n        if (this.tabsMovable) {\n            this.document.addEventListener('pointermove', this, true);\n            this.document.addEventListener('keydown', this, true);\n            this.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,\n            title: this.currentTitle\n        });\n    }\n    /**\n     * Handle the `'pointermove'` event for the tab bar.\n     */\n    _evtPointerMove(event) {\n        // Do nothing if no drag is in progress.\n        let 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        let tabs = this.contentNode.children;\n        // Bail early if the drag threshold has not been met.\n        if (!data.dragActive && !Private$7.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            let 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.tabPressOffset = {\n                x: data.pressX - tabRect.left,\n                y: data.pressY - tabRect.top\n            };\n            data.tabLayout = Private$7.snapTabLayout(tabs, this._orientation);\n            data.contentRect = this.contentNode.getBoundingClientRect();\n            data.override = Drag.overrideCursor('default');\n            // Add the dragging style classes.\n            data.tab.classList.add('lm-mod-dragging');\n            this.addClass('lm-mod-dragging');\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$7.detachExceeded(data, event)) {\n            // Only emit the signal once per drag cycle.\n            data.detachRequested = true;\n            // Setup the arguments for the signal.\n            let index = data.index;\n            let clientX = event.clientX;\n            let clientY = event.clientY;\n            let tab = tabs[index];\n            let title = this._titles[index];\n            // Emit the tab detach requested signal.\n            this._tabDetachRequested.emit({\n                index,\n                title,\n                tab,\n                clientX,\n                clientY,\n                offset: data.tabPressOffset\n            });\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$7.layoutTabs(tabs, data, event, this._orientation);\n    }\n    /**\n     * Handle the `'pointerup'` event for the document.\n     */\n    _evtPointerUp(event) {\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        const data = this._dragData;\n        if (!data) {\n            return;\n        }\n        const isTouch = Utils$1.isTouchEvent(event);\n        // Stop the event propagation.\n        if (!isTouch) {\n            event.preventDefault();\n        }\n        event.stopPropagation();\n        // Remove the extra mouse event listeners.\n        this.document.removeEventListener('pointermove', this, true);\n        this.document.removeEventListener('pointerup', this, true);\n        this.document.removeEventListener('keydown', this, true);\n        this.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            let 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            let tabs = this.contentNode.children;\n            // Find the index of the released tab.\n            let index = ArrayExt.findFirstIndex(tabs, tab => {\n                return 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            let 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, title });\n                return;\n            }\n            // Emit the close requested signal if the close icon was released.\n            let icon = tabs[index].querySelector(this.renderer.closeIconSelector);\n            if (icon && icon.contains(event.target)) {\n                this._tabSizeFrozen = true;\n                if (isTouch) {\n                    this._pendingTouchCloseRequest = { index, title };\n                    return;\n                }\n                this._tabCloseRequested.emit({ index, 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$7.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        // Parse the transition duration for releasing the tab.\n        let duration = Private$7.parseTransitionDuration(data.tab);\n        // Complete the release on a timer to allow the tab to transition.\n        setTimeout(() => {\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$7.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            // If the tab was not moved, there is nothing else to do.\n            let i = data.index;\n            let j = data.targetIndex;\n            if (j === -1 || i === j) {\n                return;\n            }\n            // Move the title to the new locations.\n            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,\n                toIndex: j,\n                title: this._titles[j]\n            });\n            // Update the tabs immediately to prevent flicker.\n            MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);\n        }, duration);\n    }\n    /**\n     * Release the mouse and restore the non-dragged tab positions.\n     */\n    _releaseMouse() {\n        // Do nothing if no drag is in progress.\n        let data = this._dragData;\n        if (!data) {\n            return;\n        }\n        // Clear the drag data reference.\n        this._dragData = null;\n        // Remove the extra document event listeners.\n        this.document.removeEventListener('pointermove', this, true);\n        this.document.removeEventListener('pointerup', this, true);\n        this.document.removeEventListener('keydown', this, true);\n        this.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$7.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    }\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    _adjustCurrentForInsert(i, title) {\n        // Lookup commonly used variables.\n        let ct = this.currentTitle;\n        let ci = this._currentIndex;\n        let 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,\n                previousTitle: ct,\n                currentIndex: i,\n                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     * Handle the `'click'` event for the tab bar.\n     */\n    _evtClick(event) {\n        const request = this._pendingTouchCloseRequest;\n        if (!request) {\n            return;\n        }\n        this._pendingTouchCloseRequest = null;\n        event.preventDefault();\n        event.stopPropagation();\n        const tab = this.contentNode.children[request.index];\n        const icon = tab === null || tab === void 0 ? void 0 : tab.querySelector(this.renderer.closeIconSelector);\n        if (this._titles[request.index] !== request.title ||\n            !icon ||\n            !icon.contains(event.target)) {\n            this._clearTabSizeFreezeState();\n            return;\n        }\n        this._tabCloseRequested.emit(request);\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    _adjustCurrentForMove(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    _adjustCurrentForRemove(i, title) {\n        // Lookup commonly used variables.\n        let ci = this._currentIndex;\n        let 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,\n                previousTitle: title,\n                currentIndex: -1,\n                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,\n                previousTitle: title,\n                currentIndex: this._currentIndex,\n                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,\n                previousTitle: title,\n                currentIndex: this._currentIndex,\n                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,\n                previousTitle: title,\n                currentIndex: this._currentIndex,\n                currentTitle: this.currentTitle\n            });\n            return;\n        }\n        // Otherwise, no tab gets selected.\n        this._currentIndex = -1;\n        this._currentChanged.emit({\n            previousIndex: i,\n            previousTitle: title,\n            currentIndex: -1,\n            currentTitle: null\n        });\n    }\n    /**\n     * Handle the `changed` signal of a title object.\n     */\n    _onTitleChanged(sender) {\n        this.update();\n    }\n    /**\n     * Handle the `'pointerleave'` event for the tab bar.\n     *\n     * This restores the natural tab sizing after tabs were frozen\n     * due to a close-icon click.\n     */\n    _evtPointerLeave(event) {\n        // Do nothing if tab sizes are not currently frozen.\n        if (!this._tabSizeFrozen) {\n            return;\n        }\n        // Unfreeze tab sizes.\n        this._tabSizeFrozen = false;\n        this._frozenTabWidths = null;\n        // Start a new unfreeze run and clear stale listeners/timers.\n        this._unfreezeRunID++;\n        let runID = this._unfreezeRunID;\n        this._clearUnfreezeTransitionState();\n        // Add the unfreezing class to enable a smooth width transition.\n        this.addClass('lm-mod-unfreezing');\n        // Clear the inline width on all tabs, triggering the CSS transition.\n        let tabs = this.contentNode.children;\n        for (let i = 0, n = tabs.length; i < n; ++i) {\n            let tab = tabs[i];\n            tab.style.width = '';\n            tab.style.flexBasis = '';\n        }\n        if (tabs.length === 0) {\n            this.removeClass('lm-mod-unfreezing');\n        }\n        else {\n            let onTransitionDone = (event) => {\n                let propertyName = event.propertyName;\n                if (propertyName === 'width' || propertyName === 'flex-basis') {\n                    this._finalizeUnfreezeRun(runID);\n                }\n            };\n            this._unfreezeTransitionListener = onTransitionDone;\n            this.node.addEventListener('transitionend', onTransitionDone);\n            this.node.addEventListener('transitioncancel', onTransitionDone);\n            this._unfreezeFallbackTimerID = window.setTimeout(() => {\n                this._finalizeUnfreezeRun(runID);\n            }, 2000);\n        }\n        // Schedule an update to re-render the tabs at natural size.\n        this.update();\n    }\n    /**\n     * Apply a frozen size to a tab.\n     *\n     * The width is mirrored to `flex-basis` so frozen sizing works even when\n     * themes define tab sizing through flex rules.\n     */\n    _setFrozenTabSize(tab, width) {\n        let size = `${width}px`;\n        tab.style.width = size;\n        tab.style.flexBasis = size;\n    }\n    /**\n     * Finish an in-flight unfreeze transition run.\n     */\n    _finalizeUnfreezeRun(runID) {\n        if (runID !== this._unfreezeRunID) {\n            return;\n        }\n        this._clearUnfreezeTransitionState();\n        this.removeClass('lm-mod-unfreezing');\n    }\n    /**\n     * Remove unfreeze listeners and timers.\n     */\n    _clearUnfreezeTransitionState() {\n        if (this._unfreezeTransitionListener) {\n            this.node.removeEventListener('transitionend', this._unfreezeTransitionListener);\n            this.node.removeEventListener('transitioncancel', this._unfreezeTransitionListener);\n            this._unfreezeTransitionListener = null;\n        }\n        if (this._unfreezeFallbackTimerID !== 0) {\n            clearTimeout(this._unfreezeFallbackTimerID);\n            this._unfreezeFallbackTimerID = 0;\n        }\n    }\n    /**\n     * Clear transient tab-size freeze state and styles.\n     */\n    _clearTabSizeFreezeState() {\n        this._tabSizeFrozen = false;\n        this._frozenTabWidths = null;\n        this.removeClass('lm-mod-unfreezing');\n        let tabs = this.contentNode.children;\n        for (let i = 0, n = tabs.length; i < n; ++i) {\n            let tab = tabs[i];\n            tab.style.width = '';\n            tab.style.flexBasis = '';\n        }\n    }\n}\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    class Renderer {\n        constructor() {\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            this._uuid = ++Renderer._nInstance;\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        renderTab(data) {\n            let title = data.title.caption;\n            let key = this.createTabKey(data);\n            let id = key;\n            let style = this.createTabStyle(data);\n            let className = this.createTabClass(data);\n            let dataset = this.createTabDataset(data);\n            let aria = this.createTabARIA(data);\n            if (data.title.closable) {\n                return h.li({ id, key, className, title, style, dataset, ...aria }, this.renderIcon(data), this.renderLabel(data), this.renderCloseIcon(data));\n            }\n            else {\n                return h.li({ id, key, className, title, style, 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        renderIcon(data) {\n            const { title } = data;\n            let className = this.createIconClass(data);\n            // If title.icon is undefined, it will be ignored.\n            return h.div({ 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        renderLabel(data) {\n            return h.div({ className: 'lm-TabBar-tabLabel' }, 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        renderCloseIcon(data) {\n            return h.div({ className: 'lm-TabBar-tabCloseIcon' });\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        createTabKey(data) {\n            let key = this._tabKeys.get(data.title);\n            if (key === undefined) {\n                key = `tab-key-${this._uuid}-${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        createTabStyle(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        createTabClass(data) {\n            let name = 'lm-TabBar-tab';\n            if (data.title.className) {\n                name += ` ${data.title.className}`;\n            }\n            if (data.title.closable) {\n                name += ' lm-mod-closable';\n            }\n            if (data.current) {\n                name += ' lm-mod-current';\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        createTabDataset(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        createTabARIA(data) {\n            var _a;\n            return {\n                role: 'tab',\n                'aria-selected': data.current.toString(),\n                tabindex: `${(_a = data.tabIndex) !== null && _a !== void 0 ? _a : '-1'}`\n            };\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        createIconClass(data) {\n            let name = 'lm-TabBar-tabIcon';\n            let extra = data.title.iconClass;\n            return extra ? `${name} ${extra}` : name;\n        }\n    }\n    Renderer._nInstance = 0;\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$7;\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        let node = document.createElement('div');\n        let content = document.createElement('ul');\n        content.setAttribute('role', 'tablist');\n        content.className = 'lm-TabBar-content';\n        node.appendChild(content);\n        let add = document.createElement('div');\n        add.className = 'lm-TabBar-addButton lm-mod-hidden';\n        add.setAttribute('tabindex', '-1');\n        add.setAttribute('role', 'button');\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        let 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        let layout = new Array(tabs.length);\n        for (let i = 0, n = tabs.length; i < n; ++i) {\n            let node = tabs[i];\n            let 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        let dx = Math.abs(event.clientX - data.pressX);\n        let 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        let 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        let pressPos;\n        let localPos;\n        let clientPos;\n        let 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        let targetIndex = data.index;\n        let targetPos = localPos - data.tabPressPos;\n        let targetEnd = targetPos + data.tabSize;\n        // Update the relative tab positions.\n        for (let i = 0, n = tabs.length; i < n; ++i) {\n            let pxPos;\n            let layout = data.tabLayout[i];\n            let 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                let ideal = clientPos - pressPos;\n                let 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        let 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        let ideal;\n        if (data.targetIndex === data.index) {\n            ideal = 0;\n        }\n        else if (data.targetIndex > data.index) {\n            let tgt = data.tabLayout[data.targetIndex];\n            ideal = tgt.pos + tgt.size - data.tabSize - data.tabPos;\n        }\n        else {\n            let tgt = data.tabLayout[data.targetIndex];\n            ideal = tgt.pos - data.tabPos;\n        }\n        // Compute the tab position limit.\n        let limit = clientSize - (data.tabPos + data.tabSize);\n        let 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        for (const tab of tabs) {\n            if (orientation === 'horizontal') {\n                tab.style.left = '';\n            }\n            else {\n                tab.style.top = '';\n            }\n        }\n    }\n    Private.resetTabPositions = resetTabPositions;\n})(Private$7 || (Private$7 = {}));\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 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 */\nclass DockLayout extends Layout {\n    /**\n     * Construct a new dock layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    constructor(options) {\n        super();\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 = Utils$1.clampDimension(options.spacing);\n        }\n        this._document = options.document || document;\n        this._hiddenMode =\n            options.hiddenMode !== undefined\n                ? options.hiddenMode\n                : Widget.HiddenMode.Display;\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    dispose() {\n        // Get an iterator over the widgets in the layout.\n        let widgets = this[Symbol.iterator]();\n        // Dispose of the layout items.\n        this._items.forEach(item => {\n            item.dispose();\n        });\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        for (const widget of widgets) {\n            widget.dispose();\n        }\n        // Dispose of the base class.\n        super.dispose();\n    }\n    /**\n     * The method for hiding child widgets.\n     *\n     * #### Notes\n     * If there is only one child widget, `Display` hiding mode will be used\n     * regardless of this setting.\n     */\n    get hiddenMode() {\n        return this._hiddenMode;\n    }\n    set hiddenMode(v) {\n        if (this._hiddenMode === v) {\n            return;\n        }\n        this._hiddenMode = v;\n        for (const bar of this.tabBars()) {\n            if (bar.titles.length > 1) {\n                for (const title of bar.titles) {\n                    title.owner.hiddenMode = this._hiddenMode;\n                }\n            }\n        }\n    }\n    /**\n     * Get the inter-element spacing for the dock layout.\n     */\n    get spacing() {\n        return this._spacing;\n    }\n    /**\n     * Set the inter-element spacing for the dock layout.\n     */\n    set spacing(value) {\n        value = Utils$1.clampDimension(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    /**\n     * Whether the dock layout is empty.\n     */\n    get isEmpty() {\n        return this._root === null;\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    [Symbol.iterator]() {\n        return this._root ? this._root.iterAllWidgets() : 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    widgets() {\n        return this._root ? this._root.iterUserWidgets() : 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    selectedWidgets() {\n        return this._root ? this._root.iterSelectedWidgets() : 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    tabBars() {\n        return this._root ? this._root.iterTabBars() : 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    handles() {\n        return this._root ? this._root.iterHandles() : 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    moveHandle(handle, offsetX, offsetY) {\n        // Bail early if there is no root or if the handle is hidden.\n        let hidden = handle.classList.contains('lm-mod-hidden');\n        if (!this._root || hidden) {\n            return;\n        }\n        // Lookup the split node for the handle.\n        let data = this._root.findSplitNode(handle);\n        if (!data) {\n            return;\n        }\n        // Compute the desired delta movement for the handle.\n        let 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    saveLayout() {\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    restoreLayout(config) {\n        // Create the widget set for validating the config.\n        let widgetSet = new Set();\n        // Normalize the main area config and collect the widgets.\n        let mainConfig;\n        if (config.main) {\n            mainConfig = Private$6.normalizeAreaConfig(config.main, widgetSet);\n        }\n        else {\n            mainConfig = null;\n        }\n        // Create iterators over the old content.\n        let oldWidgets = this.widgets();\n        let oldTabBars = this.tabBars();\n        let 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        for (const widget of oldWidgets) {\n            if (!widgetSet.has(widget)) {\n                widget.parent = null;\n            }\n        }\n        // Dispose of the old tab bars.\n        for (const tabBar of oldTabBars) {\n            tabBar.dispose();\n        }\n        // Remove the old handles.\n        for (const handle of oldHandles) {\n            if (handle.parentNode) {\n                handle.parentNode.removeChild(handle);\n            }\n        }\n        // Reparent the new widgets to the current parent.\n        for (const widget of widgetSet) {\n            widget.parent = this.parent;\n        }\n        // Create the root node for the new config.\n        if (mainConfig) {\n            this._root = Private$6.realizeAreaConfig(mainConfig, {\n                // Ignoring optional `document` argument as we must reuse `this._document`\n                createTabBar: (document) => this._createTabBar(),\n                createHandle: () => this._createHandle()\n            }, this._document);\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(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    addWidget(widget, options = {}) {\n        // Parse the options.\n        let ref = options.ref || null;\n        let mode = options.mode || 'tab-after';\n        // Find the tab node which holds the reference widget.\n        let 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            case 'merge-top':\n                this._insertSplit(widget, ref, refNode, 'vertical', false, true);\n                break;\n            case 'merge-left':\n                this._insertSplit(widget, ref, refNode, 'horizontal', false, true);\n                break;\n            case 'merge-right':\n                this._insertSplit(widget, ref, refNode, 'horizontal', true, true);\n                break;\n            case 'merge-bottom':\n                this._insertSplit(widget, ref, refNode, 'vertical', true, 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    removeWidget(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    hitTestTabAreas(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 = ElementExt.boxSizing(this.parent.node);\n        }\n        // Convert from client to local coordinates.\n        let rect = this.parent.node.getBoundingClientRect();\n        let x = clientX - rect.left - this._box.borderLeft;\n        let y = clientY - rect.top - this._box.borderTop;\n        // Find the tab layout node at the local position.\n        let 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        let { tabBar, top, left, width, height } = tabNode;\n        // Compute the right and bottom edges of the tab area.\n        let borderWidth = this._box.borderLeft + this._box.borderRight;\n        let borderHeight = this._box.borderTop + this._box.borderBottom;\n        let right = rect.width - borderWidth - (left + width);\n        let bottom = rect.height - borderHeight - (top + height);\n        // Return the hit test results.\n        return { tabBar, x, y, top, left, right, bottom, width, height };\n    }\n    /**\n     * Perform layout initialization which requires the parent widget.\n     */\n    init() {\n        // Perform superclass initialization.\n        super.init();\n        // Attach each widget to the parent.\n        for (const widget of this) {\n            this.attachWidget(widget);\n        }\n        // Attach each handle to the parent.\n        for (const handle of this.handles()) {\n            this.parent.node.appendChild(handle);\n        }\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    attachWidget(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            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            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    detachWidget(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            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            MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Delete the layout item for the widget.\n        let 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    onBeforeShow(msg) {\n        super.onBeforeShow(msg);\n        this.parent.update();\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(msg) {\n        super.onBeforeAttach(msg);\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    onChildShown(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    onChildHidden(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    onResize(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    onUpdateRequest(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    onFitRequest(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    _removeWidget(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        let tabNode = this._root.findTabNode(widget);\n        // Bail early if the tab node is not found.\n        if (!tabNode) {\n            return;\n        }\n        Private$6.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            if (this._hiddenMode === Widget.HiddenMode.Scale &&\n                tabNode.tabBar.titles.length == 1) {\n                const existingWidget = tabNode.tabBar.titles[0].owner;\n                existingWidget.hiddenMode = Widget.HiddenMode.Display;\n            }\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        let splitNode = tabNode.parent;\n        tabNode.parent = null;\n        // Remove the tab node from its parent split node.\n        let i = ArrayExt.removeFirstOf(splitNode.children, tabNode);\n        let handle = ArrayExt.removeAt(splitNode.handles, i);\n        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        let maybeParent = splitNode.parent;\n        splitNode.parent = null;\n        // Lookup the remaining child node and handle.\n        let childNode = splitNode.children[0];\n        let 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        let parentNode = maybeParent;\n        // Lookup the index of the split node.\n        let j = parentNode.children.indexOf(splitNode);\n        // Handle the case where the child node is a tab node.\n        if (childNode instanceof Private$6.TabLayoutNode) {\n            childNode.parent = parentNode;\n            parentNode.children[j] = childNode;\n            return;\n        }\n        // Remove the split data from the parent.\n        let splitHandle = ArrayExt.removeAt(parentNode.handles, j);\n        ArrayExt.removeAt(parentNode.children, j);\n        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 (let i = 0, n = childNode.children.length; i < n; ++i) {\n            let gChild = childNode.children[i];\n            let gHandle = childNode.handles[i];\n            let gSizer = childNode.sizers[i];\n            ArrayExt.insert(parentNode.children, j + i, gChild);\n            ArrayExt.insert(parentNode.handles, j + i, gHandle);\n            ArrayExt.insert(parentNode.sizers, j + i, 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     * Create the tab layout node to hold the widget.\n     */\n    _createTabNode(widget) {\n        let tabNode = new Private$6.TabLayoutNode(this._createTabBar());\n        tabNode.tabBar.addTab(widget.title);\n        Private$6.addAria(widget, tabNode.tabBar);\n        return tabNode;\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    _insertTab(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            let tabNode = new Private$6.TabLayoutNode(this._createTabBar());\n            tabNode.tabBar.addTab(widget.title);\n            this._root = tabNode;\n            Private$6.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        let index;\n        if (ref) {\n            index = refNode.tabBar.titles.indexOf(ref.title);\n        }\n        else {\n            index = refNode.tabBar.currentIndex;\n        }\n        // Using transform create an additional layer in the pixel pipeline\n        // to limit the number of layer, it is set only if there is more than one widget.\n        if (this._hiddenMode === Widget.HiddenMode.Scale) {\n            if (refNode.tabBar.titles.length === 0) {\n                // Singular tab should use display mode to limit number of layers.\n                widget.hiddenMode = Widget.HiddenMode.Display;\n            }\n            else if (refNode.tabBar.titles.length == 1) {\n                // If we are adding a second tab, switch the existing tab back to scale.\n                const existingWidget = refNode.tabBar.titles[0].owner;\n                existingWidget.hiddenMode = Widget.HiddenMode.Scale;\n            }\n            else {\n                // For the third and subsequent tabs no special action is needed.\n                widget.hiddenMode = Widget.HiddenMode.Scale;\n            }\n        }\n        else {\n            // For all other modes just propagate the current mode.\n            widget.hiddenMode = this._hiddenMode;\n        }\n        // Insert the widget's tab relative to the target index.\n        refNode.tabBar.insertTab(index + (after ? 1 : 0), widget.title);\n        Private$6.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    _insertSplit(widget, ref, refNode, orientation, after, merge = false) {\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        // Set the root if it does not exist.\n        if (!this._root) {\n            this._root = this._createTabNode(widget);\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            let root = this._splitRoot(orientation);\n            // Determine the insert index for the new tab node.\n            let i = after ? root.children.length : 0;\n            // Normalize the split node.\n            root.normalizeSizes();\n            // Create the sizer for new tab node.\n            let sizer = Private$6.createSizer(refNode ? 1 : Private$6.GOLDEN_RATIO);\n            // Insert the tab node sized to the golden ratio.\n            let tabNode = this._createTabNode(widget);\n            ArrayExt.insert(root.children, i, tabNode);\n            ArrayExt.insert(root.sizers, i, sizer);\n            ArrayExt.insert(root.handles, i, 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        let 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            let i = splitNode.children.indexOf(refNode);\n            // Conditionally reuse a tab layout found in the wanted position.\n            if (merge) {\n                let j = i + (after ? 1 : -1);\n                let sibling = splitNode.children[j];\n                if (sibling instanceof Private$6.TabLayoutNode) {\n                    this._insertTab(widget, null, sibling, true);\n                    ++sibling.tabBar.currentIndex;\n                    return;\n                }\n            }\n            // Normalize the split node.\n            splitNode.normalizeSizes();\n            // Consume half the space for the insert location.\n            let s = (splitNode.sizers[i].sizeHint /= 2);\n            // Insert the tab node sized to the other half.\n            let j = i + (after ? 1 : 0);\n            let tabNode = this._createTabNode(widget);\n            ArrayExt.insert(splitNode.children, j, tabNode);\n            ArrayExt.insert(splitNode.sizers, j, Private$6.createSizer(s));\n            ArrayExt.insert(splitNode.handles, j, 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        let i = ArrayExt.removeFirstOf(splitNode.children, refNode);\n        // Create a new normalized split node for the children.\n        let childNode = new Private$6.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$6.createSizer(0.5));\n        childNode.handles.push(this._createHandle());\n        refNode.parent = childNode;\n        // Add the tab node sized to the other half.\n        let j = after ? 1 : 0;\n        let tabNode = this._createTabNode(widget);\n        ArrayExt.insert(childNode.children, j, tabNode);\n        ArrayExt.insert(childNode.sizers, j, Private$6.createSizer(0.5));\n        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        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    _splitRoot(orientation) {\n        // Bail early if the root already meets the requirements.\n        let oldRoot = this._root;\n        if (oldRoot instanceof Private$6.SplitLayoutNode) {\n            if (oldRoot.orientation === orientation) {\n                return oldRoot;\n            }\n        }\n        // Create a new root node with the specified orientation.\n        let newRoot = (this._root = new Private$6.SplitLayoutNode(orientation));\n        // Add the old root to the new root.\n        if (oldRoot) {\n            newRoot.children.push(oldRoot);\n            newRoot.sizers.push(Private$6.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    _fit() {\n        // Set up the computed minimum size.\n        let minW = 0;\n        let minH = 0;\n        // Update the size limits for the layout tree.\n        if (this._root) {\n            let 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        let box = (this._box = ElementExt.boxSizing(this.parent.node));\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        let 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            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            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    _update(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 = ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the actual layout bounds adjusted for border and padding.\n        let x = this._box.paddingTop;\n        let y = this._box.paddingLeft;\n        let width = offsetWidth - this._box.horizontalSum;\n        let 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    _createTabBar() {\n        // Create the tab bar using the renderer.\n        let tabBar = this.renderer.createTabBar(this._document);\n        // Enforce necessary tab bar behavior.\n        tabBar.orientation = 'horizontal';\n        // Attach the tab bar to the parent if possible.\n        if (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    _createHandle() {\n        // Create the handle using the renderer.\n        let handle = this.renderer.createHandle();\n        // Initialize the handle layout behavior.\n        let style = handle.style;\n        style.position = 'absolute';\n        style.contain = 'strict';\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}\n/**\n * The namespace for the module implementation details.\n */\nvar Private$6;\n(function (Private) {\n    /**\n     * A fraction used for sizing root panels; ~= `1 / golden_ratio`.\n     */\n    Private.GOLDEN_RATIO = 0.618;\n    /**\n     * Create a box sizer with an initial size hint.\n     */\n    function createSizer(hint) {\n        let 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        let 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, document) {\n        let node;\n        if (config.type === 'tab-area') {\n            node = realizeTabAreaConfig(config, renderer, document);\n        }\n        else {\n            node = realizeSplitAreaConfig(config, renderer, document);\n        }\n        return node;\n    }\n    Private.realizeAreaConfig = realizeAreaConfig;\n    /**\n     * A layout node which holds the data for a tabbed area.\n     */\n    class TabLayoutNode {\n        /**\n         * Construct a new tab layout node.\n         *\n         * @param tabBar - The tab bar to use for the layout node.\n         */\n        constructor(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            let tabSizer = new BoxSizer();\n            let widgetSizer = new BoxSizer();\n            tabSizer.stretch = 0;\n            widgetSizer.stretch = 1;\n            this.tabBar = tabBar;\n            this.sizers = [tabSizer, widgetSizer];\n        }\n        /**\n         * The most recent value for the `top` edge of the layout box.\n         */\n        get top() {\n            return this._top;\n        }\n        /**\n         * The most recent value for the `left` edge of the layout box.\n         */\n        get left() {\n            return this._left;\n        }\n        /**\n         * The most recent value for the `width` of the layout box.\n         */\n        get width() {\n            return this._width;\n        }\n        /**\n         * The most recent value for the `height` of the layout box.\n         */\n        get height() {\n            return this._height;\n        }\n        /**\n         * Create an iterator for all widgets in the layout tree.\n         */\n        *iterAllWidgets() {\n            yield this.tabBar;\n            yield* this.iterUserWidgets();\n        }\n        /**\n         * Create an iterator for the user widgets in the layout tree.\n         */\n        *iterUserWidgets() {\n            for (const title of this.tabBar.titles) {\n                yield title.owner;\n            }\n        }\n        /**\n         * Create an iterator for the selected widgets in the layout tree.\n         */\n        *iterSelectedWidgets() {\n            let title = this.tabBar.currentTitle;\n            if (title) {\n                yield title.owner;\n            }\n        }\n        /**\n         * Create an iterator for the tab bars in the layout tree.\n         */\n        *iterTabBars() {\n            yield this.tabBar;\n        }\n        /**\n         * Create an iterator for the handles in the layout tree.\n         */\n        // eslint-disable-next-line require-yield\n        *iterHandles() {\n            return;\n        }\n        /**\n         * Find the tab layout node which contains the given widget.\n         */\n        findTabNode(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        findSplitNode(handle) {\n            return null;\n        }\n        /**\n         * Find the first tab layout node in a layout tree.\n         */\n        findFirstTabNode() {\n            return this;\n        }\n        /**\n         * Find the tab layout node which contains the local point.\n         */\n        hitTestTabNodes(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        createConfig() {\n            let widgets = this.tabBar.titles.map(title => title.owner);\n            let currentIndex = this.tabBar.currentIndex;\n            return { type: 'tab-area', widgets, 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        holdAllSizes() {\n            return;\n        }\n        /**\n         * Fit the layout tree.\n         */\n        fit(spacing, items) {\n            // Set up the limit variables.\n            let minWidth = 0;\n            let minHeight = 0;\n            let maxWidth = Infinity;\n            let maxHeight = Infinity;\n            // Lookup the tab bar layout item.\n            let tabBarItem = items.get(this.tabBar);\n            // Lookup the widget layout item.\n            let current = this.tabBar.currentTitle;\n            let widgetItem = current ? items.get(current.owner) : undefined;\n            // Lookup the tab bar and widget sizers.\n            let [tabBarSizer, widgetSizer] = this.sizers;\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, minHeight, maxWidth, maxHeight };\n        }\n        /**\n         * Update the layout tree.\n         */\n        update(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            let tabBarItem = items.get(this.tabBar);\n            // Lookup the widget layout item.\n            let current = this.tabBar.currentTitle;\n            let 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                let 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                let size = this.sizers[1].size;\n                widgetItem.update(left, top, width, size);\n            }\n        }\n    }\n    Private.TabLayoutNode = TabLayoutNode;\n    /**\n     * A layout node which holds the data for a split area.\n     */\n    class SplitLayoutNode {\n        /**\n         * Construct a new split layout node.\n         *\n         * @param orientation - The orientation of the node.\n         */\n        constructor(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        *iterAllWidgets() {\n            for (const child of this.children) {\n                yield* child.iterAllWidgets();\n            }\n        }\n        /**\n         * Create an iterator for the user widgets in the layout tree.\n         */\n        *iterUserWidgets() {\n            for (const child of this.children) {\n                yield* child.iterUserWidgets();\n            }\n        }\n        /**\n         * Create an iterator for the selected widgets in the layout tree.\n         */\n        *iterSelectedWidgets() {\n            for (const child of this.children) {\n                yield* child.iterSelectedWidgets();\n            }\n        }\n        /**\n         * Create an iterator for the tab bars in the layout tree.\n         */\n        *iterTabBars() {\n            for (const child of this.children) {\n                yield* child.iterTabBars();\n            }\n        }\n        /**\n         * Create an iterator for the handles in the layout tree.\n         */\n        *iterHandles() {\n            yield* this.handles;\n            for (const child of this.children) {\n                yield* child.iterHandles();\n            }\n        }\n        /**\n         * Find the tab layout node which contains the given widget.\n         */\n        findTabNode(widget) {\n            for (let i = 0, n = this.children.length; i < n; ++i) {\n                let 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        findSplitNode(handle) {\n            let index = this.handles.indexOf(handle);\n            if (index !== -1) {\n                return { index, node: this };\n            }\n            for (let i = 0, n = this.children.length; i < n; ++i) {\n                let 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        findFirstTabNode() {\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        hitTestTabNodes(x, y) {\n            for (let i = 0, n = this.children.length; i < n; ++i) {\n                let 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        createConfig() {\n            let orientation = this.orientation;\n            let sizes = this.createNormalizedSizes();\n            let children = this.children.map(child => child.createConfig());\n            return { type: 'split-area', orientation, children, sizes };\n        }\n        /**\n         * Sync the visibility and orientation of the handles.\n         */\n        syncHandles() {\n            this.handles.forEach((handle, i) => {\n                handle.setAttribute('data-orientation', this.orientation);\n                if (i === this.handles.length - 1) {\n                    handle.classList.add('lm-mod-hidden');\n                }\n                else {\n                    handle.classList.remove('lm-mod-hidden');\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        holdSizes() {\n            for (const sizer of this.sizers) {\n                sizer.sizeHint = sizer.size;\n            }\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        holdAllSizes() {\n            for (const child of this.children) {\n                child.holdAllSizes();\n            }\n            this.holdSizes();\n        }\n        /**\n         * Normalize the sizes of the split layout node.\n         */\n        normalizeSizes() {\n            // Bail early if the sizers are empty.\n            let 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            let sum = this.sizers.reduce((v, sizer) => v + sizer.sizeHint, 0);\n            // Normalize the sizes based on the sum.\n            if (sum === 0) {\n                for (const sizer of this.sizers) {\n                    sizer.size = sizer.sizeHint = 1 / n;\n                }\n            }\n            else {\n                for (const sizer of this.sizers) {\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        createNormalizedSizes() {\n            // Bail early if the sizers are empty.\n            let n = this.sizers.length;\n            if (n === 0) {\n                return [];\n            }\n            // Grab the current sizes of the sizers.\n            let sizes = this.sizers.map(sizer => sizer.size);\n            // Compute the sum of the sizes.\n            let sum = sizes.reduce((v, size) => v + size, 0);\n            // Normalize the sizes based on the sum.\n            if (sum === 0) {\n                for (let i = sizes.length - 1; i > -1; i--) {\n                    sizes[i] = 1 / n;\n                }\n            }\n            else {\n                for (let i = sizes.length - 1; i > -1; i--) {\n                    sizes[i] /= sum;\n                }\n            }\n            // Return the normalized sizes.\n            return sizes;\n        }\n        /**\n         * Fit the layout tree.\n         */\n        fit(spacing, items) {\n            // Compute the required fixed space.\n            let horizontal = this.orientation === 'horizontal';\n            let fixed = Math.max(0, this.children.length - 1) * spacing;\n            // Set up the limit variables.\n            let minWidth = horizontal ? fixed : 0;\n            let minHeight = horizontal ? 0 : fixed;\n            let maxWidth = Infinity;\n            let maxHeight = Infinity;\n            // Fit the children and update the limits.\n            for (let i = 0, n = this.children.length; i < n; ++i) {\n                let 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, minHeight, maxWidth, maxHeight };\n        }\n        /**\n         * Update the layout tree.\n         */\n        update(left, top, width, height, spacing, items) {\n            // Compute the available layout space.\n            let horizontal = this.orientation === 'horizontal';\n            let fixed = Math.max(0, this.children.length - 1) * spacing;\n            let space = Math.max(0, (horizontal ? width : height) - fixed);\n            // De-normalize the sizes if needed.\n            if (this.normalized) {\n                for (const sizer of this.sizers) {\n                    sizer.sizeHint *= space;\n                }\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 (let i = 0, n = this.children.length; i < n; ++i) {\n                let child = this.children[i];\n                let size = this.sizers[i].size;\n                let 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    }\n    Private.SplitLayoutNode = SplitLayoutNode;\n    function addAria(widget, tabBar) {\n        widget.node.setAttribute('role', 'tabpanel');\n        let renderer = tabBar.renderer;\n        if (renderer instanceof TabBar.Renderer) {\n            let tabId = renderer.createTabKey({\n                title: widget.title,\n                current: false,\n                zIndex: 0\n            });\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        let widgets = [];\n        // Filter the config for unique widgets.\n        for (const widget of config.widgets) {\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        let 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, 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        let orientation = config.orientation;\n        let children = [];\n        let sizes = [];\n        // Normalize the config children.\n        for (let i = 0, n = config.children.length; i < n; ++i) {\n            // Normalize the child config.\n            let 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(...child.children);\n                sizes.push(...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, children, sizes };\n    }\n    /**\n     * Convert a normalized tab area config into a layout tree.\n     */\n    function realizeTabAreaConfig(config, renderer, document) {\n        // Create the tab bar for the layout node.\n        let tabBar = renderer.createTabBar(document);\n        // Hide each widget and add it to the tab bar.\n        for (const widget of config.widgets) {\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, document) {\n        // Create the split layout node.\n        let node = new SplitLayoutNode(config.orientation);\n        // Add each child to the layout node.\n        config.children.forEach((child, i) => {\n            // Create the child data for the layout node.\n            let childNode = realizeAreaConfig(child, renderer, document);\n            let sizer = createSizer(config.sizes[i]);\n            let 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$6 || (Private$6 = {}));\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 widget which provides a flexible docking area for widgets.\n *\n * #### Notes\n * See also the related [example](../../examples/dockpanel/index.html) and\n * its [source](https://github.com/jupyterlab/lumino/tree/main/examples/example-dockpanel).\n */\nclass DockPanel extends Widget {\n    /**\n     * Construct a new dock panel.\n     *\n     * @param options - The options for initializing the panel.\n     */\n    constructor(options = {}) {\n        super();\n        this._drag = null;\n        this._tabsMovable = true;\n        this._tabsConstrained = false;\n        this._addButtonEnabled = false;\n        this._pressData = null;\n        this._layoutModified = new Signal(this);\n        this._addRequested = new Signal(this);\n        this.addClass('lm-DockPanel');\n        this._document = options.document || document;\n        this._mode = options.mode || 'multiple-document';\n        this._renderer = options.renderer || DockPanel.defaultRenderer;\n        this._edges = options.edges || Private$5.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        let renderer = {\n            createTabBar: () => this._createTabBar(),\n            createHandle: () => this._createHandle()\n        };\n        // Set up the dock layout for the panel.\n        this.layout = new DockLayout({\n            document: this._document,\n            renderer,\n            spacing: options.spacing,\n            hiddenMode: options.hiddenMode\n        });\n        // Set up the overlay drop indicator.\n        this.overlay = options.overlay || new DockPanel.Overlay();\n        this.node.appendChild(this.overlay.node);\n    }\n    /**\n     * Dispose of the resources held by the panel.\n     */\n    dispose() {\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.dispose();\n    }\n    /**\n     * The method for hiding widgets.\n     */\n    get hiddenMode() {\n        return this.layout.hiddenMode;\n    }\n    /**\n     * Set the method for hiding widgets.\n     */\n    set hiddenMode(v) {\n        this.layout.hiddenMode = v;\n    }\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 layoutModified() {\n        return this._layoutModified;\n    }\n    /**\n     * A signal emitted when the add button on a tab bar is clicked.\n     *\n     */\n    get addRequested() {\n        return this._addRequested;\n    }\n    /**\n     * The renderer used by the dock panel.\n     */\n    get renderer() {\n        return this.layout.renderer;\n    }\n    /**\n     * Get the spacing between the widgets.\n     */\n    get spacing() {\n        return this.layout.spacing;\n    }\n    /**\n     * Set the spacing between the widgets.\n     */\n    set spacing(value) {\n        this.layout.spacing = value;\n    }\n    /**\n     * Get the mode for the dock panel.\n     */\n    get mode() {\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 mode(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        let layout = this.layout;\n        // Configure the layout for the specified mode.\n        switch (value) {\n            case 'multiple-document':\n                for (const tabBar of layout.tabBars()) {\n                    tabBar.show();\n                }\n                break;\n            case 'single-document':\n                layout.restoreLayout(Private$5.createSingleDocumentConfig(this));\n                break;\n            default:\n                throw 'unreachable';\n        }\n        // Schedule an emit of the layout modified signal.\n        MessageLoop.postMessage(this, Private$5.LayoutModified);\n    }\n    /**\n     * Whether the tabs can be dragged / moved at runtime.\n     */\n    get tabsMovable() {\n        return this._tabsMovable;\n    }\n    /**\n     * Enable / Disable draggable / movable tabs.\n     */\n    set tabsMovable(value) {\n        this._tabsMovable = value;\n        for (const tabBar of this.tabBars()) {\n            tabBar.tabsMovable = value;\n        }\n    }\n    /**\n     * Whether the tabs are constrained to their source dock panel\n     */\n    get tabsConstrained() {\n        return this._tabsConstrained;\n    }\n    /**\n     * Constrain/Allow tabs to be dragged outside of this dock panel\n     */\n    set tabsConstrained(value) {\n        this._tabsConstrained = value;\n    }\n    /**\n     * Whether the add buttons for each tab bar are enabled.\n     */\n    get addButtonEnabled() {\n        return this._addButtonEnabled;\n    }\n    /**\n     * Set whether the add buttons for each tab bar are enabled.\n     */\n    set addButtonEnabled(value) {\n        this._addButtonEnabled = value;\n        for (const tabBar of this.tabBars()) {\n            tabBar.addButtonEnabled = value;\n        }\n    }\n    /**\n     * Whether the dock panel is empty.\n     */\n    get isEmpty() {\n        return this.layout.isEmpty;\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    *widgets() {\n        yield* 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    *selectedWidgets() {\n        yield* 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    *tabBars() {\n        yield* 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    *handles() {\n        yield* 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    selectWidget(widget) {\n        // Find the tab bar which contains the widget.\n        let tabBar = find(this.tabBars(), 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    activateWidget(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    saveLayout() {\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    restoreLayout(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 (Platform.IS_EDGE || Platform.IS_IE) {\n            MessageLoop.flush();\n        }\n        // Schedule an emit of the layout modified signal.\n        MessageLoop.postMessage(this, Private$5.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    addWidget(widget, 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        MessageLoop.postMessage(this, Private$5.LayoutModified);\n    }\n    /**\n     * Process a message sent to the widget.\n     *\n     * @param msg - The message sent to the widget.\n     */\n    processMessage(msg) {\n        if (msg.type === 'layout-modified') {\n            this._layoutModified.emit(undefined);\n        }\n        else {\n            super.processMessage(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    handleEvent(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 'pointerdown':\n                this._evtPointerDown(event);\n                break;\n            case 'pointermove':\n                this._evtPointerMove(event);\n                break;\n            case 'pointerup':\n                this._evtPointerUp(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    onBeforeAttach(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('pointerdown', this);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(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('pointerdown', this);\n        this._releaseMouse();\n    }\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    onChildAdded(msg) {\n        // Ignore the generated tab bars.\n        if (Private$5.isGeneratedTabBarProperty.get(msg.child)) {\n            return;\n        }\n        // Add the widget class to the child.\n        msg.child.addClass('lm-DockPanel-widget');\n    }\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    onChildRemoved(msg) {\n        // Ignore the generated tab bars.\n        if (Private$5.isGeneratedTabBarProperty.get(msg.child)) {\n            return;\n        }\n        // Remove the widget class from the child.\n        msg.child.removeClass('lm-DockPanel-widget');\n        // Schedule an emit of the layout modified signal.\n        MessageLoop.postMessage(this, Private$5.LayoutModified);\n    }\n    /**\n     * Handle the `'lm-dragenter'` event for the dock panel.\n     */\n    _evtDragEnter(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    _evtDragLeave(event) {\n        // Mark the event as handled.\n        event.preventDefault();\n        if (this._tabsConstrained && event.source !== this)\n            return;\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    _evtDragOver(event) {\n        // Mark the event as handled.\n        event.preventDefault();\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) ||\n            this._showOverlay(event.clientX, event.clientY) === 'invalid') {\n            event.dropAction = 'none';\n        }\n        else {\n            event.stopPropagation();\n            event.dropAction = event.proposedAction;\n        }\n    }\n    /**\n     * Handle the `'lm-drop'` event for the dock panel.\n     */\n    _evtDrop(event) {\n        // Mark the event as handled.\n        event.preventDefault();\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        let { clientX, clientY } = event;\n        let { zone, target } = Private$5.findDropTarget(this, clientX, clientY, this._edges);\n        // Bail if the drop zone is invalid.\n        if ((this._tabsConstrained && event.source !== this) ||\n            zone === 'invalid') {\n            event.dropAction = 'none';\n            return;\n        }\n        // Bail if the factory mime type has invalid data.\n        let mimeData = event.mimeData;\n        let 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        let 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        let ref = target ? Private$5.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 });\n                break;\n            case 'widget-top':\n                this.addWidget(widget, { mode: 'split-top', ref });\n                break;\n            case 'widget-left':\n                this.addWidget(widget, { mode: 'split-left', ref });\n                break;\n            case 'widget-right':\n                this.addWidget(widget, { mode: 'split-right', ref });\n                break;\n            case 'widget-bottom':\n                this.addWidget(widget, { mode: 'split-bottom', ref });\n                break;\n            case 'widget-tab':\n                this.addWidget(widget, { mode: 'tab-after', ref });\n                break;\n            default:\n                throw 'unreachable';\n        }\n        // Accept the proposed drop action.\n        event.dropAction = event.proposedAction;\n        // Stop propagation if we have not bailed so far.\n        event.stopPropagation();\n        // Activate the dropped widget.\n        this.activateWidget(widget);\n    }\n    /**\n     * Handle the `'keydown'` event for the dock panel.\n     */\n    _evtKeyDown(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            MessageLoop.postMessage(this, Private$5.LayoutModified);\n        }\n    }\n    /**\n     * Handle the `'pointerdown'` event for the dock panel.\n     */\n    _evtPointerDown(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        let layout = this.layout;\n        let target = event.target;\n        let handle = find(layout.handles(), handle => 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        this._document.addEventListener('keydown', this, true);\n        this._document.addEventListener('pointerup', this, true);\n        this._document.addEventListener('pointermove', this, true);\n        this._document.addEventListener('contextmenu', this, true);\n        // Compute the offset deltas for the handle press.\n        let rect = handle.getBoundingClientRect();\n        let deltaX = event.clientX - rect.left;\n        let deltaY = event.clientY - rect.top;\n        // Override the cursor and store the press data.\n        let style = window.getComputedStyle(handle);\n        let override = Drag.overrideCursor(style.cursor, this._document);\n        this._pressData = { handle, deltaX, deltaY, override };\n    }\n    /**\n     * Handle the `'pointermove'` event for the dock panel.\n     */\n    _evtPointerMove(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        let rect = this.node.getBoundingClientRect();\n        let xPos = event.clientX - rect.left - this._pressData.deltaX;\n        let yPos = event.clientY - rect.top - this._pressData.deltaY;\n        // Set the handle as close to the desired position as possible.\n        let layout = this.layout;\n        layout.moveHandle(this._pressData.handle, xPos, yPos);\n    }\n    /**\n     * Handle the `'pointerup'` event for the dock panel.\n     */\n    _evtPointerUp(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        MessageLoop.postMessage(this, Private$5.LayoutModified);\n    }\n    /**\n     * Release the mouse grab for the dock panel.\n     */\n    _releaseMouse() {\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        this._document.removeEventListener('keydown', this, true);\n        this._document.removeEventListener('pointerup', this, true);\n        this._document.removeEventListener('pointermove', this, true);\n        this._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    _showOverlay(clientX, clientY) {\n        // Find the dock target for the given client position.\n        let { zone, target } = Private$5.findDropTarget(this, clientX, clientY, this._edges);\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        let top;\n        let left;\n        let right;\n        let bottom;\n        let box = ElementExt.boxSizing(this.node); // TODO cache this?\n        let 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$5.GOLDEN_RATIO;\n                break;\n            case 'root-left':\n                top = box.paddingTop;\n                left = box.paddingLeft;\n                right = rect.width * Private$5.GOLDEN_RATIO;\n                bottom = box.paddingBottom;\n                break;\n            case 'root-right':\n                top = box.paddingTop;\n                left = rect.width * Private$5.GOLDEN_RATIO;\n                right = box.paddingRight;\n                bottom = box.paddingBottom;\n                break;\n            case 'root-bottom':\n                top = rect.height * Private$5.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                const 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            }\n            default:\n                throw 'unreachable';\n        }\n        // Show the overlay with the computed geometry.\n        this.overlay.show({ top, left, right, 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    _createTabBar() {\n        // Create the tab bar.\n        let tabBar = this._renderer.createTabBar(this._document);\n        // Set the generated tab bar property for the tab bar.\n        Private$5.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    _createHandle() {\n        return this._renderer.createHandle();\n    }\n    /**\n     * Handle the `tabMoved` signal from a tab bar.\n     */\n    _onTabMoved() {\n        MessageLoop.postMessage(this, Private$5.LayoutModified);\n    }\n    /**\n     * Handle the `currentChanged` signal from a tab bar.\n     */\n    _onCurrentChanged(sender, args) {\n        // Extract the previous and current title from the args.\n        let { previousTitle, currentTitle } = args;\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 (Platform.IS_EDGE || Platform.IS_IE) {\n            MessageLoop.flush();\n        }\n        // Schedule an emit of the layout modified signal.\n        MessageLoop.postMessage(this, Private$5.LayoutModified);\n    }\n    /**\n     * Handle the `addRequested` signal from a tab bar.\n     */\n    _onTabAddRequested(sender) {\n        this._addRequested.emit(sender);\n    }\n    /**\n     * Handle the `tabActivateRequested` signal from a tab bar.\n     */\n    _onTabActivateRequested(sender, args) {\n        args.title.owner.activate();\n    }\n    /**\n     * Handle the `tabCloseRequested` signal from a tab bar.\n     */\n    _onTabCloseRequested(sender, args) {\n        args.title.owner.close();\n    }\n    /**\n     * Handle the `tabDetachRequested` signal from a tab bar.\n     */\n    _onTabDetachRequested(sender, args) {\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        let { title, tab, clientX, clientY, offset } = args;\n        // Setup the mime data for the drag operation.\n        let mimeData = new MimeData();\n        let factory = () => title.owner;\n        mimeData.setData('application/vnd.lumino.widget-factory', factory);\n        // Create the drag image for the drag operation.\n        let dragImage = tab.cloneNode(true);\n        if (offset) {\n            dragImage.style.top = `-${offset.y}px`;\n            dragImage.style.left = `-${offset.x}px`;\n        }\n        // Create the drag object to manage the drag-drop operation.\n        this._drag = new Drag({\n            document: this._document,\n            mimeData,\n            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        let cleanup = () => {\n            this._drag = null;\n            tab.classList.remove('lm-mod-hidden');\n        };\n        // Start the drag operation and cleanup when done.\n        this._drag.start(clientX, clientY).then(cleanup);\n    }\n}\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    class Overlay {\n        /**\n         * Construct a new overlay.\n         */\n        constructor() {\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            this.node.style.position = 'absolute';\n            this.node.style.contain = 'strict';\n        }\n        /**\n         * Show the overlay using the given overlay geometry.\n         *\n         * @param geo - The desired geometry for the overlay.\n         */\n        show(geo) {\n            // Update the position of the overlay.\n            let 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        }\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        hide(delay) {\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                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(() => {\n                this._timer = -1;\n                this._hidden = true;\n                this.node.classList.add('lm-mod-hidden');\n            }, delay);\n        }\n    }\n    DockPanel.Overlay = Overlay;\n    /**\n     * The default implementation of `IRenderer`.\n     */\n    class Renderer {\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        createTabBar(document) {\n            let bar = new TabBar({ document });\n            bar.addClass('lm-DockPanel-tabBar');\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        createHandle() {\n            let handle = document.createElement('div');\n            handle.className = 'lm-DockPanel-handle';\n            return handle;\n        }\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$5;\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 ConflatableMessage('layout-modified');\n    /**\n     * An attached property used to track generated tab bars.\n     */\n    Private.isGeneratedTabBarProperty = new AttachedProperty({\n        name: 'isGeneratedTabBar',\n        create: () => 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        let widgets = Array.from(panel.widgets());\n        // Get the first selected widget in the panel.\n        let selected = panel.selectedWidgets().next().value;\n        // Compute the current index for the new config.\n        let currentIndex = selected ? widgets.indexOf(selected) : -1;\n        // Return the single document config.\n        return { main: { type: 'tab-area', widgets, 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 (!ElementExt.hitTest(panel.node, clientX, clientY)) {\n            return { zone: 'invalid', target: null };\n        }\n        // Look up the layout for the panel.\n        let 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            let panelRect = panel.node.getBoundingClientRect();\n            // Compute the distance to each edge of the panel.\n            let pl = clientX - panelRect.left + 1;\n            let pt = clientY - panelRect.top + 1;\n            let pr = panelRect.right - clientX;\n            let pb = panelRect.bottom - clientY;\n            // Find the minimum distance to an edge.\n            let 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        let 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 };\n        }\n        // Compute the distance to each edge of the tab area.\n        let al = target.x - target.left + 1;\n        let at = target.y - target.top + 1;\n        let ar = target.left + target.width - target.x;\n        let ab = target.top + target.height - target.y;\n        const tabHeight = target.tabBar.node.getBoundingClientRect().height;\n        if (at < tabHeight) {\n            return { zone: 'widget-tab', target };\n        }\n        // Get the X and Y edge sizes for the area.\n        let rx = Math.round(target.width / 3);\n        let 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 };\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        let ad = Math.min(al, at, ar, ab);\n        // Find the widget zone for the area edge.\n        let 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, 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$5 || (Private$5 = {}));\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 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 */\nclass FocusTracker {\n    constructor() {\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 Signal(this);\n        this._currentChanged = new Signal(this);\n    }\n    /**\n     * Dispose of the resources held by the tracker.\n     */\n    dispose() {\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        Signal.clearData(this);\n        // Remove all event listeners.\n        for (const widget of this._widgets) {\n            widget.node.removeEventListener('focus', this, true);\n            widget.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    /**\n     * A signal emitted when the current widget has changed.\n     */\n    get currentChanged() {\n        return this._currentChanged;\n    }\n    /**\n     * A signal emitted when the active widget has changed.\n     */\n    get activeChanged() {\n        return this._activeChanged;\n    }\n    /**\n     * A flag indicating whether the tracker is disposed.\n     */\n    get isDisposed() {\n        return this._counter < 0;\n    }\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 currentWidget() {\n        return this._currentWidget;\n    }\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 activeWidget() {\n        return this._activeWidget;\n    }\n    /**\n     * A read only array of the widgets being tracked.\n     */\n    get widgets() {\n        return this._widgets;\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    focusNumber(widget) {\n        let 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    has(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    add(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        let focused = widget.node.contains(document.activeElement);\n        // Set up the initial focus number.\n        let 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    remove(widget) {\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        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        let valid = this._widgets.filter(w => this._numbers.get(w) !== -1);\n        // Get the valid widget with the max focus number.\n        let previous = max(valid, (first, second) => {\n            let a = this._numbers.get(first);\n            let 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    handleEvent(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    _setWidgets(current, active) {\n        // Swap the current widget.\n        let oldCurrent = this._currentWidget;\n        this._currentWidget = current;\n        // Swap the active widget.\n        let 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    _evtFocus(event) {\n        // Find the widget which gained focus, which is known to exist.\n        let 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    _evtBlur(event) {\n        // Find the widget which lost focus, which is known to exist.\n        let widget = this._nodes.get(event.currentTarget);\n        // Get the node which being focused after this blur.\n        let 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 (!find(this._widgets, w => 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    _onWidgetDisposed(sender) {\n        this.remove(sender);\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 layout which arranges its widgets in a grid.\n */\nclass GridLayout extends Layout {\n    /**\n     * Construct a new grid layout.\n     *\n     * @param options - The options for initializing the layout.\n     */\n    constructor(options = {}) {\n        super(options);\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$4.reallocSizers(this._rowSizers, options.rowCount);\n        }\n        if (options.columnCount !== undefined) {\n            Private$4.reallocSizers(this._columnSizers, options.columnCount);\n        }\n        if (options.rowSpacing !== undefined) {\n            this._rowSpacing = Private$4.clampValue(options.rowSpacing);\n        }\n        if (options.columnSpacing !== undefined) {\n            this._columnSpacing = Private$4.clampValue(options.columnSpacing);\n        }\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    dispose() {\n        // Dispose of the widgets and layout items.\n        for (const item of this._items) {\n            let 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.dispose();\n    }\n    /**\n     * Get the number of rows in the layout.\n     */\n    get rowCount() {\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 rowCount(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$4.reallocSizers(this._rowSizers, value);\n        // Schedule a fit of the parent.\n        if (this.parent) {\n            this.parent.fit();\n        }\n    }\n    /**\n     * Get the number of columns in the layout.\n     */\n    get columnCount() {\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 columnCount(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$4.reallocSizers(this._columnSizers, value);\n        // Schedule a fit of the parent.\n        if (this.parent) {\n            this.parent.fit();\n        }\n    }\n    /**\n     * Get the row spacing for the layout.\n     */\n    get rowSpacing() {\n        return this._rowSpacing;\n    }\n    /**\n     * Set the row spacing for the layout.\n     */\n    set rowSpacing(value) {\n        // Clamp the spacing to the allowed range.\n        value = Private$4.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    /**\n     * Get the column spacing for the layout.\n     */\n    get columnSpacing() {\n        return this._columnSpacing;\n    }\n    /**\n     * Set the col spacing for the layout.\n     */\n    set columnSpacing(value) {\n        // Clamp the spacing to the allowed range.\n        value = Private$4.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    /**\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    rowStretch(index) {\n        let 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    setRowStretch(index, value) {\n        // Look up the row sizer.\n        let 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$4.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    columnStretch(index) {\n        let 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    setColumnStretch(index, value) {\n        // Look up the column sizer.\n        let 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$4.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    *[Symbol.iterator]() {\n        for (const item of this._items) {\n            yield item.widget;\n        }\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    addWidget(widget) {\n        // Look up the index for the widget.\n        let i = ArrayExt.findFirstIndex(this._items, it => 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    removeWidget(widget) {\n        // Look up the index for the widget.\n        let i = ArrayExt.findFirstIndex(this._items, it => 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        let item = 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    init() {\n        super.init();\n        for (const widget of this) {\n            this.attachWidget(widget);\n        }\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    attachWidget(widget) {\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    detachWidget(widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    onBeforeShow(msg) {\n        super.onBeforeShow(msg);\n        this.parent.update();\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(msg) {\n        super.onBeforeAttach(msg);\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    onChildShown(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    onChildHidden(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    onResize(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    onUpdateRequest(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    onFitRequest(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    _fit() {\n        // Reset the min sizes of the sizers.\n        for (let i = 0, n = this.rowCount; i < n; ++i) {\n            this._rowSizers[i].minSize = 0;\n        }\n        for (let i = 0, n = this.columnCount; i < n; ++i) {\n            this._columnSizers[i].minSize = 0;\n        }\n        // Filter for the visible layout items.\n        let items = this._items.filter(it => !it.isHidden);\n        // Fit the layout items.\n        for (let i = 0, n = items.length; i < n; ++i) {\n            items[i].fit();\n        }\n        // Get the max row and column index.\n        let maxRow = this.rowCount - 1;\n        let maxCol = this.columnCount - 1;\n        // Sort the items by row span.\n        items.sort(Private$4.rowSpanCmp);\n        // Update the min sizes of the row sizers.\n        for (let i = 0, n = items.length; i < n; ++i) {\n            // Fetch the item.\n            let item = items[i];\n            // Get the row bounds for the item.\n            let config = GridLayout.getCellConfig(item.widget);\n            let r1 = Math.min(config.row, maxRow);\n            let r2 = Math.min(config.row + config.rowSpan - 1, maxRow);\n            // Distribute the minimum height to the sizers as needed.\n            Private$4.distributeMin(this._rowSizers, r1, r2, item.minHeight);\n        }\n        // Sort the items by column span.\n        items.sort(Private$4.columnSpanCmp);\n        // Update the min sizes of the column sizers.\n        for (let i = 0, n = items.length; i < n; ++i) {\n            // Fetch the item.\n            let item = items[i];\n            // Get the column bounds for the item.\n            let config = GridLayout.getCellConfig(item.widget);\n            let c1 = Math.min(config.column, maxCol);\n            let c2 = Math.min(config.column + config.columnSpan - 1, maxCol);\n            // Distribute the minimum width to the sizers as needed.\n            Private$4.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            MessageLoop.sendMessage(this.parent, Widget.Msg.UpdateRequest);\n            return;\n        }\n        // Set up the computed min size.\n        let minH = maxRow * this._rowSpacing;\n        let minW = maxCol * this._columnSpacing;\n        // Add the sizer minimums to the computed min size.\n        for (let i = 0, n = this.rowCount; i < n; ++i) {\n            minH += this._rowSizers[i].minSize;\n        }\n        for (let 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        let box = (this._box = ElementExt.boxSizing(this.parent.node));\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        let 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            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            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    _update(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 = ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the layout area adjusted for border and padding.\n        let top = this._box.paddingTop;\n        let left = this._box.paddingLeft;\n        let width = offsetWidth - this._box.horizontalSum;\n        let height = offsetHeight - this._box.verticalSum;\n        // Get the max row and column index.\n        let maxRow = this.rowCount - 1;\n        let maxCol = this.columnCount - 1;\n        // Compute the total fixed row and column space.\n        let fixedRowSpace = maxRow * this._rowSpacing;\n        let 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 (let 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 (let 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 (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            let item = this._items[i];\n            // Ignore hidden items.\n            if (item.isHidden) {\n                continue;\n            }\n            // Fetch the cell bounds for the widget.\n            let config = GridLayout.getCellConfig(item.widget);\n            let r1 = Math.min(config.row, maxRow);\n            let c1 = Math.min(config.column, maxCol);\n            let r2 = Math.min(config.row + config.rowSpan - 1, maxRow);\n            let c2 = Math.min(config.column + config.columnSpan - 1, maxCol);\n            // Compute the cell geometry.\n            let x = this._columnStarts[c1];\n            let y = this._rowStarts[r1];\n            let w = this._columnStarts[c2] + this._columnSizers[c2].size - x;\n            let 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}\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$4.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$4.cellConfigProperty.set(widget, Private$4.normalizeConfig(value));\n    }\n    GridLayout.setCellConfig = setCellConfig;\n})(GridLayout || (GridLayout = {}));\n/**\n * The namespace for the module implementation details.\n */\nvar Private$4;\n(function (Private) {\n    /**\n     * The property descriptor for the widget cell config.\n     */\n    Private.cellConfigProperty = new AttachedProperty({\n        name: 'cellConfig',\n        create: () => ({ 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        let row = Math.max(0, Math.floor(config.row || 0));\n        let column = Math.max(0, Math.floor(config.column || 0));\n        let rowSpan = Math.max(1, Math.floor(config.rowSpan || 0));\n        let columnSpan = Math.max(1, Math.floor(config.columnSpan || 0));\n        return { row, column, rowSpan, 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        let c1 = Private.cellConfigProperty.get(a.widget);\n        let 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        let c1 = Private.cellConfigProperty.get(a.widget);\n        let 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            let 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        let totalMin = 0;\n        for (let 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        let portion = (minSize - totalMin) / (i2 - i1 + 1);\n        // Add the portion to each sizer.\n        for (let 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$4 || (Private$4 = {}));\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 widget which displays menus as a canonical menu bar.\n *\n * #### Notes\n * See also the related [example](../../examples/menubar/index.html) and\n * its [source](https://github.com/jupyterlab/lumino/tree/main/examples/example-menubar).\n */\nclass MenuBar extends Widget {\n    /**\n     * Construct a new menu bar.\n     *\n     * @param options - The options for initializing the menu bar.\n     */\n    constructor(options = {}) {\n        super({ node: Private$3.createNode() });\n        // Track the index of the item that is currently focused or hovered. -1 means nothing focused or hovered.\n        this._activeIndex = -1;\n        // Track which item can be focused using the TAB key. Unlike _activeIndex will\n        // always point to a menuitem. Whenever you update this value, it's important\n        // to follow it with an \"update-request\" message so that the `tabindex`\n        // attribute on each menubar item gets properly updated.\n        this._tabFocusIndex = 0;\n        this._menus = [];\n        this._childMenu = null;\n        this._overflowMenu = null;\n        this._menuItemSizes = [];\n        this._overflowIndex = -1;\n        this.addClass('lm-MenuBar');\n        this.setFlag(Widget.Flag.DisallowLayout);\n        this.renderer = options.renderer || MenuBar.defaultRenderer;\n        this._forceItemsPosition = options.forceItemsPosition || {\n            forceX: true,\n            forceY: true\n        };\n        this._overflowMenuOptions = options.overflowMenuOptions || {\n            isVisible: true\n        };\n    }\n    /**\n     * Dispose of the resources held by the widget.\n     */\n    dispose() {\n        this._closeChildMenu();\n        this._menus.length = 0;\n        super.dispose();\n    }\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 childMenu() {\n        return this._childMenu;\n    }\n    /**\n     * The overflow index of the menu bar.\n     */\n    get overflowIndex() {\n        return this._overflowIndex;\n    }\n    /**\n     * The overflow menu of the menu bar.\n     */\n    get overflowMenu() {\n        return this._overflowMenu;\n    }\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 contentNode() {\n        return this.node.getElementsByClassName('lm-MenuBar-content')[0];\n    }\n    /**\n     * Get the currently active menu.\n     */\n    get activeMenu() {\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 activeMenu(value) {\n        this.activeIndex = value ? this._menus.indexOf(value) : -1;\n    }\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 activeIndex() {\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 activeIndex(value) {\n        // Adjust the value for an out of range index.\n        if (value < 0 || value >= this._menus.length) {\n            value = -1;\n        }\n        // An empty menu cannot be active\n        if (value > -1 && this._menus[value].items.length === 0) {\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    /**\n     * A read-only array of the menus in the menu bar.\n     */\n    get menus() {\n        return this._menus;\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    openActiveMenu() {\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    addMenu(menu, update = true) {\n        this.insertMenu(this._menus.length, menu, update);\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    insertMenu(index, menu, update = true) {\n        // Close the child menu before making changes.\n        this._closeChildMenu();\n        // Look up the index of the menu.\n        let i = this._menus.indexOf(menu);\n        // Clamp the insert index to the array bounds.\n        let 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            ArrayExt.insert(this._menus, j, menu);\n            // Add the styling class to the menu.\n            menu.addClass('lm-MenuBar-menu');\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            if (update) {\n                this.update();\n            }\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        ArrayExt.move(this._menus, i, j);\n        // Schedule an update of the items.\n        if (update) {\n            this.update();\n        }\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    removeMenu(menu, update = true) {\n        this.removeMenuAt(this._menus.indexOf(menu), update);\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    removeMenuAt(index, update = true) {\n        // Close the child menu before making changes.\n        this._closeChildMenu();\n        // Remove the menu from the array.\n        let menu = 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        // Schedule an update of the items.\n        if (update) {\n            this.update();\n        }\n    }\n    /**\n     * Remove all menus from the menu bar.\n     */\n    clearMenus() {\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 (let menu of this._menus) {\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        }\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    handleEvent(event) {\n        switch (event.type) {\n            case 'keydown':\n                this._evtKeyDown(event);\n                break;\n            case 'pointerdown':\n                this._evtPointerDown(event);\n                break;\n            case 'pointermove':\n            case 'pointerleave':\n                this._evtPointerMove(event);\n                break;\n            case 'focusout':\n                this._evtFocusOut(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    onBeforeAttach(msg) {\n        this.node.addEventListener('keydown', this);\n        this.node.addEventListener('pointerdown', this);\n        this.node.addEventListener('pointermove', this);\n        this.node.addEventListener('pointerleave', this);\n        this.node.addEventListener('focusout', this);\n        this.node.addEventListener('contextmenu', this);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(msg) {\n        this.node.removeEventListener('keydown', this);\n        this.node.removeEventListener('pointerdown', this);\n        this.node.removeEventListener('pointermove', this);\n        this.node.removeEventListener('pointerleave', this);\n        this.node.removeEventListener('focusout', this);\n        this.node.removeEventListener('contextmenu', this);\n        this._closeChildMenu();\n    }\n    /**\n     * A message handler invoked on an `'activate-request'` message.\n     */\n    onActivateRequest(msg) {\n        if (this.isAttached) {\n            this._focusItemAt(0);\n        }\n    }\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    onResize(msg) {\n        this.update();\n        super.onResize(msg);\n    }\n    /**\n     * A message handler invoked on an `'update-request'` message.\n     */\n    onUpdateRequest(msg) {\n        var _a;\n        let menus = this._menus;\n        let renderer = this.renderer;\n        let activeIndex = this._activeIndex;\n        let tabFocusIndex = this._tabFocusIndex >= 0 && this._tabFocusIndex < menus.length\n            ? this._tabFocusIndex\n            : 0;\n        let length = this._overflowIndex > -1 ? this._overflowIndex : menus.length;\n        let totalMenuSize = 0;\n        let isVisible = false;\n        // Check that the overflow menu doesn't count\n        length = this._overflowMenu !== null ? length - 1 : length;\n        let content = new Array(length);\n        // Render visible menus\n        for (let i = 0; i < length; ++i) {\n            content[i] = renderer.renderItem({\n                title: menus[i].title,\n                active: i === activeIndex,\n                tabbable: i === tabFocusIndex,\n                disabled: menus[i].items.length === 0,\n                onfocus: () => {\n                    this._tabFocusIndex = i;\n                    this.activeIndex = i;\n                }\n            });\n            // Calculate size of current menu\n            totalMenuSize += this._menuItemSizes[i];\n            // Check if overflow menu is already rendered\n            if (menus[i].title.label === this._overflowMenuOptions.title) {\n                isVisible = true;\n                length--;\n            }\n        }\n        // Render overflow menu if needed and active\n        if (this._overflowMenuOptions.isVisible) {\n            if (this._overflowIndex > -1 && !isVisible) {\n                // Create overflow menu\n                if (this._overflowMenu === null) {\n                    const overflowMenuTitle = (_a = this._overflowMenuOptions.title) !== null && _a !== void 0 ? _a : '...';\n                    this._overflowMenu = new Menu({ commands: new CommandRegistry() });\n                    this._overflowMenu.title.label = overflowMenuTitle;\n                    this._overflowMenu.title.mnemonic = 0;\n                    this.addMenu(this._overflowMenu, false);\n                }\n                // Move menus to overflow menu\n                for (let i = menus.length - 2; i >= length; i--) {\n                    const submenu = this.menus[i];\n                    submenu.title.mnemonic = 0;\n                    this._overflowMenu.insertItem(0, {\n                        type: 'submenu',\n                        submenu: submenu\n                    });\n                    this.removeMenu(submenu, false);\n                }\n                content[length] = renderer.renderItem({\n                    title: this._overflowMenu.title,\n                    active: length === activeIndex && menus[length].items.length !== 0,\n                    tabbable: length === tabFocusIndex,\n                    disabled: menus[length].items.length === 0,\n                    onfocus: () => {\n                        this._tabFocusIndex = length;\n                        this.activeIndex = length;\n                    }\n                });\n                length++;\n            }\n            else if (this._overflowMenu !== null) {\n                // Remove submenus from overflow menu\n                let overflowMenuItems = this._overflowMenu.items;\n                let screenSize = this.node.offsetWidth;\n                let n = this._overflowMenu.items.length;\n                for (let i = 0; i < n; ++i) {\n                    let index = menus.length - 1 - i;\n                    if (screenSize - totalMenuSize > this._menuItemSizes[index]) {\n                        let menu = overflowMenuItems[0].submenu;\n                        this._overflowMenu.removeItemAt(0);\n                        this.insertMenu(length, menu, false);\n                        content[length] = renderer.renderItem({\n                            title: menu.title,\n                            active: false,\n                            tabbable: length === tabFocusIndex,\n                            disabled: menus[length].items.length === 0,\n                            onfocus: () => {\n                                this._tabFocusIndex = length;\n                                this.activeIndex = length;\n                            }\n                        });\n                        length++;\n                    }\n                }\n                if (this._overflowMenu.items.length === 0) {\n                    this.removeMenu(this._overflowMenu, false);\n                    content.pop();\n                    this._overflowMenu = null;\n                    this._overflowIndex = -1;\n                }\n            }\n        }\n        VirtualDOM.render(content, this.contentNode);\n        this._updateOverflowIndex();\n    }\n    /**\n     * Calculate and update the current overflow index.\n     */\n    _updateOverflowIndex() {\n        if (!this._overflowMenuOptions.isVisible) {\n            return;\n        }\n        // Get elements visible in the main menu bar\n        const itemMenus = this.contentNode.childNodes;\n        let screenSize = this.node.offsetWidth;\n        let totalMenuSize = 0;\n        let index = -1;\n        let n = itemMenus.length;\n        if (this._menuItemSizes.length == 0) {\n            // Check if it is the first resize and get info about menu items sizes\n            for (let i = 0; i < n; i++) {\n                let item = itemMenus[i];\n                // Add sizes to array\n                totalMenuSize += item.offsetWidth;\n                this._menuItemSizes.push(item.offsetWidth);\n                if (totalMenuSize > screenSize && index === -1) {\n                    index = i;\n                }\n            }\n        }\n        else {\n            // Calculate current menu size\n            for (let i = 0; i < this._menuItemSizes.length; i++) {\n                totalMenuSize += this._menuItemSizes[i];\n                if (totalMenuSize > screenSize) {\n                    index = i;\n                    break;\n                }\n            }\n        }\n        this._overflowIndex = index;\n    }\n    /**\n     * Handle the `'keydown'` event for the menu bar.\n     *\n     * #### Notes\n     * All keys are trapped except the tab key that is ignored.\n     */\n    _evtKeyDown(event) {\n        // Fetch the key code for the event.\n        let kc = event.keyCode;\n        // Reset the active index on tab, but do not trap the tab key.\n        if (kc === 9) {\n            this.activeIndex = -1;\n            return;\n        }\n        // A menu bar handles all other keydown events.\n        event.preventDefault();\n        event.stopPropagation();\n        // Enter, Space, Up Arrow, Down Arrow\n        if (kc === 13 || kc === 32 || kc === 38 || kc === 40) {\n            // The active index may have changed (for example, user hovers over an\n            // item with the mouse), so be sure to use the focus index.\n            this.activeIndex = this._tabFocusIndex;\n            if (this.activeIndex !== this._tabFocusIndex) {\n                // Bail if the setter refused to set activeIndex to tabFocusIndex\n                // because it means that the item at tabFocusIndex cannot be opened (for\n                // example, it has an empty menu)\n                return;\n            }\n            this.openActiveMenu();\n            return;\n        }\n        // Escape\n        if (kc === 27) {\n            this._closeChildMenu();\n            this._focusItemAt(this.activeIndex);\n            return;\n        }\n        // Left or Right Arrow\n        if (kc === 37 || kc === 39) {\n            let direction = kc === 37 ? -1 : 1;\n            let start = this._tabFocusIndex + direction;\n            let n = this._menus.length;\n            for (let i = 0; i < n; i++) {\n                let index = (n + start + direction * i) % n;\n                if (this._menus[index].items.length) {\n                    this._focusItemAt(index);\n                    return;\n                }\n            }\n            return;\n        }\n        // Get the pressed key character.\n        let key = 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        let start = this._activeIndex + 1;\n        let result = Private$3.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            this._focusItemAt(this.activeIndex);\n        }\n        else if (result.auto !== -1) {\n            this.activeIndex = result.auto;\n            this._focusItemAt(this.activeIndex);\n        }\n    }\n    /**\n     * Handle the `'pointerdown'` event for the menu bar.\n     */\n    _evtPointerDown(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 (!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.stopPropagation();\n        event.stopImmediatePropagation();\n        // Check if the mouse is over one of the menu items.\n        let index = ArrayExt.findFirstIndex(this.contentNode.children, node => {\n            return 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            // If we don't call preventDefault() here, then the item in the menu\n            // bar will take focus over the menu that is being opened.\n            event.preventDefault();\n            const position = this._positionForMenu(index);\n            Menu.saveWindowData();\n            // Begin DOM modifications.\n            this.activeIndex = index;\n            this._openChildMenu(position);\n        }\n    }\n    /**\n     * Handle the `'pointermove'` event for the menu bar.\n     */\n    _evtPointerMove(event) {\n        if (Utils$1.isTouchEvent(event)) {\n            return;\n        }\n        // Check if the mouse is over one of the menu items.\n        let index = ArrayExt.findFirstIndex(this.contentNode.children, node => {\n            return 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        // Get position for the new menu >before< updating active index.\n        const position = index >= 0 && this._childMenu ? this._positionForMenu(index) : null;\n        // Before any modification, update window data.\n        Menu.saveWindowData();\n        // Begin DOM modifications.\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 (position) {\n            this._openChildMenu(position);\n        }\n    }\n    /**\n     * Find initial position for the menu based on menubar item position.\n     *\n     * NOTE: this should be called before updating active index to avoid\n     * an additional layout and style invalidation as changing active\n     * index modifies DOM.\n     */\n    _positionForMenu(index) {\n        let itemNode = this.contentNode.children[index];\n        let { left, bottom } = itemNode.getBoundingClientRect();\n        return {\n            top: bottom,\n            left\n        };\n    }\n    /**\n     * Handle the `'focusout'` event for the menu bar.\n     */\n    _evtFocusOut(event) {\n        // Reset the active index if there is no open menu and the menubar is losing focus.\n        if (!this._childMenu && !this.node.contains(event.relatedTarget)) {\n            this.activeIndex = -1;\n        }\n    }\n    /**\n     * Focus an item in the menu bar.\n     *\n     * #### Notes\n     * Does not open the associated menu.\n     */\n    _focusItemAt(index) {\n        const itemNode = this.contentNode.childNodes[index];\n        if (itemNode) {\n            itemNode.focus();\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    _openChildMenu(options = {}) {\n        // If there is no active menu, close the current menu.\n        let newMenu = this.activeMenu;\n        if (!newMenu) {\n            this._closeChildMenu();\n            return;\n        }\n        // Bail if there is no effective menu change.\n        let 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            document.addEventListener('pointerdown', this, true);\n        }\n        // Update the tab focus index and ensure the menu bar is updated.\n        this._tabFocusIndex = this.activeIndex;\n        MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);\n        // Get the positioning data for the new menu.\n        let { left, top } = options;\n        if (typeof left === 'undefined' || typeof top === 'undefined') {\n            ({ left, top } = this._positionForMenu(this._activeIndex));\n        }\n        // Begin DOM modifications\n        if (!oldMenu) {\n            // Continue setup for new menu\n            this.addClass('lm-mod-active');\n        }\n        // Open the new menu at the computed location.\n        if (newMenu.items.length > 0) {\n            newMenu.open(left, top, this._forceItemsPosition);\n        }\n    }\n    /**\n     * Close the child menu immediately.\n     *\n     * This is a no-op if a child menu is not open.\n     */\n    _closeChildMenu() {\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        // Remove the document listeners.\n        document.removeEventListener('pointerdown', this, true);\n        // Clear the internal menu reference.\n        let 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    _onMenuAboutToClose(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        // Remove the document listeners.\n        document.removeEventListener('pointerdown', 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    _onMenuMenuRequested(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        let i = this._activeIndex;\n        let 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    _onTitleChanged() {\n        this.update();\n    }\n}\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    class Renderer {\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        renderItem(data) {\n            let className = this.createItemClass(data);\n            let dataset = this.createItemDataset(data);\n            let aria = this.createItemARIA(data);\n            return h.li({\n                className,\n                dataset,\n                ...(data.disabled ? {} : { tabindex: data.tabbable ? '0' : '-1' }),\n                onfocus: data.onfocus,\n                ...aria\n            }, 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        renderIcon(data) {\n            let className = this.createIconClass(data);\n            // If data.title.icon is undefined, it will be ignored.\n            return h.div({ 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        renderLabel(data) {\n            let content = this.formatLabel(data);\n            return h.div({ className: 'lm-MenuBar-itemLabel' }, 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        createItemClass(data) {\n            let name = 'lm-MenuBar-item';\n            if (data.title.className) {\n                name += ` ${data.title.className}`;\n            }\n            if (data.active && !data.disabled) {\n                name += ' lm-mod-active';\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        createItemDataset(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        createItemARIA(data) {\n            return {\n                role: 'menuitem',\n                'aria-haspopup': 'true',\n                'aria-disabled': data.disabled ? 'true' : 'false'\n            };\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        createIconClass(data) {\n            let name = 'lm-MenuBar-itemIcon';\n            let 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        formatLabel(data) {\n            // Fetch the label text and mnemonic index.\n            let { label, mnemonic } = data.title;\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            let prefix = label.slice(0, mnemonic);\n            let suffix = label.slice(mnemonic + 1);\n            let char = label[mnemonic];\n            // Wrap the mnemonic character in a span.\n            let span = h.span({ className: 'lm-MenuBar-itemMnemonic' }, char);\n            // Return the content parts.\n            return [prefix, span, suffix];\n        }\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$3;\n(function (Private) {\n    /**\n     * Create the DOM node for a menu bar.\n     */\n    function createNode() {\n        let node = document.createElement('div');\n        let content = document.createElement('ul');\n        content.className = 'lm-MenuBar-content';\n        node.appendChild(content);\n        content.setAttribute('role', 'menubar');\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        let index = -1;\n        let auto = -1;\n        let multiple = false;\n        // Normalize the key to upper case.\n        let upperKey = key.toUpperCase();\n        // Search the items from the given start index.\n        for (let i = 0, n = menus.length; i < n; ++i) {\n            // Compute the wrapped index.\n            let k = (i + start) % n;\n            // Look up the menu title.\n            let 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            let 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, multiple, auto };\n    }\n    Private.findMnemonic = findMnemonic;\n})(Private$3 || (Private$3 = {}));\n\n/**\n * A widget which implements a canonical scroll bar.\n */\nclass ScrollBar extends Widget {\n    /**\n     * Construct a new scroll bar.\n     *\n     * @param options - The options for initializing the scroll bar.\n     */\n    constructor(options = {}) {\n        super({ node: Private$2.createNode() });\n        /**\n         * A timeout callback for repeating the mouse press.\n         */\n        this._onRepeat = () => {\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            let 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            let mouseX = this._pressData.mouseX;\n            let 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 (!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 (!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 (!ElementExt.hitTest(this.trackNode, mouseX, mouseY)) {\n                    return;\n                }\n                // Fetch the thumb node.\n                let thumbNode = this.thumbNode;\n                // Bail if the mouse is over the thumb.\n                if (ElementExt.hitTest(thumbNode, mouseX, mouseY)) {\n                    return;\n                }\n                // Fetch the client rect for the thumb.\n                let thumbRect = thumbNode.getBoundingClientRect();\n                // Determine the direction for the page request.\n                let dir;\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 Signal(this);\n        this._stepRequested = new Signal(this);\n        this._pageRequested = new Signal(this);\n        this.addClass('lm-ScrollBar');\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    }\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 thumbMoved() {\n        return this._thumbMoved;\n    }\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 stepRequested() {\n        return this._stepRequested;\n    }\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 pageRequested() {\n        return this._pageRequested;\n    }\n    /**\n     * Get the orientation of the scroll bar.\n     */\n    get orientation() {\n        return this._orientation;\n    }\n    /**\n     * Set the orientation of the scroll bar.\n     */\n    set orientation(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    /**\n     * Get the current value of the scroll bar.\n     */\n    get value() {\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 value(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    /**\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 page() {\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 page(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    /**\n     * Get the maximum value of the scroll bar.\n     */\n    get maximum() {\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 maximum(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    /**\n     * The scroll bar decrement button node.\n     *\n     * #### Notes\n     * Modifying this node directly can lead to undefined behavior.\n     */\n    get decrementNode() {\n        return this.node.getElementsByClassName('lm-ScrollBar-button')[0];\n    }\n    /**\n     * The scroll bar increment button node.\n     *\n     * #### Notes\n     * Modifying this node directly can lead to undefined behavior.\n     */\n    get incrementNode() {\n        return this.node.getElementsByClassName('lm-ScrollBar-button')[1];\n    }\n    /**\n     * The scroll bar track node.\n     *\n     * #### Notes\n     * Modifying this node directly can lead to undefined behavior.\n     */\n    get trackNode() {\n        return this.node.getElementsByClassName('lm-ScrollBar-track')[0];\n    }\n    /**\n     * The scroll bar thumb node.\n     *\n     * #### Notes\n     * Modifying this node directly can lead to undefined behavior.\n     */\n    get thumbNode() {\n        return this.node.getElementsByClassName('lm-ScrollBar-thumb')[0];\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    handleEvent(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    onBeforeAttach(msg) {\n        this.node.addEventListener('mousedown', this);\n        this.update();\n    }\n    /**\n     * A method invoked on an 'after-detach' message.\n     */\n    onAfterDetach(msg) {\n        this.node.removeEventListener('mousedown', this);\n        this._releaseMouse();\n    }\n    /**\n     * A method invoked on an 'update-request' message.\n     */\n    onUpdateRequest(msg) {\n        // Convert the value and page into percentages.\n        let value = (this._value * 100) / this._maximum;\n        let 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        let 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    _evtKeyDown(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        let 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    _evtMouseDown(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        let part = Private$2.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        let override = Drag.overrideCursor('default');\n        // Set up the press data.\n        this._pressData = {\n            part,\n            override,\n            delta: -1,\n            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            let thumbNode = this.thumbNode;\n            // Fetch the client rect for the thumb.\n            let 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            // 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            let thumbRect = this.thumbNode.getBoundingClientRect();\n            // Determine the direction for the page request.\n            let dir;\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            // 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            // 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    _evtMouseMove(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        let thumbRect = this.thumbNode.getBoundingClientRect();\n        let trackRect = this.trackNode.getBoundingClientRect();\n        // Fetch the scroll geometry based on the orientation.\n        let trackPos;\n        let 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        let 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    _evtMouseUp(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    _releaseMouse() {\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    }\n    /**\n     * Move the thumb to the specified position.\n     */\n    _moveThumb(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}\n/**\n * The namespace for the module implementation details.\n */\nvar Private$2;\n(function (Private) {\n    /**\n     * Create the DOM node for a scroll bar.\n     */\n    function createNode() {\n        let node = document.createElement('div');\n        let decrement = document.createElement('div');\n        let increment = document.createElement('div');\n        let track = document.createElement('div');\n        let 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        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$2 || (Private$2 = {}));\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 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 */\nclass SingletonLayout extends Layout {\n    constructor() {\n        super(...arguments);\n        this._widget = null;\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    dispose() {\n        if (this._widget) {\n            let widget = this._widget;\n            this._widget = null;\n            widget.dispose();\n        }\n        super.dispose();\n    }\n    /**\n     * Get the child widget for the layout.\n     */\n    get widget() {\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 widget(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    /**\n     * Create an iterator over the widgets in the layout.\n     *\n     * @returns A new iterator over the widgets in the layout.\n     */\n    *[Symbol.iterator]() {\n        if (this._widget) {\n            yield this._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    removeWidget(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    init() {\n        super.init();\n        for (const widget of this) {\n            this.attachWidget(widget);\n        }\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     * #### 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    attachWidget(widget) {\n        // Send a `'before-attach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            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    detachWidget(widget) {\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\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 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 */\nclass StackedLayout extends PanelLayout {\n    constructor(options = {}) {\n        super(options);\n        this._dirty = false;\n        this._items = [];\n        this._box = null;\n        this._hiddenMode =\n            options.hiddenMode !== undefined\n                ? options.hiddenMode\n                : Widget.HiddenMode.Display;\n    }\n    /**\n     * The method for hiding widgets.\n     *\n     * #### Notes\n     * If there is only one child widget, `Display` hiding mode will be used\n     * regardless of this setting.\n     */\n    get hiddenMode() {\n        return this._hiddenMode;\n    }\n    /**\n     * Set the method for hiding widgets.\n     *\n     * #### Notes\n     * If there is only one child widget, `Display` hiding mode will be used\n     * regardless of this setting.\n     */\n    set hiddenMode(v) {\n        if (this._hiddenMode === v) {\n            return;\n        }\n        this._hiddenMode = v;\n        if (this.widgets.length > 1) {\n            this.widgets.forEach(w => {\n                w.hiddenMode = this._hiddenMode;\n            });\n        }\n    }\n    /**\n     * Dispose of the resources held by the layout.\n     */\n    dispose() {\n        // Dispose of the layout items.\n        for (const item of this._items) {\n            item.dispose();\n        }\n        // Clear the layout state.\n        this._box = null;\n        this._items.length = 0;\n        // Dispose of the rest of the layout.\n        super.dispose();\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    attachWidget(index, widget) {\n        // Using transform create an additional layer in the pixel pipeline\n        // to limit the number of layer, it is set only if there is more than one widget.\n        if (this._hiddenMode === Widget.HiddenMode.Scale &&\n            this._items.length > 0) {\n            if (this._items.length === 1) {\n                this.widgets[0].hiddenMode = Widget.HiddenMode.Scale;\n            }\n            widget.hiddenMode = Widget.HiddenMode.Scale;\n        }\n        else {\n            widget.hiddenMode = Widget.HiddenMode.Display;\n        }\n        // Create and add a new layout item for the widget.\n        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            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            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    moveWidget(fromIndex, toIndex, widget) {\n        // Move the layout item for the widget.\n        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    detachWidget(index, widget) {\n        // Remove the layout item for the widget.\n        let item = ArrayExt.removeAt(this._items, index);\n        // Send a `'before-detach'` message if the parent is attached.\n        if (this.parent.isAttached) {\n            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            MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);\n        }\n        // Reset the z-index for the widget.\n        item.widget.node.style.zIndex = '';\n        // Reset the hidden mode for the widget.\n        if (this._hiddenMode === Widget.HiddenMode.Scale) {\n            widget.hiddenMode = Widget.HiddenMode.Display;\n            // Reset the hidden mode for the first widget if necessary.\n            if (this._items.length === 1) {\n                this._items[0].widget.hiddenMode = Widget.HiddenMode.Display;\n            }\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    onBeforeShow(msg) {\n        super.onBeforeShow(msg);\n        this.parent.update();\n    }\n    /**\n     * A message handler invoked on a `'before-attach'` message.\n     */\n    onBeforeAttach(msg) {\n        super.onBeforeAttach(msg);\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-shown'` message.\n     */\n    onChildShown(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'child-hidden'` message.\n     */\n    onChildHidden(msg) {\n        this.parent.fit();\n    }\n    /**\n     * A message handler invoked on a `'resize'` message.\n     */\n    onResize(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    onUpdateRequest(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    onFitRequest(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    _fit() {\n        // Set up the computed minimum size.\n        let minW = 0;\n        let minH = 0;\n        // Update the computed minimum size.\n        for (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            let 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        let box = (this._box = ElementExt.boxSizing(this.parent.node));\n        minW += box.horizontalSum;\n        minH += box.verticalSum;\n        // Update the parent's min size constraints.\n        let 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            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            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    _update(offsetWidth, offsetHeight) {\n        // Clear the dirty flag to indicate the update occurred.\n        this._dirty = false;\n        // Compute the visible item count.\n        let nVisible = 0;\n        for (let 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 = ElementExt.boxSizing(this.parent.node);\n        }\n        // Compute the actual layout bounds adjusted for border and padding.\n        let top = this._box.paddingTop;\n        let left = this._box.paddingLeft;\n        let width = offsetWidth - this._box.horizontalSum;\n        let height = offsetHeight - this._box.verticalSum;\n        // Update the widget stacking order and layout geometry.\n        for (let i = 0, n = this._items.length; i < n; ++i) {\n            // Fetch the item.\n            let 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}\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 panel where visible widgets are stacked atop one another.\n *\n * #### Notes\n * This class provides a convenience wrapper around a {@link StackedLayout}.\n */\nclass StackedPanel extends Panel {\n    /**\n     * Construct a new stacked panel.\n     *\n     * @param options - The options for initializing the panel.\n     */\n    constructor(options = {}) {\n        super({ layout: Private$1.createLayout(options) });\n        this._widgetRemoved = new Signal(this);\n        this.addClass('lm-StackedPanel');\n    }\n    /**\n     * The method for hiding widgets.\n     *\n     * #### Notes\n     * If there is only one child widget, `Display` hiding mode will be used\n     * regardless of this setting.\n     */\n    get hiddenMode() {\n        return this.layout.hiddenMode;\n    }\n    /**\n     * Set the method for hiding widgets.\n     *\n     * #### Notes\n     * If there is only one child widget, `Display` hiding mode will be used\n     * regardless of this setting.\n     */\n    set hiddenMode(v) {\n        this.layout.hiddenMode = v;\n    }\n    /**\n     * A signal emitted when a widget is removed from a stacked panel.\n     */\n    get widgetRemoved() {\n        return this._widgetRemoved;\n    }\n    /**\n     * A message handler invoked on a `'child-added'` message.\n     */\n    onChildAdded(msg) {\n        msg.child.addClass('lm-StackedPanel-child');\n    }\n    /**\n     * A message handler invoked on a `'child-removed'` message.\n     */\n    onChildRemoved(msg) {\n        msg.child.removeClass('lm-StackedPanel-child');\n        this._widgetRemoved.emit(msg.child);\n    }\n}\n/**\n * The namespace for the module implementation details.\n */\nvar Private$1;\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$1 || (Private$1 = {}));\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 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 */\nclass TabPanel extends Widget {\n    /**\n     * Construct a new tab panel.\n     *\n     * @param options - The options for initializing the tab panel.\n     */\n    constructor(options = {}) {\n        super();\n        this._currentChanged = new Signal(this);\n        this._addRequested = new Signal(this);\n        this.addClass('lm-TabPanel');\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        // 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        let direction = Private.directionFromPlacement(this._tabPlacement);\n        let orientation = Private.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        let layout = new BoxLayout({ 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    }\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 currentChanged() {\n        return this._currentChanged;\n    }\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 currentIndex() {\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 currentIndex(value) {\n        this.tabBar.currentIndex = value;\n    }\n    /**\n     * Get the currently selected widget.\n     *\n     * #### Notes\n     * This will be `null` if there is no selected tab.\n     */\n    get currentWidget() {\n        let 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 currentWidget(value) {\n        this.tabBar.currentTitle = value ? value.title : null;\n    }\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 tabsMovable() {\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 tabsMovable(value) {\n        this.tabBar.tabsMovable = value;\n    }\n    /**\n     * Get the whether the add button is enabled.\n     *\n     */\n    get addButtonEnabled() {\n        return this.tabBar.addButtonEnabled;\n    }\n    /**\n     * Set the whether the add button is enabled.\n     *\n     */\n    set addButtonEnabled(value) {\n        this.tabBar.addButtonEnabled = value;\n    }\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 tabPlacement() {\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 tabPlacement(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        let direction = Private.directionFromPlacement(value);\n        let orientation = Private.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    /**\n     * A signal emitted when the add button on a tab bar is clicked.\n     *\n     */\n    get addRequested() {\n        return this._addRequested;\n    }\n    /**\n     * A read-only array of the widgets in the panel.\n     */\n    get widgets() {\n        return this.stackedPanel.widgets;\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    addWidget(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    insertWidget(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        let renderer = this.tabBar.renderer;\n        if (renderer instanceof TabBar.Renderer) {\n            let tabId = renderer.createTabKey({\n                title: widget.title,\n                current: false,\n                zIndex: 0\n            });\n            widget.node.setAttribute('aria-labelledby', tabId);\n        }\n    }\n    /**\n     * Handle the `currentChanged` signal from the tab bar.\n     */\n    _onCurrentChanged(sender, args) {\n        // Extract the previous and current title from the args.\n        let { previousIndex, previousTitle, currentIndex, currentTitle } = args;\n        // Extract the widgets from the titles.\n        let previousWidget = previousTitle ? previousTitle.owner : null;\n        let 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,\n            previousWidget,\n            currentIndex,\n            currentWidget\n        });\n        // Flush the message loop on IE and Edge to prevent flicker.\n        if (Platform.IS_EDGE || Platform.IS_IE) {\n            MessageLoop.flush();\n        }\n    }\n    /**\n     * Handle the `tabAddRequested` signal from the tab bar.\n     */\n    _onTabAddRequested(sender, args) {\n        this._addRequested.emit(sender);\n    }\n    /**\n     * Handle the `tabActivateRequested` signal from the tab bar.\n     */\n    _onTabActivateRequested(sender, args) {\n        args.title.owner.activate();\n    }\n    /**\n     * Handle the `tabCloseRequested` signal from the tab bar.\n     */\n    _onTabCloseRequested(sender, args) {\n        args.title.owner.close();\n    }\n    /**\n     * Handle the `tabMoved` signal from the tab bar.\n     */\n    _onTabMoved(sender, args) {\n        this.stackedPanel.insertWidget(args.toIndex, args.title.owner);\n    }\n    /**\n     * Handle the `widgetRemoved` signal from the stacked panel.\n     */\n    _onWidgetRemoved(sender, widget) {\n        widget.node.removeAttribute('role');\n        widget.node.removeAttribute('aria-labelledby');\n        this.tabBar.removeTab(widget.title);\n    }\n}\n/**\n * The namespace for the module implementation details.\n */\nvar Private;\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    const 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    const placementToDirectionMap = {\n        top: 'top-to-bottom',\n        left: 'left-to-right',\n        right: 'right-to-left',\n        bottom: 'bottom-to-top'\n    };\n})(Private || (Private = {}));\n\nexport { AccordionLayout, AccordionPanel, BoxEngine, BoxLayout, BoxPanel, BoxSizer, CommandPalette, ContextMenu, DockLayout, DockPanel, FocusTracker, GridLayout, Layout, LayoutItem, Menu, MenuBar, Panel, PanelLayout, ScrollBar, SingletonLayout, SplitLayout, SplitPanel, StackedLayout, StackedPanel, TabBar, TabPanel, Title, Widget };\n//# sourceMappingURL=index.es6.js.map\n","export { each } from \"@lumino/algorithm\";\nexport { CommandRegistry } from \"@lumino/commands\";\nexport { ConflatableMessage, Message, MessageLoop } from \"@lumino/messaging\";\nexport type { IMessageHandler, IMessageHook } from \"@lumino/messaging\";\nexport { BoxPanel, CommandPalette, ContextMenu, DockLayout, DockPanel, Menu, MenuBar, SplitPanel, TabBar, TabPanel, Widget } from \"@lumino/widgets\";\n\nimport \"@lumino/widgets/style/widget.css\";\n\nimport \"@lumino/widgets/style/commandpalette.css\";\nimport \"@lumino/widgets/style/dockpanel.css\";\nimport \"@lumino/widgets/style/menu.css\";\nimport \"@lumino/widgets/style/menubar.css\";\nimport \"@lumino/widgets/style/scrollbar.css\";\nimport \"@lumino/widgets/style/splitpanel.css\";\nimport \"@lumino/widgets/style/tabbar.css\";\nimport \"@lumino/widgets/style/tabpanel.css\";\n","import { Widget, select as d3Select } from \"@hpcc-js/common\";\n// import { Persist } from \"@hpcc-js/other\";\nimport { ConflatableMessage, Message, MessageLoop, Widget as PWidget } from \"./phosphor-shim.ts\";\n\nimport \"../src/WidgetAdapter.css\";\n\nexport namespace Msg {\n\n    export class WAConflatableMessage extends ConflatableMessage {\n        private _wa: WidgetAdapter;\n\n        constructor(wa: WidgetAdapter, msg: string) {\n            super(msg);\n            this._wa = wa;\n        }\n\n        get wa(): WidgetAdapter {\n            return this._wa;\n        }\n\n        conflate(other: WAConflatableMessage): boolean {\n            this._wa = other.wa;\n            return true;\n        }\n    }\n\n    export class WAActivateRequest extends WAConflatableMessage {\n\n        static type = \"wa-activate-request\";\n\n        constructor(wa: WidgetAdapter) {\n            super(wa, WAActivateRequest.type);\n        }\n    }\n\n    export class WALayoutChanged extends WAConflatableMessage {\n\n        static type = \"wa-layout-changed\";\n\n        constructor(wa: WidgetAdapter) {\n            super(wa, WALayoutChanged.type);\n        }\n    }\n}\n\nexport interface IClosable {\n    canClose(e: Widget, wa: WidgetAdapter): boolean;\n}\n\nexport interface WidgetAdapterExt {\n    overflowX?: string;\n    overflowY?: string;\n}\n\nexport class WidgetAdapter extends PWidget {\n    protected _owner;\n    protected _element;\n    private _widget: Widget;\n    get widget(): Widget { return this._widget; }\n    private _widgetLayout: object;\n    lparam: any = {};\n    padding: number = 0;\n    _width: number = 0;\n    _height: number = 0;\n    _ext: WidgetAdapterExt;\n    private _closable: IClosable;\n\n    constructor(owner?: Widget, widget?: Widget | object, lparam: object = {}, closable: boolean | IClosable = false, ext: WidgetAdapterExt = {}) {\n        super();\n        this._owner = owner;\n        this._element = d3Select(this.node);\n        // this.setFlag(Widget.Flag.DisallowLayout);\n        this.addClass(\"phosphor_WidgetAdapter\");\n        // this.addClass(name.toLowerCase());\n        this.title.label = \"\";\n        this.title.closable = !!closable;\n        this.title.caption = `Long description for: ${name}`;\n        this._ext = ext;\n\n        if (typeof closable === \"boolean\") {\n            this._closable = {\n                canClose(e: Widget, wa: WidgetAdapter): boolean { return closable; }\n            };\n        } else {\n            this._closable = closable;\n        }\n\n        if (widget instanceof Widget) {\n            this._widget = widget\n                .target(this.node)\n                ;\n        } else {\n            this._widgetLayout = widget;\n        }\n        this.lparam = lparam;\n    }\n\n    get inputNode(): HTMLInputElement {\n        return this.node.getElementsByTagName(\"input\")[0] as HTMLInputElement;\n    }\n\n    resizeAndRender() {\n        if (this._widget) {\n            d3Select(this.node)\n                .style(\"padding\", this.padding + \"px\")\n                .style(\"width\", this._width + \"px\")\n                .style(\"height\", this._height + \"px\")\n                .style(\"overflow-x\", this._ext.overflowX)\n                .style(\"overflow-y\", this._ext.overflowY)\n                ;\n            this._widget\n                .resize({ width: this._width - this.padding * 2 - 2, height: this._height - this.padding * 2 - 2 })\n                .lazyRender()\n                ;\n            if (this._owner) {\n                MessageLoop.postMessage(this._owner, new Msg.WALayoutChanged(this));\n            }\n        }\n    }\n\n    protected onActivateRequest(msg: Message): void {\n        super.onActivateRequest(msg);\n        if (this._widget) {\n            this.resizeAndRender();\n        }\n        if (this._owner) {\n            MessageLoop.postMessage(this._owner, new Msg.WAActivateRequest(this));\n        }\n    }\n\n    protected onResize(msg: PWidget.ResizeMessage): void {\n        super.onResize(msg);\n        if (this.node && this.node.offsetParent !== null && msg.width >= 0 && msg.height >= 0) {\n            this._width = msg.width;\n            this._height = msg.height;\n            this.resizeAndRender();\n        } else if (this._widgetLayout) {\n            /*\n            Persist.create(this._widgetLayout).then((widget: Widget) => {\n                delete this._widgetLayout;\n                this._widget = widget;\n                this._widget\n                    .target(this.node)\n                    .resize({ width: msg.width - this.padding * 2 - 2, height: msg.height - this.padding * 2 - 2 })\n                    .lazyRender()\n                    ;\n                if (this._widget[\"title\"]) {\n                    this.title.label = this._widget[\"title\"]();\n                }\n            });\n            */\n        }\n    }\n\n    protected onCloseRequest(msg: Message): void {\n        if (this._closable.canClose(this._widget, this)) {\n            this.dispose();\n        }\n    }\n}\n\nexport class WidgetAdapterArray extends Array<WidgetAdapter> {\n\n    private constructor(items?: WidgetAdapter[]) {\n        super(...items);\n    }\n\n    static create<WidgetAdapter>(): WidgetAdapterArray {\n        return Object.create(WidgetAdapterArray.prototype);\n    }\n\n    watchRendered(w: Widget, callback?: (w: Widget) => void) {\n        if (!callback) return;\n\n        const content = this.map(wa => {\n            return {\n                wa,\n                w: wa.widget,\n                rc: wa.widget.renderCount()\n            };\n        });\n\n        const intervalHandle = setInterval(() => {\n            if (complete()) {\n                clearInterval(intervalHandle);\n                callback(w);\n            }\n        }, 20);\n\n        function complete(): boolean {\n            for (const item of content) {\n                if (item.wa.isVisible && item.rc >= item.w.renderCount()) {\n                    return false;\n                }\n            }\n            return true;\n        }\n    }\n}\n","import { HTMLWidget, Widget, Utility } from \"@hpcc-js/common\";\nimport { Widget as PWidget, IMessageHandler, IMessageHook, Message, MessageLoop } from \"./phosphor-shim.ts\";\nimport { Msg, WidgetAdapter, WidgetAdapterArray } from \"./WidgetAdapter.ts\";\n\nexport namespace BasePanel {\n    export interface IAddWidgetOptions {\n        /** Minimum size in pixels */\n        minSize?: number;\n        /** Preferred/default size in pixels — used as initial size hint */\n        defaultSize?: number;\n        /** Inner padding in pixels (default 8) */\n        padding?: number;\n\n        /** Reference widget for split/tab positioning */\n        refWidget?: Widget;\n    }\n}\n\nexport abstract class BasePanel extends HTMLWidget implements IMessageHandler, IMessageHook {\n\n    protected abstract _content: WidgetAdapterArray;\n\n    constructor() {\n        super();\n        this._tag = \"div\";\n        MessageLoop.installMessageHook(this, this);\n    }\n\n    getWidget(wa: PWidget): Widget | undefined {\n        if (wa instanceof WidgetAdapter) {\n            return wa.widget;\n        }\n    }\n\n    getWidgetAdapter(widget: Widget): WidgetAdapter | null {\n        let retVal = null;\n        this._content.some(wa => {\n            if (wa.widget === widget) {\n                retVal = wa;\n                return true;\n            }\n            return false;\n        });\n        return retVal;\n    }\n\n    protected _prevActive: Widget;\n    active(): Widget {\n        return this._prevActive;\n    }\n\n    //  Phosphor Messaging  ---\n    protected _lazyLayoutChanged = Utility.debounce(async () => {\n        this.layoutChanged();\n    }, 1000);\n\n    processMessage(msg: Message): void {\n        switch (msg.type) {\n            case Msg.WAActivateRequest.type:\n                const wa = (msg as Msg.WAActivateRequest).wa;\n                const widget = wa.widget;\n                if (this._prevActive !== widget) {\n                    this._prevActive = widget;\n                    this.childActivation(widget, wa);\n                }\n                break;\n            case Msg.WALayoutChanged.type:\n                this._lazyLayoutChanged();\n                break;\n        }\n    }\n\n    messageHook(handler: IMessageHandler, msg: Message): boolean {\n        if (handler === this) {\n            this.processMessage(msg);\n        }\n        return true;\n    }\n\n    //  Events  ---\n    childActivation(w: Widget, wa: WidgetAdapter) {\n    }\n\n    layoutChanged() {\n    }\n\n}\n","// import { Persist } from \"@hpcc-js/other\";\nimport { DockLayout, DockPanel, TabBar, Widget } from \"./phosphor-shim.ts\";\nimport { WidgetAdapter, WidgetAdapterArray } from \"./WidgetAdapter.ts\";\n\nexport class PRenderer extends DockPanel.Renderer {\n    _owner: PDockPanel;\n\n    constructor() {\n        super();\n    }\n\n    createTabBar(): TabBar<Widget> {\n        const bar = super.createTabBar();\n        bar.tabsMovable = this._owner.tabsMovable;\n        return bar;\n    }\n}\n\nexport class PDockPanel extends DockPanel {\n\n    private _content: WidgetAdapterArray;\n    private _contentMap: { [key: string]: WidgetAdapter };\n\n    constructor(options: DockPanel.IOptions = {}) {\n        options.renderer = options.renderer || new PRenderer();\n        super(options);\n        if (this[\"_renderer\"] instanceof PRenderer) {\n            this[\"_renderer\"]._owner = this;\n        }\n        this._content = WidgetAdapterArray.create();\n        this._contentMap = {};\n    }\n\n    appendContent(wa: WidgetAdapter) {\n        this._content.push(wa);\n        this._contentMap[wa.widget.id()] = wa;\n    }\n\n    removeContent(wa: WidgetAdapter) {\n        const idx = this._content.indexOf(wa);\n        if (idx >= 0) {\n            this._content.splice(idx, 1);\n        }\n        delete this._contentMap[wa.widget.id()];\n        wa.dispose();\n    }\n\n    content(): WidgetAdapterArray {\n        return this._content;\n    }\n\n    serializeWidget(widget: Widget): object {\n        if (widget instanceof WidgetAdapter) {\n            try {\n                return {\n                    __id: widget.widget.id()\n                };\n            } catch (e: any) {\n                return {\n                    exception: {\n                        message: e.message ?? \"\",\n                        stack: e.stack ?? []\n                    }\n                };\n            }\n        }\n        return null;\n    }\n\n    deserializeWidget(layout: any): WidgetAdapter {\n        let wa: WidgetAdapter = this._contentMap[layout.__id];\n        if (wa) {\n            // Persist.deserializeFromObject(wa.widget, layout);\n        } else {\n            wa = new WidgetAdapter(undefined, layout);\n        }\n        return wa;\n    }\n\n    serializeITabAreaConfig(config: DockLayout.ITabAreaConfig, deserialize: boolean): DockLayout.ITabAreaConfig {\n        return {\n            ...config,\n            widgets: config.widgets.map(widget => deserialize ? this.deserializeWidget(widget) : this.serializeWidget(widget) as any)\n        };\n    }\n\n    serializeISplitAreaConfig(config: DockLayout.ISplitAreaConfig, deserialize: boolean): DockLayout.ISplitAreaConfig {\n        return {\n            ...config,\n            children: config.children.map(child => this.serializeAreaConfig(child, deserialize))\n        };\n    }\n\n    serializeAreaConfig(config: DockLayout.AreaConfig, deserialize: boolean): DockLayout.AreaConfig {\n        if (config) {\n            switch (config.type) {\n                case \"tab-area\":\n                    return this.serializeITabAreaConfig(config, deserialize);\n                case \"split-area\":\n                    return this.serializeISplitAreaConfig(config, deserialize);\n            }\n        }\n        return undefined;\n    }\n\n    saveLayout(): DockLayout.ILayoutConfig {\n        return {\n            main: this.serializeAreaConfig(super.saveLayout().main, false)\n        };\n    }\n\n    restoreLayout(config: DockLayout.ILayoutConfig) {\n        return super.restoreLayout({\n            main: this.serializeAreaConfig(config.main, true)\n        });\n    }\n}\n","import { Widget, select as d3Select } from \"@hpcc-js/common\";\nimport { BasePanel } from \"./BasePanel.ts\";\nimport { DockLayout, DockPanel as PhosphorDockPanel, MessageLoop, Widget as PWidget } from \"./phosphor-shim.ts\";\nimport { IClosable, WidgetAdapter } from \"./WidgetAdapter.ts\";\nimport { PDockPanel } from \"./PDockPanel.ts\";\n\nimport \"../src/DockPanel.css\";\n\nexport namespace DockPanel {\n    export interface IAddWidgetOptions extends BasePanel.IAddWidgetOptions {\n        /** Tab title */\n        title?: string;\n        /** Insertion mode relative to refWidget */\n        location?: PhosphorDockPanel.InsertMode;\n        /** Whether the tab can be closed */\n        closable?: boolean | IClosable;\n    }\n}\n\nexport class DockPanel extends BasePanel {\n    private _dock = new PDockPanel({ mode: \"multiple-document\" });\n    protected _content = this._dock.content();\n\n    constructor() {\n        super();\n        this._dock.id = \"p\" + this.id();\n    }\n\n    private _pendingDefaults: Map<WidgetAdapter, { defaultSize?: number }> = new Map();\n    addWidget(widget: Widget, options: DockPanel.IAddWidgetOptions): this;\n    /** @deprecated Use options object form instead */\n    addWidget(widget: Widget, title: string, location?: PhosphorDockPanel.InsertMode, refWidget?: Widget, closable?: boolean | IClosable, padding?: number): this;\n    addWidget(widget: Widget, titleOrOptions: string | DockPanel.IAddWidgetOptions, location: PhosphorDockPanel.InsertMode = \"split-right\", refWidget?: Widget, closable?: boolean | IClosable, padding: number = 8) {\n        const opts: DockPanel.IAddWidgetOptions = typeof titleOrOptions === \"string\"\n            ? { title: titleOrOptions, location, refWidget, closable, padding }\n            : titleOrOptions;\n\n        const {\n            title = \"\",\n            location: loc = \"split-right\",\n            refWidget: ref,\n            closable: canClose,\n            padding: pad = 8,\n            minSize,\n            defaultSize\n        } = opts;\n\n        const addMode: PhosphorDockPanel.IAddOptions = { mode: loc, ref: this.getWidgetAdapter(ref) };\n        const wa = new WidgetAdapter(this, widget, {}, canClose);\n        wa.title.label = title;\n        wa.padding = pad;\n\n        if (minSize != null) {\n            const style = wa.node.style;\n            if (loc === \"split-left\" || loc === \"split-right\") {\n                style.minWidth = `${minSize}px`;\n            } else {\n                style.minHeight = `${minSize}px`;\n            }\n        }\n\n        this._dock.addWidget(wa, addMode);\n        this._dock.appendContent(wa);\n        this._dock.tabsMovable = true;\n\n        if (defaultSize != null) {\n            this._pendingDefaults.set(wa, { defaultSize });\n        }\n\n        return this;\n    }\n\n    private _applyPendingDefaults() {\n        if (this._pendingDefaults.size === 0) return;\n\n        const config = this._dock.saveLayout() as DockLayout.ILayoutConfig;\n        if (!config.main) {\n            this._pendingDefaults.clear();\n            return;\n        }\n\n        // Build a lookup: widgetId → { defaultSize }\n        const lookup = new Map<string, { defaultSize?: number }>();\n        for (const [wa, defaults] of this._pendingDefaults) {\n            lookup.set(wa.widget.id(), defaults);\n        }\n        this._pendingDefaults.clear();\n\n        const containerWidth = this.width();\n        const containerHeight = this.height();\n\n        const applySizes = (area: DockLayout.AreaConfig, availWidth: number, availHeight: number): void => {\n            if (!area || area.type !== \"split-area\") return;\n\n            const isHorizontal = area.orientation === \"horizontal\";\n            const totalSpace = isHorizontal ? availWidth : availHeight;\n            const n = area.children.length;\n\n            // Collect requested pixel sizes per child\n            let usedSpace = 0;\n            let flexCount = 0;\n            const pixelSizes: (number | null)[] = area.children.map((child, i) => {\n                if (child.type === \"tab-area\") {\n                    for (const w of (child as any).widgets) {\n                        const defaults = lookup.get(w?.__id);\n                        if (defaults) {\n                            const size = defaults.defaultSize;\n                            if (size != null) {\n                                usedSpace += size;\n                                return size;\n                            }\n                        }\n                    }\n                }\n                flexCount++;\n                return null;\n            });\n\n            // Only apply if at least one child has a default\n            if (flexCount < n) {\n                const remainingSpace = Math.max(0, totalSpace - usedSpace);\n                const flexSize = flexCount > 0 ? remainingSpace / flexCount : 0;\n                area.sizes = pixelSizes.map(px => px != null ? px : flexSize);\n            }\n\n            // Recurse into nested split areas with their allocated portion\n            for (let i = 0; i < area.children.length; i++) {\n                const child = area.children[i];\n                if (child.type === \"split-area\") {\n                    const ratio = area.sizes[i] / (area.sizes.reduce((a, b) => a + b, 0) || 1);\n                    const childW = isHorizontal ? availWidth * ratio : availWidth;\n                    const childH = isHorizontal ? availHeight : availHeight * ratio;\n                    applySizes(child, childW, childH);\n                }\n            }\n        };\n\n        applySizes(config.main, containerWidth, containerHeight);\n        this._dock.restoreLayout(config as any);\n    }\n\n    removeWidget(widget: Widget) {\n        const wa = this.getWidgetAdapter(widget);\n        if (wa) {\n            widget.target(null);\n            this._dock.removeContent(wa);\n        }\n        return this;\n    }\n\n    isVisible(widget: Widget) {\n        return this.getWidgetAdapter(widget).isVisible;\n    }\n\n    widgetAdapters(): WidgetAdapter[] {\n        return this._dock.content();\n    }\n\n    widgets(): Widget[] {\n        return this._dock.content().map(wa => wa.widget);\n    }\n\n    layout(): object;\n    layout(_: object): this;\n    layout(_?: object): object | this {\n        if (!arguments.length) return this._dock.saveLayout();\n        this._dock.restoreLayout(_ as any);\n        return this;\n    }\n\n    //  Used to delay load a layout during render...\n    private _layoutObj: object = null;\n    layoutObj(_: object | null): this {\n        this._layoutObj = _;\n        return this;\n    }\n\n    enter(domNode, element) {\n        super.enter(domNode, element);\n        PWidget.attach(this._dock, domNode);\n    }\n\n    _prevHideSingleTabs;\n    update(domNode, element) {\n        super.update(domNode, element);\n        element.select(\".lm-Widget\")\n            .style(\"width\", this.width() + \"px\")\n            .style(\"height\", this.height() + \"px\")\n            ;\n\n        this.widgets().forEach(w => w.render());\n    }\n\n    exit(domNode, element) {\n        if (this._dock.isAttached) {\n            if (this._dock.node.isConnected) {\n                // Proper Lumino detach — propagates AfterDetach to all children\n                // (TabBars etc.), clearing their isAttached flags before disposal.\n                PWidget.detach(this._dock);\n            } else {\n                // The DOM node has already been removed from the document by the\n                // parent framework (e.g. React unmount).  We cannot call the\n                // static Widget.detach() because it guards against !isConnected,\n                // so manually broadcast AfterDetach so that Lumino's isAttached\n                // bookkeeping is consistent before we dispose child widgets.\n                MessageLoop.sendMessage(this._dock, PWidget.Msg.AfterDetach);\n            }\n        }\n        [...this.widgets()].forEach(w => this.removeWidget(w));\n        super.exit(domNode, element);\n    }\n\n    render(callback?: (w: Widget) => void): this {\n        const context = this;\n        if (this._layoutObj !== null) {\n            this.layout(this._layoutObj);\n            this.layoutObj(null);\n        }\n        return super.render((w) => {\n            this._applyPendingDefaults();\n            this._dock.content().watchRendered(this, callback);\n            this._dock.update();\n            setTimeout(() => {\n                const tabBars = this.element().selectAll(\".lm-Widget.lm-TabBar.lm-DockPanel-tabBar\");\n                let refit = false;\n                tabBars.each(function (this: HTMLElement) {\n                    const tabBar = d3Select(this);\n                    const tabsCount = (tabBar.node() as HTMLElement).childNodes[0].childNodes.length;\n                    const hide = context.hideSingleTabs() && tabsCount === 1;\n                    if (hide !== tabBar.classed(\"hide\")) {\n                        tabBar.classed(\"hide\", hide);\n                        refit = true;\n                    }\n                });\n                if (refit) {\n                    this._dock.fit();\n                }\n            }, 0);\n        });\n    }\n\n    refit() {\n        this._dock.fit();\n    }\n\n    //  Events  ---\n    childActivation(w: Widget, wa: WidgetAdapter) {\n    }\n\n    layoutChanged() {\n    }\n}\nDockPanel.prototype._class += \" phosphor_DockPanel\";\n\nexport interface DockPanel {\n    hideSingleTabs(): boolean;\n    hideSingleTabs(_: boolean): this;\n}\n\nDockPanel.prototype.publish(\"hideSingleTabs\", false, \"boolean\");\n","import { HTMLWidget, SVGWidget, Widget } from \"@hpcc-js/common\";\nimport { BasePanel } from \"./BasePanel.ts\";\nimport { SplitPanel as PSplitPanel, Widget as PWidget } from \"./phosphor-shim.ts\";\nimport { WidgetAdapter, WidgetAdapterArray } from \"./WidgetAdapter.ts\";\n\nimport \"../src/DockPanel.css\";\n\nexport namespace SplitPanel {\n\n    export interface IAddWidgetOptions extends BasePanel.IAddWidgetOptions {\n        /** Maximum size in pixels */\n        maxSize?: number;\n    }\n}\n\nexport class SplitPanel extends BasePanel {\n    private _split: PSplitPanel;\n    protected _content = WidgetAdapterArray.create();\n\n    constructor(readonly _orientation: \"horizontal\" | \"vertical\" = \"vertical\") {\n        super();\n        this._split = new PSplitPanel({ orientation: _orientation });\n        this._split.id = \"p\" + this.id();\n    }\n\n    private _pendingDefaults: Map<number, { defaultSize?: number }> = new Map();\n    addWidget(widget: SVGWidget | HTMLWidget, options?: SplitPanel.IAddWidgetOptions): this {\n        const opts = options || {};\n        const wa = new WidgetAdapter(this, widget);\n        wa.padding = opts.padding ?? 0;\n\n        if (opts.minSize != null || opts.maxSize != null) {\n            const style = wa.node.style;\n            if (opts.minSize != null) {\n                if (this._orientation === \"horizontal\") {\n                    style.minWidth = `${opts.minSize}px`;\n                } else {\n                    style.minHeight = `${opts.minSize}px`;\n                }\n            }\n            if (opts.maxSize != null) {\n                if (this._orientation === \"horizontal\") {\n                    style.maxWidth = `${opts.maxSize}px`;\n                } else {\n                    style.maxHeight = `${opts.maxSize}px`;\n                }\n            }\n        }\n\n        this._split.addWidget(wa);\n        this._content.push(wa);\n\n        if (opts.defaultSize != null) {\n            this._pendingDefaults.set(this._content.length - 1, {\n                defaultSize: opts.defaultSize\n            });\n        }\n\n        return this;\n    }\n\n    relativeSizes(): number[];\n    relativeSizes(_: number[]): this;\n    relativeSizes(_?: number[]): number[] | this {\n        if (!arguments.length) return this._split.relativeSizes();\n        this._split.setRelativeSizes(_);\n        return this;\n    }\n\n    enter(domNode, element) {\n        super.enter(domNode, element);\n        PWidget.attach(this._split, domNode);\n    }\n\n    update(domNode, element) {\n        super.update(domNode, element);\n        element.select(\".lm-Widget\")\n            .style(\"width\", this.width() + \"px\")\n            .style(\"height\", this.height() + \"px\")\n            ;\n    }\n\n    exit(domNode, element) {\n        PWidget.detach(this._split);\n        super.exit(domNode, element);\n    }\n\n    render(callback?: (w: Widget) => void): this {\n        return super.render(w => {\n            this._applyPendingDefaults();\n            this._content.watchRendered(this, callback);\n            this._split.update();\n        });\n    }\n\n    private _applyPendingDefaults() {\n        if (this._pendingDefaults.size === 0) return;\n\n        const isHorizontal = this._orientation === \"horizontal\";\n        const totalSpace = isHorizontal ? this.width() : this.height();\n        const n = this._content.length;\n\n        let usedSpace = 0;\n        let flexCount = 0;\n        const pixelSizes: (number | null)[] = [];\n\n        for (let i = 0; i < n; i++) {\n            const defaults = this._pendingDefaults.get(i);\n            if (defaults) {\n                const size = defaults.defaultSize;\n                if (size != null) {\n                    pixelSizes.push(size);\n                    usedSpace += size;\n                    continue;\n                }\n            }\n            pixelSizes.push(null);\n            flexCount++;\n        }\n\n        this._pendingDefaults.clear();\n\n        const remainingSpace = Math.max(0, totalSpace - usedSpace);\n        const flexSize = flexCount > 0 ? remainingSpace / flexCount : 0;\n        const sizes = pixelSizes.map(px => px != null ? px : flexSize);\n        this._split.setRelativeSizes(sizes);\n    }\n\n    //  Events  ---\n    childActivation(w: Widget, wa: WidgetAdapter) {\n    }\n\n    layoutChanged() {\n    }\n}\nSplitPanel.prototype._class += \" phosphor_SplitPanel\";\n\n","import { HTMLWidget, SVGWidget, Widget } from \"@hpcc-js/common\";\nimport { BasePanel } from \"./BasePanel.ts\";\nimport { TabPanel as PTabPanel, Widget as PWidget } from \"./phosphor-shim.ts\";\nimport { WidgetAdapter, WidgetAdapterArray, WidgetAdapterExt } from \"./WidgetAdapter.ts\";\n\nimport \"../src/DockPanel.css\";\n\nexport namespace TabPanel {\n\n    export interface IAddWidgetOptions {\n        /** Inner padding in pixels (default 8) */\n        padding?: number;\n        /** Tab title */\n        title?: string;\n        /** Widget adapter extensions (overflow settings) */\n        ext?: WidgetAdapterExt;\n    }\n}\n\nexport class TabPanel extends BasePanel {\n    private _tab = new PTabPanel({ tabPlacement: \"top\" });\n    protected _content = WidgetAdapterArray.create();\n\n    constructor() {\n        super();\n        this._tab.id = \"p\" + this.id();\n    }\n\n    addWidget(widget: SVGWidget | HTMLWidget, options: TabPanel.IAddWidgetOptions): this;\n    /** @deprecated Use options object form instead */\n    addWidget(widget: SVGWidget | HTMLWidget, title: string, ext?: WidgetAdapterExt): this;\n    addWidget(widget: SVGWidget | HTMLWidget, titleOrOptions: string | TabPanel.IAddWidgetOptions, ext: WidgetAdapterExt = {}) {\n        const opts: TabPanel.IAddWidgetOptions = typeof titleOrOptions === \"string\"\n            ? { title: titleOrOptions, ext }\n            : titleOrOptions;\n\n        const {\n            title = \"\",\n            ext: widgetExt = {},\n            padding = 8\n        } = opts;\n\n        if (!this._prevActive) {\n            this._prevActive = widget;\n        }\n        const wa = new WidgetAdapter(this, widget, undefined, undefined, widgetExt);\n        wa.title.label = title;\n        wa.padding = padding;\n\n        this._tab.addWidget(wa);\n        this._content.push(wa);\n        return this;\n    }\n\n    removeWidget(widget: SVGWidget | HTMLWidget) {\n        const wa = this.getWidgetAdapter(widget);\n        if (wa) {\n            const found = this._content.indexOf(wa);\n            if (found >= 0) {\n                this._content.splice(found, 1);\n            }\n            widget.target(null);\n            wa.dispose();\n        }\n        return this;\n    }\n\n    enter(domNode, element) {\n        super.enter(domNode, element);\n        PWidget.attach(this._tab, domNode);\n    }\n\n    update(domNode, element) {\n        super.update(domNode, element);\n        element.select(\".lm-Widget\")\n            .style(\"width\", this.width() + \"px\")\n            .style(\"height\", this.height() + \"px\")\n            ;\n    }\n\n    exit(domNode, element) {\n        PWidget.detach(this._tab);\n        super.exit(domNode, element);\n    }\n\n    render(callback?: (w: Widget) => void): this {\n        return super.render(w => {\n            this._content.watchRendered(this, callback);\n            this._tab.update();\n        });\n    }\n\n    active(): Widget;\n    active(_: Widget);\n    active(_?: Widget): Widget | this {\n        if (!arguments.length) return this.getWidget(this._tab.currentWidget);\n        this._tab.currentWidget = this.getWidgetAdapter(_);\n        return this;\n    }\n\n    //  Events  ---\n    childActivation(w: Widget, wa: WidgetAdapter) {\n    }\n\n    layoutChanged() {\n    }\n}\nTabPanel.prototype._class += \" phosphor_TabPanel\";\n"],"ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13],"mappings":"C,gpCAAaoD,EAAW,oBACXC,EAAc,SACdC,EAAgB,S,0cC+3C7B,SAAU,MAAM,GAAGI,EAAS,CACxB,IAAK,IAAMC,KAAUD,EACjB,MAAOC,CAEf,CA0BA,SAAU,OAAQ,CAElB,CA+BA,SAAU,UAAU,EAAQ,EAAQ,EAAG,CACnC,IAAK,IAAMC,KAASD,EAChB,KAAM,CAAC,IAASC,CAAK,CAE7B,CA+BA,SAAU,OAAO,EAAQ,EAAI,CACzB,IAAIC,EAAQ,EACZ,IAAK,IAAMD,KAASD,EACZvB,EAAGwB,EAAO,GAAO,IACjB,MAAMA,EAGlB,CA2CA,SA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