import*as i18n from"../i18n/i18n.js";import*as SDK from"../sdk/sdk.js";import*as UI from"../ui/ui.js";const UIStrings={websocketDisconnected:"WebSocket disconnected"},str_=i18n.i18n.registerUIStrings("components/TargetDetachedDialog.js",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class TargetDetachedDialog extends SDK.SDKModel.SDKModel{constructor(e){super(e),e.registerInspectorDispatcher(this),e.inspectorAgent().invoke_enable(),this._hideCrashedDialog=null}detached({reason:e}){UI.RemoteDebuggingTerminatedScreen.RemoteDebuggingTerminatedScreen.show(e)}static webSocketConnectionLost(){UI.RemoteDebuggingTerminatedScreen.RemoteDebuggingTerminatedScreen.show(i18nString(UIStrings.websocketDisconnected))}targetCrashed(){if(this.target().parentTarget())return;const e=new UI.Dialog.Dialog;e.setSizeBehavior(UI.GlassPane.SizeBehavior.MeasureContent),e.addCloseButton(),e.setDimmed(!0),this._hideCrashedDialog=e.hide.bind(e),new UI.TargetCrashedScreen.TargetCrashedScreen((()=>{this._hideCrashedDialog=null})).show(e.contentElement),e.show()}targetReloadedAfterCrash(){this.target().runtimeAgent().invoke_runIfWaitingForDebugger(),this._hideCrashedDialog&&(this._hideCrashedDialog.call(null),this._hideCrashedDialog=null)}}SDK.SDKModel.SDKModel.register(TargetDetachedDialog,SDK.SDKModel.Capability.Inspector,!0);