import*as Common from"../common/common.js";import*as i18n from"../i18n/i18n.js";import*as Root from"../root/root.js";import*as SDK from"../sdk/sdk.js";import*as UI from"../ui/ui.js";let loadedProfilerModule;const UIStrings={memory:"Memory",liveHeapProfile:"Live Heap Profile",startRecordingHeapAllocations:"Start recording heap allocations",stopRecordingHeapAllocations:"Stop recording heap allocations",startRecordingHeapAllocationsAndReload:"Start recording heap allocations and reload the page",startStopRecording:"Start/stop recording",showNativeFunctions:"Show native functions in JS Profile",showMemory:"Show Memory",showLiveHeapProfile:"Show Live Heap Profile"},str_=i18n.i18n.registerUIStrings("profiler/profiler-meta.ts",UIStrings),i18nLazyString=i18n.i18n.getLazilyComputedLocalizedString.bind(void 0,str_);async function loadProfilerModule(){return loadedProfilerModule||(await Root.Runtime.Runtime.instance().loadModulePromise("profiler"),loadedProfilerModule=await import("./profiler.js")),loadedProfilerModule}function maybeRetrieveContextTypes(e){return void 0===loadedProfilerModule?[]:e(loadedProfilerModule)}UI.ViewManager.registerViewExtension({location:"panel",id:"heap_profiler",commandPrompt:i18nLazyString(UIStrings.showMemory),title:i18nLazyString(UIStrings.memory),order:60,loadView:async()=>(await loadProfilerModule()).HeapProfilerPanel.HeapProfilerPanel.instance()}),UI.ViewManager.registerViewExtension({location:"drawer-view",id:"live_heap_profile",commandPrompt:i18nLazyString(UIStrings.showLiveHeapProfile),title:i18nLazyString(UIStrings.liveHeapProfile),persistence:"closeable",order:100,loadView:async()=>(await loadProfilerModule()).LiveHeapProfileView.LiveHeapProfileView.instance(),experiment:Root.Runtime.ExperimentName.LIVE_HEAP_PROFILE}),UI.ActionRegistration.registerActionExtension({actionId:"live-heap-profile.toggle-recording",iconClass:"largeicon-start-recording",toggleable:!0,toggledIconClass:"largeicon-stop-recording",toggleWithRedColor:!0,loadActionDelegate:async()=>(await loadProfilerModule()).LiveHeapProfileView.ActionDelegate.instance(),category:UI.ActionRegistration.ActionCategory.MEMORY,experiment:Root.Runtime.ExperimentName.LIVE_HEAP_PROFILE,options:[{value:!0,title:i18nLazyString(UIStrings.startRecordingHeapAllocations)},{value:!1,title:i18nLazyString(UIStrings.stopRecordingHeapAllocations)}]}),UI.ActionRegistration.registerActionExtension({actionId:"live-heap-profile.start-with-reload",iconClass:"largeicon-refresh",loadActionDelegate:async()=>(await loadProfilerModule()).LiveHeapProfileView.ActionDelegate.instance(),category:UI.ActionRegistration.ActionCategory.MEMORY,experiment:Root.Runtime.ExperimentName.LIVE_HEAP_PROFILE,title:i18nLazyString(UIStrings.startRecordingHeapAllocationsAndReload)}),UI.ActionRegistration.registerActionExtension({actionId:"profiler.heap-toggle-recording",category:UI.ActionRegistration.ActionCategory.MEMORY,iconClass:"largeicon-start-recording",title:i18nLazyString(UIStrings.startStopRecording),toggleable:!0,toggledIconClass:"largeicon-stop-recording",toggleWithRedColor:!0,contextTypes:()=>maybeRetrieveContextTypes((e=>[e.HeapProfilerPanel.HeapProfilerPanel])),loadActionDelegate:async()=>(await loadProfilerModule()).HeapProfilerPanel.HeapProfilerPanel.instance(),bindings:[{platform:"windows,linux",shortcut:"Ctrl+E"},{platform:"mac",shortcut:"Meta+E"}]}),UI.ActionRegistration.registerActionExtension({actionId:"profiler.js-toggle-recording",category:UI.ActionRegistration.ActionCategory.JAVASCRIPT_PROFILER,title:i18nLazyString(UIStrings.startStopRecording),iconClass:"largeicon-start-recording",toggleable:!0,toggledIconClass:"largeicon-stop-recording",toggleWithRedColor:!0,contextTypes:()=>maybeRetrieveContextTypes((e=>[e.ProfilesPanel.JSProfilerPanel])),loadActionDelegate:async()=>(await loadProfilerModule()).ProfilesPanel.JSProfilerPanel.instance(),bindings:[{platform:"windows,linux",shortcut:"Ctrl+E"},{platform:"mac",shortcut:"Meta+E"}]}),Common.Settings.registerSettingExtension({category:"PERFORMANCE",title:i18nLazyString(UIStrings.showNativeFunctions),settingName:"showNativeFunctionsInJSProfile",settingType:"boolean",defaultValue:!0}),UI.ContextMenu.registerProvider({contextTypes:()=>[SDK.RemoteObject.RemoteObject],loadProvider:async()=>(await loadProfilerModule()).HeapProfilerPanel.HeapProfilerPanel.instance(),experiment:void 0});