export default class Widget extends Common.Object{constructor(isWebComponent,delegatesFocus){super();this.contentElement=createElementWithClass('div','widget');if(isWebComponent){this.element=createElementWithClass('div','vbox flex-auto');this._shadowRoot=UI.createShadowRootWithCoreStyles(this.element,undefined,delegatesFocus);this._shadowRoot.appendChild(this.contentElement);}else{this.element=this.contentElement;} this._isWebComponent=isWebComponent;this.element.__widget=this;this._visible=false;this._isRoot=false;this._isShowing=false;this._children=[];this._hideOnDetach=false;this._notificationDepth=0;this._invalidationsSuspended=0;this._defaultFocusedChild=null;} static _incrementWidgetCounter(parentElement,childElement){const count=(childElement.__widgetCounter||0)+(childElement.__widget?1:0);if(!count){return;} while(parentElement){parentElement.__widgetCounter=(parentElement.__widgetCounter||0)+count;parentElement=parentElement.parentElementOrShadowHost();}} static _decrementWidgetCounter(parentElement,childElement){const count=(childElement.__widgetCounter||0)+(childElement.__widget?1:0);if(!count){return;} while(parentElement){parentElement.__widgetCounter-=count;parentElement=parentElement.parentElementOrShadowHost();}} static __assert(condition,message){if(!condition){throw new Error(message);}} static focusWidgetForNode(node){while(node){if(node.__widget){break;} node=node.parentNodeOrShadowHost();} if(!node){return;} let widget=node.__widget;while(widget._parentWidget){widget._parentWidget._defaultFocusedChild=widget;widget=widget._parentWidget;}} markAsRoot(){Widget.__assert(!this.element.parentElement,'Attempt to mark as root attached node');this._isRoot=true;} parentWidget(){return this._parentWidget;} children(){return this._children;} childWasDetached(widget){} isShowing(){return this._isShowing;} shouldHideOnDetach(){if(!this.element.parentElement){return false;} if(this._hideOnDetach){return true;} for(const child of this._children){if(child.shouldHideOnDetach()){return true;}} return false;} setHideOnDetach(){this._hideOnDetach=true;} _inNotification(){return!!this._notificationDepth||(this._parentWidget&&this._parentWidget._inNotification());} _parentIsShowing(){if(this._isRoot){return true;} return!!this._parentWidget&&this._parentWidget.isShowing();} _callOnVisibleChildren(method){const copy=this._children.slice();for(let i=0;i