import*as Common from"../common/common.js";import*as Components from"../components/components.js";import*as MobileThrottling from"../mobile_throttling/mobile_throttling.js";import{ls}from"../platform/platform.js";import*as SDK from"../sdk/sdk.js";let workerMainImplInstance;export class WorkerMainImpl extends Common.ObjectWrapper.ObjectWrapper{static instance(e={forceNew:null}){const{forceNew:n}=e;return workerMainImplInstance&&!n||(workerMainImplInstance=new WorkerMainImpl),workerMainImplInstance}async run(){SDK.Connections.initMainConnection((async()=>{SDK.SDKModel.TargetManager.instance().createTarget("main",ls`Main`,SDK.SDKModel.Type.ServiceWorker,null)}),Components.TargetDetachedDialog.TargetDetachedDialog.webSocketConnectionLost),new MobileThrottling.NetworkPanelIndicator.NetworkPanelIndicator}}Common.Runnable.registerEarlyInitializationRunnable(WorkerMainImpl.instance),SDK.ChildTargetManager.ChildTargetManager.install((async({target:e,waitingForDebugger:n})=>{if(e.parentTarget()||e.type()!==SDK.SDKModel.Type.ServiceWorker||!n)return;const o=e.model(SDK.DebuggerModel.DebuggerModel);o&&(o.isReadyToPause()||await o.once(SDK.DebuggerModel.Events.DebuggerIsReadyToPause),o.pause())}));