var Le=Object.defineProperty;var H=(c,e)=>{for(var t in e)Le(c,t,{get:e[t],enumerable:!0})};var ue={};H(ue,{ExecutionContextSelector:()=>U});import*as r from"./../../core/sdk/sdk.js";var U=class{#t;#e;#n;#o;constructor(e,t){t.addFlavorChangeListener(r.RuntimeModel.ExecutionContext,this.#a,this),t.addFlavorChangeListener(r.Target.Target,this.#c,this),e.addModelListener(r.RuntimeModel.RuntimeModel,r.RuntimeModel.Events.ExecutionContextCreated,this.#d,this),e.addModelListener(r.RuntimeModel.RuntimeModel,r.RuntimeModel.Events.ExecutionContextDestroyed,this.#l,this),e.addModelListener(r.RuntimeModel.RuntimeModel,r.RuntimeModel.Events.ExecutionContextOrderChanged,this.#g,this),this.#t=e,this.#e=t,e.observeModels(r.RuntimeModel.RuntimeModel,this)}modelAdded(e){queueMicrotask(t.bind(this));function t(){this.#e.flavor(r.Target.Target)||this.#e.setFlavor(r.Target.Target,e.target())}}modelRemoved(e){this.#e.flavor(r.RuntimeModel.ExecutionContext)?.runtimeModel===e&&this.#m();let o=this.#t.models(r.RuntimeModel.RuntimeModel);this.#e.flavor(r.Target.Target)===e.target()&&o.length&&this.#e.setFlavor(r.Target.Target,o[0].target())}#a({data:e}){e&&(this.#e.setFlavor(r.Target.Target,e.target()),this.#o||(this.#n=this.#s(e)))}#s(e){return e.isDefault?e.target().name()+":"+e.frameId:""}#c({data:e}){let t=this.#e.flavor(r.RuntimeModel.ExecutionContext);if(!e||t&&t.target()===e)return;let o=e.model(r.RuntimeModel.RuntimeModel),n=o?o.executionContexts():[];if(!n.length)return;let a=null;for(let l=0;l<n.length&&!a;++l)this.#i(n[l])&&(a=n[l]);for(let l=0;l<n.length&&!a;++l)this.#r(n[l])&&(a=n[l]);this.#o=!0,this.#e.setFlavor(r.RuntimeModel.ExecutionContext,a||n[0]),this.#o=!1}#i(e){return e.target().targetInfo()?.subtype?!1:this.#n&&this.#n===this.#s(e)?!0:!this.#n&&this.#r(e)}#r(e){return!e.isDefault||!e.frameId||e.target().parentTarget()?.type()===r.Target.Type.FRAME?!1:!!e.target().model(r.ResourceTreeModel.ResourceTreeModel)?.frameForId(e.frameId)?.isOutermostFrame()}#d(e){if(this.#n===void 0){this.#u(e.data);return}switch(e.data.target().type()){case r.Target.Type.AUCTION_WORKLET:case r.Target.Type.SHARED_STORAGE_WORKLET:case r.Target.Type.SHARED_WORKER:case r.Target.Type.ServiceWorker:case r.Target.Type.WORKLET:case r.Target.Type.Worker:return;case r.Target.Type.BROWSER:case r.Target.Type.FRAME:case r.Target.Type.NODE:case r.Target.Type.TAB:this.#u(e.data);break}}#l(e){let t=e.data;this.#e.flavor(r.RuntimeModel.ExecutionContext)===t&&this.#m()}#g(e){let o=e.data.executionContexts();for(let n=0;n<o.length&&!this.#u(o[n]);n++);}#u(e){return!this.#e.flavor(r.RuntimeModel.ExecutionContext)||this.#i(e)?(this.#o=!0,this.#e.setFlavor(r.RuntimeModel.ExecutionContext,e),this.#o=!1,!0):!1}#m(){let e=this.#t.models(r.RuntimeModel.RuntimeModel),t=null;for(let o=0;o<e.length&&!t;++o){let n=e[o].executionContexts();for(let a of n)if(this.#r(a)){t=a;break}}if(!t)for(let o=0;o<e.length&&!t;++o){let n=e[o].executionContexts();if(n.length){t=n[0];break}}this.#o=!0,this.#e.setFlavor(r.RuntimeModel.ExecutionContext,t),this.#o=!1}};var Se={};H(Se,{DEFAULT_VIEW:()=>Ie,GlobalAiButton:()=>V,GlobalAiButtonState:()=>y,GlobalAiButtonToolbarProvider:()=>X});import*as pe from"./../../core/common/common.js";import*as J from"./../../core/i18n/i18n.js";import*as j from"./../../core/root/root.js";import*as q from"./../../models/ai_assistance/ai_assistance.js";import*as I from"./../../ui/legacy/legacy.js";import*as Ue from"./../../ui/lit/lit.js";import*as fe from"./../../ui/visual_logging/visual_logging.js";var me=`@scope to (devtools-widget > *){.global-ai-button-container{margin-left:var(--sys-size-3);margin-right:var(--sys-size-2)}.global-ai-button{display:flex;justify-content:center;align-items:center;width:var(--sys-size-9);height:var(--sys-size-9);border-radius:var(--sys-shape-corner-full);background-image:var(--app-gradient-google-ai);font:var(--sys-typescale-body4-medium);color:var(--ref-palette-neutral100);transition:width 1s,padding 1s;margin-left:auto;overflow:hidden;position:relative;border:0;&:focus-visible{outline:var(--sys-size-2) solid var(--sys-color-state-focus-ring)}&:hover::after,
    &:active::after{content:"";height:100%;width:100%;border-radius:inherit;position:absolute;top:0;left:0}&:hover::after{background-color:var(--sys-color-state-hover-on-prominent)}&:active::after{background-color:var(--sys-color-state-ripple-primary)}devtools-icon{width:var(--sys-size-7);height:var(--sys-size-7);color:var(--ref-palette-neutral100)}.button-text{opacity:0%;transition:opacity 1s}}.global-ai-button.expanded{width:auto;padding:0 var(--sys-size-6) 0 var(--sys-size-5);.button-text{opacity:100%}}}
/*# sourceURL=${import.meta.resolve("././globalAiButton.css")} */`;var{render:Ae,html:Pe,Directives:{classMap:Fe}}=Ue,A={aiAssistance:"AI assistance",openAiAssistance:"Open AI assistance panel",gemini:"Gemini",openGemini:"Open Gemini panel"},He=J.i18n.registerUIStrings("entrypoints/main/GlobalAiButton.ts",A),N=J.i18n.getLocalizedString.bind(void 0,He),Ne=5e3,Ve=new Date("2026-09-30");function he(){return pe.Settings.Settings.instance().createSetting("global-ai-button-click-count",0,"Synced")}function Oe(){let c=he();c.set(c.get()+1)}var y;(function(c){c.PROMOTION="promotion",c.DEFAULT="default"})(y||(y={}));var Ie=(c,e,t)=>{let o=c.state===y.PROMOTION,n=Fe({"global-ai-button":!0,expanded:o}),a=q.AiUtils.isGeminiBranding()?{title:N(A.openGemini),label:N(A.gemini)}:{title:N(A.openAiAssistance),label:N(A.aiAssistance)},l=q.AiUtils.getIconName();Ae(Pe`
    <style>${me}</style>
    <div class="global-ai-button-container">
      <button class=${n} @click=${c.onClick} title=${a.title} jslog=${fe.action().track({click:!0}).context("global-ai-button")}>
        <devtools-icon name=${l}></devtools-icon>
        <span class="button-text">${` ${a.label}`}</span>
      </button>
    </div>
  `,t)},V=class extends I.Widget.Widget{#t;#e=y.DEFAULT;#n=!1;#o;constructor(e,t){super(e),this.#t=t??Ie,this.requestUpdate(),this.#r()&&this.#d()}willHide(){super.willHide(),this.#i(),this.#o&&window.clearTimeout(this.#o)}#a=()=>{this.#n=!0};#s=()=>{this.#n=!1};#c(){I.InspectorView.InspectorView.instance().tabbedPane.headerElement().addEventListener("mouseenter",this.#a),I.InspectorView.InspectorView.instance().tabbedPane.headerElement().addEventListener("mouseleave",this.#s)}#i(){I.InspectorView.InspectorView.instance().tabbedPane.headerElement().removeEventListener("mouseenter",this.#a),I.InspectorView.InspectorView.instance().tabbedPane.headerElement().removeEventListener("mouseleave",this.#s)}#r(){let e=!!j.Runtime.hostConfig.devToolsGlobalAiButton?.promotionEnabled,t=new Date<Ve;return e&&t&&he().get()<2}#d(){this.#e=y.PROMOTION,this.requestUpdate(),this.#c(),this.#l()}#l(){this.#o&&window.clearTimeout(this.#o),this.#o=window.setTimeout(()=>{if(this.#n){this.#l();return}this.#e=y.DEFAULT,this.requestUpdate(),this.#i()},Ne)}#g(){I.ViewManager.ViewManager.instance().showViewInLocation("freestyler","drawer-view"),Oe();let e=I.InspectorView.InspectorView.instance().isUserExplicitlyUpdatedDrawerOrientation();j.Runtime.hostConfig.devToolsFlexibleLayout?.verticalDrawerEnabled&&!e&&(I.InspectorView.InspectorView.instance().showDrawer({focus:!0,hasTargetDrawer:!1}),I.InspectorView.InspectorView.instance().toggleDrawerOrientation({force:I.InspectorView.DrawerOrientation.VERTICAL}))}performUpdate(){this.#t({state:this.#e,onClick:this.#g.bind(this)},void 0,this.contentElement)}},G,X=class c{#t;#e;constructor(){this.#e=document.createElement("devtools-widget"),new V(this.#e),this.#t=new I.Toolbar.ToolbarItemWithCompactLayout(this.#e),this.#t.setVisible(!1)}item(){return this.#t}static instance(e={forceNew:null}){let{forceNew:t}=e;return(!G||t)&&(G=new c),G}};var ye={};H(ye,{MainImpl:()=>F,MainMenuItem:()=>ie,PauseListener:()=>B,ReloadActionDelegate:()=>ae,SearchActionDelegate:()=>se,SettingsButtonProvider:()=>re,ZoomActionDelegate:()=>ne,sendOverProtocol:()=>ze});import*as u from"./../../core/common/common.js";import*as i from"./../../core/host/host.js";import*as D from"./../../core/i18n/i18n.js";import*as be from"./../../core/platform/platform.js";import*as le from"./../../core/protocol_client/protocol_client.js";import*as g from"./../../core/root/root.js";import*as m from"./../../core/sdk/sdk.js";import*as ve from"./../../foundation/foundation.js";import*as Te from"./../../models/ai_assistance/ai_assistance.js";import*as Me from"./../../models/autofill_manager/autofill_manager.js";import*as ee from"./../../models/badges/badges.js";import*as L from"./../../models/bindings/bindings.js";import*as te from"./../../models/breakpoints/breakpoints.js";import*as ke from"./../../models/crux-manager/crux-manager.js";import*as P from"./../../models/issues_manager/issues_manager.js";import*as Ce from"./../../models/live-metrics/live-metrics.js";import*as K from"./../../models/logs/logs.js";import*as S from"./../../models/persistence/persistence.js";import*as Re from"./../../models/project_settings/project_settings.js";import*as w from"./../../models/workspace/workspace.js";import*as x from"./../../panels/common/common.js";import*as Ee from"./../../panels/snippets/snippets.js";import"./../../ui/components/buttons/buttons.js";import*as oe from"./../../ui/components/snackbars/snackbars.js";import*as De from"./../../ui/helpers/helpers.js";import*as W from"./../../ui/legacy/components/utils/utils.js";import*as s from"./../../ui/legacy/legacy.js";import*as O from"./../../ui/legacy/theme_support/theme_support.js";import{html as Be,render as Ke}from"./../../ui/lit/lit.js";import*as p from"./../../ui/visual_logging/visual_logging.js";var C,f={customizeAndControlDevtools:"Customize and control DevTools",dockSide:"Dock side",placementOfDevtoolsRelativeToThe:"Placement of DevTools relative to the page. ({PH1} to restore last position)",undockIntoSeparateWindow:"Undock into separate window",dockToBottom:"Dock to bottom",dockToRight:"Dock to right",dockToLeft:"Dock to left",focusDebuggee:"Focus page",hideConsoleDrawer:"Hide console drawer",showConsoleDrawer:"Show console drawer",moreTools:"More tools",help:"Help",dockSideNavigation:"Use left and right arrow keys to navigate the options",aiModelDownloaded:"AI model downloaded",getDevToolsMcp:"Get `DevTools MCP`"},We=D.i18n.registerUIStrings("entrypoints/main/MainImpl.ts",f),h=D.i18n.getLocalizedString.bind(void 0,We),we,_e={register(c){},async get(c){return window.localStorage.getItem(c)},set(c,e){window.localStorage.setItem(c,e)},remove(c){window.localStorage.removeItem(c)},clear:()=>window.localStorage.clear()},Z;function $e(){return typeof Z>"u"&&(Z=window.location.toString().startsWith("devtools://devtools/custom/")),Z}var F=class{#t=Promise.withResolvers();#e;#n;constructor(){C.instanceForTest=this,this.#o()}static time(e){i.InspectorFrontendHost.isUnderTest()||console.time(e)}static timeEnd(e){i.InspectorFrontendHost.isUnderTest()||console.timeEnd(e)}async#o(){console.timeStamp("Main._loaded"),g.Runtime.Runtime.setPlatform(i.Platform.platform());let[e,t]=await Promise.all([new Promise(l=>{i.InspectorFrontendHost.InspectorFrontendHostInstance.getHostConfig(l)}),new Promise(l=>i.InspectorFrontendHost.InspectorFrontendHostInstance.getPreferences(l))]);console.timeStamp("Main._gotPreferences"),this.#a(),Object.assign(g.Runtime.hostConfig,e);let o={settingsCreationOptions:{...this.createSettingsStorage(t),settingRegistrations:u.SettingRegistration.getRegisteredSettings(),logSettingAccess:p.logSettingAccess,runSettingsMigration:!i.InspectorFrontendHost.isUnderTest()}};this.#n=new ve.Universe.Universe(o),g.DevToolsContext.setGlobalInstance(this.#n.context),g.Runtime.experiments.cleanUpStaleExperiments(),await this.requestAndRegisterLocaleData(),i.userMetrics.syncSetting(u.Settings.Settings.instance().moduleSetting("sync-preferences").get());let n=e.devToolsVeLogging,a=u.Settings.Settings.instance().createSetting("veLogsTestMode",!1).get();if(n?.enabled)if(n?.testing||a){p.setVeDebugLoggingEnabled(!0,"Test");let l={processingThrottler:new u.Throttler.Throttler(0),keyboardLogThrottler:new u.Throttler.Throttler(10),hoverLogThrottler:new u.Throttler.Throttler(50),dragLogThrottler:new u.Throttler.Throttler(50),clickLogThrottler:new u.Throttler.Throttler(10),resizeLogThrottler:new u.Throttler.Throttler(10)};this.#e=p.startLogging(l)}else this.#e=p.startLogging();this.#i()}#a(){self.Extensions||={},self.Host||={},self.Host.userMetrics||=i.userMetrics,self.Host.UserMetrics||=i.UserMetrics,self.ProtocolClient||={},self.ProtocolClient.test||=le.InspectorBackend.test}async requestAndRegisterLocaleData(){let e=u.Settings.Settings.instance().moduleSetting("language").get(),t=D.DevToolsLocale.DevToolsLocale.instance({create:!0,data:{navigatorLanguage:navigator.language,settingLanguage:e,lookupClosestDevToolsLocale:D.i18n.lookupClosestSupportedDevToolsLocale}});i.userMetrics.language(t.locale),t.locale!=="en-US"&&await D.i18n.fetchAndRegisterLocaleData("en-US");try{await D.i18n.fetchAndRegisterLocaleData(t.locale)}catch(o){console.warn(`Unable to fetch & register locale data for '${t.locale}', falling back to 'en-US'. Cause: `,o),t.forceFallbackLocale()}}createSettingsStorage(e){this.#c();let t="";$e()?t="__custom__":!g.Runtime.Runtime.queryParam("can_dock")&&g.Runtime.Runtime.queryParam("debugFrontend")&&!i.InspectorFrontendHost.isUnderTest()&&(t="__bundled__");let o;!i.InspectorFrontendHost.isUnderTest()&&window.localStorage?o=new u.Settings.SettingsStorage(window.localStorage,_e,t):o=new u.Settings.SettingsStorage({},void 0,t);let n={register:d=>i.InspectorFrontendHost.InspectorFrontendHostInstance.registerPreference(d,{synced:!1}),set:i.InspectorFrontendHost.InspectorFrontendHostInstance.setPreference,get:d=>new Promise(M=>{i.InspectorFrontendHost.InspectorFrontendHostInstance.getPreference(d,M)}),remove:i.InspectorFrontendHost.InspectorFrontendHostInstance.removePreference,clear:i.InspectorFrontendHost.InspectorFrontendHostInstance.clearPreferences},a={...n,register:d=>i.InspectorFrontendHost.InspectorFrontendHostInstance.registerPreference(d,{synced:!0})},l=new u.Settings.SettingsStorage(e,a,t),R=new u.Settings.SettingsStorage(e,n,t);return{syncedStorage:l,globalStorage:R,localStorage:o}}#s(e,t){let o=g.Runtime.experiments.getValueFromStorage(e);o!==void 0&&t.aboutFlag&&(t.setEnabled(o),i.InspectorFrontendHost.InspectorFrontendHostInstance.setChromeFlag(t.aboutFlag,o))}#c(){let e=(g.Runtime.hostConfig.devToolsProtocolMonitor?.enabled??!1)||!!g.Runtime.Runtime.queryParam("isChromeForTesting"),t=g.Runtime.experiments.registerHostExperiment({name:g.ExperimentNames.ExperimentName.PROTOCOL_MONITOR,title:"Protocol Monitor",aboutFlag:"devtools-protocol-monitor",isEnabled:e,requiresChromeRestart:!1,docLink:"https://developer.chrome.com/blog/new-in-devtools-92/#protocol-monitor"});this.#s(g.ExperimentNames.ExperimentName.PROTOCOL_MONITOR,t),g.Runtime.experiments.register(g.ExperimentNames.ExperimentName.INSTRUMENTATION_BREAKPOINTS,"Instrumentation breakpoints"),g.Runtime.experiments.registerHostExperiment({name:g.ExperimentNames.ExperimentName.DURABLE_MESSAGES,title:"Durable Messages",aboutFlag:"devtools-enable-durable-messages",isEnabled:g.Runtime.hostConfig.devToolsEnableDurableMessages?.enabled??!1,requiresChromeRestart:!1}),g.Runtime.experiments.registerHostExperiment({name:g.ExperimentNames.ExperimentName.JPEG_XL,title:"JPEG XL support",aboutFlag:"enable-jxl-image-format",isEnabled:g.Runtime.hostConfig.devToolsJpegXlImageFormat?.enabled??!1,requiresChromeRestart:!0}),g.Runtime.experiments.registerHostExperiment({name:g.ExperimentNames.ExperimentName.PLUS_BUTTON,title:'Show "+" button on the tab strip for adding tools',aboutFlag:"devtools-plus-button",isEnabled:g.Runtime.hostConfig.devToolsPlusButton?.enabled??!1,requiresChromeRestart:!1});let o=g.Runtime.Runtime.queryParam("enabledExperiments");o&&g.Runtime.experiments.setServerEnabledExperiments(o.split(";"));for(let n of g.Runtime.experiments.allConfigurableExperiments())n.isEnabled()?i.userMetrics.experimentEnabledAtLaunch(n.name):i.userMetrics.experimentDisabledAtLaunch(n.name)}async#i(){C.time("Main._createAppUI");let e=S.IsolatedFileSystemManager.IsolatedFileSystemManager.instance();e.addEventListener(S.IsolatedFileSystemManager.Events.FileSystemError,b=>oe.Snackbar.Snackbar.show({message:b.data}));let o=u.Settings.Settings.instance().createSetting("ui-theme","systemPreferred");s.UIUtils.initializeUIUtils(document),O.ThemeSupport.hasInstance()||O.ThemeSupport.instance({forceNew:!0,setting:o}),s.UIUtils.addPlatformClass(document.documentElement),s.UIUtils.installComponentRootStyles(document.body),this.#I(document);let n=!!g.Runtime.Runtime.queryParam("can_dock");s.ZoomManager.ZoomManager.instance({forceNew:!0,win:window,frontendHost:i.InspectorFrontendHost.InspectorFrontendHostInstance}),s.ContextMenu.ContextMenu.initialize(),s.ContextMenu.ContextMenu.installHandler(document),s.ViewManager.ViewManager.instance({forceNew:!0,universe:this.#n}),K.NetworkLog.NetworkLog.instance(),K.LogManager.LogManager.instance(),P.IssuesManager.IssuesManager.instance({forceNew:!0,ensureFirst:!0,showThirdPartyIssuesSetting:P.Issue.getShowThirdPartyIssuesSetting(),hideIssueSetting:P.IssuesManager.getHideIssueByCodeSetting()}),s.DockController.DockController.instance({forceNew:!0,canDock:n}),m.DOMDebuggerModel.DOMDebuggerManager.instance({forceNew:!0});let a=m.TargetManager.TargetManager.instance();a.addEventListener("SuspendStateChanged",this.#S.bind(this)),w.FileManager.FileManager.instance({forceNew:!0}),L.NetworkProject.NetworkProjectManager.instance(),new L.PresentationConsoleMessageHelper.PresentationConsoleMessageManager,a.setScopeTarget(a.primaryPageTarget()),s.Context.Context.instance().addFlavorChangeListener(m.Target.Target,({data:b})=>{let E=b?.outermostTarget();a.setScopeTarget(E)}),te.BreakpointManager.BreakpointManager.instance({forceNew:!0,workspace:w.Workspace.WorkspaceImpl.instance(),targetManager:a,debuggerWorkspaceBinding:L.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),settings:u.Settings.Settings.instance()}),self.Extensions.extensionServer=x.ExtensionServer.ExtensionServer.instance({forceNew:!0}),new S.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding(e,w.Workspace.WorkspaceImpl.instance()),e.addPlatformFileSystem("snippet://",new Ee.ScriptSnippetFileSystem.SnippetFileSystem);let l=S.Persistence.PersistenceImpl.instance({forceNew:!0,workspace:w.Workspace.WorkspaceImpl.instance(),breakpointManager:te.BreakpointManager.BreakpointManager.instance()}),R=new x.PersistenceUtils.LinkDecorator(l);W.Linkifier.Linkifier.setLinkDecorator(R),S.NetworkPersistenceManager.NetworkPersistenceManager.instance({forceNew:!0,workspace:w.Workspace.WorkspaceImpl.instance()}),new U(a,s.Context.Context.instance());let d=Re.ProjectSettingsModel.ProjectSettingsModel.instance({forceNew:!0,hostConfig:g.Runtime.hostConfig,pageResourceLoader:m.PageResourceLoader.PageResourceLoader.instance(),targetManager:a}),M=S.AutomaticFileSystemManager.AutomaticFileSystemManager.instance({forceNew:!0,inspectorFrontendHost:i.InspectorFrontendHost.InspectorFrontendHostInstance,projectSettingsModel:d});S.AutomaticFileSystemWorkspaceBinding.AutomaticFileSystemWorkspaceBinding.instance({forceNew:!0,automaticFileSystemManager:M,isolatedFileSystemManager:e,workspace:w.Workspace.WorkspaceImpl.instance()}),Me.AutofillManager.AutofillManager.instance({forceNew:null,targetManager:a}),Ce.LiveMetrics.instance(),ke.CrUXManager.instance(),Te.BuiltInAi.BuiltInAi.instance().addEventListener("downloadedAndSessionCreated",()=>oe.Snackbar.Snackbar.show({message:h(f.aiModelDownloaded)})),new B;let k=s.ActionRegistry.ActionRegistry.instance({forceNew:!0});s.ShortcutRegistry.ShortcutRegistry.instance({forceNew:!0,actionRegistry:k}),this.#u(),i.GdpClient.isGdpProfilesAvailable()&&(i.GdpClient.GdpClient.instance().getProfile().then(b=>{if(!b)return;let{profile:E,isEligible:z}=b;p.logFunctionCall("gdp-client-initialize",!!E?"has-profile":z?"no-profile-and-eligible":"no-profile-and-not-eligible")}),ee.UserBadges.instance().initialize(),ee.UserBadges.instance().addEventListener("BadgeTriggered",async b=>{we??=await import("./../../panels/common/common.js");let E=new we.BadgeNotification,{badge:z,reason:ge}=b.data;E.present(z,ge)})),g.Runtime.hostConfig.devToolsGeminiRebranding?.enabled&&await x.GeminiRebrandPromoDialog.maybeShow(),C.timeEnd("Main._createAppUI");let T=s.AppProvider.getRegisteredAppProviders()[0];if(!T)throw new Error("Unable to boot DevTools, as the appprovider is missing");await this.#r(await T.loadAppProvider())}async#r(e){C.time("Main._showAppUI");let t=e.createApp();if(s.DockController.DockController.instance().initialize(),O.ThemeSupport.instance().fetchColorsAndApplyHostTheme(),t.presentUI(document),s.ActionRegistry.ActionRegistry.instance().hasAction("elements.toggle-element-search")){let n=s.ActionRegistry.ActionRegistry.instance().getAction("elements.toggle-element-search");i.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(i.InspectorFrontendHostAPI.Events.EnterInspectElementMode,()=>{n.execute()},this)}i.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(i.InspectorFrontendHostAPI.Events.RevealSourceLine,this.#m,this);let o=s.InspectorView.InspectorView.instance();S.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("LocalOverridesRequested",n=>{o.displaySelectOverrideFolderInfobar(n.data)}),await o.createToolbars(),i.InspectorFrontendHost.InspectorFrontendHostInstance.loadCompleted(),s.ARIAUtils.LiveAnnouncer.initializeAnnouncerElements(),s.DockController.DockController.instance().announceDockLocation(),window.setTimeout(this.#d.bind(this),0),C.timeEnd("Main._showAppUI")}async#d(){C.time("Main._initializeTarget");for(let e of u.Runnable.earlyInitializationRunnables())await e().run();await this.#e,i.InspectorFrontendHost.InspectorFrontendHostInstance.readyForTest(),this.#t.resolve(),window.setTimeout(this.#g.bind(this),100),await this.#l(),C.timeEnd("Main._initializeTarget")}async#l(){let e=m.TargetManager.TargetManager.instance().primaryPageTarget(),t=e?.targetInfo()?.url,o=t?u.ParsedURL.ParsedURL.extractOrigin(t):void 0,n="__devtools_ve_inspection_binding__";if(e&&await p.isUnderInspection(o)){let a=e.model(m.RuntimeModel.RuntimeModel);await a?.addBinding({name:n}),a?.addEventListener(m.RuntimeModel.Events.BindingCalled,l=>{l.data.name===n&&(l.data.payload==="true"||l.data.payload==="false"?p.setVeDebuggingEnabled(l.data.payload==="true",R=>{p.setVeDebuggingEnabled(!1),a?.defaultExecutionContext()?.evaluate({expression:`window.inspect(${JSON.stringify(R)})`,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1)}):p.setHighlightedVe(l.data.payload==="null"?null:l.data.payload))})}}async#g(){C.time("Main._lateInitialization"),x.ExtensionServer.ExtensionServer.instance().initializeExtensions(),Promise.all(u.Runnable.lateInitializationRunnables().map(async e=>await(await e()).run())),C.timeEnd("Main._lateInitialization")}readyForTest(){return this.#t.promise}#u(){u.Console.Console.instance().addEventListener("messageAdded",e);function e({data:t}){t.show&&u.Console.Console.instance().show()}}#m(e){let{url:t,lineNumber:o,columnNumber:n}=e.data,a=w.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(t);if(a){u.Revealer.reveal(a.uiLocation(o,n));return}function l(R){let d=R.data;d.url()===t&&(u.Revealer.reveal(d.uiLocation(o,n)),w.Workspace.WorkspaceImpl.instance().removeEventListener(w.Workspace.Events.UISourceCodeAdded,l))}w.Workspace.WorkspaceImpl.instance().addEventListener(w.Workspace.Events.UISourceCodeAdded,l)}#f(e){e.handled||s.ShortcutRegistry.ShortcutRegistry.instance().handleShortcut(e)}#p(e){let t=new CustomEvent("clipboard-"+e.type,{bubbles:!0});t.original=e;let o=e.target&&e.target.ownerDocument,n=o?s.DOMUtilities.deepActiveElement(o):null;n&&n.dispatchEvent(t),t.handled&&e.preventDefault()}#h(e){(e.handled||e.target.classList.contains("popup-glasspane"))&&e.preventDefault()}#I(e){e.addEventListener("keydown",this.#f.bind(this),!1),e.addEventListener("beforecopy",this.#p.bind(this),!0),e.addEventListener("copy",this.#p.bind(this),!1),e.addEventListener("cut",this.#p.bind(this),!1),e.addEventListener("paste",this.#p.bind(this),!1),e.addEventListener("contextmenu",this.#h.bind(this),!0)}#S(){let e=m.TargetManager.TargetManager.instance().allTargetsSuspended();s.InspectorView.InspectorView.instance().onSuspendStateChanged(e)}static instanceForTest=null};C=F;globalThis.Main=globalThis.Main||{};globalThis.Main.Main=F;var ne=class{handleAction(e,t){if(i.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode())return!1;switch(t){case"main.zoom-in":return i.InspectorFrontendHost.InspectorFrontendHostInstance.zoomIn(),!0;case"main.zoom-out":return i.InspectorFrontendHost.InspectorFrontendHostInstance.zoomOut(),!0;case"main.zoom-reset":return i.InspectorFrontendHost.InspectorFrontendHostInstance.resetZoom(),!0}return!1}},se=class{handleAction(e,t){let o=s.SearchableView.SearchableView.fromElement(s.DOMUtilities.deepActiveElement(document));if(!o){let n=s.InspectorView.InspectorView.instance().currentPanelDeprecated();if(n?.searchableView&&(o=n.searchableView()),!o)return!1}switch(t){case"main.search-in-panel.find":return o.handleFindShortcut();case"main.search-in-panel.cancel":return o.handleCancelSearchShortcut();case"main.search-in-panel.find-next":return o.handleFindNextShortcut();case"main.search-in-panel.find-previous":return o.handleFindPreviousShortcut()}return!1}},Y,ie=class c{#t;constructor(){this.#t=new s.Toolbar.ToolbarMenuButton(this.#e.bind(this),!0,!0,"main-menu","dots-vertical"),this.#t.element.classList.add("main-menu"),this.#t.setTitle(h(f.customizeAndControlDevtools))}static instance(e={forceNew:null}){let{forceNew:t}=e;return(!Y||t)&&(Y=new c),Y}item(){return this.#t}#e(e){let t=s.DockController.DockController.instance();if(t.canDock()){let d=document.createElement("div");d.classList.add("flex-auto","flex-centered","location-menu"),d.setAttribute("jslog",`${p.item("dock-side").track({keydown:"ArrowDown|ArrowLeft|ArrowRight"})}`),d.tabIndex=-1,s.ARIAUtils.setLabel(d,f.dockSide+f.dockSideNavigation);let[M]=s.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction("main.toggle-dock");Ke(Be`
        <span class="dockside-title"
              title=${h(f.placementOfDevtoolsRelativeToThe,{PH1:M.title()})}>
          ${h(f.dockSide)}
        </span>
        <devtools-toolbar @mousedown=${v=>v.consume()}>
          <devtools-button class="toolbar-button"
                           jslog=${p.toggle().track({click:!0}).context("current-dock-state-undock")}
                           title=${h(f.undockIntoSeparateWindow)}
                           aria-label=${h(f.undockIntoSeparateWindow)}
                           .iconName=${"dock-window"}
                           .toggled=${t.dockSide()==="undocked"}
                           .toggledIconName=${"dock-window"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"undocked")}></devtools-button>
          <devtools-button class="toolbar-button"
                           jslog=${p.toggle().track({click:!0}).context("current-dock-state-left")}
                           title=${h(f.dockToLeft)}
                           aria-label=${h(f.dockToLeft)}
                           .iconName=${"dock-left"}
                           .toggled=${t.dockSide()==="left"}
                           .toggledIconName=${"dock-left"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"left")}></devtools-button>
          <devtools-button class="toolbar-button"
                           jslog=${p.toggle().track({click:!0}).context("current-dock-state-bottom")}
                           title=${h(f.dockToBottom)}
                           aria-label=${h(f.dockToBottom)}
                           .iconName=${"dock-bottom"}
                           .toggled=${t.dockSide()==="bottom"}
                           .toggledIconName=${"dock-bottom"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"bottom")}></devtools-button>
          <devtools-button class="toolbar-button"
                           jslog=${p.toggle().track({click:!0}).context("current-dock-state-right")}
                           title=${h(f.dockToRight)}
                           aria-label=${h(f.dockToRight)}
                           .iconName=${"dock-right"}
                           .toggled=${t.dockSide()==="right"}
                           .toggledIconName=${"dock-right"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"right")}></devtools-button>
        </devtools-toolbar>
      `,d,{host:this}),d.addEventListener("keydown",v=>{let k=0;if(v.key==="ArrowLeft")k=-1;else if(v.key==="ArrowRight")k=1;else if(v.key==="ArrowDown"){d.closest(".soft-context-menu")?.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowDown"}));return}else return;let T=Array.from(d.querySelectorAll("devtools-button")),b=T.findIndex(E=>E.hasFocus());b=be.NumberUtilities.clamp(b+k,0,T.length-1),T[b].focus(),v.consume(!0)}),e.headerSection().appendCustomItem(d,"dock-side")}let o=this.#t.element;function n(d){t.once("AfterDockSideChanged").then(()=>o.focus()),t.setDockSide(d),e.discard()}if(e.defaultSection().appendAction("freestyler.main-menu",void 0,!0),e.defaultSection().appendItem(h(f.getDevToolsMcp),()=>{De.openInNewTab("https://github.com/ChromeDevTools/chrome-devtools-mcp")},{additionalElement:s.UIUtils.maybeCreateNewBadge("get-devtools-mcp"),jslogContext:"get-devtools-mcp"}),e.defaultSection().appendSeparator(),t.dockSide()==="undocked"){let d=m.TargetManager.TargetManager.instance().primaryPageTarget();d&&d.type()===m.Target.Type.FRAME&&e.defaultSection().appendAction("inspector-main.focus-debuggee",h(f.focusDebuggee))}e.defaultSection().appendAction("main.toggle-drawer",s.InspectorView.InspectorView.instance().drawerVisible()?h(f.hideConsoleDrawer):h(f.showConsoleDrawer)),e.appendItemsAtLocation("mainMenu");let a=e.defaultSection().appendSubMenuItem(h(f.moreTools),!1,"more-tools"),l=s.ViewManager.ViewManager.instance().getRegisteredViewExtensions();l.sort((d,M)=>{let v=d.title(),k=M.title();return v.localeCompare(k)});for(let d of l){let M=d.location(),v=d.persistence(),k=d.title(),T=d.viewId();if(T==="issues-pane"){a.defaultSection().appendItem(k,()=>{i.userMetrics.issuesPanelOpenedFrom(3),s.ViewManager.ViewManager.instance().showView("issues-pane",!0)},{jslogContext:T});continue}v==="closeable"&&(M!=="drawer-view"&&M!=="panel"||a.defaultSection().appendItem(k,()=>{s.ViewManager.ViewManager.instance().showView(T,!0,!1)},{isPreviewFeature:d.isPreviewFeature(),jslogContext:T}))}e.footerSection().appendSubMenuItem(h(f.help),!1,"help").appendItemsAtLocation("mainMenuHelp")}},Q,re=class c{#t;constructor(){this.#t=s.Toolbar.Toolbar.createActionButton("settings.show")}static instance(e={forceNew:null}){let{forceNew:t}=e;return(!Q||t)&&(Q=new c),Q}item(){return this.#t}},B=class{constructor(){m.TargetManager.TargetManager.instance().addModelListener(m.DebuggerModel.DebuggerModel,m.DebuggerModel.Events.DebuggerPaused,this.#t,this)}#t(e){m.TargetManager.TargetManager.instance().removeModelListener(m.DebuggerModel.DebuggerModel,m.DebuggerModel.Events.DebuggerPaused,this.#t,this);let t=e.data,o=t.debuggerPausedDetails();s.Context.Context.instance().setFlavor(m.Target.Target,t.target()),u.Revealer.reveal(o)}};function ze(c,e){return new Promise((t,o)=>{let n=le.InspectorBackend.test.sendRawMessage;if(!n)return o("Unable to send message to test client");n(c,e,(a,...l)=>a?o(a):t(l))})}var ae=class{handleAction(e,t){return t==="main.debug-reload"?(W.Reload.reload(),!0):!1}};var xe={};H(xe,{SimpleApp:()=>_,SimpleAppProvider:()=>de});import*as $ from"./../../ui/legacy/legacy.js";var _=class{presentUI(e){let t=new $.RootView.RootView;$.InspectorView.InspectorView.instance().show(t.element),t.attachToDocument(e),t.focus()}},ce,de=class c{static instance(e={forceNew:null}){let{forceNew:t}=e;return(!ce||t)&&(ce=new c),ce}createApp(){return new _}};export{ue as ExecutionContextSelector,Se as GlobalAiButton,ye as MainImpl,xe as SimpleApp};
//# sourceMappingURL=main.js.map
