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

/***/ "../node_modules/@jupyterlab/running/lib/index.js":
/*!********************************************************!*\
  !*** ../node_modules/@jupyterlab/running/lib/index.js ***!
  \********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   IRunningSessionManagers: () => (/* binding */ IRunningSessionManagers),\n/* harmony export */   IRunningSessionSidebar: () => (/* binding */ IRunningSessionSidebar),\n/* harmony export */   RunningSessionManagers: () => (/* binding */ RunningSessionManagers),\n/* harmony export */   RunningSessions: () => (/* binding */ RunningSessions),\n/* harmony export */   SearchableSessions: () => (/* binding */ SearchableSessions),\n/* harmony export */   SearchableSessionsList: () => (/* binding */ SearchableSessionsList)\n/* harmony export */ });\n/* harmony import */ var _jupyter_react_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyter/react-components */ \"webpack/sharing/consume/default/@jupyter/react-components/@jupyter/react-components\");\n/* harmony import */ var _jupyter_react_components__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyter_react_components__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @jupyterlab/apputils */ \"webpack/sharing/consume/default/@jupyterlab/apputils/@jupyterlab/apputils\");\n/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @jupyterlab/translation */ \"webpack/sharing/consume/default/@jupyterlab/translation/@jupyterlab/translation\");\n/* harmony import */ var _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @jupyterlab/ui-components */ \"webpack/sharing/consume/default/@jupyterlab/ui-components/@jupyterlab/ui-components\");\n/* harmony import */ var _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _lumino_coreutils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @lumino/coreutils */ \"webpack/sharing/consume/default/@lumino/coreutils/@lumino/coreutils\");\n/* harmony import */ var _lumino_coreutils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_lumino_coreutils__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _lumino_disposable__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @lumino/disposable */ \"webpack/sharing/consume/default/@lumino/disposable/@lumino/disposable\");\n/* harmony import */ var _lumino_disposable__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_lumino_disposable__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _lumino_domutils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @lumino/domutils */ \"webpack/sharing/consume/default/@lumino/domutils/@lumino/domutils\");\n/* harmony import */ var _lumino_domutils__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_lumino_domutils__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @lumino/signaling */ \"webpack/sharing/consume/default/@lumino/signaling/@lumino/signaling\");\n/* harmony import */ var _lumino_signaling__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_lumino_signaling__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var _lumino_widgets__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @lumino/widgets */ \"webpack/sharing/consume/default/@lumino/widgets/@lumino/widgets\");\n/* harmony import */ var _lumino_widgets__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_lumino_widgets__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react */ \"webpack/sharing/consume/default/react/react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_9__);\n// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/**\n * @packageDocumentation\n * @module running\n */\n\n\n\n\n\n\n\n\n\n\n/**\n * The class name added to a running widget.\n */\nconst RUNNING_CLASS = 'jp-RunningSessions';\n/**\n * The class name added to a searchable widget.\n */\nconst SEARCHABLE_CLASS = 'jp-SearchableSessions';\n/**\n * The class name added to the running terminal sessions section.\n */\nconst SECTION_CLASS = 'jp-RunningSessions-section';\n/**\n * The class name added to a section container.\n */\nconst CONTAINER_CLASS = 'jp-RunningSessions-sectionContainer';\n/**\n * The class name added to the running sessions items.\n */\nconst ITEM_CLASS = 'jp-RunningSessions-item';\n/**\n * The class name added to a running session item label.\n */\nconst ITEM_LABEL_CLASS = 'jp-RunningSessions-itemLabel';\n/**\n * The class name added to a running session item detail.\n */\nconst ITEM_DETAIL_CLASS = 'jp-RunningSessions-itemDetail';\n/**\n * The class name added to a running session item shutdown button.\n */\nconst SHUTDOWN_BUTTON_CLASS = 'jp-RunningSessions-itemShutdown';\n/**\n * The class name added to a running session item shutdown button.\n */\nconst SHUTDOWN_ALL_BUTTON_CLASS = 'jp-RunningSessions-shutdownAll';\n/**\n * The class name added to icons.\n */\nconst ITEM_ICON_CLASS = 'jp-RunningSessions-icon';\n/**\n * Modifier added to a section when flattened list view is requested.\n */\nconst LIST_VIEW_CLASS = 'jp-mod-running-list-view';\n/**\n * The class name added to button switching between nested and flat view.\n */\nconst VIEW_BUTTON_CLASS = 'jp-RunningSessions-viewButton';\n/**\n * The class name added to button switching between nested and flat view.\n */\nconst COLLAPSE_EXPAND_BUTTON_CLASS = 'jp-RunningSessions-collapseButton';\n/**\n * Identifier used in the state database.\n */\nconst STATE_DB_ID = 'jp-running-sessions';\n/**\n * The running sessions managers token.\n */\nconst IRunningSessionManagers = new _lumino_coreutils__WEBPACK_IMPORTED_MODULE_4__.Token('@jupyterlab/running:IRunningSessionManagers', 'A service to add running session managers.');\n/**\n * The running sessions token.\n */\nconst IRunningSessionSidebar = new _lumino_coreutils__WEBPACK_IMPORTED_MODULE_4__.Token('@jupyterlab/running:IRunningSessionsSidebar', 'A token allowing to modify the running sessions sidebar.');\nclass RunningSessionManagers {\n    constructor() {\n        this._added = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal(this);\n        this._managers = [];\n    }\n    /**\n     * Signal emitted when a new manager is added.\n     */\n    get added() {\n        return this._added;\n    }\n    /**\n     * Add a running item manager.\n     *\n     * @param manager - The running item manager.\n     *\n     */\n    add(manager) {\n        this._managers.push(manager);\n        this._added.emit(manager);\n        return new _lumino_disposable__WEBPACK_IMPORTED_MODULE_5__.DisposableDelegate(() => {\n            const i = this._managers.indexOf(manager);\n            if (i > -1) {\n                this._managers.splice(i, 1);\n            }\n        });\n    }\n    /**\n     * Return an iterator of launcher items.\n     */\n    items() {\n        return this._managers;\n    }\n}\nfunction Item(props) {\n    var _a, _b;\n    const { runningItem } = props;\n    const [collapsed, setCollapsed] = react__WEBPACK_IMPORTED_MODULE_9___default().useState(false);\n    // Use a ref instead of a state because the state does not have the time\n    // to update in the callbacks\n    const shuttingDown = (0,react__WEBPACK_IMPORTED_MODULE_9__.useRef)(false);\n    const classList = [ITEM_CLASS];\n    const detail = (_a = runningItem.detail) === null || _a === void 0 ? void 0 : _a.call(runningItem);\n    const icon = runningItem.icon();\n    const title = runningItem.labelTitle ? runningItem.labelTitle() : '';\n    const translator = props.translator || _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__.nullTranslator;\n    const trans = translator.load('jupyterlab');\n    // Handle shutdown requests.\n    const shutdownItemIcon = props.shutdownItemIcon || _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.closeIcon;\n    const shutdownLabel = (_b = (typeof props.shutdownLabel === 'function'\n        ? props.shutdownLabel(runningItem)\n        : props.shutdownLabel)) !== null && _b !== void 0 ? _b : trans.__('Shut Down');\n    const shutdown = (0,react__WEBPACK_IMPORTED_MODULE_9__.useCallback)((event) => {\n        var _a;\n        shuttingDown.current = true;\n        event.preventDefault();\n        (_a = runningItem.shutdown) === null || _a === void 0 ? void 0 : _a.call(runningItem);\n    }, [runningItem, shuttingDown]);\n    // Materialise getter to avoid triggering it repeatedly\n    const children = runningItem.children;\n    // Manage collapsed state. Use the shutdown flag in lieu of `stopPropagation`.\n    const collapsible = !!(children === null || children === void 0 ? void 0 : children.length);\n    const onClick = (0,react__WEBPACK_IMPORTED_MODULE_9__.useCallback)((event) => {\n        if (shuttingDown.current) {\n            return;\n        }\n        const item = (0,_jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.getTreeItemElement)(event.target);\n        if (event.currentTarget !== item) {\n            return;\n        }\n        if (collapsible) {\n            setCollapsed(!collapsed);\n        }\n    }, [collapsible, collapsed, shuttingDown]);\n    // Listen to signal to collapse from outside\n    props.collapseToggled.connect((_emitter, newCollapseState) => setCollapsed(newCollapseState));\n    if (runningItem.className) {\n        classList.push(runningItem.className);\n    }\n    return (react__WEBPACK_IMPORTED_MODULE_9___default().createElement((react__WEBPACK_IMPORTED_MODULE_9___default().Fragment), null,\n        react__WEBPACK_IMPORTED_MODULE_9___default().createElement(_jupyter_react_components__WEBPACK_IMPORTED_MODULE_0__.TreeItem, { className: `${classList.join(' ')} jp-TreeItem nested`, onClick: onClick, \"data-context\": runningItem.context || '', expanded: !collapsed },\n            icon ? (typeof icon === 'string' ? (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(\"img\", { src: icon, className: ITEM_ICON_CLASS, slot: \"start\" })) : (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(icon.react, { slot: \"start\", tag: \"span\", className: ITEM_ICON_CLASS }))) : undefined,\n            react__WEBPACK_IMPORTED_MODULE_9___default().createElement(\"span\", { className: ITEM_LABEL_CLASS, title: title, onClick: runningItem.open && (() => runningItem.open()) }, runningItem.label()),\n            detail && react__WEBPACK_IMPORTED_MODULE_9___default().createElement(\"span\", { className: ITEM_DETAIL_CLASS }, detail),\n            runningItem.shutdown && (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(_jupyter_react_components__WEBPACK_IMPORTED_MODULE_0__.Button, { appearance: \"stealth\", className: SHUTDOWN_BUTTON_CLASS, onClick: shutdown, title: shutdownLabel, slot: \"end\" },\n                react__WEBPACK_IMPORTED_MODULE_9___default().createElement(shutdownItemIcon.react, { tag: null }))),\n            children && (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(List, { runningItems: children, shutdownItemIcon: shutdownItemIcon, translator: translator, collapseToggled: props.collapseToggled })))));\n}\nfunction List(props) {\n    const filter = props.filter;\n    const items = filter\n        ? props.runningItems\n            .map(item => {\n            return {\n                item,\n                score: filter(item)\n            };\n        })\n            .filter(({ score }) => score !== null)\n            .sort((a, b) => {\n            return a.score.score - b.score.score;\n        })\n            .map(({ item }) => item)\n        : props.runningItems;\n    return (react__WEBPACK_IMPORTED_MODULE_9___default().createElement((react__WEBPACK_IMPORTED_MODULE_9___default().Fragment), null, items.map((item, i) => (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(Item, { child: props.child, key: i, runningItem: item, shutdownLabel: props.shutdownLabel, shutdownItemIcon: props.shutdownItemIcon, translator: props.translator, collapseToggled: props.collapseToggled })))));\n}\nclass FilterWidget extends _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.ReactWidget {\n    constructor(translator) {\n        super();\n        this._filterFn = (_) => {\n            return { score: 0 };\n        };\n        this._filterChanged = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal(this);\n        this.filter = this.filter.bind(this);\n        this._updateFilter = this._updateFilter.bind(this);\n        this._trans = translator.load('jupyterlab');\n        this.addClass('jp-SearchableSessions-filter');\n    }\n    get filterChanged() {\n        return this._filterChanged;\n    }\n    render() {\n        return (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(_jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.FilterBox, { placeholder: this._trans.__('Search'), updateFilter: this._updateFilter, useFuzzyFilter: false, caseSensitive: false }));\n    }\n    filter(item) {\n        var _a;\n        const labels = [this._getTextContent(item.label())];\n        for (const child of (_a = item.children) !== null && _a !== void 0 ? _a : []) {\n            labels.push(this._getTextContent(child.label()));\n        }\n        return this._filterFn(labels.join(' '));\n    }\n    _getTextContent(node) {\n        if (typeof node === 'string') {\n            return node;\n        }\n        if (typeof node === 'number') {\n            return '' + node;\n        }\n        if (typeof node === 'boolean') {\n            return '' + node;\n        }\n        if (Array.isArray(node)) {\n            return node.map(n => this._getTextContent(n)).join(' ');\n        }\n        if (node && (0,react__WEBPACK_IMPORTED_MODULE_9__.isValidElement)(node)) {\n            return node.props.children\n                .map((n) => this._getTextContent(n))\n                .join(' ');\n        }\n        return '';\n    }\n    _updateFilter(filterFn) {\n        this._filterFn = filterFn;\n        this._filterChanged.emit();\n    }\n}\nclass ListWidget extends _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.ReactWidget {\n    constructor(_options) {\n        super();\n        this._options = _options;\n        this._update = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal(this);\n        _options.manager.runningChanged.connect(this._emitUpdate, this);\n        if (_options.filterProvider) {\n            _options.filterProvider.filterChanged.connect(this._emitUpdate, this);\n        }\n    }\n    /**\n     * Whether the items are displayed as a tree view\n     * or a flat list.\n     */\n    get mode() {\n        return this._mode;\n    }\n    set mode(v) {\n        if (this._mode !== v) {\n            this._mode = v;\n            this._update.emit();\n        }\n    }\n    dispose() {\n        _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal.clearData(this);\n        super.dispose();\n    }\n    onBeforeShow(msg) {\n        super.onBeforeShow(msg);\n        this._update.emit();\n    }\n    render() {\n        const options = this._options;\n        let cached = true;\n        return (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(_jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.UseSignal, { signal: this._update }, () => {\n            var _a;\n            // Cache the running items for the initial load and request from\n            // the service every subsequent load.\n            if (cached) {\n                cached = false;\n            }\n            else {\n                options.runningItems = options.manager.running({ mode: this.mode });\n            }\n            const classes = ['jp-TreeView'];\n            if (this.mode === 'list') {\n                classes.push('jp-mod-flat');\n            }\n            return (react__WEBPACK_IMPORTED_MODULE_9___default().createElement(\"div\", { className: CONTAINER_CLASS },\n                react__WEBPACK_IMPORTED_MODULE_9___default().createElement(_jupyter_react_components__WEBPACK_IMPORTED_MODULE_0__.TreeView, { className: classes.join(' ') },\n                    react__WEBPACK_IMPORTED_MODULE_9___default().createElement(List, { runningItems: options.runningItems, shutdownLabel: options.manager.shutdownLabel, shutdownItemIcon: options.manager.shutdownItemIcon, filter: (_a = options.filterProvider) === null || _a === void 0 ? void 0 : _a.filter, translator: options.translator, collapseToggled: options.collapseToggled }))));\n        }));\n    }\n    _emitUpdate() {\n        if (!this.isVisible) {\n            return;\n        }\n        this._update.emit();\n    }\n}\n/**\n * The Section component contains the shared look and feel for an interactive\n * list of kernels and sessions.\n *\n * It is specialized for each based on its props.\n */\nclass Section extends _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.PanelWithToolbar {\n    constructor(options) {\n        var _a;\n        super();\n        this._buttons = null;\n        this._listView = false;\n        this._collapseToggled = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal(this);\n        this._viewChanged = new _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal(this);\n        this._listView = ((_a = options.viewMode) !== null && _a !== void 0 ? _a : 'tree') === 'list';\n        this._manager = options.manager;\n        this._filterProvider = options.filterProvider;\n        const translator = options.translator || _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__.nullTranslator;\n        this._trans = translator.load('jupyterlab');\n        this.addClass(SECTION_CLASS);\n        this.title.label = options.manager.name;\n        this._manager.runningChanged.connect(this._onListChanged, this);\n        if (options.filterProvider) {\n            options.filterProvider.filterChanged.connect(this._onListChanged, this);\n        }\n        this._updateEmptyClass();\n        const runningItems = options.manager.running({\n            mode: options.manager.supportsMultipleViews && !this._listView\n                ? 'tree'\n                : 'list'\n        });\n        if (options.showToolbar !== false) {\n            this._initializeToolbar(runningItems);\n        }\n        this._listWidget = new ListWidget({\n            runningItems,\n            collapseToggled: this._collapseToggled,\n            ...options\n        });\n        this._listWidget.mode =\n            options.manager.supportsMultipleViews && !this._listView\n                ? 'tree'\n                : 'list';\n        this.addWidget(this._listWidget);\n    }\n    /**\n     * Toggle between list and tree view.\n     */\n    toggleListView(forceOn) {\n        const newState = typeof forceOn !== 'undefined' ? forceOn : !this._listView;\n        this._listView = newState;\n        if (this._buttons) {\n            const switchViewButton = this._buttons['switch-view'];\n            switchViewButton.pressed = newState;\n        }\n        this._collapseToggled.emit(false);\n        if (this._manager.supportsMultipleViews === undefined) {\n            this.toggleClass(LIST_VIEW_CLASS, newState);\n        }\n        this._updateButtons();\n        this._listWidget.mode =\n            this._manager.supportsMultipleViews && !this._listView ? 'tree' : 'list';\n        this._viewChanged.emit({ mode: newState ? 'list' : 'tree' });\n    }\n    /**\n     * Dispose the resources held by the widget\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal.clearData(this);\n        super.dispose();\n    }\n    get _shutdownAllLabel() {\n        return this._manager.shutdownAllLabel || this._trans.__('Shut Down All');\n    }\n    _initializeToolbar(runningItems) {\n        const enabled = runningItems.length > 0;\n        const shutdownAllLabel = this._shutdownAllLabel;\n        const shutdownTitle = `${shutdownAllLabel}?`;\n        const onShutdown = () => {\n            var _a;\n            const shutdownAllConfirmationText = (_a = (typeof this._manager.shutdownAllConfirmationText === 'function'\n                ? this._manager.shutdownAllConfirmationText()\n                : this._manager.shutdownAllConfirmationText)) !== null && _a !== void 0 ? _a : `${shutdownAllLabel} ${this._manager.name}`;\n            void (0,_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.showDialog)({\n                title: shutdownTitle,\n                body: shutdownAllConfirmationText,\n                buttons: [\n                    _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.Dialog.cancelButton(),\n                    _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.Dialog.warnButton({ label: shutdownAllLabel })\n                ]\n            }).then(result => {\n                if (result.button.accept) {\n                    this._manager.shutdownAll();\n                }\n            });\n        };\n        const shutdownAllButton = new _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton({\n            label: shutdownAllLabel,\n            className: `${SHUTDOWN_ALL_BUTTON_CLASS}${!enabled ? ' jp-mod-disabled' : ''}`,\n            enabled,\n            onClick: onShutdown.bind(this)\n        });\n        const switchViewButton = new _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton({\n            className: VIEW_BUTTON_CLASS,\n            enabled,\n            icon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.tableRowsIcon,\n            pressedIcon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.treeViewIcon,\n            onClick: () => this.toggleListView(),\n            tooltip: this._trans.__('Switch to List View'),\n            pressedTooltip: this._trans.__('Switch to Tree View')\n        });\n        const collapseExpandAllButton = new _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton({\n            className: COLLAPSE_EXPAND_BUTTON_CLASS,\n            enabled,\n            icon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.collapseAllIcon,\n            pressedIcon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.expandAllIcon,\n            onClick: () => {\n                const newState = !collapseExpandAllButton.pressed;\n                this._collapseToggled.emit(newState);\n                collapseExpandAllButton.pressed = newState;\n            },\n            tooltip: this._trans.__('Collapse All'),\n            pressedTooltip: this._trans.__('Expand All')\n        });\n        this._buttons = {\n            'switch-view': switchViewButton,\n            'collapse-expand': collapseExpandAllButton,\n            'shutdown-all': shutdownAllButton\n        };\n        // Update buttons once defined and before adding to DOM\n        this._updateButtons();\n        this._manager.runningChanged.connect(this._updateButtons, this);\n        // Add manager-specific buttons\n        if (this._manager.toolbarButtons) {\n            this._manager.toolbarButtons.forEach(button => this.toolbar.addItem(button instanceof _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.CommandToolbarButton ? button.commandId : button.id, button));\n        }\n        for (const name of ['collapse-expand', 'switch-view', 'shutdown-all']) {\n            this.toolbar.addItem(name, this._buttons[name]);\n        }\n        this.toolbar.addClass('jp-RunningSessions-toolbar');\n        this._toolbar.node.setAttribute('aria-label', this._trans.__('%1 toolbar', this.title.label));\n    }\n    _onListChanged() {\n        this._updateButtons();\n        this._updateEmptyClass();\n    }\n    _updateEmptyClass() {\n        if (this._filterProvider) {\n            const items = this._manager\n                .running({\n                mode: this._manager.supportsMultipleViews && !this._listView\n                    ? 'tree'\n                    : 'list'\n            })\n                .filter(this._filterProvider.filter);\n            const empty = items.length === 0;\n            if (empty) {\n                this.node.classList.toggle('jp-mod-empty', true);\n            }\n            else {\n                this.node.classList.toggle('jp-mod-empty', false);\n            }\n        }\n    }\n    get viewChanged() {\n        return this._viewChanged;\n    }\n    _updateButtons() {\n        if (!this._buttons) {\n            return;\n        }\n        let runningItems = this._manager.running({\n            mode: this._manager.supportsMultipleViews && !this._listView ? 'tree' : 'list'\n        });\n        const enabled = runningItems.length > 0;\n        const hasNesting = \n        // If the flag is undefined fallback to the old behavior\n        // @deprecated we should remove the fallback in the next iteration\n        this._manager.supportsMultipleViews === undefined\n            ? runningItems.filter(item => item.children).length !== 0\n            : this._manager.supportsMultipleViews;\n        const inTreeView = hasNesting && !this._buttons['switch-view'].pressed;\n        this._buttons['switch-view'].node.style.display = hasNesting\n            ? 'flex'\n            : 'none';\n        this._buttons['collapse-expand'].node.style.display = inTreeView\n            ? 'flex'\n            : 'none';\n        this._buttons['collapse-expand'].enabled = enabled;\n        this._buttons['switch-view'].enabled = enabled;\n        this._buttons['shutdown-all'].enabled = enabled;\n    }\n}\n/**\n * A class that exposes the running terminal and kernel sessions.\n */\nclass RunningSessions extends _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.SidePanel {\n    /**\n     * Construct a new running widget.\n     */\n    constructor(managers, translator, stateDB) {\n        super();\n        this.managers = managers;\n        this._stateDB = stateDB !== null && stateDB !== void 0 ? stateDB : null;\n        this.translator = translator !== null && translator !== void 0 ? translator : _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__.nullTranslator;\n        const trans = this.translator.load('jupyterlab');\n        this.addClass(RUNNING_CLASS);\n        this.toolbar.addItem('refresh', new _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton({\n            tooltip: trans.__('Refresh List'),\n            icon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_3__.refreshIcon,\n            onClick: () => managers.items().forEach(manager => manager.refreshRunning())\n        }));\n        managers.items().forEach(manager => this.addSection(managers, manager));\n        managers.added.connect(this.addSection, this);\n    }\n    /**\n     * Dispose the resources held by the widget\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        this.managers.added.disconnect(this.addSection, this);\n        super.dispose();\n    }\n    /**\n     * Add a section for a new manager.\n     *\n     * @param managers Managers\n     * @param manager New manager\n     */\n    async addSection(managers, manager) {\n        const section = new Section({ manager, translator: this.translator });\n        this.addWidget(section);\n        const state = await this._getState();\n        const sectionsInListView = state.listViewSections;\n        const sectionId = manager.name;\n        if (sectionsInListView && sectionsInListView.includes(sectionId)) {\n            section.toggleListView(true);\n        }\n        section.viewChanged.connect(async (_emitter, viewState) => {\n            await this._updateState(sectionId, viewState.mode);\n        });\n    }\n    /**\n     * Update state database with the new state of a given section.\n     */\n    async _updateState(sectionId, mode) {\n        var _a;\n        const state = await this._getState();\n        let listViewSections = (_a = state.listViewSections) !== null && _a !== void 0 ? _a : [];\n        if (mode === 'list' && !listViewSections.includes(sectionId)) {\n            listViewSections.push(sectionId);\n        }\n        else {\n            listViewSections = listViewSections.filter(e => e !== sectionId);\n        }\n        const newState = { listViewSections };\n        if (this._stateDB) {\n            await this._stateDB.save(STATE_DB_ID, newState);\n        }\n    }\n    /**\n     * Get current state from the state database.\n     */\n    async _getState() {\n        var _a;\n        if (!this._stateDB) {\n            return {};\n        }\n        return ((_a = (await this._stateDB.fetch(STATE_DB_ID))) !== null && _a !== void 0 ? _a : {});\n    }\n}\n/**\n * Section but rendering its own title before the content\n */\nclass TitledSection extends Section {\n    constructor(options) {\n        super(options);\n        const titleNode = document.createElement('h3');\n        titleNode.className = 'jp-SearchableSessions-title';\n        const label = titleNode.appendChild(document.createElement('span'));\n        label.className = 'jp-SearchableSessions-titleLabel';\n        label.textContent = this.title.label;\n        this.node.insertAdjacentElement('afterbegin', titleNode);\n    }\n}\nclass EmptyIndicator extends _lumino_widgets__WEBPACK_IMPORTED_MODULE_8__.Widget {\n    constructor(translator) {\n        super();\n        const trans = translator.load('jupyterlab');\n        this.addClass('jp-SearchableSessions-emptyIndicator');\n        this.node.textContent = trans.__('No matches');\n    }\n}\n/**\n * A panel intended for use within `Dialog` to allow searching tabs and running sessions.\n */\nclass SearchableSessions extends _lumino_widgets__WEBPACK_IMPORTED_MODULE_8__.Panel {\n    constructor(managers, translator) {\n        super();\n        this._activeIndex = 0;\n        this._translator = translator !== null && translator !== void 0 ? translator : _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__.nullTranslator;\n        this.addClass(RUNNING_CLASS);\n        this.addClass(SEARCHABLE_CLASS);\n        this._filterWidget = new FilterWidget(this._translator);\n        this.addWidget(this._filterWidget);\n        this._list = new SearchableSessionsList(managers, this._filterWidget, translator);\n        this.addWidget(this._list);\n        this._filterWidget.filterChanged.connect(() => {\n            this._activeIndex = 0;\n            this._updateActive(0);\n        }, this);\n    }\n    /**\n     * Dispose the resources held by the widget\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        _lumino_signaling__WEBPACK_IMPORTED_MODULE_7__.Signal.clearData(this);\n        super.dispose();\n    }\n    /**\n     * Click active element when the user confirmed the choice in the dialog.\n     */\n    getValue() {\n        const items = [\n            ...this.node.querySelectorAll('.' + ITEM_LABEL_CLASS)\n        ];\n        const pos = Math.min(Math.max(this._activeIndex, 0), items.length - 1);\n        items[pos].click();\n    }\n    /**\n     * Handle incoming events.\n     */\n    handleEvent(event) {\n        switch (event.type) {\n            case 'keydown':\n                this._evtKeydown(event);\n                break;\n        }\n    }\n    /**\n     * A message handler invoked on an `'after-attach'` message.\n     */\n    onAfterAttach(_) {\n        this._forceFocusInput();\n        this.node.addEventListener('keydown', this);\n        setTimeout(() => {\n            this._updateActive(0);\n        }, 0);\n    }\n    /**\n     * A message handler invoked on an `'after-detach'` message.\n     */\n    onAfterDetach(_) {\n        this.node.removeEventListener('keydown', this);\n    }\n    /**\n     * Force focus on the filter input.\n     *\n     * Note: forces focus because this widget is intended to be used in `Dialog`,\n     * which does not support focusing React widget nested within a non-React\n     * widget (a limitation of `focusNodeSelector` option implementation).\n     */\n    _forceFocusInput() {\n        var _a;\n        (_a = this._filterWidget.renderPromise) === null || _a === void 0 ? void 0 : _a.then(() => {\n            var _a;\n            const jpSearch = this._filterWidget.node.querySelector('jp-search');\n            const input = (_a = jpSearch === null || jpSearch === void 0 ? void 0 : jpSearch.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input');\n            if (!input) {\n                console.warn('Input element not found, cannot focus');\n                return;\n            }\n            input.focus();\n        }).catch(console.warn);\n    }\n    /**\n     * Navigate between items using up/down keys by shifting focus.\n     */\n    _evtKeydown(event) {\n        if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n            const direction = event.key === 'ArrowDown' ? +1 : -1;\n            const wasSet = this._updateActive(direction);\n            if (wasSet) {\n                event.preventDefault();\n            }\n        }\n    }\n    /**\n     * Set and mark active item relative to the current.\n     *\n     * Returns whether an active item was set.\n     */\n    _updateActive(direction) {\n        const items = [...this.node.querySelectorAll('.' + ITEM_CLASS)].filter(e => e.checkVisibility());\n        if (!items.length) {\n            return false;\n        }\n        for (const item of items) {\n            if (item.classList.contains('jp-mod-active')) {\n                item.classList.toggle('jp-mod-active', false);\n            }\n        }\n        const currentIndex = this._activeIndex;\n        let newIndex = null;\n        if (currentIndex === -1) {\n            // First or last\n            newIndex = direction === +1 ? 0 : items.length - 1;\n        }\n        else {\n            newIndex = Math.min(Math.max(currentIndex + direction, 0), items.length - 1);\n        }\n        if (newIndex !== null) {\n            items[newIndex].classList.add('jp-mod-active');\n            _lumino_domutils__WEBPACK_IMPORTED_MODULE_6__.ElementExt.scrollIntoViewIfNeeded(this._list.node, items[newIndex]);\n            this._activeIndex = newIndex;\n            return true;\n        }\n        return false;\n    }\n}\n/**\n * A panel list of searchable sessions.\n */\nclass SearchableSessionsList extends _lumino_widgets__WEBPACK_IMPORTED_MODULE_8__.Panel {\n    constructor(managers, filterWidget, translator) {\n        super();\n        this._managers = managers;\n        this._translator = translator !== null && translator !== void 0 ? translator : _jupyterlab_translation__WEBPACK_IMPORTED_MODULE_2__.nullTranslator;\n        this._filterWidget = filterWidget;\n        this.addClass('jp-SearchableSessions-list');\n        this._emptyIndicator = new EmptyIndicator(this._translator);\n        this.addWidget(this._emptyIndicator);\n        managers.items().forEach(manager => this.addSection(managers, manager));\n        managers.added.connect(this.addSection, this);\n    }\n    /**\n     * Dispose the resources held by the widget\n     */\n    dispose() {\n        if (this.isDisposed) {\n            return;\n        }\n        this._managers.added.disconnect(this.addSection, this);\n        super.dispose();\n    }\n    /**\n     * Add a section for a new manager.\n     *\n     * @param managers Managers\n     * @param manager New manager\n     */\n    addSection(managers, manager) {\n        const section = new TitledSection({\n            manager,\n            translator: this._translator,\n            showToolbar: false,\n            filterProvider: this._filterWidget,\n            viewMode: 'list'\n        });\n        // Do not use tree view in searchable list\n        section.toggleListView(true);\n        this.addWidget(section);\n        // Move empty indicator to the end\n        this.addWidget(this._emptyIndicator);\n    }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@jupyterlab/running/lib/index.js?");

/***/ })

}]);