import*as Common from"../common/common.js";import*as Host from"../host/host.js";import*as Root from"../root/root.js";import*as UI from"../ui/ui.js";import{releaseNoteText}from"./ReleaseNoteText.js";export const releaseVersionSeen="releaseNoteVersionSeen";export const releaseNoteViewId="release-note";let latestReleaseNoteInstance,helpLateInitializationInstance,releaseNotesActionDelegateInstance,reportIssueActionDelegateInstance;export function latestReleaseNote(){const e=self.Help.releaseNoteText;return latestReleaseNoteInstance||(latestReleaseNoteInstance=(e||releaseNoteText).reduce(((e,t)=>t.version>e.version?t:e))),latestReleaseNoteInstance}export function showReleaseNoteIfNeeded(){innerShowReleaseNoteIfNeeded(Common.Settings.Settings.instance().createSetting(releaseVersionSeen,0).get(),latestReleaseNote().version,Common.Settings.Settings.instance().moduleSetting("help.show-release-note").get())}export function innerShowReleaseNoteIfNeeded(e,t,n){const o=Common.Settings.Settings.instance().createSetting(releaseVersionSeen,0);e?n&&(e>=t||(o.set(t),UI.ViewManager.ViewManager.instance().showView("release-note",!0))):o.set(t)}export class HelpLateInitialization{static instance(e={forceNew:null}){const{forceNew:t}=e;return helpLateInitializationInstance&&!t||(helpLateInitializationInstance=new HelpLateInitialization),helpLateInitializationInstance}async run(){Host.InspectorFrontendHost.isUnderTest()||(await Root.Runtime.Runtime.instance().loadModulePromise("help"),showReleaseNoteIfNeeded())}}Common.Runnable.registerLateInitializationRunnable(HelpLateInitialization.instance);export class ReleaseNotesActionDelegate{handleAction(e,t){return Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(latestReleaseNote().link),!0}static instance(e={forceNew:null}){const{forceNew:t}=e;return releaseNotesActionDelegateInstance&&!t||(releaseNotesActionDelegateInstance=new ReleaseNotesActionDelegate),releaseNotesActionDelegateInstance}}export class ReportIssueActionDelegate{handleAction(e,t){return Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://bugs.chromium.org/p/chromium/issues/entry?template=DevTools+issue"),!0}static instance(e={forceNew:null}){const{forceNew:t}=e;return reportIssueActionDelegateInstance&&!t||(reportIssueActionDelegateInstance=new ReportIssueActionDelegate),reportIssueActionDelegateInstance}}