import*as UI from"../ui/ui.js";import{ConsoleView}from"./ConsoleView.js";let consolePanelInstance;export class ConsolePanel extends UI.Panel.Panel{constructor(){super("console"),this._view=ConsoleView.instance()}static instance(e={forceNew:null}){const{forceNew:n}=e;return consolePanelInstance&&!n||(consolePanelInstance=new ConsolePanel),consolePanelInstance}static _updateContextFlavor(){const e=ConsolePanel.instance()._view;UI.Context.Context.instance().setFlavor(ConsoleView,e.isShowing()?e:null)}wasShown(){super.wasShown();wrapperViewInstance&&wrapperViewInstance.isShowing()&&UI.InspectorView.InspectorView.instance().setDrawerMinimized(!0),this._view.show(this.element),ConsolePanel._updateContextFlavor()}willHide(){super.willHide(),UI.InspectorView.InspectorView.instance().setDrawerMinimized(!1),wrapperViewInstance&&wrapperViewInstance._showViewInWrapper(),ConsolePanel._updateContextFlavor()}searchableView(){return ConsoleView.instance().searchableView()}}let consoleRevealerInstance,wrapperViewInstance=null;export class WrapperView extends UI.Widget.VBox{constructor(){super(),this.element.classList.add("console-view-wrapper"),this._view=ConsoleView.instance()}static instance(){return wrapperViewInstance||(wrapperViewInstance=new WrapperView),wrapperViewInstance}wasShown(){ConsolePanel.instance().isShowing()?UI.InspectorView.InspectorView.instance().setDrawerMinimized(!0):this._showViewInWrapper(),ConsolePanel._updateContextFlavor()}willHide(){UI.InspectorView.InspectorView.instance().setDrawerMinimized(!1),ConsolePanel._updateContextFlavor()}_showViewInWrapper(){this._view.show(this.element)}}export class ConsoleRevealer{static instance(e={forceNew:null}){const{forceNew:n}=e;return consoleRevealerInstance&&!n||(consoleRevealerInstance=new ConsoleRevealer),consoleRevealerInstance}async reveal(e){const n=ConsoleView.instance();n.isShowing()?n.focus():await UI.ViewManager.ViewManager.instance().showView("console-view")}}