import*as LayerViewer from"../layer_viewer/layer_viewer.js";import*as UI from"../ui/ui.js";export class TimelineLayersView extends UI.SplitWidget.SplitWidget{constructor(e,i){super(!0,!1,"timelineLayersView"),this._model=e,this._showPaintProfilerCallback=i,this.element.classList.add("timeline-layers-view"),this._rightSplitWidget=new UI.SplitWidget.SplitWidget(!0,!0,"timelineLayersViewDetails"),this._rightSplitWidget.element.classList.add("timeline-layers-view-properties"),this.setMainWidget(this._rightSplitWidget);const t=new UI.Widget.VBox;this.setSidebarWidget(t),this._layerViewHost=new LayerViewer.LayerViewHost.LayerViewHost;const s=new LayerViewer.LayerTreeOutline.LayerTreeOutline(this._layerViewHost);t.element.appendChild(s.element),this._layers3DView=new LayerViewer.Layers3DView.Layers3DView(this._layerViewHost),this._layers3DView.addEventListener(LayerViewer.Layers3DView.Events.PaintProfilerRequested,this._onPaintProfilerRequested,this),this._rightSplitWidget.setMainWidget(this._layers3DView);const r=new LayerViewer.LayerDetailsView.LayerDetailsView(this._layerViewHost);this._rightSplitWidget.setSidebarWidget(r),r.addEventListener(LayerViewer.LayerDetailsView.Events.PaintProfilerRequested,this._onPaintProfilerRequested,this)}showLayerTree(e){this._frameLayerTree=e,this.isShowing()?this._update():this._updateWhenVisible=!0}wasShown(){this._updateWhenVisible&&(this._updateWhenVisible=!1,this._update())}_onPaintProfilerRequested(e){const i=e.data;this._layers3DView.snapshotForSelection(i).then((e=>{e&&this._showPaintProfilerCallback(e.snapshot)}))}_update(){this._frameLayerTree&&this._frameLayerTree.layerTreePromise().then((e=>this._layerViewHost.setLayerTree(e)))}}