From 05367de5e689f448a8474d1d1a8b6f12db52c369 Mon Sep 17 00:00:00 2001 From: Edmond Chui <edmondc@meta.com> Date: Wed, 13 Nov 2024 11:27:38 -0800 Subject: [PATCH] Update debugger-frontend from ff343d8...b61aae3 (#47593) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47593 Changelog: [Internal] - Update `react-native/debugger-frontend` from ff343d8...b61aae3 Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/ff343d805527223750fafb8573ee48f8e2fb0d1e...b61aae3ccc6e2684dfbf1e2a06b0f985b459f11f). Reviewed By: huntie Differential Revision: D65894096 fbshipit-source-id: e2fd4bff7d643fc56abde2ddea0ef5fab91d2b4d --- packages/debugger-frontend/BUILD_INFO | 4 +-- .../front_end/panels/sources/sources.js | 28 +++++++++---------- .../third-party/front_end/ui/legacy/legacy.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/debugger-frontend/BUILD_INFO b/packages/debugger-frontend/BUILD_INFO index 50211110ee2778..25486188863ec7 100644 --- a/packages/debugger-frontend/BUILD_INFO +++ b/packages/debugger-frontend/BUILD_INFO @@ -1,5 +1,5 @@ -@generated SignedSource<<b5e82d2eb99e1ed4c012065a530ca78b>> -Git revision: ff343d805527223750fafb8573ee48f8e2fb0d1e +@generated SignedSource<<6b92b66e59525cef52902139f863f175>> +Git revision: b61aae3ccc6e2684dfbf1e2a06b0f985b459f11f Built with --nohooks: false Is local checkout: false Remote URL: https://github.com/facebookexperimental/rn-chrome-devtools-frontend diff --git a/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js b/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js index 22d6f18bc7f58b..38dbf47936b473 100644 --- a/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js +++ b/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js @@ -1,14 +1,14 @@ -import*as e from"../../core/i18n/i18n.js";import*as t from"../../ui/legacy/legacy.js";import*as i from"../../core/common/common.js";import*as o from"../../core/sdk/sdk.js";import*as n from"../../third_party/codemirror.next/codemirror.next.js";import*as r from"../../ui/components/icon_button/icon_button.js";import*as s from"../../ui/components/text_editor/text_editor.js";import*as a from"../../ui/visual_logging/visual_logging.js";import*as c from"../../core/host/host.js";import*as l from"../../core/platform/platform.js";import{assertNotNullOrUndefined as d}from"../../core/platform/platform.js";import*as u from"../../models/bindings/bindings.js";import*as h from"../../models/persistence/persistence.js";import*as p from"../../models/source_map_scopes/source_map_scopes.js";import*as g from"../../models/text_utils/text_utils.js";import*as m from"../../ui/legacy/components/source_frame/source_frame.js";import*as b from"../coverage/coverage.js";import*as f from"../../models/workspace/workspace.js";import*as S from"../../ui/legacy/components/color_picker/color_picker.js";import*as v from"../../ui/legacy/components/inline_editor/inline_editor.js";import*as C from"../../core/root/root.js";import*as w from"../../models/breakpoints/breakpoints.js";import*as I from"../../models/formatter/formatter.js";import*as y from"../../ui/legacy/components/object_ui/object_ui.js";import*as x from"./components/components.js";import*as k from"../../models/extensions/extensions.js";import*as T from"../snippets/snippets.js";import*as E from"../search/search.js";import*as L from"../../ui/legacy/components/quick_open/quick_open.js";import*as M from"../../models/issues_manager/issues_manager.js";import*as P from"../../ui/components/issue_counter/issue_counter.js";import*as F from"../../ui/legacy/components/utils/utils.js";import{PanelUtils as D}from"../utils/utils.js";import*as N from"../../ui/components/buttons/buttons.js";const A=new CSSStyleSheet;A.replaceSync(':host{padding:10px}.widget{align-items:center}label{white-space:nowrap}input[type="text"].add-source-map{box-shadow:0 0 0 1px var(--box-shadow-outline-color);font-size:inherit;margin:0 8px 0 5px}\n/*# sourceURL=dialog.css */\n');const U={sourceMapUrl:"Source map URL: ",debugInfoUrl:"DWARF symbols URL: ",add:"Add"},R=e.i18n.registerUIStrings("panels/sources/AddSourceMapURLDialog.ts",U),B=e.i18n.getLocalizedString.bind(void 0,R);class j extends t.Widget.HBox{input;dialog;callback;constructor(e,i,o){super(!0),this.contentElement.createChild("label").textContent=e,this.input=t.UIUtils.createInput("add-source-map","text","url"),this.input.addEventListener("keydown",this.onKeyDown.bind(this),!1),this.contentElement.appendChild(this.input);const n=t.UIUtils.createTextButton(B(U.add),this.apply.bind(this),{jslogContext:"add"});this.contentElement.appendChild(n),this.dialog=new t.Dialog.Dialog(i),this.dialog.setSizeBehavior("MeasureContent"),this.dialog.setDefaultFocusedElement(this.input),this.callback=o}static createAddSourceMapURLDialog(e){return new j(B(U.sourceMapUrl),"add-source-map-url",e)}static createAddDWARFSymbolsURLDialog(e){return new j(B(U.debugInfoUrl),"add-debug-info-url",e)}show(){super.show(this.dialog.contentElement),this.dialog.show()}done(e){this.dialog.hide(),this.callback(e)}apply(){this.done(this.input.value)}onKeyDown(e){"Enter"===e.key&&(e.consume(!0),this.apply())}wasShown(){super.wasShown(),this.registerCSSFiles([A])}}var V=Object.freeze({__proto__:null,AddDebugInfoURLDialog:j});const W=new CSSStyleSheet;W.replaceSync(":host{z-index:30;padding:4px;background-color:var(--sys-color-surface3);border-radius:7px;border:2px solid var(--sys-color-divider);width:90%;pointer-events:auto}:host(.sources-edit-breakpoint-dialog){border-radius:0;z-index:30;background-color:var(--sys-color-surface3);width:555px;pointer-events:auto;margin-left:-1px;padding:0 10px 10px 5px;border:1px solid var(--sys-color-divider)}:host-context(.sources-edit-breakpoint-dialog) .condition-editor{background-color:var(--sys-color-cdt-base-container);margin:0 6px 20px 3px}:host-context(.sources-edit-breakpoint-dialog) .source-frame-breakpoint-toolbar{font-family:sans-serif;font-size:12px}:host-context(.sources-edit-breakpoint-dialog) .link,\n.devtools-link{font-family:sans-serif;font-size:12px;margin:0 3px}:host-context(.sources-edit-breakpoint-dialog) devtools-icon.link-icon{vertical-align:sub;margin-right:0.5ch;color:var(--icon-link);width:16px;height:16px}:host-context(.sources-edit-breakpoint-dialog) .link-wrapper{display:inline-flex}:host-context(.sources-edit-breakpoint-dialog) .dialog-header{display:flex;justify-content:space-between;align-items:center}:host-context(.sources-edit-breakpoint-dialog) .dialog-header > devtools-icon:hover{color:var(--icon-default-hover)}\n/*# sourceURL=breakpointEditDialog.css */\n");const{Direction:O}=s.TextEditorHistory,H={breakpointType:"Breakpoint type",breakpoint:"Breakpoint",closeDialog:"Close edit dialog and save changes",conditionalBreakpoint:"Conditional breakpoint",logpoint:"Logpoint",expressionToCheckBeforePausingEg:"Expression to check before pausing, e.g. x > 5",pauseOnlyWhenTheConditionIsTrue:"Pause only when the condition is true",learnMoreOnBreakpointTypes:"Learn more: Breakpoint Types",logMessageEgXIsX:"Log message, e.g. `'x is', x`",logAMessageToConsoleDoNotBreak:"Log a message to Console, do not break"},_=e.i18n.registerUIStrings("panels/sources/BreakpointEditDialog.ts",H),z=e.i18n.getLocalizedString.bind(void 0,_);class q extends t.Widget.Widget{onFinish;finished;editor;typeSelector;placeholderCompartment;#e;#t;constructor(e,o,c,l){super(!0);const d=[n.javascript.javascriptLanguage,s.Config.baseConfiguration(o||""),s.Config.closeBrackets,s.Config.autocompletion.instance(),n.EditorView.lineWrapping,s.Config.showCompletionHint,s.Config.conservativeCompletion,n.javascript.javascriptLanguage.data.of({autocomplete:e=>this.#t.historyCompletions(e)}),n.autocompletion(),s.JavaScript.argumentHints()];this.onFinish=l,this.finished=!1,this.element.tabIndex=-1,this.element.classList.add("sources-edit-breakpoint-dialog"),this.element.setAttribute("jslog",`${a.dialog("edit-breakpoint")}`);const u=this.contentElement.createChild("div","dialog-header"),h=new t.Toolbar.Toolbar("source-frame-breakpoint-toolbar",u);h.appendText(`Line ${e+1}:`),this.typeSelector=new t.Toolbar.ToolbarComboBox(this.onTypeChanged.bind(this),z(H.breakpointType),void 0,"type"),this.typeSelector.createOption(z(H.breakpoint),"REGULAR_BREAKPOINT");const p=this.typeSelector.createOption(z(H.conditionalBreakpoint),"CONDITIONAL_BREAKPOINT"),g=this.typeSelector.createOption(z(H.logpoint),"LOGPOINT");this.typeSelector.select(c?g:p),h.appendToolbarItem(this.typeSelector);const m=o||"",b=e=>(s.JavaScript.isExpressionComplete(e.state.doc.toString()).then((t=>{t?this.finishEditing(!0,this.editor.state.doc.toString()):n.insertNewlineAndIndent(e)})),!0),f=[{key:"ArrowUp",run:()=>this.#t.moveHistory(-1)},{key:"ArrowDown",run:()=>this.#t.moveHistory(1)},{mac:"Ctrl-p",run:()=>this.#t.moveHistory(-1,!0)},{mac:"Ctrl-n",run:()=>this.#t.moveHistory(1,!0)},{key:"Mod-Enter",run:b},{key:"Enter",run:b},{key:"Shift-Enter",run:n.insertNewlineAndIndent},{key:"Escape",run:()=>(this.finishEditing(!1,""),!0)}];this.placeholderCompartment=new n.Compartment;const S=this.contentElement.appendChild(document.createElement("div"));S.classList.add("condition-editor"),S.setAttribute("jslog",`${a.textField()}`),this.editor=new s.TextEditor.TextEditor(n.EditorState.create({doc:m,selection:{anchor:0,head:m.length},extensions:[this.placeholderCompartment.of(this.getPlaceholder()),n.keymap.of(f),d]})),S.appendChild(this.editor);const v=new r.Icon.Icon;v.name="cross",v.title=z(H.closeDialog),v.setAttribute("jslog",`${a.close().track({click:!0})}`),v.onclick=()=>this.finishEditing(!0,this.editor.state.doc.toString()),u.appendChild(v),this.#e=new s.AutocompleteHistory.AutocompleteHistory(i.Settings.Settings.instance().createLocalSetting("breakpoint-condition-history",[])),this.#t=new s.TextEditorHistory.TextEditorHistory(this.editor,this.#e);const C=this.contentElement.appendChild(document.createElement("div"));C.classList.add("link-wrapper");const w=t.Fragment.html`<x-link class="link devtools-link" tabindex="0" href="https://goo.gle/devtools-loc" - jslog="${a.link("learn-more")}">${z(H.learnMoreOnBreakpointTypes)}</x-link>`,I=new r.Icon.Icon;I.name="open-externally",I.classList.add("link-icon"),w.prepend(I),C.appendChild(w),this.updateTooltip()}saveAndFinish(){this.finishEditing(!0,this.editor.state.doc.toString())}focusEditor(){this.editor.editor.focus()}onTypeChanged(){"REGULAR_BREAKPOINT"!==this.breakpointType?(this.focusEditor(),this.editor.dispatch({effects:this.placeholderCompartment.reconfigure(this.getPlaceholder())}),this.updateTooltip()):this.finishEditing(!0,"")}get breakpointType(){const e=this.typeSelector.selectedOption();return e?e.value:null}getPlaceholder(){const e=this.breakpointType;return"CONDITIONAL_BREAKPOINT"===e?n.placeholder(z(H.expressionToCheckBeforePausingEg)):"LOGPOINT"===e?n.placeholder(z(H.logMessageEgXIsX)):[]}updateTooltip(){const e=this.breakpointType;"CONDITIONAL_BREAKPOINT"===e?t.Tooltip.Tooltip.install(this.typeSelector.element,z(H.pauseOnlyWhenTheConditionIsTrue)):"LOGPOINT"===e&&t.Tooltip.Tooltip.install(this.typeSelector.element,z(H.logAMessageToConsoleDoNotBreak))}finishEditing(e,t){if(this.finished)return;this.finished=!0,this.editor.remove(),this.#e.pushHistoryItem(t);const i="LOGPOINT"===this.breakpointType;this.onFinish({committed:e,condition:t,isLogpoint:i})}wasShown(){super.wasShown(),this.registerCSSFiles([W])}get editorForTest(){return this.editor}}var $=Object.freeze({__proto__:null,BreakpointEditDialog:q});const G=new CSSStyleSheet;G.replaceSync('.call-frame-warnings-message{text-align:center;font-style:italic;padding:4px;color:var(--sys-color-on-surface-yellow);background-color:var(--sys-color-surface-yellow)}.ignore-listed-message{padding:1px}.ignore-listed-message-label{color:var(--sys-color-token-subtle);align-items:center;display:flex}.show-more-message > .link{margin-left:5px}.show-more-message{text-align:center;font-style:italic;padding:4px;border-top:1px solid var(--sys-color-divider)}.call-frame-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.call-frame-title-text{text-overflow:ellipsis;overflow:hidden}.async-header + .call-frame-item{border-top:0}.call-frame-item:not(.async-header){border-top:1px solid var(--sys-color-divider)}.call-frame-item-title,\n.call-frame-location{display:flex;white-space:nowrap}.async-header .call-frame-item-title{font-weight:bold;color:var(--sys-color-on-surface);background-color:var(--sys-color-cdt-base-container);margin-left:-5px;padding:0 5px;z-index:1}.call-frame-item:focus-visible,\n.call-frame-item.async-header:focus-visible .call-frame-item-title{background-color:var(--sys-color-tonal-container)}.ignore-listed-checkbox:focus-visible{outline-width:unset}.call-frame-item:not(.async-header):hover{background-color:var(--sys-color-state-hover-on-subtle)}.call-frame-location{color:var(--sys-color-token-subtle);margin-left:auto;padding:0 10px}.async-header::before{content:" ";width:100%;border-top:1px solid var(--sys-color-divider);margin-top:8px;position:absolute;left:0}.ignore-listed-call-frame{opacity:60%;font-style:italic}.selected-call-frame-icon{display:none;position:absolute;top:3px;left:4px}.call-frame-item.selected .selected-call-frame-icon{display:block}.call-frame-warning-icon{display:block;position:absolute;top:3px;right:4px}@media (forced-colors: active){.call-frame-item:focus-visible,\n .call-frame-item:not(.async-header):hover{forced-color-adjust:none;background-color:Highlight}.call-frame-item:focus-visible *,\n .call-frame-item:not(.async-header):hover *{color:HighlightText}}\n/*# sourceURL=callStackSidebarPane.css */\n');const K={callStack:"Call Stack",notPaused:"Not paused",onIgnoreList:"on ignore list",showIgnorelistedFrames:"Show ignore-listed frames",showMore:"Show more",copyStackTrace:"Copy stack trace",callFrameWarnings:"Some call frames have warnings",debugFileNotFound:'Failed to load debug file "{PH1}".',restartFrame:"Restart frame"},J=e.i18n.registerUIStrings("panels/sources/CallStackSidebarPane.ts",K),X=e.i18n.getLocalizedString.bind(void 0,J);let Y;class Q extends t.View.SimpleView{ignoreListMessageElement;ignoreListCheckboxElement;notPausedMessageElement;callFrameWarningsElement;items;list;showMoreMessageElement;showIgnoreListed;locationPool;updateThrottler;maxAsyncStackChainDepth;updateItemThrottler;scheduledForUpdateItems;muteActivateItem;lastDebuggerModel=null;constructor(){super(X(K.callStack),!0,"sources.callstack"),this.contentElement.setAttribute("jslog",`${a.section("sources.callstack")}`),({element:this.ignoreListMessageElement,checkbox:this.ignoreListCheckboxElement}=this.createIgnoreListMessageElementAndCheckbox()),this.contentElement.appendChild(this.ignoreListMessageElement),this.notPausedMessageElement=this.contentElement.createChild("div","gray-info-message"),this.notPausedMessageElement.textContent=X(K.notPaused),this.notPausedMessageElement.tabIndex=-1,this.callFrameWarningsElement=this.contentElement.createChild("div","call-frame-warnings-message");const e=new r.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("call-frame-warning-icon"),this.callFrameWarningsElement.appendChild(e),this.callFrameWarningsElement.appendChild(document.createTextNode(X(K.callFrameWarnings))),this.callFrameWarningsElement.tabIndex=-1,this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport),this.contentElement.appendChild(this.list.element),this.list.element.addEventListener("contextmenu",this.onContextMenu.bind(this),!1),self.onInvokeElement(this.list.element,(e=>{const t=this.list.itemForNode(e.target);t&&(this.activateItem(t),e.consume(!0))})),this.showMoreMessageElement=this.createShowMoreMessageElement(),this.showMoreMessageElement.classList.add("hidden"),this.contentElement.appendChild(this.showMoreMessageElement),this.showIgnoreListed=!1,this.locationPool=new u.LiveLocation.LiveLocationPool,this.updateThrottler=new i.Throttler.Throttler(100),this.maxAsyncStackChainDepth=te,this.update(),this.updateItemThrottler=new i.Throttler.Throttler(100),this.scheduledForUpdateItems=new Set,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this)}static instance(e={forceNew:null}){const{forceNew:t}=e;return Y&&!t||(Y=new Q),Y}flavorChanged(e){this.showIgnoreListed=!1,this.ignoreListCheckboxElement.checked=!1,this.maxAsyncStackChainDepth=te,this.update()}debugInfoAttached(){this.update()}setSourceMapSubscription(e){this.lastDebuggerModel!==e&&(this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this),this.lastDebuggerModel=e,this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this))}update(){this.updateThrottler.schedule((()=>this.doUpdate()))}async doUpdate(){this.locationPool.disposeAll(),this.callFrameWarningsElement.classList.add("hidden");const e=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.setSourceMapSubscription(e?.debuggerModel??null),!e)return this.notPausedMessageElement.classList.remove("hidden"),this.ignoreListMessageElement.classList.add("hidden"),this.showMoreMessageElement.classList.add("hidden"),this.items.replaceAll([]),void t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,null);this.notPausedMessageElement.classList.add("hidden");const i=[],n=new Set;for(const t of e.callFrames){const e=ie.createForDebuggerCallFrame(t,this.locationPool,this.refreshItem.bind(this)).then((e=>(Z.set(e,t),e)));i.push(e),t.missingDebugInfoDetails&&n.add(t.missingDebugInfoDetails.details)}const r=await Promise.all(i);n.size&&(this.callFrameWarningsElement.classList.remove("hidden"),t.Tooltip.Tooltip.install(this.callFrameWarningsElement,Array.from(n).join("\n")));let s=e.debuggerModel,a=e.asyncStackTraceId,c=e.asyncStackTrace,l=e.callFrames;for(let{maxAsyncStackChainDepth:e}=this;e>0;--e){if(!c){if(!a)break;if(a.debuggerId){const e=await o.DebuggerModel.DebuggerModel.modelForDebuggerId(a.debuggerId);if(!e)break;s=e}if(c=await s.fetchAsyncStackTrace(a),!c)break}const e=t.UIUtils.asyncStackTraceLabel(c.description,l);r.push(...await ie.createItemsForAsyncStack(e,s,c.callFrames,this.locationPool,this.refreshItem.bind(this))),l=c.callFrames,a=c.parentId,c=c.parent}this.showMoreMessageElement.classList.toggle("hidden",!c),this.items.replaceAll(r);for(const e of this.items)this.refreshItem(e);if(this.maxAsyncStackChainDepth===te){this.list.selectNextItem(!0,!1);const e=this.list.selectedItem();e&&this.activateItem(e)}this.updatedForTest()}updatedForTest(){}refreshItem(e){this.scheduledForUpdateItems.add(e),this.updateItemThrottler.schedule((async()=>{const e=Array.from(this.scheduledForUpdateItems);if(this.scheduledForUpdateItems.clear(),this.muteActivateItem=!0,!this.showIgnoreListed&&this.items.every((e=>e.isIgnoreListed))){this.showIgnoreListed=!0;for(let e=0;e<this.items.length;++e)this.list.refreshItemByIndex(e);this.ignoreListMessageElement.classList.toggle("hidden",!0)}else{this.showIgnoreListed=this.ignoreListCheckboxElement.checked;const t=new Set(e);let i=!1;for(let e=0;e<this.items.length;++e){const o=this.items.at(e);t.has(o)&&this.list.refreshItemByIndex(e),i=i||o.isIgnoreListed}this.ignoreListMessageElement.classList.toggle("hidden",!i)}delete this.muteActivateItem}))}createElementForItem(e){const i=document.createElement("div");i.classList.add("call-frame-item");const n=i.createChild("div","call-frame-item-title").createChild("div","call-frame-title-text");if(n.textContent=e.title,e.isAsyncHeader)i.classList.add("async-header");else{t.Tooltip.Tooltip.install(n,e.title);const o=i.createChild("div","call-frame-location");o.textContent=l.StringUtilities.trimMiddle(e.linkText,30),t.Tooltip.Tooltip.install(o,e.linkText),i.classList.toggle("ignore-listed-call-frame",e.isIgnoreListed),e.isIgnoreListed&&t.ARIAUtils.setDescription(i,X(K.onIgnoreList)),Z.has(e)||t.ARIAUtils.setDisabled(i,!0)}const s=Z.get(e),a=s===t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);i.classList.toggle("selected",a),t.ARIAUtils.setSelected(i,a),i.classList.toggle("hidden",!this.showIgnoreListed&&e.isIgnoreListed);const c=new r.Icon.Icon;if(c.data={iconName:"large-arrow-right-filled",color:"var(--icon-arrow-main-thread)",width:"14px",height:"14px"},c.classList.add("selected-call-frame-icon"),i.appendChild(c),i.tabIndex=e===this.list.selectedItem()?0:-1,s&&s.missingDebugInfoDetails){const e=new r.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("call-frame-warning-icon");const o=s.missingDebugInfoDetails.resources.map((e=>X(K.debugFileNotFound,{PH1:e})));t.Tooltip.Tooltip.install(e,[s.missingDebugInfoDetails.details,...o].join("\n")),i.appendChild(e)}return i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1),o&&(this.setDefaultFocusedElement(o),o.tabIndex=0,this.hasFocus()&&o.focus())}updateSelectedItemARIA(e,t){return!0}createIgnoreListMessageElementAndCheckbox(){const e=document.createElement("div");e.classList.add("ignore-listed-message");const t=e.createChild("label");t.classList.add("ignore-listed-message-label");const i=t.createChild("input");i.tabIndex=0,i.type="checkbox",i.classList.add("ignore-listed-checkbox"),t.append(X(K.showIgnorelistedFrames));return i.addEventListener("click",(()=>{this.showIgnoreListed=i.checked;for(const e of this.items)this.refreshItem(e)})),{element:e,checkbox:i}}createShowMoreMessageElement(){const e=document.createElement("div");e.classList.add("show-more-message"),e.createChild("span");const t=e.createChild("span","link");return t.textContent=X(K.showMore),t.addEventListener("click",(()=>{this.maxAsyncStackChainDepth+=te,this.update()}),!1),e}onContextMenu(e){const i=this.list.itemForNode(e.target);if(!i)return;const o=new t.ContextMenu.ContextMenu(e),n=Z.get(i);n&&o.defaultSection().appendItem(X(K.restartFrame),(()=>{c.userMetrics.actionTaken(c.UserMetrics.Action.StackFrameRestarted),n.restart()}),{disabled:!n.canBeRestarted,jslogContext:"restart-frame"}),o.defaultSection().appendItem(X(K.copyStackTrace),this.copyStackTrace.bind(this),{jslogContext:"copy-stack-trace"}),i.uiLocation&&this.appendIgnoreListURLContextMenuItems(o,i.uiLocation.uiSourceCode),o.show()}onClick(e){const t=this.list.itemForNode(e.target);t&&this.activateItem(t)}activateItem(e){const n=e.uiLocation;if(this.muteActivateItem||!n)return;this.list.selectItem(e);const r=Z.get(e),s=this.activeCallFrameItem();r&&s!==e?(r.debuggerModel.setSelectedCallFrame(r),t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,r),s&&this.refreshItem(s),this.refreshItem(e)):i.Revealer.reveal(n)}activeCallFrameItem(){const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);return e&&this.items.find((t=>Z.get(t)===e))||null}appendIgnoreListURLContextMenuItems(e,t){const i=h.Persistence.PersistenceImpl.instance().binding(t);i&&(t=i.network);const o=e.section("ignoreList");if(!(o.items.length>0))for(const{text:e,callback:i,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListURLContextMenuItems(t))o.appendItem(e,i,{jslogContext:n})}selectNextCallFrameOnStack(){const e=this.activeCallFrameItem();for(let t=e?this.items.indexOf(e)+1:0;t<this.items.length;t++){const e=this.items.at(t);if(Z.has(e)){this.activateItem(e);break}}}selectPreviousCallFrameOnStack(){const e=this.activeCallFrameItem();for(let t=e?this.items.indexOf(e)-1:this.items.length-1;t>=0;t--){const e=this.items.at(t);if(Z.has(e)){this.activateItem(e);break}}}copyStackTrace(){const e=[];for(const t of this.items){let i=t.title;t.uiLocation&&(i+=" ("+t.uiLocation.linkText(!0)+")"),e.push(i)}c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.join("\n"))}wasShown(){super.wasShown(),this.registerCSSFiles([G])}}const Z=new WeakMap,ee=Symbol("element"),te=32;class ie{isIgnoreListed;title;linkText;uiLocation;isAsyncHeader;updateDelegate;static async createForDebuggerCallFrame(e,i,o){const n=e.functionName,r=new ie(t.UIUtils.beautifyFunctionName(n),o);return await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),r.update.bind(r),i),p.NamesResolver.resolveDebuggerFrameFunctionName(e).then((e=>{e&&e!==n&&(r.title=e,r.updateDelegate(r))})),r}static async createItemsForAsyncStack(e,i,o,n,r){const s=new WeakMap,a=new ie(e,r);s.set(a,new Set),a.isAsyncHeader=!0;const c=[],l=[];for(const e of o){const o=new ie(t.UIUtils.beautifyFunctionName(e.functionName),d),r=i.createRawLocationByScriptId(e.scriptId,e.lineNumber,e.columnNumber);l.push(u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(r,o.update.bind(o),n)),c.push(o)}return await Promise.all(l),r(a),[a,...c];function d(e){r(e);let t=!1;const i=s.get(a);i&&(e.isIgnoreListed?(i.delete(e),t=0===i.size):(t=0===i.size,i.add(e)),a.isIgnoreListed=0===i.size),t&&r(a)}}constructor(e,t){this.isIgnoreListed=!1,this.title=e,this.linkText="",this.uiLocation=null,this.isAsyncHeader=!1,this.updateDelegate=t}async update(e){const t=await e.uiLocation();this.isIgnoreListed=await e.isIgnoreListed(),this.linkText=t?t.linkText():"",this.uiLocation=t,this.updateDelegate(this)}}var oe=Object.freeze({__proto__:null,CallStackSidebarPane:Q,elementSymbol:ee,defaultMaxAsyncStackChainDepth:te,ActionDelegate:class{handleAction(e,t){switch(t){case"debugger.next-call-frame":return Q.instance().selectNextCallFrameOnStack(),!0;case"debugger.previous-call-frame":return Q.instance().selectPreviousCallFrameOnStack(),!0}return!1}},Item:ie});const ne={beforeBidderWorkletBiddingStart:"Bidder Bidding Phase Start",beforeBidderWorkletReportingStart:"Bidder Reporting Phase Start",beforeSellerWorkletScoringStart:"Seller Scoring Phase Start",beforeSellerWorkletReportingStart:"Seller Reporting Phase Start",setTimeoutOrIntervalFired:"{PH1} fired",scriptFirstStatement:"Script First Statement",scriptBlockedByContentSecurity:"Script Blocked by Content Security Policy",requestAnimationFrame:"Request Animation Frame",cancelAnimationFrame:"Cancel Animation Frame",animationFrameFired:"Animation Frame Fired",webglErrorFired:"WebGL Error Fired",webglWarningFired:"WebGL Warning Fired",setInnerhtml:"Set `innerHTML`",createCanvasContext:"Create canvas context",createAudiocontext:"Create `AudioContext`",closeAudiocontext:"Close `AudioContext`",resumeAudiocontext:"Resume `AudioContext`",suspendAudiocontext:"Suspend `AudioContext`",sinkViolations:"Sink Violations",policyViolations:"Policy Violations"},re=e.i18n.registerUIStrings("panels/sources/CategorizedBreakpointL10n.ts",ne),se=e.i18n.getLazilyComputedLocalizedString.bind(void 0,re);function ae(t){return(de.get(t)??e.i18n.lockedLazyString(t))()}const ce={beforeBidderWorkletBiddingStart:se(ne.beforeBidderWorkletBiddingStart),beforeBidderWorkletReportingStart:se(ne.beforeBidderWorkletReportingStart),beforeSellerWorkletScoringStart:se(ne.beforeSellerWorkletScoringStart),beforeSellerWorkletReportingStart:se(ne.beforeSellerWorkletReportingStart),setTimeout:e.i18n.lockedLazyString("setTimeout"),clearTimeout:e.i18n.lockedLazyString("clearTimeout"),setInterval:e.i18n.lockedLazyString("setInterval"),clearInterval:e.i18n.lockedLazyString("clearInterval"),"setTimeout.callback":se(ne.setTimeoutOrIntervalFired,{PH1:"setTimeout"}),"setInterval.callback":se(ne.setTimeoutOrIntervalFired,{PH1:"setInterval"}),scriptFirstStatement:se(ne.scriptFirstStatement),scriptBlockedByCSP:se(ne.scriptBlockedByContentSecurity),sharedStorageWorkletScriptFirstStatement:se(ne.scriptFirstStatement),requestAnimationFrame:se(ne.requestAnimationFrame),cancelAnimationFrame:se(ne.cancelAnimationFrame),"requestAnimationFrame.callback":se(ne.animationFrameFired),webglErrorFired:se(ne.webglErrorFired),webglWarningFired:se(ne.webglWarningFired),"Element.setInnerHTML":se(ne.setInnerhtml),canvasContextCreated:se(ne.createCanvasContext),"Geolocation.getCurrentPosition":e.i18n.lockedLazyString("getCurrentPosition"),"Geolocation.watchPosition":e.i18n.lockedLazyString("watchPosition"),"Notification.requestPermission":e.i18n.lockedLazyString("requestPermission"),"DOMWindow.close":e.i18n.lockedLazyString("window.close"),"Document.write":e.i18n.lockedLazyString("document.write"),audioContextCreated:se(ne.createAudiocontext),audioContextClosed:se(ne.closeAudiocontext),audioContextResumed:se(ne.resumeAudiocontext),audioContextSuspended:se(ne.suspendAudiocontext)},le={"trustedtype-policy-violation":se(ne.policyViolations),"trustedtype-sink-violation":se(ne.sinkViolations)},de=new Map([...Object.entries(ce),...Object.entries(le)]);var ue=Object.freeze({__proto__:null,getLocalizedBreakpointName:ae});class he{uiSourceCode;constructor(e,t){this.uiSourceCode=e}static accepts(e){return!1}willHide(){}rightToolbarItems(){return[]}leftToolbarItems(){return[]}populateLineGutterContextMenu(e,t){}populateTextAreaContextMenu(e,t,i){}decorationChanged(e,t){}editorExtension(){return[]}editorInitialized(e){}dispose(){}}var pe=Object.freeze({__proto__:null,Plugin:he});const ge={clickToShowCoveragePanel:"Click to show Coverage Panel",showDetails:"Show Details",coverageS:"Coverage: {PH1}",coverageNa:"Coverage: n/a"},me=e.i18n.registerUIStrings("panels/sources/CoveragePlugin.ts",ge),be=e.i18n.getLocalizedString.bind(void 0,me);class fe extends he{originalSourceCode;infoInToolbar;model;coverage;#i;constructor(e,i){super(e),this.originalSourceCode=this.uiSourceCode,this.#i=i,this.infoInToolbar=new t.Toolbar.ToolbarButton(be(ge.clickToShowCoveragePanel),void 0,void 0,"debugger.show-coverage"),this.infoInToolbar.setSecondary(),this.infoInToolbar.addEventListener("Click",(()=>{t.ViewManager.ViewManager.instance().showView("coverage")}));const n=o.TargetManager.TargetManager.instance().primaryPageTarget();n&&(this.model=n.model(b.CoverageModel.CoverageModel),this.model&&(this.model.addEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this),this.coverage=this.model.getCoverageForUrl(this.originalSourceCode.url()),this.coverage&&this.coverage.addEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this))),this.updateStats()}dispose(){this.coverage&&this.coverage.removeEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this),this.model&&this.model.removeEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this)}static accepts(e){return e.contentType().isDocumentOrScriptOrStyleSheet()}handleReset(){this.coverage=null,this.updateStats()}handleCoverageSizesChanged(){this.updateStats()}updateStats(){if(this.coverage){this.infoInToolbar.setTitle(be(ge.showDetails));const t=new Intl.NumberFormat(e.DevToolsLocale.DevToolsLocale.instance().locale,{style:"percent",maximumFractionDigits:1});this.infoInToolbar.setText(be(ge.coverageS,{PH1:t.format(this.coverage.usedPercentage())}))}else this.infoInToolbar.setTitle(be(ge.clickToShowCoveragePanel)),this.infoInToolbar.setText(be(ge.coverageNa))}rightToolbarItems(){return[this.infoInToolbar]}editorExtension(){return ye.of([])}getCoverageManager(){return this.uiSourceCode.getDecorationData("coverage")}editorInitialized(e){this.getCoverageManager()&&this.startDecoUpdate(e)}decorationChanged(e,t){"coverage"===e&&this.startDecoUpdate(t)}startDecoUpdate(e){const i=this.getCoverageManager();(i?i.usageByLine(this.uiSourceCode,this.#o(e)):Promise.resolve([])).then((i=>{const o=Boolean(e.state.field(Ie,!1));var r;i.length?o?e.dispatch({effects:we.of(i)}):e.dispatch({effects:ye.reconfigure([Ie.init((e=>Ce(i,e))),(r=this.uiSourceCode.url(),n.gutter({markers:e=>e.state.field(Ie),domEventHandlers:{click:()=>(t.ViewManager.ViewManager.instance().showView("coverage").then((()=>{const e=t.ViewManager.ViewManager.instance().view("coverage");return e&&e.widget()})).then((e=>{const t=r.match(/(.*):formatted$/),i=t&&t[1]||r;e.selectCoverageItemByUrl(i)})),!0)},class:"cm-coverageGutter"})),xe])}):o&&e.dispatch({effects:ye.reconfigure([])})}))}#o(e){const t=[];for(let i=1;i<=e.state.doc.lines;++i){const o=e.state.doc.line(i),{lineNumber:n,columnNumber:r}=this.#i.editorLocationToUILocation(i-1,0),{lineNumber:s,columnNumber:a}=this.#i.editorLocationToUILocation(i-1,o.length);t.push(new g.TextRange.TextRange(n,r,s,a))}return t}}const Se=new class extends n.GutterMarker{elementClass="cm-coverageUsed"},ve=new class extends n.GutterMarker{elementClass="cm-coverageUnused"};function Ce(e,t){const i=new n.RangeSetBuilder;for(let o=0;o<e.length;o++){const n=e[o];if(void 0!==n&&o<t.doc.lines){const e=t.doc.line(o+1).from;i.add(e,e,n?Se:ve)}}return i.finish()}const we=n.StateEffect.define(),Ie=n.StateField.define({create:()=>n.RangeSet.empty,update:(e,t)=>t.effects.reduce(((e,i)=>i.is(we)?Ce(i.value,t.state):e),e.map(t.changes))});const ye=new n.Compartment,xe=n.EditorView.baseTheme({".cm-coverageGutter":{width:"5px",marginLeft:"3px"},".cm-coverageUnused":{backgroundColor:"var(--app-color-coverage-unused)"},".cm-coverageUsed":{backgroundColor:"var(--app-color-coverage-used)"}});var ke=Object.freeze({__proto__:null,CoveragePlugin:fe});const Te={openColorPicker:"Open color picker.",openCubicBezierEditor:"Open cubic bezier editor.",addSourceMap:"Add source map…"},Ee=e.i18n.registerUIStrings("panels/sources/CSSPlugin.ts",Te),Le=e.i18n.getLocalizedString.bind(void 0,Ee),Me=new Set(["ColorLiteral","NumberLiteral","StringLiteral","Comment","Important"]);async function Pe(e,t,i){const r=n.syntaxTree(e.state).resolveInner(e.pos,-1);if("ClassName"===r.name){d(i);const e=function(e,t){const i=t.getStyleSheetIdsForURL(e);if(0===i.length)throw new Error("Can't find style sheet ID for current URL");return i[0]}(t.url(),i),o=await i.getClassNames(e);return{from:r.from,options:o.map((e=>({type:"constant",label:e})))}}const s=function(e,t){if(Me.has(e.name))return null;for(let i=e;i&&"StyleSheet"!==i.name&&"Styles"!==i.name&&"CallExpression"!==i.name;i=i.parent)if("Declaration"===i.name){const e=i.getChild("PropertyName"),o=i.getChild(":");return e&&o&&o.to<=t?e:null}return null}(r,e.pos);if(s){const t=o.CSSMetadata.cssMetadata().getPropertyValues(e.state.sliceDoc(s.from,s.to));return{from:"ValueName"===r.name?r.from:e.pos,options:t.map((e=>({type:"constant",label:e}))),validFor:/^[\w\P{ASCII}\-]+$/u}}return null}class Fe extends n.WidgetType{#n;#r;#s;constructor(e,t,i){super(),this.#r=e,this.#n=t,this.#s=i}eq(e){return this.#r.equal(e.#r)&&this.#n===e.#n&&this.#s===e.#s}toDOM(e){const t=new v.ColorSwatch.ColorSwatch;t.renderColor(this.#r,!1,Le(Te.openColorPicker));const i=t.createChild("span");return i.textContent=this.#n,i.setAttribute("hidden","true"),t.addEventListener(v.ColorSwatch.ColorChangedEvent.eventName,(i=>{e.dispatch({changes:{from:this.#s,to:this.#s+this.#n.length,insert:i.data.text}}),this.#n=i.data.text,this.#r=t.getColor()})),t.addEventListener(v.ColorSwatch.ClickEvent.eventName,(i=>{i.consume(!0),e.dispatch({effects:Ne.of({type:0,pos:e.posAtDOM(t),text:this.#n,swatch:t,color:this.#r})})})),t}ignoreEvent(){return!0}}class De extends n.WidgetType{curve;text;constructor(e,t){super(),this.curve=e,this.text=t}eq(e){return this.curve.asCSSText()===e.curve.asCSSText()&&this.text===e.text}toDOM(e){const i=v.Swatches.BezierSwatch.create();return i.setBezierText(this.text),t.Tooltip.Tooltip.install(i.iconElement(),Le(Te.openCubicBezierEditor)),i.iconElement().addEventListener("click",(t=>{t.consume(!0),e.dispatch({effects:Ne.of({type:1,pos:e.posAtDOM(i),text:this.text,swatch:i,curve:this.curve})})}),!1),i.hideText(!0),i}ignoreEvent(){return!0}}const Ne=n.StateEffect.define(),Ae=n.Annotation.define(),Ue=n.StateField.define({create:()=>null,update(e,t){!t.docChanged&&!t.selection||t.annotation(Ae)||(e=null);for(const i of t.effects)i.is(Ne)&&(e=i.value);return e},provide:e=>n.showTooltip.from(e,(e=>e&&function(e){return{pos:e.pos,arrow:!0,create(t){let i,o,n=e.text;if(0===e.type){const n=new S.Spectrum.Spectrum;o=e=>{n.addEventListener("ColorChanged",e)},n.addEventListener("SizeChanged",(()=>t.requestMeasure())),n.setColor(e.color,e.color.format()),i=n,c.userMetrics.colorPickerOpenedFrom(0)}else{const t=new v.BezierEditor.BezierEditor(e.curve);i=t,o=e=>{t.addEventListener("BezierChanged",e)}}const r=document.createElement("div");return r.className="cm-tooltip-swatchEdit",i.markAsRoot(),i.show(r),i.showWidget(),i.element.addEventListener("keydown",(o=>{"Escape"===o.key&&(o.consume(),t.dispatch({effects:Ne.of(null),changes:n===e.text?void 0:{from:e.pos,to:e.pos+n.length,insert:e.text}}),i.hideWidget(),t.focus())})),i.element.addEventListener("focusout",(e=>{e.relatedTarget&&!i.element.contains(e.relatedTarget)&&(t.dispatch({effects:Ne.of(null)}),i.hideWidget())}),!1),i.element.addEventListener("mousedown",(e=>e.consume())),{dom:r,resize:!1,offset:{x:-8,y:0},mount:()=>{i.focus(),i.wasShown(),o((i=>{t.dispatch({changes:{from:e.pos,to:e.pos+n.length,insert:i.data},annotations:Ae.of(!0)}),n=i.data}))}}}}}(e)))});function Re(e,o,r){const s=new n.RangeSetBuilder;return function(e,o,r,s,a){let c=e.doc.lineAt(o);function l(t,i){return t>=c.to&&(c=e.doc.lineAt(t)),c.text.slice(t-c.from,i-c.from)}const d=n.ensureSyntaxTree(e,r,100);d&&d.iterate({from:o,to:r,enter:o=>{let n;if("ValueName"===o.name||"ColorLiteral"===o.name?n=l(o.from,o.to):"Callee"===o.name&&/^(?:(?:rgba?|hsla?|hwba?|lch|oklch|lab|oklab|color)|cubic-bezier)$/.test(l(o.from,o.to))&&(n=e.sliceDoc(o.from,o.node.parent.to)),n){const e=i.Color.parse(n);if(e)s(o.from,e,n);else{const e=t.Geometry.CubicBezier.parse(n);e&&a(o.from,e,n)}}}})}(e,o,r,((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new Fe(t,i,e)}))}),((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new De(t,i)}))})),s.finish()}const Be=n.ViewPlugin.fromClass(class{decorations;constructor(e){this.decorations=Re(e.state,e.viewport.from,e.viewport.to)}update(e){(e.viewportChanged||e.docChanged)&&(this.decorations=Re(e.state,e.view.viewport.from,e.view.viewport.to))}},{decorations:e=>e.decorations});function je(e){if("Unit"===e.name&&(e=e.parent),"NumberLiteral"===e.name){const t=e.lastChild;return{from:e.from,to:t&&"Unit"===t.name?t.from:e.to}}return null}function Ve(e,t){const{head:i}=e.state.selection.main,o=n.syntaxTree(e.state).resolveInner(i,-1),r=je(o)||je(o.resolve(i,1));if(!r)return!1;const s=Number(e.state.sliceDoc(r.from,r.to));return!isNaN(s)&&(e.dispatch({changes:{from:r.from,to:r.to,insert:String(s+t)},scrollIntoView:!0,userEvent:"insert.modifyUnit"}),!0)}function We(){let e=null;const i=t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"sources.increment-css":()=>Promise.resolve(Ve(e,1)),"sources.increment-css-by-ten":()=>Promise.resolve(Ve(e,10)),"sources.decrement-css":()=>Promise.resolve(Ve(e,-1)),"sources.decrement-css-by-ten":()=>Promise.resolve(Ve(e,-10))});return n.EditorView.domEventHandlers({keydown:(t,o)=>{const n=e;return e=o,i(t),e=n,t.defaultPrevented}})}class Oe extends he{#a;constructor(e,t){super(e,t),o.TargetManager.TargetManager.instance().observeModels(o.CSSModel.CSSModel,this)}static accepts(e){return e.contentType().hasStyleSheets()}modelAdded(e){e.target()===o.TargetManager.TargetManager.instance().primaryPageTarget()&&(this.#a=e)}modelRemoved(e){this.#a===e&&(this.#a=void 0)}editorExtension(){return[We(),this.#c(),[Be,Ue]]}#c(){const{cssCompletionSource:e}=n.css,t=this.uiSourceCode,i=this.#a;return n.autocompletion({override:[async o=>await Pe(o,t,i)||e(o)]})}populateTextAreaContextMenu(e){const t=this.#a,i=this.uiSourceCode.url();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&t&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(i)){const o=Le(Te.addSourceMap);e.debugSection().appendItem(o,(()=>function(e,t){j.createAddSourceMapURLDialog((i=>{u.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().modelToInfo.get(e)?.addSourceMap(t,i)})).show()}(t,i)),{jslogContext:"add-source-map"})}}}var He=Object.freeze({__proto__:null,cssBindings:We,CSSPlugin:Oe});const _e=new CSSStyleSheet;_e.replaceSync(".paused-status{margin:6px;padding:4px 10px;border-radius:10px;background-color:var(--sys-color-yellow-container);color:var(--sys-color-on-yellow-container)}.paused-status.error-reason{background-color:var(--sys-color-surface-error);color:var(--sys-color-on-surface-error)}.status-main{padding-left:18px;position:relative}.status-sub:not(:empty){padding-left:15px;padding-top:5px;overflow:hidden;text-overflow:ellipsis}.paused-status.error-reason .status-sub{color:var(--sys-color-error);line-height:11px;max-height:27px;user-select:text}devtools-icon{position:absolute;left:-1px;top:-1px}\n/*# sourceURL=debuggerPausedMessage.css */\n");const ze={pausedOnS:"Paused on {PH1}",childSAdded:"Child {PH1} added",descendantSAdded:"Descendant {PH1} added",descendantSRemoved:"Descendant {PH1} removed",pausedOnEventListener:"Paused on event listener",pausedOnXhrOrFetch:"Paused on XHR or fetch",pausedOnException:"Paused on exception",pausedOnPromiseRejection:"Paused on `promise` rejection",pausedOnAssertion:"Paused on assertion",pausedOnDebuggedFunction:"Paused on debugged function",pausedBeforePotentialOutofmemory:"Paused before potential out-of-memory crash",pausedOnCspViolation:"Paused on CSP violation",trustedTypeSinkViolation:"`Trusted Type` Sink Violation",trustedTypePolicyViolation:"`Trusted Type` Policy Violation",pausedOnBreakpoint:"Paused on breakpoint",debuggerPaused:"Debugger paused",subtreeModifications:"subtree modifications",attributeModifications:"attribute modifications",nodeRemoval:"node removal",webglErrorFiredS:"WebGL Error Fired ({PH1})",scriptBlockedDueToContent:"Script blocked due to Content Security Policy directive: {PH1}"},qe=e.i18n.registerUIStrings("panels/sources/DebuggerPausedMessage.ts",ze),$e=e.i18n.getLocalizedString.bind(void 0,qe),Ge=e.i18n.getLazilyComputedLocalizedString.bind(void 0,qe);class Ke{elementInternal;contentElement;constructor(){this.elementInternal=document.createElement("div"),this.elementInternal.classList.add("paused-message"),this.elementInternal.classList.add("flex-none");const e=t.Utils.createShadowRootWithCoreStyles(this.elementInternal,{cssFile:[_e],delegatesFocus:void 0});this.contentElement=e.createChild("div"),t.ARIAUtils.markAsPoliteLiveRegion(this.elementInternal,!1)}element(){return this.elementInternal}static descriptionWithoutStack(e){const t=/^\s+at\s/m.exec(e);return t?e.substring(0,t.index-1):e.substring(0,e.lastIndexOf("\n"))}static async createDOMBreakpointHitMessage(t){const n=document.createElement("span"),s=t.debuggerModel.target().model(o.DOMDebuggerModel.DOMDebuggerModel);if(!t.auxData||!s)return n;const a=s.resolveDOMBreakpointData(t.auxData);if(!a)return n;const c=n.createChild("div","status-main"),l=new r.Icon.Icon;l.data={iconName:"info",color:"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},c.appendChild(l);const d=Je.get(a.type);c.appendChild(document.createTextNode($e(ze.pausedOnS,{PH1:d?d():String(null)})));const u=n.createChild("div","status-sub monospace"),h=await i.Linkifier.Linkifier.linkify(a.node);if(u.appendChild(h),a.targetNode){const t=await i.Linkifier.Linkifier.linkify(a.targetNode);let o;o=a.insertion?a.targetNode===a.node?e.i18n.getFormatLocalizedString(qe,ze.childSAdded,{PH1:t}):e.i18n.getFormatLocalizedString(qe,ze.descendantSAdded,{PH1:t}):e.i18n.getFormatLocalizedString(qe,ze.descendantSRemoved,{PH1:t}),u.appendChild(document.createElement("br")),u.appendChild(o)}return n}static#l(e){if(!e)return"";const{eventName:t,webglErrorName:i,directiveText:n,targetName:r}=e;if("instrumentation:webglErrorFired"===t&&i){const e=i.replace(/^.*(0x[0-9a-f]+).*$/i,"$1");return $e(ze.webglErrorFiredS,{PH1:e})}if("instrumentation:scriptBlockedByCSP"===t&&n)return $e(ze.scriptBlockedDueToContent,{PH1:n});let s=o.EventBreakpointsModel.EventBreakpointsManager.instance().resolveEventListenerBreakpoint(e);return s?ae(s.name):(s=o.DOMDebuggerModel.DOMDebuggerManager.instance().resolveEventListenerBreakpoint(e),s&&r?r+"."+s.name:s?.name??"")}async render(e,i,o){if(this.contentElement.removeChildren(),this.contentElement.hidden=!e,!e)return;const n=this.contentElement.createChild("div","paused-status"),s="exception"===e.reason||"promiseRejection"===e.reason||"assert"===e.reason||"OOM"===e.reason;let a;if("DOM"===e.reason)a=await Ke.createDOMBreakpointHitMessage(e);else if("EventListener"===e.reason){const t=Ke.#l(e.auxData);a=c($e(ze.pausedOnEventListener),t)}else if("XHR"===e.reason){const t=e.auxData;a=c($e(ze.pausedOnXhrOrFetch),t.url||"")}else if("exception"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Ke.descriptionWithoutStack(i);a=c($e(ze.pausedOnException),o,i)}else if("promiseRejection"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Ke.descriptionWithoutStack(i);a=c($e(ze.pausedOnPromiseRejection),o,i)}else if("assert"===e.reason)a=c($e(ze.pausedOnAssertion));else if("debugCommand"===e.reason)a=c($e(ze.pausedOnDebuggedFunction));else if("OOM"===e.reason)a=c($e(ze.pausedBeforePotentialOutofmemory));else if("CSPViolation"===e.reason&&e.auxData&&e.auxData.violationType){const t=e.auxData.violationType;"trustedtype-sink-violation"===t?a=c($e(ze.pausedOnCspViolation),$e(ze.trustedTypeSinkViolation)):"trustedtype-policy-violation"===t&&(a=c($e(ze.pausedOnCspViolation),$e(ze.trustedTypePolicyViolation)))}else if(e.callFrames.length){const t=await i.rawLocationToUILocation(e.callFrames[0].location()),n=t?o.findBreakpoint(t):null;a=c($e(n?ze.pausedOnBreakpoint:ze.debuggerPaused))}else console.warn("ScriptsPanel paused, but callFrames.length is zero.");function c(e,i,o){const n=document.createElement("span"),a=n.createChild("div","status-main"),c=new r.Icon.Icon;if(c.data={iconName:s?"cross-circle-filled":"info",color:s?"var(--icon-error)":"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},a.appendChild(c),a.appendChild(document.createTextNode(e)),i){const e=n.createChild("div","status-sub monospace");e.textContent=i,t.Tooltip.Tooltip.install(e,o||i)}return n}n.classList.toggle("error-reason",s),a&&n.appendChild(a)}}const Je=new Map([["subtree-modified",Ge(ze.subtreeModifications)],["attribute-modified",Ge(ze.attributeModifications)],["node-removed",Ge(ze.nodeRemoval)]]);var Xe=Object.freeze({__proto__:null,DebuggerPausedMessage:Ke,BreakpointTypeNouns:Je});const Ye=new CSSStyleSheet;Ye.replaceSync(":host{overflow-y:auto}.icon,\n.icon-basic,\n.icon-badge{margin:-3px -5px}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n.navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection){filter:grayscale(50%);opacity:50%}.is-ignore-listed{opacity:50%}.tree-outline li{min-height:20px}.tree-outline li:hover:not(.selected) .selection{display:block;background-color:var(--sys-color-state-hover-on-subtle)}.navigator-fs-folder-tree-item devtools-icon{color:var(--icon-folder-workspace)}.navigator-fs-tree-item devtools-icon{color:var(--icon-file-authored)}.navigator-nw-folder-tree-item devtools-icon{color:var(--icon-folder-deployed)}.navigator-sm-script-tree-item devtools-icon,\n.navigator-script-tree-item devtools-icon,\n.navigator-snippet-tree-item devtools-icon{color:var(--icon-file-script)}.navigator-file-tree-item devtools-icon.dot::before{width:7px;height:7px;top:12px;left:11px}.navigator-file-tree-item:hover:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-hover)}.navigator-file-tree-item.selected:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-inactive)}.navigator-file-tree-item.selected.force-white-icons devtools-icon.dot::before{outline-color:var(--icon-gap-focus-selected)}.navigator-sm-stylesheet-tree-item devtools-icon,\n.navigator-stylesheet-tree-item devtools-icon{color:var(--icon-file-styles)}.navigator-image-tree-item devtools-icon,\n.navigator-font-tree-item devtools-icon{color:var(--icon-file-image)}.navigator-nw-folder-tree-item.is-from-source-map devtools-icon{color:var(--icon-folder-authored)}.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-folder-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-script-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-stylesheet-tree-item .tree-element-title{font-style:italic}@media (forced-colors: active){.tree-outline li .leading-icons devtools-icon{color:ButtonText}.tree-outline li:hover:not(.selected) .selection{forced-color-adjust:none;background-color:Highlight}.tree-outline:not(.hide-selection-when-blurred) li.parent:hover:not(.selected)::before{background-color:HighlightText}.tree-outline:not(.hide-selection-when-blurred) li:hover:not(.selected) devtools-icon,\n .tree-outline li:not(.selected):hover .tree-element-title{forced-color-adjust:none;color:HighlightText}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .is-ignore-listed{filter:none;opacity:100%}}\n/*# sourceURL=navigatorTree.css */\n");const Qe=new CSSStyleSheet;Qe.replaceSync(".navigator-toolbar{border-bottom:1px solid var(--sys-color-divider);padding-left:8px}\n/*# sourceURL=navigatorView.css */\n");class Ze{searchId;searchResultCandidates;searchResultCallback;searchFinishedCallback;searchConfig;constructor(){this.searchId=0,this.searchResultCandidates=[],this.searchResultCallback=null,this.searchFinishedCallback=null,this.searchConfig=null}static filesComparator(e,t){if(e.isDirty()&&!t.isDirty())return-1;if(!e.isDirty()&&t.isDirty())return 1;const i=e.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(e);if(i!==(t.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(t)))return i?1:-1;const o=e.url(),n=t.url();return o&&!n?-1:!o&&n?1:l.StringUtilities.naturalOrderComparator(e.fullDisplayName(),t.fullDisplayName())}static urlComparator(e,t){return l.StringUtilities.naturalOrderComparator(e.url(),t.url())}performIndexing(e){this.stopSearch();const t=this.projects(),o=new i.Progress.CompositeProgress(e);for(let e=0;e<t.length;++e){const i=t[e],n=o.createSubProgress([...i.uiSourceCodes()].length);i.indexContent(n)}}projects(){const e=i.Settings.Settings.instance().moduleSetting("search-in-anonymous-and-content-scripts").get();return f.Workspace.WorkspaceImpl.instance().projects().filter((t=>t.type()!==f.Workspace.projectTypes.Service&&(!(!e&&t.isServiceProject()&&t.type()!==f.Workspace.projectTypes.Formatter)&&!(!e&&t.type()===f.Workspace.projectTypes.ContentScripts))))}performSearch(e,t,o,n){this.stopSearch(),this.searchResultCandidates=[],this.searchResultCallback=o,this.searchFinishedCallback=n,this.searchConfig=e;const r=[],s=new i.Progress.CompositeProgress(t),a=s.createSubProgress(),c=new i.Progress.CompositeProgress(s.createSubProgress());for(const t of this.projects()){const i=[...t.uiSourceCodes()].length,o=c.createSubProgress(i),n=this.projectFilesMatchingFileQuery(t,e),s=t.findFilesMatchingSearchRequest(e,n,o).then(this.processMatchingFilesForProject.bind(this,this.searchId,t,e,n));r.push(s)}Promise.all(r).then(this.processMatchingFiles.bind(this,this.searchId,a,this.searchFinishedCallback.bind(this,!0)))}projectFilesMatchingFileQuery(e,t,i){const o=[];for(const n of e.uiSourceCodes()){if(!n.contentType().isTextType())continue;if(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(n))continue;const e=h.Persistence.PersistenceImpl.instance().binding(n);e&&e.network===n||(i&&!n.isDirty()||t.filePathMatchesFileQuery(n.fullDisplayName())&&o.push(n))}return o.sort(Ze.urlComparator),o}processMatchingFilesForProject(e,t,i,o,n){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);let r=[...n.keys()];r.sort(Ze.urlComparator),r=l.ArrayUtilities.intersectOrdered(r,o,Ze.urlComparator);const s=this.projectFilesMatchingFileQuery(t,i,!0);r=l.ArrayUtilities.mergeOrdered(r,s,Ze.urlComparator);const a=[];for(const e of r){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&!t.isAnonymousScript()||a.push(e)}a.sort(Ze.filesComparator),this.searchResultCandidates=l.ArrayUtilities.mergeOrdered(this.searchResultCandidates,a,Ze.filesComparator)}processMatchingFiles(e,t,i){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);const o=this.searchResultCandidates;if(!o.length)return t.done(),void i();t.setTotalWork(o.length);let n=0;let r=0;for(let e=0;e<20&&e<o.length;++e)a.call(this);function s(e){e.isDirty()?c.call(this,e,e.workingCopy()):e.requestContent().then((t=>{c.call(this,e,t.content||"")}))}function a(){if(n>=o.length)return r?void 0:(t.done(),void i());++r;const e=o[n++];window.setTimeout(s.bind(this,e),0)}function c(e,i){t.incrementWorked(1);let o=[];const n=this.searchConfig,s=n.queries();if(null!==i){for(let e=0;e<s.length;++e){const t=g.TextUtils.performSearchInContent(i,s[e],!n.ignoreCase(),n.isRegex());o=l.ArrayUtilities.mergeOrdered(o,t,g.ContentProvider.SearchMatch.comparator)}n.queries().length||(o=[new g.ContentProvider.SearchMatch(0,new g.Text.Text(i).lineAt(0),0,0)])}if(o&&this.searchResultCallback){const t=new et(e,o);this.searchResultCallback(t)}--r,a.call(this)}}stopSearch(){++this.searchId}}class et{uiSourceCode;searchMatches;constructor(e,t){this.uiSourceCode=e,this.searchMatches=t}label(){return this.uiSourceCode.displayName()}description(){return this.uiSourceCode.fullDisplayName()}matchesCount(){return this.searchMatches.length}matchLineContent(e){return this.searchMatches[e].lineContent}matchRevealable(e){const{lineNumber:t,columnNumber:i,matchLength:o}=this.searchMatches[e],n=new g.TextRange.TextRange(t,i,t,i+o);return new f.UISourceCode.UILocationRange(this.uiSourceCode,n)}matchLabel(e){return String(this.searchMatches[e].lineNumber+1)}matchColumn(e){return this.searchMatches[e].columnNumber}matchLength(e){return this.searchMatches[e].matchLength}}var tt=Object.freeze({__proto__:null,SourcesSearchScope:Ze,FileBasedSearchResult:et});class it{query;constructor(e){this.query=e}}class ot extends E.SearchView.SearchView{constructor(){super("sources",new i.Throttler.Throttler(200))}createScope(){return new Ze}}var nt=Object.freeze({__proto__:null,SearchSources:it,SearchSourcesView:ot,ActionDelegate:class{handleAction(e,o){if("sources.search"===o){const e=t.InspectorView.InspectorView.instance().element.window().getSelection(),o=e?e.toString().replace(/\r?\n.*/,""):"";return i.Revealer.reveal(new it(o)),!0}return!1}},Revealer:class{async reveal({query:e},i){const o=t.ViewManager.ViewManager.instance();await o.showView("sources.search-sources-tab",!0,i);const n=o.materializedWidget("sources.search-sources-tab");n instanceof ot&&n.toggle(e)}}});const rt={searchInFolder:"Search in folder",searchInAllFiles:"Search in all files",noDomain:"(no domain)",authored:"Authored",authoredTooltip:"Contains original sources",deployed:"Deployed",deployedTooltip:"Contains final sources the browser sees",areYouSureYouWantToExcludeThis:"Are you sure you want to exclude this folder?",areYouSureYouWantToDeleteThis:"Are you sure you want to delete this file?",rename:"Rename…",makeACopy:"Make a copy…",delete:"Delete",remove:"Remove",areYouSureYouWantToDeleteFolder:"Are you sure you want to delete this folder and its contents?",actionCannotBeUndone:"This action cannot be undone.",openFolder:"Open folder",newFile:"New file",excludeFolder:"Exclude from workspace",removeFolderFromWorkspace:"Remove from workspace",areYouSureYouWantToRemoveThis:"Remove ‘{PH1}’ from Workspace?",workspaceStopSyncing:"This will stop syncing changes from DevTools to your sources.",sFromSourceMap:"{PH1} (from source map)",sIgnoreListed:"{PH1} (ignore listed)"},st=e.i18n.registerUIStrings("panels/sources/NavigatorView.ts",rt),at=e.i18n.getLocalizedString.bind(void 0,st),ct={Authored:"authored",Deployed:"deployed",Domain:"domain",File:"file",FileSystem:"fs",FileSystemFolder:"fs-folder",Frame:"frame",NetworkFolder:"nw-folder",Root:"root",Worker:"worker"},lt=new Map([[ct.Root,1],[ct.Authored,1],[ct.Deployed,5],[ct.Domain,10],[ct.FileSystemFolder,1],[ct.NetworkFolder,1],[ct.File,10],[ct.Frame,70],[ct.Worker,90],[ct.FileSystem,100]]);class dt extends t.Widget.VBox{placeholder;scriptsTree;uiSourceCodeNodes;subfolderNodes;rootNode;frameNodes;authoredNode;deployedNode;navigatorGroupByFolderSetting;navigatorGroupByAuthoredExperiment;workspaceInternal;groupByFrame;groupByAuthored;groupByDomain;groupByFolder;constructor(e,n){super(!0),this.placeholder=null,this.scriptsTree=new t.TreeOutline.TreeOutlineInShadow,this.scriptsTree.setComparator(dt.treeElementsCompare),this.scriptsTree.setFocusable(!1),this.contentElement.setAttribute("jslog",`${a.pane(e).track({resize:!0})}`),this.contentElement.appendChild(this.scriptsTree.element),this.setDefaultFocusedElement(this.scriptsTree.element),this.uiSourceCodeNodes=new l.MapUtilities.Multimap,this.subfolderNodes=new Map,this.rootNode=new mt(this),this.rootNode.populate(),this.frameNodes=new Map,this.contentElement.addEventListener("contextmenu",this.handleContextMenu.bind(this),!1),t.ShortcutRegistry.ShortcutRegistry.instance().addShortcutListener(this.contentElement,{"sources.rename":this.renameShortcut.bind(this)}),this.navigatorGroupByFolderSetting=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder"),this.navigatorGroupByFolderSetting.addChangeListener(this.groupingChanged.bind(this)),n&&(this.navigatorGroupByAuthoredExperiment="authored-deployed-grouping"),u.IgnoreListManager.IgnoreListManager.instance().addChangeListener(this.ignoreListChanged.bind(this)),this.initGrouping(),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingCreated,this.onBindingChanged,this),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingRemoved,this.onBindingChanged,this),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("RequestsForHeaderOverridesFileChanged",this.#d,this),o.TargetManager.TargetManager.instance().addEventListener("NameChanged",this.targetNameChanged,this),o.TargetManager.TargetManager.instance().observeTargets(this),this.resetWorkspace(f.Workspace.WorkspaceImpl.instance()),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this)),u.NetworkProject.NetworkProjectManager.instance().addEventListener("FrameAttributionAdded",this.frameAttributionAdded,this),u.NetworkProject.NetworkProjectManager.instance().addEventListener("FrameAttributionRemoved",this.frameAttributionRemoved,this)}static treeElementOrder(e){if(ut.has(e))return 0;const t=e;let i=lt.get(t.nodeType)||0;if(t.uiSourceCode){const e=t.uiSourceCode.contentType();e.isDocument()?i+=3:e.isScript()?i+=5:e.isStyleSheet()?i+=10:i+=15}return i}static appendSearchItem(e,t){const o=at(t?rt.searchInFolder:rt.searchInAllFiles),n=new it(t&&`file:${t}`);e.viewSection().appendItem(o,(()=>i.Revealer.reveal(n)),{jslogContext:t?"search-in-folder":"search-in-all-files"})}static treeElementsCompare(e,t){const i=dt.treeElementOrder(e),o=dt.treeElementOrder(t);return i>o?1:i<o?-1:l.StringUtilities.naturalOrderComparator(e.titleAsText(),t.titleAsText())}setPlaceholder(e){function i(){const t=this.scriptsTree.firstChild();t?e.hideWidget():e.showWidget(),this.scriptsTree.element.classList.toggle("hidden",!t)}console.assert(!this.placeholder,"A placeholder widget was already set"),this.placeholder=e,e.show(this.contentElement,this.contentElement.firstChild),i.call(this),this.scriptsTree.addEventListener(t.TreeOutline.Events.ElementAttached,i.bind(this)),this.scriptsTree.addEventListener(t.TreeOutline.Events.ElementsDetached,i.bind(this))}onBindingChanged(e){const t=e.data;let o=!1;const n=this.uiSourceCodeNodes.get(t.network);for(const e of n)e.updateTitle(),o||=e.uiSourceCode().contentType().isFromSourceMap();const r=this.uiSourceCodeNodes.get(t.fileSystem);for(const e of r)e.updateTitle(),o||=e.uiSourceCode().contentType().isFromSourceMap();const s=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(t.fileSystem);let a=l.DevToolsPath.EmptyEncodedPathString;for(let e=0;e<s.length-1;++e){a=i.ParsedURL.ParsedURL.concatenate(a,s[e]);const n=this.folderNodeId(t.fileSystem.project(),null,null,t.fileSystem.origin(),o,a),r=this.subfolderNodes.get(n);r&&r.updateTitle(),a=i.ParsedURL.ParsedURL.concatenate(a,"/")}const c=this.rootOrDeployedNode().child(t.fileSystem.project().id());c&&c.updateTitle()}#d(e){const t=e.data,i=this.uiSourceCodeNodes.get(t);for(const e of i)e.updateTitle()}focus(){this.scriptsTree.focus()}appendChild(e,t){this.scriptsTree.setFocusable(!0),e.appendChild(t)}removeChild(e,t){e.removeChild(t),0===this.scriptsTree.rootElement().childCount()&&this.scriptsTree.setFocusable(!1)}resetWorkspace(e){this.workspaceInternal&&(this.workspaceInternal.removeEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAddedCallback,this),this.workspaceInternal.removeEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemovedCallback,this),this.workspaceInternal.removeEventListener(f.Workspace.Events.ProjectAdded,this.projectAddedCallback,this),this.workspaceInternal.removeEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemovedCallback,this)),this.workspaceInternal=e,this.workspaceInternal.addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAddedCallback,this),this.workspaceInternal.addEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemovedCallback,this),this.workspaceInternal.addEventListener(f.Workspace.Events.ProjectAdded,this.projectAddedCallback,this),this.workspaceInternal.addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemovedCallback,this),this.workspaceInternal.projects().forEach(this.projectAdded.bind(this)),this.computeUniqueFileSystemProjectNames()}projectAddedCallback(e){const t=e.data;this.projectAdded(t),t.type()===f.Workspace.projectTypes.FileSystem&&this.computeUniqueFileSystemProjectNames()}projectRemovedCallback(e){const t=e.data;this.removeProject(t),t.type()===f.Workspace.projectTypes.FileSystem&&this.computeUniqueFileSystemProjectNames()}workspace(){return this.workspaceInternal}acceptProject(e){return!e.isServiceProject()}frameAttributionAdded(e){const{uiSourceCode:t}=e.data;if(!this.acceptsUISourceCode(t))return;const i=e.data.frame;this.addUISourceCodeNode(t,i)}frameAttributionRemoved(e){const{uiSourceCode:t}=e.data;if(!this.acceptsUISourceCode(t))return;const i=e.data.frame,o=Array.from(this.uiSourceCodeNodes.get(t)).find((e=>e.frame()===i));o&&this.removeUISourceCodeNode(o)}acceptsUISourceCode(e){return this.acceptProject(e.project())}addUISourceCode(e){if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return;if(!this.acceptsUISourceCode(e))return;if(e.isFetchXHR())return;const t=u.NetworkProject.NetworkProject.framesForUISourceCode(e);if(t.length)for(const i of t)this.addUISourceCodeNode(e,i);else this.addUISourceCodeNode(e,null);this.uiSourceCodeAdded(e)}addUISourceCodeNode(e,t){const o=e.contentType().isFromSourceMap();let n;n=e.project().type()===f.Workspace.projectTypes.FileSystem?h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(e).slice(0,-1):i.ParsedURL.ParsedURL.extractPath(e.url()).split("/").slice(1,-1);const r=e.project(),s=u.NetworkProject.NetworkProject.targetForUISourceCode(e),a=this.folderNode(e,r,s,t,e.origin(),n,o),c=new bt(this,e,t),l=a.child(c.id);l&&l instanceof bt?this.uiSourceCodeNodes.set(e,l):(a.appendChild(c),this.uiSourceCodeNodes.set(e,c),c.updateTitleBubbleUp()),this.selectDefaultTreeNode()}uiSourceCodeAdded(e){}uiSourceCodeAddedCallback(e){const t=e.data;this.addUISourceCode(t)}uiSourceCodeRemovedCallback(e){this.removeUISourceCodes([e.data])}tryAddProject(e){this.projectAdded(e);for(const t of e.uiSourceCodes())this.addUISourceCode(t)}projectAdded(e){const t=this.rootOrDeployedNode();!this.acceptProject(e)||e.type()!==f.Workspace.projectTypes.FileSystem||T.ScriptSnippetFileSystem.isSnippetsProject(e)||t.child(e.id())||(t.appendChild(new St(this,e,e.id(),ct.FileSystem,e.displayName())),this.selectDefaultTreeNode())}selectDefaultTreeNode(){const e=this.rootNode.children();e.length&&!this.scriptsTree.selectedTreeElement&&e[0].treeNode().select(!0,!1)}computeUniqueFileSystemProjectNames(){const e=this.workspaceInternal.projectsForType(f.Workspace.projectTypes.FileSystem);if(!e.length)return;const t=i.Trie.Trie.newArrayTrie(),o=[];for(const i of e){const e=i.fileSystemPath().split("/").reverse();o.push(e),t.add(e)}const n=this.rootOrDeployedNode();for(let r=0;r<e.length;++r){const s=o[r],a=e[r];t.remove(s);const c=t.longestPrefix(s,!1);t.add(s);const l=s.slice(0,c.length+1),d=i.ParsedURL.ParsedURL.encodedPathToRawPathString(l.reverse().join("/")),u=n.child(a.id());u&&u.setTitle(d)}}removeProject(e){if(this.removeUISourceCodes(e.uiSourceCodes()),e.type()!==f.Workspace.projectTypes.FileSystem)return;const t=this.rootNode.child(e.id());t&&this.rootNode.removeChild(t)}folderNodeId(e,t,i,o,n,r){const s=e.type()===f.Workspace.projectTypes.FileSystem?e.id():"";let a=!t||this.groupByAuthored&&n?"":t.id(),c=this.groupByFrame&&i?i.id:"";return this.groupByAuthored&&(n?(a="Authored",c=""):a="Deployed:"+a),a+":"+s+":"+c+":"+o+":"+r}folderNode(e,t,o,n,r,s,a){if(T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e))return this.rootNode;if(o&&!this.groupByFolder&&!a)return this.domainNode(e,t,o,n,r);const c=i.ParsedURL.ParsedURL.join(s,"/"),l=this.folderNodeId(t,o,n,r,a,c);let d=this.subfolderNodes.get(l);if(d)return d;if(!s.length)return o?this.domainNode(e,t,o,n,r):this.rootOrDeployedNode().child(t.id());const u=this.folderNode(e,t,o,n,r,s.slice(0,-1),a);let h=ct.NetworkFolder;t.type()===f.Workspace.projectTypes.FileSystem&&(h=ct.FileSystemFolder);const p=i.ParsedURL.ParsedURL.encodedPathToRawPathString(s[s.length-1]);return d=new ft(this,t,l,h,c,p,r),this.subfolderNodes.set(l,d),u.appendChild(d),d}domainNode(e,t,o,n,r){const s=e.contentType().isFromSourceMap(),a=this.frameNode(t,o,n,s);if(!this.groupByDomain)return a;let c=a.child(r);return c||(c=new St(this,t,r,ct.Domain,this.computeProjectDisplayName(o,r)),n&&r===i.ParsedURL.ParsedURL.extractOrigin(n.url)&&ut.add(c.treeNode()),a.appendChild(c),s&&this.groupByAuthored&&c.treeNode().expand(),c)}frameNode(e,t,i,n){if(!this.groupByFrame||!i||this.groupByAuthored&&n)return this.targetNode(e,t,n);let r=this.frameNodes.get(i);if(r)return r;r=new St(this,e,t.id()+":"+i.id,ct.Frame,i.displayName()),r.setHoverCallback((function(e){if(e){const e=t.model(o.OverlayModel.OverlayModel);e&&i&&e.highlightFrame(i.id)}else o.OverlayModel.OverlayModel.hideDOMNodeHighlight()})),this.frameNodes.set(i,r);const s=i.parentFrame();return this.frameNode(e,s?s.resourceTreeModel().target():t,s,n).appendChild(r),s||(ut.add(r.treeNode()),r.treeNode().expand()),r}targetNode(e,t,i){if(this.groupByAuthored&&i)return this.authoredNode||(this.authoredNode=new St(this,null,"group:Authored",ct.Authored,at(rt.authored),at(rt.authoredTooltip)),this.rootNode.appendChild(this.authoredNode),this.authoredNode.treeNode().expand()),this.authoredNode;const n=this.rootOrDeployedNode();if(t===o.TargetManager.TargetManager.instance().scopeTarget())return n;let r=n.child("target:"+t.id());return r||(r=new St(this,e,"target:"+t.id(),t.type()===o.Target.Type.Frame?ct.Frame:ct.Worker,t.name()),n.appendChild(r)),r}rootOrDeployedNode(){return this.groupByAuthored?(this.deployedNode||(this.deployedNode=new St(this,null,"group:Deployed",ct.Deployed,at(rt.deployed),at(rt.deployedTooltip)),this.rootNode.appendChild(this.deployedNode)),this.deployedNode):this.rootNode}computeProjectDisplayName(e,t){const n=e.model(o.RuntimeModel.RuntimeModel),r=n?n.executionContexts():[];for(const e of r)if(e.name&&e.origin&&t.startsWith(e.origin))return e.name;if(!t)return at(rt.noDomain);const s=new i.ParsedURL.ParsedURL(t);return(s.isValid?s.host+(s.port?":"+s.port:""):"")||t}revealUISourceCode(e,i){const o=this.uiSourceCodeNodes.get(e);if(0===o.size)return null;const n=o.values().next().value;if(!n)return null;if(this.scriptsTree.selectedTreeElement){if(t.UIUtils.isBeingEdited(this.scriptsTree.selectedTreeElement.treeOutline?.element))return null;this.scriptsTree.selectedTreeElement.deselect()}return n.reveal(i),n}sourceSelected(e,t){i.Revealer.reveal(e,!t)}#u(e){const t=this.scriptsTree.selectedTreeElement,i=t&&t.node;let o=e;for(;o;){if(o===i)return!0;if(o=o.parent,!(e instanceof St||e instanceof ht))break}return!1}removeUISourceCodes(e){const t=[];for(const i of e){const e=this.uiSourceCodeNodes.get(i);for(const i of e)this.#u(i)?t.push(i):this.removeUISourceCodeNode(i)}t.forEach(this.removeUISourceCodeNode.bind(this))}removeUISourceCodeNode(e){const t=e.uiSourceCode();this.uiSourceCodeNodes.delete(t,e);const i=t.project(),o=u.NetworkProject.NetworkProject.targetForUISourceCode(t);let n=e.frame(),r=e.parent;if(!r)return;r.removeChild(e);let s=r;for(;s&&(r=s.parent,r)&&(r!==this.rootNode&&r!==this.deployedNode||i.type()!==f.Workspace.projectTypes.FileSystem)&&(s instanceof St||s instanceof ft);){if(!s.isEmpty()){s.updateTitleBubbleUp();break}if(s.type===ct.Frame)this.discardFrame(n,Boolean(this.groupByAuthored)&&t.contentType().isFromSourceMap()),n=n.parentFrame();else{const e=this.folderNodeId(i,o,n,t.origin(),t.contentType().isFromSourceMap(),s instanceof ft&&s.folderPath||l.DevToolsPath.EmptyEncodedPathString);this.subfolderNodes.delete(e),r.removeChild(s)}s===this.authoredNode?this.authoredNode=void 0:s===this.deployedNode&&(this.deployedNode=void 0),s=r}}reset(e){for(const e of this.uiSourceCodeNodes.valuesArray())e.dispose();this.scriptsTree.removeChildren(),this.scriptsTree.setFocusable(!1),this.uiSourceCodeNodes.clear(),this.subfolderNodes.clear(),this.frameNodes.clear(),this.rootNode.reset(),this.authoredNode=void 0,this.deployedNode=void 0,e||this.resetWorkspace(f.Workspace.WorkspaceImpl.instance())}handleContextMenu(e){}async renameShortcut(){const e=this.scriptsTree.selectedTreeElement,t=e&&e.node;return!!(t&&t.uiSourceCode()&&t.uiSourceCode().canRename())&&(this.rename(t,!1),!0)}handleContextMenuCreate(e,t,o){if(o){const e=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(o);e.pop(),t=i.ParsedURL.ParsedURL.join(e,"/")}this.create(e,t,o)}handleContextMenuRename(e){this.rename(e,!1)}async handleContextMenuExclude(e,i){await t.UIUtils.ConfirmDialog.show(at(rt.areYouSureYouWantToExcludeThis),void 0,{jslogContext:"exclude-folder-confirmation"})&&(t.UIUtils.startBatchUpdate(),e.excludeFolder(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.completeURL(e,i)),t.UIUtils.endBatchUpdate())}async handleContextMenuDelete(e){await t.UIUtils.ConfirmDialog.show(at(rt.areYouSureYouWantToDeleteThis),void 0,{jslogContext:"delete-file-confirmation"})&&e.project().deleteFile(e)}handleFileContextMenu(e,i){const o=i.uiSourceCode(),n=new t.ContextMenu.ContextMenu(e);n.appendApplicableItems(o);const r=o.project();r.type()===f.Workspace.projectTypes.FileSystem&&(n.editSection().appendItem(at(rt.rename),this.handleContextMenuRename.bind(this,i),{jslogContext:"rename"}),n.editSection().appendItem(at(rt.makeACopy),this.handleContextMenuCreate.bind(this,r,l.DevToolsPath.EmptyEncodedPathString,o),{jslogContext:"make-a-copy"}),n.editSection().appendItem(at(rt.delete),this.handleContextMenuDelete.bind(this,o),{jslogContext:"delete"})),n.show()}async handleDeleteFolder(e){const i=`${at(rt.areYouSureYouWantToDeleteFolder)}\n${at(rt.actionCannotBeUndone)}`;if(await t.UIUtils.ConfirmDialog.show(i,void 0,{jslogContext:"delete-folder-confirmation"})){c.userMetrics.actionTaken(c.UserMetrics.Action.OverrideTabDeleteFolderContextMenu);const t=this.findTopNonMergedNode(e);await this.removeUISourceCodeFromProject(t),await this.deleteDirectoryRecursively(t)}}async removeUISourceCodeFromProject(e){e.children().forEach((async e=>{await this.removeUISourceCodeFromProject(e)})),e instanceof bt&&e.uiSourceCode().project().removeUISourceCode(e.uiSourceCode().url())}async deleteDirectoryRecursively(e){e instanceof ft&&await(h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()?.deleteDirectoryRecursively(e.folderPath))}findTopNonMergedNode(e){return e.isMerged&&e.parent instanceof ft?this.findTopNonMergedNode(e.parent):e}handleFolderContextMenu(e,o){const n=o.folderPath||l.DevToolsPath.EmptyEncodedPathString,r=o.project||null,s=new t.ContextMenu.ContextMenu(e);if(dt.appendSearchItem(s,n),r){if(r.type()===f.Workspace.projectTypes.FileSystem){const e=i.ParsedURL.ParsedURL.urlToRawPathString(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.completeURL(r,n),c.Platform.isWin());s.revealSection().appendItem(at(rt.openFolder),(()=>c.InspectorFrontendHost.InspectorFrontendHostInstance.showItemInFolder(e)),{jslogContext:"open-folder"}),r.canCreateFile()&&s.defaultSection().appendItem(at(rt.newFile),(()=>{this.handleContextMenuCreate(r,n,void 0)}),{jslogContext:"new-file"})}else if(o.origin&&o.folderPath){const e=i.ParsedURL.ParsedURL.concatenate(o.origin,"/",o.folderPath),t={isContentScript:o.recursiveProperties.exclusivelyContentScripts||!1,isKnownThirdParty:o.recursiveProperties.exclusivelyThirdParty||!1,isCurrentlyIgnoreListed:o.recursiveProperties.exclusivelyIgnored||!1};for(const{text:i,callback:o,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListFolderContextMenuItems(e,t))s.defaultSection().appendItem(i,o,{jslogContext:n})}if(r.canExcludeFolder(n)&&s.defaultSection().appendItem(at(rt.excludeFolder),this.handleContextMenuExclude.bind(this,r,n),{jslogContext:"exclude-folder"}),r.type()===f.Workspace.projectTypes.FileSystem){"overrides"===r.fileSystem().type()?o instanceof St||s.defaultSection().appendItem(at(rt.delete),this.handleDeleteFolder.bind(this,o),{jslogContext:"delete"}):o instanceof St&&s.defaultSection().appendItem(at(rt.removeFolderFromWorkspace),(async()=>{const e=`${at(rt.areYouSureYouWantToRemoveThis,{PH1:o.title})}\n${at(rt.workspaceStopSyncing)}`;await t.UIUtils.ConfirmDialog.show(e,void 0,{okButtonLabel:at(rt.remove),jslogContext:"remove-folder-from-workspace-confirmation"})&&r.remove()}),{jslogContext:"remove-folder-from-workspace"})}s.show()}}rename(e,t){const i=e.uiSourceCode();e.rename(function(o){if(!t)return;o?e.treeElement&&e.treeElement.listItemElement.hasFocus()&&this.sourceSelected(i,!0):i.remove()}.bind(this))}async create(e,t,i){let o="";i&&(o=(await i.requestContent()).content||"");const n=await e.createFile(t,null,o);if(!n)return;this.sourceSelected(n,!1);const r=this.revealUISourceCode(n,!0);r&&this.rename(r,!0)}groupingChanged(){this.reset(!0),this.initGrouping(),this.resetWorkspace(f.Workspace.WorkspaceImpl.instance()),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}ignoreListChanged(){C.Runtime.experiments.isEnabled("just-my-code")?this.groupingChanged():this.rootNode.updateTitleRecursive()}initGrouping(){this.groupByFrame=!0,this.groupByDomain=this.navigatorGroupByFolderSetting.get(),this.groupByFolder=this.groupByDomain,this.navigatorGroupByAuthoredExperiment?this.groupByAuthored=C.Runtime.experiments.isEnabled(this.navigatorGroupByAuthoredExperiment):this.groupByAuthored=!1}resetForTest(){this.reset(),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}discardFrame(e,t){if(t)return;const i=this.frameNodes.get(e);if(i){i.parent&&i.parent.removeChild(i),this.frameNodes.delete(e);for(const i of e.childFrames)this.discardFrame(i,t)}}targetAdded(e){}targetRemoved(e){const t=this.rootOrDeployedNode(),i=t.child("target:"+e.id());i&&t.removeChild(i)}targetNameChanged(e){const t=e.data,i=this.rootOrDeployedNode().child("target:"+t.id());i&&i.setTitle(t.name())}wasShown(){super.wasShown(),this.scriptsTree.registerCSSFiles([Ye]),this.registerCSSFiles([Qe])}}const ut=new WeakSet;class ht extends t.TreeOutline.TreeElement{nodeType;navigatorView;hoverCallback;node;hovered;isIgnoreListed;isFromSourceMap;constructor(e,i,o,n){super("",!0,ht.#h(i)),this.listItemElement.classList.add("navigator-"+i+"-tree-item","navigator-folder-tree-item"),t.ARIAUtils.setLabel(this.listItemElement,`${o}, ${i}`),this.nodeType=i,this.title=o,this.tooltip=o,this.navigatorView=e,this.hoverCallback=n,this.isFromSourceMap=!1;let s="folder";i===ct.Domain?s="cloud":i===ct.Frame?s="frame":i===ct.Worker?s="gears":i===ct.Authored?s="code":i===ct.Deployed&&(s="deployed");const a=r.Icon.create(s);this.setLeadingIcons([a])}async onpopulate(){this.node.populate()}onattach(){this.collapse(),this.node.onattach(),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("mousemove",this.mouseMove.bind(this),!1),this.listItemElement.addEventListener("mouseleave",this.mouseLeave.bind(this),!1)}setIgnoreListed(e){this.isIgnoreListed!==e&&(this.isIgnoreListed=e,this.listItemElement.classList.toggle("is-ignore-listed",e),this.updateTooltip())}setFromSourceMap(e){this.isFromSourceMap=e,this.listItemElement.classList.toggle("is-from-source-map",e)}setNode(e){this.node=e,this.updateTooltip(),t.ARIAUtils.setLabel(this.listItemElement,`${this.title}, ${this.nodeType}`)}updateTooltip(){if(this.node.tooltip)this.tooltip=this.node.tooltip;else{const e=[];let t=this.node;for(;t&&!t.isRoot()&&t.type===this.node.type;)e.push(t.title),t=t.parent;e.reverse();let i=e.join("/");this.isIgnoreListed&&(i=at(rt.sIgnoreListed,{PH1:i})),this.tooltip=i}}handleContextMenuEvent(e){this.node&&(this.select(),this.navigatorView.handleFolderContextMenu(e,this.node))}mouseMove(e){!this.hovered&&this.hoverCallback&&(this.hovered=!0,this.hoverCallback(!0))}mouseLeave(e){this.hoverCallback&&(this.hovered=!1,this.hoverCallback(!1))}static#h(e){switch(e){case ct.Domain:return"domain";case ct.Frame:return"frame";case ct.Worker:return"worker";case ct.Authored:return"authored";case ct.Deployed:return"deployed"}return"folder"}}class pt extends t.TreeOutline.TreeElement{nodeType;node;navigatorView;uiSourceCodeInternal;constructor(e,o,n,r){super("",!1,o.contentType().name()),this.nodeType=ct.File,this.node=r,this.title=n,this.listItemElement.classList.add("navigator-"+o.contentType().name()+"-tree-item","navigator-file-tree-item"),this.tooltip=o.url(),t.ARIAUtils.setLabel(this.listItemElement,`${o.name()}, ${this.nodeType}`),i.EventTarget.fireEvent("source-tree-file-added",o.fullDisplayName()),this.navigatorView=e,this.uiSourceCodeInternal=o,this.updateIcon()}updateIcon(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),i=h.NetworkPersistenceManager.NetworkPersistenceManager.instance();let o="document",n=[];if(e){T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e.fileSystem)&&(o="snippet");n=i.project()===e.fileSystem.project()?["dot","purple"]:["dot","green"]}else i.isActiveHeaderOverrides(this.uiSourceCode)?n=["dot","purple"]:T.ScriptSnippetFileSystem.isSnippetsUISourceCode(this.uiSourceCodeInternal)&&(o="snippet");const s=r.Icon.create(o,n.join(" "));e&&t.Tooltip.Tooltip.install(s,h.PersistenceUtils.PersistenceUtils.tooltipForUISourceCode(this.uiSourceCodeInternal)),this.setLeadingIcons([s])}updateAccessibleName(){t.ARIAUtils.setLabel(this.listItemElement,`${this.uiSourceCodeInternal.name()}, ${this.nodeType}`)}get uiSourceCode(){return this.uiSourceCodeInternal}onattach(){this.listItemElement.draggable=!0,this.listItemElement.addEventListener("click",this.onclick.bind(this),!1),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("dragstart",this.ondragstart.bind(this),!1)}shouldRenameOnMouseDown(){if(!this.uiSourceCodeInternal.canRename())return!1;if(!this.treeOutline)return!1;return this===this.treeOutline.selectedTreeElement&&this.treeOutline.element.hasFocus()&&!t.UIUtils.isBeingEdited(this.treeOutline.element)}selectOnMouseDown(e){1===e.which&&this.shouldRenameOnMouseDown()?window.setTimeout(function(){this.shouldRenameOnMouseDown()&&this.navigatorView.rename(this.node,!1)}.bind(this),300):super.selectOnMouseDown(e)}ondragstart(e){e.dataTransfer&&(e.dataTransfer.setData("text/plain",this.uiSourceCodeInternal.url()),e.dataTransfer.effectAllowed="copy")}onspace(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}onclick(e){this.navigatorView.sourceSelected(this.uiSourceCode,!1)}ondblclick(e){const t=1===e.button;return this.navigatorView.sourceSelected(this.uiSourceCode,!t),!1}onenter(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}ondelete(){return!0}handleContextMenuEvent(e){this.select(),this.navigatorView.handleFileContextMenu(e,this.node)}}class gt{id;navigatorView;type;childrenInternal;populated;isMerged;parent;title;tooltip;recursiveProperties;constructor(e,t,i,o){this.id=t,this.navigatorView=e,this.type=i,this.childrenInternal=new Map,this.tooltip=o,this.populated=!1,this.isMerged=!1,this.recursiveProperties={exclusivelySourceMapped:null,exclusivelyIgnored:null,exclusivelyContentScripts:null,exclusivelyThirdParty:null}}treeNode(){throw"Not implemented"}dispose(){}updateTitle(){}updateTitleRecursive(){for(const e of this.children())e.updateTitleRecursive();this.updateTitle()}updateTitleBubbleUp(){this.updateTitle(),this.parent&&this.parent.updateTitleBubbleUp()}isRoot(){return!1}hasChildren(){return!0}onattach(){}setTitle(e){throw"Not implemented"}populate(){this.isPopulated()||(this.parent&&this.parent.populate(),this.populated=!0,this.wasPopulated())}wasPopulated(){const e=this.children();for(let t=0;t<e.length;++t)this.navigatorView.appendChild(this.treeNode(),e[t].treeNode())}didAddChild(e){this.isPopulated()&&this.navigatorView.appendChild(this.treeNode(),e.treeNode())}willRemoveChild(e){this.isPopulated()&&this.navigatorView.removeChild(this.treeNode(),e.treeNode())}isPopulated(){return this.populated}isEmpty(){return!this.childrenInternal.size}children(){return[...this.childrenInternal.values()]}child(e){return this.childrenInternal.get(e)||null}appendChild(e){this.childrenInternal.set(e.id,e),e.parent=this,this.didAddChild(e)}removeChild(e){this.willRemoveChild(e),this.childrenInternal.delete(e.id),e.parent=null,e.dispose()}reset(){this.childrenInternal.clear()}}class mt extends gt{constructor(e){super(e,"",ct.Root)}isRoot(){return!0}treeNode(){return this.navigatorView.scriptsTree.rootElement()}}class bt extends gt{uiSourceCodeInternal;treeElement;eventListeners;frameInternal;constructor(e,t,i){super(e,"UISourceCode:"+t.canononicalScriptId(),ct.File),this.uiSourceCodeInternal=t,this.treeElement=null,this.eventListeners=[],this.frameInternal=i,this.recursiveProperties.exclusivelySourceMapped=t.contentType().isFromSourceMap(),t.contentType().isScript()&&(this.recursiveProperties.exclusivelyThirdParty=t.isKnownThirdParty(),this.recursiveProperties.exclusivelyContentScripts=t.project().type()===f.Workspace.projectTypes.ContentScripts)}frame(){return this.frameInternal}uiSourceCode(){return this.uiSourceCodeInternal}treeNode(){if(this.treeElement)return this.treeElement;this.treeElement=new pt(this.navigatorView,this.uiSourceCodeInternal,"",this),this.updateTitle();const e=this.updateTitle.bind(this,void 0);return this.eventListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.TitleChanged,e),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,e),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,e)],this.treeElement}updateTitle(e){const t=u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(this.uiSourceCodeInternal);if((this.uiSourceCodeInternal.contentType().isScript()||t)&&(this.recursiveProperties.exclusivelyIgnored=t),!this.treeElement)return;let i=this.uiSourceCodeInternal.displayName();!e&&this.uiSourceCodeInternal.isDirty()&&(i="*"+i),this.treeElement.title=i,this.treeElement.updateIcon(),this.treeElement.listItemElement.classList.toggle("is-ignore-listed",t);let o=this.uiSourceCodeInternal.url();this.uiSourceCodeInternal.contentType().isFromSourceMap()&&(o=at(rt.sFromSourceMap,{PH1:this.uiSourceCodeInternal.displayName()})),t&&(o=at(rt.sIgnoreListed,{PH1:o})),this.treeElement.tooltip=o,this.treeElement.updateAccessibleName(),this.parent?.childrenInternal.delete(this.id),this.id="UISourceCode:"+this.uiSourceCodeInternal.canononicalScriptId(),this.parent?.childrenInternal.set(this.id,this)}hasChildren(){return!1}dispose(){i.EventTarget.removeEventListeners(this.eventListeners)}reveal(e){this.parent&&(this.parent.populate(),this.parent.treeNode().expand()),this.treeElement&&(this.treeElement.reveal(!0),e&&this.treeElement.select(!0))}rename(e){if(!this.treeElement)return;if(this.treeElement.listItemElement.focus(),!this.treeElement.treeOutline)return;const i=this.treeElement.treeOutline.element;function o(o){if(!o)return t.UIUtils.markBeingEdited(i,!1),this.updateTitle(),void this.rename(e);if(this.treeElement){const{parent:e}=this.treeElement;e&&(e.removeChild(this.treeElement),e.appendChild(this.treeElement),this.treeElement.select())}n.call(this,!0)}function n(o){t.UIUtils.markBeingEdited(i,!1),this.updateTitle(),e&&e(o)}t.UIUtils.markBeingEdited(i,!0),this.updateTitle(!0),this.treeElement.startEditingTitle(new t.InplaceEditor.Config(function(e,t,i){if(t!==i)return this.treeElement&&(this.treeElement.title=t),void this.uiSourceCodeInternal.rename(t).then(o.bind(this));n.call(this,!0)}.bind(this),n.bind(this,!1)))}}class ft extends gt{project;folderPath;origin;title;treeElement;constructor(e,t,i,o,n,r,s){super(e,i,o),this.project=t,this.folderPath=n,this.title=r,this.origin=s}treeNode(){return this.treeElement||(this.treeElement=this.createTreeElement(this.title,this),this.updateTitle()),this.treeElement}updateTitle(){let e;for(e in this.recursiveProperties){let t=null;for(const i of this.children()){if(!1===i.recursiveProperties[e]){t=!1;break}i.recursiveProperties[e]&&(t=!0)}this.recursiveProperties[e]=t}if(!this.treeElement)return;if(this.treeElement.setFromSourceMap(this.recursiveProperties.exclusivelySourceMapped||!1),this.treeElement.setIgnoreListed(this.recursiveProperties.exclusivelyIgnored||!1),!this.project||this.project.type()!==f.Workspace.projectTypes.FileSystem)return;const t=i.ParsedURL.ParsedURL.concatenate(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemPath(this.project.id()),"/",this.folderPath),o=h.Persistence.PersistenceImpl.instance().filePathHasBindings(t);this.treeElement.listItemElement.classList.toggle("has-mapped-files",o)}createTreeElement(e,t){const i=new ht(this.navigatorView,this.type,e);return i.setNode(t),i}wasPopulated(){this.treeElement&&this.treeElement.node===this&&this.addChildrenRecursive()}addChildrenRecursive(){const e=this.children();for(let t=0;t<e.length;++t){const i=e[t];this.didAddChild(i),i instanceof ft&&i.addChildrenRecursive()}}shouldMerge(e){return this.type!==ct.Domain&&e instanceof ft}didAddChild(e){if(!this.treeElement)return;let t,i=this.children();if(1===i.length&&this.shouldMerge(e))return e.isMerged=!0,this.treeElement.title=this.treeElement.title+"/"+e.title,e.treeElement=this.treeElement,e.updateTitle(),void this.treeElement.setNode(e);if(2===i.length&&(t=i[0]!==e?i[0]:i[1]),t&&t.isMerged){t.isMerged=!1;const e=[];e.push(this);let o=this;for(;o&&o.isMerged;)o=o.parent,o&&e.push(o);e.reverse();const n=e.map((e=>e.title)).join("/"),r=[];o=t;do{r.push(o),i=o.children(),o=1===i.length?i[0]:null}while(o&&o.isMerged);if(!this.isPopulated()){this.treeElement.title=n,this.treeElement.setNode(this);for(let e=0;e<r.length;++e)r[e].treeElement=null,r[e].isMerged=!1;return void this.updateTitle()}const s=this.treeElement,a=this.createTreeElement(n,this);for(let t=0;t<e.length;++t)e[t].treeElement=a,e[t].updateTitle();s.parent&&this.navigatorView.appendChild(s.parent,a),s.setNode(r[r.length-1]),s.title=r.map((e=>e.title)).join("/"),s.parent&&this.navigatorView.removeChild(s.parent,s),this.navigatorView.appendChild(this.treeElement,s),s.expanded&&a.expand(),this.updateTitle()}this.isPopulated()&&this.navigatorView.appendChild(this.treeElement,e.treeNode())}willRemoveChild(e){const t=e;!t.isMerged&&this.isPopulated()&&this.treeElement&&t.treeElement&&this.navigatorView.removeChild(this.treeElement,t.treeElement)}}class St extends gt{project;title;hoverCallback;treeElement;constructor(e,t,i,o,n,r){super(e,i,o,r),this.project=t,this.title=n,this.populate()}setHoverCallback(e){this.hoverCallback=e}treeNode(){return this.treeElement||(this.treeElement=new ht(this.navigatorView,this.type,this.title,this.hoverCallback),this.treeElement.setNode(this)),this.treeElement}onattach(){this.updateTitle()}updateTitle(){if(!this.treeElement||!this.project||this.project.type()!==f.Workspace.projectTypes.FileSystem)return;const e=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemPath(this.project.id()),t=this.treeElement.listItemElement.classList.contains("has-mapped-files"),i=h.Persistence.PersistenceImpl.instance().filePathHasBindings(e);t!==i&&(this.treeElement.listItemElement.classList.toggle("has-mapped-files",i),this.treeElement.childrenListElement.hasFocus()||(i?this.treeElement.expand():this.treeElement.collapse()))}setTitle(e){this.title=e,this.treeElement&&(this.treeElement.title=this.title)}}var vt=Object.freeze({__proto__:null,Types:ct,NavigatorView:dt,NavigatorFolderTreeElement:ht,NavigatorSourceTreeElement:pt,NavigatorTreeNode:gt,NavigatorRootTreeNode:mt,NavigatorUISourceCodeTreeNode:bt,NavigatorFolderTreeNode:ft,NavigatorGroupTreeNode:St});const Ct=new CSSStyleSheet;Ct.replaceSync('.paused-message{align-self:center;width:fit-content}.scripts-debug-toolbar{position:absolute;top:0;width:100%;background-color:var(--app-color-toolbar-background);border-bottom:1px solid var(--sys-color-divider);overflow:hidden;z-index:1}.scripts-debug-toolbar-drawer{flex:0 0 52px;transition:margin-top 0.1s ease-in-out;margin-top:-26px;padding-top:25px;background-color:var(--sys-color-cdt-base-container);overflow:hidden;white-space:nowrap}.scripts-debug-toolbar-drawer.expanded{margin-top:0}.scripts-debug-toolbar-drawer > [is="dt-checkbox"]{display:none;padding-left:3px;height:28px}.scripts-debug-toolbar-drawer.expanded > [is="dt-checkbox"]{display:flex}.cursor-auto{cursor:auto}.navigator-tabbed-pane{background-color:var(--sys-color-cdt-base-container)}\n/*# sourceURL=sourcesPanel.css */\n');class wt{sourcesView;entries=[];current=-1;revealing=!1;constructor(e){this.sourcesView=e}trackSourceFrameCursorJumps(e){e.addEventListener("EditorUpdate",(t=>this.onEditorUpdate(t.data,e)))}onEditorUpdate(e,t){e.docChanged&&this.mapEntriesFor(t.uiSourceCode(),e.changes);const i=e.startState.selection.main,o=e.state.selection.main;!this.revealing&&i.anchor!==o.anchor&&e.transactions.some((e=>Boolean(e.isUserEvent("select.pointer")||e.isUserEvent("select.reveal")||e.isUserEvent("select.search"))))&&(this.updateCurrentState(t.uiSourceCode(),i.head),this.entries.length>this.current+1&&(this.entries.length=this.current+1),this.entries.push(new It(t.uiSourceCode(),o.head)),this.current++,this.entries.length>20&&(this.entries.shift(),this.current--))}updateCurrentState(e,t){if(!this.revealing){const i=this.current>=0?this.entries[this.current]:null;i?.matches(e)&&(i.position=t)}}mapEntriesFor(e,t){for(const i of this.entries)i.matches(e)&&(i.position=t.mapPos(i.position))}reveal(e){const t=f.Workspace.WorkspaceImpl.instance().uiSourceCode(e.projectId,e.url);t&&(this.revealing=!0,this.sourcesView.showSourceLocation(t,e.position,!1,!0),this.revealing=!1)}rollback(){this.current>0&&(this.current--,this.reveal(this.entries[this.current]))}rollover(){this.current<this.entries.length-1&&(this.current++,this.reveal(this.entries[this.current]))}removeHistoryForSourceCode(e){for(let t=this.entries.length-1;t>=0;t--)this.entries[t].matches(e)&&(this.entries.splice(t,1),this.current>=t&&this.current--)}}class It{projectId;url;position;constructor(e,t){this.projectId=e.project().id(),this.url=e.url(),this.position=t}matches(e){return this.url===e.url()&&this.projectId===e.project().id()}}var yt=Object.freeze({__proto__:null,HistoryDepth:20,EditingLocationHistoryManager:wt});const xt=new CSSStyleSheet;xt.replaceSync("#sources-panel-sources-view{--override-highlight-animation-10pc-background-color:rgb(158 54 153);--override-highlight-animation-10pc-foreground-color:rgb(255 255 255);flex:auto;position:relative}#sources-panel-sources-view .sources-toolbar{display:flex;flex:0 0 27px;background-color:var(--sys-color-cdt-base-container);border-top:1px solid var(--sys-color-divider);overflow:hidden;z-index:0}.sources-toolbar .toolbar{cursor:default}.source-frame-debugger-script{--override-debugger-background-tint:rgb(255 255 194/50%);background-color:var(--override-debugger-background-tint)}.-theme-with-dark-background .source-frame-debugger-script{--override-debugger-background-tint:rgb(61 61 0/50%)}\n/*# sourceURL=sourcesView.css */\n");const kt=["application/javascript","application/json","application/manifest+json","text/css","text/html","text/javascript"],Tt={ms:"ms",mb:"MB",kb:"kB"},Et=e.i18n.registerUIStrings("panels/sources/ProfilePlugin.ts",Tt),Lt=e.i18n.getLocalizedString.bind(void 0,Et);class Mt extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";let t=this.value;const i=l.NumberUtilities.clamp(Math.log10(1+.002*t)/5,.02,1);let o,n;e.style.backgroundColor=`hsla(217, 100%, 70%, ${i.toFixed(3)})`,t/=1e3,t>=1e3?(o=Lt(Tt.mb),t/=1e3,n=t>=20?0:1):(o=Lt(Tt.kb),n=0),e.textContent=t.toFixed(n);const r=e.appendChild(document.createElement("span"));return r.className="cm-units",r.textContent=o,e}}class Pt extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";const t=l.NumberUtilities.clamp(Math.log10(1+10*this.value)/5,.02,1);e.textContent=this.value.toFixed(1),e.style.backgroundColor=`hsla(44, 100%, 50%, ${t.toFixed(3)})`;const i=document.createElement("span");return i.className="cm-units",i.textContent=Lt(Tt.ms),e.appendChild(i),e}}function Ft(e,t,i){const o="performance"===i?Pt:Mt,r=[];for(const[i,n]of e)if(i<=t.doc.lines){const{from:e}=t.doc.line(i);r.push(new o(n).range(e))}return n.RangeSet.of(r,!0)}const Dt=e=>class extends he{updateEffect=n.StateEffect.define();field;gutter;compartment=new n.Compartment;constructor(t){super(t),this.field=n.StateField.define({create:()=>n.RangeSet.empty,update:(t,i)=>i.effects.reduce(((t,o)=>o.is(this.updateEffect)?Ft(o.value,i.state,e):t),t.map(i.changes))}),this.gutter=n.gutter({markers:e=>e.state.field(this.field),class:`cm-${e}Gutter`})}static accepts(e){return e.contentType().hasScripts()}getLineMap(){return this.uiSourceCode.getDecorationData(e)}editorExtension(){const t=this.getLineMap();return this.compartment.of(t?[this.field.init((i=>Ft(t,i,e))),this.gutter,Nt]:[])}decorationChanged(e,t){const i=Boolean(t.state.field(this.field,!1)),o=this.getLineMap();o?i?t.dispatch({effects:this.updateEffect.of(o)}):t.dispatch({effects:this.compartment.reconfigure([this.field.init((t=>Ft(o,t,e))),this.gutter,Nt])}):i&&t.dispatch({effects:this.compartment.reconfigure([])})}},Nt=n.EditorView.baseTheme({".cm-performanceGutter":{width:"60px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-memoryGutter":{width:"48px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-profileMarker":{textAlign:"right",paddingRight:"3px"},".cm-profileMarker .cm-units":{color:"var(--sys-color-token-subtle)",fontSize:"75%",marginLeft:"3px"}}),At=Dt("memory"),Ut=Dt("performance"),Rt={fromS:"(From {PH1})",sourceMappedFromS:"(Source mapped from {PH1})"},Bt=e.i18n.registerUIStrings("panels/sources/ResourceOriginPlugin.ts",Rt),jt=e.i18n.getLocalizedString.bind(void 0,Bt);class Vt extends he{static accepts(e){const t=e.contentType();return t.hasScripts()||t.isFromSourceMap()}rightToolbarItems(){const i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();if(this.uiSourceCode.contentType().isFromSourceMap()){const o=[];for(const e of i.scriptsForUISourceCode(this.uiSourceCode)){const t=i.uiSourceCodeForScript(e);if(!t)continue;const n=t.url(),r=u.ResourceUtils.displayNameForURL(n),s=jt(Rt.sourceMappedFromS,{PH1:r});o.push(F.Linkifier.Linkifier.linkifyRevealable(t,r,n,s))}for(const e of u.SASSSourceMapping.SASSSourceMapping.uiSourceOrigin(this.uiSourceCode))o.push(F.Linkifier.Linkifier.linkifyURL(e));if(0===o.length)return[];const n=document.createElement("span");return o.forEach(((e,t)=>{t>0&&n.append(", "),n.append(e)})),[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(Bt,Rt.fromS,{PH1:n}))]}for(const o of i.scriptsForUISourceCode(this.uiSourceCode))if(o.originStackTrace){const i=Wt.linkifyStackTraceTopFrame(o.debuggerModel.target(),o.originStackTrace);return[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(Bt,Rt.fromS,{PH1:i}))]}return[]}}const Wt=new F.Linkifier.Linkifier;var Ot=Object.freeze({__proto__:null,ResourceOriginPlugin:Vt,linkifier:Wt});const Ht={enter:"⌘+Enter",ctrlenter:"Ctrl+Enter"},_t=e.i18n.registerUIStrings("panels/sources/SnippetsPlugin.ts",Ht),zt=e.i18n.getLocalizedString.bind(void 0,_t);class qt extends he{static accepts(e){return T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e)}rightToolbarItems(){const e=t.Toolbar.Toolbar.createActionButtonForId("debugger.run-snippet");return e.setText(c.Platform.isMac()?zt(Ht.enter):zt(Ht.ctrlenter)),[e]}editorExtension(){return s.JavaScript.completion()}}var $t=Object.freeze({__proto__:null,SnippetsPlugin:qt});class Gt extends(i.ObjectWrapper.eventMixin(m.SourceFrame.SourceFrameImpl)){uiSourceCodeInternal;muteSourceCodeEvents;persistenceBinding;uiSourceCodeEventListeners;messageAndDecorationListeners;boundOnBindingChanged;plugins=[];errorPopoverHelper;#p=!1;constructor(e){super((()=>this.workingCopy())),this.element.setAttribute("jslog",`${a.textField()}`),this.uiSourceCodeInternal=e,this.muteSourceCodeEvents=!1,this.persistenceBinding=h.Persistence.PersistenceImpl.instance().binding(e),this.uiSourceCodeEventListeners=[],this.messageAndDecorationListeners=[],this.boundOnBindingChanged=this.onBindingChanged.bind(this),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").addChangeListener(this.onNetworkPersistenceChanged,this),this.errorPopoverHelper=new t.PopoverHelper.PopoverHelper(this.textEditor.editor.contentDOM,this.getErrorPopoverContent.bind(this),"sources.error"),this.errorPopoverHelper.setHasPadding(!0),this.errorPopoverHelper.setTimeout(100,100),this.initializeUISourceCode()}async workingCopy(){return this.uiSourceCodeInternal.isDirty()?{content:this.uiSourceCodeInternal.workingCopy(),isEncoded:!1}:this.uiSourceCodeInternal.requestContent()}editorConfiguration(e){return[super.editorConfiguration(e),(t=this.allMessages(),[ni.init((e=>oi.create(Zt.create(t),e.doc))),si]),Xt.of(this.plugins.map((e=>e.editorExtension())))];var t}onFocus(){super.onFocus(),t.Context.Context.instance().setFlavor(Gt,this)}onBlur(){super.onBlur(),t.Context.Context.instance().setFlavor(Gt,null)}installMessageAndDecorationListeners(){if(this.persistenceBinding){const e=this.persistenceBinding.network,t=this.persistenceBinding.fileSystem;this.messageAndDecorationListeners=[e.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),e.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),e.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this),t.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),t.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this)]}else this.messageAndDecorationListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this)]}uiSourceCode(){return this.uiSourceCodeInternal}setUISourceCode(e){const t=e.contentLoaded()?Promise.resolve():e.requestContent(),i=this.uiSourceCodeInternal;t.then((async()=>{this.uiSourceCodeInternal===i&&(this.unloadUISourceCode(),this.uiSourceCodeInternal=e,e.workingCopy()!==this.textEditor.state.doc.toString()?await this.setDeferredContent(Promise.resolve(e.workingCopyContent())):this.reloadPlugins(),this.initializeUISourceCode())}),console.error)}unloadUISourceCode(){i.EventTarget.removeEventListeners(this.messageAndDecorationListeners),i.EventTarget.removeEventListeners(this.uiSourceCodeEventListeners),this.uiSourceCodeInternal.removeWorkingCopyGetter(),h.Persistence.PersistenceImpl.instance().unsubscribeFromBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged)}initializeUISourceCode(){this.uiSourceCodeEventListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.onWorkingCopyChanged,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.onWorkingCopyCommitted,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.TitleChanged,this.onTitleChanged,this)],h.Persistence.PersistenceImpl.instance().subscribeForBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged),this.installMessageAndDecorationListeners(),this.updateStyle();const e=kt.includes(this.contentType)&&!this.uiSourceCodeInternal.project().canSetFileContent()&&null===h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=!this.uiSourceCodeInternal.contentType().isFromSourceMap();this.setCanPrettyPrint(e,t)}wasShown(){super.wasShown(),this.setEditable(this.canEditSourceInternal())}willHide(){for(const e of this.plugins)e.willHide();super.willHide(),t.Context.Context.instance().setFlavor(Gt,null),this.uiSourceCodeInternal.removeWorkingCopyGetter()}getContentType(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network.mimeType():this.uiSourceCodeInternal.mimeType();return i.ResourceType.ResourceType.simplifyContentType(t)}canEditSourceInternal(){return!this.hasLoadError()&&(!this.uiSourceCodeInternal.editDisabled()&&("application/wasm"!==this.uiSourceCodeInternal.mimeType()&&(!!h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal)||(!!this.uiSourceCodeInternal.project().canSetFileContent()||!this.uiSourceCodeInternal.project().isServiceProject()&&(!(this.uiSourceCodeInternal.project().type()!==f.Workspace.projectTypes.Network||!h.NetworkPersistenceManager.NetworkPersistenceManager.instance().active())||(!this.pretty||!this.uiSourceCodeInternal.contentType().hasScripts())&&this.uiSourceCodeInternal.contentType()!==i.ResourceType.resourceTypes.Document)))))}onNetworkPersistenceChanged(){this.setEditable(this.canEditSourceInternal())}commitEditing(){this.uiSourceCodeInternal.isDirty()&&(this.muteSourceCodeEvents=!0,this.uiSourceCodeInternal.commitWorkingCopy(),this.muteSourceCodeEvents=!1)}async setContent(e){this.disposePlugins(),this.loadPlugins(),await super.setContent(e);for(const e of this.plugins)e.editorInitialized(this.textEditor);this.#g(),i.EventTarget.fireEvent("source-file-loaded",this.uiSourceCodeInternal.displayName(!0))}createMessage(e){const{lineNumber:t,columnNumber:i}=this.uiLocationToEditorLocation(e.lineNumber(),e.columnNumber());return new Yt(e,t,i)}allMessages(){return(null!==this.persistenceBinding?[...this.persistenceBinding.network.messages(),...this.persistenceBinding.fileSystem.messages()]:[...this.uiSourceCodeInternal.messages()]).map((e=>this.createMessage(e)))}onTextChanged(){const e=this.pretty;super.onTextChanged(),this.errorPopoverHelper.hidePopover(),Wi.instance().updateLastModificationTime(),this.muteSourceCodeEvents=!0,this.isClean()?this.uiSourceCodeInternal.resetWorkingCopy():this.uiSourceCodeInternal.setWorkingCopyGetter((()=>this.textEditor.state.sliceDoc())),this.muteSourceCodeEvents=!1,e!==this.pretty&&(this.updateStyle(),this.reloadPlugins())}onWorkingCopyChanged(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCodeInternal.workingCopyContent())}onWorkingCopyCommitted(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCode().workingCopyContent()),this.contentCommitted(),this.updateStyle()}reloadPlugins(){this.disposePlugins(),this.loadPlugins();const e=this.textEditor;e.dispatch({effects:Xt.reconfigure(this.plugins.map((e=>e.editorExtension())))});for(const t of this.plugins)t.editorInitialized(e)}onTitleChanged(){this.updateLanguageMode("").then((()=>this.reloadPlugins()),console.error)}loadPlugins(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network:this.uiSourceCodeInternal;for(const e of[Oe,Qi,qt,Vt,fe,At,Ut])e.accepts(t)&&this.plugins.push(new e(t,this));this.dispatchEventToListeners("ToolbarItemsChanged")}disposePlugins(){for(const e of this.plugins)e.dispose();this.plugins=[]}onBindingChanged(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal);e!==this.persistenceBinding&&(this.unloadUISourceCode(),this.persistenceBinding=e,this.initializeUISourceCode(),this.reloadMessages(),this.reloadPlugins())}reloadMessages(){const e=this.allMessages(),{editor:t}=this.textEditor;t.dispatch({effects:ei.of(Zt.create(e))})}updateStyle(){this.setEditable(this.canEditSourceInternal())}maybeSetContent(e){this.textEditor.state.doc.toString()!==e.content&&this.setDeferredContent(Promise.resolve(e))}populateTextAreaContextMenu(e,t,i){super.populateTextAreaContextMenu(e,t,i),e.appendApplicableItems(this.uiSourceCodeInternal);const o=this.editorLocationToUILocation(t,i);e.appendApplicableItems(new f.UISourceCode.UILocation(this.uiSourceCodeInternal,o.lineNumber,o.columnNumber));for(const o of this.plugins)o.populateTextAreaContextMenu(e,t,i)}populateLineGutterContextMenu(e,t){super.populateLineGutterContextMenu(e,t);for(const i of this.plugins)i.populateLineGutterContextMenu(e,t)}dispose(){this.errorPopoverHelper.dispose(),this.disposePlugins(),this.unloadUISourceCode(),this.textEditor.editor.destroy(),this.detach(),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").removeChangeListener(this.onNetworkPersistenceChanged,this)}onMessageAdded(e){const{editor:t}=this.textEditor,i=t.state.field(ni,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ei.of(i.messages.add(o))})}}onMessageRemoved(e){const{editor:t}=this.textEditor,i=t.state.field(ni,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ei.of(i.messages.remove(o))})}}onDecorationChanged(e){for(const t of this.plugins)t.decorationChanged(e.data,this.textEditor)}async toolbarItems(){const e=await super.toolbarItems(),i=[];for(const t of this.plugins)e.push(...t.leftToolbarItems()),i.push(...t.rightToolbarItems());return i.length?[...e,new t.Toolbar.ToolbarSeparator(!0),...i]:e}getErrorPopoverContent(e){const t=e,i=e.target,o=i.enclosingNodeOrSelfWithClass("cm-messageIcon-error")||i.enclosingNodeOrSelfWithClass("cm-messageIcon-issue");if(!o)return null;const n=this.textEditor.state.field(ni,!1);if(!n||0===n.messages.rows.length)return null;const{editor:r}=this.textEditor,s=r.posAtCoords(t);if(null===s)return null;const a=r.state.doc.lineAt(s);if(s!==a.to)return null;const c=n.messages.rows.find((e=>e[0].lineNumber()===a.number-1));if(!c)return null;const l=o.classList.contains("cm-messageIcon-issue"),d=c.filter((e=>"Issue"===e.level()===l));if(!d.length)return null;const u=o?o.boxInWindow():new AnchorBox(t.clientX,t.clientY,1,1),h=function(e){const t=[];for(let i=0;i<e.length;i++){t[i]=0;for(let o=0;o<=i;o++)if(e[o].isEqual(e[i])){t[o]++;break}}return t}(d),p=document.createElement("div");p.classList.add("text-editor-messages-description-container");for(let e=0;e<d.length;e++)h[e]&&p.appendChild(ri(d[e],h[e]));return{box:u,hide(){},show:async e=>(e.contentElement.append(p),!0)}}#g(){if(this.#p)return;this.#p=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCodeInternal.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCodeInternal.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCodeInternal.content()));c.userMetrics.sourcesPanelFileOpened(t)}}function Kt(e){return"Error"===e?{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}:"Warning"===e?{color:"var(--icon-warning)",width:"18px",height:"14px",iconName:"warning-filled"}:"Issue"===e?{color:"var(--icon-warning)",width:"17px",height:"14px",iconName:"issue-exclamation-filled"}:{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}}function Jt(e,t){const i={Issue:2,Warning:3,Error:4};return i[e.level()]-i[t.level()]}const Xt=new n.Compartment;class Yt{origin;#m;#b;constructor(e,t,i){this.origin=e,this.#m=t,this.#b=i}level(){return this.origin.level()}text(){return this.origin.text()}clickHandler(){return this.origin.clickHandler()}lineNumber(){return this.#m}columnNumber(){return this.#b}isEqual(e){return this.origin.isEqual(e.origin)}}function Qt(e,t){const i=t.lineNumber();let o=0;for(;o<e.length;o++){const n=e[o][0].lineNumber()-i;if(0===n)return e[o]=e[o].concat(t),e;if(n>0)break}return e.splice(o,0,[t]),e}class Zt{rows;constructor(e){this.rows=e}static create(e){const t=[];for(const i of e)Qt(t,i);return new Zt(t)}remove(e){const t=this.rows.slice();return function(e,t){for(let i=0;i<e.length;i++)if(e[i][0].lineNumber()===t.lineNumber()){const o=e[i].filter((e=>!e.isEqual(t)));o.length?e[i]=o:e.splice(i,1);break}}(t,e),new Zt(t)}add(e){return new Zt(Qt(this.rows.slice(),e))}}const ei=n.StateEffect.define(),ti=n.Decoration.mark({class:"cm-waveUnderline"});class ii extends n.WidgetType{messages;constructor(e){super(),this.messages=e}eq(e){return e.messages===this.messages}toDOM(){const e=document.createElement("span");e.classList.add("cm-messageIcon");const t=this.messages.filter((e=>"Issue"!==e.level()));if(t.length){const i=t.sort(Jt)[t.length-1],o=e.appendChild(new r.Icon.Icon);o.data=Kt(i.level()),o.classList.add("cm-messageIcon-error")}const i=this.messages.find((e=>"Issue"===e.level()));if(i){const t=e.appendChild(new r.Icon.Icon);t.data=Kt("Issue"),t.classList.add("cm-messageIcon-issue"),t.addEventListener("click",(()=>(i.clickHandler()||Math.min)()))}return e}ignoreEvents(){return!0}}class oi{messages;decorations;constructor(e,t){this.messages=e,this.decorations=t}static create(e,t){const i=new n.RangeSetBuilder;for(const o of e.rows){const e=t.line(Math.min(t.lines,o[0].lineNumber()+1)),r=o.reduce(((e,t)=>Math.min(e,t.columnNumber()||0)),e.length);r<e.length&&i.add(e.from+r,e.to,ti),i.add(e.to,e.to,n.Decoration.widget({side:1,widget:new ii(o)}))}return new oi(e,i.finish())}apply(e){let t=this;e.docChanged&&(t=new oi(this.messages,this.decorations.map(e.changes)));for(const i of e.effects)i.is(ei)&&(t=oi.create(i.value,e.state.doc));return t}}const ni=n.StateField.define({create:e=>oi.create(new Zt([]),e.doc),update:(e,t)=>e.apply(t),provide:e=>n.Prec.lowest(n.EditorView.decorations.from(e,(e=>e.decorations)))});function ri(e,t){const i=document.createElement("div");if(i.classList.add("text-editor-row-message"),i.style.display="flex",i.style.alignItems="center",i.style.gap="4px",1===t){const t=i.appendChild(new r.Icon.Icon);t.data=function(e){return e.origin instanceof M.SourceFrameIssuesManager.IssueMessage?{...P.IssueCounter.getIssueKindIconData(e.origin.getIssueKind()),width:"12px",height:"12px"}:Kt(e.level())}(e),t.classList.add("text-editor-row-message-icon"),t.addEventListener("click",(()=>(e.clickHandler()||Math.min)()))}else{const o=document.createElement("span",{is:"dt-small-bubble"});o.textContent=String(t),o.classList.add("text-editor-row-message-repeat-count"),o.style.flexShrink="0",i.appendChild(o),o.type=function(e){switch(e){case"Error":return"error";case"Warning":case"Issue":return"warning"}}(e.level())}const o=i.createChild("div");for(const t of e.text().split("\n"))o.createChild("div").textContent=t;return i}const si=n.EditorView.baseTheme({".cm-tooltip-message":{padding:"4px"},".cm-waveUnderline":{backgroundImage:"var(--image-file-errorWave)",backgroundRepeat:"repeat-x",backgroundPosition:"bottom",paddingBottom:"1px"},".cm-messageIcon":{cursor:"pointer","& > *":{verticalAlign:"text-bottom",marginLeft:"2px"}},".cm-messageIcon-issue, .cm-messageIcon-error":{marginTop:"-1px",marginBottom:"-1px"}});var ai=Object.freeze({__proto__:null,UISourceCodeFrame:Gt});const ci={areYouSureYouWantToCloseUnsaved:"Are you sure you want to close unsaved file: {PH1}?",unableToLoadThisContent:"Unable to load this content.",changesToThisFileWereNotSavedTo:"Changes to this file were not saved to file system."},li=e.i18n.registerUIStrings("panels/sources/TabbedEditorContainer.ts",ci),di=e.i18n.getLocalizedString.bind(void 0,li);let ui=0;class hi extends i.ObjectWrapper.ObjectWrapper{delegate;tabbedPane;tabIds;files;previouslyViewedFilesSetting;history;uriToUISourceCode;idToUISourceCode;currentFileInternal;currentView;scrollTimer;reentrantShow;constructor(e,i,o,n){super(),this.delegate=e,this.tabbedPane=new t.TabbedPane.TabbedPane,this.tabbedPane.setPlaceholderElement(o,n),this.tabbedPane.setTabDelegate(new fi(this)),this.tabbedPane.setCloseableTabs(!0),this.tabbedPane.setAllowTabReorder(!0,!0),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabClosed,this.tabClosed,this),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabSelected,this.tabSelected,this),this.tabbedPane.headerElement().setAttribute("jslog",`${a.toolbar("top")}`),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingCreated,this.onBindingCreated,this),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingRemoved,this.onBindingRemoved,this),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("RequestsForHeaderOverridesFileChanged",this.#d,this),this.tabIds=new Map,this.files=new Map,this.previouslyViewedFilesSetting=i,this.history=bi.fromObject(this.previouslyViewedFilesSetting.get()),this.uriToUISourceCode=new Map,this.idToUISourceCode=new Map,this.reentrantShow=!1}onBindingCreated(e){const t=e.data;this.updateFileTitle(t.fileSystem);const i=this.tabIds.get(t.network);let o=this.tabIds.get(t.fileSystem);const n=this.currentFileInternal===t.network,r=gi(t.network),s=this.history.selectionRange(r),a=this.history.scrollLineNumber(r);if(this.history.remove(r),i){if(!o){const e=this.tabbedPane.tabView(i),n=this.tabbedPane.tabIndex(i);if(e instanceof Gt)this.delegate.recycleUISourceCodeFrame(e,t.fileSystem),o=this.appendFileTab(t.fileSystem,!1,n,e);else{o=this.appendFileTab(t.fileSystem,!1,n);const e=this.tabbedPane.tabView(o);this.restoreEditorProperties(e,s,a)}}this.closeTabs([i],!0),n&&this.tabbedPane.selectTab(o,!1),this.updateHistory()}}#d(e){this.updateFileTitle(e.data)}onBindingRemoved(e){const t=e.data;this.updateFileTitle(t.fileSystem)}get view(){return this.tabbedPane}get visibleView(){return this.tabbedPane.visibleView}fileViews(){return this.tabbedPane.tabViews()}leftToolbar(){return this.tabbedPane.leftToolbar()}rightToolbar(){return this.tabbedPane.rightToolbar()}show(e){this.tabbedPane.show(e)}showFile(e){const o=h.Persistence.PersistenceImpl.instance().binding(e);e=o?o.fileSystem:e;const n=t.Context.Context.instance().flavor(Ii);if(n?.currentSourceFrame()?.contentSet&&this.currentFileInternal===e&&n?.currentUISourceCode()===e)i.EventTarget.fireEvent("source-file-loaded",e.displayName(!0));else{if(e.project().type()===f.Workspace.projectTypes.Debugger){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&t.isInlineScript()&&!t.hasSourceURL&&(t.isModule?c.userMetrics.vmInlineScriptContentShown(0):c.userMetrics.vmInlineScriptContentShown(1))}this.innerShowFile(e,!0)}}closeFile(e){const t=this.tabIds.get(e);t&&this.closeTabs([t])}closeAllFiles(){this.closeTabs(this.tabbedPane.tabIds())}historyUISourceCodes(){const e=[];for(const{url:t,resourceType:i}of this.history.keys()){const o=this.uriToUISourceCode.get(t);void 0!==o&&o.contentType()===i&&e.push(o)}return e}selectNextTab(){this.tabbedPane.selectNextTab()}selectPrevTab(){this.tabbedPane.selectPrevTab()}addViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.addEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.addEventListener("EditorScroll",this.onScrollChanged,this))}removeViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.removeEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.removeEventListener("EditorScroll",this.onScrollChanged,this))}onScrollChanged(){if(this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=window.setTimeout((()=>this.previouslyViewedFilesSetting.set(this.history.toObject())),100),this.currentFileInternal)){const{editor:e}=this.currentView.textEditor,t=e.lineBlockAtHeight(e.scrollDOM.getBoundingClientRect().top-e.documentTop),i=e.state.doc.lineAt(t.from).number-1;this.history.updateScrollLineNumber(gi(this.currentFileInternal),i)}}onEditorUpdate({data:e}){if(e.docChanged||e.selectionSet){const{main:t}=e.state.selection,i=e.state.doc.lineAt(t.from),o=e.state.doc.lineAt(t.to),n=new g.TextRange.TextRange(i.number-1,t.from-i.from,o.number-1,t.to-o.from);this.currentFileInternal&&this.history.updateSelectionRange(gi(this.currentFileInternal),n),this.previouslyViewedFilesSetting.set(this.history.toObject()),this.currentFileInternal&&k.ExtensionServer.ExtensionServer.instance().sourceSelectionChanged(this.currentFileInternal.url(),n)}}innerShowFile(e,t){if(this.reentrantShow)return;const i=this.canonicalUISourceCode(e),o=h.Persistence.PersistenceImpl.instance().binding(e);if(e=o?o.fileSystem:e,this.currentFileInternal===e)return;this.removeViewListeners(),this.currentFileInternal=e;try{this.reentrantShow=!0;const e=this.tabIds.get(i)||this.appendFileTab(i,t);this.tabbedPane.selectTab(e,t)}finally{this.reentrantShow=!1}t&&this.editorSelectedByUserAction();const n=this.currentView;this.currentView=this.visibleView,this.addViewListeners(),this.currentView instanceof Gt&&this.currentView.uiSourceCode()!==e&&(this.delegate.recycleUISourceCodeFrame(this.currentView,e),e.project().type()!==f.Workspace.projectTypes.FileSystem&&e.disableEdit());const r={currentFile:this.currentFileInternal,currentView:this.currentView,previousView:n,userGesture:t};this.dispatchEventToListeners("EditorSelected",r)}titleForFile(e){let t=l.StringUtilities.trimMiddle(e.displayName(!0),30);return e.isDirty()&&(t+="*"),t}maybeCloseTab(e,t){const i=this.files.get(e);if(!i)return!1;return!(i.isDirty()&&i.project().canSetFileContent()&&!confirm(di(ci.areYouSureYouWantToCloseUnsaved,{PH1:i.name()})))&&(i.resetWorkingCopy(),t&&this.tabbedPane.selectTab(t,!0),this.tabbedPane.closeTab(e,!0),!0)}closeTabs(e,t){const i=[],o=[];for(let n=0;n<e.length;++n){const r=e[n],s=this.files.get(r);s&&(!t&&s.isDirty()?i.push(r):o.push(r))}i.length&&this.tabbedPane.selectTab(i[0],!0),this.tabbedPane.closeTabs(o,!0);for(let e=0;e<i.length;++e){const t=e+1<i.length?i[e+1]:null;if(!this.maybeCloseTab(i[e],t))break}}onContextMenu(e,t){const i=this.files.get(e);i&&t.appendApplicableItems(i)}canonicalUISourceCode(e){const t=this.idToUISourceCode.get(e.canononicalScriptId());return t||(this.idToUISourceCode.set(e.canononicalScriptId(),e),this.uriToUISourceCode.set(e.url(),e),e)}addUISourceCode(e){const t=this.canonicalUISourceCode(e),i=t!==e,o=h.Persistence.PersistenceImpl.instance().binding(t);if(e=o?o.fileSystem:t,i&&e.project().type()!==f.Workspace.projectTypes.FileSystem&&e.disableEdit(),this.currentFileInternal?.canononicalScriptId()===e.canononicalScriptId())return;const n=this.history.index(gi(e));if(-1===n)return;if(this.tabIds.has(e)||this.appendFileTab(e,!1),!n)return void this.innerShowFile(e,!1);if(!this.currentFileInternal)return;const r=T.ScriptSnippetFileSystem.isSnippetsUISourceCode(this.currentFileInternal),s=T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e);this.history.index(gi(this.currentFileInternal))&&r&&!s&&this.innerShowFile(e,!1)}removeUISourceCode(e){this.removeUISourceCodes([e])}removeUISourceCodes(e){const t=[];for(const i of e){const e=this.tabIds.get(i);e&&t.push(e),this.uriToUISourceCode.get(i.url())===i&&this.uriToUISourceCode.delete(i.url()),this.idToUISourceCode.get(i.canononicalScriptId())===i&&this.idToUISourceCode.delete(i.canononicalScriptId())}this.tabbedPane.closeTabs(t)}editorClosedByUserAction(e){this.history.remove(gi(e)),this.updateHistory()}editorSelectedByUserAction(){this.updateHistory()}updateHistory(){const e=[];for(const t of this.tabbedPane.lastOpenedTabIds(pi)){const i=this.files.get(t);void 0!==i&&e.push(gi(i))}this.history.update(e),this.previouslyViewedFilesSetting.set(this.history.toObject())}tooltipForFile(e){return(e=h.Persistence.PersistenceImpl.instance().network(e)||e).url()}appendFileTab(e,t,i,o){const n=o||this.delegate.viewForFile(e),r=this.titleForFile(e),s=this.tooltipForFile(e),a=this.generateTabId();if(this.tabIds.set(e,a),this.files.set(a,e),!o){const t=this.history.selectionRange(gi(e)),i=this.history.scrollLineNumber(gi(e));this.restoreEditorProperties(n,t,i)}return this.tabbedPane.appendTab(a,r,n,s,t,void 0,void 0,i),this.updateFileTitle(e),this.addUISourceCodeListeners(e),e.loadError()?this.addLoadErrorIcon(a):e.contentLoaded()||e.requestContent().then((t=>{e.loadError()&&this.addLoadErrorIcon(a)})),a}addLoadErrorIcon(e){const i=new r.Icon.Icon;i.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(i,di(ci.unableToLoadThisContent)),this.tabbedPane.tabView(e)&&this.tabbedPane.setTabIcon(e,i)}restoreEditorProperties(e,t,i){const o=e instanceof m.SourceFrame.SourceFrameImpl?e:null;o&&(t&&o.setSelection(t),"number"==typeof i&&o.scrollToLine(i))}tabClosed(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);this.currentFileInternal&&this.currentFileInternal.canononicalScriptId()===o?.canononicalScriptId()&&(this.removeViewListeners(),this.currentView=null,this.currentFileInternal=null),o&&this.tabIds.delete(o),this.files.delete(t),o&&(this.removeUISourceCodeListeners(o),this.dispatchEventToListeners("EditorClosed",o),i&&this.editorClosedByUserAction(o))}tabSelected(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);o&&this.innerShowFile(o,i)}addUISourceCodeListeners(e){e.addEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}removeUISourceCodeListeners(e){e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}updateFileTitle(e){const i=this.tabIds.get(e);if(i){const o=this.titleForFile(e),n=this.tooltipForFile(e);this.tabbedPane.changeTabTitle(i,o,n);let s=null;e.loadError()?(s=new r.Icon.Icon,s.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,di(ci.unableToLoadThisContent))):h.Persistence.PersistenceImpl.instance().hasUnsavedCommittedChanges(e)?(s=new r.Icon.Icon,s.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,di(ci.changesToThisFileWereNotSavedTo))):s=h.PersistenceUtils.PersistenceUtils.iconForUISourceCode(e),this.tabbedPane.setTabIcon(i,s)}}uiSourceCodeTitleChanged(e){const t=e.data;this.updateFileTitle(t),this.updateHistory();for(const[e,i]of this.uriToUISourceCode)i===t&&e!==i.url()&&this.uriToUISourceCode.delete(e);for(const[e,i]of this.idToUISourceCode)i===t&&e!==i.canononicalScriptId()&&this.idToUISourceCode.delete(e);this.canonicalUISourceCode(t)}uiSourceCodeWorkingCopyChanged(e){const t=e.data;this.updateFileTitle(t)}uiSourceCodeWorkingCopyCommitted(e){const t=e.data.uiSourceCode;this.updateFileTitle(t)}generateTabId(){return"tab-"+ui++}currentFile(){return this.currentFileInternal||null}}const pi=30;function gi(e){return{url:e.url(),resourceType:e.contentType()}}class mi{url;resourceType;selectionRange;scrollLineNumber;constructor(e,t,i,o){this.url=e,this.resourceType=t,this.selectionRange=i,this.scrollLineNumber=o}static fromObject(e){const t=i.ResourceType.ResourceType.fromName(e.resourceTypeName);if(null===t)throw new TypeError(`Invalid resource type name "${e.resourceTypeName}"`);const o=e.selectionRange?g.TextRange.TextRange.fromObject(e.selectionRange):void 0;return new mi(e.url,t,o,e.scrollLineNumber)}toObject(){return this.url.length>=4096?null:{url:this.url,resourceTypeName:this.resourceType.name(),selectionRange:this.selectionRange,scrollLineNumber:this.scrollLineNumber}}}class bi{items;constructor(e){this.items=e}static fromObject(e){const t=[];for(const i of e)try{t.push(mi.fromObject(i))}catch{}return new bi(t)}index({url:e,resourceType:t}){return this.items.findIndex((i=>i.url===e&&i.resourceType===t))}selectionRange(e){const t=this.index(e);if(-1!==t)return this.items[t].selectionRange}updateSelectionRange(e,t){if(!t)return;const i=this.index(e);-1!==i&&(this.items[i].selectionRange=t)}scrollLineNumber(e){const t=this.index(e);if(-1!==t)return this.items[t].scrollLineNumber}updateScrollLineNumber(e,t){const i=this.index(e);-1!==i&&(this.items[i].scrollLineNumber=t)}update(e){for(let t=e.length-1;t>=0;--t){const i=this.index(e[t]);let o;-1!==i?(o=this.items[i],this.items.splice(i,1)):o=new mi(e[t].url,e[t].resourceType),this.items.unshift(o)}}remove(e){const t=this.index(e);-1!==t&&this.items.splice(t,1)}toObject(){const e=[];for(const t of this.items){const i=t.toObject();if(i&&e.push(i),e.length===pi)break}return e}keys(){return this.items}}class fi{editorContainer;constructor(e){this.editorContainer=e}closeTabs(e,t){this.editorContainer.closeTabs(t)}onContextMenu(e,t){this.editorContainer.onContextMenu(e,t)}}var Si=Object.freeze({__proto__:null,TabbedEditorContainer:hi,HistoryItem:mi,History:bi,EditorContainerTabDelegate:fi});const vi={openFile:"Open file",runCommand:"Run command",workspaceDropInAFolderToSyncSources:"To sync edits to the workspace, drop a folder with your sources here or",selectFolder:"Select folder",sourceViewActions:"Source View Actions"},Ci=e.i18n.registerUIStrings("panels/sources/SourcesView.ts",vi),wi=e.i18n.getLocalizedString.bind(void 0,Ci);class Ii extends(i.ObjectWrapper.eventMixin(t.Widget.VBox)){selectedIndex;searchableViewInternal;sourceViewByUISourceCode;editorContainer;historyManager;toolbarContainerElementInternal;scriptViewToolbar;bottomToolbarInternal;toolbarChangedListener;focusedPlaceholderElement;searchView;searchConfig;constructor(){super(),this.element.id="sources-panel-sources-view",this.element.setAttribute("jslog",`${a.pane("editor")}`),this.setMinimumAndPreferredSizes(88,52,150,100),this.selectedIndex=0;const e=f.Workspace.WorkspaceImpl.instance();this.searchableViewInternal=new t.SearchableView.SearchableView(this,this,"sources-view-search-config"),this.searchableViewInternal.setMinimalSearchQuerySize(0),this.searchableViewInternal.show(this.element),this.sourceViewByUISourceCode=new Map,this.editorContainer=new hi(this,i.Settings.Settings.instance().createLocalSetting("previously-viewed-files",[]),this.placeholderElement(),this.focusedPlaceholderElement),this.editorContainer.show(this.searchableViewInternal.element),this.editorContainer.addEventListener("EditorSelected",this.editorSelected,this),this.editorContainer.addEventListener("EditorClosed",this.editorClosed,this),this.historyManager=new wt(this),this.toolbarContainerElementInternal=this.element.createChild("div","sources-toolbar"),this.toolbarContainerElementInternal.setAttribute("jslog",`${a.toolbar("bottom")}`),this.scriptViewToolbar=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.scriptViewToolbar.element.style.flex="auto",this.bottomToolbarInternal=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.toolbarChangedListener=null,t.UIUtils.startBatchUpdate(),e.uiSourceCodes().forEach(this.addUISourceCode.bind(this)),t.UIUtils.endBatchUpdate(),e.addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),e.addEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemoved,this),e.addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved.bind(this),this),o.TargetManager.TargetManager.instance().addScopeChangeListener(this.#f.bind(this)),window.opener||window.addEventListener("beforeunload",(function(e){if(e.returnValue)return;const o=[],n=f.Workspace.WorkspaceImpl.instance().projectsForType(f.Workspace.projectTypes.FileSystem);for(const e of n)for(const t of e.uiSourceCodes())t.isDirty()&&o.push(t);if(o.length){e.returnValue=!0,t.ViewManager.ViewManager.instance().showView("sources");for(const e of o)i.Revealer.reveal(e)}}),!0)}placeholderElement(){const e=[{actionId:"quick-open.show",description:wi(vi.openFile)},{actionId:"quick-open.show-command-menu",description:wi(vi.runCommand)},{actionId:"sources.add-folder-to-workspace",condition:C.Runtime.ConditionName.NOT_SOURCES_HIDE_ADD_FOLDER,description:wi(vi.workspaceDropInAFolderToSyncSources),isWorkspace:!0}],i=document.createElement("div");t.ARIAUtils.markAsList(i),t.ARIAUtils.setLabel(i,wi(vi.sourceViewActions));for(const o of e){const{condition:e}=o;if(void 0!==e&&!C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:()=>Boolean(C.Runtime.Runtime.queryParam(e))}))continue;const n=t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(o.actionId),r=i.createChild("div","tabbed-pane-placeholder-row");if(t.ARIAUtils.markAsListitem(r),n){r.createChild("span").textContent=n;const e=r.createChild("button");e.textContent=o.description;const i=t.ActionRegistry.ActionRegistry.instance().getAction(o.actionId);e.addEventListener("click",(()=>i.execute()))}if(o.isWorkspace){const e=r.createChild("span","workspace");e.textContent=o.description;const t=e.createChild("button");t.textContent=wi(vi.selectFolder),t.addEventListener("click",this.addFileSystemClicked.bind(this))}}return C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&i.appendChild(t.XLink.XLink.create("https://developer.chrome.com/docs/devtools/workspaces/","Learn more about Workspaces")),i}async addFileSystemClicked(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem()&&(c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSelectFolder),t.ViewManager.ViewManager.instance().showView("navigator-files"))}static defaultUISourceCodeScores(){const e=new Map,i=t.Context.Context.instance().flavor(Ii);if(i){const t=i.editorContainer.historyUISourceCodes();for(let i=1;i<t.length;++i)e.set(t[i],t.length-i)}return e}leftToolbar(){return this.editorContainer.leftToolbar()}rightToolbar(){return this.editorContainer.rightToolbar()}bottomToolbar(){return this.bottomToolbarInternal}wasShown(){super.wasShown(),this.registerCSSFiles([xt]),t.Context.Context.instance().setFlavor(Ii,this)}willHide(){t.Context.Context.instance().setFlavor(Ii,null),super.willHide()}toolbarContainerElement(){return this.toolbarContainerElementInternal}searchableView(){return this.searchableViewInternal}visibleView(){return this.editorContainer.visibleView}currentSourceFrame(){const e=this.visibleView();return e instanceof Gt?e:null}currentUISourceCode(){return this.editorContainer.currentFile()}onCloseEditorTab(){const e=this.editorContainer.currentFile();return!!e&&(this.editorContainer.closeFile(e),!0)}onJumpToPreviousLocation(){this.historyManager.rollback()}onJumpToNextLocation(){this.historyManager.rollover()}#f(){const e=f.Workspace.WorkspaceImpl.instance();for(const t of e.uiSourceCodes()){if(t.project().type()!==f.Workspace.projectTypes.Network)continue;const e=u.NetworkProject.NetworkProject.targetForUISourceCode(t);o.TargetManager.TargetManager.instance().isInScope(e)?this.addUISourceCode(t):this.removeUISourceCodes([t])}}uiSourceCodeAdded(e){const t=e.data;this.addUISourceCode(t)}addUISourceCode(e){const t=e.project();if(!t.isServiceProject()){switch(t.type()){case f.Workspace.projectTypes.FileSystem:if("overrides"===h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(t))return;break;case f.Workspace.projectTypes.Network:{const t=u.NetworkProject.NetworkProject.targetForUISourceCode(e);if(!o.TargetManager.TargetManager.instance().isInScope(t))return}}this.editorContainer.addUISourceCode(e)}}uiSourceCodeRemoved(e){const t=e.data;this.removeUISourceCodes([t])}removeUISourceCodes(e){this.editorContainer.removeUISourceCodes(e);for(let t=0;t<e.length;++t)this.removeSourceFrame(e[t]),this.historyManager.removeHistoryForSourceCode(e[t])}projectRemoved(e){const t=e.data.uiSourceCodes();this.removeUISourceCodes([...t])}updateScriptViewToolbarItems(){const e=this.visibleView();e instanceof t.View.SimpleView&&e.toolbarItems().then((e=>{this.scriptViewToolbar.removeToolbarItems();for(const e of ki())this.scriptViewToolbar.appendToolbarItem(e.getOrCreateButton(this));e.map((e=>this.scriptViewToolbar.appendToolbarItem(e)))}))}showSourceLocation(e,t,i,o){const n=this.currentSourceFrame();n&&this.historyManager.updateCurrentState(n.uiSourceCode(),n.textEditor.state.selection.main.head),this.editorContainer.showFile(e);const r=this.currentSourceFrame();r&&t&&r.revealPosition(t,!o);const s=this.visibleView();!i&&s&&s.focus()}createSourceView(e){let t;const o=e.contentType();return o===i.ResourceType.resourceTypes.Image?t=new m.ImageView.ImageView(e.mimeType(),e):o===i.ResourceType.resourceTypes.Font?t=new m.FontView.FontView(e.mimeType(),e):e.name()===Ei?t=new x.HeadersView.HeadersView(e):(t=new Gt(e),this.historyManager.trackSourceFrameCursorJumps(t)),e.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.set(e,t),t}#v(e){return e instanceof m.ImageView.ImageView?"ImageView":e instanceof m.FontView.FontView?"FontView":e instanceof x.HeadersView.HeadersView?"HeadersView":"SourceView"}#C(e){if(e.name()===Ei)return"HeadersView";switch(e.contentType()){case i.ResourceType.resourceTypes.Image:return"ImageView";case i.ResourceType.resourceTypes.Font:return"FontView";default:return"SourceView"}}#S(e){const t=e.data,i=this.sourceViewByUISourceCode.get(t);i&&this.#v(i)!==this.#C(t)&&(this.removeUISourceCodes([t]),this.showSourceLocation(t))}getSourceView(e){return this.sourceViewByUISourceCode.get(e)}getOrCreateSourceView(e){return this.sourceViewByUISourceCode.get(e)||this.createSourceView(e)}recycleUISourceCodeFrame(e,t){e.uiSourceCode().removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.delete(e.uiSourceCode()),e.setUISourceCode(t),this.sourceViewByUISourceCode.set(t,e),t.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}viewForFile(e){return this.getOrCreateSourceView(e)}removeSourceFrame(e){const t=this.sourceViewByUISourceCode.get(e);this.sourceViewByUISourceCode.delete(e),t&&t instanceof Gt&&t.dispose(),e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}editorClosed(e){const t=e.data;this.historyManager.removeHistoryForSourceCode(t);let i=!1;this.editorContainer.currentFile()||(i=!0),this.removeToolbarChangedListener(),this.updateScriptViewToolbarItems(),this.searchableViewInternal.resetSearch();const o={uiSourceCode:t,wasSelected:i};this.dispatchEventToListeners("EditorClosed",o)}editorSelected(e){const t=e.data.previousView instanceof Gt?e.data.previousView:null;t&&t.setSearchableView(null);const i=e.data.currentView instanceof Gt?e.data.currentView:null;i&&i.setSearchableView(this.searchableViewInternal),this.searchableViewInternal.setReplaceable(Boolean(i?.canEditSource())),this.searchableViewInternal.refreshSearch(),this.updateToolbarChangedListener(),this.updateScriptViewToolbarItems();const o=this.editorContainer.currentFile();o&&this.dispatchEventToListeners("EditorSelected",o)}removeToolbarChangedListener(){this.toolbarChangedListener&&i.EventTarget.removeEventListeners([this.toolbarChangedListener]),this.toolbarChangedListener=null}updateToolbarChangedListener(){this.removeToolbarChangedListener();const e=this.currentSourceFrame();e&&(this.toolbarChangedListener=e.addEventListener("ToolbarItemsChanged",this.updateScriptViewToolbarItems,this))}onSearchCanceled(){this.searchView&&this.searchView.onSearchCanceled(),delete this.searchView,delete this.searchConfig}performSearch(e,t,i){const o=this.currentSourceFrame();o&&(this.searchView=o,this.searchConfig=e,this.searchView.performSearch(this.searchConfig,t,i))}jumpToNextSearchResult(){this.searchView&&(this.searchConfig&&this.searchView!==this.currentSourceFrame()?this.performSearch(this.searchConfig,!0):this.searchView.jumpToNextSearchResult())}jumpToPreviousSearchResult(){if(this.searchView)return this.searchConfig&&this.searchView!==this.currentSourceFrame()?(this.performSearch(this.searchConfig,!0),void(this.searchView&&this.searchView.jumpToLastSearchResult())):void this.searchView.jumpToPreviousSearchResult()}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!0}replaceSelectionWith(e,t){const i=this.currentSourceFrame();i?i.replaceSelectionWith(e,t):console.assert(Boolean(i))}replaceAllWith(e,t){const i=this.currentSourceFrame();i?i.replaceAllWith(e,t):console.assert(Boolean(i))}showOutlineQuickOpen(){L.QuickOpen.QuickOpenImpl.show("@")}showGoToLineQuickOpen(){this.editorContainer.currentFile()&&L.QuickOpen.QuickOpenImpl.show(":")}save(){this.saveSourceFrame(this.currentSourceFrame())}saveAll(){this.editorContainer.fileViews().forEach(this.saveSourceFrame.bind(this))}saveSourceFrame(e){if(!(e instanceof Gt))return;e.commitEditing()}toggleBreakpointsActiveState(e){this.editorContainer.view.element.classList.toggle("breakpoints-deactivated",!e)}}const yi=[];function xi(e){yi.push(e)}function ki(){return yi.map((e=>e()))}class Ti{static nextFile(e){function t(e){const t=e.lastIndexOf(".");return e.substr(0,-1!==t?t:e.length).toLowerCase()}const o=[],n=e.parentURL(),r=e.name(),s=t(r);for(const i of e.project().uiSourceCodes())n===i.parentURL()&&t(i.name())===s&&o.push(i.name());o.sort(l.StringUtilities.naturalOrderComparator);const a=l.NumberUtilities.mod(o.indexOf(r)+1,o.length),c=i.ParsedURL.ParsedURL.concatenate(n?i.ParsedURL.ParsedURL.concatenate(n,"/"):"",o[a]),d=e.project().uiSourceCodeForURL(c);return d!==e?d:null}handleAction(e,t){const i=e.flavor(Ii);if(!i)return!1;const o=i.currentUISourceCode();if(!o)return!1;const n=Ti.nextFile(o);return!!n&&(i.showSourceLocation(n),!0)}}const Ei=".headers";var Li=Object.freeze({__proto__:null,SourcesView:Ii,registerEditorAction:xi,getRegisteredEditorActions:ki,SwitchFileActionDelegate:Ti,ActionDelegate:class{handleAction(e,t){const i=e.flavor(Ii);if(!i)return!1;switch(t){case"sources.close-all":return i.editorContainer.closeAllFiles(),!0;case"sources.jump-to-previous-location":return i.onJumpToPreviousLocation(),!0;case"sources.jump-to-next-location":return i.onJumpToNextLocation(),!0;case"sources.next-editor-tab":return i.editorContainer.selectNextTab(),!0;case"sources.previous-editor-tab":return i.editorContainer.selectPrevTab(),!0;case"sources.close-editor-tab":return i.onCloseEditorTab();case"sources.go-to-line":return i.showGoToLineQuickOpen(),!0;case"sources.go-to-member":return i.showOutlineQuickOpen(),!0;case"sources.save":return i.save(),!0;case"sources.save-all":return i.saveAll(),!0}return!1}}});const Mi=new CSSStyleSheet;Mi.replaceSync(".thread-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.thread-item + .thread-item{border-top:1px solid var(--sys-color-divider)}.thread-item:hover{background-color:var(--sys-color-state-hover-on-subtle)}.thread-item:focus-visible{background-color:var(--sys-color-tonal-container)}.thread-item-title,\n.thread-item-paused-state{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.thread-item-paused-state{color:var(--sys-color-state-disabled);margin-left:auto;padding:0 10px}.selected-thread-icon{display:none;position:absolute;top:3px;left:4px}.thread-item.selected .selected-thread-icon{display:block}@media (forced-colors: active){.thread-item:hover,\n .thread-item:focus-visible{forced-color-adjust:none;background-color:Highlight}.thread-item:hover > div,\n .thread-item:focus-visible > div{color:HighlightText}}\n/*# sourceURL=threadsSidebarPane.css */\n");const Pi={paused:"paused"},Fi=e.i18n.registerUIStrings("panels/sources/ThreadsSidebarPane.ts",Pi),Di=e.i18n.getLocalizedString.bind(void 0,Fi);class Ni extends t.Widget.VBox{items;list;selectedModel;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.threads")}`),this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport);const e=t.Context.Context.instance().flavor(o.Target.Target);this.selectedModel=null!==e?e.model(o.DebuggerModel.DebuggerModel):null,this.contentElement.appendChild(this.list.element),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.targetFlavorChanged,this),o.TargetManager.TargetManager.instance().observeModels(o.DebuggerModel.DebuggerModel,this)}static shouldBeShown(){return o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel).length>=2}createElementForItem(e){const i=document.createElement("div");i.classList.add("thread-item");const n=i.createChild("div","thread-item-title"),s=i.createChild("div","thread-item-paused-state"),a=new r.Icon.Icon;a.data={iconName:"large-arrow-right-filled",color:"var(--icon-arrow-main-thread)",width:"14px",height:"14px"},a.classList.add("selected-thread-icon"),i.appendChild(a),i.tabIndex=-1,self.onInvokeElement(i,(i=>{t.Context.Context.instance().setFlavor(o.Target.Target,e.target()),i.consume(!0)}));const c=t.Context.Context.instance().flavor(o.Target.Target)===e.target();function l(){const t=e.runtimeModel().defaultExecutionContext();n.textContent=t&&t.label()?t.label():e.target().name()}function d(){s.textContent=e.isPaused()?Di(Pi.paused):""}return i.classList.toggle("selected",c),t.ARIAUtils.setSelected(i,c),e.addEventListener(o.DebuggerModel.Events.DebuggerPaused,d),e.addEventListener(o.DebuggerModel.Events.DebuggerResumed,d),e.runtimeModel().addEventListener(o.RuntimeModel.Events.ExecutionContextChanged,l),o.TargetManager.TargetManager.instance().addEventListener("NameChanged",(function(t){t.data===e.target()&&l()})),d(),l(),i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1);const n=o;n&&(this.setDefaultFocusedElement(n),n.tabIndex=0,this.hasFocus()&&n.focus())}updateSelectedItemARIA(e,t){return!1}modelAdded(e){this.items.insert(this.items.length,e);t.Context.Context.instance().flavor(o.Target.Target)===e.target()&&this.list.selectItem(e)}modelRemoved(e){this.items.remove(this.items.indexOf(e))}targetFlavorChanged({data:e}){const t=this.hasFocus(),i=e.model(o.DebuggerModel.DebuggerModel);this.list.selectItem(i),i&&this.list.refreshItem(i),null!==this.selectedModel&&this.list.refreshItem(this.selectedModel),this.selectedModel=i,t&&this.focus()}wasShown(){super.wasShown(),this.registerCSSFiles([Mi])}}var Ai=Object.freeze({__proto__:null,ThreadsSidebarPane:Ni});const Ui={dropWorkspaceFolderHere:"Drop workspace folder here",moreOptions:"More options",showNavigator:"Show navigator",hideNavigator:"Hide navigator",navigatorShown:"Navigator sidebar shown",navigatorHidden:"Navigator sidebar hidden",debuggerShown:"Debugger sidebar shown",debuggerHidden:"Debugger sidebar hidden",showDebugger:"Show debugger",hideDebugger:"Hide debugger",groupByFolder:"Group by folder",groupByAuthored:"Group by Authored/Deployed",hideIgnoreListed:"Hide ignore-listed sources",resumeWithAllPausesBlockedForMs:"Resume with all pauses blocked for 500 ms",terminateCurrentJavascriptCall:"Terminate current JavaScript call",pauseOnCaughtExceptions:"Pause on caught exceptions",revealInSidebar:"Reveal in navigator sidebar",continueToHere:"Continue to here",storeAsGlobalVariable:"Store as global variable",copyS:"Copy {PH1}",copyStringContents:"Copy string contents",copyStringAsJSLiteral:"Copy string as JavaScript literal",copyStringAsJSONLiteral:"Copy string as JSON literal",showFunctionDefinition:"Show function definition",openInSourcesPanel:"Open in Sources panel"},Ri=e.i18n.registerUIStrings("panels/sources/SourcesPanel.ts",Ui),Bi=e.i18n.getLocalizedString.bind(void 0,Ri),ji=new Set(["number","boolean","bigint","undefined"]);let Vi;class Wi extends t.Panel.Panel{workspace;togglePauseAction;stepOverAction;stepIntoAction;stepOutAction;stepAction;toggleBreakpointsActiveAction;debugToolbar;debugToolbarDrawer;debuggerPausedMessage;splitWidget;editorView;navigatorTabbedLocation;sourcesViewInternal;toggleNavigatorSidebarButton;toggleDebuggerSidebarButton;threadsSidebarPane;watchSidebarPane;callstackPane;liveLocationPool;lastModificationTime;pausedInternal;switchToPausedTargetTimeout;ignoreExecutionLineEvents;executionLineLocation;pauseOnExceptionButton;sidebarPaneStack;tabbedLocationHeader;extensionSidebarPanesContainer;sidebarPaneView;constructor(){super("sources"),C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&new t.DropTarget.DropTarget(this.element,[t.DropTarget.Type.Folder],Bi(Ui.dropWorkspaceFolderHere),this.handleDrop.bind(this)),this.workspace=f.Workspace.WorkspaceImpl.instance(),this.togglePauseAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-pause"),this.stepOverAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-over"),this.stepIntoAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-into"),this.stepOutAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-out"),this.stepAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step"),this.toggleBreakpointsActiveAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-breakpoints-active"),this.debugToolbar=this.createDebugToolbar(),this.debugToolbarDrawer=this.createDebugToolbarDrawer(),this.debuggerPausedMessage=new Ke;this.splitWidget=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-split-view-state",225),this.splitWidget.enableShowModeSaving(),this.splitWidget.show(this.element);this.editorView=new t.SplitWidget.SplitWidget(!0,!1,"sources-panel-navigator-split-view-state",225),this.editorView.enableShowModeSaving(),this.splitWidget.setMainWidget(this.editorView),this.navigatorTabbedLocation=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"navigator-view",!0,!0);const e=this.navigatorTabbedLocation.tabbedPane();e.setMinimumSize(100,25),e.element.classList.add("navigator-tabbed-pane"),e.headerElement().setAttribute("jslog",`${a.toolbar("navigator")}`);const n=new t.Toolbar.ToolbarMenuButton(this.populateNavigatorMenu.bind(this),!0,"more-options");if(n.setTitle(Bi(Ui.moreOptions)),e.rightToolbar().appendToolbarItem(n),e.addEventListener(t.TabbedPane.Events.TabSelected,(({data:{tabId:e}})=>c.userMetrics.sourcesSidebarTabShown(e))),t.ViewManager.ViewManager.instance().hasViewsForLocation("run-view-sidebar")){const i=new t.SplitWidget.SplitWidget(!1,!0,"source-panel-navigator-sidebar-split-view-state");i.setMainWidget(e);const o=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"run-view-sidebar").tabbedPane();i.setSidebarWidget(o),i.installResizer(o.headerElement()),this.editorView.setSidebarWidget(i)}else this.editorView.setSidebarWidget(e);this.sourcesViewInternal=new Ii,this.sourcesViewInternal.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.toggleNavigatorSidebarButton=this.editorView.createShowHideSidebarButton(Bi(Ui.showNavigator),Bi(Ui.hideNavigator),Bi(Ui.navigatorShown),Bi(Ui.navigatorHidden),"navigator"),this.toggleDebuggerSidebarButton=this.splitWidget.createShowHideSidebarButton(Bi(Ui.showDebugger),Bi(Ui.hideDebugger),Bi(Ui.debuggerShown),Bi(Ui.debuggerHidden),"debugger"),this.editorView.setMainWidget(this.sourcesViewInternal),this.threadsSidebarPane=null,this.watchSidebarPane=t.ViewManager.ViewManager.instance().view("sources.watch"),this.callstackPane=Q.instance(),i.Settings.Settings.instance().moduleSetting("sidebar-position").addChangeListener(this.updateSidebarPosition.bind(this)),this.updateSidebarPosition(),this.updateDebuggerButtonsAndStatus(),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.setTarget(t.Context.Context.instance().flavor(o.Target.Target)),i.Settings.Settings.instance().moduleSetting("breakpoints-active").addChangeListener(this.breakpointsActiveStateChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.onCurrentTargetChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerWasEnabled,this.debuggerWasEnabled,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerPaused,this.debuggerPaused,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerResumed,(e=>this.debuggerResumed(e.data))),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.GlobalObjectCleared,(e=>this.debuggerResumed(e.data))),k.ExtensionServer.ExtensionServer.instance().addEventListener("SidebarPaneAdded",this.extensionSidebarPaneAdded,this),o.TargetManager.TargetManager.instance().observeTargets(this),this.lastModificationTime=-1/0}static instance(e={forceNew:null}){const{forceNew:t}=e;return Vi&&!t||(Vi=new Wi),Vi}static updateResizerAndSidebarButtons(e){e.sourcesViewInternal.leftToolbar().removeToolbarItems(),e.sourcesViewInternal.rightToolbar().removeToolbarItems(),e.sourcesViewInternal.bottomToolbar().removeToolbarItems();const i=t.Context.Context.instance().flavor(zi)&&!t.InspectorView.InspectorView.instance().isDrawerMinimized();e.splitWidget.isVertical()||i?e.splitWidget.uninstallResizer(e.sourcesViewInternal.toolbarContainerElement()):e.splitWidget.installResizer(e.sourcesViewInternal.toolbarContainerElement()),i||(e.sourcesViewInternal.leftToolbar().appendToolbarItem(e.toggleNavigatorSidebarButton),e.splitWidget.isVertical()?e.sourcesViewInternal.rightToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton):e.sourcesViewInternal.bottomToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton))}targetAdded(e){this.showThreadsIfNeeded()}targetRemoved(e){}showThreadsIfNeeded(){Ni.shouldBeShown()&&!this.threadsSidebarPane&&(this.threadsSidebarPane=t.ViewManager.ViewManager.instance().view("sources.threads"),this.sidebarPaneStack&&this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane,this.splitWidget.isVertical()?this.watchSidebarPane:this.callstackPane))}setTarget(e){if(!e)return;const t=e.model(o.DebuggerModel.DebuggerModel);t&&(t.isPaused()?this.showDebuggerPausedDetails(t.debuggerPausedDetails()):(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0)))}onCurrentTargetChanged({data:e}){this.setTarget(e)}paused(){return this.pausedInternal||!1}wasShown(){t.Context.Context.instance().setFlavor(Wi,this),this.registerCSSFiles([Ct]),super.wasShown(),t.Context.Context.instance().flavor(zi)&&(t.InspectorView.InspectorView.instance().setDrawerMinimized(!0),Wi.updateResizerAndSidebarButtons(this)),this.editorView.setMainWidget(this.sourcesViewInternal)}willHide(){super.willHide(),t.Context.Context.instance().setFlavor(Wi,null);const e=t.Context.Context.instance().flavor(zi);e&&(e.showViewInWrapper(),t.InspectorView.InspectorView.instance().setDrawerMinimized(!1),Wi.updateResizerAndSidebarButtons(this))}resolveLocation(e){return"sources.sidebar-top"===e||"sources.sidebar-bottom"===e||"sources.sidebar-tabs"===e?this.sidebarPaneStack||null:this.navigatorTabbedLocation}ensureSourcesViewVisible(){return!!t.Context.Context.instance().flavor(zi)||!!t.InspectorView.InspectorView.instance().canSelectPanel("sources")&&(t.ViewManager.ViewManager.instance().showView("sources"),!0)}onResize(){"auto"===i.Settings.Settings.instance().moduleSetting("sidebar-position").get()&&this.element.window().requestAnimationFrame(this.updateSidebarPosition.bind(this))}searchableView(){return this.sourcesViewInternal.searchableView()}toggleNavigatorSidebar(){this.editorView.toggleSidebar()}toggleDebuggerSidebar(){this.splitWidget.toggleSidebar()}debuggerPaused(e){const n=e.data,r=n.debuggerPausedDetails();!this.pausedInternal&&i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&this.setAsCurrentPanel(),t.Context.Context.instance().flavor(o.Target.Target)===n.target()?this.showDebuggerPausedDetails(r):this.pausedInternal||t.Context.Context.instance().setFlavor(o.Target.Target,n.target())}debugInfoAttached(e){const{debuggerModel:i}=e.data;if(!i.isPaused())return;const n=i.debuggerPausedDetails();n&&t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.showDebuggerPausedDetails(n)}showDebuggerPausedDetails(e){this.pausedInternal=!0,this.updateDebuggerButtonsAndStatus(),t.Context.Context.instance().setFlavor(o.DebuggerModel.DebuggerPausedDetails,e),this.toggleDebuggerSidebarButton.setEnabled(!1),this.revealDebuggerSidebar(),window.focus(),c.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront()}debuggerResumed(e){const i=e.target();t.Context.Context.instance().flavor(o.Target.Target)===i&&(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0),this.switchToPausedTargetTimeout=window.setTimeout(this.switchToPausedTarget.bind(this,e),500))}debuggerWasEnabled(e){const i=e.data;t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.updateDebuggerButtonsAndStatus()}get visibleView(){return this.sourcesViewInternal.visibleView()}showUISourceCode(e,i,o){if(o){if(!this.isShowing()&&!t.Context.Context.instance().flavor(zi))return}else this.showEditor();this.sourcesViewInternal.showSourceLocation(e,i,o)}showEditor(){t.Context.Context.instance().flavor(zi)||this.setAsCurrentPanel()}showUILocation(e,t){const{uiSourceCode:i,lineNumber:o,columnNumber:n}=e;this.showUISourceCode(i,{lineNumber:o,columnNumber:n},t)}async revealInNavigator(e,i){const o=t.ViewManager.ViewManager.instance();for(const t of o.viewsForLocation("navigator-view")){const o=await t.widget();if(o instanceof dt&&o.acceptProject(e.project())){o.revealUISourceCode(e,!0),this.navigatorTabbedLocation.tabbedPane().selectTab(t.viewId(),!0),i||(this.editorView.showBoth(!0),o.focus());break}}}addExperimentMenuItem(e,t,o){e.appendCheckboxItem(o,(function(){const e=C.Runtime.experiments.isEnabled(t);C.Runtime.experiments.setEnabled(t,!e),c.userMetrics.experimentChanged(t,e);const o=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");o.set(o.get())}),{checked:C.Runtime.experiments.isEnabled(t),additionalElement:r.Icon.create("experiment"),jslogContext:l.StringUtilities.toKebabCase(t)})}populateNavigatorMenu(e){const t=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");e.appendItemsAtLocation("navigatorMenu"),e.viewSection().appendCheckboxItem(Bi(Ui.groupByFolder),(()=>t.set(!t.get())),{checked:t.get(),jslogContext:t.name}),this.addExperimentMenuItem(e.viewSection(),"authored-deployed-grouping",Bi(Ui.groupByAuthored)),this.addExperimentMenuItem(e.viewSection(),"just-my-code",Bi(Ui.hideIgnoreListed))}setIgnoreExecutionLineEvents(e){this.ignoreExecutionLineEvents=e}updateLastModificationTime(){this.lastModificationTime=window.performance.now()}async executionLineChanged(e){const t=await e.uiLocation();e.isDisposed()||t&&(window.performance.now()-this.lastModificationTime<Oi||this.sourcesViewInternal.showSourceLocation(t.uiSourceCode,t,void 0,!0))}lastModificationTimeoutPassedForTest(){Oi=Number.MIN_VALUE}updateLastModificationTimeForTest(){Oi=Number.MAX_VALUE}async callFrameChanged(){const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);e&&(this.executionLineLocation&&this.executionLineLocation.dispose(),this.executionLineLocation=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),this.executionLineChanged.bind(this),this.liveLocationPool))}async updateDebuggerButtonsAndStatus(){const e=t.Context.Context.instance().flavor(o.Target.Target),i=e?e.model(o.DebuggerModel.DebuggerModel):null;i?this.pausedInternal?(this.togglePauseAction.setToggled(!0),this.togglePauseAction.setEnabled(!0),this.stepOverAction.setEnabled(!0),this.stepIntoAction.setEnabled(!0),this.stepOutAction.setEnabled(!0),this.stepAction.setEnabled(!0)):(this.togglePauseAction.setToggled(!1),this.togglePauseAction.setEnabled(!i.isPausing()),this.stepOverAction.setEnabled(!1),this.stepIntoAction.setEnabled(!1),this.stepOutAction.setEnabled(!1),this.stepAction.setEnabled(!1)):(this.togglePauseAction.setEnabled(!1),this.stepOverAction.setEnabled(!1),this.stepIntoAction.setEnabled(!1),this.stepOutAction.setEnabled(!1),this.stepAction.setEnabled(!1));const n=i?i.debuggerPausedDetails():null;await this.debuggerPausedMessage.render(n,u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),w.BreakpointManager.BreakpointManager.instance()),n&&this.updateDebuggerButtonsAndStatusForTest()}updateDebuggerButtonsAndStatusForTest(){}clearInterface(){this.updateDebuggerButtonsAndStatus(),t.Context.Context.instance().setFlavor(o.DebuggerModel.DebuggerPausedDetails,null),this.switchToPausedTargetTimeout&&clearTimeout(this.switchToPausedTargetTimeout),this.liveLocationPool.disposeAll()}switchToPausedTarget(e){if(delete this.switchToPausedTargetTimeout,!this.pausedInternal&&!e.isPaused())for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel))if(e.isPaused()){t.Context.Context.instance().setFlavor(o.Target.Target,e.target());break}}runSnippet(){const e=this.sourcesViewInternal.currentUISourceCode();e&&T.ScriptSnippetFileSystem.evaluateScriptSnippet(e)}editorSelected(e){const t=e.data;this.editorView.mainWidget()&&i.Settings.Settings.instance().moduleSetting("auto-reveal-in-navigator").get()&&this.revealInNavigator(t,!0)}togglePause(){const e=t.Context.Context.instance().flavor(o.Target.Target);if(!e)return!0;const i=e.model(o.DebuggerModel.DebuggerModel);return!i||(this.pausedInternal?(this.pausedInternal=!1,i.resume()):i.pause(),this.clearInterface(),!0)}prepareToResume(){if(!this.pausedInternal)return null;this.pausedInternal=!1,this.clearInterface();const e=t.Context.Context.instance().flavor(o.Target.Target);return e?e.model(o.DebuggerModel.DebuggerModel):null}longResume(){const e=this.prepareToResume();e&&(e.skipAllPausesUntilReloadOrTimeout(500),e.resume())}terminateExecution(){const e=this.prepareToResume();e&&(e.runtimeModel().terminateExecution(),e.resume())}stepOver(){const e=this.prepareToResume();return e&&e.stepOver(),!0}stepInto(){const e=this.prepareToResume();return e&&e.stepInto(),!0}stepIntoAsync(){const e=this.prepareToResume();return e&&e.scheduleStepIntoAsync(),!0}stepOut(){const e=this.prepareToResume();return e&&e.stepOut(),!0}async continueToLocation(e){const i=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);if(!i)return;const n=(await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().uiLocationToRawLocations(e.uiSourceCode,e.lineNumber,0)).find((e=>e.debuggerModel===i.debuggerModel));n&&this.prepareToResume()&&n.continueToLocation()}toggleBreakpointsActive(){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!i.Settings.Settings.instance().moduleSetting("breakpoints-active").get())}breakpointsActiveStateChanged(){const e=i.Settings.Settings.instance().moduleSetting("breakpoints-active").get();this.toggleBreakpointsActiveAction.setToggled(!e),this.sourcesViewInternal.toggleBreakpointsActiveState(e)}createDebugToolbar(){const e=new t.Toolbar.Toolbar("scripts-debug-toolbar");e.element.setAttribute("jslog",`${a.toolbar("debug")}`);const i=new t.Toolbar.ToolbarButton(Bi(Ui.resumeWithAllPausesBlockedForMs),"play");i.addEventListener("Click",this.longResume,this);const o=new t.Toolbar.ToolbarButton(Bi(Ui.terminateCurrentJavascriptCall),"stop");return o.addEventListener("Click",this.terminateExecution,this),e.appendToolbarItem(t.Toolbar.Toolbar.createLongPressActionButton(this.togglePauseAction,[o,i],[])),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOverAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepIntoAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOutAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepAction)),e.appendSeparator(),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.toggleBreakpointsActiveAction)),e}createDebugToolbarDrawer(){const e=document.createElement("div");e.classList.add("scripts-debug-toolbar-drawer");const o=Bi(Ui.pauseOnCaughtExceptions),n=i.Settings.Settings.instance().moduleSetting("pause-on-caught-exception");return e.appendChild(t.SettingsUI.createSettingCheckbox(o,n,!0)),e}appendApplicableItems(e,t,i){i instanceof f.UISourceCode.UISourceCode?this.appendUISourceCodeItems(e,t,i):i instanceof Gt?this.appendUISourceCodeFrameItems(t,i):i instanceof f.UISourceCode.UILocation?this.appendUILocationItems(t,i):i instanceof o.RemoteObject.RemoteObject?this.appendRemoteObjectItems(t,i):this.appendNetworkRequestItems(t,i)}appendUISourceCodeItems(e,t,i){if(!e.target)return;const o=e.target;i.project().isServiceProject()||o.isSelfOrDescendant(this.navigatorTabbedLocation.widget().element)||C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||t.revealSection().appendItem(Bi(Ui.revealInSidebar),this.revealInNavigator.bind(this,i),{jslogContext:"sources.reveal-in-navigator-sidebar"}),i.contentType().hasScripts()&&u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(i).every((e=>e.isJavaScript()))&&this.callstackPane.appendIgnoreListURLContextMenuItems(t,i)}appendUISourceCodeFrameItems(e,t){t.uiSourceCode().contentType().isFromSourceMap()||t.textEditor.state.selection.main.empty||e.debugSection().appendAction("debugger.evaluate-selection")}appendUILocationItems(e,i){const n=i.uiSourceCode;if(!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(n).every((e=>e.isJavaScript())))return;if(n.contentType().hasScripts()){const r=t.Context.Context.instance().flavor(o.Target.Target),s=r?r.model(o.DebuggerModel.DebuggerModel):null;s&&s.isPaused()&&e.debugSection().appendItem(Bi(Ui.continueToHere),this.continueToLocation.bind(this,i),{jslogContext:"continue-to-here"}),this.callstackPane.appendIgnoreListURLContextMenuItems(e,n)}}appendRemoteObjectItems(e,n){const r=i.Settings.Settings.instance().moduleSetting("text-editor-indent").get(),s=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);const a="wasm"===n.type?n.subtype:"node"===n.subtype?"outerHTML":n.type;e.debugSection().appendItem(Bi(Ui.storeAsGlobalVariable),(()=>s?.target().model(o.ConsoleModel.ConsoleModel)?.saveToTempVariable(s,n)),{jslogContext:"store-as-global-variable"});const d=e.clipboardSection(),u=c.InspectorFrontendHost.InspectorFrontendHostInstance;if("string"===n.type)d.appendItem(Bi(Ui.copyStringContents),(()=>{u.copyText(n.value)}),{jslogContext:"copy-string-contents"}),d.appendItem(Bi(Ui.copyStringAsJSLiteral),(()=>{u.copyText(l.StringUtilities.formatAsJSLiteral(n.value))}),{jslogContext:"copy-string-as-js-literal"}),d.appendItem(Bi(Ui.copyStringAsJSONLiteral),(()=>{u.copyText(JSON.stringify(n.value))}),{jslogContext:"copy-string-as-json-literal"});else if(ji.has(n.type))d.appendItem(Bi(Ui.copyS,{PH1:String(a)}),(()=>{u.copyText(n.description)}),{jslogContext:"copy-primitive"});else if("object"===n.type){const e=async()=>{const e=await n.callFunctionJSON(h,[{value:{subtype:n.subtype,indent:r}}]);u.copyText(e)};d.appendItem(Bi(Ui.copyS,{PH1:String(a)}),e,{jslogContext:"copy-object"})}else"function"===n.type&&e.debugSection().appendItem(Bi(Ui.showFunctionDefinition),this.showFunctionDefinition.bind(this,n),{jslogContext:"show-function-definition"});function h(e){const t=e.subtype,i=e.indent;if("map"!==t){if("set"!==t){if("node"===t)return this instanceof Element?this.outerHTML:void 0;if(t&&void 0===this)return String(t);try{return JSON.stringify(this,null,i)}catch(e){return String(this)}}else if(this instanceof Set){const e=Array.from(this.values());return`new Set(${0===e.length?"":JSON.stringify(e,null,i)})`}}else if(this instanceof Map){const e=Array.from(this.entries());return`new Map(${0===e.length?"":JSON.stringify(e,null,i)})`}}}appendNetworkRequestItems(e,t){const i=this.workspace.uiSourceCodeForURL(t.url());if(!i)return;const o=Bi(Ui.openInSourcesPanel),n=this.showUILocation.bind(this,i.uiLocation(0,0));e.revealSection().appendItem(o,n,{jslogContext:"reveal-in-sources"})}showFunctionDefinition(e){o.RemoteObject.RemoteFunction.objectAsFunction(e).targetFunction().then((e=>e.debuggerModel().functionDetailsPromise(e).then(this.didGetFunctionDetails.bind(this))))}async didGetFunctionDetails(e){if(!e||!e.location)return;const t=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e.location);t&&this.showUILocation(t)}revealNavigatorSidebar(){this.setAsCurrentPanel(),this.editorView.showBoth(!0)}revealDebuggerSidebar(){i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&(this.setAsCurrentPanel(),this.splitWidget.showBoth(!0))}updateSidebarPosition(){let e;const o=i.Settings.Settings.instance().moduleSetting("sidebar-position").get();if(e="right"!==o&&("bottom"===o||t.InspectorView.InspectorView.instance().element.offsetWidth<680),this.sidebarPaneView&&e===!this.splitWidget.isVertical())return;if(this.sidebarPaneView&&this.sidebarPaneView.shouldHideOnDetach())return;this.sidebarPaneView&&this.sidebarPaneView.detach(),this.splitWidget.setVertical(!e),this.splitWidget.element.classList.toggle("sources-split-view-vertical",e),Wi.updateResizerAndSidebarButtons(this);const n=new t.Widget.VBox;n.element.appendChild(this.debugToolbar.element),n.element.appendChild(this.debugToolbarDrawer),n.setMinimumAndPreferredSizes(Hi,25,Hi,100),this.sidebarPaneStack=t.ViewManager.ViewManager.instance().createStackLocation(this.revealDebuggerSidebar.bind(this),void 0,"debug"),this.sidebarPaneStack.widget().element.classList.add("overflow-auto"),this.sidebarPaneStack.widget().show(n.element),this.sidebarPaneStack.widget().element.appendChild(this.debuggerPausedMessage.element()),this.sidebarPaneStack.appendApplicableItems("sources.sidebar-top"),this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane);const r=t.ViewManager.ViewManager.instance().view("sources.js-breakpoints"),s=t.ViewManager.ViewManager.instance().view("sources.scope-chain");if(this.tabbedLocationHeader&&(this.splitWidget.uninstallResizer(this.tabbedLocationHeader),this.tabbedLocationHeader=null),e){const e=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-debugger-sidebar-split-view-state",.5);e.setMainWidget(n),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(this.callstackPane);const i=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealDebuggerSidebar.bind(this));e.setSidebarWidget(i.tabbedPane()),this.tabbedLocationHeader=i.tabbedPane().headerElement(),this.splitWidget.installResizer(this.tabbedLocationHeader),this.splitWidget.installResizer(this.debugToolbar.gripElementForResize()),i.appendView(s),i.appendView(this.watchSidebarPane),i.appendApplicableItems("sources.sidebar-tabs"),this.extensionSidebarPanesContainer=i,this.sidebarPaneView=e}else this.sidebarPaneStack.appendView(this.watchSidebarPane),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(s),this.sidebarPaneStack.showView(this.callstackPane),this.extensionSidebarPanesContainer=this.sidebarPaneStack,this.sidebarPaneView=n,this.splitWidget.uninstallResizer(this.debugToolbar.gripElementForResize());this.sidebarPaneStack.appendApplicableItems("sources.sidebar-bottom");const a=k.ExtensionServer.ExtensionServer.instance().sidebarPanes();for(let e=0;e<a.length;++e)this.addExtensionSidebarPane(a[e]);this.splitWidget.setSidebarWidget(this.sidebarPaneView)}setAsCurrentPanel(){return t.ViewManager.ViewManager.instance().showView("sources")}extensionSidebarPaneAdded(e){this.addExtensionSidebarPane(e.data)}addExtensionSidebarPane(e){e.panelName()===this.name&&this.extensionSidebarPanesContainer.appendView(e)}sourcesView(){return this.sourcesViewInternal}handleDrop(e){const i=e.items;if(!i.length)return;const o=i[0].webkitGetAsEntry();o&&o.isDirectory&&(c.InspectorFrontendHost.InspectorFrontendHostInstance.upgradeDraggedFileSystemPermissions(o.filesystem),c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceDropFolder),t.ViewManager.ViewManager.instance().showView("navigator-files"))}}let Oi=200;const Hi=215;class _i{static#w;static instance(e={forceNew:!1}){return _i.#w&&!e.forceNew||(_i.#w=new _i),_i.#w}async reveal(e,t){const{uiSourceCode:i,range:{start:o,end:n}}=e;Wi.instance().showUISourceCode(i,{from:o,to:n},t)}}class zi extends t.Widget.VBox{view;constructor(){super(),this.element.classList.add("sources-view-wrapper"),this.element.setAttribute("jslog",`${a.panel("sources.quick").track({resize:!0})}`),this.view=Wi.instance().sourcesView()}wasShown(){t.Context.Context.instance().setFlavor(zi,this),super.wasShown(),Wi.instance().isShowing()?t.InspectorView.InspectorView.instance().setDrawerMinimized(!0):this.showViewInWrapper(),Wi.updateResizerAndSidebarButtons(Wi.instance())}willHide(){t.InspectorView.InspectorView.instance().setDrawerMinimized(!1),queueMicrotask((()=>{Wi.updateResizerAndSidebarButtons(Wi.instance())})),super.willHide(),t.Context.Context.instance().setFlavor(zi,null)}showViewInWrapper(){this.view.show(this.element)}}var qi=Object.freeze({__proto__:null,SourcesPanel:Wi,get lastModificationTimeout(){return Oi},minToolbarWidth:Hi,UILocationRevealer:class{async reveal(e,t){Wi.instance().showUILocation(e,t)}},UILocationRangeRevealer:_i,DebuggerLocationRevealer:class{async reveal(e,t){const i=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);i&&Wi.instance().showUILocation(i,t)}},UISourceCodeRevealer:class{async reveal(e,t){Wi.instance().showUISourceCode(e,void 0,t)}},DebuggerPausedDetailsRevealer:class{async reveal(e){if(i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get())return Wi.instance().setAsCurrentPanel()}},RevealingActionDelegate:class{handleAction(e,o){const n=Wi.instance();if(!n.ensureSourcesViewVisible())return!1;if("debugger.toggle-pause"===o){return e.flavor(t.ShortcutRegistry.ForwardedShortcut)&&!i.Settings.Settings.instance().moduleSetting("disable-paused-state-overlay").get()||n.togglePause(),!0}return!1}},ActionDelegate:class{handleAction(e,t){const i=Wi.instance();switch(t){case"debugger.step-over":return i.stepOver(),!0;case"debugger.step-into":return i.stepIntoAsync(),!0;case"debugger.step":return i.stepInto(),!0;case"debugger.step-out":return i.stepOut(),!0;case"debugger.run-snippet":return i.runSnippet(),!0;case"debugger.toggle-breakpoints-active":return i.toggleBreakpointsActive(),!0;case"debugger.evaluate-selection":{const t=e.flavor(Gt);if(t){const{state:i}=t.textEditor;let n=i.sliceDoc(i.selection.main.from,i.selection.main.to);const r=e.flavor(o.RuntimeModel.ExecutionContext),s=r?.target().model(o.ConsoleModel.ConsoleModel);if(r&&s){const e=s.addCommandMessage(r,n);n=y.JavaScriptREPL.JavaScriptREPL.wrapObjectLiteral(n),s.evaluateCommandInConsole(r,e,n,!0)}}return!0}case"sources.reveal-in-navigator-sidebar":{const e=i.sourcesView().currentUISourceCode();return null!==e&&(i.revealInNavigator(e),!0)}case"sources.toggle-navigator-sidebar":return i.toggleNavigatorSidebar(),!0;case"sources.toggle-debugger-sidebar":return i.toggleDebuggerSidebar(),!0}return!1}},QuickSourceView:zi});const{EMPTY_BREAKPOINT_CONDITION:$i,NEVER_PAUSE_HERE_CONDITION:Gi}=w.BreakpointManager,Ki={thisScriptIsOnTheDebuggersIgnore:"This script is on the debugger's ignore list",removeFromIgnoreList:"Remove from ignore list",configure:"Configure",addBreakpoint:"Add breakpoint",addConditionalBreakpoint:"Add conditional breakpoint…",addLogpoint:"Add logpoint…",neverPauseHere:"Never pause here",removeBreakpoint:"{n, plural, =1 {Remove breakpoint} other {Remove all breakpoints in line}}",editBreakpoint:"Edit breakpoint…",disableBreakpoint:"{n, plural, =1 {Disable breakpoint} other {Disable all breakpoints in line}}",enableBreakpoint:"{n, plural, =1 {Enable breakpoint} other {Enable all breakpoints in line}}",addSourceMap:"Add source map…",addWasmDebugInfo:"Add DWARF debug info…",sourceMapLoaded:"Source map loaded.",associatedFilesAreAvailable:"Associated files are available via file tree or {PH1}.",associatedFilesShouldBeAdded:"Associated files should be added to the file tree. You can debug these resolved source files as regular JavaScript files.",theDebuggerWillSkipStepping:"The debugger will skip stepping through this script, and will not stop on exceptions.",sourceMapSkipped:"Source map skipped for this file.",sourceMapFailed:"Source map failed to load.",debuggingPowerReduced:"DevTools can't show authored sources, but you can debug the deployed code.",reloadForSourceMap:"To enable again, make sure the file isn't on the ignore list and reload.",errorLoading:"Error loading url {PH1}: {PH2}",ignoreScript:"Ignore this file",ignoreContentScripts:"Ignore extension scripts",debugFileNotFound:'Failed to load debug file "{PH1}".',debugInfoNotFound:"Failed to load any debug info for {PH1}."},Ji=e.i18n.registerUIStrings("panels/sources/DebuggerPlugin.ts",Ki),Xi=e.i18n.getLocalizedString.bind(void 0,Ji),Yi=new Map;class Qi extends he{transformer;editor=void 0;executionLocation=null;controlDown=!1;controlTimeout=void 0;sourceMapInfobar=null;scriptsPanel;breakpointManager;popoverHelper=null;scriptFileForDebuggerModel;breakpoints=[];continueToLocations=null;liveLocationPool;muted;initializedMuted;ignoreListInfobar;refreshBreakpointsTimeout=void 0;activeBreakpointDialog=null;#I=void 0;#y=!1;missingDebugInfoBar=null;#x=!1;loader;ignoreListCallback;constructor(e,i){super(e),this.transformer=i,Yi.set(e,this),this.scriptsPanel=Wi.instance(),this.breakpointManager=w.BreakpointManager.BreakpointManager.instance(),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),this.scriptFileForDebuggerModel=new Map,this.loader=o.PageResourceLoader.PageResourceLoader.instance(),this.loader.addEventListener("Update",this.showSourceMapInfobarIfNeeded.bind(this),this),this.ignoreListCallback=this.showIgnoreListInfobarIfNeeded.bind(this),u.IgnoreListManager.IgnoreListManager.instance().addChangeListener(this.ignoreListCallback),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.updateScriptFiles(),this.muted=this.uiSourceCode.isDirty(),this.initializedMuted=this.muted,this.ignoreListInfobar=null,this.showIgnoreListInfobarIfNeeded();for(const e of this.scriptFileForDebuggerModel.values())e.checkMapping()}editorExtension(){const e=this.shortcutHandlers();return[n.EditorView.updateListener.of((e=>this.onEditorUpdate(e))),n.EditorView.domEventHandlers({keydown:t=>!!this.onKeyDown(t)||(e(t),t.defaultPrevented),keyup:e=>this.onKeyUp(e),mousemove:e=>this.onMouseMove(e),mousedown:e=>this.onMouseDown(e),focusout:e=>this.onBlur(e),wheel:e=>this.onWheel(e)}),n.lineNumbers({domEventHandlers:{mousedown:(e,t,i)=>this.handleGutterClick(e.state.doc.lineAt(t.from),i)}}),to,ro,n.Prec.highest(po.field),n.Prec.lowest(fo.field),Co,Io.field,n.Prec.lowest(Po.field),Fo,this.uiSourceCode.project().type()===f.Workspace.projectTypes.Debugger?n.EditorView.editorAttributes.of({class:"source-frame-debugger-script"}):[]]}shortcutHandlers(){const e=e=>e.state.doc.lineAt(e.state.selection.main.head);return t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"debugger.toggle-breakpoint":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!1),!0),"debugger.toggle-breakpoint-enabled":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!0),!0),"debugger.breakpoint-input-window":async()=>{if(this.muted||!this.editor)return!1;const t=e(this.editor);return c.userMetrics.breakpointEditDialogRevealedFrom(4),this.#k(t),!0}})}#k(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.breakpoints.find((t=>t.position>=e.from&&t.position<=e.to))?.breakpoint||null;void 0===t&&null!==i&&(t=i.isLogpoint()),this.editBreakpointCondition({line:e,breakpoint:i,location:null,isLogpoint:t})}editorInitialized(e){this.editor=e,async function(e,t,i){const o=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),n=await o.getMappedLines(i);if(!n)return[];const r=[];for(let i=0;i<e.doc.lines;i++){const{lineNumber:o}=t.editorLocationToUILocation(i,0);n.has(o)||r.push(e.doc.line(i+1).from)}return r}(e.state,this.transformer,this.uiSourceCode).then((t=>{t.length&&e.dispatch({effects:m.SourceFrame.addNonBreakableLines.of(t)})}),console.error),this.ignoreListInfobar&&this.attachInfobar(this.ignoreListInfobar),this.missingDebugInfoBar&&this.attachInfobar(this.missingDebugInfoBar),this.sourceMapInfobar&&this.attachInfobar(this.sourceMapInfobar),this.muted||this.refreshBreakpoints(),this.callFrameChanged(),this.popoverHelper?.dispose(),this.popoverHelper=new t.PopoverHelper.PopoverHelper(e,this.getPopoverRequest.bind(this),"sources.object-properties"),this.popoverHelper.setDisableOnClick(!0),this.popoverHelper.setTimeout(250,250),this.popoverHelper.setHasPadding(!0)}static accepts(e){return e.contentType().hasScripts()}showIgnoreListInfobarIfNeeded(){const e=this.uiSourceCode;if(!e.contentType().hasScripts())return;if(!u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return void this.hideIgnoreListInfobar();this.ignoreListInfobar&&this.ignoreListInfobar.dispose();const i=new t.Infobar.Infobar("warning",Xi(Ki.thisScriptIsOnTheDebuggersIgnore),[{text:Xi(Ki.removeFromIgnoreList),highlight:!1,delegate:function(){u.IgnoreListManager.IgnoreListManager.instance().unIgnoreListUISourceCode(e)},dismiss:!0,jslogContext:"remove-from-ignore-list"},{text:Xi(Ki.configure),highlight:!1,delegate:t.ViewManager.ViewManager.instance().showView.bind(t.ViewManager.ViewManager.instance(),"blackbox"),dismiss:!1,jslogContext:"configure"}],void 0,void 0,"script-on-ignore-list");this.ignoreListInfobar=i,i.setCloseCallback((()=>this.removeInfobar(this.ignoreListInfobar))),i.createDetailsRowMessage(Xi(Ki.theDebuggerWillSkipStepping)),this.attachInfobar(this.ignoreListInfobar)}attachInfobar(e){this.editor&&this.editor.dispatch({effects:Zi.of(e)})}removeInfobar(e){this.editor&&e&&this.editor.dispatch({effects:eo.of(e)})}hideIgnoreListInfobar(){this.ignoreListInfobar&&(this.ignoreListInfobar.dispose(),this.ignoreListInfobar=null)}willHide(){this.popoverHelper?.hidePopover()}editBreakpointLocation({breakpoint:e,uiLocation:t}){const{lineNumber:i}=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber),o=this.editor?.state.doc.line(i+1);o&&this.editBreakpointCondition({line:o,breakpoint:e,location:null,isLogpoint:e.isLogpoint()})}populateLineGutterContextMenu(e,t){const i=new f.UISourceCode.UILocation(this.uiSourceCode,t,0);if(this.scriptsPanel.appendUILocationItems(e,i),this.muted||!this.editor)return;const o=this.editor.state.doc.line(t+1),n=this.lineBreakpoints(o),r=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode);if(n.length){const t=Xi(Ki.removeBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>{c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterContextMenu),e.remove(!1)}))),{jslogContext:"remove-breakpoint"}),1===n.length&&r&&e.debugSection().appendItem(Xi(Ki.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:o,breakpoint:n[0],location:null})}),{jslogContext:"edit-breakpoint"});if(n.some((e=>e.enabled()))){const t=Xi(Ki.disableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!1)))),{jslogContext:"enable-breakpoint"})}if(n.some((e=>!e.enabled()))){const t=Xi(Ki.enableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!0)))),{jslogContext:"disable-breakpoint"})}}else this.editor&&m.SourceFrame.isBreakableLine(this.editor.state,o)&&(e.debugSection().appendItem(Xi(Ki.addBreakpoint),this.createNewBreakpoint.bind(this,o,$i,!0,!1),{jslogContext:"add-breakpoint"}),r&&(e.debugSection().appendItem(Xi(Ki.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),e.debugSection().appendItem(Xi(Ki.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),e.debugSection().appendItem(Xi(Ki.neverPauseHere),this.createNewBreakpoint.bind(this,o,Gi,!0,!1),{jslogContext:"never-pause-here"})))}populateTextAreaContextMenu(e){function t(e,t){t&&e.addSourceMapURL(t)}function o(e,t){t&&e.addDebugInfoURL(t)}if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get()&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(this.uiSourceCode.url())&&this.scriptFileForDebuggerModel.size){const i=this.scriptFileForDebuggerModel.values().next().value,n=Xi(Ki.addSourceMap);e.debugSection().appendItem(n,function(e){j.createAddSourceMapURLDialog(t.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-source-map"}),i.script?.isWasm()&&!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().pluginManager.hasPluginForScript(i.script)&&e.debugSection().appendItem(Xi(Ki.addWasmDebugInfo),function(e){j.createAddDWARFSymbolsURLDialog(o.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-wasm-debug-info"})}}workingCopyChanged(){this.scriptFileForDebuggerModel.size||this.setMuted(this.uiSourceCode.isDirty())}workingCopyCommitted(){this.scriptsPanel.updateLastModificationTime(),this.scriptFileForDebuggerModel.size||this.setMuted(!1)}didMergeToVM(){this.consistentScripts()&&this.setMuted(!1)}didDivergeFromVM(){this.setMuted(!0)}setMuted(e){this.initializedMuted||e!==this.muted&&(this.muted=e,e?this.editor&&this.editor.dispatch({effects:oo.of(null)}):this.restoreBreakpointsAfterEditing())}consistentScripts(){for(const e of this.scriptFileForDebuggerModel.values())if(e.hasDivergedFromVM()||e.isMergingToVM())return!1;return!0}isVariableIdentifier(e){return"VariableName"===e||"VariableDefinition"===e}isIdentifier(e){return"VariableName"===e||"VariableDefinition"===e||"PropertyName"===e||"PropertyDefinition"===e}getPopoverRequest(e){if(t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return null;const i=t.Context.Context.instance().flavor(o.Target.Target),r=i?i.model(o.DebuggerModel.DebuggerModel):null,{editor:s}=this;if(!r||!r.isPaused()||!s)return null;const a=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!a)return null;let c=s.editor.posAtCoords(e);if(!c)return null;const l=s.editor.coordsAtPos(c);if(!l||e.clientY<l.top||e.clientY>l.bottom||e.clientX<l.left-30||e.clientX>l.right+30)return null;e.clientX<l.left&&c>s.state.doc.lineAt(c).from&&(c-=1);const d=Eo(s.state,this.uiSourceCode.mimeType(),c);if(!d)return null;const u=s.state.doc.lineAt(d.from);if(d.to>u.to)return null;const h=s.editor.coordsAtPos(d.from),g=s.editor.coordsAtPos(d.to);if(!h||!g)return null;const m=new AnchorBox(h.left,h.top-2,g.right-h.left,g.bottom-h.top),b=s.state.sliceDoc(d.from,d.to);let f=null;return{box:m,show:async e=>{let i="";if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const e=await p.NamesResolver.allVariablesInCallFrame(a);try{i=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(b,e)}catch{}}else i=await p.NamesResolver.resolveExpression(a,b,this.uiSourceCode,u.number-1,d.from-u.from,d.to-u.from);const c=C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")&&d.containsSideEffects,l=await a.evaluate({expression:i||b,objectGroup:"popover",includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1,throwOnSideEffect:c,timeout:void 0,disableBreaks:void 0,replMode:void 0,allowUnsafeEvalBlockedByCSP:void 0});if(!l||"error"in l||!l.object||"object"===l.object.type&&"error"===l.object.subtype)return!1;f=await y.ObjectPopoverHelper.ObjectPopoverHelper.buildObjectPopover(l.object,e);const h=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!f||a!==h)return r.runtimeModel().releaseObjectGroup("popover"),f&&f.dispose(),!1;const g=n.Decoration.set(Mo.range(d.from,d.to));return s.dispatch({effects:Po.update.of(g)}),!0},hide:()=>{f&&f.dispose(),r.runtimeModel().releaseObjectGroup("popover"),s.dispatch({effects:Po.update.of(n.Decoration.none)})}}}onEditorUpdate(e){if(!e.changes.empty)for(const t of this.breakpoints)t.position=e.changes.mapPos(t.position)}onWheel(e){this.executionLocation&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&e.preventDefault()}onKeyDown(e){const i=t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e);return i||this.setControlDown(!1),e.key===l.KeyboardUtilities.ESCAPE_KEY&&this.popoverHelper&&this.popoverHelper.isPopoverVisible()?(this.popoverHelper.hidePopover(),e.consume(),!0):(i&&this.executionLocation&&this.setControlDown(!0),!1)}onMouseMove(e){this.executionLocation&&this.controlDown&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&(this.continueToLocations||this.showContinueToLocations())}onMouseDown(e){if(!this.executionLocation||!t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return;if(!this.continueToLocations||!this.editor)return;e.consume();const i=this.editor.editor.posAtCoords(e);if(null!==i)for(const{from:e,to:t,click:o}of this.continueToLocations)if(e<=i&&t>=i){o();break}}onBlur(e){this.setControlDown(!1)}onKeyUp(e){this.setControlDown(!1)}setControlDown(e){e!==this.controlDown&&(this.controlDown=e,clearTimeout(this.controlTimeout),this.controlTimeout=void 0,e&&this.executionLocation?this.controlTimeout=window.setTimeout((()=>{this.executionLocation&&this.controlDown&&this.showContinueToLocations()}),150):this.clearContinueToLocations())}editBreakpointCondition(e){const{line:t,breakpoint:i,location:o,isLogpoint:r}=e;if(i?.isRemoved)return;this.#y=!1;if(this.#I&&function(e,t){if(e.line.number!==t.line.number)return!1;if(e.line.from!==t.line.from)return!1;if(e.line.text!==t.line.text)return!1;if(e.breakpoint!==t.breakpoint)return!1;if(e.location!==t.location)return!1;return e.isLogpoint===t.isLogpoint}(this.#I,e))return;this.activeBreakpointDialog&&this.activeBreakpointDialog.saveAndFinish();const s=this.editor,a=i?i.condition():"",l=i?.isLogpoint()??Boolean(r),d=document.createElement("div"),u=new n.Compartment,h=new q(t.number-1,a,l,(async e=>{this.activeBreakpointDialog=null,this.#I=void 0,h.detach(),s.dispatch({effects:u.reconfigure([])}),e.committed?(x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,a!==e.condition),function(e){const{condition:t,isLogpoint:o}=e,n=0!==t.length&&!o,r=i?.isLogpoint(),s=a&&0!==a.length&&!r;o&&!r?c.userMetrics.breakpointWithConditionAdded(0):n&&!s&&c.userMetrics.breakpointWithConditionAdded(1)}(e),i?i.setCondition(e.condition,e.isLogpoint):o?await this.setBreakpoint(o.lineNumber,o.columnNumber,e.condition,!0,e.isLogpoint):await this.createNewBreakpoint(t,e.condition,!0,e.isLogpoint)):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,!1)}));s.dispatch({effects:n.StateEffect.appendConfig.of(u.of(n.EditorView.decorations.of(n.Decoration.set([n.Decoration.widget({block:!0,widget:new class extends n.WidgetType{toDOM(){return d}},side:1}).range(t.to)]))))}),h.element.addEventListener("blur",(async e=>{(!e.relatedTarget||e.relatedTarget&&!e.relatedTarget.isSelfOrDescendant(h.element))&&(this.#y=!0,setTimeout((()=>{this.activeBreakpointDialog===h&&(this.#y?(h.saveAndFinish(),this.#y=!1):h.focusEditor())}),200))}),!0),h.markAsExternallyManaged(),h.show(d),h.focusEditor(),this.activeBreakpointDialog=h,this.#I=e}async updateValueDecorations(){if(!this.editor)return;const e=this.executionLocation?await this.computeValueDecorations():null;this.editor&&(e||this.editor.state.field(Io.field).size)&&this.editor.dispatch({effects:Io.update.of(e||n.Decoration.none)})}async#T(e,t){const i=e&&await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);if(!i||i.uiSourceCode.url()!==t)return null;const o=this.editor?.toOffset(this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber));return o??null}async computeValueDecorations(){if(!this.editor)return null;if(!i.Settings.Settings.instance().moduleSetting("inline-variable-values").get())return null;if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext))return null;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return null;const r=this.uiSourceCode.url(),s=this.#T(e.functionLocation(),r),a=this.#T(e.location(),r),[c,l]=await Promise.all([s,a]);if(!c||!l||!this.editor)return null;if(c>=l||l-c>1e4)return null;const d=xo(this.editor.state,c,l,l);if(0===d.length)return null;const u=await ko(e,(e=>this.#T(e,r)));if(0===u.length)return null;const h=To(u,d);if(!h||!this.editor)return null;const p=[];for(const[e,t]of h){const i=h.get(e-1);let o=i?Array.from(t).filter((e=>i.get(e[0])!==e[1])):Array.from(t);o.length&&(o.length>10&&(o=o.slice(0,10)),p.push(n.Decoration.widget({widget:new wo(o),side:1}).range(this.editor.state.doc.line(e+1).to)))}return n.Decoration.set(p,!0)}async showContinueToLocations(){this.popoverHelper?.hidePopover();if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext)||!this.editor)return;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return;const i=e.functionLocation()||e.location(),r=e.debuggerModel,{state:s}=this.editor,a=await r.getPossibleBreakpoints(i,null,!0);this.continueToLocations=[];let c=-1;for(const e of a.reverse()){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber);if(c===t.lineNumber&&"call"!==e.type||t.lineNumber>=s.doc.lines)continue;const i=s.doc.line(t.lineNumber+1),o=Math.min(i.to,i.from+t.columnNumber);let r=n.syntaxTree(s).resolveInner(o,1);if(r.firstChild||r.from<i.from||r.to>i.to)continue;if("."===r.name){const e=r.resolve(r.to,1);if(e.firstChild||e.from<i.from||e.to>i.to)continue;r=e}const a=r.name,l="this"===a||"return"===a||"new"===a||"break"===a||"continue"===a;if(!l&&!this.isIdentifier(a))continue;this.continueToLocations.push({from:r.from,to:r.to,async:!1,click:()=>e.continueToLocation()}),"call"===e.type&&(c=t.lineNumber);const d=l?"":i.text.slice(r.from-i.from,r.to-i.from);let u=null;if("then"===d&&"MemberExpression"===r.parent?.name?u=r.parent.parent:"setTimeout"!==d&&"setInterval"!==d&&"postMessage"!==d||(u=r.parent),"new"===a){const e=r.parent?.getChild("Expression");e&&"VariableName"===e.name&&"Worker"===s.sliceDoc(e.from,e.to)&&(u=r.parent)}if(u&&("CallExpression"===u.name||"NewExpression"===u.name)&&"call"===e.type){const t=u.getChild("ArgList")?.firstChild?.nextSibling;let i;if("VariableName"===t?.name?i=t:"ArrowFunction"!==t?.name&&"FunctionExpression"!==t?.name||(i=t.firstChild,"async"===i?.name&&(i=i.nextSibling)),i){const t=this.executionLocation&&e.lineNumber===this.executionLocation.lineNumber&&e.columnNumber===this.executionLocation.columnNumber;this.continueToLocations.push({from:i.from,to:i.to,async:!0,click:()=>this.asyncStepIn(e,Boolean(t))})}}}const l=n.Decoration.set(this.continueToLocations.map((e=>(e.async?bo:mo).range(e.from,e.to))),!0);this.editor.dispatch({effects:fo.update.of(l)})}clearContinueToLocations(){this.editor&&this.editor.state.field(fo.field).size&&this.editor.dispatch({effects:fo.update.of(n.Decoration.none)})}asyncStepIn(e,t){function i(){e.debuggerModel.scheduleStepIntoAsync()}t?i():e.continueToLocation(i)}fetchBreakpoints(){if(!this.editor)return[];const{editor:e}=this;return this.breakpointManager.breakpointLocationsForUISourceCode(this.uiSourceCode).map((({uiLocation:t,breakpoint:i})=>{const o=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber);return{position:e.toOffset(o),breakpoint:i}}))}lineBreakpoints(e){return this.breakpoints.filter((t=>t.position>=e.from&&t.position<=e.to)).map((e=>e.breakpoint))}async computeBreakpointDecoration(e,t){const i=[],o=[],r=new Map,s=new Map,a=[],c=new Set,l=(e,t,i)=>{let o=s.get(e);o||(o=[],s.set(e,o)),o.push({breakpoint:i,column:t})};for(const{position:i,breakpoint:o}of t){const t=e.doc.lineAt(i);let n=r.get(t.from);if(n||(n=[],r.set(t.from,n)),o.enabled()&&n.every((e=>!e.enabled()))){const e=this.transformer.editorLocationToUILocation(t.number-1,0),i=this.transformer.editorLocationToUILocation(t.number-1,Math.min(t.length,2500)),o=new g.TextRange.TextRange(e.lineNumber,e.columnNumber||0,i.lineNumber,i.columnNumber||0);a.push(this.breakpointManager.possibleBreakpoints(this.uiSourceCode,o).then((e=>d(t,e))))}n.push(o),o.enabled()&&(c.add(i),l(t.from,i-t.from,o))}for(const[e,t]of r){const i=t.sort(co)[0];let n="cm-breakpoint";i.enabled()||(n+=" cm-breakpoint-disabled"),i.bound()||(n+=" cm-breakpoint-unbound"),i.isLogpoint()?n+=" cm-breakpoint-logpoint":i.condition()&&(n+=" cm-breakpoint-conditional"),o.push(new ao(n,e).range(e))}const d=(e,t)=>{for(const i of t){const t=this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber);if(t.lineNumber!==e.number-1)continue;const o=Math.min(e.to,e.from+t.columnNumber);c.has(o)||l(e.from,t.columnNumber,null)}};await Promise.all(a);for(const[e,t]of s)if(t.length>1)for(const{column:o,breakpoint:r}of t){const t=new so(r,this);i.push(n.Decoration.widget({widget:t,side:-1}).range(e+o))}return{content:n.Decoration.set(i,!0),gutter:n.RangeSet.of(o,!0)}}async restoreBreakpointsAfterEditing(){const{breakpoints:e}=this,t=this.editor;this.breakpoints=[],await Promise.all(e.map((async e=>{const{breakpoint:i,position:o}=e,n=i.condition(),r=i.enabled(),s=i.isLogpoint();await i.remove(!1);const a=t.toLineColumn(o),c=this.transformer.editorLocationToUILocation(a.lineNumber,a.columnNumber);await this.setBreakpoint(c.lineNumber,c.columnNumber,n,r,s)})))}async refreshBreakpoints(){if(this.editor){this.breakpoints=this.fetchBreakpoints();const e=this.breakpoints,t=await this.computeBreakpointDecoration(this.editor.state,e);this.editor&&this.breakpoints===e&&(t.gutter.size||this.editor.state.field(ro,!1)?.gutter.size)&&this.editor.dispatch({effects:io.of(t)})}}breakpointChange(e){const{uiLocation:t}=e.data;if(t.uiSourceCode===this.uiSourceCode&&!this.muted){for(const e of this.scriptFileForDebuggerModel.values())if(e.isDivergingFromVM()||e.isMergingToVM())return;window.clearTimeout(this.refreshBreakpointsTimeout),this.refreshBreakpointsTimeout=window.setTimeout((()=>this.refreshBreakpoints()),50)}}onInlineBreakpointMarkerClick(e,t){if(e.consume(!0),t)e.shiftKey?t.setEnabled(!t.enabled()):t.remove(!1);else if(this.editor){const t=this.editor.editor.posAtDOM(e.target),i=this.editor.state.doc.lineAt(t),o=this.transformer.editorLocationToUILocation(i.number-1,t-i.from);this.setBreakpoint(o.lineNumber,o.columnNumber,$i,!0,!1)}}onInlineBreakpointMarkerContextMenu(e,i){e.consume(!0);const o=this.editor,n=o.editor.posAtDOM(e.target),r=o.state.doc.lineAt(n);if(!m.SourceFrame.isBreakableLine(o.state,r)||!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode))return;const s=new t.ContextMenu.ContextMenu(e);if(i)s.debugSection().appendItem(Xi(Ki.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:i,location:null})}),{jslogContext:"edit-breakpoint"});else{const e=this.transformer.editorLocationToUILocation(r.number-1,n-r.from);s.debugSection().appendItem(Xi(Ki.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),s.debugSection().appendItem(Xi(Ki.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),s.debugSection().appendItem(Xi(Ki.neverPauseHere),(()=>this.setBreakpoint(e.lineNumber,e.columnNumber,Gi,!0,!1)),{jslogContext:"never-pause-here"})}s.show()}updateScriptFiles(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e)&&this.updateScriptFile(e)}this.showSourceMapInfobarIfNeeded()}updateScriptFile(e){const t=this.scriptFileForDebuggerModel.get(e),i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);this.scriptFileForDebuggerModel.delete(e),t&&(t.removeEventListener("DidMergeToVM",this.didMergeToVM,this),t.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),this.muted&&!this.uiSourceCode.isDirty()&&this.consistentScripts()&&this.setMuted(!1)),i&&(this.scriptFileForDebuggerModel.set(e,i),i.addEventListener("DidMergeToVM",this.didMergeToVM,this),i.addEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),i.checkMapping(),i.missingSymbolFiles().then((e=>{if(e){const t=Xi(Ki.debugInfoNotFound,{PH1:i.uiSourceCode.url()});this.updateMissingDebugInfoInfobar({resources:e,details:t})}else this.updateMissingDebugInfoInfobar(null)})))}updateMissingDebugInfoInfobar(e){if(!this.missingDebugInfoBar){if(null===e)return this.removeInfobar(this.missingDebugInfoBar),void(this.missingDebugInfoBar=null);if(this.missingDebugInfoBar=t.Infobar.Infobar.create("error",e.details,[],void 0,"missing-debug-info"),this.missingDebugInfoBar){for(const t of e.resources){const e=this.missingDebugInfoBar?.createDetailsRowMessage(Xi(Ki.debugFileNotFound,{PH1:t}));e&&e.classList.add("infobar-selectable")}this.missingDebugInfoBar.setCloseCallback((()=>{this.removeInfobar(this.missingDebugInfoBar),this.missingDebugInfoBar=null})),this.attachInfobar(this.missingDebugInfoBar)}}}scriptHasSourceMap(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){const t=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);if(t&&t.hasSourceMapURL())return!0}return!1}getSourceMapResource(){const e=this.loader.getResourcesLoaded();for(const[t,n]of this.scriptFileForDebuggerModel.entries()){const r=n.script?.sourceMapURL;if(r){const s=o.SourceMapManager.SourceMapManager.resolveRelativeSourceURL(t.target(),n.script.sourceURL),a=i.ParsedURL.ParsedURL.completeURL(s,r);if(a){const t=e.get(o.PageResourceLoader.PageResourceLoader.makeKey(a,n.script.createPageResourceLoadInitiator()));if(t)return t}}}return null}showSourceMapInfobarIfNeeded(){if(this.sourceMapInfobar)return;if(!i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get())return;if(!this.scriptHasSourceMap())return;const e=this.getSourceMapResource();if(!e||null!==e.success){if(e)if(e.success){if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Xi(Ki.sourceMapLoaded),[],i.Settings.Settings.instance().createSetting("source-map-infobar-disabled",!1),"source-map-loaded"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.associatedFilesShouldBeAdded)),this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.associatedFilesAreAvailable,{PH1:String(t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction("quick-open.show"))}))}else{let i,o;const n=u.IgnoreListManager.IgnoreListManager.instance();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.ContentScripts?(i=Xi(Ki.ignoreContentScripts),o=n.ignoreListContentScripts.bind(n)):(i=Xi(Ki.ignoreScript),o=n.ignoreListUISourceCode.bind(n,this.uiSourceCode)),this.sourceMapInfobar=t.Infobar.Infobar.create("warning",Xi(Ki.sourceMapFailed),[{text:i,highlight:!1,delegate:o,dismiss:!0}],void 0,"source-map-failed"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.debuggingPowerReduced)),e.errorMessage&&this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.errorLoading,{PH1:l.StringUtilities.trimMiddle(e.url,t.UIUtils.MaxLengthForDisplayedURLs),PH2:e.errorMessage}))}else{if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Xi(Ki.sourceMapSkipped),[],i.Settings.Settings.instance().createSetting("source-map-skipped-infobar-disabled",!1),"source-map-skipped"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.debuggingPowerReduced)),this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.reloadForSourceMap))}this.sourceMapInfobar.setCloseCallback((()=>{this.removeInfobar(this.sourceMapInfobar),this.sourceMapInfobar=null})),this.attachInfobar(this.sourceMapInfobar)}}handleGutterClick(e,t){return!this.muted&&0===t.button&&!t.altKey&&(t.metaKey||t.ctrlKey?(c.userMetrics.breakpointEditDialogRevealedFrom(6),this.#k(e,t.shiftKey),!0):(this.toggleBreakpoint(e,t.shiftKey),!0))}async toggleBreakpoint(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.lineBreakpoints(e);if(!i.length)return void await this.createNewBreakpoint(e,$i,!0,!1);const o=i.some((e=>!e.enabled()));for(const e of i)t?e.setEnabled(o):(c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterToggle),e.remove(!1))}async createNewBreakpoint(e,t,i,o){if(!this.editor||!m.SourceFrame.isBreakableLine(this.editor.state,e))return;c.userMetrics.actionTaken(c.UserMetrics.Action.ScriptsBreakpointSet),this.#E();const n=this.transformer.editorLocationToUILocation(e.number-1);await this.setBreakpoint(n.lineNumber,n.columnNumber,t,i,o)}async setBreakpoint(e,t,o,n,r){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!0);const s=await this.breakpointManager.setBreakpoint(this.uiSourceCode,e,t,o,n,r,"USER_ACTION");return this.breakpointWasSetForTest(e,t,o,n),s}breakpointWasSetForTest(e,t,i,o){}async callFrameChanged(){this.liveLocationPool.disposeAll();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);e?await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),(async t=>{const i=await t.uiLocation();i&&i.uiSourceCode===this.uiSourceCode?(this.setExecutionLocation(i),this.updateMissingDebugInfoInfobar(e.missingDebugInfoDetails),this.#E()):this.setExecutionLocation(null)}),this.liveLocationPool):this.setExecutionLocation(null)}setExecutionLocation(e){if(this.executionLocation!==e&&this.editor)if(this.executionLocation=e,e){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber),i=go(this.editor.state,t.lineNumber,t.columnNumber);this.editor.dispatch({effects:po.update.of(i)}),this.updateValueDecorations(),this.controlDown&&this.showContinueToLocations()}else this.editor.dispatch({effects:[po.update.of(n.Decoration.none),fo.update.of(n.Decoration.none),Io.update.of(n.Decoration.none)]})}dispose(){this.hideIgnoreListInfobar(),this.sourceMapInfobar&&this.sourceMapInfobar.dispose();for(const e of this.scriptFileForDebuggerModel.values())e.removeEventListener("DidMergeToVM",this.didMergeToVM,this),e.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this);this.scriptFileForDebuggerModel.clear(),this.popoverHelper?.hidePopover(),this.popoverHelper?.dispose(),this.setExecutionLocation(null),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),u.IgnoreListManager.IgnoreListManager.instance().removeChangeListener(this.ignoreListCallback),Yi.delete(this.uiSourceCode),super.dispose(),window.clearTimeout(this.refreshBreakpointsTimeout),this.editor=void 0,t.Context.Context.instance().removeFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool.disposeAll()}#E(){if(this.#x)return;this.#x=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCode.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCode.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCode.content()));c.userMetrics.sourcesPanelFileDebugged(t)}}const Zi=n.StateEffect.define(),eo=n.StateEffect.define(),to=n.StateField.define({create:()=>[],update(e,t){for(const i of t.effects)i.is(Zi)?e=e.concat(i.value):i.is(eo)&&(e=e.filter((e=>e!==i.value)));return e},provide:e=>n.showPanel.computeN([e],(t=>t.field(e).map((e=>()=>({dom:e.element})))))});const io=n.StateEffect.define(),oo=n.StateEffect.define();function no(e,t){const i=[];return e.between(0,t.length,((e,t,o)=>{let n=o.elementClass;/cm-breakpoint-disabled/.test(n)||(n+=" cm-breakpoint-disabled"),i.push(new ao(n,e).range(e))})),n.RangeSet.of(i,!1)}const ro=n.StateField.define({create:()=>({content:n.RangeSet.empty,gutter:n.RangeSet.empty}),update(e,t){t.changes.empty||(e={content:e.content.map(t.changes),gutter:e.gutter.map(t.changes)});for(const i of t.effects)i.is(io)?e=i.value:i.is(oo)&&(e={content:n.RangeSet.empty,gutter:no(e.gutter,t.state.doc)});return e},provide:e=>[n.EditorView.decorations.from(e,(e=>e.content)),n.lineNumberMarkers.from(e,(e=>e.gutter))]});class so extends n.WidgetType{breakpoint;parent;class;constructor(e,t){super(),this.breakpoint=e,this.parent=t,this.class="cm-inlineBreakpoint",e?.isLogpoint()?this.class+=" cm-inlineBreakpoint-logpoint":e?.condition()&&(this.class+=" cm-inlineBreakpoint-conditional"),e?.enabled()||(this.class+=" cm-inlineBreakpoint-disabled")}eq(e){return e.class===this.class&&e.breakpoint===this.breakpoint}toDOM(){const e=document.createElement("span");return e.className=this.class,e.setAttribute("jslog",`${a.breakpointMarker("inline").track({click:!0})}`),e.addEventListener("click",(e=>{this.parent.onInlineBreakpointMarkerClick(e,this.breakpoint),e.consume()})),e.addEventListener("contextmenu",(e=>{this.parent.onInlineBreakpointMarkerContextMenu(e,this.breakpoint),e.consume()})),e}ignoreEvent(){return!0}}class ao extends n.GutterMarker{elementClass;#L;constructor(e,t){super(),this.elementClass=e,this.#L=t}eq(e){return e.elementClass===this.elementClass}toDOM(e){const t=document.createElement("div");t.setAttribute("jslog",`${a.breakpointMarker("gutter").track({click:!0})}`);const i=e.state.doc.lineAt(this.#L).number,o=e.state.facet(m.SourceFrame.LINE_NUMBER_FORMATTER);return t.textContent=o(i,e.state),t}}function co(e,t){return e.enabled()!==t.enabled()?e.enabled()?-1:1:e.bound()!==t.bound()?e.bound()?-1:1:Boolean(e.condition())!==Boolean(t.condition())?Boolean(e.condition())?-1:1:0}function lo(){const e=n.StateEffect.define(),t=n.StateField.define({create:()=>n.Decoration.none,update:(t,i)=>i.effects.reduce(((t,i)=>i.is(e)?i.value:t),t.map(i.changes)),provide:e=>n.EditorView.decorations.from(e)});return{update:e,field:t}}const uo=n.Decoration.line({attributes:{class:"cm-executionLine"}}),ho=n.Decoration.mark({attributes:{class:"cm-executionToken"}}),po=lo();function go(e,t,i){const{doc:o}=e;if(t>=o.lines)return n.Decoration.none;const r=o.line(t+1),s=[uo.range(r.from)],a=Math.min(r.to,r.from+i);let c=null;for(;null===c;)c=n.ensureSyntaxTree(e,r.to,500);let l=c.resolveInner(a,1);l.to===l.from-1&&/[(.]/.test(o.sliceString(l.from,l.to))&&(l=l.resolve(l.to,1));const d=Math.min(r.to,l.to);return d>a&&s.push(ho.range(a,d)),n.Decoration.set(s)}const mo=n.Decoration.mark({class:"cm-continueToLocation"}),bo=n.Decoration.mark({class:"cm-continueToLocation cm-continueToLocation-async"}),fo=lo(),So={},vo={class:"cm-hasContinueMarkers"},Co=n.EditorView.contentAttributes.compute([fo.field],(e=>e.field(fo.field).size?vo:So));class wo extends n.WidgetType{pairs;constructor(e){super(),this.pairs=e}eq(e){return this.pairs.length===e.pairs.length&&this.pairs.every(((t,i)=>t[0]===e.pairs[i][0]&&t[1]===e.pairs[i][1]))}toDOM(){const e=new y.RemoteObjectPreviewFormatter.RemoteObjectPreviewFormatter,i=document.createElement("div");i.classList.add("cm-variableValues");let o=!0;for(const[n,r]of this.pairs){o?o=!1:t.UIUtils.createTextChild(i,", ");const s=i.createChild("span");t.UIUtils.createTextChild(s,n+" = ");const a=r.preview?r.preview.properties.length:0,c=r.preview&&r.preview.entries?r.preview.entries.length:0;if(r.preview&&a+c<10)e.appendObjectPreview(s,r.preview,!1);else{const e=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValue(r,!1,!1);s.appendChild(e.element)}}return i}}const Io=lo();class yo{blockList=new Set;variables=[]}function xo(e,t,i,o){const r=e.doc.lineAt(t);t=Math.min(r.to,t),i=e.doc.lineAt(i).from;const s=n.ensureSyntaxTree(e,i,100);if(!s)return[];function a(e){return("Block"===(t=e.name)||"ForSpec"===t)&&(e.to<o||o<e.from);var t}const c=[];let l=r;const d=[];let u=null;function h(){return d.length?d[d.length-1].variables:c}return s.iterate({from:t,to:i,enter:i=>{if(i.from<t)return;if("let"===(o=i.name)||"const"===o)return void(u=i.node.nextSibling);var o;if(a(i))return void d.push(new yo);const n=function(e){return"VariableName"===e||"VariableDefinition"===e}(i.name)&&e.sliceDoc(i.from,i.to);n&&(u&&function(e){return"VariableDefinition"===e}(i.name)&&d.length>0?d[d.length-1].blockList.add(n):(i.from>l.to&&(l=e.doc.lineAt(i.from)),h().push({line:l.number-1,from:i.from,id:n})))},leave:e=>{if(u===e.node)u=null;else if(a(e)){const e=d.pop(),t=h();for(const i of e?.variables??[])e?.blockList.has(i.id)||t.push(i)}}}),c}async function ko(e,t){const i=[];for(const o of e.scopeChain()){const e=await t(o.range()?.start??null);if(!e)break;const n=await t(o.range()?.end??null);if(!n)break;const{properties:r}=await p.NamesResolver.resolveScopeInObject(o).getAllProperties(!1,!1);if(!r||r.length>500)break;const s=new Map(r.map((e=>[e.name,e.value])));if(i.push({scopeStart:e,scopeEnd:n,variableMap:s}),"local"===o.type())break}return i}function To(e,t){const i=new Map;for(const{line:n,from:r,id:s}of t){const t=o(s,r,e);if(!t)continue;let a=i.get(n);a||(a=new Map,i.set(n,a)),a.set(s,t)}return i;function o(e,t,i){for(const o of i){if(t<o.scopeStart||t>=o.scopeEnd)continue;const i=o.variableMap.get(e);if(i)return i}return null}}function Eo(e,t,i){const{main:o}=e.selection;if(!o.empty)return i<o.from||o.to<i?null:{from:o.from,to:o.to,containsSideEffects:!1};const r=n.ensureSyntaxTree(e,i,5e3);if(!r)return null;const s=r.resolveInner(i,1);if(s.firstChild)return null;switch(t){case"application/wasm":{if("Identifier"!==s.name)return null;const t=["block","loop","if","else","end","br","br_if","br_table"];for(let i=s.parent;i;i=i.parent)if("App"===i.name){const o=i.firstChild,n="Keyword"===o?.name&&e.sliceDoc(o.from,o.to);if(n&&t.includes(n))return null}return{from:s.from,to:s.to,containsSideEffects:!1}}case"text/html":case"text/javascript":case"text/jsx":case"text/typescript":case"text/typescript-jsx":{let t=s;for(;t&&"this"!==t.name&&"VariableDefinition"!==t.name&&"VariableName"!==t.name&&"MemberExpression"!==t.name&&("PropertyName"!==t.name||"PatternProperty"!==t.parent?.name||":"===t.nextSibling?.name)&&("PropertyDefinition"!==t.name||"Property"!==t.parent?.name||":"===t.nextSibling?.name);)t=t.parent;return t?{from:t.from,to:t.to,containsSideEffects:Lo(e.doc,t)}:null}default:return s.to-s.from>50||/[^\w_\-$]/.test(e.sliceDoc(s.from,s.to))?null:{from:s.from,to:s.to,containsSideEffects:!1}}}function Lo(e,t){let i=!1;return t.toTree().iterate({enter(t){switch(t.name){case"AssignmentExpression":case"CallExpression":return i=!0,!1;case"ArithOp":{const o=e.sliceString(t.from,t.to);if("++"===o||"--"===o)return i=!0,!1;break}}return!0}}),i}const Mo=n.Decoration.mark({class:"cm-evaluatedExpression"}),Po=lo(),Fo=n.EditorView.baseTheme({".cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover, &.cm-breakpoint":{borderStyle:"solid",borderWidth:"1px 4px 1px 1px",marginRight:"-4px",paddingLeft:"8px",lineHeight:"calc(1.2em - 2px)",position:"relative"},"&:hover":{WebkitBorderImage:Do("#ebeced","#ebeced")},"&.cm-breakpoint":{color:"#fff",WebkitBorderImage:Do("#4285f4","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:Do("#f29900","#e37400"),"&::before":{content:'"?"',position:"absolute",top:0,left:"1px"}},"&.cm-breakpoint-logpoint":{WebkitBorderImage:Do("#f439a0","#d01884"),"&::before":{content:'"‥"',position:"absolute",top:"-3px",left:"1px"}}},"&dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover":{WebkitBorderImage:Do("#3c4043","#3c4043")},"&.cm-breakpoint":{WebkitBorderImage:Do("#5186EC","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:Do("#e9a33a","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:Do("#E54D9B","#d01884")}},":host-context(.breakpoints-deactivated) & .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{color:"#1a73e8",WebkitBorderImage:Do("#d9e7fd","#1a73e8"),"&.cm-breakpoint-conditional":{color:"#e37400",WebkitBorderImage:Do("#fcebcc","#e37400")},"&.cm-breakpoint-logpoint":{color:"#d01884",WebkitBorderImage:Do("#fdd7ec","#f439a0")}},":host-context(.breakpoints-deactivated) &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{WebkitBorderImage:Do("#2a384e","#1a73e8"),"&.cm-breakpoint-conditional":{WebkitBorderImage:Do("#4d3c1d","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:Do("#4e283d","#f439a0")}},".cm-inlineBreakpoint":{cursor:"pointer",position:"relative",top:"1px",content:No("#4285F4","#1A73E8"),height:"10px","&.cm-inlineBreakpoint-conditional":{content:Ao("#F29900","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Uo("#F439A0","#D01884")}},"&dark .cm-inlineBreakpoint":{content:No("#5186EC","#1A73E8"),"&.cm-inlineBreakpoint-conditional":{content:Ao("#e9a33a","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Uo("#E54D9B","#D01884")}},":host-context(.breakpoints-deactivated) & .cm-inlineBreakpoint, .cm-inlineBreakpoint-disabled":{content:No("#4285F4","#1A73E8","0.2"),"&.cm-inlineBreakpoint-conditional":{content:Ao("#F9AB00","#E37400","0.2")},"&.cm-inlineBreakpoint-logpoint":{content:Uo("#F439A0","#D01884","0.2")}},".cm-executionLine":{backgroundColor:"var(--sys-color-yellow-container)",outline:"1px solid var(--sys-color-yellow-outline)",".cm-hasContinueMarkers &":{backgroundColor:"transparent"},"&.cm-highlightedLine":{animation:"cm-fading-highlight-execution 2s 0s"},"&.cm-line::selection, &.cm-line ::selection":{backgroundColor:"var(--sys-color-tonal-container) !important"}},".cm-executionToken":{backgroundColor:"var(--sys-color-state-focus-select)"},"@keyframes cm-fading-highlight-execution":{from:{backgroundColor:"var(--sys-color-tonal-container)"},to:{backgroundColor:"var(--sys-color-yellow-container)"}},".cm-continueToLocation":{cursor:"pointer",backgroundColor:"var(--color-continue-to-location)","&:hover":{backgroundColor:"var(--color-continue-to-location-hover)",border:"1px solid var(--color-continue-to-location-hover-border)",margin:"0 -1px"},"&.cm-continueToLocation-async":{backgroundColor:"var(--color-continue-to-location-async)","&:hover":{backgroundColor:"var(--color-continue-to-location-async-hover)",border:"1px solid var(--color-continue-to-location-async-hover-border)",margin:"0 -1px"}}},".cm-evaluatedExpression":{backgroundColor:"var(--color-evaluated-expression)",border:"1px solid var(--color-evaluated-expression-border)",margin:"0 -1px"},".cm-variableValues":{display:"inline",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"1000px",opacity:"80%",backgroundColor:"var(--color-variable-values)",marginLeft:"10px",padding:"0 5px",userSelect:"text",".cm-executionLine &":{backgroundColor:"transparent",opacity:"50%"}}});function Do(e,t){return`url('data:image/svg+xml,<svg height="11" width="26" xmlns="http://www.w3.org/2000/svg"><path d="M22.8.5l2.7 5-2.7 5H.5V.5z" fill="${encodeURIComponent(e)}" stroke="${encodeURIComponent(t)}"/></svg>') 1 3 1 1`}function No(e,t,i="1"){return`url('data:image/svg+xml,<svg width="11" height="12" viewBox="0 0 11 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.5 0.5H5.80139C6.29382 0.5 6.7549 0.741701 7.03503 1.14669L10.392 6L7.03503 10.8533C6.7549 11.2583 6.29382 11.5 5.80139 11.5H0.5V0.5Z" fill="${encodeURIComponent(e)}" stroke="${encodeURIComponent(t)}" fill-opacity="${encodeURIComponent(i)}"/></svg>')`}function Ao(e,t,i="1"){return`url('data:image/svg+xml,<svg width="11" height="12" viewBox="0 0 11 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.5 0.5H5.80139C6.29382 0.5 6.75489 0.741701 7.03503 1.14669L10.392 6L7.03503 10.8533C6.75489 11.2583 6.29382 11.5 5.80138 11.5H0.5V0.5Z" fill="${encodeURIComponent(e)}" fill-opacity="${encodeURIComponent(i)}" stroke="${encodeURIComponent(t)}"/><path d="M3.51074 7.75635H4.68408V9H3.51074V7.75635ZM4.68408 7.23779H3.51074V6.56104C3.51074 6.271 3.55615 6.02344 3.64697 5.81836C3.73779 5.61328 3.90039 5.39648 4.13477 5.16797L4.53027 4.77686C4.71484 4.59814 4.83936 4.4502 4.90381 4.33301C4.97119 4.21582 5.00488 4.09424 5.00488 3.96826C5.00488 3.77197 4.9375 3.62402 4.80273 3.52441C4.66797 3.4248 4.46582 3.375 4.19629 3.375C3.9502 3.375 3.69238 3.42773 3.42285 3.5332C3.15625 3.63574 2.88232 3.78955 2.60107 3.99463V2.81689C2.88818 2.65283 3.17822 2.52979 3.47119 2.44775C3.76709 2.36279 4.06299 2.32031 4.35889 2.32031C4.95068 2.32031 5.41504 2.45801 5.75195 2.7334C6.08887 3.00879 6.25732 3.38818 6.25732 3.87158C6.25732 4.09424 6.20752 4.30225 6.10791 4.49561C6.0083 4.68604 5.8208 4.91602 5.54541 5.18555L5.15869 5.56348C4.95947 5.75684 4.83203 5.91504 4.77637 6.03809C4.7207 6.16113 4.69287 6.31201 4.69287 6.49072C4.69287 6.51709 4.69141 6.54785 4.68848 6.58301C4.68848 6.61816 4.68701 6.65625 4.68408 6.69727V7.23779Z" fill="white"/></svg>')`}function Uo(e,t,i="1"){return`url('data:image/svg+xml,<svg width="11" height="12" viewBox="0 0 11 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.5 0.5H5.80139C6.29382 0.5 6.7549 0.741701 7.03503 1.14669L10.392 6L7.03503 10.8533C6.7549 11.2583 6.29382 11.5 5.80139 11.5H0.5V0.5Z" fill="${encodeURIComponent(e)}" stroke="${encodeURIComponent(t)}" fill-opacity="${encodeURIComponent(i)}"/><circle cx="3" cy="6" r="1" fill="white"/><circle cx="7" cy="6" r="1" fill="white"/></svg>')`}var Ro=Object.freeze({__proto__:null,DebuggerPlugin:Qi,BreakpointLocationRevealer:class{async reveal(e,t){const{uiLocation:i}=e;Wi.instance().showUILocation(i,t);const o=Yi.get(i.uiSourceCode);o?o.editBreakpointLocation(e):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(e.breakpoint,!1)}},computeExecutionDecorations:go,getVariableNamesByLine:xo,computeScopeMappings:ko,getVariableValuesByLine:To,computePopoverHighlightRange:Eo});class Bo{query;queryUpperCase;score;sequence;dataUpperCase;fileNameIndex;constructor(e){this.query=e,this.queryUpperCase=e.toUpperCase(),this.score=new Int32Array(2e3),this.sequence=new Int32Array(2e3),this.dataUpperCase="",this.fileNameIndex=0}calculateScore(e,t){if(!e||!this.query)return 0;const i=this.query.length,o=e.length;(!this.score||this.score.length<i*o)&&(this.score=new Int32Array(i*o*2),this.sequence=new Int32Array(i*o*2));const n=this.score,r=this.sequence;this.dataUpperCase=e.toUpperCase(),this.fileNameIndex=e.lastIndexOf("/");for(let t=0;t<i;++t)for(let i=0;i<o;++i){const s=0===i?0:n[t*o+i-1],a=0===t||0===i?0:n[(t-1)*o+i-1],c=0===t||0===i?0:r[(t-1)*o+i-1],l=this.match(this.query,e,t,i,c);l&&a+l>=s?(r[t*o+i]=c+1,n[t*o+i]=a+l):(r[t*o+i]=0,n[t*o+i]=s)}t&&this.restoreMatchIndexes(r,i,o,t);return 256*n[i*o-1]+(256-e.length)}testWordStart(e,t){if(0===t)return!0;const i=e.charAt(t-1);return"_"===i||"-"===i||"/"===i||"."===i||" "===i||e[t-1]!==this.dataUpperCase[t-1]&&e[t]===this.dataUpperCase[t]}restoreMatchIndexes(e,t,i,o){let n=t-1,r=i-1;for(;n>=0&&r>=0;)if(0===e[n*i+r])--r;else o.push(r),--n,--r;o.reverse()}singleCharScore(e,t,i,o){const n=this.testWordStart(t,o),r=o>this.fileNameIndex;let s=10;return(0===o||"/"===t[o-1])&&(s+=4),n&&(s+=2),e[i]===t[o]&&e[i]===this.queryUpperCase[i]&&(s+=6),r&&(s+=4),o===this.fileNameIndex+1&&0===i&&(s+=5),r&&n&&(s+=3),s}sequenceCharScore(e,t,i,o,n){let r=10;return o>this.fileNameIndex&&(r+=4),(0===o||"/"===t[o-1])&&(r+=5),r+=4*n,r}match(e,t,i,o,n){return this.queryUpperCase[i]!==this.dataUpperCase[o]?0:n?this.sequenceCharScore(e,t,i,o-n,n):this.singleCharScore(e,t,i,o)}}var jo=Object.freeze({__proto__:null,FilePathScoreFunction:Bo});const Vo={noFilesFound:"No files found",sIgnoreListed:"{PH1} (ignore listed)"},Wo=e.i18n.registerUIStrings("panels/sources/FilteredUISourceCodeListProvider.ts",Vo),Oo=e.i18n.getLocalizedString.bind(void 0,Wo);class Ho extends L.FilteredListWidget.Provider{queryLineNumberAndColumnNumber;defaultScores;scorer;uiSourceCodes;uiSourceCodeIds;query;constructor(e){super(e),this.queryLineNumberAndColumnNumber="",this.defaultScores=null,this.scorer=new Bo(""),this.uiSourceCodes=[],this.uiSourceCodeIds=new Set}projectRemoved(e){const t=e.data;this.populate(t),this.refresh()}populate(e){this.uiSourceCodes=[],this.uiSourceCodeIds.clear();for(const t of f.Workspace.WorkspaceImpl.instance().projects())if(t!==e&&this.filterProject(t))for(const e of t.uiSourceCodes())this.filterUISourceCode(e)&&(this.uiSourceCodes.push(e),this.uiSourceCodeIds.add(e.canononicalScriptId()))}filterUISourceCode(e){if(this.uiSourceCodeIds.has(e.canononicalScriptId()))return!1;if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return!1;if(e.isFetchXHR())return!1;const t=h.Persistence.PersistenceImpl.instance().binding(e);return!t||t.fileSystem===e}uiSourceCodeSelected(e,t,i){}filterProject(e){return!0}itemCount(){return this.uiSourceCodes.length}itemContentTypeAt(e){return this.uiSourceCodes[e].contentType()}itemKeyAt(e){return this.uiSourceCodes[e].url()}setDefaultScores(e){this.defaultScores=e}itemScoreAt(e,t){const i=this.uiSourceCodes[e],o=this.defaultScores&&this.defaultScores.get(i)||0;if(!t||t.length<2)return o;this.query!==t&&(this.query=t,this.scorer=new Bo(t));let n=10;i.project().type()!==f.Workspace.projectTypes.FileSystem||h.Persistence.PersistenceImpl.instance().binding(i)||(n=5);let r=0;i.contentType().isFromSourceMap()&&!i.isKnownThirdParty()&&(r=100),i.contentType().isScript()&&(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||(r+=50));const s=i.fullDisplayName();return o+n*(r+this.scorer.calculateScore(s,null))}renderItem(e,i,o,n){i=this.rewriteQuery(i);const r=this.uiSourceCodes[e],s=r.fullDisplayName(),a=[];new Bo(i).calculateScore(s,a);const c=s.lastIndexOf("/");let l=s;u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(r)&&(o.parentElement?.classList.add("is-ignore-listed"),l=Oo(Vo.sIgnoreListed,{PH1:l})),o.textContent=r.displayName()+(this.queryLineNumberAndColumnNumber||""),this.renderSubtitleElement(n,s.substring(0,c+1)),t.Tooltip.Tooltip.install(n,l);const d=[];for(let e=0;e<a.length;++e)d.push({offset:a[e],length:1});if(a[0]>c){for(let e=0;e<d.length;++e)d[e].offset-=c+1;t.UIUtils.highlightRangesWithStyleClass(o,d,"highlight")}else t.UIUtils.highlightRangesWithStyleClass(n,d,"highlight")}renderSubtitleElement(e,i){e.removeChildren();let o=i.lastIndexOf("/");i.length>43&&(o=i.length-43);e.createChild("div","first-part").textContent=i.substring(0,o);e.createChild("div","second-part").textContent=i.substring(o),t.Tooltip.Tooltip.install(e,i)}selectItem(e,t){const i=t.trim().match(/^([^:]*)(:\d+)?(:\d+)?$/);if(!i)return;let o,n;i[2]&&(o=parseInt(i[2].substr(1),10)-1),i[3]&&(n=parseInt(i[3].substr(1),10)-1);const r=null!==e?this.uiSourceCodes[e]:null;this.uiSourceCodeSelected(r,o,n)}rewriteQuery(e){if(!(e=e?e.trim():"")||":"===e)return"";const t=e.match(/^([^:]+)((?::[^:]*){0,2})$/);return this.queryLineNumberAndColumnNumber=t?t[2]:"",t?t[1]:e}uiSourceCodeAdded(e){const t=e.data;this.filterUISourceCode(t)&&this.filterProject(t.project())&&(this.uiSourceCodes.push(t),this.uiSourceCodeIds.add(t.canononicalScriptId()),this.refresh())}notFoundText(){return Oo(Vo.noFilesFound)}attach(){f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.populate()}detach(){f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.queryLineNumberAndColumnNumber="",this.defaultScores=null}}var _o=Object.freeze({__proto__:null,FilteredUISourceCodeListProvider:Ho});const zo={noFileSelected:"No file selected.",noResultsFound:"No results found",typeANumberToGoToThatLine:"Type a number to go to that line.",currentPositionXsTypeAnOffset:"Current position: 0x{PH1}. Type an offset between 0x{PH2} and 0x{PH3} to navigate to.",currentLineSTypeALineNumber:"Current line: {PH1}. Type a line number between 1 and {PH2} to navigate to.",goToOffsetXs:"Go to offset 0x{PH1}.",goToLineSAndColumnS:"Go to line {PH1} and column {PH2}.",goToLineS:"Go to line {PH1}."},qo=e.i18n.registerUIStrings("panels/sources/GoToLineQuickOpen.ts",zo),$o=e.i18n.getLocalizedString.bind(void 0,qo);class Go extends L.FilteredListWidget.Provider{#M=[];constructor(){super("source-line")}selectItem(e,t){const i=this.currentSourceFrame();if(!i)return;const o=this.parsePosition(t);o&&i.revealPosition({lineNumber:o.line-1,columnNumber:o.column-1})}itemCount(){return this.#M.length}renderItem(e,i,o,n){t.UIUtils.createTextChild(o,this.#M[e])}rewriteQuery(e){return""}queryChanged(e){this.#M=[];const t=this.parsePosition(e),i=this.currentSourceFrame();if(t)i&&i.wasmDisassembly?this.#M.push($o(zo.goToOffsetXs,{PH1:(t.column-1).toString(16)})):t.column&&t.column>1?this.#M.push($o(zo.goToLineSAndColumnS,{PH1:t.line,PH2:t.column})):i&&t.line>i.textEditor.state.doc.lines||this.#M.push($o(zo.goToLineS,{PH1:t.line}));else{if(!i)return void this.#M.push($o(zo.typeANumberToGoToThatLine));const e=i.textEditor.state,t=i.wasmDisassembly,o=i.editorLocationToUILocation(e.doc.lineAt(e.selection.main.head).number-1).lineNumber;if(t){const e=t.lineNumberToBytecodeOffset(t.lineNumbers-1),i=e.toString(16).length,n=t.lineNumberToBytecodeOffset(o);return void this.#M.push($o(zo.currentPositionXsTypeAnOffset,{PH1:n.toString(16).padStart(i,"0"),PH2:"0".padStart(i,"0"),PH3:e.toString(16)}))}const n=i.editorLocationToUILocation(e.doc.lines-1).lineNumber+1;this.#M.push($o(zo.currentLineSTypeALineNumber,{PH1:o+1,PH2:n}))}}notFoundText(e){return this.currentSourceFrame()?$o(zo.noResultsFound):$o(zo.noFileSelected)}parsePosition(e){const t=this.currentSourceFrame();if(t&&t.wasmDisassembly){const t=e.match(/0x([0-9a-fA-F]+)/);if(!t||!t[0]||t[0].length!==e.length)return null;return{line:0,column:parseInt(t[0],16)+1}}const i=e.match(/([0-9]+)(\:[0-9]*)?/);if(!i||!i[0]||i[0].length!==e.length)return null;const o=parseInt(i[1],10);let n=0;return i[2]&&(n=parseInt(i[2].substring(1),10)),{line:Math.max(0|o,1),column:Math.max(0|n,1)}}currentSourceFrame(){const e=t.Context.Context.instance().flavor(Ii);return e?e.currentSourceFrame():null}}var Ko=Object.freeze({__proto__:null,GoToLineQuickOpen:Go});const Jo={formatS:"Format {PH1}",format:"Format"},Xo=e.i18n.registerUIStrings("panels/sources/InplaceFormatterEditorAction.ts",Jo),Yo=e.i18n.getLocalizedString.bind(void 0,Xo);let Qo;class Zo{button;sourcesView;uiSourceCodeTitleChangedEvent=null;constructor(){}static instance(e={forceNew:null}){const{forceNew:t}=e;return Qo&&!t||(Qo=new Zo),Qo}editorSelected(e){const t=e.data;this.updateButton(t)}editorClosed(e){const{wasSelected:t}=e.data;t&&this.updateButton(null)}updateButton(e){this.uiSourceCodeTitleChangedEvent&&i.EventTarget.removeEventListeners([this.uiSourceCodeTitleChangedEvent]),this.uiSourceCodeTitleChangedEvent=e?e.addEventListener(f.UISourceCode.Events.TitleChanged,(e=>this.updateButton(e.data)),this):null;const t=this.isFormattable(e);this.button.element.classList.toggle("hidden",!t),e&&t&&this.button.setTitle(Yo(Jo.formatS,{PH1:e.name()}))}getOrCreateButton(e){return this.button||(this.sourcesView=e,this.sourcesView.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.sourcesView.addEventListener("EditorClosed",this.editorClosed.bind(this)),this.button=new t.Toolbar.ToolbarButton(Yo(Jo.format),"brackets"),this.button.addEventListener("Click",this.formatSourceInPlace,this),this.updateButton(e.currentUISourceCode())),this.button}isFormattable(e){return!!e&&(!!e.project().canSetFileContent()||null!==h.Persistence.PersistenceImpl.instance().binding(e))}formatSourceInPlace(){const e=this.sourcesView.currentSourceFrame();if(!e)return;const t=e.uiSourceCode();this.isFormattable(t)&&(t.isDirty()?this.contentLoaded(t,e,t.workingCopy()):t.requestContent().then((i=>{this.contentLoaded(t,e,i.content||"")})))}async contentLoaded(e,t,i){const{formattedContent:o,formattedMapping:n}=await I.ScriptFormatter.format(e.contentType(),t.contentType,i);if(e.workingCopy()===o)return;const r=t.textEditor.toLineColumn(t.textEditor.state.selection.main.head),[s,a]=n.originalToFormatted(r.lineNumber,r.columnNumber);e.setWorkingCopy(o),this.sourcesView.showSourceLocation(e,{lineNumber:s,columnNumber:a})}}xi(Zo.instance);var en=Object.freeze({__proto__:null,InplaceFormatterEditorAction:Zo});var tn=Object.freeze({__proto__:null,OpenFileQuickOpen:class extends Ho{constructor(){super("source-file")}attach(){this.setDefaultScores(Ii.defaultUISourceCodeScores()),super.attach()}uiSourceCodeSelected(e,t,o){c.userMetrics.actionTaken(c.UserMetrics.Action.SelectFileFromFilePicker),e&&("number"==typeof t?i.Revealer.reveal(e.uiLocation(t,o)):i.Revealer.reveal(e))}filterProject(e){return!e.isServiceProject()}renderItem(e,t,i,o){super.renderItem(e,t,i,o);const n=new r.Icon.Icon,s=D.iconDataForResourceType(this.itemContentTypeAt(e));n.data={...s,width:"20px",height:"20px"},i.parentElement?.parentElement?.insertBefore(n,i.parentElement)}renderAsTwoRows(){return!0}}});const on={noFileSelected:"No file selected.",openAJavascriptOrCssFileToSee:"Open a JavaScript or CSS file to see symbols",noResultsFound:"No results found"},nn=e.i18n.registerUIStrings("panels/sources/OutlineQuickOpen.ts",on),rn=e.i18n.getLocalizedString.bind(void 0,nn);function sn(e){function t(t){t=Math.max(0,Math.min(t,e.doc.length));const i=e.doc.lineAt(t);return{lineNumber:i.number-1,columnNumber:t-i.from}}function i(){for(;"ParamList"!==r.name&&r.nextSibling(););let t="";if("ParamList"===r.name&&r.firstChild())do{switch(r.name){case"ArrayPattern":t+="[‥]";break;case"ObjectPattern":t+="{‥}";break;case"VariableDefinition":t+=e.sliceDoc(r.from,r.to);break;case"Spread":t+="...";break;case",":t+=", "}}while(r.nextSibling());return`(${t})`}const o=[],r=n.syntaxTree(e).cursor();do{switch(r.name){case"RuleSet":for(r.firstChild();;r.nextSibling()){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);if(o.push({title:i,lineNumber:n,columnNumber:s}),r.nextSibling(),","!==r.name)break}break;case"FunctionDeclaration":case"MethodDeclaration":{let n="";r.firstChild();do{switch(r.name){case"abstract":case"async":case"get":case"set":case"static":n=`${n}${r.name} `;break;case"Star":n+="*";break;case"PropertyDefinition":case"PrivatePropertyDefinition":case"VariableDefinition":{const s=n+e.sliceDoc(r.from,r.to),{lineNumber:a,columnNumber:c}=t(r.from),l=i();o.push({title:s,subtitle:l,lineNumber:a,columnNumber:c});break}}}while(r.nextSibling());break}case"Property":{let n="";r.firstChild();do{if("async"===r.name||"get"===r.name||"set"===r.name)n=`${n}${r.name} `;else{if("Star"!==r.name){if("PropertyDefinition"===r.name){let s=e.sliceDoc(r.from,r.to);const{lineNumber:a,columnNumber:c}=t(r.from);for(;r.nextSibling();){if("ClassExpression"===r.name){s=`class ${s}`,o.push({title:s,lineNumber:a,columnNumber:c});break}if("ArrowFunction"!==r.name&&"FunctionExpression"!==r.name||r.firstChild(),"async"===r.name)n=`async ${n}`;else if("Star"===r.name)n+="*";else if("ParamList"===r.name){s=n+s;const e=i();o.push({title:s,subtitle:e,lineNumber:a,columnNumber:c});break}}break}break}n+="*"}}while(r.nextSibling());break}case"PropertyName":case"VariableDefinition":if(r.matchContext(["ClassDeclaration"])){const i="class "+e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["AssignmentExpression","MemberExpression"])||r.matchContext(["VariableDeclaration"])){let n=e.sliceDoc(r.from,r.to);const{lineNumber:s,columnNumber:a}=t(r.from);for(;"Equals"!==r.name&&r.next(););if(!r.nextSibling())break;if("ArrowFunction"===r.name||"FunctionExpression"===r.name){r.firstChild();let e="";for(;"ParamList"!==r.name&&("async"===r.name?e=`async ${e}`:"Star"===r.name&&(e+="*"),r.nextSibling()););n=e+n;const t=i();o.push({title:n,subtitle:t,lineNumber:s,columnNumber:a})}else"ClassExpression"===r.name&&(n=`class ${n}`,o.push({title:n,lineNumber:s,columnNumber:a}))}break;case"App":if(r.firstChild()&&r.nextSibling()&&"module"===e.sliceDoc(r.from,r.to)){if(r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}do{if("App"===r.name&&r.firstChild()){if(r.nextSibling()&&"func"===e.sliceDoc(r.from,r.to)&&r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from),a=[];for(;r.nextSibling();)"App"===r.name&&r.firstChild()&&(r.nextSibling()&&"param"===e.sliceDoc(r.from,r.to)&&(r.nextSibling()&&"Identifier"===r.name?a.push(e.sliceDoc(r.from,r.to)):a.push(`$${a.length}`)),r.parent());const c=`(${a.join(", ")})`;o.push({title:i,subtitle:c,lineNumber:n,columnNumber:s})}r.parent()}}while(r.nextSibling())}break;case"FieldIdentifier":case"Identifier":if(r.matchContext(["FunctionDeclarator"])){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}break;case"TypeIdentifier":if(r.matchContext(["ClassSpecifier"])){const i=`class ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["StructSpecifier"])){const i=`struct ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}}}while(r.next());return o}class an extends L.FilteredListWidget.Provider{items=[];active=!1;constructor(){super("source-symbol")}attach(){const e=this.currentSourceFrame();e?(this.active=!0,this.items=sn(e.textEditor.state).map((({title:t,subtitle:i,lineNumber:o,columnNumber:n})=>(({lineNumber:o,columnNumber:n}=e.editorLocationToUILocation(o,n)),{title:t,subtitle:i,lineNumber:o,columnNumber:n})))):(this.active=!1,this.items=[])}detach(){this.active=!1,this.items=[]}itemCount(){return this.items.length}itemKeyAt(e){const t=this.items[e];return t.title+(t.subtitle?t.subtitle:"")}itemScoreAt(e,t){const i=this.items[e];return t.split("(")[0].toLowerCase()===i.title.toLowerCase()?1/(1+i.lineNumber):-i.lineNumber-1}renderItem(e,t,i,o){const n=this.items[e];i.textContent=n.title+(n.subtitle?n.subtitle:""),L.FilteredListWidget.FilteredListWidget.highlightRanges(i,t);const r=this.currentSourceFrame();if(!r)return;const s=i.parentElement?.parentElement?.createChild("span","tag");if(!s)return;const a=r.wasmDisassembly;if(a){const e=a.lineNumberToBytecodeOffset(a.lineNumbers-1).toString(16).length;s.textContent=`:0x${n.columnNumber.toString(16).padStart(e,"0")}`}else s.textContent=`:${n.lineNumber+1}`}selectItem(e,t){if(null===e)return;const i=this.currentSourceFrame();if(!i)return;const o=this.items[e];i.revealPosition({lineNumber:o.lineNumber,columnNumber:o.columnNumber},!0)}currentSourceFrame(){const e=t.Context.Context.instance().flavor(Ii);return e&&e.currentSourceFrame()}notFoundText(){return this.currentSourceFrame()?this.active?rn(on.noResultsFound):rn(on.openAJavascriptOrCssFileToSee):rn(on.noFileSelected)}}var cn=Object.freeze({__proto__:null,outline:sn,OutlineQuickOpen:an});const ln=new CSSStyleSheet;ln.replaceSync(".scope-chain-sidebar-pane-section-header{flex:auto}.scope-chain-sidebar-pane-section-icon{float:left;margin-right:5px}.scope-chain-sidebar-pane-section-subtitle{float:right;margin-left:5px;max-width:55%;text-overflow:ellipsis;overflow:hidden}.scope-chain-sidebar-pane-section-title{font-weight:normal;word-wrap:break-word;white-space:normal}.scope-chain-sidebar-pane-section{padding:2px 4px;flex:none}\n/*# sourceURL=scopeChainSidebarPane.css */\n");const dn={loading:"Loading...",notPaused:"Not paused",noVariables:"No variables",closureS:"Closure ({PH1})",closure:"Closure",exception:"Exception",returnValue:"Return value"},un=e.i18n.registerUIStrings("panels/sources/ScopeChainSidebarPane.ts",dn),hn=e.i18n.getLocalizedString.bind(void 0,un);let pn;class gn extends t.Widget.VBox{treeOutline;expandController;linkifier;infoElement;#P=null;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.scope-chain")}`),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),this.linkifier=new F.Linkifier.Linkifier,this.infoElement=document.createElement("div"),this.infoElement.className="gray-info-message",this.infoElement.tabIndex=-1,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),this.update()}static instance(){return pn||(pn=new gn),pn}flavorChanged(e){this.update()}focus(){this.hasFocus()||t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails)&&this.treeOutline.forceSelect()}sourceMapAttached(e){e.data.client===this.#P&&this.update()}setScopeSourceMapSubscription(e){const t=this.#P;this.#P=e?.script??null,t?.debuggerModel!==this.#P?.debuggerModel&&(t&&t.debuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),this.#P&&this.#P.debuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this))}debugInfoAttached(e){e.data===this.#P&&this.update()}async update(){this.infoElement.textContent=hn(dn.loading),this.contentElement.removeChildren(),this.contentElement.appendChild(this.infoElement),this.linkifier.reset();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);this.setScopeSourceMapSubscription(e);const[i,n]=await Promise.all([p.NamesResolver.resolveThisObject(e),p.NamesResolver.resolveScopeChain(e)]);if(e===t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame)){const r=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.treeOutline.removeChildren(),!r||!e||!n)return void(this.infoElement.textContent=hn(dn.notPaused));this.contentElement.removeChildren(),this.contentElement.appendChild(this.treeOutline.element);let s=!1;for(let t=0;t<n.length;++t){const o=n[t],a=this.extraPropertiesForScope(o,r,e,i,0===t);"local"===o.type()&&(s=!0);const c=this.createScopeSectionTreeElement(o,a);"global"===o.type()?c.collapse():s&&"local"!==o.type()||c.expand(),this.treeOutline.appendChild(c),0===t&&c.select(!0)}this.sidebarPaneUpdatedForTest()}}createScopeSectionTreeElement(e,i){let o=null;e.type(),o=hn(dn.noVariables);let n=e.typeName();if("closure"===e.type()){const i=e.name();n=i?hn(dn.closureS,{PH1:t.UIUtils.beautifyFunctionName(i)}):hn(dn.closure)}let r=e.description();n&&n!==r||(r=null);const s=e.icon(),a=document.createElement("div");if(a.classList.add("scope-chain-sidebar-pane-section-header"),a.classList.add("tree-element-title"),s){const e=document.createElement("img");e.classList.add("scope-chain-sidebar-pane-section-icon"),e.src=s,a.appendChild(e)}a.createChild("div","scope-chain-sidebar-pane-section-subtitle").textContent=r,a.createChild("div","scope-chain-sidebar-pane-section-title").textContent=n;const c=new y.ObjectPropertiesSection.RootElement(p.NamesResolver.resolveScopeInObject(e),this.linkifier,o,0,i);return c.title=a,c.listItemElement.classList.add("scope-chain-sidebar-pane-section"),c.listItemElement.setAttribute("aria-label",n),this.expandController.watchSection(n+(r?":"+r:""),c),c}extraPropertiesForScope(e,t,i,n,r){if("local"!==e.type()||i.script.isWasm())return[];const s=[];if(n&&s.push(new o.RemoteObject.RemoteObjectProperty("this",n,void 0,void 0,void 0,void 0,void 0,!0)),r){const e=t.exception();e&&s.push(new o.RemoteObject.RemoteObjectProperty(hn(dn.exception),e,void 0,void 0,void 0,void 0,void 0,!0));const n=i.returnValue();n&&s.push(new o.RemoteObject.RemoteObjectProperty(hn(dn.returnValue),n,void 0,void 0,void 0,void 0,void 0,!0,i.setReturnValue.bind(i)))}return s}sidebarPaneUpdatedForTest(){}wasShown(){super.wasShown(),this.treeOutline.registerCSSFiles([ln]),this.registerCSSFiles([ln])}}var mn=Object.freeze({__proto__:null,ScopeChainSidebarPane:gn});const bn=new CSSStyleSheet;bn.replaceSync(".border-container{border-bottom:1px solid var(--sys-color-divider);flex-shrink:0}\n/*# sourceURL=sourcesNavigator.css */\n");const fn={explainWorkspace:"Set up workspace to sync edits directly to the sources you develop",explainLocalOverrides:"Override network requests and web content locally to mock remote resources",learnMore:"Learn more",clearConfiguration:"Clear configuration",selectFolderForOverrides:"Select folder for overrides",explainContentScripts:"View content scripts served by extensions",explainSnippets:"Save the JavaScript code you run often to run it again anytime",newSnippet:"New snippet",createNewSnippet:"Create new snippet",run:"Run",rename:"Rename…",remove:"Remove",saveAs:"Save as..."},Sn=e.i18n.registerUIStrings("panels/sources/SourcesNavigator.ts",fn),vn=e.i18n.getLocalizedString.bind(void 0,Sn);let Cn,wn;class In extends dt{constructor(){super("navigator-network",!0),o.TargetManager.TargetManager.instance().addEventListener("InspectedURLChanged",this.inspectedURLChanged,this),c.userMetrics.panelLoaded("sources","DevTools.Launch.Sources"),o.TargetManager.TargetManager.instance().addScopeChangeListener(this.onScopeChange.bind(this))}wasShown(){this.registerCSSFiles([bn]),super.wasShown()}static instance(e={forceNew:null}){const{forceNew:t}=e;return Cn&&!t||(Cn=new In),Cn}acceptProject(e){return e.type()===f.Workspace.projectTypes.Network&&o.TargetManager.TargetManager.instance().isInScope(u.NetworkProject.NetworkProject.getTargetForProject(e))}onScopeChange(){for(const e of f.Workspace.WorkspaceImpl.instance().projects())this.acceptProject(e)?this.tryAddProject(e):this.removeProject(e)}inspectedURLChanged(e){const t=o.TargetManager.TargetManager.instance().scopeTarget();if(e.data!==t)return;const i=t&&t.inspectedURL();if(i)for(const e of this.workspace().uiSourceCodes())this.acceptProject(e.project())&&e.url()===i&&this.revealUISourceCode(e,!0)}uiSourceCodeAdded(e){const t=o.TargetManager.TargetManager.instance().scopeTarget(),i=t&&t.inspectedURL();i&&e.url()===i&&this.revealUISourceCode(e,!0)}}class yn extends dt{toolbar;constructor(){super("navigator-overrides");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` - <div>${vn(fn.explainLocalOverrides)}</div><br /> - ${t.XLink.XLink.create("https://goo.gle/devtools-overrides",vn(fn.learnMore),void 0,void 0,"learn-more")} - `),this.toolbar=new t.Toolbar.Toolbar("navigator-toolbar"),this.contentElement.insertBefore(this.toolbar.element,this.contentElement.firstChild),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("ProjectChanged",this.updateProjectAndUI,this),this.workspace().addEventListener(f.Workspace.Events.ProjectAdded,this.onProjectAddOrRemoved,this),this.workspace().addEventListener(f.Workspace.Events.ProjectRemoved,this.onProjectAddOrRemoved,this),this.updateProjectAndUI()}static instance(e={forceNew:null}){const{forceNew:t}=e;return wn&&!t||(wn=new yn),wn}onProjectAddOrRemoved(e){const t=e.data;t&&t.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(t)||this.updateUI()}updateProjectAndUI(){this.reset();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();e&&this.tryAddProject(e),this.updateUI()}updateUI(){this.toolbar.removeToolbarItems();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();if(e){const o=new t.Toolbar.ToolbarSettingCheckbox(i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled"));this.toolbar.appendToolbarItem(o),this.toolbar.appendToolbarItem(new t.Toolbar.ToolbarSeparator(!0));const n=new t.Toolbar.ToolbarButton(vn(fn.clearConfiguration),"clear");return n.addEventListener("Click",(()=>{i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!1),e.remove()})),void this.toolbar.appendToolbarItem(n)}const o=vn(fn.selectFolderForOverrides),n=new t.Toolbar.ToolbarButton(o,"plus",o);n.addEventListener("Click",(e=>{this.setupNewWorkspace()}),this),this.toolbar.appendToolbarItem(n)}async setupNewWorkspace(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem("overrides")&&i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!0)}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.OverridesSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e===h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()}}var xn=Object.freeze({__proto__:null,NetworkNavigatorView:In,FilesNavigatorView:class extends dt{constructor(){super("navigator-files");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` - <div>${vn(fn.explainWorkspace)}</div><br /> - ${t.XLink.XLink.create("https://goo.gle/devtools-workspace",vn(fn.learnMore),void 0,void 0,"learn-more")} - `);const i=new t.Toolbar.Toolbar("navigator-toolbar");i.appendItemsAtLocation("files-navigator-toolbar").then((()=>{i.empty()||this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}))}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(e)&&!T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.defaultSection().appendAction("sources.add-folder-to-workspace",void 0,!0),i.show()}},OverridesNavigatorView:yn,ContentScriptsNavigatorView:class extends dt{constructor(){super("navigator-content-scripts");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` - <div>${vn(fn.explainContentScripts)}</div><br /> - ${t.XLink.XLink.create("https://developer.chrome.com/extensions/content_scripts",vn(fn.learnMore),void 0,void 0,"learn-more")} - `)}acceptProject(e){return e.type()===f.Workspace.projectTypes.ContentScripts}},SnippetsNavigatorView:class extends dt{constructor(){super("navigator-snippets");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` - <div>${vn(fn.explainSnippets)}</div><br /> - ${t.XLink.XLink.create("https://goo.gle/devtools-snippets",vn(fn.learnMore),void 0,void 0,"learn-more")} - `);const i=new t.Toolbar.Toolbar("navigator-toolbar"),o=new t.Toolbar.ToolbarButton(vn(fn.newSnippet),"plus",vn(fn.newSnippet),"sources.new-snippet");o.addEventListener("Click",(e=>{this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")})),i.appendToolbarItem(o),this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}acceptProject(e){return T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.headerSection().appendItem(vn(fn.createNewSnippet),(()=>this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")),{jslogContext:"create-new-snippet"}),i.show()}handleFileContextMenu(e,i){const o=i.uiSourceCode(),n=new t.ContextMenu.ContextMenu(e);n.headerSection().appendItem(vn(fn.run),(()=>T.ScriptSnippetFileSystem.evaluateScriptSnippet(o)),{jslogContext:"run"}),n.editSection().appendItem(vn(fn.rename),(()=>this.rename(i,!1)),{jslogContext:"rename"}),n.editSection().appendItem(vn(fn.remove),(()=>o.project().deleteFile(o)),{jslogContext:"remove"}),n.saveSection().appendItem(vn(fn.saveAs),this.handleSaveAs.bind(this,o),{jslogContext:"save-as"}),n.show()}async handleSaveAs(e){e.commitWorkingCopy();const{content:t}=await e.requestContent();await f.FileManager.FileManager.instance().save(this.addJSExtension(e.url()),t||"",!0),f.FileManager.FileManager.instance().close(e.url())}addJSExtension(e){return i.ParsedURL.ParsedURL.concatenate(e,".js")}},ActionDelegate:class{handleAction(e,t){switch(t){case"sources.create-snippet":return T.ScriptSnippetFileSystem.findSnippetsProject().createFile(l.DevToolsPath.EmptyEncodedPathString,null,"").then((e=>i.Revealer.reveal(e))),!0;case"sources.add-folder-to-workspace":return h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem(),!0}return!1}}});const kn=new CSSStyleSheet;kn.replaceSync(".value.object-value-node:hover{background-color:var(--sys-color-state-hover-on-subtle)}.object-value-function-prefix,\n.object-value-boolean{color:var(--sys-color-token-attribute-value)}.object-value-function{font-style:italic}.object-value-function.linkified:hover{--override-linkified-hover-background:rgb(0 0 0/10%);background-color:var(--override-linkified-hover-background);cursor:pointer}.-theme-with-dark-background .object-value-function.linkified:hover,\n:host-context(.-theme-with-dark-background) .object-value-function.linkified:hover{--override-linkified-hover-background:rgb(230 230 230/10%)}.object-value-number{color:var(--sys-color-token-attribute-value)}.object-value-bigint{color:var(--sys-color-token-comment)}.object-value-string,\n.object-value-regexp,\n.object-value-symbol{white-space:pre;unicode-bidi:-webkit-isolate;color:var(--sys-color-token-property-special)}.object-value-node{position:relative;vertical-align:baseline;color:var(--sys-color-token-variable);white-space:nowrap}.object-value-null,\n.object-value-undefined{color:var(--sys-color-state-disabled)}.object-value-unavailable{color:var(--sys-color-token-tag)}.object-value-calculate-value-button:hover{text-decoration:underline}.object-properties-section-custom-section{display:inline-flex;flex-direction:column}.-theme-with-dark-background .object-value-number,\n:host-context(.-theme-with-dark-background) .object-value-number,\n.-theme-with-dark-background .object-value-boolean,\n:host-context(.-theme-with-dark-background) .object-value-boolean{--override-primitive-dark-mode-color:hsl(252deg 100% 75%);color:var(--override-primitive-dark-mode-color)}.object-properties-section .object-description{color:var(--sys-color-token-subtle)}.value .object-properties-preview{white-space:nowrap}.name{color:var(--sys-color-token-tag);flex-shrink:0}.object-properties-preview .name{color:var(--sys-color-token-subtle)}@media (forced-colors: active){.object-value-calculate-value-button:hover{forced-color-adjust:none;color:Highlight}}\n/*# sourceURL=objectValue.css */\n");const Tn=new CSSStyleSheet;Tn.replaceSync(".watch-expression-delete-button{position:absolute;opacity:0%;right:0;.watch-expression-title:hover &{opacity:100%}}:host-context(.-theme-with-dark-background) .watch-expression-delete-button{filter:brightness(1.5)}.watch-expressions{min-height:26px}.watch-expression-title{white-space:nowrap;line-height:20px;display:flex}.watch-expression-title:hover{padding-right:26px}.watch-expression-object-header .watch-expression-title{margin-left:1px}.watch-expression{position:relative;flex:auto;min-height:20px}.watch-expression .name{color:var(--sys-color-purple);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:1000000;min-width:2em}.watch-expression-error{color:var(--sys-color-error)}.watch-expressions-separator{flex-shrink:0;flex-grow:0}.watch-expression .value{white-space:nowrap;display:inline;overflow:hidden;padding-left:4px;text-overflow:ellipsis;flex-shrink:1}.watch-expression .text-prompt{text-overflow:clip;overflow:hidden;white-space:nowrap;padding-left:4px;min-height:18px;line-height:18px;user-select:text}.watch-expression-text-prompt-proxy{margin:2px 12px 2px -4px;padding-bottom:3px}.watch-expression-header{flex:auto;margin-left:-16px;padding-left:15px}li.watch-expression-tree-item{padding-left:4px}li.watch-expression-tree-item.selected{background:var(--sys-color-neutral-container)}li.watch-expression-tree-item.selected:focus{background:var(--sys-color-tonal-container)}.watch-expression-header:focus-visible{background:var(--sys-color-tonal-container)}li.watch-expression-editing::before{background-color:transparent}@media (forced-colors: active){.watch-expression-title:hover .watch-expression-delete-button,\n .watch-expressions .dimmed{opacity:100%}li.watch-expression-tree-item *{forced-color-adjust:none;color:ButtonText}li.watch-expression-tree-item:hover{forced-color-adjust:none;background-color:Highlight}li.watch-expression-tree-item:hover *{color:HighlightText}li.watch-expression-tree-item:hover .watch-expression-delete-button{background-color:HighlightText}}\n/*# sourceURL=watchExpressionsSidebarPane.css */\n");const En={addWatchExpression:"Add watch expression",refreshWatchExpressions:"Refresh watch expressions",noWatchExpressions:"No watch expressions",deleteAllWatchExpressions:"Delete all watch expressions",addPropertyPathToWatch:"Add property path to watch",deleteWatchExpression:"Delete watch expression",notAvailable:"<not available>",copyValue:"Copy value"},Ln=e.i18n.registerUIStrings("panels/sources/WatchExpressionsSidebarPane.ts",En),Mn=e.i18n.getLocalizedString.bind(void 0,Ln);let Pn;class Fn extends t.ThrottledWidget.ThrottledWidget{watchExpressions;emptyElement;watchExpressionsSetting;addButton;refreshButton;treeOutline;expandController;linkifier;constructor(){super(!0),this.watchExpressions=[],this.watchExpressionsSetting=i.Settings.Settings.instance().createLocalSetting("watch-expressions",[]),this.addButton=new t.Toolbar.ToolbarButton(Mn(En.addWatchExpression),"plus",void 0,"add-watch-expression"),this.addButton.addEventListener("Click",(e=>{this.addButtonClicked()})),this.refreshButton=new t.Toolbar.ToolbarButton(Mn(En.refreshWatchExpressions),"refresh",void 0,"refresh-watch-expressions"),this.refreshButton.addEventListener("Click",this.update,this),this.contentElement.classList.add("watch-expressions"),this.contentElement.setAttribute("jslog",`${a.section("sources.watch")}`),this.contentElement.addEventListener("contextmenu",this.contextMenu.bind(this),!1),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),t.Context.Context.instance().addFlavorChangeListener(o.RuntimeModel.ExecutionContext,this.update,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.update,this),this.linkifier=new F.Linkifier.Linkifier,this.update()}static instance(){return Pn||(Pn=new Fn),Pn}toolbarItems(){return[this.addButton,this.refreshButton]}focus(){this.hasFocus()||this.watchExpressions.length>0&&this.treeOutline.forceSelect()}hasExpressions(){return Boolean(this.watchExpressionsSetting.get().length)}saveExpressions(){const e=[];for(let t=0;t<this.watchExpressions.length;t++){const i=this.watchExpressions[t].expression();i&&e.push(i)}this.watchExpressionsSetting.set(e)}async addButtonClicked(){await t.ViewManager.ViewManager.instance().showView("sources.watch"),this.emptyElement.classList.add("hidden"),this.createWatchExpression(null).startEditing()}async doUpdate(){this.linkifier.reset(),this.contentElement.removeChildren(),this.treeOutline.removeChildren(),this.watchExpressions=[],this.emptyElement=this.contentElement.createChild("div","gray-info-message"),this.emptyElement.textContent=Mn(En.noWatchExpressions),this.emptyElement.tabIndex=-1;const e=this.watchExpressionsSetting.get();e.length&&this.emptyElement.classList.add("hidden");for(let t=0;t<e.length;++t){const i=e[t];i&&this.createWatchExpression(i)}}createWatchExpression(e){this.contentElement.appendChild(this.treeOutline.element);const t=new Dn(e,this.expandController,this.linkifier);return t.addEventListener("ExpressionUpdated",this.watchExpressionUpdated,this),this.treeOutline.appendChild(t.treeElement()),this.watchExpressions.push(t),t}watchExpressionUpdated({data:e}){e.expression()||(l.ArrayUtilities.removeElement(this.watchExpressions,e),this.treeOutline.removeChild(e.treeElement()),this.emptyElement.classList.toggle("hidden",Boolean(this.watchExpressions.length)),0===this.watchExpressions.length&&this.treeOutline.element.remove()),this.saveExpressions()}contextMenu(e){const i=new t.ContextMenu.ContextMenu(e);this.populateContextMenu(i,e),i.show()}populateContextMenu(e,t){let i=!1;for(const e of this.watchExpressions)i=i||e.isEditing();i||e.debugSection().appendItem(Mn(En.addWatchExpression),this.addButtonClicked.bind(this),{jslogContext:"add-watch-expression"}),this.watchExpressions.length>1&&e.debugSection().appendItem(Mn(En.deleteAllWatchExpressions),this.deleteAllButtonClicked.bind(this),{jslogContext:"delete-all-watch-expressions"});const o=this.treeOutline.treeElementFromEvent(t);if(!o)return;const n=this.watchExpressions.find((e=>o.hasAncestorOrSelf(e.treeElement())));n&&n.populateContextMenu(e,t)}deleteAllButtonClicked(){this.watchExpressions=[],this.saveExpressions(),this.update()}async focusAndAddExpressionToWatch(e){await t.ViewManager.ViewManager.instance().showView("sources.watch"),this.createWatchExpression(e),this.saveExpressions(),this.update()}handleAction(e,i){const o=t.Context.Context.instance().flavor(Gt);if(!o)return!1;const{state:n}=o.textEditor,r=n.sliceDoc(n.selection.main.from,n.selection.main.to);return this.focusAndAddExpressionToWatch(r),!0}appendApplicableItems(e,t,i){i instanceof y.ObjectPropertiesSection.ObjectPropertyTreeElement?i.property.synthetic||t.debugSection().appendItem(Mn(En.addPropertyPathToWatch),(()=>this.focusAndAddExpressionToWatch(i.path())),{jslogContext:"add-property-path-to-watch"}):i.textEditor.state.selection.main.empty||t.debugSection().appendAction("sources.add-to-watch")}wasShown(){super.wasShown(),this.treeOutline.registerCSSFiles([Tn]),this.registerCSSFiles([Tn,kn])}}class Dn extends i.ObjectWrapper.ObjectWrapper{treeElementInternal;nameElement;valueElement;expressionInternal;expandController;element;editing;linkifier;textPrompt;result;preventClickTimeout;constructor(e,t,i){super(),this.expressionInternal=e,this.expandController=t,this.element=document.createElement("div"),this.element.classList.add("watch-expression"),this.element.classList.add("monospace"),this.editing=!1,this.linkifier=i,this.createWatchExpression(),this.update()}treeElement(){return this.treeElementInternal}expression(){return this.expressionInternal}async#F(e,t){if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const i=e.debuggerModel.selectedCallFrame();if(i){const e=await p.NamesResolver.allVariablesInCallFrame(i);try{t=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(t,e)}catch{}}}return e.evaluate({expression:t,objectGroup:Dn.watchObjectGroupId,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1)}update(){const e=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);e&&this.expressionInternal?this.#F(e,this.expressionInternal).then((e=>{"object"in e?this.createWatchExpression(e.object,e.exceptionDetails):this.createWatchExpression()})):this.createWatchExpression()}startEditing(){this.editing=!0,this.treeElementInternal.setDisableSelectFocus(!0),this.element.removeChildren();const e=this.element.createChild("div");e.textContent=this.nameElement.textContent,this.textPrompt=new y.ObjectPropertiesSection.ObjectPropertyPrompt,this.textPrompt.renderAsBlock();const t=this.textPrompt.attachAndStartEditing(e,this.finishEditing.bind(this));this.treeElementInternal.listItemElement.classList.add("watch-expression-editing"),this.treeElementInternal.collapse(),t.classList.add("watch-expression-text-prompt-proxy"),t.addEventListener("keydown",this.promptKeyDown.bind(this),!1);const i=this.element.getComponentSelection();i&&i.selectAllChildren(e)}isEditing(){return Boolean(this.editing)}finishEditing(e,t){if(e&&e.consume(t),this.editing=!1,this.treeElementInternal.setDisableSelectFocus(!1),this.treeElementInternal.listItemElement.classList.remove("watch-expression-editing"),this.textPrompt){this.textPrompt.detach();const e=t?this.expressionInternal:this.textPrompt.text();this.textPrompt=void 0,this.element.removeChildren(),this.updateExpression(e)}}dblClickOnWatchExpression(e){e.consume(),this.isEditing()||this.startEditing()}updateExpression(e){this.expressionInternal&&this.expandController.stopWatchSectionsWithId(this.expressionInternal),this.expressionInternal=e,this.update(),this.dispatchEventToListeners("ExpressionUpdated",this)}deleteWatchExpression(e){e.consume(!0),this.updateExpression(null)}createWatchExpression(e,t){this.result=e||null,this.element.removeChildren();const i=this.treeElementInternal;if(this.createWatchExpressionTreeElement(e,t),i&&i.parent){const e=i.parent,t=e.indexOfChild(i);e.removeChild(i),e.insertChild(this.treeElementInternal,t)}this.treeElementInternal.select()}createWatchExpressionHeader(e,i){const o=this.element.createChild("div","watch-expression-header"),n=new N.Button.Button;n.variant="round",n.iconName="bin",n.className="watch-expression-delete-button",n.jslogContext="delete-watch-expression",n.size="SMALL",t.Tooltip.Tooltip.install(n,Mn(En.deleteWatchExpression)),n.addEventListener("click",this.deleteWatchExpression.bind(this),!1);const r=o.createChild("div","watch-expression-title tree-element-title");if(r.appendChild(n),this.nameElement=y.ObjectPropertiesSection.ObjectPropertiesSection.createNameElement(this.expressionInternal),t.Tooltip.Tooltip.install(this.nameElement,this.expressionInternal),Boolean(i)||!e)this.valueElement=document.createElement("span"),this.valueElement.classList.add("watch-expression-error"),this.valueElement.classList.add("value"),r.classList.add("dimmed"),this.valueElement.textContent=Mn(En.notAvailable),void 0!==i&&void 0!==i.exception&&void 0!==i.exception.description&&t.Tooltip.Tooltip.install(this.valueElement,i.exception.description);else{const t=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValueWithCustomSupport(e,Boolean(i),!1,r,this.linkifier);this.valueElement=t.element}const s=document.createElement("span");return s.classList.add("watch-expressions-separator"),s.textContent=": ",r.append(this.nameElement,s,this.valueElement),o}createWatchExpressionTreeElement(e,i){const o=this.createWatchExpressionHeader(e,i);!i&&e&&e.hasChildren&&!e.customPreview()?(o.classList.add("watch-expression-object-header"),this.treeElementInternal=new y.ObjectPropertiesSection.RootElement(e,this.linkifier),this.expandController.watchSection(this.expressionInternal,this.treeElementInternal),this.treeElementInternal.toggleOnClick=!1,this.treeElementInternal.listItemElement.addEventListener("click",this.onSectionClick.bind(this),!1),this.treeElementInternal.listItemElement.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this))):(o.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this)),this.treeElementInternal=new t.TreeOutline.TreeElement),this.treeElementInternal.title=this.element,this.treeElementInternal.listItemElement.classList.add("watch-expression-tree-item"),this.treeElementInternal.listItemElement.addEventListener("keydown",(e=>{"Enter"!==e.key||this.isEditing()?"Delete"!==e.key||this.isEditing()||this.deleteWatchExpression(e):(this.startEditing(),e.consume(!0))}))}onSectionClick(e){e.consume(!0);1===e.detail?this.preventClickTimeout=window.setTimeout(function(){if(!this.treeElementInternal)return;this.treeElementInternal.expanded?this.treeElementInternal.collapse():this.editing||this.treeElementInternal.expand()}.bind(this),333):void 0!==this.preventClickTimeout&&(window.clearTimeout(this.preventClickTimeout),this.preventClickTimeout=void 0)}promptKeyDown(e){const t=l.KeyboardUtilities.isEscKey(e);("Enter"===e.key||t)&&this.finishEditing(e,t)}populateContextMenu(e,i){this.isEditing()||e.editSection().appendItem(Mn(En.deleteWatchExpression),this.updateExpression.bind(this,null),{jslogContext:"delete-watch-expression"}),this.isEditing()||!this.result||"number"!==this.result.type&&"string"!==this.result.type||e.clipboardSection().appendItem(Mn(En.copyValue),this.copyValueButtonClicked.bind(this),{jslogContext:"copy-watch-expression-value"});const o=t.UIUtils.deepElementFromEvent(i);o&&this.valueElement.isSelfOrAncestor(o)&&this.result&&e.appendApplicableItems(this.result)}copyValueButtonClicked(){c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(this.valueElement.textContent)}static watchObjectGroupId="watch-group"}var Nn=Object.freeze({__proto__:null,WatchExpressionsSidebarPane:Fn,WatchExpression:Dn});export{V as AddSourceMapURLDialog,$ as BreakpointEditDialog,He as CSSPlugin,oe as CallStackSidebarPane,ue as CategorizedBreakpointL10n,ke as CoveragePlugin,Xe as DebuggerPausedMessage,Ro as DebuggerPlugin,yt as EditingLocationHistoryManager,jo as FilePathScoreFunction,_o as FilteredUISourceCodeListProvider,Ko as GoToLineQuickOpen,en as InplaceFormatterEditorAction,vt as NavigatorView,tn as OpenFileQuickOpen,cn as OutlineQuickOpen,pe as Plugin,Ot as ResourceOriginPlugin,mn as ScopeChainSidebarPane,nt as SearchSourcesView,$t as SnippetsPlugin,xn as SourcesNavigator,qi as SourcesPanel,tt as SourcesSearchScope,Li as SourcesView,Si as TabbedEditorContainer,Ai as ThreadsSidebarPane,ai as UISourceCodeFrame,Nn as WatchExpressionsSidebarPane}; +import*as e from"../../core/i18n/i18n.js";import*as t from"../../ui/legacy/legacy.js";import*as i from"../../core/common/common.js";import*as o from"../../core/sdk/sdk.js";import*as n from"../../third_party/codemirror.next/codemirror.next.js";import*as r from"../../ui/components/icon_button/icon_button.js";import*as s from"../../ui/components/text_editor/text_editor.js";import*as a from"../../ui/visual_logging/visual_logging.js";import*as c from"../../core/host/host.js";import*as l from"../../core/platform/platform.js";import{assertNotNullOrUndefined as d}from"../../core/platform/platform.js";import*as u from"../../models/bindings/bindings.js";import*as h from"../../models/persistence/persistence.js";import*as p from"../../models/source_map_scopes/source_map_scopes.js";import*as g from"../../models/text_utils/text_utils.js";import*as m from"../../ui/legacy/components/source_frame/source_frame.js";import*as b from"../coverage/coverage.js";import*as f from"../../models/workspace/workspace.js";import*as S from"../../ui/legacy/components/color_picker/color_picker.js";import*as v from"../../ui/legacy/components/inline_editor/inline_editor.js";import*as C from"../../core/root/root.js";import*as w from"../../models/breakpoints/breakpoints.js";import*as I from"../../models/formatter/formatter.js";import*as y from"../../ui/legacy/components/object_ui/object_ui.js";import*as x from"./components/components.js";import*as k from"../../models/extensions/extensions.js";import*as T from"../snippets/snippets.js";import*as E from"../search/search.js";import*as L from"../../ui/legacy/components/quick_open/quick_open.js";import*as M from"../../models/issues_manager/issues_manager.js";import*as P from"../../ui/components/adorners/adorners.js";import*as F from"../../ui/components/issue_counter/issue_counter.js";import*as D from"../../ui/legacy/components/utils/utils.js";import{PanelUtils as N}from"../utils/utils.js";import*as A from"../../ui/components/buttons/buttons.js";const U=new CSSStyleSheet;U.replaceSync(':host{padding:10px}.widget{align-items:center}label{white-space:nowrap}input[type="text"].add-source-map{box-shadow:0 0 0 1px var(--box-shadow-outline-color);font-size:inherit;margin:0 8px 0 5px}\n/*# sourceURL=dialog.css */\n');const R={sourceMapUrl:"Source map URL: ",debugInfoUrl:"DWARF symbols URL: ",add:"Add"},B=e.i18n.registerUIStrings("panels/sources/AddSourceMapURLDialog.ts",R),j=e.i18n.getLocalizedString.bind(void 0,B);class V extends t.Widget.HBox{input;dialog;callback;constructor(e,i,o){super(!0),this.contentElement.createChild("label").textContent=e,this.input=t.UIUtils.createInput("add-source-map","text","url"),this.input.addEventListener("keydown",this.onKeyDown.bind(this),!1),this.contentElement.appendChild(this.input);const n=t.UIUtils.createTextButton(j(R.add),this.apply.bind(this),{jslogContext:"add"});this.contentElement.appendChild(n),this.dialog=new t.Dialog.Dialog(i),this.dialog.setSizeBehavior("MeasureContent"),this.dialog.setDefaultFocusedElement(this.input),this.callback=o}static createAddSourceMapURLDialog(e){return new V(j(R.sourceMapUrl),"add-source-map-url",e)}static createAddDWARFSymbolsURLDialog(e){return new V(j(R.debugInfoUrl),"add-debug-info-url",e)}show(){super.show(this.dialog.contentElement),this.dialog.show()}done(e){this.dialog.hide(),this.callback(e)}apply(){this.done(this.input.value)}onKeyDown(e){"Enter"===e.key&&(e.consume(!0),this.apply())}wasShown(){super.wasShown(),this.registerCSSFiles([U])}}var W=Object.freeze({__proto__:null,AddDebugInfoURLDialog:V});const O=new CSSStyleSheet;O.replaceSync(":host{z-index:30;padding:4px;background-color:var(--sys-color-surface3);border-radius:7px;border:2px solid var(--sys-color-divider);width:90%;pointer-events:auto}:host(.sources-edit-breakpoint-dialog){border-radius:0;z-index:30;background-color:var(--sys-color-surface3);width:555px;pointer-events:auto;margin-left:-1px;padding:0 10px 10px 5px;border:1px solid var(--sys-color-divider)}:host-context(.sources-edit-breakpoint-dialog) .condition-editor{background-color:var(--sys-color-cdt-base-container);margin:0 6px 20px 3px}:host-context(.sources-edit-breakpoint-dialog) .source-frame-breakpoint-toolbar{font-family:sans-serif;font-size:12px}:host-context(.sources-edit-breakpoint-dialog) .link,\n.devtools-link{font-family:sans-serif;font-size:12px;margin:0 3px}:host-context(.sources-edit-breakpoint-dialog) devtools-icon.link-icon{vertical-align:sub;margin-right:0.5ch;color:var(--icon-link);width:16px;height:16px}:host-context(.sources-edit-breakpoint-dialog) .link-wrapper{display:inline-flex}:host-context(.sources-edit-breakpoint-dialog) .dialog-header{display:flex;justify-content:space-between;align-items:center}:host-context(.sources-edit-breakpoint-dialog) .dialog-header > devtools-icon:hover{color:var(--icon-default-hover)}\n/*# sourceURL=breakpointEditDialog.css */\n");const{Direction:H}=s.TextEditorHistory,_={breakpointType:"Breakpoint type",breakpoint:"Breakpoint",closeDialog:"Close edit dialog and save changes",conditionalBreakpoint:"Conditional breakpoint",logpoint:"Logpoint",expressionToCheckBeforePausingEg:"Expression to check before pausing, e.g. x > 5",pauseOnlyWhenTheConditionIsTrue:"Pause only when the condition is true",learnMoreOnBreakpointTypes:"Learn more: Breakpoint Types",logMessageEgXIsX:"Log message, e.g. `'x is', x`",logAMessageToConsoleDoNotBreak:"Log a message to Console, do not break"},z=e.i18n.registerUIStrings("panels/sources/BreakpointEditDialog.ts",_),q=e.i18n.getLocalizedString.bind(void 0,z);class $ extends t.Widget.Widget{onFinish;finished;editor;typeSelector;placeholderCompartment;#e;#t;constructor(e,o,c,l){super(!0);const d=[n.javascript.javascriptLanguage,s.Config.baseConfiguration(o||""),s.Config.closeBrackets,s.Config.autocompletion.instance(),n.EditorView.lineWrapping,s.Config.showCompletionHint,s.Config.conservativeCompletion,n.javascript.javascriptLanguage.data.of({autocomplete:e=>this.#t.historyCompletions(e)}),n.autocompletion(),s.JavaScript.argumentHints()];this.onFinish=l,this.finished=!1,this.element.tabIndex=-1,this.element.classList.add("sources-edit-breakpoint-dialog"),this.element.setAttribute("jslog",`${a.dialog("edit-breakpoint")}`);const u=this.contentElement.createChild("div","dialog-header"),h=new t.Toolbar.Toolbar("source-frame-breakpoint-toolbar",u);h.appendText(`Line ${e+1}:`),this.typeSelector=new t.Toolbar.ToolbarComboBox(this.onTypeChanged.bind(this),q(_.breakpointType),void 0,"type"),this.typeSelector.createOption(q(_.breakpoint),"REGULAR_BREAKPOINT");const p=this.typeSelector.createOption(q(_.conditionalBreakpoint),"CONDITIONAL_BREAKPOINT"),g=this.typeSelector.createOption(q(_.logpoint),"LOGPOINT");this.typeSelector.select(c?g:p),h.appendToolbarItem(this.typeSelector);const m=o||"",b=e=>(s.JavaScript.isExpressionComplete(e.state.doc.toString()).then((t=>{t?this.finishEditing(!0,this.editor.state.doc.toString()):n.insertNewlineAndIndent(e)})),!0),f=[{key:"ArrowUp",run:()=>this.#t.moveHistory(-1)},{key:"ArrowDown",run:()=>this.#t.moveHistory(1)},{mac:"Ctrl-p",run:()=>this.#t.moveHistory(-1,!0)},{mac:"Ctrl-n",run:()=>this.#t.moveHistory(1,!0)},{key:"Mod-Enter",run:b},{key:"Enter",run:b},{key:"Shift-Enter",run:n.insertNewlineAndIndent},{key:"Escape",run:()=>(this.finishEditing(!1,""),!0)}];this.placeholderCompartment=new n.Compartment;const S=this.contentElement.appendChild(document.createElement("div"));S.classList.add("condition-editor"),S.setAttribute("jslog",`${a.textField()}`),this.editor=new s.TextEditor.TextEditor(n.EditorState.create({doc:m,selection:{anchor:0,head:m.length},extensions:[this.placeholderCompartment.of(this.getPlaceholder()),n.keymap.of(f),d]})),S.appendChild(this.editor);const v=new r.Icon.Icon;v.name="cross",v.title=q(_.closeDialog),v.setAttribute("jslog",`${a.close().track({click:!0})}`),v.onclick=()=>this.finishEditing(!0,this.editor.state.doc.toString()),u.appendChild(v),this.#e=new s.AutocompleteHistory.AutocompleteHistory(i.Settings.Settings.instance().createLocalSetting("breakpoint-condition-history",[])),this.#t=new s.TextEditorHistory.TextEditorHistory(this.editor,this.#e);const C=this.contentElement.appendChild(document.createElement("div"));C.classList.add("link-wrapper");const w=t.Fragment.html`<x-link class="link devtools-link" tabindex="0" href="https://goo.gle/devtools-loc" + jslog="${a.link("learn-more")}">${q(_.learnMoreOnBreakpointTypes)}</x-link>`,I=new r.Icon.Icon;I.name="open-externally",I.classList.add("link-icon"),w.prepend(I),C.appendChild(w),this.updateTooltip()}saveAndFinish(){this.finishEditing(!0,this.editor.state.doc.toString())}focusEditor(){this.editor.editor.focus()}onTypeChanged(){"REGULAR_BREAKPOINT"!==this.breakpointType?(this.focusEditor(),this.editor.dispatch({effects:this.placeholderCompartment.reconfigure(this.getPlaceholder())}),this.updateTooltip()):this.finishEditing(!0,"")}get breakpointType(){const e=this.typeSelector.selectedOption();return e?e.value:null}getPlaceholder(){const e=this.breakpointType;return"CONDITIONAL_BREAKPOINT"===e?n.placeholder(q(_.expressionToCheckBeforePausingEg)):"LOGPOINT"===e?n.placeholder(q(_.logMessageEgXIsX)):[]}updateTooltip(){const e=this.breakpointType;"CONDITIONAL_BREAKPOINT"===e?t.Tooltip.Tooltip.install(this.typeSelector.element,q(_.pauseOnlyWhenTheConditionIsTrue)):"LOGPOINT"===e&&t.Tooltip.Tooltip.install(this.typeSelector.element,q(_.logAMessageToConsoleDoNotBreak))}finishEditing(e,t){if(this.finished)return;this.finished=!0,this.editor.remove(),this.#e.pushHistoryItem(t);const i="LOGPOINT"===this.breakpointType;this.onFinish({committed:e,condition:t,isLogpoint:i})}wasShown(){super.wasShown(),this.registerCSSFiles([O])}get editorForTest(){return this.editor}}var G=Object.freeze({__proto__:null,BreakpointEditDialog:$});const K=new CSSStyleSheet;K.replaceSync('.call-frame-warnings-message{text-align:center;font-style:italic;padding:4px;color:var(--sys-color-on-surface-yellow);background-color:var(--sys-color-surface-yellow)}.ignore-listed-message{padding:1px}.ignore-listed-message-label{color:var(--sys-color-token-subtle);align-items:center;display:flex}.show-more-message > .link{margin-left:5px}.show-more-message{text-align:center;font-style:italic;padding:4px;border-top:1px solid var(--sys-color-divider)}.call-frame-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.call-frame-title-text{text-overflow:ellipsis;overflow:hidden}.async-header + .call-frame-item{border-top:0}.call-frame-item:not(.async-header){border-top:1px solid var(--sys-color-divider)}.call-frame-item-title,\n.call-frame-location{display:flex;white-space:nowrap}.async-header .call-frame-item-title{font-weight:bold;color:var(--sys-color-on-surface);background-color:var(--sys-color-cdt-base-container);margin-left:-5px;padding:0 5px;z-index:1}.call-frame-item:focus-visible,\n.call-frame-item.async-header:focus-visible .call-frame-item-title{background-color:var(--sys-color-tonal-container)}.ignore-listed-checkbox:focus-visible{outline-width:unset}.call-frame-item:not(.async-header):hover{background-color:var(--sys-color-state-hover-on-subtle)}.call-frame-location{color:var(--sys-color-token-subtle);margin-left:auto;padding:0 10px}.async-header::before{content:" ";width:100%;border-top:1px solid var(--sys-color-divider);margin-top:8px;position:absolute;left:0}.ignore-listed-call-frame{opacity:60%;font-style:italic}.selected-call-frame-icon{display:none;position:absolute;top:3px;left:4px}.call-frame-item.selected .selected-call-frame-icon{display:block}.call-frame-warning-icon{display:block;position:absolute;top:3px;right:4px}@media (forced-colors: active){.call-frame-item:focus-visible,\n .call-frame-item:not(.async-header):hover{forced-color-adjust:none;background-color:Highlight}.call-frame-item:focus-visible *,\n .call-frame-item:not(.async-header):hover *{color:HighlightText}}\n/*# sourceURL=callStackSidebarPane.css */\n');const J={callStack:"Call Stack",notPaused:"Not paused",onIgnoreList:"on ignore list",showIgnorelistedFrames:"Show ignore-listed frames",showMore:"Show more",copyStackTrace:"Copy stack trace",callFrameWarnings:"Some call frames have warnings",debugFileNotFound:'Failed to load debug file "{PH1}".',restartFrame:"Restart frame"},X=e.i18n.registerUIStrings("panels/sources/CallStackSidebarPane.ts",J),Y=e.i18n.getLocalizedString.bind(void 0,X);let Q;class Z extends t.View.SimpleView{ignoreListMessageElement;ignoreListCheckboxElement;notPausedMessageElement;callFrameWarningsElement;items;list;showMoreMessageElement;showIgnoreListed;locationPool;updateThrottler;maxAsyncStackChainDepth;updateItemThrottler;scheduledForUpdateItems;muteActivateItem;lastDebuggerModel=null;constructor(){super(Y(J.callStack),!0,"sources.callstack"),this.contentElement.setAttribute("jslog",`${a.section("sources.callstack")}`),({element:this.ignoreListMessageElement,checkbox:this.ignoreListCheckboxElement}=this.createIgnoreListMessageElementAndCheckbox()),this.contentElement.appendChild(this.ignoreListMessageElement),this.notPausedMessageElement=this.contentElement.createChild("div","gray-info-message"),this.notPausedMessageElement.textContent=Y(J.notPaused),this.notPausedMessageElement.tabIndex=-1,this.callFrameWarningsElement=this.contentElement.createChild("div","call-frame-warnings-message");const e=new r.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("call-frame-warning-icon"),this.callFrameWarningsElement.appendChild(e),this.callFrameWarningsElement.appendChild(document.createTextNode(Y(J.callFrameWarnings))),this.callFrameWarningsElement.tabIndex=-1,this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport),this.contentElement.appendChild(this.list.element),this.list.element.addEventListener("contextmenu",this.onContextMenu.bind(this),!1),self.onInvokeElement(this.list.element,(e=>{const t=this.list.itemForNode(e.target);t&&(this.activateItem(t),e.consume(!0))})),this.showMoreMessageElement=this.createShowMoreMessageElement(),this.showMoreMessageElement.classList.add("hidden"),this.contentElement.appendChild(this.showMoreMessageElement),this.showIgnoreListed=!1,this.locationPool=new u.LiveLocation.LiveLocationPool,this.updateThrottler=new i.Throttler.Throttler(100),this.maxAsyncStackChainDepth=ie,this.update(),this.updateItemThrottler=new i.Throttler.Throttler(100),this.scheduledForUpdateItems=new Set,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this)}static instance(e={forceNew:null}){const{forceNew:t}=e;return Q&&!t||(Q=new Z),Q}flavorChanged(e){this.showIgnoreListed=!1,this.ignoreListCheckboxElement.checked=!1,this.maxAsyncStackChainDepth=ie,this.update()}debugInfoAttached(){this.update()}setSourceMapSubscription(e){this.lastDebuggerModel!==e&&(this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this),this.lastDebuggerModel=e,this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this))}update(){this.updateThrottler.schedule((()=>this.doUpdate()))}async doUpdate(){this.locationPool.disposeAll(),this.callFrameWarningsElement.classList.add("hidden");const e=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.setSourceMapSubscription(e?.debuggerModel??null),!e)return this.notPausedMessageElement.classList.remove("hidden"),this.ignoreListMessageElement.classList.add("hidden"),this.showMoreMessageElement.classList.add("hidden"),this.items.replaceAll([]),void t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,null);this.notPausedMessageElement.classList.add("hidden");const i=[],n=new Set;for(const t of e.callFrames){const e=oe.createForDebuggerCallFrame(t,this.locationPool,this.refreshItem.bind(this)).then((e=>(ee.set(e,t),e)));i.push(e),t.missingDebugInfoDetails&&n.add(t.missingDebugInfoDetails.details)}const r=await Promise.all(i);n.size&&(this.callFrameWarningsElement.classList.remove("hidden"),t.Tooltip.Tooltip.install(this.callFrameWarningsElement,Array.from(n).join("\n")));let s=e.debuggerModel,a=e.asyncStackTraceId,c=e.asyncStackTrace,l=e.callFrames;for(let{maxAsyncStackChainDepth:e}=this;e>0;--e){if(!c){if(!a)break;if(a.debuggerId){const e=await o.DebuggerModel.DebuggerModel.modelForDebuggerId(a.debuggerId);if(!e)break;s=e}if(c=await s.fetchAsyncStackTrace(a),!c)break}const e=t.UIUtils.asyncStackTraceLabel(c.description,l);r.push(...await oe.createItemsForAsyncStack(e,s,c.callFrames,this.locationPool,this.refreshItem.bind(this))),l=c.callFrames,a=c.parentId,c=c.parent}this.showMoreMessageElement.classList.toggle("hidden",!c),this.items.replaceAll(r);for(const e of this.items)this.refreshItem(e);if(this.maxAsyncStackChainDepth===ie){this.list.selectNextItem(!0,!1);const e=this.list.selectedItem();e&&this.activateItem(e)}this.updatedForTest()}updatedForTest(){}refreshItem(e){this.scheduledForUpdateItems.add(e),this.updateItemThrottler.schedule((async()=>{const e=Array.from(this.scheduledForUpdateItems);if(this.scheduledForUpdateItems.clear(),this.muteActivateItem=!0,!this.showIgnoreListed&&this.items.every((e=>e.isIgnoreListed))){this.showIgnoreListed=!0;for(let e=0;e<this.items.length;++e)this.list.refreshItemByIndex(e);this.ignoreListMessageElement.classList.toggle("hidden",!0)}else{this.showIgnoreListed=this.ignoreListCheckboxElement.checked;const t=new Set(e);let i=!1;for(let e=0;e<this.items.length;++e){const o=this.items.at(e);t.has(o)&&this.list.refreshItemByIndex(e),i=i||o.isIgnoreListed}this.ignoreListMessageElement.classList.toggle("hidden",!i)}delete this.muteActivateItem}))}createElementForItem(e){const i=document.createElement("div");i.classList.add("call-frame-item");const n=i.createChild("div","call-frame-item-title").createChild("div","call-frame-title-text");if(n.textContent=e.title,e.isAsyncHeader)i.classList.add("async-header");else{t.Tooltip.Tooltip.install(n,e.title);const o=i.createChild("div","call-frame-location");o.textContent=l.StringUtilities.trimMiddle(e.linkText,30),t.Tooltip.Tooltip.install(o,e.linkText),i.classList.toggle("ignore-listed-call-frame",e.isIgnoreListed),e.isIgnoreListed&&t.ARIAUtils.setDescription(i,Y(J.onIgnoreList)),ee.has(e)||t.ARIAUtils.setDisabled(i,!0)}const s=ee.get(e),a=s===t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);i.classList.toggle("selected",a),t.ARIAUtils.setSelected(i,a),i.classList.toggle("hidden",!this.showIgnoreListed&&e.isIgnoreListed);const c=new r.Icon.Icon;if(c.data={iconName:"large-arrow-right-filled",color:"var(--icon-arrow-main-thread)",width:"14px",height:"14px"},c.classList.add("selected-call-frame-icon"),i.appendChild(c),i.tabIndex=e===this.list.selectedItem()?0:-1,s&&s.missingDebugInfoDetails){const e=new r.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("call-frame-warning-icon");const o=s.missingDebugInfoDetails.resources.map((e=>Y(J.debugFileNotFound,{PH1:e})));t.Tooltip.Tooltip.install(e,[s.missingDebugInfoDetails.details,...o].join("\n")),i.appendChild(e)}return i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1),o&&(this.setDefaultFocusedElement(o),o.tabIndex=0,this.hasFocus()&&o.focus())}updateSelectedItemARIA(e,t){return!0}createIgnoreListMessageElementAndCheckbox(){const e=document.createElement("div");e.classList.add("ignore-listed-message");const t=e.createChild("label");t.classList.add("ignore-listed-message-label");const i=t.createChild("input");i.tabIndex=0,i.type="checkbox",i.classList.add("ignore-listed-checkbox"),t.append(Y(J.showIgnorelistedFrames));return i.addEventListener("click",(()=>{this.showIgnoreListed=i.checked;for(const e of this.items)this.refreshItem(e)})),{element:e,checkbox:i}}createShowMoreMessageElement(){const e=document.createElement("div");e.classList.add("show-more-message"),e.createChild("span");const t=e.createChild("span","link");return t.textContent=Y(J.showMore),t.addEventListener("click",(()=>{this.maxAsyncStackChainDepth+=ie,this.update()}),!1),e}onContextMenu(e){const i=this.list.itemForNode(e.target);if(!i)return;const o=new t.ContextMenu.ContextMenu(e),n=ee.get(i);n&&o.defaultSection().appendItem(Y(J.restartFrame),(()=>{c.userMetrics.actionTaken(c.UserMetrics.Action.StackFrameRestarted),n.restart()}),{disabled:!n.canBeRestarted,jslogContext:"restart-frame"}),o.defaultSection().appendItem(Y(J.copyStackTrace),this.copyStackTrace.bind(this),{jslogContext:"copy-stack-trace"}),i.uiLocation&&this.appendIgnoreListURLContextMenuItems(o,i.uiLocation.uiSourceCode),o.show()}onClick(e){const t=this.list.itemForNode(e.target);t&&this.activateItem(t)}activateItem(e){const n=e.uiLocation;if(this.muteActivateItem||!n)return;this.list.selectItem(e);const r=ee.get(e),s=this.activeCallFrameItem();r&&s!==e?(r.debuggerModel.setSelectedCallFrame(r),t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,r),s&&this.refreshItem(s),this.refreshItem(e)):i.Revealer.reveal(n)}activeCallFrameItem(){const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);return e&&this.items.find((t=>ee.get(t)===e))||null}appendIgnoreListURLContextMenuItems(e,t){const i=h.Persistence.PersistenceImpl.instance().binding(t);i&&(t=i.network);const o=e.section("ignoreList");if(!(o.items.length>0))for(const{text:e,callback:i,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListURLContextMenuItems(t))o.appendItem(e,i,{jslogContext:n})}selectNextCallFrameOnStack(){const e=this.activeCallFrameItem();for(let t=e?this.items.indexOf(e)+1:0;t<this.items.length;t++){const e=this.items.at(t);if(ee.has(e)){this.activateItem(e);break}}}selectPreviousCallFrameOnStack(){const e=this.activeCallFrameItem();for(let t=e?this.items.indexOf(e)-1:this.items.length-1;t>=0;t--){const e=this.items.at(t);if(ee.has(e)){this.activateItem(e);break}}}copyStackTrace(){const e=[];for(const t of this.items){let i=t.title;t.uiLocation&&(i+=" ("+t.uiLocation.linkText(!0)+")"),e.push(i)}c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.join("\n"))}wasShown(){super.wasShown(),this.registerCSSFiles([K])}}const ee=new WeakMap,te=Symbol("element"),ie=32;class oe{isIgnoreListed;title;linkText;uiLocation;isAsyncHeader;updateDelegate;static async createForDebuggerCallFrame(e,i,o){const n=e.functionName,r=new oe(t.UIUtils.beautifyFunctionName(n),o);return await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),r.update.bind(r),i),p.NamesResolver.resolveDebuggerFrameFunctionName(e).then((e=>{e&&e!==n&&(r.title=e,r.updateDelegate(r))})),r}static async createItemsForAsyncStack(e,i,o,n,r){const s=new WeakMap,a=new oe(e,r);s.set(a,new Set),a.isAsyncHeader=!0;const c=[],l=[];for(const e of o){const o=new oe(t.UIUtils.beautifyFunctionName(e.functionName),d),r=i.createRawLocationByScriptId(e.scriptId,e.lineNumber,e.columnNumber);l.push(u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(r,o.update.bind(o),n)),c.push(o)}return await Promise.all(l),r(a),[a,...c];function d(e){r(e);let t=!1;const i=s.get(a);i&&(e.isIgnoreListed?(i.delete(e),t=0===i.size):(t=0===i.size,i.add(e)),a.isIgnoreListed=0===i.size),t&&r(a)}}constructor(e,t){this.isIgnoreListed=!1,this.title=e,this.linkText="",this.uiLocation=null,this.isAsyncHeader=!1,this.updateDelegate=t}async update(e){const t=await e.uiLocation();this.isIgnoreListed=await e.isIgnoreListed(),this.linkText=t?t.linkText():"",this.uiLocation=t,this.updateDelegate(this)}}var ne=Object.freeze({__proto__:null,CallStackSidebarPane:Z,elementSymbol:te,defaultMaxAsyncStackChainDepth:ie,ActionDelegate:class{handleAction(e,t){switch(t){case"debugger.next-call-frame":return Z.instance().selectNextCallFrameOnStack(),!0;case"debugger.previous-call-frame":return Z.instance().selectPreviousCallFrameOnStack(),!0}return!1}},Item:oe});const re={beforeBidderWorkletBiddingStart:"Bidder Bidding Phase Start",beforeBidderWorkletReportingStart:"Bidder Reporting Phase Start",beforeSellerWorkletScoringStart:"Seller Scoring Phase Start",beforeSellerWorkletReportingStart:"Seller Reporting Phase Start",setTimeoutOrIntervalFired:"{PH1} fired",scriptFirstStatement:"Script First Statement",scriptBlockedByContentSecurity:"Script Blocked by Content Security Policy",requestAnimationFrame:"Request Animation Frame",cancelAnimationFrame:"Cancel Animation Frame",animationFrameFired:"Animation Frame Fired",webglErrorFired:"WebGL Error Fired",webglWarningFired:"WebGL Warning Fired",setInnerhtml:"Set `innerHTML`",createCanvasContext:"Create canvas context",createAudiocontext:"Create `AudioContext`",closeAudiocontext:"Close `AudioContext`",resumeAudiocontext:"Resume `AudioContext`",suspendAudiocontext:"Suspend `AudioContext`",sinkViolations:"Sink Violations",policyViolations:"Policy Violations"},se=e.i18n.registerUIStrings("panels/sources/CategorizedBreakpointL10n.ts",re),ae=e.i18n.getLazilyComputedLocalizedString.bind(void 0,se);function ce(t){return(ue.get(t)??e.i18n.lockedLazyString(t))()}const le={beforeBidderWorkletBiddingStart:ae(re.beforeBidderWorkletBiddingStart),beforeBidderWorkletReportingStart:ae(re.beforeBidderWorkletReportingStart),beforeSellerWorkletScoringStart:ae(re.beforeSellerWorkletScoringStart),beforeSellerWorkletReportingStart:ae(re.beforeSellerWorkletReportingStart),setTimeout:e.i18n.lockedLazyString("setTimeout"),clearTimeout:e.i18n.lockedLazyString("clearTimeout"),setInterval:e.i18n.lockedLazyString("setInterval"),clearInterval:e.i18n.lockedLazyString("clearInterval"),"setTimeout.callback":ae(re.setTimeoutOrIntervalFired,{PH1:"setTimeout"}),"setInterval.callback":ae(re.setTimeoutOrIntervalFired,{PH1:"setInterval"}),scriptFirstStatement:ae(re.scriptFirstStatement),scriptBlockedByCSP:ae(re.scriptBlockedByContentSecurity),sharedStorageWorkletScriptFirstStatement:ae(re.scriptFirstStatement),requestAnimationFrame:ae(re.requestAnimationFrame),cancelAnimationFrame:ae(re.cancelAnimationFrame),"requestAnimationFrame.callback":ae(re.animationFrameFired),webglErrorFired:ae(re.webglErrorFired),webglWarningFired:ae(re.webglWarningFired),"Element.setInnerHTML":ae(re.setInnerhtml),canvasContextCreated:ae(re.createCanvasContext),"Geolocation.getCurrentPosition":e.i18n.lockedLazyString("getCurrentPosition"),"Geolocation.watchPosition":e.i18n.lockedLazyString("watchPosition"),"Notification.requestPermission":e.i18n.lockedLazyString("requestPermission"),"DOMWindow.close":e.i18n.lockedLazyString("window.close"),"Document.write":e.i18n.lockedLazyString("document.write"),audioContextCreated:ae(re.createAudiocontext),audioContextClosed:ae(re.closeAudiocontext),audioContextResumed:ae(re.resumeAudiocontext),audioContextSuspended:ae(re.suspendAudiocontext)},de={"trustedtype-policy-violation":ae(re.policyViolations),"trustedtype-sink-violation":ae(re.sinkViolations)},ue=new Map([...Object.entries(le),...Object.entries(de)]);var he=Object.freeze({__proto__:null,getLocalizedBreakpointName:ce});class pe{uiSourceCode;constructor(e,t){this.uiSourceCode=e}static accepts(e){return!1}willHide(){}rightToolbarItems(){return[]}leftToolbarItems(){return[]}populateLineGutterContextMenu(e,t){}populateTextAreaContextMenu(e,t,i){}decorationChanged(e,t){}editorExtension(){return[]}editorInitialized(e){}dispose(){}}var ge=Object.freeze({__proto__:null,Plugin:pe});const me={clickToShowCoveragePanel:"Click to show Coverage Panel",showDetails:"Show Details",coverageS:"Coverage: {PH1}",coverageNa:"Coverage: n/a"},be=e.i18n.registerUIStrings("panels/sources/CoveragePlugin.ts",me),fe=e.i18n.getLocalizedString.bind(void 0,be);class Se extends pe{originalSourceCode;infoInToolbar;model;coverage;#i;constructor(e,i){super(e),this.originalSourceCode=this.uiSourceCode,this.#i=i,this.infoInToolbar=new t.Toolbar.ToolbarButton(fe(me.clickToShowCoveragePanel),void 0,void 0,"debugger.show-coverage"),this.infoInToolbar.setSecondary(),this.infoInToolbar.addEventListener("Click",(()=>{t.ViewManager.ViewManager.instance().showView("coverage")}));const n=o.TargetManager.TargetManager.instance().primaryPageTarget();n&&(this.model=n.model(b.CoverageModel.CoverageModel),this.model&&(this.model.addEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this),this.coverage=this.model.getCoverageForUrl(this.originalSourceCode.url()),this.coverage&&this.coverage.addEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this))),this.updateStats()}dispose(){this.coverage&&this.coverage.removeEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this),this.model&&this.model.removeEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this)}static accepts(e){return e.contentType().isDocumentOrScriptOrStyleSheet()}handleReset(){this.coverage=null,this.updateStats()}handleCoverageSizesChanged(){this.updateStats()}updateStats(){if(this.coverage){this.infoInToolbar.setTitle(fe(me.showDetails));const t=new Intl.NumberFormat(e.DevToolsLocale.DevToolsLocale.instance().locale,{style:"percent",maximumFractionDigits:1});this.infoInToolbar.setText(fe(me.coverageS,{PH1:t.format(this.coverage.usedPercentage())}))}else this.infoInToolbar.setTitle(fe(me.clickToShowCoveragePanel)),this.infoInToolbar.setText(fe(me.coverageNa))}rightToolbarItems(){return[this.infoInToolbar]}editorExtension(){return xe.of([])}getCoverageManager(){return this.uiSourceCode.getDecorationData("coverage")}editorInitialized(e){this.getCoverageManager()&&this.startDecoUpdate(e)}decorationChanged(e,t){"coverage"===e&&this.startDecoUpdate(t)}startDecoUpdate(e){const i=this.getCoverageManager();(i?i.usageByLine(this.uiSourceCode,this.#o(e)):Promise.resolve([])).then((i=>{const o=Boolean(e.state.field(ye,!1));var r;i.length?o?e.dispatch({effects:Ie.of(i)}):e.dispatch({effects:xe.reconfigure([ye.init((e=>we(i,e))),(r=this.uiSourceCode.url(),n.gutter({markers:e=>e.state.field(ye),domEventHandlers:{click:()=>(t.ViewManager.ViewManager.instance().showView("coverage").then((()=>{const e=t.ViewManager.ViewManager.instance().view("coverage");return e&&e.widget()})).then((e=>{const t=r.match(/(.*):formatted$/),i=t&&t[1]||r;e.selectCoverageItemByUrl(i)})),!0)},class:"cm-coverageGutter"})),ke])}):o&&e.dispatch({effects:xe.reconfigure([])})}))}#o(e){const t=[];for(let i=1;i<=e.state.doc.lines;++i){const o=e.state.doc.line(i),{lineNumber:n,columnNumber:r}=this.#i.editorLocationToUILocation(i-1,0),{lineNumber:s,columnNumber:a}=this.#i.editorLocationToUILocation(i-1,o.length);t.push(new g.TextRange.TextRange(n,r,s,a))}return t}}const ve=new class extends n.GutterMarker{elementClass="cm-coverageUsed"},Ce=new class extends n.GutterMarker{elementClass="cm-coverageUnused"};function we(e,t){const i=new n.RangeSetBuilder;for(let o=0;o<e.length;o++){const n=e[o];if(void 0!==n&&o<t.doc.lines){const e=t.doc.line(o+1).from;i.add(e,e,n?ve:Ce)}}return i.finish()}const Ie=n.StateEffect.define(),ye=n.StateField.define({create:()=>n.RangeSet.empty,update:(e,t)=>t.effects.reduce(((e,i)=>i.is(Ie)?we(i.value,t.state):e),e.map(t.changes))});const xe=new n.Compartment,ke=n.EditorView.baseTheme({".cm-coverageGutter":{width:"5px",marginLeft:"3px"},".cm-coverageUnused":{backgroundColor:"var(--app-color-coverage-unused)"},".cm-coverageUsed":{backgroundColor:"var(--app-color-coverage-used)"}});var Te=Object.freeze({__proto__:null,CoveragePlugin:Se});const Ee={openColorPicker:"Open color picker.",openCubicBezierEditor:"Open cubic bezier editor.",addSourceMap:"Add source map…"},Le=e.i18n.registerUIStrings("panels/sources/CSSPlugin.ts",Ee),Me=e.i18n.getLocalizedString.bind(void 0,Le),Pe=new Set(["ColorLiteral","NumberLiteral","StringLiteral","Comment","Important"]);async function Fe(e,t,i){const r=n.syntaxTree(e.state).resolveInner(e.pos,-1);if("ClassName"===r.name){d(i);const e=function(e,t){const i=t.getStyleSheetIdsForURL(e);if(0===i.length)throw new Error("Can't find style sheet ID for current URL");return i[0]}(t.url(),i),o=await i.getClassNames(e);return{from:r.from,options:o.map((e=>({type:"constant",label:e})))}}const s=function(e,t){if(Pe.has(e.name))return null;for(let i=e;i&&"StyleSheet"!==i.name&&"Styles"!==i.name&&"CallExpression"!==i.name;i=i.parent)if("Declaration"===i.name){const e=i.getChild("PropertyName"),o=i.getChild(":");return e&&o&&o.to<=t?e:null}return null}(r,e.pos);if(s){const t=o.CSSMetadata.cssMetadata().getPropertyValues(e.state.sliceDoc(s.from,s.to));return{from:"ValueName"===r.name?r.from:e.pos,options:t.map((e=>({type:"constant",label:e}))),validFor:/^[\w\P{ASCII}\-]+$/u}}return null}class De extends n.WidgetType{#n;#r;#s;constructor(e,t,i){super(),this.#r=e,this.#n=t,this.#s=i}eq(e){return this.#r.equal(e.#r)&&this.#n===e.#n&&this.#s===e.#s}toDOM(e){const t=new v.ColorSwatch.ColorSwatch;t.renderColor(this.#r,!1,Me(Ee.openColorPicker));const i=t.createChild("span");return i.textContent=this.#n,i.setAttribute("hidden","true"),t.addEventListener(v.ColorSwatch.ColorChangedEvent.eventName,(i=>{e.dispatch({changes:{from:this.#s,to:this.#s+this.#n.length,insert:i.data.text}}),this.#n=i.data.text,this.#r=t.getColor()})),t.addEventListener(v.ColorSwatch.ClickEvent.eventName,(i=>{i.consume(!0),e.dispatch({effects:Ae.of({type:0,pos:e.posAtDOM(t),text:this.#n,swatch:t,color:this.#r})})})),t}ignoreEvent(){return!0}}class Ne extends n.WidgetType{curve;text;constructor(e,t){super(),this.curve=e,this.text=t}eq(e){return this.curve.asCSSText()===e.curve.asCSSText()&&this.text===e.text}toDOM(e){const i=v.Swatches.BezierSwatch.create();return i.setBezierText(this.text),t.Tooltip.Tooltip.install(i.iconElement(),Me(Ee.openCubicBezierEditor)),i.iconElement().addEventListener("click",(t=>{t.consume(!0),e.dispatch({effects:Ae.of({type:1,pos:e.posAtDOM(i),text:this.text,swatch:i,curve:this.curve})})}),!1),i.hideText(!0),i}ignoreEvent(){return!0}}const Ae=n.StateEffect.define(),Ue=n.Annotation.define(),Re=n.StateField.define({create:()=>null,update(e,t){!t.docChanged&&!t.selection||t.annotation(Ue)||(e=null);for(const i of t.effects)i.is(Ae)&&(e=i.value);return e},provide:e=>n.showTooltip.from(e,(e=>e&&function(e){return{pos:e.pos,arrow:!0,create(t){let i,o,n=e.text;if(0===e.type){const n=new S.Spectrum.Spectrum;o=e=>{n.addEventListener("ColorChanged",e)},n.addEventListener("SizeChanged",(()=>t.requestMeasure())),n.setColor(e.color,e.color.format()),i=n,c.userMetrics.colorPickerOpenedFrom(0)}else{const t=new v.BezierEditor.BezierEditor(e.curve);i=t,o=e=>{t.addEventListener("BezierChanged",e)}}const r=document.createElement("div");return r.className="cm-tooltip-swatchEdit",i.markAsRoot(),i.show(r),i.showWidget(),i.element.addEventListener("keydown",(o=>{"Escape"===o.key&&(o.consume(),t.dispatch({effects:Ae.of(null),changes:n===e.text?void 0:{from:e.pos,to:e.pos+n.length,insert:e.text}}),i.hideWidget(),t.focus())})),i.element.addEventListener("focusout",(e=>{e.relatedTarget&&!i.element.contains(e.relatedTarget)&&(t.dispatch({effects:Ae.of(null)}),i.hideWidget())}),!1),i.element.addEventListener("mousedown",(e=>e.consume())),{dom:r,resize:!1,offset:{x:-8,y:0},mount:()=>{i.focus(),i.wasShown(),o((i=>{t.dispatch({changes:{from:e.pos,to:e.pos+n.length,insert:i.data},annotations:Ue.of(!0)}),n=i.data}))}}}}}(e)))});function Be(e,o,r){const s=new n.RangeSetBuilder;return function(e,o,r,s,a){let c=e.doc.lineAt(o);function l(t,i){return t>=c.to&&(c=e.doc.lineAt(t)),c.text.slice(t-c.from,i-c.from)}const d=n.ensureSyntaxTree(e,r,100);d&&d.iterate({from:o,to:r,enter:o=>{let n;if("ValueName"===o.name||"ColorLiteral"===o.name?n=l(o.from,o.to):"Callee"===o.name&&/^(?:(?:rgba?|hsla?|hwba?|lch|oklch|lab|oklab|color)|cubic-bezier)$/.test(l(o.from,o.to))&&(n=e.sliceDoc(o.from,o.node.parent.to)),n){const e=i.Color.parse(n);if(e)s(o.from,e,n);else{const e=t.Geometry.CubicBezier.parse(n);e&&a(o.from,e,n)}}}})}(e,o,r,((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new De(t,i,e)}))}),((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new Ne(t,i)}))})),s.finish()}const je=n.ViewPlugin.fromClass(class{decorations;constructor(e){this.decorations=Be(e.state,e.viewport.from,e.viewport.to)}update(e){(e.viewportChanged||e.docChanged)&&(this.decorations=Be(e.state,e.view.viewport.from,e.view.viewport.to))}},{decorations:e=>e.decorations});function Ve(e){if("Unit"===e.name&&(e=e.parent),"NumberLiteral"===e.name){const t=e.lastChild;return{from:e.from,to:t&&"Unit"===t.name?t.from:e.to}}return null}function We(e,t){const{head:i}=e.state.selection.main,o=n.syntaxTree(e.state).resolveInner(i,-1),r=Ve(o)||Ve(o.resolve(i,1));if(!r)return!1;const s=Number(e.state.sliceDoc(r.from,r.to));return!isNaN(s)&&(e.dispatch({changes:{from:r.from,to:r.to,insert:String(s+t)},scrollIntoView:!0,userEvent:"insert.modifyUnit"}),!0)}function Oe(){let e=null;const i=t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"sources.increment-css":()=>Promise.resolve(We(e,1)),"sources.increment-css-by-ten":()=>Promise.resolve(We(e,10)),"sources.decrement-css":()=>Promise.resolve(We(e,-1)),"sources.decrement-css-by-ten":()=>Promise.resolve(We(e,-10))});return n.EditorView.domEventHandlers({keydown:(t,o)=>{const n=e;return e=o,i(t),e=n,t.defaultPrevented}})}class He extends pe{#a;constructor(e,t){super(e,t),o.TargetManager.TargetManager.instance().observeModels(o.CSSModel.CSSModel,this)}static accepts(e){return e.contentType().hasStyleSheets()}modelAdded(e){e.target()===o.TargetManager.TargetManager.instance().primaryPageTarget()&&(this.#a=e)}modelRemoved(e){this.#a===e&&(this.#a=void 0)}editorExtension(){return[Oe(),this.#c(),[je,Re]]}#c(){const{cssCompletionSource:e}=n.css,t=this.uiSourceCode,i=this.#a;return n.autocompletion({override:[async o=>await Fe(o,t,i)||e(o)]})}populateTextAreaContextMenu(e){const t=this.#a,i=this.uiSourceCode.url();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&t&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(i)){const o=Me(Ee.addSourceMap);e.debugSection().appendItem(o,(()=>function(e,t){V.createAddSourceMapURLDialog((i=>{u.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().modelToInfo.get(e)?.addSourceMap(t,i)})).show()}(t,i)),{jslogContext:"add-source-map"})}}}var _e=Object.freeze({__proto__:null,cssBindings:Oe,CSSPlugin:He});const ze=new CSSStyleSheet;ze.replaceSync(".paused-status{margin:6px;padding:4px 10px;border-radius:10px;background-color:var(--sys-color-yellow-container);color:var(--sys-color-on-yellow-container)}.paused-status.error-reason{background-color:var(--sys-color-surface-error);color:var(--sys-color-on-surface-error)}.status-main{padding-left:18px;position:relative}.status-sub:not(:empty){padding-left:15px;padding-top:5px;overflow:hidden;text-overflow:ellipsis}.paused-status.error-reason .status-sub{color:var(--sys-color-error);line-height:11px;max-height:27px;user-select:text}devtools-icon{position:absolute;left:-1px;top:-1px}\n/*# sourceURL=debuggerPausedMessage.css */\n");const qe={pausedOnS:"Paused on {PH1}",childSAdded:"Child {PH1} added",descendantSAdded:"Descendant {PH1} added",descendantSRemoved:"Descendant {PH1} removed",pausedOnEventListener:"Paused on event listener",pausedOnXhrOrFetch:"Paused on XHR or fetch",pausedOnException:"Paused on exception",pausedOnPromiseRejection:"Paused on `promise` rejection",pausedOnAssertion:"Paused on assertion",pausedOnDebuggedFunction:"Paused on debugged function",pausedBeforePotentialOutofmemory:"Paused before potential out-of-memory crash",pausedOnCspViolation:"Paused on CSP violation",trustedTypeSinkViolation:"`Trusted Type` Sink Violation",trustedTypePolicyViolation:"`Trusted Type` Policy Violation",pausedOnBreakpoint:"Paused on breakpoint",debuggerPaused:"Debugger paused",subtreeModifications:"subtree modifications",attributeModifications:"attribute modifications",nodeRemoval:"node removal",webglErrorFiredS:"WebGL Error Fired ({PH1})",scriptBlockedDueToContent:"Script blocked due to Content Security Policy directive: {PH1}"},$e=e.i18n.registerUIStrings("panels/sources/DebuggerPausedMessage.ts",qe),Ge=e.i18n.getLocalizedString.bind(void 0,$e),Ke=e.i18n.getLazilyComputedLocalizedString.bind(void 0,$e);class Je{elementInternal;contentElement;constructor(){this.elementInternal=document.createElement("div"),this.elementInternal.classList.add("paused-message"),this.elementInternal.classList.add("flex-none");const e=t.Utils.createShadowRootWithCoreStyles(this.elementInternal,{cssFile:[ze],delegatesFocus:void 0});this.contentElement=e.createChild("div"),t.ARIAUtils.markAsPoliteLiveRegion(this.elementInternal,!1)}element(){return this.elementInternal}static descriptionWithoutStack(e){const t=/^\s+at\s/m.exec(e);return t?e.substring(0,t.index-1):e.substring(0,e.lastIndexOf("\n"))}static async createDOMBreakpointHitMessage(t){const n=document.createElement("span"),s=t.debuggerModel.target().model(o.DOMDebuggerModel.DOMDebuggerModel);if(!t.auxData||!s)return n;const a=s.resolveDOMBreakpointData(t.auxData);if(!a)return n;const c=n.createChild("div","status-main"),l=new r.Icon.Icon;l.data={iconName:"info",color:"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},c.appendChild(l);const d=Xe.get(a.type);c.appendChild(document.createTextNode(Ge(qe.pausedOnS,{PH1:d?d():String(null)})));const u=n.createChild("div","status-sub monospace"),h=await i.Linkifier.Linkifier.linkify(a.node);if(u.appendChild(h),a.targetNode){const t=await i.Linkifier.Linkifier.linkify(a.targetNode);let o;o=a.insertion?a.targetNode===a.node?e.i18n.getFormatLocalizedString($e,qe.childSAdded,{PH1:t}):e.i18n.getFormatLocalizedString($e,qe.descendantSAdded,{PH1:t}):e.i18n.getFormatLocalizedString($e,qe.descendantSRemoved,{PH1:t}),u.appendChild(document.createElement("br")),u.appendChild(o)}return n}static#l(e){if(!e)return"";const{eventName:t,webglErrorName:i,directiveText:n,targetName:r}=e;if("instrumentation:webglErrorFired"===t&&i){const e=i.replace(/^.*(0x[0-9a-f]+).*$/i,"$1");return Ge(qe.webglErrorFiredS,{PH1:e})}if("instrumentation:scriptBlockedByCSP"===t&&n)return Ge(qe.scriptBlockedDueToContent,{PH1:n});let s=o.EventBreakpointsModel.EventBreakpointsManager.instance().resolveEventListenerBreakpoint(e);return s?ce(s.name):(s=o.DOMDebuggerModel.DOMDebuggerManager.instance().resolveEventListenerBreakpoint(e),s&&r?r+"."+s.name:s?.name??"")}async render(e,i,o){if(this.contentElement.removeChildren(),this.contentElement.hidden=!e,!e)return;const n=this.contentElement.createChild("div","paused-status"),s="exception"===e.reason||"promiseRejection"===e.reason||"assert"===e.reason||"OOM"===e.reason;let a;if("DOM"===e.reason)a=await Je.createDOMBreakpointHitMessage(e);else if("EventListener"===e.reason){const t=Je.#l(e.auxData);a=c(Ge(qe.pausedOnEventListener),t)}else if("XHR"===e.reason){const t=e.auxData;a=c(Ge(qe.pausedOnXhrOrFetch),t.url||"")}else if("exception"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Je.descriptionWithoutStack(i);a=c(Ge(qe.pausedOnException),o,i)}else if("promiseRejection"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Je.descriptionWithoutStack(i);a=c(Ge(qe.pausedOnPromiseRejection),o,i)}else if("assert"===e.reason)a=c(Ge(qe.pausedOnAssertion));else if("debugCommand"===e.reason)a=c(Ge(qe.pausedOnDebuggedFunction));else if("OOM"===e.reason)a=c(Ge(qe.pausedBeforePotentialOutofmemory));else if("CSPViolation"===e.reason&&e.auxData&&e.auxData.violationType){const t=e.auxData.violationType;"trustedtype-sink-violation"===t?a=c(Ge(qe.pausedOnCspViolation),Ge(qe.trustedTypeSinkViolation)):"trustedtype-policy-violation"===t&&(a=c(Ge(qe.pausedOnCspViolation),Ge(qe.trustedTypePolicyViolation)))}else if(e.callFrames.length){const t=await i.rawLocationToUILocation(e.callFrames[0].location()),n=t?o.findBreakpoint(t):null;a=c(Ge(n?qe.pausedOnBreakpoint:qe.debuggerPaused))}else console.warn("ScriptsPanel paused, but callFrames.length is zero.");function c(e,i,o){const n=document.createElement("span"),a=n.createChild("div","status-main"),c=new r.Icon.Icon;if(c.data={iconName:s?"cross-circle-filled":"info",color:s?"var(--icon-error)":"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},a.appendChild(c),a.appendChild(document.createTextNode(e)),i){const e=n.createChild("div","status-sub monospace");e.textContent=i,t.Tooltip.Tooltip.install(e,o||i)}return n}n.classList.toggle("error-reason",s),a&&n.appendChild(a)}}const Xe=new Map([["subtree-modified",Ke(qe.subtreeModifications)],["attribute-modified",Ke(qe.attributeModifications)],["node-removed",Ke(qe.nodeRemoval)]]);var Ye=Object.freeze({__proto__:null,DebuggerPausedMessage:Je,BreakpointTypeNouns:Xe});const Qe=new CSSStyleSheet;Qe.replaceSync(":host{overflow-y:auto}.icon,\n.icon-basic,\n.icon-badge{margin:-3px -5px}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n.navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection){filter:grayscale(50%);opacity:50%}.is-ignore-listed{opacity:50%}.tree-outline li{min-height:20px}.tree-outline li:hover:not(.selected) .selection{display:block;background-color:var(--sys-color-state-hover-on-subtle)}.navigator-fs-folder-tree-item devtools-icon{color:var(--icon-folder-workspace)}.navigator-fs-tree-item devtools-icon{color:var(--icon-file-authored)}.navigator-nw-folder-tree-item devtools-icon{color:var(--icon-folder-deployed)}.navigator-sm-script-tree-item devtools-icon,\n.navigator-script-tree-item devtools-icon,\n.navigator-snippet-tree-item devtools-icon{color:var(--icon-file-script)}.navigator-file-tree-item devtools-icon.dot::before{width:7px;height:7px;top:12px;left:11px}.navigator-file-tree-item:hover:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-hover)}.navigator-file-tree-item.selected:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-inactive)}.navigator-file-tree-item.selected.force-white-icons devtools-icon.dot::before{outline-color:var(--icon-gap-focus-selected)}.navigator-sm-stylesheet-tree-item devtools-icon,\n.navigator-stylesheet-tree-item devtools-icon{color:var(--icon-file-styles)}.navigator-image-tree-item devtools-icon,\n.navigator-font-tree-item devtools-icon{color:var(--icon-file-image)}.navigator-nw-folder-tree-item.is-from-source-map devtools-icon{color:var(--icon-folder-authored)}.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-folder-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-script-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-stylesheet-tree-item .tree-element-title{font-style:italic}@media (forced-colors: active){.tree-outline li .leading-icons devtools-icon{color:ButtonText}.tree-outline li:hover:not(.selected) .selection{forced-color-adjust:none;background-color:Highlight}.tree-outline:not(.hide-selection-when-blurred) li.parent:hover:not(.selected)::before{background-color:HighlightText}.tree-outline:not(.hide-selection-when-blurred) li:hover:not(.selected) devtools-icon,\n .tree-outline li:not(.selected):hover .tree-element-title{forced-color-adjust:none;color:HighlightText}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .is-ignore-listed{filter:none;opacity:100%}}\n/*# sourceURL=navigatorTree.css */\n");const Ze=new CSSStyleSheet;Ze.replaceSync(".navigator-toolbar{border-bottom:1px solid var(--sys-color-divider);padding-left:8px}\n/*# sourceURL=navigatorView.css */\n");class et{searchId;searchResultCandidates;searchResultCallback;searchFinishedCallback;searchConfig;constructor(){this.searchId=0,this.searchResultCandidates=[],this.searchResultCallback=null,this.searchFinishedCallback=null,this.searchConfig=null}static filesComparator(e,t){if(e.isDirty()&&!t.isDirty())return-1;if(!e.isDirty()&&t.isDirty())return 1;const i=e.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(e);if(i!==(t.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(t)))return i?1:-1;const o=e.url(),n=t.url();return o&&!n?-1:!o&&n?1:l.StringUtilities.naturalOrderComparator(e.fullDisplayName(),t.fullDisplayName())}static urlComparator(e,t){return l.StringUtilities.naturalOrderComparator(e.url(),t.url())}performIndexing(e){this.stopSearch();const t=this.projects(),o=new i.Progress.CompositeProgress(e);for(let e=0;e<t.length;++e){const i=t[e],n=o.createSubProgress([...i.uiSourceCodes()].length);i.indexContent(n)}}projects(){const e=i.Settings.Settings.instance().moduleSetting("search-in-anonymous-and-content-scripts").get();return f.Workspace.WorkspaceImpl.instance().projects().filter((t=>t.type()!==f.Workspace.projectTypes.Service&&(!(!e&&t.isServiceProject()&&t.type()!==f.Workspace.projectTypes.Formatter)&&!(!e&&t.type()===f.Workspace.projectTypes.ContentScripts))))}performSearch(e,t,o,n){this.stopSearch(),this.searchResultCandidates=[],this.searchResultCallback=o,this.searchFinishedCallback=n,this.searchConfig=e;const r=[],s=new i.Progress.CompositeProgress(t),a=s.createSubProgress(),c=new i.Progress.CompositeProgress(s.createSubProgress());for(const t of this.projects()){const i=[...t.uiSourceCodes()].length,o=c.createSubProgress(i),n=this.projectFilesMatchingFileQuery(t,e),s=t.findFilesMatchingSearchRequest(e,n,o).then(this.processMatchingFilesForProject.bind(this,this.searchId,t,e,n));r.push(s)}Promise.all(r).then(this.processMatchingFiles.bind(this,this.searchId,a,this.searchFinishedCallback.bind(this,!0)))}projectFilesMatchingFileQuery(e,t,i){const o=[];for(const n of e.uiSourceCodes()){if(!n.contentType().isTextType())continue;if(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(n))continue;const e=h.Persistence.PersistenceImpl.instance().binding(n);e&&e.network===n||(i&&!n.isDirty()||t.filePathMatchesFileQuery(n.fullDisplayName())&&o.push(n))}return o.sort(et.urlComparator),o}processMatchingFilesForProject(e,t,i,o,n){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);let r=[...n.keys()];r.sort(et.urlComparator),r=l.ArrayUtilities.intersectOrdered(r,o,et.urlComparator);const s=this.projectFilesMatchingFileQuery(t,i,!0);r=l.ArrayUtilities.mergeOrdered(r,s,et.urlComparator);const a=[];for(const e of r){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&!t.isAnonymousScript()||a.push(e)}a.sort(et.filesComparator),this.searchResultCandidates=l.ArrayUtilities.mergeOrdered(this.searchResultCandidates,a,et.filesComparator)}processMatchingFiles(e,t,i){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);const o=this.searchResultCandidates;if(!o.length)return t.done(),void i();t.setTotalWork(o.length);let n=0;let r=0;for(let e=0;e<20&&e<o.length;++e)a.call(this);function s(e){e.isDirty()?c.call(this,e,e.workingCopy()):e.requestContent().then((t=>{c.call(this,e,t.content||"")}))}function a(){if(n>=o.length)return r?void 0:(t.done(),void i());++r;const e=o[n++];window.setTimeout(s.bind(this,e),0)}function c(e,i){t.incrementWorked(1);let o=[];const n=this.searchConfig,s=n.queries();if(null!==i){for(let e=0;e<s.length;++e){const t=g.TextUtils.performSearchInContent(i,s[e],!n.ignoreCase(),n.isRegex());o=l.ArrayUtilities.mergeOrdered(o,t,g.ContentProvider.SearchMatch.comparator)}n.queries().length||(o=[new g.ContentProvider.SearchMatch(0,new g.Text.Text(i).lineAt(0),0,0)])}if(o&&this.searchResultCallback){const t=new tt(e,o);this.searchResultCallback(t)}--r,a.call(this)}}stopSearch(){++this.searchId}}class tt{uiSourceCode;searchMatches;constructor(e,t){this.uiSourceCode=e,this.searchMatches=t}label(){return this.uiSourceCode.displayName()}description(){return this.uiSourceCode.fullDisplayName()}matchesCount(){return this.searchMatches.length}matchLineContent(e){return this.searchMatches[e].lineContent}matchRevealable(e){const{lineNumber:t,columnNumber:i,matchLength:o}=this.searchMatches[e],n=new g.TextRange.TextRange(t,i,t,i+o);return new f.UISourceCode.UILocationRange(this.uiSourceCode,n)}matchLabel(e){return String(this.searchMatches[e].lineNumber+1)}matchColumn(e){return this.searchMatches[e].columnNumber}matchLength(e){return this.searchMatches[e].matchLength}}var it=Object.freeze({__proto__:null,SourcesSearchScope:et,FileBasedSearchResult:tt});class ot{query;constructor(e){this.query=e}}class nt extends E.SearchView.SearchView{constructor(){super("sources",new i.Throttler.Throttler(200))}createScope(){return new et}}var rt=Object.freeze({__proto__:null,SearchSources:ot,SearchSourcesView:nt,ActionDelegate:class{handleAction(e,o){if("sources.search"===o){const e=t.InspectorView.InspectorView.instance().element.window().getSelection(),o=e?e.toString().replace(/\r?\n.*/,""):"";return i.Revealer.reveal(new ot(o)),!0}return!1}},Revealer:class{async reveal({query:e},i){const o=t.ViewManager.ViewManager.instance();await o.showView("sources.search-sources-tab",!0,i);const n=o.materializedWidget("sources.search-sources-tab");n instanceof nt&&n.toggle(e)}}});const st={searchInFolder:"Search in folder",searchInAllFiles:"Search in all files",noDomain:"(no domain)",authored:"Authored",authoredTooltip:"Contains original sources",deployed:"Deployed",deployedTooltip:"Contains final sources the browser sees",areYouSureYouWantToExcludeThis:"Are you sure you want to exclude this folder?",areYouSureYouWantToDeleteThis:"Are you sure you want to delete this file?",rename:"Rename…",makeACopy:"Make a copy…",delete:"Delete",remove:"Remove",areYouSureYouWantToDeleteFolder:"Are you sure you want to delete this folder and its contents?",actionCannotBeUndone:"This action cannot be undone.",openFolder:"Open folder",newFile:"New file",excludeFolder:"Exclude from workspace",removeFolderFromWorkspace:"Remove from workspace",areYouSureYouWantToRemoveThis:"Remove ‘{PH1}’ from Workspace?",workspaceStopSyncing:"This will stop syncing changes from DevTools to your sources.",sFromSourceMap:"{PH1} (from source map)",sIgnoreListed:"{PH1} (ignore listed)"},at=e.i18n.registerUIStrings("panels/sources/NavigatorView.ts",st),ct=e.i18n.getLocalizedString.bind(void 0,at),lt={Authored:"authored",Deployed:"deployed",Domain:"domain",File:"file",FileSystem:"fs",FileSystemFolder:"fs-folder",Frame:"frame",NetworkFolder:"nw-folder",Root:"root",Worker:"worker"},dt=new Map([[lt.Root,1],[lt.Authored,1],[lt.Deployed,5],[lt.Domain,10],[lt.FileSystemFolder,1],[lt.NetworkFolder,1],[lt.File,10],[lt.Frame,70],[lt.Worker,90],[lt.FileSystem,100]]);class ut extends t.Widget.VBox{placeholder;scriptsTree;uiSourceCodeNodes;subfolderNodes;rootNode;frameNodes;authoredNode;deployedNode;navigatorGroupByFolderSetting;navigatorGroupByAuthoredExperiment;workspaceInternal;groupByFrame;groupByAuthored;groupByDomain;groupByFolder;constructor(e,n){super(!0),this.placeholder=null,this.scriptsTree=new t.TreeOutline.TreeOutlineInShadow,this.scriptsTree.setComparator(ut.treeElementsCompare),this.scriptsTree.setFocusable(!1),this.contentElement.setAttribute("jslog",`${a.pane(e).track({resize:!0})}`),this.contentElement.appendChild(this.scriptsTree.element),this.setDefaultFocusedElement(this.scriptsTree.element),this.uiSourceCodeNodes=new l.MapUtilities.Multimap,this.subfolderNodes=new Map,this.rootNode=new bt(this),this.rootNode.populate(),this.frameNodes=new Map,this.contentElement.addEventListener("contextmenu",this.handleContextMenu.bind(this),!1),t.ShortcutRegistry.ShortcutRegistry.instance().addShortcutListener(this.contentElement,{"sources.rename":this.renameShortcut.bind(this)}),this.navigatorGroupByFolderSetting=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder"),this.navigatorGroupByFolderSetting.addChangeListener(this.groupingChanged.bind(this)),n&&(this.navigatorGroupByAuthoredExperiment="authored-deployed-grouping"),u.IgnoreListManager.IgnoreListManager.instance().addChangeListener(this.ignoreListChanged.bind(this)),this.initGrouping(),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingCreated,this.onBindingChanged,this),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingRemoved,this.onBindingChanged,this),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("RequestsForHeaderOverridesFileChanged",this.#d,this),o.TargetManager.TargetManager.instance().addEventListener("NameChanged",this.targetNameChanged,this),o.TargetManager.TargetManager.instance().observeTargets(this),this.resetWorkspace(f.Workspace.WorkspaceImpl.instance()),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this)),u.NetworkProject.NetworkProjectManager.instance().addEventListener("FrameAttributionAdded",this.frameAttributionAdded,this),u.NetworkProject.NetworkProjectManager.instance().addEventListener("FrameAttributionRemoved",this.frameAttributionRemoved,this)}static treeElementOrder(e){if(ht.has(e))return 0;const t=e;let i=dt.get(t.nodeType)||0;if(t.uiSourceCode){const e=t.uiSourceCode.contentType();e.isDocument()?i+=3:e.isScript()?i+=5:e.isStyleSheet()?i+=10:i+=15}return i}static appendSearchItem(e,t){const o=ct(t?st.searchInFolder:st.searchInAllFiles),n=new ot(t&&`file:${t}`);e.viewSection().appendItem(o,(()=>i.Revealer.reveal(n)),{jslogContext:t?"search-in-folder":"search-in-all-files"})}static treeElementsCompare(e,t){const i=ut.treeElementOrder(e),o=ut.treeElementOrder(t);return i>o?1:i<o?-1:l.StringUtilities.naturalOrderComparator(e.titleAsText(),t.titleAsText())}setPlaceholder(e){function i(){const t=this.scriptsTree.firstChild();t?e.hideWidget():e.showWidget(),this.scriptsTree.element.classList.toggle("hidden",!t)}console.assert(!this.placeholder,"A placeholder widget was already set"),this.placeholder=e,e.show(this.contentElement,this.contentElement.firstChild),i.call(this),this.scriptsTree.addEventListener(t.TreeOutline.Events.ElementAttached,i.bind(this)),this.scriptsTree.addEventListener(t.TreeOutline.Events.ElementsDetached,i.bind(this))}onBindingChanged(e){const t=e.data;let o=!1;const n=this.uiSourceCodeNodes.get(t.network);for(const e of n)e.updateTitle(),o||=e.uiSourceCode().contentType().isFromSourceMap();const r=this.uiSourceCodeNodes.get(t.fileSystem);for(const e of r)e.updateTitle(),o||=e.uiSourceCode().contentType().isFromSourceMap();const s=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(t.fileSystem);let a=l.DevToolsPath.EmptyEncodedPathString;for(let e=0;e<s.length-1;++e){a=i.ParsedURL.ParsedURL.concatenate(a,s[e]);const n=this.folderNodeId(t.fileSystem.project(),null,null,t.fileSystem.origin(),o,a),r=this.subfolderNodes.get(n);r&&r.updateTitle(),a=i.ParsedURL.ParsedURL.concatenate(a,"/")}const c=this.rootOrDeployedNode().child(t.fileSystem.project().id());c&&c.updateTitle()}#d(e){const t=e.data,i=this.uiSourceCodeNodes.get(t);for(const e of i)e.updateTitle()}focus(){this.scriptsTree.focus()}appendChild(e,t){this.scriptsTree.setFocusable(!0),e.appendChild(t)}removeChild(e,t){e.removeChild(t),0===this.scriptsTree.rootElement().childCount()&&this.scriptsTree.setFocusable(!1)}resetWorkspace(e){this.workspaceInternal&&(this.workspaceInternal.removeEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAddedCallback,this),this.workspaceInternal.removeEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemovedCallback,this),this.workspaceInternal.removeEventListener(f.Workspace.Events.ProjectAdded,this.projectAddedCallback,this),this.workspaceInternal.removeEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemovedCallback,this)),this.workspaceInternal=e,this.workspaceInternal.addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAddedCallback,this),this.workspaceInternal.addEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemovedCallback,this),this.workspaceInternal.addEventListener(f.Workspace.Events.ProjectAdded,this.projectAddedCallback,this),this.workspaceInternal.addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemovedCallback,this),this.workspaceInternal.projects().forEach(this.projectAdded.bind(this)),this.computeUniqueFileSystemProjectNames()}projectAddedCallback(e){const t=e.data;this.projectAdded(t),t.type()===f.Workspace.projectTypes.FileSystem&&this.computeUniqueFileSystemProjectNames()}projectRemovedCallback(e){const t=e.data;this.removeProject(t),t.type()===f.Workspace.projectTypes.FileSystem&&this.computeUniqueFileSystemProjectNames()}workspace(){return this.workspaceInternal}acceptProject(e){return!e.isServiceProject()}frameAttributionAdded(e){const{uiSourceCode:t}=e.data;if(!this.acceptsUISourceCode(t))return;const i=e.data.frame;this.addUISourceCodeNode(t,i)}frameAttributionRemoved(e){const{uiSourceCode:t}=e.data;if(!this.acceptsUISourceCode(t))return;const i=e.data.frame,o=Array.from(this.uiSourceCodeNodes.get(t)).find((e=>e.frame()===i));o&&this.removeUISourceCodeNode(o)}acceptsUISourceCode(e){return this.acceptProject(e.project())}addUISourceCode(e){if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return;if(!this.acceptsUISourceCode(e))return;if(e.isFetchXHR())return;const t=u.NetworkProject.NetworkProject.framesForUISourceCode(e);if(t.length)for(const i of t)this.addUISourceCodeNode(e,i);else this.addUISourceCodeNode(e,null);this.uiSourceCodeAdded(e)}addUISourceCodeNode(e,t){const o=e.contentType().isFromSourceMap();let n;n=e.project().type()===f.Workspace.projectTypes.FileSystem?h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(e).slice(0,-1):i.ParsedURL.ParsedURL.extractPath(e.url()).split("/").slice(1,-1);const r=e.project(),s=u.NetworkProject.NetworkProject.targetForUISourceCode(e),a=this.folderNode(e,r,s,t,e.origin(),n,o),c=new ft(this,e,t),l=a.child(c.id);l&&l instanceof ft?this.uiSourceCodeNodes.set(e,l):(a.appendChild(c),this.uiSourceCodeNodes.set(e,c),c.updateTitleBubbleUp()),this.selectDefaultTreeNode()}uiSourceCodeAdded(e){}uiSourceCodeAddedCallback(e){const t=e.data;this.addUISourceCode(t)}uiSourceCodeRemovedCallback(e){this.removeUISourceCodes([e.data])}tryAddProject(e){this.projectAdded(e);for(const t of e.uiSourceCodes())this.addUISourceCode(t)}projectAdded(e){const t=this.rootOrDeployedNode();!this.acceptProject(e)||e.type()!==f.Workspace.projectTypes.FileSystem||T.ScriptSnippetFileSystem.isSnippetsProject(e)||t.child(e.id())||(t.appendChild(new vt(this,e,e.id(),lt.FileSystem,e.displayName())),this.selectDefaultTreeNode())}selectDefaultTreeNode(){const e=this.rootNode.children();e.length&&!this.scriptsTree.selectedTreeElement&&e[0].treeNode().select(!0,!1)}computeUniqueFileSystemProjectNames(){const e=this.workspaceInternal.projectsForType(f.Workspace.projectTypes.FileSystem);if(!e.length)return;const t=i.Trie.Trie.newArrayTrie(),o=[];for(const i of e){const e=i.fileSystemPath().split("/").reverse();o.push(e),t.add(e)}const n=this.rootOrDeployedNode();for(let r=0;r<e.length;++r){const s=o[r],a=e[r];t.remove(s);const c=t.longestPrefix(s,!1);t.add(s);const l=s.slice(0,c.length+1),d=i.ParsedURL.ParsedURL.encodedPathToRawPathString(l.reverse().join("/")),u=n.child(a.id());u&&u.setTitle(d)}}removeProject(e){if(this.removeUISourceCodes(e.uiSourceCodes()),e.type()!==f.Workspace.projectTypes.FileSystem)return;const t=this.rootNode.child(e.id());t&&this.rootNode.removeChild(t)}folderNodeId(e,t,i,o,n,r){const s=e.type()===f.Workspace.projectTypes.FileSystem?e.id():"";let a=!t||this.groupByAuthored&&n?"":t.id(),c=this.groupByFrame&&i?i.id:"";return this.groupByAuthored&&(n?(a="Authored",c=""):a="Deployed:"+a),a+":"+s+":"+c+":"+o+":"+r}folderNode(e,t,o,n,r,s,a){if(T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e))return this.rootNode;if(o&&!this.groupByFolder&&!a)return this.domainNode(e,t,o,n,r);const c=i.ParsedURL.ParsedURL.join(s,"/"),l=this.folderNodeId(t,o,n,r,a,c);let d=this.subfolderNodes.get(l);if(d)return d;if(!s.length)return o?this.domainNode(e,t,o,n,r):this.rootOrDeployedNode().child(t.id());const u=this.folderNode(e,t,o,n,r,s.slice(0,-1),a);let h=lt.NetworkFolder;t.type()===f.Workspace.projectTypes.FileSystem&&(h=lt.FileSystemFolder);const p=i.ParsedURL.ParsedURL.encodedPathToRawPathString(s[s.length-1]);return d=new St(this,t,l,h,c,p,r),this.subfolderNodes.set(l,d),u.appendChild(d),d}domainNode(e,t,o,n,r){const s=e.contentType().isFromSourceMap(),a=this.frameNode(t,o,n,s);if(!this.groupByDomain)return a;let c=a.child(r);return c||(c=new vt(this,t,r,lt.Domain,this.computeProjectDisplayName(o,r)),n&&r===i.ParsedURL.ParsedURL.extractOrigin(n.url)&&ht.add(c.treeNode()),a.appendChild(c),s&&this.groupByAuthored&&c.treeNode().expand(),c)}frameNode(e,t,i,n){if(!this.groupByFrame||!i||this.groupByAuthored&&n)return this.targetNode(e,t,n);let r=this.frameNodes.get(i);if(r)return r;r=new vt(this,e,t.id()+":"+i.id,lt.Frame,i.displayName()),r.setHoverCallback((function(e){if(e){const e=t.model(o.OverlayModel.OverlayModel);e&&i&&e.highlightFrame(i.id)}else o.OverlayModel.OverlayModel.hideDOMNodeHighlight()})),this.frameNodes.set(i,r);const s=i.parentFrame();return this.frameNode(e,s?s.resourceTreeModel().target():t,s,n).appendChild(r),s||(ht.add(r.treeNode()),r.treeNode().expand()),r}targetNode(e,t,i){if(this.groupByAuthored&&i)return this.authoredNode||(this.authoredNode=new vt(this,null,"group:Authored",lt.Authored,ct(st.authored),ct(st.authoredTooltip)),this.rootNode.appendChild(this.authoredNode),this.authoredNode.treeNode().expand()),this.authoredNode;const n=this.rootOrDeployedNode();if(t===o.TargetManager.TargetManager.instance().scopeTarget())return n;let r=n.child("target:"+t.id());return r||(r=new vt(this,e,"target:"+t.id(),t.type()===o.Target.Type.Frame?lt.Frame:lt.Worker,t.name()),n.appendChild(r)),r}rootOrDeployedNode(){return this.groupByAuthored?(this.deployedNode||(this.deployedNode=new vt(this,null,"group:Deployed",lt.Deployed,ct(st.deployed),ct(st.deployedTooltip)),this.rootNode.appendChild(this.deployedNode)),this.deployedNode):this.rootNode}computeProjectDisplayName(e,t){const n=e.model(o.RuntimeModel.RuntimeModel),r=n?n.executionContexts():[];for(const e of r)if(e.name&&e.origin&&t.startsWith(e.origin))return e.name;if(!t)return ct(st.noDomain);const s=new i.ParsedURL.ParsedURL(t);return(s.isValid?s.host+(s.port?":"+s.port:""):"")||t}revealUISourceCode(e,i){const o=this.uiSourceCodeNodes.get(e);if(0===o.size)return null;const n=o.values().next().value;if(!n)return null;if(this.scriptsTree.selectedTreeElement){if(t.UIUtils.isBeingEdited(this.scriptsTree.selectedTreeElement.treeOutline?.element))return null;this.scriptsTree.selectedTreeElement.deselect()}return n.reveal(i),n}sourceSelected(e,t){i.Revealer.reveal(e,!t)}#u(e){const t=this.scriptsTree.selectedTreeElement,i=t&&t.node;let o=e;for(;o;){if(o===i)return!0;if(o=o.parent,!(e instanceof vt||e instanceof pt))break}return!1}removeUISourceCodes(e){const t=[];for(const i of e){const e=this.uiSourceCodeNodes.get(i);for(const i of e)this.#u(i)?t.push(i):this.removeUISourceCodeNode(i)}t.forEach(this.removeUISourceCodeNode.bind(this))}removeUISourceCodeNode(e){const t=e.uiSourceCode();this.uiSourceCodeNodes.delete(t,e);const i=t.project(),o=u.NetworkProject.NetworkProject.targetForUISourceCode(t);let n=e.frame(),r=e.parent;if(!r)return;r.removeChild(e);let s=r;for(;s&&(r=s.parent,r)&&(r!==this.rootNode&&r!==this.deployedNode||i.type()!==f.Workspace.projectTypes.FileSystem)&&(s instanceof vt||s instanceof St);){if(!s.isEmpty()){s.updateTitleBubbleUp();break}if(s.type===lt.Frame)this.discardFrame(n,Boolean(this.groupByAuthored)&&t.contentType().isFromSourceMap()),n=n.parentFrame();else{const e=this.folderNodeId(i,o,n,t.origin(),t.contentType().isFromSourceMap(),s instanceof St&&s.folderPath||l.DevToolsPath.EmptyEncodedPathString);this.subfolderNodes.delete(e),r.removeChild(s)}s===this.authoredNode?this.authoredNode=void 0:s===this.deployedNode&&(this.deployedNode=void 0),s=r}}reset(e){for(const e of this.uiSourceCodeNodes.valuesArray())e.dispose();this.scriptsTree.removeChildren(),this.scriptsTree.setFocusable(!1),this.uiSourceCodeNodes.clear(),this.subfolderNodes.clear(),this.frameNodes.clear(),this.rootNode.reset(),this.authoredNode=void 0,this.deployedNode=void 0,e||this.resetWorkspace(f.Workspace.WorkspaceImpl.instance())}handleContextMenu(e){}async renameShortcut(){const e=this.scriptsTree.selectedTreeElement,t=e&&e.node;return!!(t&&t.uiSourceCode()&&t.uiSourceCode().canRename())&&(this.rename(t,!1),!0)}handleContextMenuCreate(e,t,o){if(o){const e=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(o);e.pop(),t=i.ParsedURL.ParsedURL.join(e,"/")}this.create(e,t,o)}handleContextMenuRename(e){this.rename(e,!1)}async handleContextMenuExclude(e,i){await t.UIUtils.ConfirmDialog.show(ct(st.areYouSureYouWantToExcludeThis),void 0,{jslogContext:"exclude-folder-confirmation"})&&(t.UIUtils.startBatchUpdate(),e.excludeFolder(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.completeURL(e,i)),t.UIUtils.endBatchUpdate())}async handleContextMenuDelete(e){await t.UIUtils.ConfirmDialog.show(ct(st.areYouSureYouWantToDeleteThis),void 0,{jslogContext:"delete-file-confirmation"})&&e.project().deleteFile(e)}handleFileContextMenu(e,i){const o=i.uiSourceCode(),n=new t.ContextMenu.ContextMenu(e);n.appendApplicableItems(o);const r=o.project();r.type()===f.Workspace.projectTypes.FileSystem&&(n.editSection().appendItem(ct(st.rename),this.handleContextMenuRename.bind(this,i),{jslogContext:"rename"}),n.editSection().appendItem(ct(st.makeACopy),this.handleContextMenuCreate.bind(this,r,l.DevToolsPath.EmptyEncodedPathString,o),{jslogContext:"make-a-copy"}),n.editSection().appendItem(ct(st.delete),this.handleContextMenuDelete.bind(this,o),{jslogContext:"delete"})),n.show()}async handleDeleteFolder(e){const i=`${ct(st.areYouSureYouWantToDeleteFolder)}\n${ct(st.actionCannotBeUndone)}`;if(await t.UIUtils.ConfirmDialog.show(i,void 0,{jslogContext:"delete-folder-confirmation"})){c.userMetrics.actionTaken(c.UserMetrics.Action.OverrideTabDeleteFolderContextMenu);const t=this.findTopNonMergedNode(e);await this.removeUISourceCodeFromProject(t),await this.deleteDirectoryRecursively(t)}}async removeUISourceCodeFromProject(e){e.children().forEach((async e=>{await this.removeUISourceCodeFromProject(e)})),e instanceof ft&&e.uiSourceCode().project().removeUISourceCode(e.uiSourceCode().url())}async deleteDirectoryRecursively(e){e instanceof St&&await(h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()?.deleteDirectoryRecursively(e.folderPath))}findTopNonMergedNode(e){return e.isMerged&&e.parent instanceof St?this.findTopNonMergedNode(e.parent):e}handleFolderContextMenu(e,o){const n=o.folderPath||l.DevToolsPath.EmptyEncodedPathString,r=o.project||null,s=new t.ContextMenu.ContextMenu(e);if(ut.appendSearchItem(s,n),r){if(r.type()===f.Workspace.projectTypes.FileSystem){const e=i.ParsedURL.ParsedURL.urlToRawPathString(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.completeURL(r,n),c.Platform.isWin());s.revealSection().appendItem(ct(st.openFolder),(()=>c.InspectorFrontendHost.InspectorFrontendHostInstance.showItemInFolder(e)),{jslogContext:"open-folder"}),r.canCreateFile()&&s.defaultSection().appendItem(ct(st.newFile),(()=>{this.handleContextMenuCreate(r,n,void 0)}),{jslogContext:"new-file"})}else if(o.origin&&o.folderPath){const e=i.ParsedURL.ParsedURL.concatenate(o.origin,"/",o.folderPath),t={isContentScript:o.recursiveProperties.exclusivelyContentScripts||!1,isKnownThirdParty:o.recursiveProperties.exclusivelyThirdParty||!1,isCurrentlyIgnoreListed:o.recursiveProperties.exclusivelyIgnored||!1};for(const{text:i,callback:o,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListFolderContextMenuItems(e,t))s.defaultSection().appendItem(i,o,{jslogContext:n})}if(r.canExcludeFolder(n)&&s.defaultSection().appendItem(ct(st.excludeFolder),this.handleContextMenuExclude.bind(this,r,n),{jslogContext:"exclude-folder"}),r.type()===f.Workspace.projectTypes.FileSystem){"overrides"===r.fileSystem().type()?o instanceof vt||s.defaultSection().appendItem(ct(st.delete),this.handleDeleteFolder.bind(this,o),{jslogContext:"delete"}):o instanceof vt&&s.defaultSection().appendItem(ct(st.removeFolderFromWorkspace),(async()=>{const e=`${ct(st.areYouSureYouWantToRemoveThis,{PH1:o.title})}\n${ct(st.workspaceStopSyncing)}`;await t.UIUtils.ConfirmDialog.show(e,void 0,{okButtonLabel:ct(st.remove),jslogContext:"remove-folder-from-workspace-confirmation"})&&r.remove()}),{jslogContext:"remove-folder-from-workspace"})}s.show()}}rename(e,t){const i=e.uiSourceCode();e.rename(function(o){if(!t)return;o?e.treeElement&&e.treeElement.listItemElement.hasFocus()&&this.sourceSelected(i,!0):i.remove()}.bind(this))}async create(e,t,i){let o="";i&&(o=(await i.requestContent()).content||"");const n=await e.createFile(t,null,o);if(!n)return;this.sourceSelected(n,!1);const r=this.revealUISourceCode(n,!0);r&&this.rename(r,!0)}groupingChanged(){this.reset(!0),this.initGrouping(),this.resetWorkspace(f.Workspace.WorkspaceImpl.instance()),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}ignoreListChanged(){C.Runtime.experiments.isEnabled("just-my-code")?this.groupingChanged():this.rootNode.updateTitleRecursive()}initGrouping(){this.groupByFrame=!0,this.groupByDomain=this.navigatorGroupByFolderSetting.get(),this.groupByFolder=this.groupByDomain,this.navigatorGroupByAuthoredExperiment?this.groupByAuthored=C.Runtime.experiments.isEnabled(this.navigatorGroupByAuthoredExperiment):this.groupByAuthored=!1}resetForTest(){this.reset(),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}discardFrame(e,t){if(t)return;const i=this.frameNodes.get(e);if(i){i.parent&&i.parent.removeChild(i),this.frameNodes.delete(e);for(const i of e.childFrames)this.discardFrame(i,t)}}targetAdded(e){}targetRemoved(e){const t=this.rootOrDeployedNode(),i=t.child("target:"+e.id());i&&t.removeChild(i)}targetNameChanged(e){const t=e.data,i=this.rootOrDeployedNode().child("target:"+t.id());i&&i.setTitle(t.name())}wasShown(){super.wasShown(),this.scriptsTree.registerCSSFiles([Qe]),this.registerCSSFiles([Ze])}}const ht=new WeakSet;class pt extends t.TreeOutline.TreeElement{nodeType;navigatorView;hoverCallback;node;hovered;isIgnoreListed;isFromSourceMap;constructor(e,i,o,n){super("",!0,pt.#h(i)),this.listItemElement.classList.add("navigator-"+i+"-tree-item","navigator-folder-tree-item"),t.ARIAUtils.setLabel(this.listItemElement,`${o}, ${i}`),this.nodeType=i,this.title=o,this.tooltip=o,this.navigatorView=e,this.hoverCallback=n,this.isFromSourceMap=!1;let s="folder";i===lt.Domain?s="cloud":i===lt.Frame?s="frame":i===lt.Worker?s="gears":i===lt.Authored?s="code":i===lt.Deployed&&(s="deployed");const a=r.Icon.create(s);this.setLeadingIcons([a])}async onpopulate(){this.node.populate()}onattach(){this.collapse(),this.node.onattach(),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("mousemove",this.mouseMove.bind(this),!1),this.listItemElement.addEventListener("mouseleave",this.mouseLeave.bind(this),!1)}setIgnoreListed(e){this.isIgnoreListed!==e&&(this.isIgnoreListed=e,this.listItemElement.classList.toggle("is-ignore-listed",e),this.updateTooltip())}setFromSourceMap(e){this.isFromSourceMap=e,this.listItemElement.classList.toggle("is-from-source-map",e)}setNode(e){this.node=e,this.updateTooltip(),t.ARIAUtils.setLabel(this.listItemElement,`${this.title}, ${this.nodeType}`)}updateTooltip(){if(this.node.tooltip)this.tooltip=this.node.tooltip;else{const e=[];let t=this.node;for(;t&&!t.isRoot()&&t.type===this.node.type;)e.push(t.title),t=t.parent;e.reverse();let i=e.join("/");this.isIgnoreListed&&(i=ct(st.sIgnoreListed,{PH1:i})),this.tooltip=i}}handleContextMenuEvent(e){this.node&&(this.select(),this.navigatorView.handleFolderContextMenu(e,this.node))}mouseMove(e){!this.hovered&&this.hoverCallback&&(this.hovered=!0,this.hoverCallback(!0))}mouseLeave(e){this.hoverCallback&&(this.hovered=!1,this.hoverCallback(!1))}static#h(e){switch(e){case lt.Domain:return"domain";case lt.Frame:return"frame";case lt.Worker:return"worker";case lt.Authored:return"authored";case lt.Deployed:return"deployed"}return"folder"}}class gt extends t.TreeOutline.TreeElement{nodeType;node;navigatorView;uiSourceCodeInternal;constructor(e,o,n,r){super("",!1,o.contentType().name()),this.nodeType=lt.File,this.node=r,this.title=n,this.listItemElement.classList.add("navigator-"+o.contentType().name()+"-tree-item","navigator-file-tree-item"),this.tooltip=o.url(),t.ARIAUtils.setLabel(this.listItemElement,`${o.name()}, ${this.nodeType}`),i.EventTarget.fireEvent("source-tree-file-added",o.fullDisplayName()),this.navigatorView=e,this.uiSourceCodeInternal=o,this.updateIcon()}updateIcon(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),i=h.NetworkPersistenceManager.NetworkPersistenceManager.instance();let o="document",n=[];if(e){T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e.fileSystem)&&(o="snippet");n=i.project()===e.fileSystem.project()?["dot","purple"]:["dot","green"]}else i.isActiveHeaderOverrides(this.uiSourceCode)?n=["dot","purple"]:T.ScriptSnippetFileSystem.isSnippetsUISourceCode(this.uiSourceCodeInternal)&&(o="snippet");const s=r.Icon.create(o,n.join(" "));e&&t.Tooltip.Tooltip.install(s,h.PersistenceUtils.PersistenceUtils.tooltipForUISourceCode(this.uiSourceCodeInternal)),this.setLeadingIcons([s])}updateAccessibleName(){t.ARIAUtils.setLabel(this.listItemElement,`${this.uiSourceCodeInternal.name()}, ${this.nodeType}`)}get uiSourceCode(){return this.uiSourceCodeInternal}onattach(){this.listItemElement.draggable=!0,this.listItemElement.addEventListener("click",this.onclick.bind(this),!1),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("dragstart",this.ondragstart.bind(this),!1)}shouldRenameOnMouseDown(){if(!this.uiSourceCodeInternal.canRename())return!1;if(!this.treeOutline)return!1;return this===this.treeOutline.selectedTreeElement&&this.treeOutline.element.hasFocus()&&!t.UIUtils.isBeingEdited(this.treeOutline.element)}selectOnMouseDown(e){1===e.which&&this.shouldRenameOnMouseDown()?window.setTimeout(function(){this.shouldRenameOnMouseDown()&&this.navigatorView.rename(this.node,!1)}.bind(this),300):super.selectOnMouseDown(e)}ondragstart(e){e.dataTransfer&&(e.dataTransfer.setData("text/plain",this.uiSourceCodeInternal.url()),e.dataTransfer.effectAllowed="copy")}onspace(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}onclick(e){this.navigatorView.sourceSelected(this.uiSourceCode,!1)}ondblclick(e){const t=1===e.button;return this.navigatorView.sourceSelected(this.uiSourceCode,!t),!1}onenter(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}ondelete(){return!0}handleContextMenuEvent(e){this.select(),this.navigatorView.handleFileContextMenu(e,this.node)}}class mt{id;navigatorView;type;childrenInternal;populated;isMerged;parent;title;tooltip;recursiveProperties;constructor(e,t,i,o){this.id=t,this.navigatorView=e,this.type=i,this.childrenInternal=new Map,this.tooltip=o,this.populated=!1,this.isMerged=!1,this.recursiveProperties={exclusivelySourceMapped:null,exclusivelyIgnored:null,exclusivelyContentScripts:null,exclusivelyThirdParty:null}}treeNode(){throw"Not implemented"}dispose(){}updateTitle(){}updateTitleRecursive(){for(const e of this.children())e.updateTitleRecursive();this.updateTitle()}updateTitleBubbleUp(){this.updateTitle(),this.parent&&this.parent.updateTitleBubbleUp()}isRoot(){return!1}hasChildren(){return!0}onattach(){}setTitle(e){throw"Not implemented"}populate(){this.isPopulated()||(this.parent&&this.parent.populate(),this.populated=!0,this.wasPopulated())}wasPopulated(){const e=this.children();for(let t=0;t<e.length;++t)this.navigatorView.appendChild(this.treeNode(),e[t].treeNode())}didAddChild(e){this.isPopulated()&&this.navigatorView.appendChild(this.treeNode(),e.treeNode())}willRemoveChild(e){this.isPopulated()&&this.navigatorView.removeChild(this.treeNode(),e.treeNode())}isPopulated(){return this.populated}isEmpty(){return!this.childrenInternal.size}children(){return[...this.childrenInternal.values()]}child(e){return this.childrenInternal.get(e)||null}appendChild(e){this.childrenInternal.set(e.id,e),e.parent=this,this.didAddChild(e)}removeChild(e){this.willRemoveChild(e),this.childrenInternal.delete(e.id),e.parent=null,e.dispose()}reset(){this.childrenInternal.clear()}}class bt extends mt{constructor(e){super(e,"",lt.Root)}isRoot(){return!0}treeNode(){return this.navigatorView.scriptsTree.rootElement()}}class ft extends mt{uiSourceCodeInternal;treeElement;eventListeners;frameInternal;constructor(e,t,i){super(e,"UISourceCode:"+t.canononicalScriptId(),lt.File),this.uiSourceCodeInternal=t,this.treeElement=null,this.eventListeners=[],this.frameInternal=i,this.recursiveProperties.exclusivelySourceMapped=t.contentType().isFromSourceMap(),t.contentType().isScript()&&(this.recursiveProperties.exclusivelyThirdParty=t.isKnownThirdParty(),this.recursiveProperties.exclusivelyContentScripts=t.project().type()===f.Workspace.projectTypes.ContentScripts)}frame(){return this.frameInternal}uiSourceCode(){return this.uiSourceCodeInternal}treeNode(){if(this.treeElement)return this.treeElement;this.treeElement=new gt(this.navigatorView,this.uiSourceCodeInternal,"",this),this.updateTitle();const e=this.updateTitle.bind(this,void 0);return this.eventListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.TitleChanged,e),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,e),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,e)],this.treeElement}updateTitle(e){const t=u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(this.uiSourceCodeInternal);if((this.uiSourceCodeInternal.contentType().isScript()||t)&&(this.recursiveProperties.exclusivelyIgnored=t),!this.treeElement)return;let i=this.uiSourceCodeInternal.displayName();!e&&this.uiSourceCodeInternal.isDirty()&&(i="*"+i),this.treeElement.title=i,this.treeElement.updateIcon(),this.treeElement.listItemElement.classList.toggle("is-ignore-listed",t);let o=this.uiSourceCodeInternal.url();this.uiSourceCodeInternal.contentType().isFromSourceMap()&&(o=ct(st.sFromSourceMap,{PH1:this.uiSourceCodeInternal.displayName()})),t&&(o=ct(st.sIgnoreListed,{PH1:o})),this.treeElement.tooltip=o,this.treeElement.updateAccessibleName(),this.parent?.childrenInternal.delete(this.id),this.id="UISourceCode:"+this.uiSourceCodeInternal.canononicalScriptId(),this.parent?.childrenInternal.set(this.id,this)}hasChildren(){return!1}dispose(){i.EventTarget.removeEventListeners(this.eventListeners)}reveal(e){this.parent&&(this.parent.populate(),this.parent.treeNode().expand()),this.treeElement&&(this.treeElement.reveal(!0),e&&this.treeElement.select(!0))}rename(e){if(!this.treeElement)return;if(this.treeElement.listItemElement.focus(),!this.treeElement.treeOutline)return;const i=this.treeElement.treeOutline.element;function o(o){if(!o)return t.UIUtils.markBeingEdited(i,!1),this.updateTitle(),void this.rename(e);if(this.treeElement){const{parent:e}=this.treeElement;e&&(e.removeChild(this.treeElement),e.appendChild(this.treeElement),this.treeElement.select())}n.call(this,!0)}function n(o){t.UIUtils.markBeingEdited(i,!1),this.updateTitle(),e&&e(o)}t.UIUtils.markBeingEdited(i,!0),this.updateTitle(!0),this.treeElement.startEditingTitle(new t.InplaceEditor.Config(function(e,t,i){if(t!==i)return this.treeElement&&(this.treeElement.title=t),void this.uiSourceCodeInternal.rename(t).then(o.bind(this));n.call(this,!0)}.bind(this),n.bind(this,!1)))}}class St extends mt{project;folderPath;origin;title;treeElement;constructor(e,t,i,o,n,r,s){super(e,i,o),this.project=t,this.folderPath=n,this.title=r,this.origin=s}treeNode(){return this.treeElement||(this.treeElement=this.createTreeElement(this.title,this),this.updateTitle()),this.treeElement}updateTitle(){let e;for(e in this.recursiveProperties){let t=null;for(const i of this.children()){if(!1===i.recursiveProperties[e]){t=!1;break}i.recursiveProperties[e]&&(t=!0)}this.recursiveProperties[e]=t}if(!this.treeElement)return;if(this.treeElement.setFromSourceMap(this.recursiveProperties.exclusivelySourceMapped||!1),this.treeElement.setIgnoreListed(this.recursiveProperties.exclusivelyIgnored||!1),!this.project||this.project.type()!==f.Workspace.projectTypes.FileSystem)return;const t=i.ParsedURL.ParsedURL.concatenate(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemPath(this.project.id()),"/",this.folderPath),o=h.Persistence.PersistenceImpl.instance().filePathHasBindings(t);this.treeElement.listItemElement.classList.toggle("has-mapped-files",o)}createTreeElement(e,t){const i=new pt(this.navigatorView,this.type,e);return i.setNode(t),i}wasPopulated(){this.treeElement&&this.treeElement.node===this&&this.addChildrenRecursive()}addChildrenRecursive(){const e=this.children();for(let t=0;t<e.length;++t){const i=e[t];this.didAddChild(i),i instanceof St&&i.addChildrenRecursive()}}shouldMerge(e){return this.type!==lt.Domain&&e instanceof St}didAddChild(e){if(!this.treeElement)return;let t,i=this.children();if(1===i.length&&this.shouldMerge(e))return e.isMerged=!0,this.treeElement.title=this.treeElement.title+"/"+e.title,e.treeElement=this.treeElement,e.updateTitle(),void this.treeElement.setNode(e);if(2===i.length&&(t=i[0]!==e?i[0]:i[1]),t&&t.isMerged){t.isMerged=!1;const e=[];e.push(this);let o=this;for(;o&&o.isMerged;)o=o.parent,o&&e.push(o);e.reverse();const n=e.map((e=>e.title)).join("/"),r=[];o=t;do{r.push(o),i=o.children(),o=1===i.length?i[0]:null}while(o&&o.isMerged);if(!this.isPopulated()){this.treeElement.title=n,this.treeElement.setNode(this);for(let e=0;e<r.length;++e)r[e].treeElement=null,r[e].isMerged=!1;return void this.updateTitle()}const s=this.treeElement,a=this.createTreeElement(n,this);for(let t=0;t<e.length;++t)e[t].treeElement=a,e[t].updateTitle();s.parent&&this.navigatorView.appendChild(s.parent,a),s.setNode(r[r.length-1]),s.title=r.map((e=>e.title)).join("/"),s.parent&&this.navigatorView.removeChild(s.parent,s),this.navigatorView.appendChild(this.treeElement,s),s.expanded&&a.expand(),this.updateTitle()}this.isPopulated()&&this.navigatorView.appendChild(this.treeElement,e.treeNode())}willRemoveChild(e){const t=e;!t.isMerged&&this.isPopulated()&&this.treeElement&&t.treeElement&&this.navigatorView.removeChild(this.treeElement,t.treeElement)}}class vt extends mt{project;title;hoverCallback;treeElement;constructor(e,t,i,o,n,r){super(e,i,o,r),this.project=t,this.title=n,this.populate()}setHoverCallback(e){this.hoverCallback=e}treeNode(){return this.treeElement||(this.treeElement=new pt(this.navigatorView,this.type,this.title,this.hoverCallback),this.treeElement.setNode(this)),this.treeElement}onattach(){this.updateTitle()}updateTitle(){if(!this.treeElement||!this.project||this.project.type()!==f.Workspace.projectTypes.FileSystem)return;const e=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemPath(this.project.id()),t=this.treeElement.listItemElement.classList.contains("has-mapped-files"),i=h.Persistence.PersistenceImpl.instance().filePathHasBindings(e);t!==i&&(this.treeElement.listItemElement.classList.toggle("has-mapped-files",i),this.treeElement.childrenListElement.hasFocus()||(i?this.treeElement.expand():this.treeElement.collapse()))}setTitle(e){this.title=e,this.treeElement&&(this.treeElement.title=this.title)}}var Ct=Object.freeze({__proto__:null,Types:lt,NavigatorView:ut,NavigatorFolderTreeElement:pt,NavigatorSourceTreeElement:gt,NavigatorTreeNode:mt,NavigatorRootTreeNode:bt,NavigatorUISourceCodeTreeNode:ft,NavigatorFolderTreeNode:St,NavigatorGroupTreeNode:vt});const wt=new CSSStyleSheet;wt.replaceSync('.paused-message{align-self:center;width:fit-content}.scripts-debug-toolbar{position:absolute;top:0;width:100%;background-color:var(--app-color-toolbar-background);border-bottom:1px solid var(--sys-color-divider);overflow:hidden;z-index:1}.scripts-debug-toolbar-drawer{flex:0 0 52px;transition:margin-top 0.1s ease-in-out;margin-top:-26px;padding-top:25px;background-color:var(--sys-color-cdt-base-container);overflow:hidden;white-space:nowrap}.scripts-debug-toolbar-drawer.expanded{margin-top:0}.scripts-debug-toolbar-drawer > [is="dt-checkbox"]{display:none;padding-left:3px;height:28px}.scripts-debug-toolbar-drawer.expanded > [is="dt-checkbox"]{display:flex}.cursor-auto{cursor:auto}.navigator-tabbed-pane{background-color:var(--sys-color-cdt-base-container)}\n/*# sourceURL=sourcesPanel.css */\n');class It{sourcesView;entries=[];current=-1;revealing=!1;constructor(e){this.sourcesView=e}trackSourceFrameCursorJumps(e){e.addEventListener("EditorUpdate",(t=>this.onEditorUpdate(t.data,e)))}onEditorUpdate(e,t){e.docChanged&&this.mapEntriesFor(t.uiSourceCode(),e.changes);const i=e.startState.selection.main,o=e.state.selection.main;!this.revealing&&i.anchor!==o.anchor&&e.transactions.some((e=>Boolean(e.isUserEvent("select.pointer")||e.isUserEvent("select.reveal")||e.isUserEvent("select.search"))))&&(this.updateCurrentState(t.uiSourceCode(),i.head),this.entries.length>this.current+1&&(this.entries.length=this.current+1),this.entries.push(new yt(t.uiSourceCode(),o.head)),this.current++,this.entries.length>20&&(this.entries.shift(),this.current--))}updateCurrentState(e,t){if(!this.revealing){const i=this.current>=0?this.entries[this.current]:null;i?.matches(e)&&(i.position=t)}}mapEntriesFor(e,t){for(const i of this.entries)i.matches(e)&&(i.position=t.mapPos(i.position))}reveal(e){const t=f.Workspace.WorkspaceImpl.instance().uiSourceCode(e.projectId,e.url);t&&(this.revealing=!0,this.sourcesView.showSourceLocation(t,e.position,!1,!0),this.revealing=!1)}rollback(){this.current>0&&(this.current--,this.reveal(this.entries[this.current]))}rollover(){this.current<this.entries.length-1&&(this.current++,this.reveal(this.entries[this.current]))}removeHistoryForSourceCode(e){for(let t=this.entries.length-1;t>=0;t--)this.entries[t].matches(e)&&(this.entries.splice(t,1),this.current>=t&&this.current--)}}class yt{projectId;url;position;constructor(e,t){this.projectId=e.project().id(),this.url=e.url(),this.position=t}matches(e){return this.url===e.url()&&this.projectId===e.project().id()}}var xt=Object.freeze({__proto__:null,HistoryDepth:20,EditingLocationHistoryManager:It});const kt=new CSSStyleSheet;kt.replaceSync("#sources-panel-sources-view{--override-highlight-animation-10pc-background-color:rgb(158 54 153);--override-highlight-animation-10pc-foreground-color:rgb(255 255 255);flex:auto;position:relative}#sources-panel-sources-view .sources-toolbar{display:flex;flex:0 0 27px;background-color:var(--sys-color-cdt-base-container);border-top:1px solid var(--sys-color-divider);overflow:hidden;z-index:0}.sources-toolbar .toolbar{cursor:default}.source-frame-debugger-script{--override-debugger-background-tint:rgb(255 255 194/50%);background-color:var(--override-debugger-background-tint)}.-theme-with-dark-background .source-frame-debugger-script{--override-debugger-background-tint:rgb(61 61 0/50%)}\n/*# sourceURL=sourcesView.css */\n");const Tt=["application/javascript","application/json","application/manifest+json","text/css","text/html","text/javascript"],Et={ms:"ms",mb:"MB",kb:"kB"},Lt=e.i18n.registerUIStrings("panels/sources/ProfilePlugin.ts",Et),Mt=e.i18n.getLocalizedString.bind(void 0,Lt);class Pt extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";let t=this.value;const i=l.NumberUtilities.clamp(Math.log10(1+.002*t)/5,.02,1);let o,n;e.style.backgroundColor=`hsla(217, 100%, 70%, ${i.toFixed(3)})`,t/=1e3,t>=1e3?(o=Mt(Et.mb),t/=1e3,n=t>=20?0:1):(o=Mt(Et.kb),n=0),e.textContent=t.toFixed(n);const r=e.appendChild(document.createElement("span"));return r.className="cm-units",r.textContent=o,e}}class Ft extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";const t=l.NumberUtilities.clamp(Math.log10(1+10*this.value)/5,.02,1);e.textContent=this.value.toFixed(1),e.style.backgroundColor=`hsla(44, 100%, 50%, ${t.toFixed(3)})`;const i=document.createElement("span");return i.className="cm-units",i.textContent=Mt(Et.ms),e.appendChild(i),e}}function Dt(e,t,i){const o="performance"===i?Ft:Pt,r=[];for(const[i,n]of e)if(i<=t.doc.lines){const{from:e}=t.doc.line(i);r.push(new o(n).range(e))}return n.RangeSet.of(r,!0)}const Nt=e=>class extends pe{updateEffect=n.StateEffect.define();field;gutter;compartment=new n.Compartment;constructor(t){super(t),this.field=n.StateField.define({create:()=>n.RangeSet.empty,update:(t,i)=>i.effects.reduce(((t,o)=>o.is(this.updateEffect)?Dt(o.value,i.state,e):t),t.map(i.changes))}),this.gutter=n.gutter({markers:e=>e.state.field(this.field),class:`cm-${e}Gutter`})}static accepts(e){return e.contentType().hasScripts()}getLineMap(){return this.uiSourceCode.getDecorationData(e)}editorExtension(){const t=this.getLineMap();return this.compartment.of(t?[this.field.init((i=>Dt(t,i,e))),this.gutter,At]:[])}decorationChanged(e,t){const i=Boolean(t.state.field(this.field,!1)),o=this.getLineMap();o?i?t.dispatch({effects:this.updateEffect.of(o)}):t.dispatch({effects:this.compartment.reconfigure([this.field.init((t=>Dt(o,t,e))),this.gutter,At])}):i&&t.dispatch({effects:this.compartment.reconfigure([])})}},At=n.EditorView.baseTheme({".cm-performanceGutter":{width:"60px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-memoryGutter":{width:"48px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-profileMarker":{textAlign:"right",paddingRight:"3px"},".cm-profileMarker .cm-units":{color:"var(--sys-color-token-subtle)",fontSize:"75%",marginLeft:"3px"}}),Ut=Nt("memory"),Rt=Nt("performance"),Bt={fromS:"(From {PH1})",sourceMappedFromS:"(Source mapped from {PH1})"},jt=e.i18n.registerUIStrings("panels/sources/ResourceOriginPlugin.ts",Bt),Vt=e.i18n.getLocalizedString.bind(void 0,jt);class Wt extends pe{static accepts(e){const t=e.contentType();return t.hasScripts()||t.isFromSourceMap()}rightToolbarItems(){const i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();if(this.uiSourceCode.contentType().isFromSourceMap()){const o=[];for(const e of i.scriptsForUISourceCode(this.uiSourceCode)){const t=i.uiSourceCodeForScript(e);if(!t)continue;const n=t.url(),r=u.ResourceUtils.displayNameForURL(n),s=Vt(Bt.sourceMappedFromS,{PH1:r});o.push(D.Linkifier.Linkifier.linkifyRevealable(t,r,n,s))}for(const e of u.SASSSourceMapping.SASSSourceMapping.uiSourceOrigin(this.uiSourceCode))o.push(D.Linkifier.Linkifier.linkifyURL(e));if(0===o.length)return[];const n=document.createElement("span");return o.forEach(((e,t)=>{t>0&&n.append(", "),n.append(e)})),[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(jt,Bt.fromS,{PH1:n}))]}for(const o of i.scriptsForUISourceCode(this.uiSourceCode))if(o.originStackTrace){const i=Ot.linkifyStackTraceTopFrame(o.debuggerModel.target(),o.originStackTrace);return[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(jt,Bt.fromS,{PH1:i}))]}return[]}}const Ot=new D.Linkifier.Linkifier;var Ht=Object.freeze({__proto__:null,ResourceOriginPlugin:Wt,linkifier:Ot});const _t={enter:"⌘+Enter",ctrlenter:"Ctrl+Enter"},zt=e.i18n.registerUIStrings("panels/sources/SnippetsPlugin.ts",_t),qt=e.i18n.getLocalizedString.bind(void 0,zt);class $t extends pe{static accepts(e){return T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e)}rightToolbarItems(){const e=t.Toolbar.Toolbar.createActionButtonForId("debugger.run-snippet");return e.setText(c.Platform.isMac()?qt(_t.enter):qt(_t.ctrlenter)),[e]}editorExtension(){return s.JavaScript.completion()}}var Gt=Object.freeze({__proto__:null,SnippetsPlugin:$t});class Kt extends(i.ObjectWrapper.eventMixin(m.SourceFrame.SourceFrameImpl)){uiSourceCodeInternal;muteSourceCodeEvents;persistenceBinding;uiSourceCodeEventListeners;messageAndDecorationListeners;boundOnBindingChanged;plugins=[];errorPopoverHelper;openInExternalEditorToolbarButton;#p=!1;constructor(e){if(super((()=>this.workingCopy())),this.element.setAttribute("jslog",`${a.textField()}`),this.uiSourceCodeInternal=e,this.muteSourceCodeEvents=!1,this.persistenceBinding=h.Persistence.PersistenceImpl.instance().binding(e),this.uiSourceCodeEventListeners=[],this.messageAndDecorationListeners=[],this.canOpenInExternalEditor()){this.openInExternalEditorToolbarButton=new t.Toolbar.ToolbarButton("Open in editor",void 0,"Open in editor");const e=globalThis.reactNativeOpenInEditorButtonImage;if("string"==typeof e&&""!==e){const t=new P.Adorner.Adorner;t.classList.add("open-in-external-editor-adorner"),t.style.setProperty("background-image",e),this.openInExternalEditorToolbarButton.element.classList.add("toolbar-has-glyph","open-in-external-editor-button"),this.openInExternalEditorToolbarButton.setGlyphOrAdorner(t)}else this.openInExternalEditorToolbarButton.setGlyph("open-externally");this.openInExternalEditorToolbarButton.addEventListener("Click",(()=>{const e={url:this.uiSourceCode().url()},t=this.textEditor.state,i=t.doc.lineAt(t.selection.main.head),{lineNumber:o}=this.editorLocationToUILocation(i.number);e.lineNumber=o,fetch("/open-stack-frame",{method:"POST",body:JSON.stringify(e)}).catch((e=>console.error(e)))}))}this.boundOnBindingChanged=this.onBindingChanged.bind(this),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").addChangeListener(this.onNetworkPersistenceChanged,this),this.errorPopoverHelper=new t.PopoverHelper.PopoverHelper(this.textEditor.editor.contentDOM,this.getErrorPopoverContent.bind(this),"sources.error"),this.errorPopoverHelper.setHasPadding(!0),this.errorPopoverHelper.setTimeout(100,100),this.initializeUISourceCode()}canOpenInExternalEditor(){return!!globalThis.enableReactNativeOpenInExternalEditor&&(this.uiSourceCode().url().startsWith("http")??!1)}async workingCopy(){return this.uiSourceCodeInternal.isDirty()?{content:this.uiSourceCodeInternal.workingCopy(),isEncoded:!1}:this.uiSourceCodeInternal.requestContent()}editorConfiguration(e){return[super.editorConfiguration(e),(t=this.allMessages(),[ri.init((e=>ni.create(ei.create(t),e.doc))),ai]),Yt.of(this.plugins.map((e=>e.editorExtension())))];var t}onFocus(){super.onFocus(),t.Context.Context.instance().setFlavor(Kt,this)}onBlur(){super.onBlur(),t.Context.Context.instance().setFlavor(Kt,null)}installMessageAndDecorationListeners(){if(this.persistenceBinding){const e=this.persistenceBinding.network,t=this.persistenceBinding.fileSystem;this.messageAndDecorationListeners=[e.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),e.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),e.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this),t.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),t.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this)]}else this.messageAndDecorationListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this)]}uiSourceCode(){return this.uiSourceCodeInternal}setUISourceCode(e){const t=e.contentLoaded()?Promise.resolve():e.requestContent(),i=this.uiSourceCodeInternal;t.then((async()=>{this.uiSourceCodeInternal===i&&(this.unloadUISourceCode(),this.uiSourceCodeInternal=e,e.workingCopy()!==this.textEditor.state.doc.toString()?await this.setDeferredContent(Promise.resolve(e.workingCopyContent())):this.reloadPlugins(),this.initializeUISourceCode())}),console.error)}unloadUISourceCode(){i.EventTarget.removeEventListeners(this.messageAndDecorationListeners),i.EventTarget.removeEventListeners(this.uiSourceCodeEventListeners),this.uiSourceCodeInternal.removeWorkingCopyGetter(),h.Persistence.PersistenceImpl.instance().unsubscribeFromBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged)}initializeUISourceCode(){this.uiSourceCodeEventListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.onWorkingCopyChanged,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.onWorkingCopyCommitted,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.TitleChanged,this.onTitleChanged,this)],h.Persistence.PersistenceImpl.instance().subscribeForBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged),this.installMessageAndDecorationListeners(),this.updateStyle();const e=Tt.includes(this.contentType)&&!this.uiSourceCodeInternal.project().canSetFileContent()&&null===h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=!this.uiSourceCodeInternal.contentType().isFromSourceMap();this.setCanPrettyPrint(e,t)}wasShown(){super.wasShown(),this.setEditable(this.canEditSourceInternal())}willHide(){for(const e of this.plugins)e.willHide();super.willHide(),t.Context.Context.instance().setFlavor(Kt,null),this.uiSourceCodeInternal.removeWorkingCopyGetter()}getContentType(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network.mimeType():this.uiSourceCodeInternal.mimeType();return i.ResourceType.ResourceType.simplifyContentType(t)}canEditSourceInternal(){return!this.hasLoadError()&&(!this.uiSourceCodeInternal.editDisabled()&&("application/wasm"!==this.uiSourceCodeInternal.mimeType()&&(!!h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal)||(!!this.uiSourceCodeInternal.project().canSetFileContent()||!this.uiSourceCodeInternal.project().isServiceProject()&&(!(this.uiSourceCodeInternal.project().type()!==f.Workspace.projectTypes.Network||!h.NetworkPersistenceManager.NetworkPersistenceManager.instance().active())||(!this.pretty||!this.uiSourceCodeInternal.contentType().hasScripts())&&this.uiSourceCodeInternal.contentType()!==i.ResourceType.resourceTypes.Document)))))}onNetworkPersistenceChanged(){this.setEditable(this.canEditSourceInternal())}commitEditing(){this.uiSourceCodeInternal.isDirty()&&(this.muteSourceCodeEvents=!0,this.uiSourceCodeInternal.commitWorkingCopy(),this.muteSourceCodeEvents=!1)}async setContent(e){this.disposePlugins(),this.loadPlugins(),await super.setContent(e);for(const e of this.plugins)e.editorInitialized(this.textEditor);this.#g(),i.EventTarget.fireEvent("source-file-loaded",this.uiSourceCodeInternal.displayName(!0))}createMessage(e){const{lineNumber:t,columnNumber:i}=this.uiLocationToEditorLocation(e.lineNumber(),e.columnNumber());return new Qt(e,t,i)}allMessages(){return(null!==this.persistenceBinding?[...this.persistenceBinding.network.messages(),...this.persistenceBinding.fileSystem.messages()]:[...this.uiSourceCodeInternal.messages()]).map((e=>this.createMessage(e)))}onTextChanged(){const e=this.pretty;super.onTextChanged(),this.errorPopoverHelper.hidePopover(),Oi.instance().updateLastModificationTime(),this.muteSourceCodeEvents=!0,this.isClean()?this.uiSourceCodeInternal.resetWorkingCopy():this.uiSourceCodeInternal.setWorkingCopyGetter((()=>this.textEditor.state.sliceDoc())),this.muteSourceCodeEvents=!1,e!==this.pretty&&(this.updateStyle(),this.reloadPlugins())}onWorkingCopyChanged(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCodeInternal.workingCopyContent())}onWorkingCopyCommitted(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCode().workingCopyContent()),this.contentCommitted(),this.updateStyle()}reloadPlugins(){this.disposePlugins(),this.loadPlugins();const e=this.textEditor;e.dispatch({effects:Yt.reconfigure(this.plugins.map((e=>e.editorExtension())))});for(const t of this.plugins)t.editorInitialized(e)}onTitleChanged(){this.updateLanguageMode("").then((()=>this.reloadPlugins()),console.error)}loadPlugins(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network:this.uiSourceCodeInternal;for(const e of[He,Zi,$t,Wt,Se,Ut,Rt])e.accepts(t)&&this.plugins.push(new e(t,this));this.dispatchEventToListeners("ToolbarItemsChanged")}disposePlugins(){for(const e of this.plugins)e.dispose();this.plugins=[]}onBindingChanged(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal);e!==this.persistenceBinding&&(this.unloadUISourceCode(),this.persistenceBinding=e,this.initializeUISourceCode(),this.reloadMessages(),this.reloadPlugins())}reloadMessages(){const e=this.allMessages(),{editor:t}=this.textEditor;t.dispatch({effects:ti.of(ei.create(e))})}updateStyle(){this.setEditable(this.canEditSourceInternal())}maybeSetContent(e){this.textEditor.state.doc.toString()!==e.content&&this.setDeferredContent(Promise.resolve(e))}populateTextAreaContextMenu(e,t,i){super.populateTextAreaContextMenu(e,t,i),e.appendApplicableItems(this.uiSourceCodeInternal);const o=this.editorLocationToUILocation(t,i);e.appendApplicableItems(new f.UISourceCode.UILocation(this.uiSourceCodeInternal,o.lineNumber,o.columnNumber));for(const o of this.plugins)o.populateTextAreaContextMenu(e,t,i)}populateLineGutterContextMenu(e,t){super.populateLineGutterContextMenu(e,t);for(const i of this.plugins)i.populateLineGutterContextMenu(e,t)}dispose(){this.errorPopoverHelper.dispose(),this.disposePlugins(),this.unloadUISourceCode(),this.textEditor.editor.destroy(),this.detach(),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").removeChangeListener(this.onNetworkPersistenceChanged,this)}onMessageAdded(e){const{editor:t}=this.textEditor,i=t.state.field(ri,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ti.of(i.messages.add(o))})}}onMessageRemoved(e){const{editor:t}=this.textEditor,i=t.state.field(ri,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ti.of(i.messages.remove(o))})}}onDecorationChanged(e){for(const t of this.plugins)t.decorationChanged(e.data,this.textEditor)}async toolbarItems(){const e=await super.toolbarItems(),i=[];for(const t of this.plugins)e.push(...t.leftToolbarItems()),i.push(...t.rightToolbarItems());return i.length?(this.openInExternalEditorToolbarButton&&e.push(this.openInExternalEditorToolbarButton),[...e,new t.Toolbar.ToolbarSeparator(!0),...i]):e}getErrorPopoverContent(e){const t=e,i=e.target,o=i.enclosingNodeOrSelfWithClass("cm-messageIcon-error")||i.enclosingNodeOrSelfWithClass("cm-messageIcon-issue");if(!o)return null;const n=this.textEditor.state.field(ri,!1);if(!n||0===n.messages.rows.length)return null;const{editor:r}=this.textEditor,s=r.posAtCoords(t);if(null===s)return null;const a=r.state.doc.lineAt(s);if(s!==a.to)return null;const c=n.messages.rows.find((e=>e[0].lineNumber()===a.number-1));if(!c)return null;const l=o.classList.contains("cm-messageIcon-issue"),d=c.filter((e=>"Issue"===e.level()===l));if(!d.length)return null;const u=o?o.boxInWindow():new AnchorBox(t.clientX,t.clientY,1,1),h=function(e){const t=[];for(let i=0;i<e.length;i++){t[i]=0;for(let o=0;o<=i;o++)if(e[o].isEqual(e[i])){t[o]++;break}}return t}(d),p=document.createElement("div");p.classList.add("text-editor-messages-description-container");for(let e=0;e<d.length;e++)h[e]&&p.appendChild(si(d[e],h[e]));return{box:u,hide(){},show:async e=>(e.contentElement.append(p),!0)}}#g(){if(this.#p)return;this.#p=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCodeInternal.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCodeInternal.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCodeInternal.content()));c.userMetrics.sourcesPanelFileOpened(t)}}function Jt(e){return"Error"===e?{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}:"Warning"===e?{color:"var(--icon-warning)",width:"18px",height:"14px",iconName:"warning-filled"}:"Issue"===e?{color:"var(--icon-warning)",width:"17px",height:"14px",iconName:"issue-exclamation-filled"}:{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}}function Xt(e,t){const i={Issue:2,Warning:3,Error:4};return i[e.level()]-i[t.level()]}const Yt=new n.Compartment;class Qt{origin;#m;#b;constructor(e,t,i){this.origin=e,this.#m=t,this.#b=i}level(){return this.origin.level()}text(){return this.origin.text()}clickHandler(){return this.origin.clickHandler()}lineNumber(){return this.#m}columnNumber(){return this.#b}isEqual(e){return this.origin.isEqual(e.origin)}}function Zt(e,t){const i=t.lineNumber();let o=0;for(;o<e.length;o++){const n=e[o][0].lineNumber()-i;if(0===n)return e[o]=e[o].concat(t),e;if(n>0)break}return e.splice(o,0,[t]),e}class ei{rows;constructor(e){this.rows=e}static create(e){const t=[];for(const i of e)Zt(t,i);return new ei(t)}remove(e){const t=this.rows.slice();return function(e,t){for(let i=0;i<e.length;i++)if(e[i][0].lineNumber()===t.lineNumber()){const o=e[i].filter((e=>!e.isEqual(t)));o.length?e[i]=o:e.splice(i,1);break}}(t,e),new ei(t)}add(e){return new ei(Zt(this.rows.slice(),e))}}const ti=n.StateEffect.define(),ii=n.Decoration.mark({class:"cm-waveUnderline"});class oi extends n.WidgetType{messages;constructor(e){super(),this.messages=e}eq(e){return e.messages===this.messages}toDOM(){const e=document.createElement("span");e.classList.add("cm-messageIcon");const t=this.messages.filter((e=>"Issue"!==e.level()));if(t.length){const i=t.sort(Xt)[t.length-1],o=e.appendChild(new r.Icon.Icon);o.data=Jt(i.level()),o.classList.add("cm-messageIcon-error")}const i=this.messages.find((e=>"Issue"===e.level()));if(i){const t=e.appendChild(new r.Icon.Icon);t.data=Jt("Issue"),t.classList.add("cm-messageIcon-issue"),t.addEventListener("click",(()=>(i.clickHandler()||Math.min)()))}return e}ignoreEvents(){return!0}}class ni{messages;decorations;constructor(e,t){this.messages=e,this.decorations=t}static create(e,t){const i=new n.RangeSetBuilder;for(const o of e.rows){const e=t.line(Math.min(t.lines,o[0].lineNumber()+1)),r=o.reduce(((e,t)=>Math.min(e,t.columnNumber()||0)),e.length);r<e.length&&i.add(e.from+r,e.to,ii),i.add(e.to,e.to,n.Decoration.widget({side:1,widget:new oi(o)}))}return new ni(e,i.finish())}apply(e){let t=this;e.docChanged&&(t=new ni(this.messages,this.decorations.map(e.changes)));for(const i of e.effects)i.is(ti)&&(t=ni.create(i.value,e.state.doc));return t}}const ri=n.StateField.define({create:e=>ni.create(new ei([]),e.doc),update:(e,t)=>e.apply(t),provide:e=>n.Prec.lowest(n.EditorView.decorations.from(e,(e=>e.decorations)))});function si(e,t){const i=document.createElement("div");if(i.classList.add("text-editor-row-message"),i.style.display="flex",i.style.alignItems="center",i.style.gap="4px",1===t){const t=i.appendChild(new r.Icon.Icon);t.data=function(e){return e.origin instanceof M.SourceFrameIssuesManager.IssueMessage?{...F.IssueCounter.getIssueKindIconData(e.origin.getIssueKind()),width:"12px",height:"12px"}:Jt(e.level())}(e),t.classList.add("text-editor-row-message-icon"),t.addEventListener("click",(()=>(e.clickHandler()||Math.min)()))}else{const o=document.createElement("span",{is:"dt-small-bubble"});o.textContent=String(t),o.classList.add("text-editor-row-message-repeat-count"),o.style.flexShrink="0",i.appendChild(o),o.type=function(e){switch(e){case"Error":return"error";case"Warning":case"Issue":return"warning"}}(e.level())}const o=i.createChild("div");for(const t of e.text().split("\n"))o.createChild("div").textContent=t;return i}const ai=n.EditorView.baseTheme({".cm-tooltip-message":{padding:"4px"},".cm-waveUnderline":{backgroundImage:"var(--image-file-errorWave)",backgroundRepeat:"repeat-x",backgroundPosition:"bottom",paddingBottom:"1px"},".cm-messageIcon":{cursor:"pointer","& > *":{verticalAlign:"text-bottom",marginLeft:"2px"}},".cm-messageIcon-issue, .cm-messageIcon-error":{marginTop:"-1px",marginBottom:"-1px"}});var ci=Object.freeze({__proto__:null,UISourceCodeFrame:Kt});const li={areYouSureYouWantToCloseUnsaved:"Are you sure you want to close unsaved file: {PH1}?",unableToLoadThisContent:"Unable to load this content.",changesToThisFileWereNotSavedTo:"Changes to this file were not saved to file system."},di=e.i18n.registerUIStrings("panels/sources/TabbedEditorContainer.ts",li),ui=e.i18n.getLocalizedString.bind(void 0,di);let hi=0;class pi extends i.ObjectWrapper.ObjectWrapper{delegate;tabbedPane;tabIds;files;previouslyViewedFilesSetting;history;uriToUISourceCode;idToUISourceCode;currentFileInternal;currentView;scrollTimer;reentrantShow;constructor(e,i,o,n){super(),this.delegate=e,this.tabbedPane=new t.TabbedPane.TabbedPane,this.tabbedPane.setPlaceholderElement(o,n),this.tabbedPane.setTabDelegate(new Si(this)),this.tabbedPane.setCloseableTabs(!0),this.tabbedPane.setAllowTabReorder(!0,!0),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabClosed,this.tabClosed,this),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabSelected,this.tabSelected,this),this.tabbedPane.headerElement().setAttribute("jslog",`${a.toolbar("top")}`),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingCreated,this.onBindingCreated,this),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingRemoved,this.onBindingRemoved,this),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("RequestsForHeaderOverridesFileChanged",this.#d,this),this.tabIds=new Map,this.files=new Map,this.previouslyViewedFilesSetting=i,this.history=fi.fromObject(this.previouslyViewedFilesSetting.get()),this.uriToUISourceCode=new Map,this.idToUISourceCode=new Map,this.reentrantShow=!1}onBindingCreated(e){const t=e.data;this.updateFileTitle(t.fileSystem);const i=this.tabIds.get(t.network);let o=this.tabIds.get(t.fileSystem);const n=this.currentFileInternal===t.network,r=mi(t.network),s=this.history.selectionRange(r),a=this.history.scrollLineNumber(r);if(this.history.remove(r),i){if(!o){const e=this.tabbedPane.tabView(i),n=this.tabbedPane.tabIndex(i);if(e instanceof Kt)this.delegate.recycleUISourceCodeFrame(e,t.fileSystem),o=this.appendFileTab(t.fileSystem,!1,n,e);else{o=this.appendFileTab(t.fileSystem,!1,n);const e=this.tabbedPane.tabView(o);this.restoreEditorProperties(e,s,a)}}this.closeTabs([i],!0),n&&this.tabbedPane.selectTab(o,!1),this.updateHistory()}}#d(e){this.updateFileTitle(e.data)}onBindingRemoved(e){const t=e.data;this.updateFileTitle(t.fileSystem)}get view(){return this.tabbedPane}get visibleView(){return this.tabbedPane.visibleView}fileViews(){return this.tabbedPane.tabViews()}leftToolbar(){return this.tabbedPane.leftToolbar()}rightToolbar(){return this.tabbedPane.rightToolbar()}show(e){this.tabbedPane.show(e)}showFile(e){const o=h.Persistence.PersistenceImpl.instance().binding(e);e=o?o.fileSystem:e;const n=t.Context.Context.instance().flavor(yi);if(n?.currentSourceFrame()?.contentSet&&this.currentFileInternal===e&&n?.currentUISourceCode()===e)i.EventTarget.fireEvent("source-file-loaded",e.displayName(!0));else{if(e.project().type()===f.Workspace.projectTypes.Debugger){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&t.isInlineScript()&&!t.hasSourceURL&&(t.isModule?c.userMetrics.vmInlineScriptContentShown(0):c.userMetrics.vmInlineScriptContentShown(1))}this.innerShowFile(e,!0)}}closeFile(e){const t=this.tabIds.get(e);t&&this.closeTabs([t])}closeAllFiles(){this.closeTabs(this.tabbedPane.tabIds())}historyUISourceCodes(){const e=[];for(const{url:t,resourceType:i}of this.history.keys()){const o=this.uriToUISourceCode.get(t);void 0!==o&&o.contentType()===i&&e.push(o)}return e}selectNextTab(){this.tabbedPane.selectNextTab()}selectPrevTab(){this.tabbedPane.selectPrevTab()}addViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.addEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.addEventListener("EditorScroll",this.onScrollChanged,this))}removeViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.removeEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.removeEventListener("EditorScroll",this.onScrollChanged,this))}onScrollChanged(){if(this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=window.setTimeout((()=>this.previouslyViewedFilesSetting.set(this.history.toObject())),100),this.currentFileInternal)){const{editor:e}=this.currentView.textEditor,t=e.lineBlockAtHeight(e.scrollDOM.getBoundingClientRect().top-e.documentTop),i=e.state.doc.lineAt(t.from).number-1;this.history.updateScrollLineNumber(mi(this.currentFileInternal),i)}}onEditorUpdate({data:e}){if(e.docChanged||e.selectionSet){const{main:t}=e.state.selection,i=e.state.doc.lineAt(t.from),o=e.state.doc.lineAt(t.to),n=new g.TextRange.TextRange(i.number-1,t.from-i.from,o.number-1,t.to-o.from);this.currentFileInternal&&this.history.updateSelectionRange(mi(this.currentFileInternal),n),this.previouslyViewedFilesSetting.set(this.history.toObject()),this.currentFileInternal&&k.ExtensionServer.ExtensionServer.instance().sourceSelectionChanged(this.currentFileInternal.url(),n)}}innerShowFile(e,t){if(this.reentrantShow)return;const i=this.canonicalUISourceCode(e),o=h.Persistence.PersistenceImpl.instance().binding(e);if(e=o?o.fileSystem:e,this.currentFileInternal===e)return;this.removeViewListeners(),this.currentFileInternal=e;try{this.reentrantShow=!0;const e=this.tabIds.get(i)||this.appendFileTab(i,t);this.tabbedPane.selectTab(e,t)}finally{this.reentrantShow=!1}t&&this.editorSelectedByUserAction();const n=this.currentView;this.currentView=this.visibleView,this.addViewListeners(),this.currentView instanceof Kt&&this.currentView.uiSourceCode()!==e&&(this.delegate.recycleUISourceCodeFrame(this.currentView,e),e.project().type()!==f.Workspace.projectTypes.FileSystem&&e.disableEdit());const r={currentFile:this.currentFileInternal,currentView:this.currentView,previousView:n,userGesture:t};this.dispatchEventToListeners("EditorSelected",r)}titleForFile(e){let t=l.StringUtilities.trimMiddle(e.displayName(!0),30);return e.isDirty()&&(t+="*"),t}maybeCloseTab(e,t){const i=this.files.get(e);if(!i)return!1;return!(i.isDirty()&&i.project().canSetFileContent()&&!confirm(ui(li.areYouSureYouWantToCloseUnsaved,{PH1:i.name()})))&&(i.resetWorkingCopy(),t&&this.tabbedPane.selectTab(t,!0),this.tabbedPane.closeTab(e,!0),!0)}closeTabs(e,t){const i=[],o=[];for(let n=0;n<e.length;++n){const r=e[n],s=this.files.get(r);s&&(!t&&s.isDirty()?i.push(r):o.push(r))}i.length&&this.tabbedPane.selectTab(i[0],!0),this.tabbedPane.closeTabs(o,!0);for(let e=0;e<i.length;++e){const t=e+1<i.length?i[e+1]:null;if(!this.maybeCloseTab(i[e],t))break}}onContextMenu(e,t){const i=this.files.get(e);i&&t.appendApplicableItems(i)}canonicalUISourceCode(e){const t=this.idToUISourceCode.get(e.canononicalScriptId());return t||(this.idToUISourceCode.set(e.canononicalScriptId(),e),this.uriToUISourceCode.set(e.url(),e),e)}addUISourceCode(e){const t=this.canonicalUISourceCode(e),i=t!==e,o=h.Persistence.PersistenceImpl.instance().binding(t);if(e=o?o.fileSystem:t,i&&e.project().type()!==f.Workspace.projectTypes.FileSystem&&e.disableEdit(),this.currentFileInternal?.canononicalScriptId()===e.canononicalScriptId())return;const n=this.history.index(mi(e));if(-1===n)return;if(this.tabIds.has(e)||this.appendFileTab(e,!1),!n)return void this.innerShowFile(e,!1);if(!this.currentFileInternal)return;const r=T.ScriptSnippetFileSystem.isSnippetsUISourceCode(this.currentFileInternal),s=T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e);this.history.index(mi(this.currentFileInternal))&&r&&!s&&this.innerShowFile(e,!1)}removeUISourceCode(e){this.removeUISourceCodes([e])}removeUISourceCodes(e){const t=[];for(const i of e){const e=this.tabIds.get(i);e&&t.push(e),this.uriToUISourceCode.get(i.url())===i&&this.uriToUISourceCode.delete(i.url()),this.idToUISourceCode.get(i.canononicalScriptId())===i&&this.idToUISourceCode.delete(i.canononicalScriptId())}this.tabbedPane.closeTabs(t)}editorClosedByUserAction(e){this.history.remove(mi(e)),this.updateHistory()}editorSelectedByUserAction(){this.updateHistory()}updateHistory(){const e=[];for(const t of this.tabbedPane.lastOpenedTabIds(gi)){const i=this.files.get(t);void 0!==i&&e.push(mi(i))}this.history.update(e),this.previouslyViewedFilesSetting.set(this.history.toObject())}tooltipForFile(e){return(e=h.Persistence.PersistenceImpl.instance().network(e)||e).url()}appendFileTab(e,t,i,o){const n=o||this.delegate.viewForFile(e),r=this.titleForFile(e),s=this.tooltipForFile(e),a=this.generateTabId();if(this.tabIds.set(e,a),this.files.set(a,e),!o){const t=this.history.selectionRange(mi(e)),i=this.history.scrollLineNumber(mi(e));this.restoreEditorProperties(n,t,i)}return this.tabbedPane.appendTab(a,r,n,s,t,void 0,void 0,i),this.updateFileTitle(e),this.addUISourceCodeListeners(e),e.loadError()?this.addLoadErrorIcon(a):e.contentLoaded()||e.requestContent().then((t=>{e.loadError()&&this.addLoadErrorIcon(a)})),a}addLoadErrorIcon(e){const i=new r.Icon.Icon;i.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(i,ui(li.unableToLoadThisContent)),this.tabbedPane.tabView(e)&&this.tabbedPane.setTabIcon(e,i)}restoreEditorProperties(e,t,i){const o=e instanceof m.SourceFrame.SourceFrameImpl?e:null;o&&(t&&o.setSelection(t),"number"==typeof i&&o.scrollToLine(i))}tabClosed(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);this.currentFileInternal&&this.currentFileInternal.canononicalScriptId()===o?.canononicalScriptId()&&(this.removeViewListeners(),this.currentView=null,this.currentFileInternal=null),o&&this.tabIds.delete(o),this.files.delete(t),o&&(this.removeUISourceCodeListeners(o),this.dispatchEventToListeners("EditorClosed",o),i&&this.editorClosedByUserAction(o))}tabSelected(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);o&&this.innerShowFile(o,i)}addUISourceCodeListeners(e){e.addEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}removeUISourceCodeListeners(e){e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}updateFileTitle(e){const i=this.tabIds.get(e);if(i){const o=this.titleForFile(e),n=this.tooltipForFile(e);this.tabbedPane.changeTabTitle(i,o,n);let s=null;e.loadError()?(s=new r.Icon.Icon,s.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,ui(li.unableToLoadThisContent))):h.Persistence.PersistenceImpl.instance().hasUnsavedCommittedChanges(e)?(s=new r.Icon.Icon,s.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,ui(li.changesToThisFileWereNotSavedTo))):s=h.PersistenceUtils.PersistenceUtils.iconForUISourceCode(e),this.tabbedPane.setTabIcon(i,s)}}uiSourceCodeTitleChanged(e){const t=e.data;this.updateFileTitle(t),this.updateHistory();for(const[e,i]of this.uriToUISourceCode)i===t&&e!==i.url()&&this.uriToUISourceCode.delete(e);for(const[e,i]of this.idToUISourceCode)i===t&&e!==i.canononicalScriptId()&&this.idToUISourceCode.delete(e);this.canonicalUISourceCode(t)}uiSourceCodeWorkingCopyChanged(e){const t=e.data;this.updateFileTitle(t)}uiSourceCodeWorkingCopyCommitted(e){const t=e.data.uiSourceCode;this.updateFileTitle(t)}generateTabId(){return"tab-"+hi++}currentFile(){return this.currentFileInternal||null}}const gi=30;function mi(e){return{url:e.url(),resourceType:e.contentType()}}class bi{url;resourceType;selectionRange;scrollLineNumber;constructor(e,t,i,o){this.url=e,this.resourceType=t,this.selectionRange=i,this.scrollLineNumber=o}static fromObject(e){const t=i.ResourceType.ResourceType.fromName(e.resourceTypeName);if(null===t)throw new TypeError(`Invalid resource type name "${e.resourceTypeName}"`);const o=e.selectionRange?g.TextRange.TextRange.fromObject(e.selectionRange):void 0;return new bi(e.url,t,o,e.scrollLineNumber)}toObject(){return this.url.length>=4096?null:{url:this.url,resourceTypeName:this.resourceType.name(),selectionRange:this.selectionRange,scrollLineNumber:this.scrollLineNumber}}}class fi{items;constructor(e){this.items=e}static fromObject(e){const t=[];for(const i of e)try{t.push(bi.fromObject(i))}catch{}return new fi(t)}index({url:e,resourceType:t}){return this.items.findIndex((i=>i.url===e&&i.resourceType===t))}selectionRange(e){const t=this.index(e);if(-1!==t)return this.items[t].selectionRange}updateSelectionRange(e,t){if(!t)return;const i=this.index(e);-1!==i&&(this.items[i].selectionRange=t)}scrollLineNumber(e){const t=this.index(e);if(-1!==t)return this.items[t].scrollLineNumber}updateScrollLineNumber(e,t){const i=this.index(e);-1!==i&&(this.items[i].scrollLineNumber=t)}update(e){for(let t=e.length-1;t>=0;--t){const i=this.index(e[t]);let o;-1!==i?(o=this.items[i],this.items.splice(i,1)):o=new bi(e[t].url,e[t].resourceType),this.items.unshift(o)}}remove(e){const t=this.index(e);-1!==t&&this.items.splice(t,1)}toObject(){const e=[];for(const t of this.items){const i=t.toObject();if(i&&e.push(i),e.length===gi)break}return e}keys(){return this.items}}class Si{editorContainer;constructor(e){this.editorContainer=e}closeTabs(e,t){this.editorContainer.closeTabs(t)}onContextMenu(e,t){this.editorContainer.onContextMenu(e,t)}}var vi=Object.freeze({__proto__:null,TabbedEditorContainer:pi,HistoryItem:bi,History:fi,EditorContainerTabDelegate:Si});const Ci={openFile:"Open file",runCommand:"Run command",workspaceDropInAFolderToSyncSources:"To sync edits to the workspace, drop a folder with your sources here or",selectFolder:"Select folder",sourceViewActions:"Source View Actions"},wi=e.i18n.registerUIStrings("panels/sources/SourcesView.ts",Ci),Ii=e.i18n.getLocalizedString.bind(void 0,wi);class yi extends(i.ObjectWrapper.eventMixin(t.Widget.VBox)){selectedIndex;searchableViewInternal;sourceViewByUISourceCode;editorContainer;historyManager;toolbarContainerElementInternal;scriptViewToolbar;bottomToolbarInternal;toolbarChangedListener;focusedPlaceholderElement;searchView;searchConfig;constructor(){super(),this.element.id="sources-panel-sources-view",this.element.setAttribute("jslog",`${a.pane("editor")}`),this.setMinimumAndPreferredSizes(88,52,150,100),this.selectedIndex=0;const e=f.Workspace.WorkspaceImpl.instance();this.searchableViewInternal=new t.SearchableView.SearchableView(this,this,"sources-view-search-config"),this.searchableViewInternal.setMinimalSearchQuerySize(0),this.searchableViewInternal.show(this.element),this.sourceViewByUISourceCode=new Map,this.editorContainer=new pi(this,i.Settings.Settings.instance().createLocalSetting("previously-viewed-files",[]),this.placeholderElement(),this.focusedPlaceholderElement),this.editorContainer.show(this.searchableViewInternal.element),this.editorContainer.addEventListener("EditorSelected",this.editorSelected,this),this.editorContainer.addEventListener("EditorClosed",this.editorClosed,this),this.historyManager=new It(this),this.toolbarContainerElementInternal=this.element.createChild("div","sources-toolbar"),this.toolbarContainerElementInternal.setAttribute("jslog",`${a.toolbar("bottom")}`),this.scriptViewToolbar=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.scriptViewToolbar.element.style.flex="auto",this.bottomToolbarInternal=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.toolbarChangedListener=null,t.UIUtils.startBatchUpdate(),e.uiSourceCodes().forEach(this.addUISourceCode.bind(this)),t.UIUtils.endBatchUpdate(),e.addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),e.addEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemoved,this),e.addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved.bind(this),this),o.TargetManager.TargetManager.instance().addScopeChangeListener(this.#f.bind(this)),window.opener||window.addEventListener("beforeunload",(function(e){if(e.returnValue)return;const o=[],n=f.Workspace.WorkspaceImpl.instance().projectsForType(f.Workspace.projectTypes.FileSystem);for(const e of n)for(const t of e.uiSourceCodes())t.isDirty()&&o.push(t);if(o.length){e.returnValue=!0,t.ViewManager.ViewManager.instance().showView("sources");for(const e of o)i.Revealer.reveal(e)}}),!0)}placeholderElement(){const e=[{actionId:"quick-open.show",description:Ii(Ci.openFile)},{actionId:"quick-open.show-command-menu",description:Ii(Ci.runCommand)},{actionId:"sources.add-folder-to-workspace",condition:C.Runtime.ConditionName.NOT_SOURCES_HIDE_ADD_FOLDER,description:Ii(Ci.workspaceDropInAFolderToSyncSources),isWorkspace:!0}],i=document.createElement("div");t.ARIAUtils.markAsList(i),t.ARIAUtils.setLabel(i,Ii(Ci.sourceViewActions));for(const o of e){const{condition:e}=o;if(void 0!==e&&!C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:()=>Boolean(C.Runtime.Runtime.queryParam(e))}))continue;const n=t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(o.actionId),r=i.createChild("div","tabbed-pane-placeholder-row");if(t.ARIAUtils.markAsListitem(r),n){r.createChild("span").textContent=n;const e=r.createChild("button");e.textContent=o.description;const i=t.ActionRegistry.ActionRegistry.instance().getAction(o.actionId);e.addEventListener("click",(()=>i.execute()))}if(o.isWorkspace){const e=r.createChild("span","workspace");e.textContent=o.description;const t=e.createChild("button");t.textContent=Ii(Ci.selectFolder),t.addEventListener("click",this.addFileSystemClicked.bind(this))}}return C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&i.appendChild(t.XLink.XLink.create("https://developer.chrome.com/docs/devtools/workspaces/","Learn more about Workspaces")),i}async addFileSystemClicked(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem()&&(c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSelectFolder),t.ViewManager.ViewManager.instance().showView("navigator-files"))}static defaultUISourceCodeScores(){const e=new Map,i=t.Context.Context.instance().flavor(yi);if(i){const t=i.editorContainer.historyUISourceCodes();for(let i=1;i<t.length;++i)e.set(t[i],t.length-i)}return e}leftToolbar(){return this.editorContainer.leftToolbar()}rightToolbar(){return this.editorContainer.rightToolbar()}bottomToolbar(){return this.bottomToolbarInternal}wasShown(){super.wasShown(),this.registerCSSFiles([kt]),t.Context.Context.instance().setFlavor(yi,this)}willHide(){t.Context.Context.instance().setFlavor(yi,null),super.willHide()}toolbarContainerElement(){return this.toolbarContainerElementInternal}searchableView(){return this.searchableViewInternal}visibleView(){return this.editorContainer.visibleView}currentSourceFrame(){const e=this.visibleView();return e instanceof Kt?e:null}currentUISourceCode(){return this.editorContainer.currentFile()}onCloseEditorTab(){const e=this.editorContainer.currentFile();return!!e&&(this.editorContainer.closeFile(e),!0)}onJumpToPreviousLocation(){this.historyManager.rollback()}onJumpToNextLocation(){this.historyManager.rollover()}#f(){const e=f.Workspace.WorkspaceImpl.instance();for(const t of e.uiSourceCodes()){if(t.project().type()!==f.Workspace.projectTypes.Network)continue;const e=u.NetworkProject.NetworkProject.targetForUISourceCode(t);o.TargetManager.TargetManager.instance().isInScope(e)?this.addUISourceCode(t):this.removeUISourceCodes([t])}}uiSourceCodeAdded(e){const t=e.data;this.addUISourceCode(t)}addUISourceCode(e){const t=e.project();if(!t.isServiceProject()){switch(t.type()){case f.Workspace.projectTypes.FileSystem:if("overrides"===h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(t))return;break;case f.Workspace.projectTypes.Network:{const t=u.NetworkProject.NetworkProject.targetForUISourceCode(e);if(!o.TargetManager.TargetManager.instance().isInScope(t))return}}this.editorContainer.addUISourceCode(e)}}uiSourceCodeRemoved(e){const t=e.data;this.removeUISourceCodes([t])}removeUISourceCodes(e){this.editorContainer.removeUISourceCodes(e);for(let t=0;t<e.length;++t)this.removeSourceFrame(e[t]),this.historyManager.removeHistoryForSourceCode(e[t])}projectRemoved(e){const t=e.data.uiSourceCodes();this.removeUISourceCodes([...t])}updateScriptViewToolbarItems(){const e=this.visibleView();e instanceof t.View.SimpleView&&e.toolbarItems().then((e=>{this.scriptViewToolbar.removeToolbarItems();for(const e of Ti())this.scriptViewToolbar.appendToolbarItem(e.getOrCreateButton(this));e.map((e=>this.scriptViewToolbar.appendToolbarItem(e)))}))}showSourceLocation(e,t,i,o){const n=this.currentSourceFrame();n&&this.historyManager.updateCurrentState(n.uiSourceCode(),n.textEditor.state.selection.main.head),this.editorContainer.showFile(e);const r=this.currentSourceFrame();r&&t&&r.revealPosition(t,!o);const s=this.visibleView();!i&&s&&s.focus()}createSourceView(e){let t;const o=e.contentType();return o===i.ResourceType.resourceTypes.Image?t=new m.ImageView.ImageView(e.mimeType(),e):o===i.ResourceType.resourceTypes.Font?t=new m.FontView.FontView(e.mimeType(),e):e.name()===Li?t=new x.HeadersView.HeadersView(e):(t=new Kt(e),this.historyManager.trackSourceFrameCursorJumps(t)),e.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.set(e,t),t}#v(e){return e instanceof m.ImageView.ImageView?"ImageView":e instanceof m.FontView.FontView?"FontView":e instanceof x.HeadersView.HeadersView?"HeadersView":"SourceView"}#C(e){if(e.name()===Li)return"HeadersView";switch(e.contentType()){case i.ResourceType.resourceTypes.Image:return"ImageView";case i.ResourceType.resourceTypes.Font:return"FontView";default:return"SourceView"}}#S(e){const t=e.data,i=this.sourceViewByUISourceCode.get(t);i&&this.#v(i)!==this.#C(t)&&(this.removeUISourceCodes([t]),this.showSourceLocation(t))}getSourceView(e){return this.sourceViewByUISourceCode.get(e)}getOrCreateSourceView(e){return this.sourceViewByUISourceCode.get(e)||this.createSourceView(e)}recycleUISourceCodeFrame(e,t){e.uiSourceCode().removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.delete(e.uiSourceCode()),e.setUISourceCode(t),this.sourceViewByUISourceCode.set(t,e),t.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}viewForFile(e){return this.getOrCreateSourceView(e)}removeSourceFrame(e){const t=this.sourceViewByUISourceCode.get(e);this.sourceViewByUISourceCode.delete(e),t&&t instanceof Kt&&t.dispose(),e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}editorClosed(e){const t=e.data;this.historyManager.removeHistoryForSourceCode(t);let i=!1;this.editorContainer.currentFile()||(i=!0),this.removeToolbarChangedListener(),this.updateScriptViewToolbarItems(),this.searchableViewInternal.resetSearch();const o={uiSourceCode:t,wasSelected:i};this.dispatchEventToListeners("EditorClosed",o)}editorSelected(e){const t=e.data.previousView instanceof Kt?e.data.previousView:null;t&&t.setSearchableView(null);const i=e.data.currentView instanceof Kt?e.data.currentView:null;i&&i.setSearchableView(this.searchableViewInternal),this.searchableViewInternal.setReplaceable(Boolean(i?.canEditSource())),this.searchableViewInternal.refreshSearch(),this.updateToolbarChangedListener(),this.updateScriptViewToolbarItems();const o=this.editorContainer.currentFile();o&&this.dispatchEventToListeners("EditorSelected",o)}removeToolbarChangedListener(){this.toolbarChangedListener&&i.EventTarget.removeEventListeners([this.toolbarChangedListener]),this.toolbarChangedListener=null}updateToolbarChangedListener(){this.removeToolbarChangedListener();const e=this.currentSourceFrame();e&&(this.toolbarChangedListener=e.addEventListener("ToolbarItemsChanged",this.updateScriptViewToolbarItems,this))}onSearchCanceled(){this.searchView&&this.searchView.onSearchCanceled(),delete this.searchView,delete this.searchConfig}performSearch(e,t,i){const o=this.currentSourceFrame();o&&(this.searchView=o,this.searchConfig=e,this.searchView.performSearch(this.searchConfig,t,i))}jumpToNextSearchResult(){this.searchView&&(this.searchConfig&&this.searchView!==this.currentSourceFrame()?this.performSearch(this.searchConfig,!0):this.searchView.jumpToNextSearchResult())}jumpToPreviousSearchResult(){if(this.searchView)return this.searchConfig&&this.searchView!==this.currentSourceFrame()?(this.performSearch(this.searchConfig,!0),void(this.searchView&&this.searchView.jumpToLastSearchResult())):void this.searchView.jumpToPreviousSearchResult()}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!0}replaceSelectionWith(e,t){const i=this.currentSourceFrame();i?i.replaceSelectionWith(e,t):console.assert(Boolean(i))}replaceAllWith(e,t){const i=this.currentSourceFrame();i?i.replaceAllWith(e,t):console.assert(Boolean(i))}showOutlineQuickOpen(){L.QuickOpen.QuickOpenImpl.show("@")}showGoToLineQuickOpen(){this.editorContainer.currentFile()&&L.QuickOpen.QuickOpenImpl.show(":")}save(){this.saveSourceFrame(this.currentSourceFrame())}saveAll(){this.editorContainer.fileViews().forEach(this.saveSourceFrame.bind(this))}saveSourceFrame(e){if(!(e instanceof Kt))return;e.commitEditing()}toggleBreakpointsActiveState(e){this.editorContainer.view.element.classList.toggle("breakpoints-deactivated",!e)}}const xi=[];function ki(e){xi.push(e)}function Ti(){return xi.map((e=>e()))}class Ei{static nextFile(e){function t(e){const t=e.lastIndexOf(".");return e.substr(0,-1!==t?t:e.length).toLowerCase()}const o=[],n=e.parentURL(),r=e.name(),s=t(r);for(const i of e.project().uiSourceCodes())n===i.parentURL()&&t(i.name())===s&&o.push(i.name());o.sort(l.StringUtilities.naturalOrderComparator);const a=l.NumberUtilities.mod(o.indexOf(r)+1,o.length),c=i.ParsedURL.ParsedURL.concatenate(n?i.ParsedURL.ParsedURL.concatenate(n,"/"):"",o[a]),d=e.project().uiSourceCodeForURL(c);return d!==e?d:null}handleAction(e,t){const i=e.flavor(yi);if(!i)return!1;const o=i.currentUISourceCode();if(!o)return!1;const n=Ei.nextFile(o);return!!n&&(i.showSourceLocation(n),!0)}}const Li=".headers";var Mi=Object.freeze({__proto__:null,SourcesView:yi,registerEditorAction:ki,getRegisteredEditorActions:Ti,SwitchFileActionDelegate:Ei,ActionDelegate:class{handleAction(e,t){const i=e.flavor(yi);if(!i)return!1;switch(t){case"sources.close-all":return i.editorContainer.closeAllFiles(),!0;case"sources.jump-to-previous-location":return i.onJumpToPreviousLocation(),!0;case"sources.jump-to-next-location":return i.onJumpToNextLocation(),!0;case"sources.next-editor-tab":return i.editorContainer.selectNextTab(),!0;case"sources.previous-editor-tab":return i.editorContainer.selectPrevTab(),!0;case"sources.close-editor-tab":return i.onCloseEditorTab();case"sources.go-to-line":return i.showGoToLineQuickOpen(),!0;case"sources.go-to-member":return i.showOutlineQuickOpen(),!0;case"sources.save":return i.save(),!0;case"sources.save-all":return i.saveAll(),!0}return!1}}});const Pi=new CSSStyleSheet;Pi.replaceSync(".thread-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.thread-item + .thread-item{border-top:1px solid var(--sys-color-divider)}.thread-item:hover{background-color:var(--sys-color-state-hover-on-subtle)}.thread-item:focus-visible{background-color:var(--sys-color-tonal-container)}.thread-item-title,\n.thread-item-paused-state{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.thread-item-paused-state{color:var(--sys-color-state-disabled);margin-left:auto;padding:0 10px}.selected-thread-icon{display:none;position:absolute;top:3px;left:4px}.thread-item.selected .selected-thread-icon{display:block}@media (forced-colors: active){.thread-item:hover,\n .thread-item:focus-visible{forced-color-adjust:none;background-color:Highlight}.thread-item:hover > div,\n .thread-item:focus-visible > div{color:HighlightText}}\n/*# sourceURL=threadsSidebarPane.css */\n");const Fi={paused:"paused"},Di=e.i18n.registerUIStrings("panels/sources/ThreadsSidebarPane.ts",Fi),Ni=e.i18n.getLocalizedString.bind(void 0,Di);class Ai extends t.Widget.VBox{items;list;selectedModel;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.threads")}`),this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport);const e=t.Context.Context.instance().flavor(o.Target.Target);this.selectedModel=null!==e?e.model(o.DebuggerModel.DebuggerModel):null,this.contentElement.appendChild(this.list.element),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.targetFlavorChanged,this),o.TargetManager.TargetManager.instance().observeModels(o.DebuggerModel.DebuggerModel,this)}static shouldBeShown(){return o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel).length>=2}createElementForItem(e){const i=document.createElement("div");i.classList.add("thread-item");const n=i.createChild("div","thread-item-title"),s=i.createChild("div","thread-item-paused-state"),a=new r.Icon.Icon;a.data={iconName:"large-arrow-right-filled",color:"var(--icon-arrow-main-thread)",width:"14px",height:"14px"},a.classList.add("selected-thread-icon"),i.appendChild(a),i.tabIndex=-1,self.onInvokeElement(i,(i=>{t.Context.Context.instance().setFlavor(o.Target.Target,e.target()),i.consume(!0)}));const c=t.Context.Context.instance().flavor(o.Target.Target)===e.target();function l(){const t=e.runtimeModel().defaultExecutionContext();n.textContent=t&&t.label()?t.label():e.target().name()}function d(){s.textContent=e.isPaused()?Ni(Fi.paused):""}return i.classList.toggle("selected",c),t.ARIAUtils.setSelected(i,c),e.addEventListener(o.DebuggerModel.Events.DebuggerPaused,d),e.addEventListener(o.DebuggerModel.Events.DebuggerResumed,d),e.runtimeModel().addEventListener(o.RuntimeModel.Events.ExecutionContextChanged,l),o.TargetManager.TargetManager.instance().addEventListener("NameChanged",(function(t){t.data===e.target()&&l()})),d(),l(),i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1);const n=o;n&&(this.setDefaultFocusedElement(n),n.tabIndex=0,this.hasFocus()&&n.focus())}updateSelectedItemARIA(e,t){return!1}modelAdded(e){this.items.insert(this.items.length,e);t.Context.Context.instance().flavor(o.Target.Target)===e.target()&&this.list.selectItem(e)}modelRemoved(e){this.items.remove(this.items.indexOf(e))}targetFlavorChanged({data:e}){const t=this.hasFocus(),i=e.model(o.DebuggerModel.DebuggerModel);this.list.selectItem(i),i&&this.list.refreshItem(i),null!==this.selectedModel&&this.list.refreshItem(this.selectedModel),this.selectedModel=i,t&&this.focus()}wasShown(){super.wasShown(),this.registerCSSFiles([Pi])}}var Ui=Object.freeze({__proto__:null,ThreadsSidebarPane:Ai});const Ri={dropWorkspaceFolderHere:"Drop workspace folder here",moreOptions:"More options",showNavigator:"Show navigator",hideNavigator:"Hide navigator",navigatorShown:"Navigator sidebar shown",navigatorHidden:"Navigator sidebar hidden",debuggerShown:"Debugger sidebar shown",debuggerHidden:"Debugger sidebar hidden",showDebugger:"Show debugger",hideDebugger:"Hide debugger",groupByFolder:"Group by folder",groupByAuthored:"Group by Authored/Deployed",hideIgnoreListed:"Hide ignore-listed sources",resumeWithAllPausesBlockedForMs:"Resume with all pauses blocked for 500 ms",terminateCurrentJavascriptCall:"Terminate current JavaScript call",pauseOnCaughtExceptions:"Pause on caught exceptions",revealInSidebar:"Reveal in navigator sidebar",continueToHere:"Continue to here",storeAsGlobalVariable:"Store as global variable",copyS:"Copy {PH1}",copyStringContents:"Copy string contents",copyStringAsJSLiteral:"Copy string as JavaScript literal",copyStringAsJSONLiteral:"Copy string as JSON literal",showFunctionDefinition:"Show function definition",openInSourcesPanel:"Open in Sources panel"},Bi=e.i18n.registerUIStrings("panels/sources/SourcesPanel.ts",Ri),ji=e.i18n.getLocalizedString.bind(void 0,Bi),Vi=new Set(["number","boolean","bigint","undefined"]);let Wi;class Oi extends t.Panel.Panel{workspace;togglePauseAction;stepOverAction;stepIntoAction;stepOutAction;stepAction;toggleBreakpointsActiveAction;debugToolbar;debugToolbarDrawer;debuggerPausedMessage;splitWidget;editorView;navigatorTabbedLocation;sourcesViewInternal;toggleNavigatorSidebarButton;toggleDebuggerSidebarButton;threadsSidebarPane;watchSidebarPane;callstackPane;liveLocationPool;lastModificationTime;pausedInternal;switchToPausedTargetTimeout;ignoreExecutionLineEvents;executionLineLocation;pauseOnExceptionButton;sidebarPaneStack;tabbedLocationHeader;extensionSidebarPanesContainer;sidebarPaneView;constructor(){super("sources"),C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&new t.DropTarget.DropTarget(this.element,[t.DropTarget.Type.Folder],ji(Ri.dropWorkspaceFolderHere),this.handleDrop.bind(this)),this.workspace=f.Workspace.WorkspaceImpl.instance(),this.togglePauseAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-pause"),this.stepOverAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-over"),this.stepIntoAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-into"),this.stepOutAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-out"),this.stepAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step"),this.toggleBreakpointsActiveAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-breakpoints-active"),this.debugToolbar=this.createDebugToolbar(),this.debugToolbarDrawer=this.createDebugToolbarDrawer(),this.debuggerPausedMessage=new Je;this.splitWidget=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-split-view-state",225),this.splitWidget.enableShowModeSaving(),this.splitWidget.show(this.element);this.editorView=new t.SplitWidget.SplitWidget(!0,!1,"sources-panel-navigator-split-view-state",225),this.editorView.enableShowModeSaving(),this.splitWidget.setMainWidget(this.editorView),this.navigatorTabbedLocation=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"navigator-view",!0,!0);const e=this.navigatorTabbedLocation.tabbedPane();e.setMinimumSize(100,25),e.element.classList.add("navigator-tabbed-pane"),e.headerElement().setAttribute("jslog",`${a.toolbar("navigator")}`);const n=new t.Toolbar.ToolbarMenuButton(this.populateNavigatorMenu.bind(this),!0,"more-options");if(n.setTitle(ji(Ri.moreOptions)),e.rightToolbar().appendToolbarItem(n),e.addEventListener(t.TabbedPane.Events.TabSelected,(({data:{tabId:e}})=>c.userMetrics.sourcesSidebarTabShown(e))),t.ViewManager.ViewManager.instance().hasViewsForLocation("run-view-sidebar")){const i=new t.SplitWidget.SplitWidget(!1,!0,"source-panel-navigator-sidebar-split-view-state");i.setMainWidget(e);const o=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"run-view-sidebar").tabbedPane();i.setSidebarWidget(o),i.installResizer(o.headerElement()),this.editorView.setSidebarWidget(i)}else this.editorView.setSidebarWidget(e);this.sourcesViewInternal=new yi,this.sourcesViewInternal.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.toggleNavigatorSidebarButton=this.editorView.createShowHideSidebarButton(ji(Ri.showNavigator),ji(Ri.hideNavigator),ji(Ri.navigatorShown),ji(Ri.navigatorHidden),"navigator"),this.toggleDebuggerSidebarButton=this.splitWidget.createShowHideSidebarButton(ji(Ri.showDebugger),ji(Ri.hideDebugger),ji(Ri.debuggerShown),ji(Ri.debuggerHidden),"debugger"),this.editorView.setMainWidget(this.sourcesViewInternal),this.threadsSidebarPane=null,this.watchSidebarPane=t.ViewManager.ViewManager.instance().view("sources.watch"),this.callstackPane=Z.instance(),i.Settings.Settings.instance().moduleSetting("sidebar-position").addChangeListener(this.updateSidebarPosition.bind(this)),this.updateSidebarPosition(),this.updateDebuggerButtonsAndStatus(),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.setTarget(t.Context.Context.instance().flavor(o.Target.Target)),i.Settings.Settings.instance().moduleSetting("breakpoints-active").addChangeListener(this.breakpointsActiveStateChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.onCurrentTargetChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerWasEnabled,this.debuggerWasEnabled,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerPaused,this.debuggerPaused,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerResumed,(e=>this.debuggerResumed(e.data))),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.GlobalObjectCleared,(e=>this.debuggerResumed(e.data))),k.ExtensionServer.ExtensionServer.instance().addEventListener("SidebarPaneAdded",this.extensionSidebarPaneAdded,this),o.TargetManager.TargetManager.instance().observeTargets(this),this.lastModificationTime=-1/0}static instance(e={forceNew:null}){const{forceNew:t}=e;return Wi&&!t||(Wi=new Oi),Wi}static updateResizerAndSidebarButtons(e){e.sourcesViewInternal.leftToolbar().removeToolbarItems(),e.sourcesViewInternal.rightToolbar().removeToolbarItems(),e.sourcesViewInternal.bottomToolbar().removeToolbarItems();const i=t.Context.Context.instance().flavor(qi)&&!t.InspectorView.InspectorView.instance().isDrawerMinimized();e.splitWidget.isVertical()||i?e.splitWidget.uninstallResizer(e.sourcesViewInternal.toolbarContainerElement()):e.splitWidget.installResizer(e.sourcesViewInternal.toolbarContainerElement()),i||(e.sourcesViewInternal.leftToolbar().appendToolbarItem(e.toggleNavigatorSidebarButton),e.splitWidget.isVertical()?e.sourcesViewInternal.rightToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton):e.sourcesViewInternal.bottomToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton))}targetAdded(e){this.showThreadsIfNeeded()}targetRemoved(e){}showThreadsIfNeeded(){Ai.shouldBeShown()&&!this.threadsSidebarPane&&(this.threadsSidebarPane=t.ViewManager.ViewManager.instance().view("sources.threads"),this.sidebarPaneStack&&this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane,this.splitWidget.isVertical()?this.watchSidebarPane:this.callstackPane))}setTarget(e){if(!e)return;const t=e.model(o.DebuggerModel.DebuggerModel);t&&(t.isPaused()?this.showDebuggerPausedDetails(t.debuggerPausedDetails()):(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0)))}onCurrentTargetChanged({data:e}){this.setTarget(e)}paused(){return this.pausedInternal||!1}wasShown(){t.Context.Context.instance().setFlavor(Oi,this),this.registerCSSFiles([wt]),super.wasShown(),t.Context.Context.instance().flavor(qi)&&(t.InspectorView.InspectorView.instance().setDrawerMinimized(!0),Oi.updateResizerAndSidebarButtons(this)),this.editorView.setMainWidget(this.sourcesViewInternal)}willHide(){super.willHide(),t.Context.Context.instance().setFlavor(Oi,null);const e=t.Context.Context.instance().flavor(qi);e&&(e.showViewInWrapper(),t.InspectorView.InspectorView.instance().setDrawerMinimized(!1),Oi.updateResizerAndSidebarButtons(this))}resolveLocation(e){return"sources.sidebar-top"===e||"sources.sidebar-bottom"===e||"sources.sidebar-tabs"===e?this.sidebarPaneStack||null:this.navigatorTabbedLocation}ensureSourcesViewVisible(){return!!t.Context.Context.instance().flavor(qi)||!!t.InspectorView.InspectorView.instance().canSelectPanel("sources")&&(t.ViewManager.ViewManager.instance().showView("sources"),!0)}onResize(){"auto"===i.Settings.Settings.instance().moduleSetting("sidebar-position").get()&&this.element.window().requestAnimationFrame(this.updateSidebarPosition.bind(this))}searchableView(){return this.sourcesViewInternal.searchableView()}toggleNavigatorSidebar(){this.editorView.toggleSidebar()}toggleDebuggerSidebar(){this.splitWidget.toggleSidebar()}debuggerPaused(e){const n=e.data,r=n.debuggerPausedDetails();!this.pausedInternal&&i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&this.setAsCurrentPanel(),t.Context.Context.instance().flavor(o.Target.Target)===n.target()?this.showDebuggerPausedDetails(r):this.pausedInternal||t.Context.Context.instance().setFlavor(o.Target.Target,n.target())}debugInfoAttached(e){const{debuggerModel:i}=e.data;if(!i.isPaused())return;const n=i.debuggerPausedDetails();n&&t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.showDebuggerPausedDetails(n)}showDebuggerPausedDetails(e){this.pausedInternal=!0,this.updateDebuggerButtonsAndStatus(),t.Context.Context.instance().setFlavor(o.DebuggerModel.DebuggerPausedDetails,e),this.toggleDebuggerSidebarButton.setEnabled(!1),this.revealDebuggerSidebar(),window.focus(),c.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront()}debuggerResumed(e){const i=e.target();t.Context.Context.instance().flavor(o.Target.Target)===i&&(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0),this.switchToPausedTargetTimeout=window.setTimeout(this.switchToPausedTarget.bind(this,e),500))}debuggerWasEnabled(e){const i=e.data;t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.updateDebuggerButtonsAndStatus()}get visibleView(){return this.sourcesViewInternal.visibleView()}showUISourceCode(e,i,o){if(o){if(!this.isShowing()&&!t.Context.Context.instance().flavor(qi))return}else this.showEditor();this.sourcesViewInternal.showSourceLocation(e,i,o)}showEditor(){t.Context.Context.instance().flavor(qi)||this.setAsCurrentPanel()}showUILocation(e,t){const{uiSourceCode:i,lineNumber:o,columnNumber:n}=e;this.showUISourceCode(i,{lineNumber:o,columnNumber:n},t)}async revealInNavigator(e,i){const o=t.ViewManager.ViewManager.instance();for(const t of o.viewsForLocation("navigator-view")){const o=await t.widget();if(o instanceof ut&&o.acceptProject(e.project())){o.revealUISourceCode(e,!0),this.navigatorTabbedLocation.tabbedPane().selectTab(t.viewId(),!0),i||(this.editorView.showBoth(!0),o.focus());break}}}addExperimentMenuItem(e,t,o){e.appendCheckboxItem(o,(function(){const e=C.Runtime.experiments.isEnabled(t);C.Runtime.experiments.setEnabled(t,!e),c.userMetrics.experimentChanged(t,e);const o=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");o.set(o.get())}),{checked:C.Runtime.experiments.isEnabled(t),additionalElement:r.Icon.create("experiment"),jslogContext:l.StringUtilities.toKebabCase(t)})}populateNavigatorMenu(e){const t=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");e.appendItemsAtLocation("navigatorMenu"),e.viewSection().appendCheckboxItem(ji(Ri.groupByFolder),(()=>t.set(!t.get())),{checked:t.get(),jslogContext:t.name}),this.addExperimentMenuItem(e.viewSection(),"authored-deployed-grouping",ji(Ri.groupByAuthored)),this.addExperimentMenuItem(e.viewSection(),"just-my-code",ji(Ri.hideIgnoreListed))}setIgnoreExecutionLineEvents(e){this.ignoreExecutionLineEvents=e}updateLastModificationTime(){this.lastModificationTime=window.performance.now()}async executionLineChanged(e){const t=await e.uiLocation();e.isDisposed()||t&&(window.performance.now()-this.lastModificationTime<Hi||this.sourcesViewInternal.showSourceLocation(t.uiSourceCode,t,void 0,!0))}lastModificationTimeoutPassedForTest(){Hi=Number.MIN_VALUE}updateLastModificationTimeForTest(){Hi=Number.MAX_VALUE}async callFrameChanged(){const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);e&&(this.executionLineLocation&&this.executionLineLocation.dispose(),this.executionLineLocation=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),this.executionLineChanged.bind(this),this.liveLocationPool))}async updateDebuggerButtonsAndStatus(){const e=t.Context.Context.instance().flavor(o.Target.Target),i=e?e.model(o.DebuggerModel.DebuggerModel):null;i?this.pausedInternal?(this.togglePauseAction.setToggled(!0),this.togglePauseAction.setEnabled(!0),this.stepOverAction.setEnabled(!0),this.stepIntoAction.setEnabled(!0),this.stepOutAction.setEnabled(!0),this.stepAction.setEnabled(!0)):(this.togglePauseAction.setToggled(!1),this.togglePauseAction.setEnabled(!i.isPausing()),this.stepOverAction.setEnabled(!1),this.stepIntoAction.setEnabled(!1),this.stepOutAction.setEnabled(!1),this.stepAction.setEnabled(!1)):(this.togglePauseAction.setEnabled(!1),this.stepOverAction.setEnabled(!1),this.stepIntoAction.setEnabled(!1),this.stepOutAction.setEnabled(!1),this.stepAction.setEnabled(!1));const n=i?i.debuggerPausedDetails():null;await this.debuggerPausedMessage.render(n,u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),w.BreakpointManager.BreakpointManager.instance()),n&&this.updateDebuggerButtonsAndStatusForTest()}updateDebuggerButtonsAndStatusForTest(){}clearInterface(){this.updateDebuggerButtonsAndStatus(),t.Context.Context.instance().setFlavor(o.DebuggerModel.DebuggerPausedDetails,null),this.switchToPausedTargetTimeout&&clearTimeout(this.switchToPausedTargetTimeout),this.liveLocationPool.disposeAll()}switchToPausedTarget(e){if(delete this.switchToPausedTargetTimeout,!this.pausedInternal&&!e.isPaused())for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel))if(e.isPaused()){t.Context.Context.instance().setFlavor(o.Target.Target,e.target());break}}runSnippet(){const e=this.sourcesViewInternal.currentUISourceCode();e&&T.ScriptSnippetFileSystem.evaluateScriptSnippet(e)}editorSelected(e){const t=e.data;this.editorView.mainWidget()&&i.Settings.Settings.instance().moduleSetting("auto-reveal-in-navigator").get()&&this.revealInNavigator(t,!0)}togglePause(){const e=t.Context.Context.instance().flavor(o.Target.Target);if(!e)return!0;const i=e.model(o.DebuggerModel.DebuggerModel);return!i||(this.pausedInternal?(this.pausedInternal=!1,i.resume()):i.pause(),this.clearInterface(),!0)}prepareToResume(){if(!this.pausedInternal)return null;this.pausedInternal=!1,this.clearInterface();const e=t.Context.Context.instance().flavor(o.Target.Target);return e?e.model(o.DebuggerModel.DebuggerModel):null}longResume(){const e=this.prepareToResume();e&&(e.skipAllPausesUntilReloadOrTimeout(500),e.resume())}terminateExecution(){const e=this.prepareToResume();e&&(e.runtimeModel().terminateExecution(),e.resume())}stepOver(){const e=this.prepareToResume();return e&&e.stepOver(),!0}stepInto(){const e=this.prepareToResume();return e&&e.stepInto(),!0}stepIntoAsync(){const e=this.prepareToResume();return e&&e.scheduleStepIntoAsync(),!0}stepOut(){const e=this.prepareToResume();return e&&e.stepOut(),!0}async continueToLocation(e){const i=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);if(!i)return;const n=(await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().uiLocationToRawLocations(e.uiSourceCode,e.lineNumber,0)).find((e=>e.debuggerModel===i.debuggerModel));n&&this.prepareToResume()&&n.continueToLocation()}toggleBreakpointsActive(){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!i.Settings.Settings.instance().moduleSetting("breakpoints-active").get())}breakpointsActiveStateChanged(){const e=i.Settings.Settings.instance().moduleSetting("breakpoints-active").get();this.toggleBreakpointsActiveAction.setToggled(!e),this.sourcesViewInternal.toggleBreakpointsActiveState(e)}createDebugToolbar(){const e=new t.Toolbar.Toolbar("scripts-debug-toolbar");e.element.setAttribute("jslog",`${a.toolbar("debug")}`);const i=new t.Toolbar.ToolbarButton(ji(Ri.resumeWithAllPausesBlockedForMs),"play");i.addEventListener("Click",this.longResume,this);const o=new t.Toolbar.ToolbarButton(ji(Ri.terminateCurrentJavascriptCall),"stop");return o.addEventListener("Click",this.terminateExecution,this),e.appendToolbarItem(t.Toolbar.Toolbar.createLongPressActionButton(this.togglePauseAction,[o,i],[])),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOverAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepIntoAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOutAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepAction)),e.appendSeparator(),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.toggleBreakpointsActiveAction)),e}createDebugToolbarDrawer(){const e=document.createElement("div");e.classList.add("scripts-debug-toolbar-drawer");const o=ji(Ri.pauseOnCaughtExceptions),n=i.Settings.Settings.instance().moduleSetting("pause-on-caught-exception");return e.appendChild(t.SettingsUI.createSettingCheckbox(o,n,!0)),e}appendApplicableItems(e,t,i){i instanceof f.UISourceCode.UISourceCode?this.appendUISourceCodeItems(e,t,i):i instanceof Kt?this.appendUISourceCodeFrameItems(t,i):i instanceof f.UISourceCode.UILocation?this.appendUILocationItems(t,i):i instanceof o.RemoteObject.RemoteObject?this.appendRemoteObjectItems(t,i):this.appendNetworkRequestItems(t,i)}appendUISourceCodeItems(e,t,i){if(!e.target)return;const o=e.target;i.project().isServiceProject()||o.isSelfOrDescendant(this.navigatorTabbedLocation.widget().element)||C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||t.revealSection().appendItem(ji(Ri.revealInSidebar),this.revealInNavigator.bind(this,i),{jslogContext:"sources.reveal-in-navigator-sidebar"}),i.contentType().hasScripts()&&u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(i).every((e=>e.isJavaScript()))&&this.callstackPane.appendIgnoreListURLContextMenuItems(t,i)}appendUISourceCodeFrameItems(e,t){t.uiSourceCode().contentType().isFromSourceMap()||t.textEditor.state.selection.main.empty||e.debugSection().appendAction("debugger.evaluate-selection")}appendUILocationItems(e,i){const n=i.uiSourceCode;if(!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(n).every((e=>e.isJavaScript())))return;if(n.contentType().hasScripts()){const r=t.Context.Context.instance().flavor(o.Target.Target),s=r?r.model(o.DebuggerModel.DebuggerModel):null;s&&s.isPaused()&&e.debugSection().appendItem(ji(Ri.continueToHere),this.continueToLocation.bind(this,i),{jslogContext:"continue-to-here"}),this.callstackPane.appendIgnoreListURLContextMenuItems(e,n)}}appendRemoteObjectItems(e,n){const r=i.Settings.Settings.instance().moduleSetting("text-editor-indent").get(),s=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);const a="wasm"===n.type?n.subtype:"node"===n.subtype?"outerHTML":n.type;e.debugSection().appendItem(ji(Ri.storeAsGlobalVariable),(()=>s?.target().model(o.ConsoleModel.ConsoleModel)?.saveToTempVariable(s,n)),{jslogContext:"store-as-global-variable"});const d=e.clipboardSection(),u=c.InspectorFrontendHost.InspectorFrontendHostInstance;if("string"===n.type)d.appendItem(ji(Ri.copyStringContents),(()=>{u.copyText(n.value)}),{jslogContext:"copy-string-contents"}),d.appendItem(ji(Ri.copyStringAsJSLiteral),(()=>{u.copyText(l.StringUtilities.formatAsJSLiteral(n.value))}),{jslogContext:"copy-string-as-js-literal"}),d.appendItem(ji(Ri.copyStringAsJSONLiteral),(()=>{u.copyText(JSON.stringify(n.value))}),{jslogContext:"copy-string-as-json-literal"});else if(Vi.has(n.type))d.appendItem(ji(Ri.copyS,{PH1:String(a)}),(()=>{u.copyText(n.description)}),{jslogContext:"copy-primitive"});else if("object"===n.type){const e=async()=>{const e=await n.callFunctionJSON(h,[{value:{subtype:n.subtype,indent:r}}]);u.copyText(e)};d.appendItem(ji(Ri.copyS,{PH1:String(a)}),e,{jslogContext:"copy-object"})}else"function"===n.type&&e.debugSection().appendItem(ji(Ri.showFunctionDefinition),this.showFunctionDefinition.bind(this,n),{jslogContext:"show-function-definition"});function h(e){const t=e.subtype,i=e.indent;if("map"!==t){if("set"!==t){if("node"===t)return this instanceof Element?this.outerHTML:void 0;if(t&&void 0===this)return String(t);try{return JSON.stringify(this,null,i)}catch(e){return String(this)}}else if(this instanceof Set){const e=Array.from(this.values());return`new Set(${0===e.length?"":JSON.stringify(e,null,i)})`}}else if(this instanceof Map){const e=Array.from(this.entries());return`new Map(${0===e.length?"":JSON.stringify(e,null,i)})`}}}appendNetworkRequestItems(e,t){const i=this.workspace.uiSourceCodeForURL(t.url());if(!i)return;const o=ji(Ri.openInSourcesPanel),n=this.showUILocation.bind(this,i.uiLocation(0,0));e.revealSection().appendItem(o,n,{jslogContext:"reveal-in-sources"})}showFunctionDefinition(e){o.RemoteObject.RemoteFunction.objectAsFunction(e).targetFunction().then((e=>e.debuggerModel().functionDetailsPromise(e).then(this.didGetFunctionDetails.bind(this))))}async didGetFunctionDetails(e){if(!e||!e.location)return;const t=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e.location);t&&this.showUILocation(t)}revealNavigatorSidebar(){this.setAsCurrentPanel(),this.editorView.showBoth(!0)}revealDebuggerSidebar(){i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&(this.setAsCurrentPanel(),this.splitWidget.showBoth(!0))}updateSidebarPosition(){let e;const o=i.Settings.Settings.instance().moduleSetting("sidebar-position").get();if(e="right"!==o&&("bottom"===o||t.InspectorView.InspectorView.instance().element.offsetWidth<680),this.sidebarPaneView&&e===!this.splitWidget.isVertical())return;if(this.sidebarPaneView&&this.sidebarPaneView.shouldHideOnDetach())return;this.sidebarPaneView&&this.sidebarPaneView.detach(),this.splitWidget.setVertical(!e),this.splitWidget.element.classList.toggle("sources-split-view-vertical",e),Oi.updateResizerAndSidebarButtons(this);const n=new t.Widget.VBox;n.element.appendChild(this.debugToolbar.element),n.element.appendChild(this.debugToolbarDrawer),n.setMinimumAndPreferredSizes(_i,25,_i,100),this.sidebarPaneStack=t.ViewManager.ViewManager.instance().createStackLocation(this.revealDebuggerSidebar.bind(this),void 0,"debug"),this.sidebarPaneStack.widget().element.classList.add("overflow-auto"),this.sidebarPaneStack.widget().show(n.element),this.sidebarPaneStack.widget().element.appendChild(this.debuggerPausedMessage.element()),this.sidebarPaneStack.appendApplicableItems("sources.sidebar-top"),this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane);const r=t.ViewManager.ViewManager.instance().view("sources.js-breakpoints"),s=t.ViewManager.ViewManager.instance().view("sources.scope-chain");if(this.tabbedLocationHeader&&(this.splitWidget.uninstallResizer(this.tabbedLocationHeader),this.tabbedLocationHeader=null),e){const e=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-debugger-sidebar-split-view-state",.5);e.setMainWidget(n),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(this.callstackPane);const i=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealDebuggerSidebar.bind(this));e.setSidebarWidget(i.tabbedPane()),this.tabbedLocationHeader=i.tabbedPane().headerElement(),this.splitWidget.installResizer(this.tabbedLocationHeader),this.splitWidget.installResizer(this.debugToolbar.gripElementForResize()),i.appendView(s),i.appendView(this.watchSidebarPane),i.appendApplicableItems("sources.sidebar-tabs"),this.extensionSidebarPanesContainer=i,this.sidebarPaneView=e}else this.sidebarPaneStack.appendView(this.watchSidebarPane),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(s),this.sidebarPaneStack.showView(this.callstackPane),this.extensionSidebarPanesContainer=this.sidebarPaneStack,this.sidebarPaneView=n,this.splitWidget.uninstallResizer(this.debugToolbar.gripElementForResize());this.sidebarPaneStack.appendApplicableItems("sources.sidebar-bottom");const a=k.ExtensionServer.ExtensionServer.instance().sidebarPanes();for(let e=0;e<a.length;++e)this.addExtensionSidebarPane(a[e]);this.splitWidget.setSidebarWidget(this.sidebarPaneView)}setAsCurrentPanel(){return t.ViewManager.ViewManager.instance().showView("sources")}extensionSidebarPaneAdded(e){this.addExtensionSidebarPane(e.data)}addExtensionSidebarPane(e){e.panelName()===this.name&&this.extensionSidebarPanesContainer.appendView(e)}sourcesView(){return this.sourcesViewInternal}handleDrop(e){const i=e.items;if(!i.length)return;const o=i[0].webkitGetAsEntry();o&&o.isDirectory&&(c.InspectorFrontendHost.InspectorFrontendHostInstance.upgradeDraggedFileSystemPermissions(o.filesystem),c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceDropFolder),t.ViewManager.ViewManager.instance().showView("navigator-files"))}}let Hi=200;const _i=215;class zi{static#w;static instance(e={forceNew:!1}){return zi.#w&&!e.forceNew||(zi.#w=new zi),zi.#w}async reveal(e,t){const{uiSourceCode:i,range:{start:o,end:n}}=e;Oi.instance().showUISourceCode(i,{from:o,to:n},t)}}class qi extends t.Widget.VBox{view;constructor(){super(),this.element.classList.add("sources-view-wrapper"),this.element.setAttribute("jslog",`${a.panel("sources.quick").track({resize:!0})}`),this.view=Oi.instance().sourcesView()}wasShown(){t.Context.Context.instance().setFlavor(qi,this),super.wasShown(),Oi.instance().isShowing()?t.InspectorView.InspectorView.instance().setDrawerMinimized(!0):this.showViewInWrapper(),Oi.updateResizerAndSidebarButtons(Oi.instance())}willHide(){t.InspectorView.InspectorView.instance().setDrawerMinimized(!1),queueMicrotask((()=>{Oi.updateResizerAndSidebarButtons(Oi.instance())})),super.willHide(),t.Context.Context.instance().setFlavor(qi,null)}showViewInWrapper(){this.view.show(this.element)}}var $i=Object.freeze({__proto__:null,SourcesPanel:Oi,get lastModificationTimeout(){return Hi},minToolbarWidth:_i,UILocationRevealer:class{async reveal(e,t){Oi.instance().showUILocation(e,t)}},UILocationRangeRevealer:zi,DebuggerLocationRevealer:class{async reveal(e,t){const i=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);i&&Oi.instance().showUILocation(i,t)}},UISourceCodeRevealer:class{async reveal(e,t){Oi.instance().showUISourceCode(e,void 0,t)}},DebuggerPausedDetailsRevealer:class{async reveal(e){if(i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get())return Oi.instance().setAsCurrentPanel()}},RevealingActionDelegate:class{handleAction(e,o){const n=Oi.instance();if(!n.ensureSourcesViewVisible())return!1;if("debugger.toggle-pause"===o){return e.flavor(t.ShortcutRegistry.ForwardedShortcut)&&!i.Settings.Settings.instance().moduleSetting("disable-paused-state-overlay").get()||n.togglePause(),!0}return!1}},ActionDelegate:class{handleAction(e,t){const i=Oi.instance();switch(t){case"debugger.step-over":return i.stepOver(),!0;case"debugger.step-into":return i.stepIntoAsync(),!0;case"debugger.step":return i.stepInto(),!0;case"debugger.step-out":return i.stepOut(),!0;case"debugger.run-snippet":return i.runSnippet(),!0;case"debugger.toggle-breakpoints-active":return i.toggleBreakpointsActive(),!0;case"debugger.evaluate-selection":{const t=e.flavor(Kt);if(t){const{state:i}=t.textEditor;let n=i.sliceDoc(i.selection.main.from,i.selection.main.to);const r=e.flavor(o.RuntimeModel.ExecutionContext),s=r?.target().model(o.ConsoleModel.ConsoleModel);if(r&&s){const e=s.addCommandMessage(r,n);n=y.JavaScriptREPL.JavaScriptREPL.wrapObjectLiteral(n),s.evaluateCommandInConsole(r,e,n,!0)}}return!0}case"sources.reveal-in-navigator-sidebar":{const e=i.sourcesView().currentUISourceCode();return null!==e&&(i.revealInNavigator(e),!0)}case"sources.toggle-navigator-sidebar":return i.toggleNavigatorSidebar(),!0;case"sources.toggle-debugger-sidebar":return i.toggleDebuggerSidebar(),!0}return!1}},QuickSourceView:qi});const{EMPTY_BREAKPOINT_CONDITION:Gi,NEVER_PAUSE_HERE_CONDITION:Ki}=w.BreakpointManager,Ji={thisScriptIsOnTheDebuggersIgnore:"This script is on the debugger's ignore list",removeFromIgnoreList:"Remove from ignore list",configure:"Configure",addBreakpoint:"Add breakpoint",addConditionalBreakpoint:"Add conditional breakpoint…",addLogpoint:"Add logpoint…",neverPauseHere:"Never pause here",removeBreakpoint:"{n, plural, =1 {Remove breakpoint} other {Remove all breakpoints in line}}",editBreakpoint:"Edit breakpoint…",disableBreakpoint:"{n, plural, =1 {Disable breakpoint} other {Disable all breakpoints in line}}",enableBreakpoint:"{n, plural, =1 {Enable breakpoint} other {Enable all breakpoints in line}}",addSourceMap:"Add source map…",addWasmDebugInfo:"Add DWARF debug info…",sourceMapLoaded:"Source map loaded.",associatedFilesAreAvailable:"Associated files are available via file tree or {PH1}.",associatedFilesShouldBeAdded:"Associated files should be added to the file tree. You can debug these resolved source files as regular JavaScript files.",theDebuggerWillSkipStepping:"The debugger will skip stepping through this script, and will not stop on exceptions.",sourceMapSkipped:"Source map skipped for this file.",sourceMapFailed:"Source map failed to load.",debuggingPowerReduced:"DevTools can't show authored sources, but you can debug the deployed code.",reloadForSourceMap:"To enable again, make sure the file isn't on the ignore list and reload.",errorLoading:"Error loading url {PH1}: {PH2}",ignoreScript:"Ignore this file",ignoreContentScripts:"Ignore extension scripts",debugFileNotFound:'Failed to load debug file "{PH1}".',debugInfoNotFound:"Failed to load any debug info for {PH1}."},Xi=e.i18n.registerUIStrings("panels/sources/DebuggerPlugin.ts",Ji),Yi=e.i18n.getLocalizedString.bind(void 0,Xi),Qi=new Map;class Zi extends pe{transformer;editor=void 0;executionLocation=null;controlDown=!1;controlTimeout=void 0;sourceMapInfobar=null;scriptsPanel;breakpointManager;popoverHelper=null;scriptFileForDebuggerModel;breakpoints=[];continueToLocations=null;liveLocationPool;muted;initializedMuted;ignoreListInfobar;refreshBreakpointsTimeout=void 0;activeBreakpointDialog=null;#I=void 0;#y=!1;missingDebugInfoBar=null;#x=!1;loader;ignoreListCallback;constructor(e,i){super(e),this.transformer=i,Qi.set(e,this),this.scriptsPanel=Oi.instance(),this.breakpointManager=w.BreakpointManager.BreakpointManager.instance(),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),this.scriptFileForDebuggerModel=new Map,this.loader=o.PageResourceLoader.PageResourceLoader.instance(),this.loader.addEventListener("Update",this.showSourceMapInfobarIfNeeded.bind(this),this),this.ignoreListCallback=this.showIgnoreListInfobarIfNeeded.bind(this),u.IgnoreListManager.IgnoreListManager.instance().addChangeListener(this.ignoreListCallback),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.updateScriptFiles(),this.muted=this.uiSourceCode.isDirty(),this.initializedMuted=this.muted,this.ignoreListInfobar=null,this.showIgnoreListInfobarIfNeeded();for(const e of this.scriptFileForDebuggerModel.values())e.checkMapping()}editorExtension(){const e=this.shortcutHandlers();return[n.EditorView.updateListener.of((e=>this.onEditorUpdate(e))),n.EditorView.domEventHandlers({keydown:t=>!!this.onKeyDown(t)||(e(t),t.defaultPrevented),keyup:e=>this.onKeyUp(e),mousemove:e=>this.onMouseMove(e),mousedown:e=>this.onMouseDown(e),focusout:e=>this.onBlur(e),wheel:e=>this.onWheel(e)}),n.lineNumbers({domEventHandlers:{mousedown:(e,t,i)=>this.handleGutterClick(e.state.doc.lineAt(t.from),i)}}),io,so,n.Prec.highest(go.field),n.Prec.lowest(So.field),wo,yo.field,n.Prec.lowest(Fo.field),Do,this.uiSourceCode.project().type()===f.Workspace.projectTypes.Debugger?n.EditorView.editorAttributes.of({class:"source-frame-debugger-script"}):[]]}shortcutHandlers(){const e=e=>e.state.doc.lineAt(e.state.selection.main.head);return t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"debugger.toggle-breakpoint":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!1),!0),"debugger.toggle-breakpoint-enabled":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!0),!0),"debugger.breakpoint-input-window":async()=>{if(this.muted||!this.editor)return!1;const t=e(this.editor);return c.userMetrics.breakpointEditDialogRevealedFrom(4),this.#k(t),!0}})}#k(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.breakpoints.find((t=>t.position>=e.from&&t.position<=e.to))?.breakpoint||null;void 0===t&&null!==i&&(t=i.isLogpoint()),this.editBreakpointCondition({line:e,breakpoint:i,location:null,isLogpoint:t})}editorInitialized(e){this.editor=e,async function(e,t,i){const o=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),n=await o.getMappedLines(i);if(!n)return[];const r=[];for(let i=0;i<e.doc.lines;i++){const{lineNumber:o}=t.editorLocationToUILocation(i,0);n.has(o)||r.push(e.doc.line(i+1).from)}return r}(e.state,this.transformer,this.uiSourceCode).then((t=>{t.length&&e.dispatch({effects:m.SourceFrame.addNonBreakableLines.of(t)})}),console.error),this.ignoreListInfobar&&this.attachInfobar(this.ignoreListInfobar),this.missingDebugInfoBar&&this.attachInfobar(this.missingDebugInfoBar),this.sourceMapInfobar&&this.attachInfobar(this.sourceMapInfobar),this.muted||this.refreshBreakpoints(),this.callFrameChanged(),this.popoverHelper?.dispose(),this.popoverHelper=new t.PopoverHelper.PopoverHelper(e,this.getPopoverRequest.bind(this),"sources.object-properties"),this.popoverHelper.setDisableOnClick(!0),this.popoverHelper.setTimeout(250,250),this.popoverHelper.setHasPadding(!0)}static accepts(e){return e.contentType().hasScripts()}showIgnoreListInfobarIfNeeded(){const e=this.uiSourceCode;if(!e.contentType().hasScripts())return;if(!u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return void this.hideIgnoreListInfobar();this.ignoreListInfobar&&this.ignoreListInfobar.dispose();const i=new t.Infobar.Infobar("warning",Yi(Ji.thisScriptIsOnTheDebuggersIgnore),[{text:Yi(Ji.removeFromIgnoreList),highlight:!1,delegate:function(){u.IgnoreListManager.IgnoreListManager.instance().unIgnoreListUISourceCode(e)},dismiss:!0,jslogContext:"remove-from-ignore-list"},{text:Yi(Ji.configure),highlight:!1,delegate:t.ViewManager.ViewManager.instance().showView.bind(t.ViewManager.ViewManager.instance(),"blackbox"),dismiss:!1,jslogContext:"configure"}],void 0,void 0,"script-on-ignore-list");this.ignoreListInfobar=i,i.setCloseCallback((()=>this.removeInfobar(this.ignoreListInfobar))),i.createDetailsRowMessage(Yi(Ji.theDebuggerWillSkipStepping)),this.attachInfobar(this.ignoreListInfobar)}attachInfobar(e){this.editor&&this.editor.dispatch({effects:eo.of(e)})}removeInfobar(e){this.editor&&e&&this.editor.dispatch({effects:to.of(e)})}hideIgnoreListInfobar(){this.ignoreListInfobar&&(this.ignoreListInfobar.dispose(),this.ignoreListInfobar=null)}willHide(){this.popoverHelper?.hidePopover()}editBreakpointLocation({breakpoint:e,uiLocation:t}){const{lineNumber:i}=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber),o=this.editor?.state.doc.line(i+1);o&&this.editBreakpointCondition({line:o,breakpoint:e,location:null,isLogpoint:e.isLogpoint()})}populateLineGutterContextMenu(e,t){const i=new f.UISourceCode.UILocation(this.uiSourceCode,t,0);if(this.scriptsPanel.appendUILocationItems(e,i),this.muted||!this.editor)return;const o=this.editor.state.doc.line(t+1),n=this.lineBreakpoints(o),r=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode);if(n.length){const t=Yi(Ji.removeBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>{c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterContextMenu),e.remove(!1)}))),{jslogContext:"remove-breakpoint"}),1===n.length&&r&&e.debugSection().appendItem(Yi(Ji.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:o,breakpoint:n[0],location:null})}),{jslogContext:"edit-breakpoint"});if(n.some((e=>e.enabled()))){const t=Yi(Ji.disableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!1)))),{jslogContext:"enable-breakpoint"})}if(n.some((e=>!e.enabled()))){const t=Yi(Ji.enableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!0)))),{jslogContext:"disable-breakpoint"})}}else this.editor&&m.SourceFrame.isBreakableLine(this.editor.state,o)&&(e.debugSection().appendItem(Yi(Ji.addBreakpoint),this.createNewBreakpoint.bind(this,o,Gi,!0,!1),{jslogContext:"add-breakpoint"}),r&&(e.debugSection().appendItem(Yi(Ji.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),e.debugSection().appendItem(Yi(Ji.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),e.debugSection().appendItem(Yi(Ji.neverPauseHere),this.createNewBreakpoint.bind(this,o,Ki,!0,!1),{jslogContext:"never-pause-here"})))}populateTextAreaContextMenu(e){function t(e,t){t&&e.addSourceMapURL(t)}function o(e,t){t&&e.addDebugInfoURL(t)}if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get()&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(this.uiSourceCode.url())&&this.scriptFileForDebuggerModel.size){const i=this.scriptFileForDebuggerModel.values().next().value,n=Yi(Ji.addSourceMap);e.debugSection().appendItem(n,function(e){V.createAddSourceMapURLDialog(t.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-source-map"}),i.script?.isWasm()&&!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().pluginManager.hasPluginForScript(i.script)&&e.debugSection().appendItem(Yi(Ji.addWasmDebugInfo),function(e){V.createAddDWARFSymbolsURLDialog(o.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-wasm-debug-info"})}}workingCopyChanged(){this.scriptFileForDebuggerModel.size||this.setMuted(this.uiSourceCode.isDirty())}workingCopyCommitted(){this.scriptsPanel.updateLastModificationTime(),this.scriptFileForDebuggerModel.size||this.setMuted(!1)}didMergeToVM(){this.consistentScripts()&&this.setMuted(!1)}didDivergeFromVM(){this.setMuted(!0)}setMuted(e){this.initializedMuted||e!==this.muted&&(this.muted=e,e?this.editor&&this.editor.dispatch({effects:no.of(null)}):this.restoreBreakpointsAfterEditing())}consistentScripts(){for(const e of this.scriptFileForDebuggerModel.values())if(e.hasDivergedFromVM()||e.isMergingToVM())return!1;return!0}isVariableIdentifier(e){return"VariableName"===e||"VariableDefinition"===e}isIdentifier(e){return"VariableName"===e||"VariableDefinition"===e||"PropertyName"===e||"PropertyDefinition"===e}getPopoverRequest(e){if(t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return null;const i=t.Context.Context.instance().flavor(o.Target.Target),r=i?i.model(o.DebuggerModel.DebuggerModel):null,{editor:s}=this;if(!r||!r.isPaused()||!s)return null;const a=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!a)return null;let c=s.editor.posAtCoords(e);if(!c)return null;const l=s.editor.coordsAtPos(c);if(!l||e.clientY<l.top||e.clientY>l.bottom||e.clientX<l.left-30||e.clientX>l.right+30)return null;e.clientX<l.left&&c>s.state.doc.lineAt(c).from&&(c-=1);const d=Lo(s.state,this.uiSourceCode.mimeType(),c);if(!d)return null;const u=s.state.doc.lineAt(d.from);if(d.to>u.to)return null;const h=s.editor.coordsAtPos(d.from),g=s.editor.coordsAtPos(d.to);if(!h||!g)return null;const m=new AnchorBox(h.left,h.top-2,g.right-h.left,g.bottom-h.top),b=s.state.sliceDoc(d.from,d.to);let f=null;return{box:m,show:async e=>{let i="";if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const e=await p.NamesResolver.allVariablesInCallFrame(a);try{i=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(b,e)}catch{}}else i=await p.NamesResolver.resolveExpression(a,b,this.uiSourceCode,u.number-1,d.from-u.from,d.to-u.from);const c=C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")&&d.containsSideEffects,l=await a.evaluate({expression:i||b,objectGroup:"popover",includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1,throwOnSideEffect:c,timeout:void 0,disableBreaks:void 0,replMode:void 0,allowUnsafeEvalBlockedByCSP:void 0});if(!l||"error"in l||!l.object||"object"===l.object.type&&"error"===l.object.subtype)return!1;f=await y.ObjectPopoverHelper.ObjectPopoverHelper.buildObjectPopover(l.object,e);const h=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!f||a!==h)return r.runtimeModel().releaseObjectGroup("popover"),f&&f.dispose(),!1;const g=n.Decoration.set(Po.range(d.from,d.to));return s.dispatch({effects:Fo.update.of(g)}),!0},hide:()=>{f&&f.dispose(),r.runtimeModel().releaseObjectGroup("popover"),s.dispatch({effects:Fo.update.of(n.Decoration.none)})}}}onEditorUpdate(e){if(!e.changes.empty)for(const t of this.breakpoints)t.position=e.changes.mapPos(t.position)}onWheel(e){this.executionLocation&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&e.preventDefault()}onKeyDown(e){const i=t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e);return i||this.setControlDown(!1),e.key===l.KeyboardUtilities.ESCAPE_KEY&&this.popoverHelper&&this.popoverHelper.isPopoverVisible()?(this.popoverHelper.hidePopover(),e.consume(),!0):(i&&this.executionLocation&&this.setControlDown(!0),!1)}onMouseMove(e){this.executionLocation&&this.controlDown&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&(this.continueToLocations||this.showContinueToLocations())}onMouseDown(e){if(!this.executionLocation||!t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return;if(!this.continueToLocations||!this.editor)return;e.consume();const i=this.editor.editor.posAtCoords(e);if(null!==i)for(const{from:e,to:t,click:o}of this.continueToLocations)if(e<=i&&t>=i){o();break}}onBlur(e){this.setControlDown(!1)}onKeyUp(e){this.setControlDown(!1)}setControlDown(e){e!==this.controlDown&&(this.controlDown=e,clearTimeout(this.controlTimeout),this.controlTimeout=void 0,e&&this.executionLocation?this.controlTimeout=window.setTimeout((()=>{this.executionLocation&&this.controlDown&&this.showContinueToLocations()}),150):this.clearContinueToLocations())}editBreakpointCondition(e){const{line:t,breakpoint:i,location:o,isLogpoint:r}=e;if(i?.isRemoved)return;this.#y=!1;if(this.#I&&function(e,t){if(e.line.number!==t.line.number)return!1;if(e.line.from!==t.line.from)return!1;if(e.line.text!==t.line.text)return!1;if(e.breakpoint!==t.breakpoint)return!1;if(e.location!==t.location)return!1;return e.isLogpoint===t.isLogpoint}(this.#I,e))return;this.activeBreakpointDialog&&this.activeBreakpointDialog.saveAndFinish();const s=this.editor,a=i?i.condition():"",l=i?.isLogpoint()??Boolean(r),d=document.createElement("div"),u=new n.Compartment,h=new $(t.number-1,a,l,(async e=>{this.activeBreakpointDialog=null,this.#I=void 0,h.detach(),s.dispatch({effects:u.reconfigure([])}),e.committed?(x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,a!==e.condition),function(e){const{condition:t,isLogpoint:o}=e,n=0!==t.length&&!o,r=i?.isLogpoint(),s=a&&0!==a.length&&!r;o&&!r?c.userMetrics.breakpointWithConditionAdded(0):n&&!s&&c.userMetrics.breakpointWithConditionAdded(1)}(e),i?i.setCondition(e.condition,e.isLogpoint):o?await this.setBreakpoint(o.lineNumber,o.columnNumber,e.condition,!0,e.isLogpoint):await this.createNewBreakpoint(t,e.condition,!0,e.isLogpoint)):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,!1)}));s.dispatch({effects:n.StateEffect.appendConfig.of(u.of(n.EditorView.decorations.of(n.Decoration.set([n.Decoration.widget({block:!0,widget:new class extends n.WidgetType{toDOM(){return d}},side:1}).range(t.to)]))))}),h.element.addEventListener("blur",(async e=>{(!e.relatedTarget||e.relatedTarget&&!e.relatedTarget.isSelfOrDescendant(h.element))&&(this.#y=!0,setTimeout((()=>{this.activeBreakpointDialog===h&&(this.#y?(h.saveAndFinish(),this.#y=!1):h.focusEditor())}),200))}),!0),h.markAsExternallyManaged(),h.show(d),h.focusEditor(),this.activeBreakpointDialog=h,this.#I=e}async updateValueDecorations(){if(!this.editor)return;const e=this.executionLocation?await this.computeValueDecorations():null;this.editor&&(e||this.editor.state.field(yo.field).size)&&this.editor.dispatch({effects:yo.update.of(e||n.Decoration.none)})}async#T(e,t){const i=e&&await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);if(!i||i.uiSourceCode.url()!==t)return null;const o=this.editor?.toOffset(this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber));return o??null}async computeValueDecorations(){if(!this.editor)return null;if(!i.Settings.Settings.instance().moduleSetting("inline-variable-values").get())return null;if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext))return null;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return null;const r=this.uiSourceCode.url(),s=this.#T(e.functionLocation(),r),a=this.#T(e.location(),r),[c,l]=await Promise.all([s,a]);if(!c||!l||!this.editor)return null;if(c>=l||l-c>1e4)return null;const d=ko(this.editor.state,c,l,l);if(0===d.length)return null;const u=await To(e,(e=>this.#T(e,r)));if(0===u.length)return null;const h=Eo(u,d);if(!h||!this.editor)return null;const p=[];for(const[e,t]of h){const i=h.get(e-1);let o=i?Array.from(t).filter((e=>i.get(e[0])!==e[1])):Array.from(t);o.length&&(o.length>10&&(o=o.slice(0,10)),p.push(n.Decoration.widget({widget:new Io(o),side:1}).range(this.editor.state.doc.line(e+1).to)))}return n.Decoration.set(p,!0)}async showContinueToLocations(){this.popoverHelper?.hidePopover();if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext)||!this.editor)return;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return;const i=e.functionLocation()||e.location(),r=e.debuggerModel,{state:s}=this.editor,a=await r.getPossibleBreakpoints(i,null,!0);this.continueToLocations=[];let c=-1;for(const e of a.reverse()){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber);if(c===t.lineNumber&&"call"!==e.type||t.lineNumber>=s.doc.lines)continue;const i=s.doc.line(t.lineNumber+1),o=Math.min(i.to,i.from+t.columnNumber);let r=n.syntaxTree(s).resolveInner(o,1);if(r.firstChild||r.from<i.from||r.to>i.to)continue;if("."===r.name){const e=r.resolve(r.to,1);if(e.firstChild||e.from<i.from||e.to>i.to)continue;r=e}const a=r.name,l="this"===a||"return"===a||"new"===a||"break"===a||"continue"===a;if(!l&&!this.isIdentifier(a))continue;this.continueToLocations.push({from:r.from,to:r.to,async:!1,click:()=>e.continueToLocation()}),"call"===e.type&&(c=t.lineNumber);const d=l?"":i.text.slice(r.from-i.from,r.to-i.from);let u=null;if("then"===d&&"MemberExpression"===r.parent?.name?u=r.parent.parent:"setTimeout"!==d&&"setInterval"!==d&&"postMessage"!==d||(u=r.parent),"new"===a){const e=r.parent?.getChild("Expression");e&&"VariableName"===e.name&&"Worker"===s.sliceDoc(e.from,e.to)&&(u=r.parent)}if(u&&("CallExpression"===u.name||"NewExpression"===u.name)&&"call"===e.type){const t=u.getChild("ArgList")?.firstChild?.nextSibling;let i;if("VariableName"===t?.name?i=t:"ArrowFunction"!==t?.name&&"FunctionExpression"!==t?.name||(i=t.firstChild,"async"===i?.name&&(i=i.nextSibling)),i){const t=this.executionLocation&&e.lineNumber===this.executionLocation.lineNumber&&e.columnNumber===this.executionLocation.columnNumber;this.continueToLocations.push({from:i.from,to:i.to,async:!0,click:()=>this.asyncStepIn(e,Boolean(t))})}}}const l=n.Decoration.set(this.continueToLocations.map((e=>(e.async?fo:bo).range(e.from,e.to))),!0);this.editor.dispatch({effects:So.update.of(l)})}clearContinueToLocations(){this.editor&&this.editor.state.field(So.field).size&&this.editor.dispatch({effects:So.update.of(n.Decoration.none)})}asyncStepIn(e,t){function i(){e.debuggerModel.scheduleStepIntoAsync()}t?i():e.continueToLocation(i)}fetchBreakpoints(){if(!this.editor)return[];const{editor:e}=this;return this.breakpointManager.breakpointLocationsForUISourceCode(this.uiSourceCode).map((({uiLocation:t,breakpoint:i})=>{const o=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber);return{position:e.toOffset(o),breakpoint:i}}))}lineBreakpoints(e){return this.breakpoints.filter((t=>t.position>=e.from&&t.position<=e.to)).map((e=>e.breakpoint))}async computeBreakpointDecoration(e,t){const i=[],o=[],r=new Map,s=new Map,a=[],c=new Set,l=(e,t,i)=>{let o=s.get(e);o||(o=[],s.set(e,o)),o.push({breakpoint:i,column:t})};for(const{position:i,breakpoint:o}of t){const t=e.doc.lineAt(i);let n=r.get(t.from);if(n||(n=[],r.set(t.from,n)),o.enabled()&&n.every((e=>!e.enabled()))){const e=this.transformer.editorLocationToUILocation(t.number-1,0),i=this.transformer.editorLocationToUILocation(t.number-1,Math.min(t.length,2500)),o=new g.TextRange.TextRange(e.lineNumber,e.columnNumber||0,i.lineNumber,i.columnNumber||0);a.push(this.breakpointManager.possibleBreakpoints(this.uiSourceCode,o).then((e=>d(t,e))))}n.push(o),o.enabled()&&(c.add(i),l(t.from,i-t.from,o))}for(const[e,t]of r){const i=t.sort(lo)[0];let n="cm-breakpoint";i.enabled()||(n+=" cm-breakpoint-disabled"),i.bound()||(n+=" cm-breakpoint-unbound"),i.isLogpoint()?n+=" cm-breakpoint-logpoint":i.condition()&&(n+=" cm-breakpoint-conditional"),o.push(new co(n,e).range(e))}const d=(e,t)=>{for(const i of t){const t=this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber);if(t.lineNumber!==e.number-1)continue;const o=Math.min(e.to,e.from+t.columnNumber);c.has(o)||l(e.from,t.columnNumber,null)}};await Promise.all(a);for(const[e,t]of s)if(t.length>1)for(const{column:o,breakpoint:r}of t){const t=new ao(r,this);i.push(n.Decoration.widget({widget:t,side:-1}).range(e+o))}return{content:n.Decoration.set(i,!0),gutter:n.RangeSet.of(o,!0)}}async restoreBreakpointsAfterEditing(){const{breakpoints:e}=this,t=this.editor;this.breakpoints=[],await Promise.all(e.map((async e=>{const{breakpoint:i,position:o}=e,n=i.condition(),r=i.enabled(),s=i.isLogpoint();await i.remove(!1);const a=t.toLineColumn(o),c=this.transformer.editorLocationToUILocation(a.lineNumber,a.columnNumber);await this.setBreakpoint(c.lineNumber,c.columnNumber,n,r,s)})))}async refreshBreakpoints(){if(this.editor){this.breakpoints=this.fetchBreakpoints();const e=this.breakpoints,t=await this.computeBreakpointDecoration(this.editor.state,e);this.editor&&this.breakpoints===e&&(t.gutter.size||this.editor.state.field(so,!1)?.gutter.size)&&this.editor.dispatch({effects:oo.of(t)})}}breakpointChange(e){const{uiLocation:t}=e.data;if(t.uiSourceCode===this.uiSourceCode&&!this.muted){for(const e of this.scriptFileForDebuggerModel.values())if(e.isDivergingFromVM()||e.isMergingToVM())return;window.clearTimeout(this.refreshBreakpointsTimeout),this.refreshBreakpointsTimeout=window.setTimeout((()=>this.refreshBreakpoints()),50)}}onInlineBreakpointMarkerClick(e,t){if(e.consume(!0),t)e.shiftKey?t.setEnabled(!t.enabled()):t.remove(!1);else if(this.editor){const t=this.editor.editor.posAtDOM(e.target),i=this.editor.state.doc.lineAt(t),o=this.transformer.editorLocationToUILocation(i.number-1,t-i.from);this.setBreakpoint(o.lineNumber,o.columnNumber,Gi,!0,!1)}}onInlineBreakpointMarkerContextMenu(e,i){e.consume(!0);const o=this.editor,n=o.editor.posAtDOM(e.target),r=o.state.doc.lineAt(n);if(!m.SourceFrame.isBreakableLine(o.state,r)||!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode))return;const s=new t.ContextMenu.ContextMenu(e);if(i)s.debugSection().appendItem(Yi(Ji.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:i,location:null})}),{jslogContext:"edit-breakpoint"});else{const e=this.transformer.editorLocationToUILocation(r.number-1,n-r.from);s.debugSection().appendItem(Yi(Ji.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),s.debugSection().appendItem(Yi(Ji.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),s.debugSection().appendItem(Yi(Ji.neverPauseHere),(()=>this.setBreakpoint(e.lineNumber,e.columnNumber,Ki,!0,!1)),{jslogContext:"never-pause-here"})}s.show()}updateScriptFiles(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e)&&this.updateScriptFile(e)}this.showSourceMapInfobarIfNeeded()}updateScriptFile(e){const t=this.scriptFileForDebuggerModel.get(e),i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);this.scriptFileForDebuggerModel.delete(e),t&&(t.removeEventListener("DidMergeToVM",this.didMergeToVM,this),t.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),this.muted&&!this.uiSourceCode.isDirty()&&this.consistentScripts()&&this.setMuted(!1)),i&&(this.scriptFileForDebuggerModel.set(e,i),i.addEventListener("DidMergeToVM",this.didMergeToVM,this),i.addEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),i.checkMapping(),i.missingSymbolFiles().then((e=>{if(e){const t=Yi(Ji.debugInfoNotFound,{PH1:i.uiSourceCode.url()});this.updateMissingDebugInfoInfobar({resources:e,details:t})}else this.updateMissingDebugInfoInfobar(null)})))}updateMissingDebugInfoInfobar(e){if(!this.missingDebugInfoBar){if(null===e)return this.removeInfobar(this.missingDebugInfoBar),void(this.missingDebugInfoBar=null);if(this.missingDebugInfoBar=t.Infobar.Infobar.create("error",e.details,[],void 0,"missing-debug-info"),this.missingDebugInfoBar){for(const t of e.resources){const e=this.missingDebugInfoBar?.createDetailsRowMessage(Yi(Ji.debugFileNotFound,{PH1:t}));e&&e.classList.add("infobar-selectable")}this.missingDebugInfoBar.setCloseCallback((()=>{this.removeInfobar(this.missingDebugInfoBar),this.missingDebugInfoBar=null})),this.attachInfobar(this.missingDebugInfoBar)}}}scriptHasSourceMap(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){const t=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);if(t&&t.hasSourceMapURL())return!0}return!1}getSourceMapResource(){const e=this.loader.getResourcesLoaded();for(const[t,n]of this.scriptFileForDebuggerModel.entries()){const r=n.script?.sourceMapURL;if(r){const s=o.SourceMapManager.SourceMapManager.resolveRelativeSourceURL(t.target(),n.script.sourceURL),a=i.ParsedURL.ParsedURL.completeURL(s,r);if(a){const t=e.get(o.PageResourceLoader.PageResourceLoader.makeKey(a,n.script.createPageResourceLoadInitiator()));if(t)return t}}}return null}showSourceMapInfobarIfNeeded(){if(this.sourceMapInfobar)return;if(!i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get())return;if(!this.scriptHasSourceMap())return;const e=this.getSourceMapResource();if(!e||null!==e.success){if(e)if(e.success){if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Yi(Ji.sourceMapLoaded),[],i.Settings.Settings.instance().createSetting("source-map-infobar-disabled",!1),"source-map-loaded"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.associatedFilesShouldBeAdded)),this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.associatedFilesAreAvailable,{PH1:String(t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction("quick-open.show"))}))}else{let i,o;const n=u.IgnoreListManager.IgnoreListManager.instance();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.ContentScripts?(i=Yi(Ji.ignoreContentScripts),o=n.ignoreListContentScripts.bind(n)):(i=Yi(Ji.ignoreScript),o=n.ignoreListUISourceCode.bind(n,this.uiSourceCode)),this.sourceMapInfobar=t.Infobar.Infobar.create("warning",Yi(Ji.sourceMapFailed),[{text:i,highlight:!1,delegate:o,dismiss:!0}],void 0,"source-map-failed"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.debuggingPowerReduced)),e.errorMessage&&this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.errorLoading,{PH1:l.StringUtilities.trimMiddle(e.url,t.UIUtils.MaxLengthForDisplayedURLs),PH2:e.errorMessage}))}else{if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Yi(Ji.sourceMapSkipped),[],i.Settings.Settings.instance().createSetting("source-map-skipped-infobar-disabled",!1),"source-map-skipped"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.debuggingPowerReduced)),this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.reloadForSourceMap))}this.sourceMapInfobar.setCloseCallback((()=>{this.removeInfobar(this.sourceMapInfobar),this.sourceMapInfobar=null})),this.attachInfobar(this.sourceMapInfobar)}}handleGutterClick(e,t){return!this.muted&&0===t.button&&!t.altKey&&(t.metaKey||t.ctrlKey?(c.userMetrics.breakpointEditDialogRevealedFrom(6),this.#k(e,t.shiftKey),!0):(this.toggleBreakpoint(e,t.shiftKey),!0))}async toggleBreakpoint(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.lineBreakpoints(e);if(!i.length)return void await this.createNewBreakpoint(e,Gi,!0,!1);const o=i.some((e=>!e.enabled()));for(const e of i)t?e.setEnabled(o):(c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterToggle),e.remove(!1))}async createNewBreakpoint(e,t,i,o){if(!this.editor||!m.SourceFrame.isBreakableLine(this.editor.state,e))return;c.userMetrics.actionTaken(c.UserMetrics.Action.ScriptsBreakpointSet),this.#E();const n=this.transformer.editorLocationToUILocation(e.number-1);await this.setBreakpoint(n.lineNumber,n.columnNumber,t,i,o)}async setBreakpoint(e,t,o,n,r){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!0);const s=await this.breakpointManager.setBreakpoint(this.uiSourceCode,e,t,o,n,r,"USER_ACTION");return this.breakpointWasSetForTest(e,t,o,n),s}breakpointWasSetForTest(e,t,i,o){}async callFrameChanged(){this.liveLocationPool.disposeAll();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);e?await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),(async t=>{const i=await t.uiLocation();i&&i.uiSourceCode===this.uiSourceCode?(this.setExecutionLocation(i),this.updateMissingDebugInfoInfobar(e.missingDebugInfoDetails),this.#E()):this.setExecutionLocation(null)}),this.liveLocationPool):this.setExecutionLocation(null)}setExecutionLocation(e){if(this.executionLocation!==e&&this.editor)if(this.executionLocation=e,e){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber),i=mo(this.editor.state,t.lineNumber,t.columnNumber);this.editor.dispatch({effects:go.update.of(i)}),this.updateValueDecorations(),this.controlDown&&this.showContinueToLocations()}else this.editor.dispatch({effects:[go.update.of(n.Decoration.none),So.update.of(n.Decoration.none),yo.update.of(n.Decoration.none)]})}dispose(){this.hideIgnoreListInfobar(),this.sourceMapInfobar&&this.sourceMapInfobar.dispose();for(const e of this.scriptFileForDebuggerModel.values())e.removeEventListener("DidMergeToVM",this.didMergeToVM,this),e.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this);this.scriptFileForDebuggerModel.clear(),this.popoverHelper?.hidePopover(),this.popoverHelper?.dispose(),this.setExecutionLocation(null),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),u.IgnoreListManager.IgnoreListManager.instance().removeChangeListener(this.ignoreListCallback),Qi.delete(this.uiSourceCode),super.dispose(),window.clearTimeout(this.refreshBreakpointsTimeout),this.editor=void 0,t.Context.Context.instance().removeFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool.disposeAll()}#E(){if(this.#x)return;this.#x=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCode.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCode.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCode.content()));c.userMetrics.sourcesPanelFileDebugged(t)}}const eo=n.StateEffect.define(),to=n.StateEffect.define(),io=n.StateField.define({create:()=>[],update(e,t){for(const i of t.effects)i.is(eo)?e=e.concat(i.value):i.is(to)&&(e=e.filter((e=>e!==i.value)));return e},provide:e=>n.showPanel.computeN([e],(t=>t.field(e).map((e=>()=>({dom:e.element})))))});const oo=n.StateEffect.define(),no=n.StateEffect.define();function ro(e,t){const i=[];return e.between(0,t.length,((e,t,o)=>{let n=o.elementClass;/cm-breakpoint-disabled/.test(n)||(n+=" cm-breakpoint-disabled"),i.push(new co(n,e).range(e))})),n.RangeSet.of(i,!1)}const so=n.StateField.define({create:()=>({content:n.RangeSet.empty,gutter:n.RangeSet.empty}),update(e,t){t.changes.empty||(e={content:e.content.map(t.changes),gutter:e.gutter.map(t.changes)});for(const i of t.effects)i.is(oo)?e=i.value:i.is(no)&&(e={content:n.RangeSet.empty,gutter:ro(e.gutter,t.state.doc)});return e},provide:e=>[n.EditorView.decorations.from(e,(e=>e.content)),n.lineNumberMarkers.from(e,(e=>e.gutter))]});class ao extends n.WidgetType{breakpoint;parent;class;constructor(e,t){super(),this.breakpoint=e,this.parent=t,this.class="cm-inlineBreakpoint",e?.isLogpoint()?this.class+=" cm-inlineBreakpoint-logpoint":e?.condition()&&(this.class+=" cm-inlineBreakpoint-conditional"),e?.enabled()||(this.class+=" cm-inlineBreakpoint-disabled")}eq(e){return e.class===this.class&&e.breakpoint===this.breakpoint}toDOM(){const e=document.createElement("span");return e.className=this.class,e.setAttribute("jslog",`${a.breakpointMarker("inline").track({click:!0})}`),e.addEventListener("click",(e=>{this.parent.onInlineBreakpointMarkerClick(e,this.breakpoint),e.consume()})),e.addEventListener("contextmenu",(e=>{this.parent.onInlineBreakpointMarkerContextMenu(e,this.breakpoint),e.consume()})),e}ignoreEvent(){return!0}}class co extends n.GutterMarker{elementClass;#L;constructor(e,t){super(),this.elementClass=e,this.#L=t}eq(e){return e.elementClass===this.elementClass}toDOM(e){const t=document.createElement("div");t.setAttribute("jslog",`${a.breakpointMarker("gutter").track({click:!0})}`);const i=e.state.doc.lineAt(this.#L).number,o=e.state.facet(m.SourceFrame.LINE_NUMBER_FORMATTER);return t.textContent=o(i,e.state),t}}function lo(e,t){return e.enabled()!==t.enabled()?e.enabled()?-1:1:e.bound()!==t.bound()?e.bound()?-1:1:Boolean(e.condition())!==Boolean(t.condition())?Boolean(e.condition())?-1:1:0}function uo(){const e=n.StateEffect.define(),t=n.StateField.define({create:()=>n.Decoration.none,update:(t,i)=>i.effects.reduce(((t,i)=>i.is(e)?i.value:t),t.map(i.changes)),provide:e=>n.EditorView.decorations.from(e)});return{update:e,field:t}}const ho=n.Decoration.line({attributes:{class:"cm-executionLine"}}),po=n.Decoration.mark({attributes:{class:"cm-executionToken"}}),go=uo();function mo(e,t,i){const{doc:o}=e;if(t>=o.lines)return n.Decoration.none;const r=o.line(t+1),s=[ho.range(r.from)],a=Math.min(r.to,r.from+i);let c=null;for(;null===c;)c=n.ensureSyntaxTree(e,r.to,500);let l=c.resolveInner(a,1);l.to===l.from-1&&/[(.]/.test(o.sliceString(l.from,l.to))&&(l=l.resolve(l.to,1));const d=Math.min(r.to,l.to);return d>a&&s.push(po.range(a,d)),n.Decoration.set(s)}const bo=n.Decoration.mark({class:"cm-continueToLocation"}),fo=n.Decoration.mark({class:"cm-continueToLocation cm-continueToLocation-async"}),So=uo(),vo={},Co={class:"cm-hasContinueMarkers"},wo=n.EditorView.contentAttributes.compute([So.field],(e=>e.field(So.field).size?Co:vo));class Io extends n.WidgetType{pairs;constructor(e){super(),this.pairs=e}eq(e){return this.pairs.length===e.pairs.length&&this.pairs.every(((t,i)=>t[0]===e.pairs[i][0]&&t[1]===e.pairs[i][1]))}toDOM(){const e=new y.RemoteObjectPreviewFormatter.RemoteObjectPreviewFormatter,i=document.createElement("div");i.classList.add("cm-variableValues");let o=!0;for(const[n,r]of this.pairs){o?o=!1:t.UIUtils.createTextChild(i,", ");const s=i.createChild("span");t.UIUtils.createTextChild(s,n+" = ");const a=r.preview?r.preview.properties.length:0,c=r.preview&&r.preview.entries?r.preview.entries.length:0;if(r.preview&&a+c<10)e.appendObjectPreview(s,r.preview,!1);else{const e=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValue(r,!1,!1);s.appendChild(e.element)}}return i}}const yo=uo();class xo{blockList=new Set;variables=[]}function ko(e,t,i,o){const r=e.doc.lineAt(t);t=Math.min(r.to,t),i=e.doc.lineAt(i).from;const s=n.ensureSyntaxTree(e,i,100);if(!s)return[];function a(e){return("Block"===(t=e.name)||"ForSpec"===t)&&(e.to<o||o<e.from);var t}const c=[];let l=r;const d=[];let u=null;function h(){return d.length?d[d.length-1].variables:c}return s.iterate({from:t,to:i,enter:i=>{if(i.from<t)return;if("let"===(o=i.name)||"const"===o)return void(u=i.node.nextSibling);var o;if(a(i))return void d.push(new xo);const n=function(e){return"VariableName"===e||"VariableDefinition"===e}(i.name)&&e.sliceDoc(i.from,i.to);n&&(u&&function(e){return"VariableDefinition"===e}(i.name)&&d.length>0?d[d.length-1].blockList.add(n):(i.from>l.to&&(l=e.doc.lineAt(i.from)),h().push({line:l.number-1,from:i.from,id:n})))},leave:e=>{if(u===e.node)u=null;else if(a(e)){const e=d.pop(),t=h();for(const i of e?.variables??[])e?.blockList.has(i.id)||t.push(i)}}}),c}async function To(e,t){const i=[];for(const o of e.scopeChain()){const e=await t(o.range()?.start??null);if(!e)break;const n=await t(o.range()?.end??null);if(!n)break;const{properties:r}=await p.NamesResolver.resolveScopeInObject(o).getAllProperties(!1,!1);if(!r||r.length>500)break;const s=new Map(r.map((e=>[e.name,e.value])));if(i.push({scopeStart:e,scopeEnd:n,variableMap:s}),"local"===o.type())break}return i}function Eo(e,t){const i=new Map;for(const{line:n,from:r,id:s}of t){const t=o(s,r,e);if(!t)continue;let a=i.get(n);a||(a=new Map,i.set(n,a)),a.set(s,t)}return i;function o(e,t,i){for(const o of i){if(t<o.scopeStart||t>=o.scopeEnd)continue;const i=o.variableMap.get(e);if(i)return i}return null}}function Lo(e,t,i){const{main:o}=e.selection;if(!o.empty)return i<o.from||o.to<i?null:{from:o.from,to:o.to,containsSideEffects:!1};const r=n.ensureSyntaxTree(e,i,5e3);if(!r)return null;const s=r.resolveInner(i,1);if(s.firstChild)return null;switch(t){case"application/wasm":{if("Identifier"!==s.name)return null;const t=["block","loop","if","else","end","br","br_if","br_table"];for(let i=s.parent;i;i=i.parent)if("App"===i.name){const o=i.firstChild,n="Keyword"===o?.name&&e.sliceDoc(o.from,o.to);if(n&&t.includes(n))return null}return{from:s.from,to:s.to,containsSideEffects:!1}}case"text/html":case"text/javascript":case"text/jsx":case"text/typescript":case"text/typescript-jsx":{let t=s;for(;t&&"this"!==t.name&&"VariableDefinition"!==t.name&&"VariableName"!==t.name&&"MemberExpression"!==t.name&&("PropertyName"!==t.name||"PatternProperty"!==t.parent?.name||":"===t.nextSibling?.name)&&("PropertyDefinition"!==t.name||"Property"!==t.parent?.name||":"===t.nextSibling?.name);)t=t.parent;return t?{from:t.from,to:t.to,containsSideEffects:Mo(e.doc,t)}:null}default:return s.to-s.from>50||/[^\w_\-$]/.test(e.sliceDoc(s.from,s.to))?null:{from:s.from,to:s.to,containsSideEffects:!1}}}function Mo(e,t){let i=!1;return t.toTree().iterate({enter(t){switch(t.name){case"AssignmentExpression":case"CallExpression":return i=!0,!1;case"ArithOp":{const o=e.sliceString(t.from,t.to);if("++"===o||"--"===o)return i=!0,!1;break}}return!0}}),i}const Po=n.Decoration.mark({class:"cm-evaluatedExpression"}),Fo=uo(),Do=n.EditorView.baseTheme({".cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover, &.cm-breakpoint":{borderStyle:"solid",borderWidth:"1px 4px 1px 1px",marginRight:"-4px",paddingLeft:"8px",lineHeight:"calc(1.2em - 2px)",position:"relative"},"&:hover":{WebkitBorderImage:No("#ebeced","#ebeced")},"&.cm-breakpoint":{color:"#fff",WebkitBorderImage:No("#4285f4","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:No("#f29900","#e37400"),"&::before":{content:'"?"',position:"absolute",top:0,left:"1px"}},"&.cm-breakpoint-logpoint":{WebkitBorderImage:No("#f439a0","#d01884"),"&::before":{content:'"‥"',position:"absolute",top:"-3px",left:"1px"}}},"&dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover":{WebkitBorderImage:No("#3c4043","#3c4043")},"&.cm-breakpoint":{WebkitBorderImage:No("#5186EC","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:No("#e9a33a","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:No("#E54D9B","#d01884")}},":host-context(.breakpoints-deactivated) & .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{color:"#1a73e8",WebkitBorderImage:No("#d9e7fd","#1a73e8"),"&.cm-breakpoint-conditional":{color:"#e37400",WebkitBorderImage:No("#fcebcc","#e37400")},"&.cm-breakpoint-logpoint":{color:"#d01884",WebkitBorderImage:No("#fdd7ec","#f439a0")}},":host-context(.breakpoints-deactivated) &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{WebkitBorderImage:No("#2a384e","#1a73e8"),"&.cm-breakpoint-conditional":{WebkitBorderImage:No("#4d3c1d","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:No("#4e283d","#f439a0")}},".cm-inlineBreakpoint":{cursor:"pointer",position:"relative",top:"1px",content:Ao("#4285F4","#1A73E8"),height:"10px","&.cm-inlineBreakpoint-conditional":{content:Uo("#F29900","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Ro("#F439A0","#D01884")}},"&dark .cm-inlineBreakpoint":{content:Ao("#5186EC","#1A73E8"),"&.cm-inlineBreakpoint-conditional":{content:Uo("#e9a33a","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Ro("#E54D9B","#D01884")}},":host-context(.breakpoints-deactivated) & .cm-inlineBreakpoint, .cm-inlineBreakpoint-disabled":{content:Ao("#4285F4","#1A73E8","0.2"),"&.cm-inlineBreakpoint-conditional":{content:Uo("#F9AB00","#E37400","0.2")},"&.cm-inlineBreakpoint-logpoint":{content:Ro("#F439A0","#D01884","0.2")}},".cm-executionLine":{backgroundColor:"var(--sys-color-yellow-container)",outline:"1px solid var(--sys-color-yellow-outline)",".cm-hasContinueMarkers &":{backgroundColor:"transparent"},"&.cm-highlightedLine":{animation:"cm-fading-highlight-execution 2s 0s"},"&.cm-line::selection, &.cm-line ::selection":{backgroundColor:"var(--sys-color-tonal-container) !important"}},".cm-executionToken":{backgroundColor:"var(--sys-color-state-focus-select)"},"@keyframes cm-fading-highlight-execution":{from:{backgroundColor:"var(--sys-color-tonal-container)"},to:{backgroundColor:"var(--sys-color-yellow-container)"}},".cm-continueToLocation":{cursor:"pointer",backgroundColor:"var(--color-continue-to-location)","&:hover":{backgroundColor:"var(--color-continue-to-location-hover)",border:"1px solid var(--color-continue-to-location-hover-border)",margin:"0 -1px"},"&.cm-continueToLocation-async":{backgroundColor:"var(--color-continue-to-location-async)","&:hover":{backgroundColor:"var(--color-continue-to-location-async-hover)",border:"1px solid var(--color-continue-to-location-async-hover-border)",margin:"0 -1px"}}},".cm-evaluatedExpression":{backgroundColor:"var(--color-evaluated-expression)",border:"1px solid var(--color-evaluated-expression-border)",margin:"0 -1px"},".cm-variableValues":{display:"inline",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"1000px",opacity:"80%",backgroundColor:"var(--color-variable-values)",marginLeft:"10px",padding:"0 5px",userSelect:"text",".cm-executionLine &":{backgroundColor:"transparent",opacity:"50%"}}});function No(e,t){return`url('data:image/svg+xml,<svg height="11" width="26" xmlns="http://www.w3.org/2000/svg"><path d="M22.8.5l2.7 5-2.7 5H.5V.5z" fill="${encodeURIComponent(e)}" stroke="${encodeURIComponent(t)}"/></svg>') 1 3 1 1`}function Ao(e,t,i="1"){return`url('data:image/svg+xml,<svg width="11" height="12" viewBox="0 0 11 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.5 0.5H5.80139C6.29382 0.5 6.7549 0.741701 7.03503 1.14669L10.392 6L7.03503 10.8533C6.7549 11.2583 6.29382 11.5 5.80139 11.5H0.5V0.5Z" fill="${encodeURIComponent(e)}" stroke="${encodeURIComponent(t)}" fill-opacity="${encodeURIComponent(i)}"/></svg>')`}function Uo(e,t,i="1"){return`url('data:image/svg+xml,<svg width="11" height="12" viewBox="0 0 11 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.5 0.5H5.80139C6.29382 0.5 6.75489 0.741701 7.03503 1.14669L10.392 6L7.03503 10.8533C6.75489 11.2583 6.29382 11.5 5.80138 11.5H0.5V0.5Z" fill="${encodeURIComponent(e)}" fill-opacity="${encodeURIComponent(i)}" stroke="${encodeURIComponent(t)}"/><path d="M3.51074 7.75635H4.68408V9H3.51074V7.75635ZM4.68408 7.23779H3.51074V6.56104C3.51074 6.271 3.55615 6.02344 3.64697 5.81836C3.73779 5.61328 3.90039 5.39648 4.13477 5.16797L4.53027 4.77686C4.71484 4.59814 4.83936 4.4502 4.90381 4.33301C4.97119 4.21582 5.00488 4.09424 5.00488 3.96826C5.00488 3.77197 4.9375 3.62402 4.80273 3.52441C4.66797 3.4248 4.46582 3.375 4.19629 3.375C3.9502 3.375 3.69238 3.42773 3.42285 3.5332C3.15625 3.63574 2.88232 3.78955 2.60107 3.99463V2.81689C2.88818 2.65283 3.17822 2.52979 3.47119 2.44775C3.76709 2.36279 4.06299 2.32031 4.35889 2.32031C4.95068 2.32031 5.41504 2.45801 5.75195 2.7334C6.08887 3.00879 6.25732 3.38818 6.25732 3.87158C6.25732 4.09424 6.20752 4.30225 6.10791 4.49561C6.0083 4.68604 5.8208 4.91602 5.54541 5.18555L5.15869 5.56348C4.95947 5.75684 4.83203 5.91504 4.77637 6.03809C4.7207 6.16113 4.69287 6.31201 4.69287 6.49072C4.69287 6.51709 4.69141 6.54785 4.68848 6.58301C4.68848 6.61816 4.68701 6.65625 4.68408 6.69727V7.23779Z" fill="white"/></svg>')`}function Ro(e,t,i="1"){return`url('data:image/svg+xml,<svg width="11" height="12" viewBox="0 0 11 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.5 0.5H5.80139C6.29382 0.5 6.7549 0.741701 7.03503 1.14669L10.392 6L7.03503 10.8533C6.7549 11.2583 6.29382 11.5 5.80139 11.5H0.5V0.5Z" fill="${encodeURIComponent(e)}" stroke="${encodeURIComponent(t)}" fill-opacity="${encodeURIComponent(i)}"/><circle cx="3" cy="6" r="1" fill="white"/><circle cx="7" cy="6" r="1" fill="white"/></svg>')`}var Bo=Object.freeze({__proto__:null,DebuggerPlugin:Zi,BreakpointLocationRevealer:class{async reveal(e,t){const{uiLocation:i}=e;Oi.instance().showUILocation(i,t);const o=Qi.get(i.uiSourceCode);o?o.editBreakpointLocation(e):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(e.breakpoint,!1)}},computeExecutionDecorations:mo,getVariableNamesByLine:ko,computeScopeMappings:To,getVariableValuesByLine:Eo,computePopoverHighlightRange:Lo});class jo{query;queryUpperCase;score;sequence;dataUpperCase;fileNameIndex;constructor(e){this.query=e,this.queryUpperCase=e.toUpperCase(),this.score=new Int32Array(2e3),this.sequence=new Int32Array(2e3),this.dataUpperCase="",this.fileNameIndex=0}calculateScore(e,t){if(!e||!this.query)return 0;const i=this.query.length,o=e.length;(!this.score||this.score.length<i*o)&&(this.score=new Int32Array(i*o*2),this.sequence=new Int32Array(i*o*2));const n=this.score,r=this.sequence;this.dataUpperCase=e.toUpperCase(),this.fileNameIndex=e.lastIndexOf("/");for(let t=0;t<i;++t)for(let i=0;i<o;++i){const s=0===i?0:n[t*o+i-1],a=0===t||0===i?0:n[(t-1)*o+i-1],c=0===t||0===i?0:r[(t-1)*o+i-1],l=this.match(this.query,e,t,i,c);l&&a+l>=s?(r[t*o+i]=c+1,n[t*o+i]=a+l):(r[t*o+i]=0,n[t*o+i]=s)}t&&this.restoreMatchIndexes(r,i,o,t);return 256*n[i*o-1]+(256-e.length)}testWordStart(e,t){if(0===t)return!0;const i=e.charAt(t-1);return"_"===i||"-"===i||"/"===i||"."===i||" "===i||e[t-1]!==this.dataUpperCase[t-1]&&e[t]===this.dataUpperCase[t]}restoreMatchIndexes(e,t,i,o){let n=t-1,r=i-1;for(;n>=0&&r>=0;)if(0===e[n*i+r])--r;else o.push(r),--n,--r;o.reverse()}singleCharScore(e,t,i,o){const n=this.testWordStart(t,o),r=o>this.fileNameIndex;let s=10;return(0===o||"/"===t[o-1])&&(s+=4),n&&(s+=2),e[i]===t[o]&&e[i]===this.queryUpperCase[i]&&(s+=6),r&&(s+=4),o===this.fileNameIndex+1&&0===i&&(s+=5),r&&n&&(s+=3),s}sequenceCharScore(e,t,i,o,n){let r=10;return o>this.fileNameIndex&&(r+=4),(0===o||"/"===t[o-1])&&(r+=5),r+=4*n,r}match(e,t,i,o,n){return this.queryUpperCase[i]!==this.dataUpperCase[o]?0:n?this.sequenceCharScore(e,t,i,o-n,n):this.singleCharScore(e,t,i,o)}}var Vo=Object.freeze({__proto__:null,FilePathScoreFunction:jo});const Wo={noFilesFound:"No files found",sIgnoreListed:"{PH1} (ignore listed)"},Oo=e.i18n.registerUIStrings("panels/sources/FilteredUISourceCodeListProvider.ts",Wo),Ho=e.i18n.getLocalizedString.bind(void 0,Oo);class _o extends L.FilteredListWidget.Provider{queryLineNumberAndColumnNumber;defaultScores;scorer;uiSourceCodes;uiSourceCodeIds;query;constructor(e){super(e),this.queryLineNumberAndColumnNumber="",this.defaultScores=null,this.scorer=new jo(""),this.uiSourceCodes=[],this.uiSourceCodeIds=new Set}projectRemoved(e){const t=e.data;this.populate(t),this.refresh()}populate(e){this.uiSourceCodes=[],this.uiSourceCodeIds.clear();for(const t of f.Workspace.WorkspaceImpl.instance().projects())if(t!==e&&this.filterProject(t))for(const e of t.uiSourceCodes())this.filterUISourceCode(e)&&(this.uiSourceCodes.push(e),this.uiSourceCodeIds.add(e.canononicalScriptId()))}filterUISourceCode(e){if(this.uiSourceCodeIds.has(e.canononicalScriptId()))return!1;if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return!1;if(e.isFetchXHR())return!1;const t=h.Persistence.PersistenceImpl.instance().binding(e);return!t||t.fileSystem===e}uiSourceCodeSelected(e,t,i){}filterProject(e){return!0}itemCount(){return this.uiSourceCodes.length}itemContentTypeAt(e){return this.uiSourceCodes[e].contentType()}itemKeyAt(e){return this.uiSourceCodes[e].url()}setDefaultScores(e){this.defaultScores=e}itemScoreAt(e,t){const i=this.uiSourceCodes[e],o=this.defaultScores&&this.defaultScores.get(i)||0;if(!t||t.length<2)return o;this.query!==t&&(this.query=t,this.scorer=new jo(t));let n=10;i.project().type()!==f.Workspace.projectTypes.FileSystem||h.Persistence.PersistenceImpl.instance().binding(i)||(n=5);let r=0;i.contentType().isFromSourceMap()&&!i.isKnownThirdParty()&&(r=100),i.contentType().isScript()&&(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||(r+=50));const s=i.fullDisplayName();return o+n*(r+this.scorer.calculateScore(s,null))}renderItem(e,i,o,n){i=this.rewriteQuery(i);const r=this.uiSourceCodes[e],s=r.fullDisplayName(),a=[];new jo(i).calculateScore(s,a);const c=s.lastIndexOf("/");let l=s;u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(r)&&(o.parentElement?.classList.add("is-ignore-listed"),l=Ho(Wo.sIgnoreListed,{PH1:l})),o.textContent=r.displayName()+(this.queryLineNumberAndColumnNumber||""),this.renderSubtitleElement(n,s.substring(0,c+1)),t.Tooltip.Tooltip.install(n,l);const d=[];for(let e=0;e<a.length;++e)d.push({offset:a[e],length:1});if(a[0]>c){for(let e=0;e<d.length;++e)d[e].offset-=c+1;t.UIUtils.highlightRangesWithStyleClass(o,d,"highlight")}else t.UIUtils.highlightRangesWithStyleClass(n,d,"highlight")}renderSubtitleElement(e,i){e.removeChildren();let o=i.lastIndexOf("/");i.length>43&&(o=i.length-43);e.createChild("div","first-part").textContent=i.substring(0,o);e.createChild("div","second-part").textContent=i.substring(o),t.Tooltip.Tooltip.install(e,i)}selectItem(e,t){const i=t.trim().match(/^([^:]*)(:\d+)?(:\d+)?$/);if(!i)return;let o,n;i[2]&&(o=parseInt(i[2].substr(1),10)-1),i[3]&&(n=parseInt(i[3].substr(1),10)-1);const r=null!==e?this.uiSourceCodes[e]:null;this.uiSourceCodeSelected(r,o,n)}rewriteQuery(e){if(!(e=e?e.trim():"")||":"===e)return"";const t=e.match(/^([^:]+)((?::[^:]*){0,2})$/);return this.queryLineNumberAndColumnNumber=t?t[2]:"",t?t[1]:e}uiSourceCodeAdded(e){const t=e.data;this.filterUISourceCode(t)&&this.filterProject(t.project())&&(this.uiSourceCodes.push(t),this.uiSourceCodeIds.add(t.canononicalScriptId()),this.refresh())}notFoundText(){return Ho(Wo.noFilesFound)}attach(){f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.populate()}detach(){f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.queryLineNumberAndColumnNumber="",this.defaultScores=null}}var zo=Object.freeze({__proto__:null,FilteredUISourceCodeListProvider:_o});const qo={noFileSelected:"No file selected.",noResultsFound:"No results found",typeANumberToGoToThatLine:"Type a number to go to that line.",currentPositionXsTypeAnOffset:"Current position: 0x{PH1}. Type an offset between 0x{PH2} and 0x{PH3} to navigate to.",currentLineSTypeALineNumber:"Current line: {PH1}. Type a line number between 1 and {PH2} to navigate to.",goToOffsetXs:"Go to offset 0x{PH1}.",goToLineSAndColumnS:"Go to line {PH1} and column {PH2}.",goToLineS:"Go to line {PH1}."},$o=e.i18n.registerUIStrings("panels/sources/GoToLineQuickOpen.ts",qo),Go=e.i18n.getLocalizedString.bind(void 0,$o);class Ko extends L.FilteredListWidget.Provider{#M=[];constructor(){super("source-line")}selectItem(e,t){const i=this.currentSourceFrame();if(!i)return;const o=this.parsePosition(t);o&&i.revealPosition({lineNumber:o.line-1,columnNumber:o.column-1})}itemCount(){return this.#M.length}renderItem(e,i,o,n){t.UIUtils.createTextChild(o,this.#M[e])}rewriteQuery(e){return""}queryChanged(e){this.#M=[];const t=this.parsePosition(e),i=this.currentSourceFrame();if(t)i&&i.wasmDisassembly?this.#M.push(Go(qo.goToOffsetXs,{PH1:(t.column-1).toString(16)})):t.column&&t.column>1?this.#M.push(Go(qo.goToLineSAndColumnS,{PH1:t.line,PH2:t.column})):i&&t.line>i.textEditor.state.doc.lines||this.#M.push(Go(qo.goToLineS,{PH1:t.line}));else{if(!i)return void this.#M.push(Go(qo.typeANumberToGoToThatLine));const e=i.textEditor.state,t=i.wasmDisassembly,o=i.editorLocationToUILocation(e.doc.lineAt(e.selection.main.head).number-1).lineNumber;if(t){const e=t.lineNumberToBytecodeOffset(t.lineNumbers-1),i=e.toString(16).length,n=t.lineNumberToBytecodeOffset(o);return void this.#M.push(Go(qo.currentPositionXsTypeAnOffset,{PH1:n.toString(16).padStart(i,"0"),PH2:"0".padStart(i,"0"),PH3:e.toString(16)}))}const n=i.editorLocationToUILocation(e.doc.lines-1).lineNumber+1;this.#M.push(Go(qo.currentLineSTypeALineNumber,{PH1:o+1,PH2:n}))}}notFoundText(e){return this.currentSourceFrame()?Go(qo.noResultsFound):Go(qo.noFileSelected)}parsePosition(e){const t=this.currentSourceFrame();if(t&&t.wasmDisassembly){const t=e.match(/0x([0-9a-fA-F]+)/);if(!t||!t[0]||t[0].length!==e.length)return null;return{line:0,column:parseInt(t[0],16)+1}}const i=e.match(/([0-9]+)(\:[0-9]*)?/);if(!i||!i[0]||i[0].length!==e.length)return null;const o=parseInt(i[1],10);let n=0;return i[2]&&(n=parseInt(i[2].substring(1),10)),{line:Math.max(0|o,1),column:Math.max(0|n,1)}}currentSourceFrame(){const e=t.Context.Context.instance().flavor(yi);return e?e.currentSourceFrame():null}}var Jo=Object.freeze({__proto__:null,GoToLineQuickOpen:Ko});const Xo={formatS:"Format {PH1}",format:"Format"},Yo=e.i18n.registerUIStrings("panels/sources/InplaceFormatterEditorAction.ts",Xo),Qo=e.i18n.getLocalizedString.bind(void 0,Yo);let Zo;class en{button;sourcesView;uiSourceCodeTitleChangedEvent=null;constructor(){}static instance(e={forceNew:null}){const{forceNew:t}=e;return Zo&&!t||(Zo=new en),Zo}editorSelected(e){const t=e.data;this.updateButton(t)}editorClosed(e){const{wasSelected:t}=e.data;t&&this.updateButton(null)}updateButton(e){this.uiSourceCodeTitleChangedEvent&&i.EventTarget.removeEventListeners([this.uiSourceCodeTitleChangedEvent]),this.uiSourceCodeTitleChangedEvent=e?e.addEventListener(f.UISourceCode.Events.TitleChanged,(e=>this.updateButton(e.data)),this):null;const t=this.isFormattable(e);this.button.element.classList.toggle("hidden",!t),e&&t&&this.button.setTitle(Qo(Xo.formatS,{PH1:e.name()}))}getOrCreateButton(e){return this.button||(this.sourcesView=e,this.sourcesView.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.sourcesView.addEventListener("EditorClosed",this.editorClosed.bind(this)),this.button=new t.Toolbar.ToolbarButton(Qo(Xo.format),"brackets"),this.button.addEventListener("Click",this.formatSourceInPlace,this),this.updateButton(e.currentUISourceCode())),this.button}isFormattable(e){return!!e&&(!!e.project().canSetFileContent()||null!==h.Persistence.PersistenceImpl.instance().binding(e))}formatSourceInPlace(){const e=this.sourcesView.currentSourceFrame();if(!e)return;const t=e.uiSourceCode();this.isFormattable(t)&&(t.isDirty()?this.contentLoaded(t,e,t.workingCopy()):t.requestContent().then((i=>{this.contentLoaded(t,e,i.content||"")})))}async contentLoaded(e,t,i){const{formattedContent:o,formattedMapping:n}=await I.ScriptFormatter.format(e.contentType(),t.contentType,i);if(e.workingCopy()===o)return;const r=t.textEditor.toLineColumn(t.textEditor.state.selection.main.head),[s,a]=n.originalToFormatted(r.lineNumber,r.columnNumber);e.setWorkingCopy(o),this.sourcesView.showSourceLocation(e,{lineNumber:s,columnNumber:a})}}ki(en.instance);var tn=Object.freeze({__proto__:null,InplaceFormatterEditorAction:en});var on=Object.freeze({__proto__:null,OpenFileQuickOpen:class extends _o{constructor(){super("source-file")}attach(){this.setDefaultScores(yi.defaultUISourceCodeScores()),super.attach()}uiSourceCodeSelected(e,t,o){c.userMetrics.actionTaken(c.UserMetrics.Action.SelectFileFromFilePicker),e&&("number"==typeof t?i.Revealer.reveal(e.uiLocation(t,o)):i.Revealer.reveal(e))}filterProject(e){return!e.isServiceProject()}renderItem(e,t,i,o){super.renderItem(e,t,i,o);const n=new r.Icon.Icon,s=N.iconDataForResourceType(this.itemContentTypeAt(e));n.data={...s,width:"20px",height:"20px"},i.parentElement?.parentElement?.insertBefore(n,i.parentElement)}renderAsTwoRows(){return!0}}});const nn={noFileSelected:"No file selected.",openAJavascriptOrCssFileToSee:"Open a JavaScript or CSS file to see symbols",noResultsFound:"No results found"},rn=e.i18n.registerUIStrings("panels/sources/OutlineQuickOpen.ts",nn),sn=e.i18n.getLocalizedString.bind(void 0,rn);function an(e){function t(t){t=Math.max(0,Math.min(t,e.doc.length));const i=e.doc.lineAt(t);return{lineNumber:i.number-1,columnNumber:t-i.from}}function i(){for(;"ParamList"!==r.name&&r.nextSibling(););let t="";if("ParamList"===r.name&&r.firstChild())do{switch(r.name){case"ArrayPattern":t+="[‥]";break;case"ObjectPattern":t+="{‥}";break;case"VariableDefinition":t+=e.sliceDoc(r.from,r.to);break;case"Spread":t+="...";break;case",":t+=", "}}while(r.nextSibling());return`(${t})`}const o=[],r=n.syntaxTree(e).cursor();do{switch(r.name){case"RuleSet":for(r.firstChild();;r.nextSibling()){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);if(o.push({title:i,lineNumber:n,columnNumber:s}),r.nextSibling(),","!==r.name)break}break;case"FunctionDeclaration":case"MethodDeclaration":{let n="";r.firstChild();do{switch(r.name){case"abstract":case"async":case"get":case"set":case"static":n=`${n}${r.name} `;break;case"Star":n+="*";break;case"PropertyDefinition":case"PrivatePropertyDefinition":case"VariableDefinition":{const s=n+e.sliceDoc(r.from,r.to),{lineNumber:a,columnNumber:c}=t(r.from),l=i();o.push({title:s,subtitle:l,lineNumber:a,columnNumber:c});break}}}while(r.nextSibling());break}case"Property":{let n="";r.firstChild();do{if("async"===r.name||"get"===r.name||"set"===r.name)n=`${n}${r.name} `;else{if("Star"!==r.name){if("PropertyDefinition"===r.name){let s=e.sliceDoc(r.from,r.to);const{lineNumber:a,columnNumber:c}=t(r.from);for(;r.nextSibling();){if("ClassExpression"===r.name){s=`class ${s}`,o.push({title:s,lineNumber:a,columnNumber:c});break}if("ArrowFunction"!==r.name&&"FunctionExpression"!==r.name||r.firstChild(),"async"===r.name)n=`async ${n}`;else if("Star"===r.name)n+="*";else if("ParamList"===r.name){s=n+s;const e=i();o.push({title:s,subtitle:e,lineNumber:a,columnNumber:c});break}}break}break}n+="*"}}while(r.nextSibling());break}case"PropertyName":case"VariableDefinition":if(r.matchContext(["ClassDeclaration"])){const i="class "+e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["AssignmentExpression","MemberExpression"])||r.matchContext(["VariableDeclaration"])){let n=e.sliceDoc(r.from,r.to);const{lineNumber:s,columnNumber:a}=t(r.from);for(;"Equals"!==r.name&&r.next(););if(!r.nextSibling())break;if("ArrowFunction"===r.name||"FunctionExpression"===r.name){r.firstChild();let e="";for(;"ParamList"!==r.name&&("async"===r.name?e=`async ${e}`:"Star"===r.name&&(e+="*"),r.nextSibling()););n=e+n;const t=i();o.push({title:n,subtitle:t,lineNumber:s,columnNumber:a})}else"ClassExpression"===r.name&&(n=`class ${n}`,o.push({title:n,lineNumber:s,columnNumber:a}))}break;case"App":if(r.firstChild()&&r.nextSibling()&&"module"===e.sliceDoc(r.from,r.to)){if(r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}do{if("App"===r.name&&r.firstChild()){if(r.nextSibling()&&"func"===e.sliceDoc(r.from,r.to)&&r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from),a=[];for(;r.nextSibling();)"App"===r.name&&r.firstChild()&&(r.nextSibling()&&"param"===e.sliceDoc(r.from,r.to)&&(r.nextSibling()&&"Identifier"===r.name?a.push(e.sliceDoc(r.from,r.to)):a.push(`$${a.length}`)),r.parent());const c=`(${a.join(", ")})`;o.push({title:i,subtitle:c,lineNumber:n,columnNumber:s})}r.parent()}}while(r.nextSibling())}break;case"FieldIdentifier":case"Identifier":if(r.matchContext(["FunctionDeclarator"])){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}break;case"TypeIdentifier":if(r.matchContext(["ClassSpecifier"])){const i=`class ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["StructSpecifier"])){const i=`struct ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}}}while(r.next());return o}class cn extends L.FilteredListWidget.Provider{items=[];active=!1;constructor(){super("source-symbol")}attach(){const e=this.currentSourceFrame();e?(this.active=!0,this.items=an(e.textEditor.state).map((({title:t,subtitle:i,lineNumber:o,columnNumber:n})=>(({lineNumber:o,columnNumber:n}=e.editorLocationToUILocation(o,n)),{title:t,subtitle:i,lineNumber:o,columnNumber:n})))):(this.active=!1,this.items=[])}detach(){this.active=!1,this.items=[]}itemCount(){return this.items.length}itemKeyAt(e){const t=this.items[e];return t.title+(t.subtitle?t.subtitle:"")}itemScoreAt(e,t){const i=this.items[e];return t.split("(")[0].toLowerCase()===i.title.toLowerCase()?1/(1+i.lineNumber):-i.lineNumber-1}renderItem(e,t,i,o){const n=this.items[e];i.textContent=n.title+(n.subtitle?n.subtitle:""),L.FilteredListWidget.FilteredListWidget.highlightRanges(i,t);const r=this.currentSourceFrame();if(!r)return;const s=i.parentElement?.parentElement?.createChild("span","tag");if(!s)return;const a=r.wasmDisassembly;if(a){const e=a.lineNumberToBytecodeOffset(a.lineNumbers-1).toString(16).length;s.textContent=`:0x${n.columnNumber.toString(16).padStart(e,"0")}`}else s.textContent=`:${n.lineNumber+1}`}selectItem(e,t){if(null===e)return;const i=this.currentSourceFrame();if(!i)return;const o=this.items[e];i.revealPosition({lineNumber:o.lineNumber,columnNumber:o.columnNumber},!0)}currentSourceFrame(){const e=t.Context.Context.instance().flavor(yi);return e&&e.currentSourceFrame()}notFoundText(){return this.currentSourceFrame()?this.active?sn(nn.noResultsFound):sn(nn.openAJavascriptOrCssFileToSee):sn(nn.noFileSelected)}}var ln=Object.freeze({__proto__:null,outline:an,OutlineQuickOpen:cn});const dn=new CSSStyleSheet;dn.replaceSync(".scope-chain-sidebar-pane-section-header{flex:auto}.scope-chain-sidebar-pane-section-icon{float:left;margin-right:5px}.scope-chain-sidebar-pane-section-subtitle{float:right;margin-left:5px;max-width:55%;text-overflow:ellipsis;overflow:hidden}.scope-chain-sidebar-pane-section-title{font-weight:normal;word-wrap:break-word;white-space:normal}.scope-chain-sidebar-pane-section{padding:2px 4px;flex:none}\n/*# sourceURL=scopeChainSidebarPane.css */\n");const un={loading:"Loading...",notPaused:"Not paused",noVariables:"No variables",closureS:"Closure ({PH1})",closure:"Closure",exception:"Exception",returnValue:"Return value"},hn=e.i18n.registerUIStrings("panels/sources/ScopeChainSidebarPane.ts",un),pn=e.i18n.getLocalizedString.bind(void 0,hn);let gn;class mn extends t.Widget.VBox{treeOutline;expandController;linkifier;infoElement;#P=null;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.scope-chain")}`),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),this.linkifier=new D.Linkifier.Linkifier,this.infoElement=document.createElement("div"),this.infoElement.className="gray-info-message",this.infoElement.tabIndex=-1,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),this.update()}static instance(){return gn||(gn=new mn),gn}flavorChanged(e){this.update()}focus(){this.hasFocus()||t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails)&&this.treeOutline.forceSelect()}sourceMapAttached(e){e.data.client===this.#P&&this.update()}setScopeSourceMapSubscription(e){const t=this.#P;this.#P=e?.script??null,t?.debuggerModel!==this.#P?.debuggerModel&&(t&&t.debuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),this.#P&&this.#P.debuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this))}debugInfoAttached(e){e.data===this.#P&&this.update()}async update(){this.infoElement.textContent=pn(un.loading),this.contentElement.removeChildren(),this.contentElement.appendChild(this.infoElement),this.linkifier.reset();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);this.setScopeSourceMapSubscription(e);const[i,n]=await Promise.all([p.NamesResolver.resolveThisObject(e),p.NamesResolver.resolveScopeChain(e)]);if(e===t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame)){const r=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.treeOutline.removeChildren(),!r||!e||!n)return void(this.infoElement.textContent=pn(un.notPaused));this.contentElement.removeChildren(),this.contentElement.appendChild(this.treeOutline.element);let s=!1;for(let t=0;t<n.length;++t){const o=n[t],a=this.extraPropertiesForScope(o,r,e,i,0===t);"local"===o.type()&&(s=!0);const c=this.createScopeSectionTreeElement(o,a);"global"===o.type()?c.collapse():s&&"local"!==o.type()||c.expand(),this.treeOutline.appendChild(c),0===t&&c.select(!0)}this.sidebarPaneUpdatedForTest()}}createScopeSectionTreeElement(e,i){let o=null;e.type(),o=pn(un.noVariables);let n=e.typeName();if("closure"===e.type()){const i=e.name();n=i?pn(un.closureS,{PH1:t.UIUtils.beautifyFunctionName(i)}):pn(un.closure)}let r=e.description();n&&n!==r||(r=null);const s=e.icon(),a=document.createElement("div");if(a.classList.add("scope-chain-sidebar-pane-section-header"),a.classList.add("tree-element-title"),s){const e=document.createElement("img");e.classList.add("scope-chain-sidebar-pane-section-icon"),e.src=s,a.appendChild(e)}a.createChild("div","scope-chain-sidebar-pane-section-subtitle").textContent=r,a.createChild("div","scope-chain-sidebar-pane-section-title").textContent=n;const c=new y.ObjectPropertiesSection.RootElement(p.NamesResolver.resolveScopeInObject(e),this.linkifier,o,0,i);return c.title=a,c.listItemElement.classList.add("scope-chain-sidebar-pane-section"),c.listItemElement.setAttribute("aria-label",n),this.expandController.watchSection(n+(r?":"+r:""),c),c}extraPropertiesForScope(e,t,i,n,r){if("local"!==e.type()||i.script.isWasm())return[];const s=[];if(n&&s.push(new o.RemoteObject.RemoteObjectProperty("this",n,void 0,void 0,void 0,void 0,void 0,!0)),r){const e=t.exception();e&&s.push(new o.RemoteObject.RemoteObjectProperty(pn(un.exception),e,void 0,void 0,void 0,void 0,void 0,!0));const n=i.returnValue();n&&s.push(new o.RemoteObject.RemoteObjectProperty(pn(un.returnValue),n,void 0,void 0,void 0,void 0,void 0,!0,i.setReturnValue.bind(i)))}return s}sidebarPaneUpdatedForTest(){}wasShown(){super.wasShown(),this.treeOutline.registerCSSFiles([dn]),this.registerCSSFiles([dn])}}var bn=Object.freeze({__proto__:null,ScopeChainSidebarPane:mn});const fn=new CSSStyleSheet;fn.replaceSync(".border-container{border-bottom:1px solid var(--sys-color-divider);flex-shrink:0}\n/*# sourceURL=sourcesNavigator.css */\n");const Sn={explainWorkspace:"Set up workspace to sync edits directly to the sources you develop",explainLocalOverrides:"Override network requests and web content locally to mock remote resources",learnMore:"Learn more",clearConfiguration:"Clear configuration",selectFolderForOverrides:"Select folder for overrides",explainContentScripts:"View content scripts served by extensions",explainSnippets:"Save the JavaScript code you run often to run it again anytime",newSnippet:"New snippet",createNewSnippet:"Create new snippet",run:"Run",rename:"Rename…",remove:"Remove",saveAs:"Save as..."},vn=e.i18n.registerUIStrings("panels/sources/SourcesNavigator.ts",Sn),Cn=e.i18n.getLocalizedString.bind(void 0,vn);let wn,In;class yn extends ut{constructor(){super("navigator-network",!0),o.TargetManager.TargetManager.instance().addEventListener("InspectedURLChanged",this.inspectedURLChanged,this),c.userMetrics.panelLoaded("sources","DevTools.Launch.Sources"),o.TargetManager.TargetManager.instance().addScopeChangeListener(this.onScopeChange.bind(this))}wasShown(){this.registerCSSFiles([fn]),super.wasShown()}static instance(e={forceNew:null}){const{forceNew:t}=e;return wn&&!t||(wn=new yn),wn}acceptProject(e){return e.type()===f.Workspace.projectTypes.Network&&o.TargetManager.TargetManager.instance().isInScope(u.NetworkProject.NetworkProject.getTargetForProject(e))}onScopeChange(){for(const e of f.Workspace.WorkspaceImpl.instance().projects())this.acceptProject(e)?this.tryAddProject(e):this.removeProject(e)}inspectedURLChanged(e){const t=o.TargetManager.TargetManager.instance().scopeTarget();if(e.data!==t)return;const i=t&&t.inspectedURL();if(i)for(const e of this.workspace().uiSourceCodes())this.acceptProject(e.project())&&e.url()===i&&this.revealUISourceCode(e,!0)}uiSourceCodeAdded(e){const t=o.TargetManager.TargetManager.instance().scopeTarget(),i=t&&t.inspectedURL();i&&e.url()===i&&this.revealUISourceCode(e,!0)}}class xn extends ut{toolbar;constructor(){super("navigator-overrides");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` + <div>${Cn(Sn.explainLocalOverrides)}</div><br /> + ${t.XLink.XLink.create("https://goo.gle/devtools-overrides",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `),this.toolbar=new t.Toolbar.Toolbar("navigator-toolbar"),this.contentElement.insertBefore(this.toolbar.element,this.contentElement.firstChild),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("ProjectChanged",this.updateProjectAndUI,this),this.workspace().addEventListener(f.Workspace.Events.ProjectAdded,this.onProjectAddOrRemoved,this),this.workspace().addEventListener(f.Workspace.Events.ProjectRemoved,this.onProjectAddOrRemoved,this),this.updateProjectAndUI()}static instance(e={forceNew:null}){const{forceNew:t}=e;return In&&!t||(In=new xn),In}onProjectAddOrRemoved(e){const t=e.data;t&&t.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(t)||this.updateUI()}updateProjectAndUI(){this.reset();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();e&&this.tryAddProject(e),this.updateUI()}updateUI(){this.toolbar.removeToolbarItems();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();if(e){const o=new t.Toolbar.ToolbarSettingCheckbox(i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled"));this.toolbar.appendToolbarItem(o),this.toolbar.appendToolbarItem(new t.Toolbar.ToolbarSeparator(!0));const n=new t.Toolbar.ToolbarButton(Cn(Sn.clearConfiguration),"clear");return n.addEventListener("Click",(()=>{i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!1),e.remove()})),void this.toolbar.appendToolbarItem(n)}const o=Cn(Sn.selectFolderForOverrides),n=new t.Toolbar.ToolbarButton(o,"plus",o);n.addEventListener("Click",(e=>{this.setupNewWorkspace()}),this),this.toolbar.appendToolbarItem(n)}async setupNewWorkspace(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem("overrides")&&i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!0)}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.OverridesSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e===h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()}}var kn=Object.freeze({__proto__:null,NetworkNavigatorView:yn,FilesNavigatorView:class extends ut{constructor(){super("navigator-files");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` + <div>${Cn(Sn.explainWorkspace)}</div><br /> + ${t.XLink.XLink.create("https://goo.gle/devtools-workspace",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `);const i=new t.Toolbar.Toolbar("navigator-toolbar");i.appendItemsAtLocation("files-navigator-toolbar").then((()=>{i.empty()||this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}))}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(e)&&!T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.defaultSection().appendAction("sources.add-folder-to-workspace",void 0,!0),i.show()}},OverridesNavigatorView:xn,ContentScriptsNavigatorView:class extends ut{constructor(){super("navigator-content-scripts");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` + <div>${Cn(Sn.explainContentScripts)}</div><br /> + ${t.XLink.XLink.create("https://developer.chrome.com/extensions/content_scripts",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `)}acceptProject(e){return e.type()===f.Workspace.projectTypes.ContentScripts}},SnippetsNavigatorView:class extends ut{constructor(){super("navigator-snippets");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` + <div>${Cn(Sn.explainSnippets)}</div><br /> + ${t.XLink.XLink.create("https://goo.gle/devtools-snippets",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `);const i=new t.Toolbar.Toolbar("navigator-toolbar"),o=new t.Toolbar.ToolbarButton(Cn(Sn.newSnippet),"plus",Cn(Sn.newSnippet),"sources.new-snippet");o.addEventListener("Click",(e=>{this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")})),i.appendToolbarItem(o),this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}acceptProject(e){return T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.headerSection().appendItem(Cn(Sn.createNewSnippet),(()=>this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")),{jslogContext:"create-new-snippet"}),i.show()}handleFileContextMenu(e,i){const o=i.uiSourceCode(),n=new t.ContextMenu.ContextMenu(e);n.headerSection().appendItem(Cn(Sn.run),(()=>T.ScriptSnippetFileSystem.evaluateScriptSnippet(o)),{jslogContext:"run"}),n.editSection().appendItem(Cn(Sn.rename),(()=>this.rename(i,!1)),{jslogContext:"rename"}),n.editSection().appendItem(Cn(Sn.remove),(()=>o.project().deleteFile(o)),{jslogContext:"remove"}),n.saveSection().appendItem(Cn(Sn.saveAs),this.handleSaveAs.bind(this,o),{jslogContext:"save-as"}),n.show()}async handleSaveAs(e){e.commitWorkingCopy();const{content:t}=await e.requestContent();await f.FileManager.FileManager.instance().save(this.addJSExtension(e.url()),t||"",!0),f.FileManager.FileManager.instance().close(e.url())}addJSExtension(e){return i.ParsedURL.ParsedURL.concatenate(e,".js")}},ActionDelegate:class{handleAction(e,t){switch(t){case"sources.create-snippet":return T.ScriptSnippetFileSystem.findSnippetsProject().createFile(l.DevToolsPath.EmptyEncodedPathString,null,"").then((e=>i.Revealer.reveal(e))),!0;case"sources.add-folder-to-workspace":return h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem(),!0}return!1}}});const Tn=new CSSStyleSheet;Tn.replaceSync(".value.object-value-node:hover{background-color:var(--sys-color-state-hover-on-subtle)}.object-value-function-prefix,\n.object-value-boolean{color:var(--sys-color-token-attribute-value)}.object-value-function{font-style:italic}.object-value-function.linkified:hover{--override-linkified-hover-background:rgb(0 0 0/10%);background-color:var(--override-linkified-hover-background);cursor:pointer}.-theme-with-dark-background .object-value-function.linkified:hover,\n:host-context(.-theme-with-dark-background) .object-value-function.linkified:hover{--override-linkified-hover-background:rgb(230 230 230/10%)}.object-value-number{color:var(--sys-color-token-attribute-value)}.object-value-bigint{color:var(--sys-color-token-comment)}.object-value-string,\n.object-value-regexp,\n.object-value-symbol{white-space:pre;unicode-bidi:-webkit-isolate;color:var(--sys-color-token-property-special)}.object-value-node{position:relative;vertical-align:baseline;color:var(--sys-color-token-variable);white-space:nowrap}.object-value-null,\n.object-value-undefined{color:var(--sys-color-state-disabled)}.object-value-unavailable{color:var(--sys-color-token-tag)}.object-value-calculate-value-button:hover{text-decoration:underline}.object-properties-section-custom-section{display:inline-flex;flex-direction:column}.-theme-with-dark-background .object-value-number,\n:host-context(.-theme-with-dark-background) .object-value-number,\n.-theme-with-dark-background .object-value-boolean,\n:host-context(.-theme-with-dark-background) .object-value-boolean{--override-primitive-dark-mode-color:hsl(252deg 100% 75%);color:var(--override-primitive-dark-mode-color)}.object-properties-section .object-description{color:var(--sys-color-token-subtle)}.value .object-properties-preview{white-space:nowrap}.name{color:var(--sys-color-token-tag);flex-shrink:0}.object-properties-preview .name{color:var(--sys-color-token-subtle)}@media (forced-colors: active){.object-value-calculate-value-button:hover{forced-color-adjust:none;color:Highlight}}\n/*# sourceURL=objectValue.css */\n");const En=new CSSStyleSheet;En.replaceSync(".watch-expression-delete-button{position:absolute;opacity:0%;right:0;.watch-expression-title:hover &{opacity:100%}}:host-context(.-theme-with-dark-background) .watch-expression-delete-button{filter:brightness(1.5)}.watch-expressions{min-height:26px}.watch-expression-title{white-space:nowrap;line-height:20px;display:flex}.watch-expression-title:hover{padding-right:26px}.watch-expression-object-header .watch-expression-title{margin-left:1px}.watch-expression{position:relative;flex:auto;min-height:20px}.watch-expression .name{color:var(--sys-color-purple);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:1000000;min-width:2em}.watch-expression-error{color:var(--sys-color-error)}.watch-expressions-separator{flex-shrink:0;flex-grow:0}.watch-expression .value{white-space:nowrap;display:inline;overflow:hidden;padding-left:4px;text-overflow:ellipsis;flex-shrink:1}.watch-expression .text-prompt{text-overflow:clip;overflow:hidden;white-space:nowrap;padding-left:4px;min-height:18px;line-height:18px;user-select:text}.watch-expression-text-prompt-proxy{margin:2px 12px 2px -4px;padding-bottom:3px}.watch-expression-header{flex:auto;margin-left:-16px;padding-left:15px}li.watch-expression-tree-item{padding-left:4px}li.watch-expression-tree-item.selected{background:var(--sys-color-neutral-container)}li.watch-expression-tree-item.selected:focus{background:var(--sys-color-tonal-container)}.watch-expression-header:focus-visible{background:var(--sys-color-tonal-container)}li.watch-expression-editing::before{background-color:transparent}@media (forced-colors: active){.watch-expression-title:hover .watch-expression-delete-button,\n .watch-expressions .dimmed{opacity:100%}li.watch-expression-tree-item *{forced-color-adjust:none;color:ButtonText}li.watch-expression-tree-item:hover{forced-color-adjust:none;background-color:Highlight}li.watch-expression-tree-item:hover *{color:HighlightText}li.watch-expression-tree-item:hover .watch-expression-delete-button{background-color:HighlightText}}\n/*# sourceURL=watchExpressionsSidebarPane.css */\n");const Ln={addWatchExpression:"Add watch expression",refreshWatchExpressions:"Refresh watch expressions",noWatchExpressions:"No watch expressions",deleteAllWatchExpressions:"Delete all watch expressions",addPropertyPathToWatch:"Add property path to watch",deleteWatchExpression:"Delete watch expression",notAvailable:"<not available>",copyValue:"Copy value"},Mn=e.i18n.registerUIStrings("panels/sources/WatchExpressionsSidebarPane.ts",Ln),Pn=e.i18n.getLocalizedString.bind(void 0,Mn);let Fn;class Dn extends t.ThrottledWidget.ThrottledWidget{watchExpressions;emptyElement;watchExpressionsSetting;addButton;refreshButton;treeOutline;expandController;linkifier;constructor(){super(!0),this.watchExpressions=[],this.watchExpressionsSetting=i.Settings.Settings.instance().createLocalSetting("watch-expressions",[]),this.addButton=new t.Toolbar.ToolbarButton(Pn(Ln.addWatchExpression),"plus",void 0,"add-watch-expression"),this.addButton.addEventListener("Click",(e=>{this.addButtonClicked()})),this.refreshButton=new t.Toolbar.ToolbarButton(Pn(Ln.refreshWatchExpressions),"refresh",void 0,"refresh-watch-expressions"),this.refreshButton.addEventListener("Click",this.update,this),this.contentElement.classList.add("watch-expressions"),this.contentElement.setAttribute("jslog",`${a.section("sources.watch")}`),this.contentElement.addEventListener("contextmenu",this.contextMenu.bind(this),!1),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),t.Context.Context.instance().addFlavorChangeListener(o.RuntimeModel.ExecutionContext,this.update,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.update,this),this.linkifier=new D.Linkifier.Linkifier,this.update()}static instance(){return Fn||(Fn=new Dn),Fn}toolbarItems(){return[this.addButton,this.refreshButton]}focus(){this.hasFocus()||this.watchExpressions.length>0&&this.treeOutline.forceSelect()}hasExpressions(){return Boolean(this.watchExpressionsSetting.get().length)}saveExpressions(){const e=[];for(let t=0;t<this.watchExpressions.length;t++){const i=this.watchExpressions[t].expression();i&&e.push(i)}this.watchExpressionsSetting.set(e)}async addButtonClicked(){await t.ViewManager.ViewManager.instance().showView("sources.watch"),this.emptyElement.classList.add("hidden"),this.createWatchExpression(null).startEditing()}async doUpdate(){this.linkifier.reset(),this.contentElement.removeChildren(),this.treeOutline.removeChildren(),this.watchExpressions=[],this.emptyElement=this.contentElement.createChild("div","gray-info-message"),this.emptyElement.textContent=Pn(Ln.noWatchExpressions),this.emptyElement.tabIndex=-1;const e=this.watchExpressionsSetting.get();e.length&&this.emptyElement.classList.add("hidden");for(let t=0;t<e.length;++t){const i=e[t];i&&this.createWatchExpression(i)}}createWatchExpression(e){this.contentElement.appendChild(this.treeOutline.element);const t=new Nn(e,this.expandController,this.linkifier);return t.addEventListener("ExpressionUpdated",this.watchExpressionUpdated,this),this.treeOutline.appendChild(t.treeElement()),this.watchExpressions.push(t),t}watchExpressionUpdated({data:e}){e.expression()||(l.ArrayUtilities.removeElement(this.watchExpressions,e),this.treeOutline.removeChild(e.treeElement()),this.emptyElement.classList.toggle("hidden",Boolean(this.watchExpressions.length)),0===this.watchExpressions.length&&this.treeOutline.element.remove()),this.saveExpressions()}contextMenu(e){const i=new t.ContextMenu.ContextMenu(e);this.populateContextMenu(i,e),i.show()}populateContextMenu(e,t){let i=!1;for(const e of this.watchExpressions)i=i||e.isEditing();i||e.debugSection().appendItem(Pn(Ln.addWatchExpression),this.addButtonClicked.bind(this),{jslogContext:"add-watch-expression"}),this.watchExpressions.length>1&&e.debugSection().appendItem(Pn(Ln.deleteAllWatchExpressions),this.deleteAllButtonClicked.bind(this),{jslogContext:"delete-all-watch-expressions"});const o=this.treeOutline.treeElementFromEvent(t);if(!o)return;const n=this.watchExpressions.find((e=>o.hasAncestorOrSelf(e.treeElement())));n&&n.populateContextMenu(e,t)}deleteAllButtonClicked(){this.watchExpressions=[],this.saveExpressions(),this.update()}async focusAndAddExpressionToWatch(e){await t.ViewManager.ViewManager.instance().showView("sources.watch"),this.createWatchExpression(e),this.saveExpressions(),this.update()}handleAction(e,i){const o=t.Context.Context.instance().flavor(Kt);if(!o)return!1;const{state:n}=o.textEditor,r=n.sliceDoc(n.selection.main.from,n.selection.main.to);return this.focusAndAddExpressionToWatch(r),!0}appendApplicableItems(e,t,i){i instanceof y.ObjectPropertiesSection.ObjectPropertyTreeElement?i.property.synthetic||t.debugSection().appendItem(Pn(Ln.addPropertyPathToWatch),(()=>this.focusAndAddExpressionToWatch(i.path())),{jslogContext:"add-property-path-to-watch"}):i.textEditor.state.selection.main.empty||t.debugSection().appendAction("sources.add-to-watch")}wasShown(){super.wasShown(),this.treeOutline.registerCSSFiles([En]),this.registerCSSFiles([En,Tn])}}class Nn extends i.ObjectWrapper.ObjectWrapper{treeElementInternal;nameElement;valueElement;expressionInternal;expandController;element;editing;linkifier;textPrompt;result;preventClickTimeout;constructor(e,t,i){super(),this.expressionInternal=e,this.expandController=t,this.element=document.createElement("div"),this.element.classList.add("watch-expression"),this.element.classList.add("monospace"),this.editing=!1,this.linkifier=i,this.createWatchExpression(),this.update()}treeElement(){return this.treeElementInternal}expression(){return this.expressionInternal}async#F(e,t){if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const i=e.debuggerModel.selectedCallFrame();if(i){const e=await p.NamesResolver.allVariablesInCallFrame(i);try{t=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(t,e)}catch{}}}return e.evaluate({expression:t,objectGroup:Nn.watchObjectGroupId,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1)}update(){const e=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);e&&this.expressionInternal?this.#F(e,this.expressionInternal).then((e=>{"object"in e?this.createWatchExpression(e.object,e.exceptionDetails):this.createWatchExpression()})):this.createWatchExpression()}startEditing(){this.editing=!0,this.treeElementInternal.setDisableSelectFocus(!0),this.element.removeChildren();const e=this.element.createChild("div");e.textContent=this.nameElement.textContent,this.textPrompt=new y.ObjectPropertiesSection.ObjectPropertyPrompt,this.textPrompt.renderAsBlock();const t=this.textPrompt.attachAndStartEditing(e,this.finishEditing.bind(this));this.treeElementInternal.listItemElement.classList.add("watch-expression-editing"),this.treeElementInternal.collapse(),t.classList.add("watch-expression-text-prompt-proxy"),t.addEventListener("keydown",this.promptKeyDown.bind(this),!1);const i=this.element.getComponentSelection();i&&i.selectAllChildren(e)}isEditing(){return Boolean(this.editing)}finishEditing(e,t){if(e&&e.consume(t),this.editing=!1,this.treeElementInternal.setDisableSelectFocus(!1),this.treeElementInternal.listItemElement.classList.remove("watch-expression-editing"),this.textPrompt){this.textPrompt.detach();const e=t?this.expressionInternal:this.textPrompt.text();this.textPrompt=void 0,this.element.removeChildren(),this.updateExpression(e)}}dblClickOnWatchExpression(e){e.consume(),this.isEditing()||this.startEditing()}updateExpression(e){this.expressionInternal&&this.expandController.stopWatchSectionsWithId(this.expressionInternal),this.expressionInternal=e,this.update(),this.dispatchEventToListeners("ExpressionUpdated",this)}deleteWatchExpression(e){e.consume(!0),this.updateExpression(null)}createWatchExpression(e,t){this.result=e||null,this.element.removeChildren();const i=this.treeElementInternal;if(this.createWatchExpressionTreeElement(e,t),i&&i.parent){const e=i.parent,t=e.indexOfChild(i);e.removeChild(i),e.insertChild(this.treeElementInternal,t)}this.treeElementInternal.select()}createWatchExpressionHeader(e,i){const o=this.element.createChild("div","watch-expression-header"),n=new A.Button.Button;n.variant="round",n.iconName="bin",n.className="watch-expression-delete-button",n.jslogContext="delete-watch-expression",n.size="SMALL",t.Tooltip.Tooltip.install(n,Pn(Ln.deleteWatchExpression)),n.addEventListener("click",this.deleteWatchExpression.bind(this),!1);const r=o.createChild("div","watch-expression-title tree-element-title");if(r.appendChild(n),this.nameElement=y.ObjectPropertiesSection.ObjectPropertiesSection.createNameElement(this.expressionInternal),t.Tooltip.Tooltip.install(this.nameElement,this.expressionInternal),Boolean(i)||!e)this.valueElement=document.createElement("span"),this.valueElement.classList.add("watch-expression-error"),this.valueElement.classList.add("value"),r.classList.add("dimmed"),this.valueElement.textContent=Pn(Ln.notAvailable),void 0!==i&&void 0!==i.exception&&void 0!==i.exception.description&&t.Tooltip.Tooltip.install(this.valueElement,i.exception.description);else{const t=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValueWithCustomSupport(e,Boolean(i),!1,r,this.linkifier);this.valueElement=t.element}const s=document.createElement("span");return s.classList.add("watch-expressions-separator"),s.textContent=": ",r.append(this.nameElement,s,this.valueElement),o}createWatchExpressionTreeElement(e,i){const o=this.createWatchExpressionHeader(e,i);!i&&e&&e.hasChildren&&!e.customPreview()?(o.classList.add("watch-expression-object-header"),this.treeElementInternal=new y.ObjectPropertiesSection.RootElement(e,this.linkifier),this.expandController.watchSection(this.expressionInternal,this.treeElementInternal),this.treeElementInternal.toggleOnClick=!1,this.treeElementInternal.listItemElement.addEventListener("click",this.onSectionClick.bind(this),!1),this.treeElementInternal.listItemElement.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this))):(o.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this)),this.treeElementInternal=new t.TreeOutline.TreeElement),this.treeElementInternal.title=this.element,this.treeElementInternal.listItemElement.classList.add("watch-expression-tree-item"),this.treeElementInternal.listItemElement.addEventListener("keydown",(e=>{"Enter"!==e.key||this.isEditing()?"Delete"!==e.key||this.isEditing()||this.deleteWatchExpression(e):(this.startEditing(),e.consume(!0))}))}onSectionClick(e){e.consume(!0);1===e.detail?this.preventClickTimeout=window.setTimeout(function(){if(!this.treeElementInternal)return;this.treeElementInternal.expanded?this.treeElementInternal.collapse():this.editing||this.treeElementInternal.expand()}.bind(this),333):void 0!==this.preventClickTimeout&&(window.clearTimeout(this.preventClickTimeout),this.preventClickTimeout=void 0)}promptKeyDown(e){const t=l.KeyboardUtilities.isEscKey(e);("Enter"===e.key||t)&&this.finishEditing(e,t)}populateContextMenu(e,i){this.isEditing()||e.editSection().appendItem(Pn(Ln.deleteWatchExpression),this.updateExpression.bind(this,null),{jslogContext:"delete-watch-expression"}),this.isEditing()||!this.result||"number"!==this.result.type&&"string"!==this.result.type||e.clipboardSection().appendItem(Pn(Ln.copyValue),this.copyValueButtonClicked.bind(this),{jslogContext:"copy-watch-expression-value"});const o=t.UIUtils.deepElementFromEvent(i);o&&this.valueElement.isSelfOrAncestor(o)&&this.result&&e.appendApplicableItems(this.result)}copyValueButtonClicked(){c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(this.valueElement.textContent)}static watchObjectGroupId="watch-group"}var An=Object.freeze({__proto__:null,WatchExpressionsSidebarPane:Dn,WatchExpression:Nn});export{W as AddSourceMapURLDialog,G as BreakpointEditDialog,_e as CSSPlugin,ne as CallStackSidebarPane,he as CategorizedBreakpointL10n,Te as CoveragePlugin,Ye as DebuggerPausedMessage,Bo as DebuggerPlugin,xt as EditingLocationHistoryManager,Vo as FilePathScoreFunction,zo as FilteredUISourceCodeListProvider,Jo as GoToLineQuickOpen,tn as InplaceFormatterEditorAction,Ct as NavigatorView,on as OpenFileQuickOpen,ln as OutlineQuickOpen,ge as Plugin,Ht as ResourceOriginPlugin,bn as ScopeChainSidebarPane,rt as SearchSourcesView,Gt as SnippetsPlugin,kn as SourcesNavigator,$i as SourcesPanel,it as SourcesSearchScope,Mi as SourcesView,vi as TabbedEditorContainer,Ui as ThreadsSidebarPane,ci as UISourceCodeFrame,An as WatchExpressionsSidebarPane}; diff --git a/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js b/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js index a8c37b3594bde3..19eed806043d24 100644 --- a/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js +++ b/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js @@ -1,4 +1,4 @@ -import*as e from"../../core/common/common.js";import*as t from"../../core/i18n/i18n.js";import*as i from"../../core/platform/platform.js";import*as n from"../../core/root/root.js";import*as s from"../../core/host/host.js";import*as o from"../visual_logging/visual_logging.js";import*as r from"../../models/text_utils/text_utils.js";import*as a from"../components/icon_button/icon_button.js";import*as l from"../components/adorners/adorners.js";import*as h from"../components/settings/settings.js";import*as d from"./utils/utils.js";export{d as Utils};import*as c from"../../core/dom_extension/dom_extension.js";import*as u from"../components/helpers/helpers.js";import*as m from"./theme_support/theme_support.js";import*as p from"../lit-html/lit-html.js";let g;class b{flavorsInternal;eventDispatchers;constructor(){this.flavorsInternal=new Map,this.eventDispatchers=new Map}static instance(e={forceNew:null}){const{forceNew:t}=e;return g&&!t||(g=new b),g}static removeInstance(){g=void 0}setFlavor(e,t){(this.flavorsInternal.get(e)||null)!==t&&(t?this.flavorsInternal.set(e,t):this.flavorsInternal.delete(e),this.dispatchFlavorChange(e,t))}dispatchFlavorChange(e,t){for(const i of f)i.contextTypes().includes(e)&&i.loadListener().then((e=>e.flavorChanged(t)));const i=this.eventDispatchers.get(e);i&&i.dispatchEventToListeners("FlavorChanged",t)}addFlavorChangeListener(t,i,n){let s=this.eventDispatchers.get(t);s||(s=new e.ObjectWrapper.ObjectWrapper,this.eventDispatchers.set(t,s)),s.addEventListener("FlavorChanged",i,n)}removeFlavorChangeListener(e,t,i){const n=this.eventDispatchers.get(e);n&&(n.removeEventListener("FlavorChanged",t,i),n.hasEventListeners("FlavorChanged")||this.eventDispatchers.delete(e))}flavor(e){return this.flavorsInternal.get(e)||null}flavors(){return new Set(this.flavorsInternal.keys())}}const f=[];var v=Object.freeze({__proto__:null,Context:b,registerListener:function(e){f.push(e)}});const w={elements:"Elements",screenshot:"Screenshot",network:"Network",memory:"Memory",javascript_profiler:"JavaScript Profiler",console:"Console",performance:"Performance",mobile:"Mobile",help:"Help",layers:"Layers",navigation:"Navigation",drawer:"Drawer",global:"Global",resources:"Resources",background_services:"Background Services",settings:"Settings",debugger:"Debugger",sources:"Sources",rendering:"Rendering",recorder:"Recorder",changes:"Changes"},x=t.i18n.registerUIStrings("ui/legacy/ActionRegistration.ts",w),E=t.i18n.getLocalizedString.bind(void 0,x);class I extends e.ObjectWrapper.ObjectWrapper{enabledInternal=!0;toggledInternal=!1;actionRegistration;constructor(e){super(),this.actionRegistration=e}id(){return this.actionRegistration.actionId}async execute(){if(!this.actionRegistration.loadActionDelegate)return!1;const e=await this.actionRegistration.loadActionDelegate(),t=this.id();return e.handleAction(b.instance(),t)}icon(){return this.actionRegistration.iconClass}toggledIcon(){return this.actionRegistration.toggledIconClass}toggleWithRedColor(){return Boolean(this.actionRegistration.toggleWithRedColor)}setEnabled(e){this.enabledInternal!==e&&(this.enabledInternal=e,this.dispatchEventToListeners("Enabled",e))}enabled(){return this.enabledInternal}category(){return this.actionRegistration.category}tags(){if(this.actionRegistration.tags)return this.actionRegistration.tags.map((e=>e())).join("\0")}toggleable(){return Boolean(this.actionRegistration.toggleable)}title(){let e=this.actionRegistration.title?this.actionRegistration.title():t.i18n.lockedString("");const i=this.actionRegistration.options;if(i)for(const t of i)t.value!==this.toggledInternal&&(e=t.title());return e}toggled(){return this.toggledInternal}setToggled(e){console.assert(this.toggleable(),"Shouldn't be toggling an untoggleable action",this.id()),this.toggledInternal!==e&&(this.toggledInternal=e,this.dispatchEventToListeners("Toggled",e))}options(){return this.actionRegistration.options}contextTypes(){if(this.actionRegistration.contextTypes)return this.actionRegistration.contextTypes()}canInstantiate(){return Boolean(this.actionRegistration.loadActionDelegate)}bindings(){return this.actionRegistration.bindings}experiment(){return this.actionRegistration.experiment}setting(){return this.actionRegistration.setting}condition(){return this.actionRegistration.condition}order(){return this.actionRegistration.order}}const y=new Map;function S(){y.clear()}function C(){return Array.from(y.values()).filter((t=>{const i=t.setting();try{if(i&&!e.Settings.moduleSetting(i).get())return!1}catch(e){if(e.message.startsWith("No setting registered"))return!1}return n.Runtime.Runtime.isDescriptorEnabled({experiment:t.experiment(),condition:t.condition()})})).sort(((e,t)=>(e.order()||0)-(t.order()||0)))}var T=Object.freeze({__proto__:null,Action:I,registerActionExtension:function(e){const t=e.actionId;if(y.has(t))throw new Error(`Duplicate action ID '${t}'`);if(!i.StringUtilities.isExtendedKebabCase(t))throw new Error(`Invalid action ID '${t}'`);y.set(t,new I(e))},reset:S,getRegisteredActionExtensions:C,maybeRemoveActionExtension:function(e){return y.delete(e)},getLocalizedActionCategory:function(e){switch(e){case"ELEMENTS":return E(w.elements);case"SCREENSHOT":return E(w.screenshot);case"NETWORK":return E(w.network);case"MEMORY":return E(w.memory);case"JAVASCRIPT_PROFILER":return E(w.javascript_profiler);case"CONSOLE":return E(w.console);case"PERFORMANCE":return E(w.performance);case"MOBILE":return E(w.mobile);case"HELP":return E(w.help);case"LAYERS":return E(w.layers);case"NAVIGATION":return E(w.navigation);case"DRAWER":return E(w.drawer);case"GLOBAL":return E(w.global);case"RESOURCES":return E(w.resources);case"BACKGROUND_SERVICES":return E(w.background_services);case"SETTINGS":return E(w.settings);case"DEBUGGER":return E(w.debugger);case"SOURCES":return E(w.sources);case"RENDERING":return E(w.rendering);case"RECORDER":return E(w.recorder);case"CHANGES":return E(w.changes);case"":return t.i18n.lockedString("")}return t.i18n.lockedString(e)}});let k;class M{actionsById;constructor(){this.actionsById=new Map,this.registerActions()}static instance(e={forceNew:null}){const{forceNew:t}=e;return k&&!t||(k=new M),k}static removeInstance(){k=void 0}static reset(){M.removeInstance(),S()}registerActions(){for(const e of C())this.actionsById.set(e.id(),e),e.canInstantiate()||e.setEnabled(!1)}availableActions(){return this.applicableActions([...this.actionsById.keys()],b.instance())}actions(){return[...this.actionsById.values()]}applicableActions(e,t){const i=[];for(const s of e){const e=this.actionsById.get(s);e&&e.enabled()&&n(e,t.flavors())&&i.push(e)}return i;function n(e,t){const i=e.contextTypes();if(!i)return!0;for(let e=0;e<i.length;++e){const n=i[e];if(Boolean(n)&&t.has(n))return!0}return!1}}hasAction(e){return this.actionsById.has(e)}getAction(e){const t=this.actionsById.get(e);if(t)return t;throw new Error(`Cannot find registered action with ID '${e}'`)}}var L=Object.freeze({__proto__:null,ActionRegistry:M});let P,D,A=0;function R(e){return(e||"")+ ++A}function B(e,t){const i=R("labelledControl");t.id=i,e.setAttribute("for",i)}function O(e){e.setAttribute("role","alert"),e.setAttribute("aria-live","polite")}function F(e){e.setAttribute("role","button")}function z(e){e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")}function W(e){e.setAttribute("role","group")}function H(e){e.setAttribute("role","link")}function N(e){F(e),e.setAttribute("aria-haspopup","true")}function _(e){e.setAttribute("role","tab")}function j(e){e.setAttribute("role","tabpanel")}function V(e){e.setAttribute("role","tree")}function U(e){e.setAttribute("role","treeitem")}function K(e){e.setAttribute("role","textbox")}function q(e){e.setAttribute("role","menu")}function $(e){e.setAttribute("role","menuitem")}function G(e){e.setAttribute("role","menuitemcheckbox")}function X(e){$(e),e.setAttribute("aria-haspopup","true")}function Y(e){e.setAttribute("role","complementary")}function Q(e){e.setAttribute("role","navigation")}function Z(e){e.setAttribute("role","listbox")}function J(e){e.setAttribute("aria-multiselectable","true")}function ee(e){e.setAttribute("role","option")}function te(e){e.setAttribute("aria-hidden","true")}function ie(e,t){e.setAttribute("role","heading"),e.setAttribute("aria-level",t.toString())}function ne(e){return e.hasAttribute("role")}function se(e,t){t?e.setAttribute("aria-placeholder",t):e.removeAttribute("aria-placeholder")}function oe(e){e.id||(e.id=R("ariaElement"))}function re(e,t){t?(oe(t),e.setAttribute("aria-controls",t.id)):e.removeAttribute("aria-controls")}function ae(e,t){e.setAttribute("aria-expanded",Boolean(t).toString())}function le(e){e.removeAttribute("aria-expanded")}function he(e,t="none"){e.setAttribute("aria-autocomplete",t)}function de(e){e.removeAttribute("aria-autocomplete")}function ce(e,t="false"){"false"!==t?e.setAttribute("aria-haspopup",t):e.removeAttribute("aria-haspopup")}function ue(e,t){e.setAttribute("aria-selected",Boolean(t).toString())}function me(e){e.removeAttribute("aria-selected")}function pe(e,t){t?e.setAttribute("aria-invalid",t.toString()):e.removeAttribute("aria-invalid")}function ge(e,t){e.setAttribute("aria-pressed",Boolean(t).toString())}function be(e,t){e.setAttribute("aria-label",t)}function fe(e,t){e.setAttribute("aria-description",t)}function ve(e,t){t?(t.isConnected&&e.isConnected&&console.assert(i.DOMUtilities.getEnclosingShadowRootForNode(t)===i.DOMUtilities.getEnclosingShadowRootForNode(e),"elements are not in the same shadow dom"),oe(t),e.setAttribute("aria-activedescendant",t.id)):e.removeAttribute("aria-activedescendant")}function we(e,t){e.setAttribute("aria-setsize",t.toString())}function xe(e,t){e.setAttribute("aria-posinset",t.toString())}function Ee(e){e.style.position="absolute",e.style.left="-999em",e.style.width="100em",e.style.overflow="hidden"}let Ie=!1;function ye(){if(!P){const e=document.body.createChild("div");Ee(e),e.setAttribute("role","alert"),e.setAttribute("aria-atomic","true"),P=e}if(!D){const e=document.body.createChild("div");Ee(e),e.setAttribute("role","alert"),e.setAttribute("aria-atomic","true"),D=e}return Ie=!Ie,Ie?(D.textContent="",P):(P.textContent="",D)}function Se(e){ye().textContent=i.StringUtilities.trimEndWithMaxLength(e,1e4)}var Ce=Object.freeze({__proto__:null,nextId:R,bindLabelToControl:B,markAsAlert:O,markAsApplication:function(e){e.setAttribute("role","application")},markAsButton:F,markAsCheckbox:function(e){e.setAttribute("role","checkbox")},markAsCombobox:function(e){e.setAttribute("role","combobox")},markAsModalDialog:z,markAsGroup:W,markAsLink:H,markAsMenuButton:N,markAsProgressBar:function(e,t=0,i=100){e.setAttribute("role","progressbar"),e.setAttribute("aria-valuemin",t.toString()),e.setAttribute("aria-valuemax",i.toString())},markAsTab:_,markAsTablist:function(e){e.setAttribute("role","tablist")},markAsTabpanel:j,markAsTree:V,markAsTreeitem:U,markAsTextBox:K,markAsMenu:q,markAsMenuItem:$,markAsMenuItemCheckBox:G,markAsMenuItemSubMenu:X,markAsList:function(e){e.setAttribute("role","list")},markAsListitem:function(e){e.setAttribute("role","listitem")},markAsMain:function(e){e.setAttribute("role","main")},markAsComplementary:Y,markAsNavigation:Q,markAsListBox:Z,markAsMultiSelectable:J,markAsOption:ee,markAsRadioGroup:function(e){e.setAttribute("role","radiogroup")},markAsHidden:te,markAsSlider:function(e,t=0,i=100){e.setAttribute("role","slider"),e.setAttribute("aria-valuemin",String(t)),e.setAttribute("aria-valuemax",String(i))},markAsHeading:ie,markAsPoliteLiveRegion:function(e,t){e.setAttribute("aria-live","polite"),t&&e.setAttribute("aria-atomic","true")},markAsLog:function(e){e.setAttribute("role","log")},hasRole:ne,removeRole:function(e){e.removeAttribute("role")},setPlaceholder:se,markAsPresentation:function(e){e.setAttribute("role","presentation")},markAsStatus:function(e){e.setAttribute("role","status")},ensureId:oe,setAriaValueText:function(e,t){e.setAttribute("aria-valuetext",t)},setAriaValueNow:function(e,t){e.setAttribute("aria-valuenow",t)},setAriaValueMinMax:function(e,t,i){e.setAttribute("aria-valuemin",t),e.setAttribute("aria-valuemax",i)},setControls:re,setChecked:function(e,t){e.setAttribute("aria-checked",Boolean(t).toString())},setCheckboxAsIndeterminate:function(e){e.setAttribute("aria-checked","mixed")},setDisabled:function(e,t){e.setAttribute("aria-disabled",Boolean(t).toString())},setExpanded:ae,unsetExpandable:le,setHidden:function(e,t){e.setAttribute("aria-hidden",Boolean(t).toString())},setLevel:function(e,t){e.setAttribute("aria-level",t.toString())},setAutocomplete:he,clearAutocomplete:de,setHasPopup:ce,setSelected:ue,clearSelected:me,setInvalid:pe,setPressed:ge,setValueNow:function(e,t){e.setAttribute("aria-valuenow",t.toString())},setValueText:function(e,t){e.setAttribute("aria-valuetext",t.toString())},setProgressBarValue:function(e,t,i){e.setAttribute("aria-valuenow",t.toString()),i&&e.setAttribute("aria-valuetext",i)},setLabel:be,setDescription:fe,setActiveDescendant:ve,setSetSize:we,setPositionInSet:xe,alertElementInstance:ye,alert:Se}),Te=Object.freeze({__proto__:null}),ke={cssContent:".widget{box-shadow:var(--drop-shadow);background:var(--sys-color-cdt-base-container);justify-content:flex-start;align-items:stretch;display:flex}.dialog-close-button{position:absolute;right:9px;top:9px;z-index:1}"},Me={cssContent:":host{position:absolute!important;top:0;bottom:0;left:0;right:0;overflow:hidden;contain:strict;background-color:transparent}:host-context(.dimmed-pane){background-color:var(--color-background-opacity-50)}:host-context(.no-pointer-events){pointer-events:none}.widget{display:flex;background-color:transparent;pointer-events:auto;flex:none}.no-pointer-events{pointer-events:none}.arrow{background-image:var(--image-file-popoverArrows);width:19px;height:19px}.arrow-top{background-position:0 76px;margin-top:-19px;margin-left:-9px}.arrow-bottom{background-position:0 57px;margin-left:-9px}.arrow-left{background-position:0 38px;margin-left:-19px;margin-top:-9px}.arrow-right{background-position:0 19px;margin-top:-9px}.arrow-none{display:none}:host-context(.-theme-with-dark-background) .arrow{filter:invert(80%)}"},Le={cssContent:":host{padding:0;margin:0;display:inline-flex;flex-shrink:0;align-items:center!important;overflow:hidden;white-space:nowrap}input{height:12px;width:12px;flex-shrink:0;accent-color:var(--sys-color-primary-bright);color:var(--sys-color-on-primary);&:focus{outline:auto 5px -webkit-focus-ring-color}}input.inside-datagrid{height:10px;width:10px}.dt-checkbox-text{margin-left:3px;overflow:hidden;text-overflow:ellipsis}.dt-checkbox-subtitle{color:var(--sys-color-token-subtle);white-space:break-spaces}@media (forced-colors: active){input.dt-checkbox-theme-preserve{forced-color-adjust:none}input.dt-checkbox-theme-preserve:active{background:HighlightText}input.dt-checkbox-theme-preserve:checked,\n input.dt-checkbox-theme-preserve:active:checked{background:Highlight;border-color:Highlight}input.dt-checkbox-theme-preserve:hover:enabled{border-color:Highlight}input.dt-checkbox-theme-preserve:active::before,\n input.dt-checkbox-theme-preserve:active::after{background-color:Highlight}input.dt-checkbox-theme-preserve:checked::before,\n input.dt-checkbox-theme-preserve:checked::after,\n input.dt-checkbox-theme-preserve:active:checked::before,\n input.dt-checkbox-theme-preserve:active:checked::after{background-color:HighlightText}input.dt-checkbox-theme-preserve:hover:checked::before,\n input.dt-checkbox-theme-preserve:hover:checked::after{background-color:Highlight!important}input.dt-checkbox-theme-preserve:hover:checked{background:HighlightText}}"},Pe={cssContent:".close-button{width:20px;height:20px;display:flex;align-items:center;justify-content:center}.close-button:hover devtools-icon,\n.close-button:focus-visible devtools-icon{color:var(--icon-default-hover)}.close-button:focus{outline:2px solid var(--sys-color-state-focus-ring)}@media (forced-colors: active) and (prefers-color-scheme: dark){.close-button{filter:brightness(100)}}"},De={cssContent:".widget{padding:20px;box-sizing:border-box;max-width:400px;overflow:hidden}.message{text-align:center}.message,\n.button{font-size:larger;white-space:pre;margin:10px 0}.button{text-align:center;margin-top:20px}.button button{min-width:100px}.reason{color:var(--sys-color-error);margin-top:10px}.message span{white-space:normal;word-wrap:break-word;max-width:100%;display:inline-block;overflow:hidden;text-overflow:ellipsis;padding:5px;margin:0}"};const Ae=1e-5;class Re{x;y;z;constructor(e,t,i){this.x=e,this.y=t,this.z=i}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const e=this.length();e<=Ae||(this.x/=e,this.y/=e,this.z/=e)}}class Be{x;y;constructor(e,t){this.x=e,this.y=t}distanceTo(e){return Math.sqrt(Math.pow(e.x-this.x,2)+Math.pow(e.y-this.y,2))}projectOn(e){return 0===e.x&&0===e.y?new Be(0,0):e.scale((this.x*e.x+this.y*e.y)/(Math.pow(e.x,2)+Math.pow(e.y,2)))}scale(e){return new Be(this.x*e,this.y*e)}toString(){return Math.round(100*this.x)/100+", "+Math.round(100*this.y)/100}}class Oe{controlPoints;constructor(e,t){this.controlPoints=[e,t]}static parse(e){const t=Oe.KeywordValues,i=e.toLowerCase().replace(/\s+/g,"");if(t.has(i))return Oe.parse(t.get(i));const n=i.match(/^cubic-bezier\(([^,]+),([^,]+),([^,]+),([^,]+)\)$/);if(n){const e=new Be(parseFloat(n[1]),parseFloat(n[2])),t=new Be(parseFloat(n[3]),parseFloat(n[4]));return new Oe(e,t)}return null}evaluateAt(e){function t(e,t,i){return 3*(1-i)*(1-i)*i*e+3*(1-i)*i*i*t+Math.pow(i,3)}const i=t(this.controlPoints[0].x,this.controlPoints[1].x,e),n=t(this.controlPoints[0].y,this.controlPoints[1].y,e);return new Be(i,n)}asCSSText(){const e="cubic-bezier("+this.controlPoints.join(", ")+")",t=Oe.KeywordValues;for(const[i,n]of t)if(e===n&&"linear"!==i)return i;return e}static Regex=/((cubic-bezier\([^)]+\))|\b(linear(?![-\(])|ease-in-out|ease-in|ease-out|ease)\b)|(linear\([^)]+\))/g;static KeywordValues=new Map([["linear","cubic-bezier(0, 0, 1, 1)"],["ease","cubic-bezier(0.25, 0.1, 0.25, 1)"],["ease-in","cubic-bezier(0.42, 0, 1, 1)"],["ease-in-out","cubic-bezier(0.42, 0, 0.58, 1)"],["ease-out","cubic-bezier(0, 0, 0.58, 1)"]])}const Fe=new Oe(new Be(0,0),new Be(1,1));class ze{alpha;beta;gamma;constructor(e,t,i){this.alpha=e,this.beta=t,this.gamma=i}static fromDeviceOrientationRotationMatrix(e){let t,i,n;return Math.abs(e.m33)<Ae?Math.abs(e.m13)<Ae?(t=Math.atan2(e.m12,e.m11),i=e.m23>0?Math.PI/2:-Math.PI/2,n=0):e.m13>0?(t=Math.atan2(-e.m21,e.m22),i=Math.asin(e.m23),n=-Math.PI/2):(t=Math.atan2(e.m21,-e.m22),i=-Math.asin(e.m23),i+=i>0||Math.abs(i)<Ae?-Math.PI:Math.PI,n=-Math.PI/2):e.m33>0?(t=Math.atan2(-e.m21,e.m22),i=Math.asin(e.m23),n=Math.atan2(-e.m13,e.m33)):(t=Math.atan2(e.m21,-e.m22),i=-Math.asin(e.m23),i+=i>0||Math.abs(i)<Ae?-Math.PI:Math.PI,n=Math.atan2(e.m13,-e.m33)),t<-Ae&&(t+=2*Math.PI),t=Number(Ne(t).toFixed(6)),i=Number(Ne(i).toFixed(6)),n=Number(Ne(n).toFixed(6)),new ze(t,i,n)}}const We=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},He=function(e,t){const i=e.x*t.m14+e.y*t.m24+e.z*t.m34+t.m44,n=(e.x*t.m11+e.y*t.m21+e.z*t.m31+t.m41)/i,s=(e.x*t.m12+e.y*t.m22+e.z*t.m32+t.m42)/i,o=(e.x*t.m13+e.y*t.m23+e.z*t.m33+t.m43)/i;return new Re(n,s,o)},Ne=function(e){return 180*e/Math.PI};class _e{width;height;constructor(e,t){this.width=e,this.height=t}clipTo(e){return e?new _e(Math.min(this.width,e.width),Math.min(this.height,e.height)):this}scale(e){return new _e(this.width*e,this.height*e)}isEqual(e){return null!==e&&this.width===e.width&&this.height===e.height}widthToMax(e){return new _e(Math.max(this.width,"number"==typeof e?e:e.width),this.height)}addWidth(e){return new _e(this.width+("number"==typeof e?e:e.width),this.height)}heightToMax(e){return new _e(this.width,Math.max(this.height,"number"==typeof e?e:e.height))}addHeight(e){return new _e(this.width,this.height+("number"==typeof e?e:e.height))}}class je{minimum;preferred;constructor(e,t){if(this.minimum=e||new _e(0,0),this.preferred=t||this.minimum,this.minimum.width>this.preferred.width||this.minimum.height>this.preferred.height)throw new Error("Minimum size is greater than preferred.")}isEqual(e){return null!==e&&this.minimum.isEqual(e.minimum)&&this.preferred.isEqual(e.preferred)}widthToMax(e){return"number"==typeof e?new je(this.minimum.widthToMax(e),this.preferred.widthToMax(e)):new je(this.minimum.widthToMax(e.minimum),this.preferred.widthToMax(e.preferred))}addWidth(e){return"number"==typeof e?new je(this.minimum.addWidth(e),this.preferred.addWidth(e)):new je(this.minimum.addWidth(e.minimum),this.preferred.addWidth(e.preferred))}heightToMax(e){return"number"==typeof e?new je(this.minimum.heightToMax(e),this.preferred.heightToMax(e)):new je(this.minimum.heightToMax(e.minimum),this.preferred.heightToMax(e.preferred))}addHeight(e){return"number"==typeof e?new je(this.minimum.addHeight(e),this.preferred.addHeight(e)):new je(this.minimum.addHeight(e.minimum),this.preferred.addHeight(e.preferred))}}var Ve=Object.freeze({__proto__:null,_Eps:Ae,Vector:Re,Point:Be,CubicBezier:Oe,LINEAR_BEZIER:Fe,EulerAngles:ze,scalarProduct:We,crossProduct:function(e,t){const i=e.y*t.z-e.z*t.y,n=e.z*t.x-e.x*t.z,s=e.x*t.y-e.y*t.x;return new Re(i,n,s)},subtract:function(e,t){const i=e.x-t.x,n=e.y-t.y,s=e.z-t.z;return new Re(i,n,s)},multiplyVectorByMatrixAndNormalize:He,calculateAngle:function(e,t){const i=e.length(),n=t.length();if(i<=Ae||n<=Ae)return 0;const s=We(e,t)/i/n;return Math.abs(s)>1?0:Ne(Math.acos(s))},degreesToRadians:function(e){return e*Math.PI/180},degreesToGradians:function(e){return e/9*10},degreesToTurns:function(e){return e/360},radiansToDegrees:Ne,radiansToGradians:function(e){return 200*e/Math.PI},radiansToTurns:function(e){return e/(2*Math.PI)},gradiansToRadians:function(e){return e*Math.PI/200},turnsToRadians:function(e){return 2*e*Math.PI},boundsForTransformedPoints:function(e,t,i){i||(i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0}),t.length%3&&console.warn("Invalid size of points array");for(let n=0;n<t.length;n+=3){let s=new Re(t[n],t[n+1],t[n+2]);s=He(s,e),i.minX=Math.min(i.minX,s.x),i.maxX=Math.max(i.maxX,s.x),i.minY=Math.min(i.minY,s.y),i.maxY=Math.max(i.maxY,s.y)}return i},Size:_e,Constraints:je}),Ue={cssContent:":host{display:inline-flex;border:1px solid var(--sys-color-neutral-outline);border-radius:4px;position:relative;vertical-align:sub;margin:2px;background-color:var(--sys-color-cdt-base-container);justify-content:center;width:28px}:host:hover{border:none;background-color:var(--sys-color-state-hover-on-subtle)}"};class Ke{descriptors;action;type;keybindSets;constructor(e,t,i,n){this.descriptors=e,this.action=t,this.type=i,this.keybindSets=n||new Set}title(){return this.descriptors.map((e=>e.name)).join(" ")}isDefault(){return"DefaultShortcut"===this.type||"DisabledDefault"===this.type||"KeybindSetShortcut"===this.type&&this.keybindSets.has(Hs)}changeType(e){return new Ke(this.descriptors,this.action,e)}changeKeys(e){return this.descriptors=e,this}descriptorsMatch(e){return e.length===this.descriptors.length&&e.every(((e,t)=>e.key===this.descriptors[t].key))}hasKeybindSet(e){return!this.keybindSets||this.keybindSets.has(e)}equals(e){return this.descriptorsMatch(e.descriptors)&&this.type===e.type&&this.action===e.action}static createShortcutFromSettingObject(e){return new Ke(e.descriptors,e.action,e.type)}static makeKey(e,t){return"string"==typeof e&&(e=e.charCodeAt(0)-(/^[a-z]/.test(e)?32:0)),t=t||qe.None,Ke.makeKeyFromCodeAndModifiers(e,t)}static makeKeyFromEvent(e){let t=qe.None;e.shiftKey&&(t|=qe.Shift),e.ctrlKey&&(t|=qe.Ctrl),e.altKey&&(t|=qe.Alt),e.metaKey&&(t|=qe.Meta);const i=e.keyCode||e.__keyCode;return Ke.makeKeyFromCodeAndModifiers(i,t)}static makeKeyFromEventIgnoringModifiers(e){const t=e.keyCode||e.__keyCode;return Ke.makeKeyFromCodeAndModifiers(t,qe.None)}static eventHasCtrlEquivalentKey(e){return s.Platform.isMac()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}static eventHasEitherCtrlOrMeta(e){return e.metaKey||e.ctrlKey}static hasNoModifiers(e){const t=e;return!(t.ctrlKey||t.shiftKey||t.altKey||t.metaKey)}static makeDescriptor(e,t){return{key:Ke.makeKey("string"==typeof e?e:e.code,t),name:Ke.shortcutToString(e,t)}}static makeDescriptorFromBindingShortcut(e){const[t,...i]=e.split(/\+(?!$)/).reverse();let n=0;for(const t of i){const i=qe[t];console.assert(void 0!==i,`Only one key other than modifier is allowed in shortcut <${e}>`),n|=i}console.assert(t.length>0,`Modifiers-only shortcuts are not allowed (encountered <${e}>)`);const s=nt[t]||st[t];return s&&"shiftKey"in s&&s.shiftKey&&(n|=qe.Shift),Ke.makeDescriptor(s||t,n)}static shortcutToString(e,t){return"string"!=typeof e&&Ke.isModifier(e.code)?Ke.modifiersToString(t):Ke.modifiersToString(t)+Ke.keyName(e)}static keyName(e){return"string"==typeof e?e.toUpperCase():"string"==typeof e.name?e.name:e.name[s.Platform.platform()]||e.name.other||""}static makeKeyFromCodeAndModifiers(e,t){return 255&e|(t||0)<<8}static keyCodeAndModifiersFromKey(e){return{keyCode:255&e,modifiers:e>>8}}static isModifier(e){const{keyCode:t}=Ke.keyCodeAndModifiersFromKey(e);return t===nt.Shift.code||t===nt.Ctrl.code||t===nt.Alt.code||t===nt.Meta.code}static modifiersToString(e){const t=s.Platform.isMac(),i=qe,n=new Map([[i.Ctrl,t?"Ctrl ":"Ctrl + "],[i.Alt,t?"⌥ ":"Alt + "],[i.Shift,t?"⇧ ":"Shift + "],[i.Meta,t?"⌘ ":"Win + "]]);return[i.Meta,i.Ctrl,i.Alt,i.Shift].map((function(t){return(e||0)&t?n.get(t):""})).join("")}}const qe={None:0,Shift:1,Ctrl:2,Alt:4,Meta:8,CtrlOrMeta:s.Platform.isMac()?8:2,ShiftOrOption:s.Platform.isMac()?4:1},$e={code:37,name:"←"},Ge={code:38,name:"↑"},Xe={code:39,name:"→"},Ye={code:40,name:"↓"},Qe={code:17,name:"Ctrl"},Ze={code:27,name:"Esc"},Je={code:32,name:"Space"},et={code:187,name:"+"},tt={code:192,name:"`"},it={code:222,name:"'"},nt={Backspace:{code:8,name:"↤"},Tab:{code:9,name:{mac:"⇥",other:"Tab"}},Enter:{code:13,name:{mac:"↩",other:"Enter"}},Shift:{code:16,name:{mac:"⇧",other:"Shift"}},Ctrl:Qe,Control:Qe,Alt:{code:18,name:"Alt"},Esc:Ze,Escape:Ze,Space:Je," ":Je,PageUp:{code:33,name:{mac:"⇞",other:"PageUp"}},PageDown:{code:34,name:{mac:"⇟",other:"PageDown"}},End:{code:35,name:{mac:"↗",other:"End"}},Home:{code:36,name:{mac:"↖",other:"Home"}},Left:$e,Up:Ge,Right:Xe,Down:Ye,ArrowLeft:$e,ArrowUp:Ge,ArrowRight:Xe,ArrowDown:Ye,Delete:{code:46,name:"Del"},Zero:{code:48,name:"0"},H:{code:72,name:"H"},N:{code:78,name:"N"},P:{code:80,name:"P"},Meta:{code:91,name:"Meta"},F1:{code:112,name:"F1"},F2:{code:113,name:"F2"},F3:{code:114,name:"F3"},F4:{code:115,name:"F4"},F5:{code:116,name:"F5"},F6:{code:117,name:"F6"},F7:{code:118,name:"F7"},F8:{code:119,name:"F8"},F9:{code:120,name:"F9"},F10:{code:121,name:"F10"},F11:{code:122,name:"F11"},F12:{code:123,name:"F12"},Semicolon:{code:186,name:";"},NumpadPlus:{code:107,name:"Numpad +"},NumpadMinus:{code:109,name:"Numpad -"},Numpad0:{code:96,name:"Numpad 0"},Plus:et,Equal:et,Comma:{code:188,name:","},Minus:{code:189,name:"-"},Period:{code:190,name:"."},Slash:{code:191,name:"/"},QuestionMark:{code:191,name:"?"},Apostrophe:tt,Tilde:{code:192,name:"Tilde"},Backquote:tt,IntlBackslash:tt,LeftSquareBracket:{code:219,name:"["},RightSquareBracket:{code:221,name:"]"},Backslash:{code:220,name:"\\"},SingleQuote:it,Quote:it,get CtrlOrMeta(){return s.Platform.isMac()?this.Meta:this.Ctrl}},st={};!function(){for(const e in nt){const t=nt[e];if("object"==typeof t&&t.code){const i="string"==typeof t.name?t.name:e;st[i]=t}}}();var ot=Object.freeze({__proto__:null,KeyboardShortcut:Ke,Modifiers:qe,Keys:nt,KeyBindings:st}),rt={cssContent:"::slotted(input.dt-radio-button){height:17px;width:17px;min-width:17px;border-radius:8px;vertical-align:middle;margin:0 5px 5px 0;accent-color:var(--sys-color-primary-bright);color:var(--sys-color-on-primary)}::slotted(input.dt-radio-button:focus){box-shadow:var(--legacy-focus-ring-active-shadow)}@media (forced-colors: active){::slotted(input.dt-radio-button){--gradient-start:ButtonFace;--gradient-end:ButtonFace}::slotted(input.dt-radio-button:checked){--gradient-start:Highlight;--gradient-end:Highlight}}"},at={cssContent:".dt-range-input{appearance:none;margin:0;padding:0;height:10px;width:88px;outline:none;background:none}.dt-range-input::-webkit-slider-thumb,\n.-theme-preserve{appearance:none;margin:0;padding:0;border:0;width:12px;height:12px;margin-top:-5px;border-radius:50%;background-color:var(--sys-color-primary)}.dt-range-input::-webkit-slider-runnable-track{appearance:none;margin:0;padding:0;width:100%;height:2px;background-color:var(--sys-color-surface-variant)}.dt-range-input:focus::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--sys-color-inverse-primary)}.dt-range-input:disabled::-webkit-slider-thumb{background-color:var(--sys-color-state-disabled)}@media (forced-colors: active){.dt-range-input{forced-color-adjust:none}}"},lt={cssContent:"div{display:inline-flex;height:14px;align-items:center;vertical-align:middle;white-space:nowrap;padding:1px 4px;text-align:left;font-size:11px;line-height:normal;font-weight:bold;text-shadow:none;color:var(--sys-color-inverse-on-surface);border-radius:7px}div.verbose{background-color:var(--sys-color-token-attribute-value)}:host-context(.-theme-with-dark-background) div.verbose{background-color:var(--sys-color-token-tag)}div.info{background-color:var(--sys-color-token-meta)}div.warning{background-color:var(--sys-color-token-attribute)}:host-context(.-theme-with-dark-background) div.warning{background-color:var(--sys-color-token-attribute-value)}div.error{background-color:var(--sys-color-error-bright)}"};const ht={close:"Close",dockToRight:"Dock to right",dockToBottom:"Dock to bottom",dockToLeft:"Dock to left",undockIntoSeparateWindow:"Undock into separate window",devtoolsUndocked:"DevTools is undocked",devToolsDockedTo:"DevTools is docked to {PH1}"},dt=t.i18n.registerUIStrings("ui/legacy/DockController.ts",ht),ct=t.i18n.getLocalizedString.bind(void 0,dt);let ut;class mt extends e.ObjectWrapper.ObjectWrapper{canDockInternal;closeButton;currentDockStateSetting;lastDockStateSetting;dockSideInternal=void 0;titles;savedFocus;constructor(t){if(super(),this.canDockInternal=t,this.closeButton=new wn(ct(ht.close),"cross"),this.closeButton.element.setAttribute("jslog",`${o.close().track({click:!0})}`),this.closeButton.element.classList.add("close-devtools"),this.closeButton.addEventListener("Click",s.InspectorFrontendHost.InspectorFrontendHostInstance.closeWindow.bind(s.InspectorFrontendHost.InspectorFrontendHostInstance)),this.currentDockStateSetting=e.Settings.Settings.instance().moduleSetting("currentDockState"),this.lastDockStateSetting=e.Settings.Settings.instance().createSetting("last-dock-state","bottom"),!t)return this.dockSideInternal="undocked",void this.closeButton.setVisible(!1);this.currentDockStateSetting.addChangeListener(this.dockSideChanged,this),-1===pt.indexOf(this.currentDockStateSetting.get())&&this.currentDockStateSetting.set("right"),-1===pt.indexOf(this.lastDockStateSetting.get())&&this.currentDockStateSetting.set("bottom")}static instance(e={forceNew:null,canDock:!1}){const{forceNew:t,canDock:i}=e;return ut&&!t||(ut=new mt(i)),ut}initialize(){this.canDockInternal&&(this.titles=[ct(ht.dockToRight),ct(ht.dockToBottom),ct(ht.dockToLeft),ct(ht.undockIntoSeparateWindow)],this.dockSideChanged())}dockSideChanged(){this.setDockSide(this.currentDockStateSetting.get()),setTimeout(this.announceDockLocation.bind(this),2e3)}dockSide(){return this.dockSideInternal}canDock(){return this.canDockInternal}isVertical(){return"right"===this.dockSideInternal||"left"===this.dockSideInternal}setDockSide(e){if(-1===pt.indexOf(e)&&(e=pt[0]),this.dockSideInternal===e)return;void 0!==this.dockSideInternal&&document.body.classList.remove(this.dockSideInternal),document.body.classList.add(e),this.dockSideInternal&&this.lastDockStateSetting.set(this.dockSideInternal),this.savedFocus=i.DOMUtilities.deepActiveElement(document);const t={from:this.dockSideInternal,to:e};this.dispatchEventToListeners("BeforeDockSideChanged",t),console.timeStamp("DockController.setIsDocked"),this.dockSideInternal=e,this.currentDockStateSetting.set(e),s.InspectorFrontendHost.InspectorFrontendHostInstance.setIsDocked("undocked"!==e,this.setIsDockedResponse.bind(this,t)),this.closeButton.setVisible("undocked"!==this.dockSideInternal),this.dispatchEventToListeners("DockSideChanged",t)}setIsDockedResponse(e){this.dispatchEventToListeners("AfterDockSideChanged",e),this.savedFocus&&(this.savedFocus.focus(),this.savedFocus=null)}toggleDockSide(){if(this.lastDockStateSetting.get()===this.currentDockStateSetting.get()){const e=pt.indexOf(this.currentDockStateSetting.get())||0;this.lastDockStateSetting.set(pt[(e+1)%pt.length])}this.setDockSide(this.lastDockStateSetting.get())}announceDockLocation(){"undocked"===this.dockSideInternal?Se(ct(ht.devtoolsUndocked)):Se(ct(ht.devToolsDockedTo,{PH1:this.dockSideInternal||""}))}}const pt=["right","bottom","left","undocked"];let gt;class bt{static instance(e={forceNew:null}){const{forceNew:t}=e;return gt&&!t||(gt=new bt),gt}item(){return mt.instance().closeButton}}var ft=Object.freeze({__proto__:null,DockController:mt,ToggleDockActionDelegate:class{handleAction(e,t){return mt.instance().toggleDockSide(),!0}},CloseButtonProvider:bt}),vt={cssContent:".infobar{color:var(--sys-color-on-surface);display:flex;flex:auto;flex-direction:column;position:relative;padding:6px;min-width:fit-content}.infobar:focus{outline:2px solid var(--sys-color-state-focus-ring);outline-offset:-2px}.infobar-warning{background-color:var(--sys-color-surface-yellow);color:var(--sys-color-on-surface-yellow)}.infobar-error{--override-infobar-error-background:var(--sys-color-surface-error);--override-infobar-error-text:var(--sys-color-on-surface-error);background-color:var(--override-infobar-error-background);color:var(--override-infobar-error-text)}.infobar-main-row{display:flex;flex-direction:row;justify-content:flex-start;min-height:25px}.infobar-info-container{display:flex;align-items:center;flex-grow:1;flex-wrap:wrap}.infobar-info-message{display:flex;margin:5px 0}.infobar-info-text{display:flex;align-items:center;margin:0 4px}.infobar-details-rows{padding:5px 5px 0}.infobar-details-row{display:flex;flex-direction:column;line-height:18px;padding-bottom:6px}.infobar-close-container{display:flex;flex-shrink:0;align-items:center}.infobar-close-container > .infobar-button.link-style{margin:4px}.infobar-selectable{user-select:text}.infobar-button{color:var(--sys-color-token-subtle);padding:0 4px}.info-icon{mask-image:var(--image-file-info);background-color:var(--icon-info)}.warning-icon{mask-image:var(--image-file-warning);background-color:var(--icon-warning)}.error-icon{mask-image:var(--image-file-cross-circle);background-color:var(--icon-error)}.issue-icon{mask-image:var(--image-file-issue-text-filled);background-color:var(--icon-info)}.icon{mask-size:20px 20px;width:20px;height:20px;flex-shrink:0}.devtools-link.text-button:hover,\n.devtools-link.text-button:focus,\n.devtools-link.text-button:active{background-color:transparent;box-shadow:none}"};const wt={dontShowAgain:"Don't show again",showMore:"Show more",close:"Close"},xt=t.i18n.registerUIStrings("ui/legacy/Infobar.ts",wt),Et=t.i18n.getLocalizedString.bind(void 0,xt);class It{element;shadowRoot;contentElement;mainRow;detailsRows;hasDetails;detailsMessage;infoContainer;infoMessage;infoText;actionContainer;disableSetting;closeContainer;toggleElement;closeButton;closeCallback;#e=null;parentView;constructor(e,t,i,n,s=!0,r){if(this.element=document.createElement("div"),r&&this.element.setAttribute("jslog",`${o.dialog(r).track({resize:!0})}`),this.element.classList.add("flex-none"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:vt,delegatesFocus:void 0}),this.contentElement=this.shadowRoot.createChild("div","infobar infobar-"+e),this.mainRow=this.contentElement.createChild("div","infobar-main-row"),this.detailsRows=this.contentElement.createChild("div","infobar-details-rows hidden"),this.hasDetails=!1,this.detailsMessage="",this.infoContainer=this.mainRow.createChild("div","infobar-info-container"),this.infoMessage=this.infoContainer.createChild("div","infobar-info-message"),this.infoMessage.createChild("div",e+"-icon icon"),this.infoText=this.infoMessage.createChild("div","infobar-info-text"),this.infoText.textContent=t,O(this.infoText),this.actionContainer=this.infoContainer.createChild("div","infobar-info-actions"),i){this.contentElement.setAttribute("role","group");for(const e of i){const t=this.actionCallbackFactory(e);let i="infobar-button";e.highlight&&(i+=" primary-button");const n=os(e.text,t,{className:i,jslogContext:e.jslogContext});e.highlight&&!this.#e&&(this.#e=n),this.actionContainer.appendChild(n)}}if(this.disableSetting=n||null,n){const e=os(Et(wt.dontShowAgain),this.onDisable.bind(this),{className:"infobar-button"});this.actionContainer.appendChild(e)}this.closeContainer=this.mainRow.createChild("div","infobar-close-container"),this.toggleElement=os(Et(wt.showMore),this.onToggleDetails.bind(this),{className:"link-style devtools-link hidden",jslogContext:"show-more"}),this.toggleElement.setAttribute("role","link"),this.closeContainer.appendChild(this.toggleElement),this.closeButton=this.closeContainer.createChild("div","close-button","dt-close-button"),this.closeButton.hidden=!s,this.closeButton.setTabbable(!0),fe(this.closeButton,Et(wt.close)),self.onInvokeElement(this.closeButton,this.dispose.bind(this)),"issue"!==e&&(this.contentElement.tabIndex=0),be(this.contentElement,t),this.contentElement.addEventListener("keydown",(e=>e.keyCode===nt.Esc.code?(this.dispose(),void e.consume()):e.target===this.contentElement&&"Enter"===e.key&&this.hasDetails?(this.onToggleDetails(),void e.consume()):void 0)),this.closeCallback=null}static create(e,t,i,n,s){return n&&n.get()?null:new It(e,t,i,n,void 0,s)}dispose(){this.element.remove(),this.onResize(),this.closeCallback&&this.closeCallback.call(null)}setText(e){this.infoText.textContent=e,this.onResize()}setCloseCallback(e){this.closeCallback=e}setParentView(e){this.parentView=e}actionCallbackFactory(e){return e.delegate?e.dismiss?(()=>{e.delegate&&e.delegate(),this.dispose()}).bind(this):e.delegate:e.dismiss?this.dispose.bind(this):()=>{}}onResize(){this.parentView&&this.parentView.doResize()}onDisable(){this.disableSetting&&this.disableSetting.set(!0),this.dispose()}onToggleDetails(){this.detailsRows.classList.remove("hidden"),this.toggleElement.remove(),this.onResize(),Se("string"==typeof this.detailsMessage?this.detailsMessage:this.detailsMessage.textContent||""),this.#e?this.#e.focus():this.closeButton.focus()}createDetailsRowMessage(e){this.hasDetails=!0,this.detailsMessage=e,this.toggleElement.classList.remove("hidden");const t=this.detailsRows.createChild("div","infobar-details-row").createChild("span","infobar-row-message");return"string"==typeof e?t.textContent=e:t.appendChild(e),t}}var yt=Object.freeze({__proto__:null,Infobar:It}),St={cssContent:".tabbed-pane-header-tab{height:26px;margin:0;border:none;border-left:2px solid transparent;border-right:2px solid transparent;&.selected{border-width:0 2px}& > .tabbed-pane-header-tab-icon > devtools-icon{width:14px;height:14px;color:var(--icon-warning)}}.tabbed-pane-header-contents{margin-left:0;min-width:min-content}.tabbed-pane-left-toolbar{margin-right:0!important}"};class Ct extends e.ObjectWrapper.ObjectWrapper{isEnabledInternal;elementsInternal;installDragOnMouseDownBound;cursorInternal;startX;startY;constructor(){super(),this.isEnabledInternal=!0,this.elementsInternal=new Set,this.installDragOnMouseDownBound=this.installDragOnMouseDown.bind(this),this.cursorInternal="nwse-resize"}isEnabled(){return this.isEnabledInternal}setEnabled(e){this.isEnabledInternal=e,this.updateElementCursors()}elements(){return[...this.elementsInternal]}addElement(e){this.elementsInternal.has(e)||(this.elementsInternal.add(e),e.addEventListener("pointerdown",this.installDragOnMouseDownBound,!1),this.updateElementCursor(e))}removeElement(e){this.elementsInternal.has(e)&&(this.elementsInternal.delete(e),e.removeEventListener("pointerdown",this.installDragOnMouseDownBound,!1),e.style.removeProperty("cursor"))}updateElementCursors(){this.elementsInternal.forEach(this.updateElementCursor.bind(this))}updateElementCursor(e){this.isEnabledInternal?(e.style.setProperty("cursor",this.cursor()),e.style.setProperty("touch-action","none")):(e.style.removeProperty("cursor"),e.style.removeProperty("touch-action"))}cursor(){return this.cursorInternal}setCursor(e){this.cursorInternal=e,this.updateElementCursors()}installDragOnMouseDown(e){const t=e.target;if(!this.elementsInternal.has(t))return!1;Rn(t,this.dragStart.bind(this),(e=>{this.drag(e)}),this.dragEnd.bind(this),this.cursor(),e)}dragStart(e){return!!this.isEnabledInternal&&(this.startX=e.pageX,this.startY=e.pageY,this.sendDragStart(this.startX,this.startY),!0)}sendDragStart(e,t){this.dispatchEventToListeners("ResizeStart",{startX:e,currentX:e,startY:t,currentY:t})}drag(e){return this.isEnabledInternal?(this.sendDragMove(this.startX,e.pageX,this.startY,e.pageY,e.shiftKey),e.preventDefault(),!1):(this.dragEnd(e),!0)}sendDragMove(e,t,i,n,s){this.dispatchEventToListeners("ResizeUpdateXY",{startX:e,currentX:t,startY:i,currentY:n,shiftKey:s})}dragEnd(e){this.dispatchEventToListeners("ResizeEnd"),delete this.startX,delete this.startY}}class Tt extends Ct{isVerticalInternal;constructor(){super(),this.isVerticalInternal=!0}isVertical(){return this.isVerticalInternal}setVertical(e){this.isVerticalInternal=e,this.updateElementCursors()}cursor(){return this.isVerticalInternal?"ns-resize":"ew-resize"}sendDragStart(e,t){const i=this.isVerticalInternal?t:e;this.dispatchEventToListeners("ResizeStart",{startPosition:i,currentPosition:i})}sendDragMove(e,t,i,n,s){this.isVerticalInternal?this.dispatchEventToListeners("ResizeUpdatePosition",{startPosition:i,currentPosition:n,shiftKey:s}):this.dispatchEventToListeners("ResizeUpdatePosition",{startPosition:e,currentPosition:t,shiftKey:s})}}var kt=Object.freeze({__proto__:null,ResizerWidget:Ct,SimpleResizerWidget:Tt}),Mt={cssContent:".shadow-split-widget{display:flex;overflow:hidden}.shadow-split-widget-contents{display:flex;position:relative;flex-direction:column;contain:layout size style}.shadow-split-widget-sidebar{flex:none}.shadow-split-widget-main,\n.shadow-split-widget-sidebar.maximized{flex:auto}.shadow-split-widget.hbox > .shadow-split-widget-resizer{position:absolute;top:0;bottom:0;width:6px;z-index:4000}.shadow-split-widget.vbox > .shadow-split-widget-resizer{position:absolute;left:0;right:0;height:6px;z-index:4000}.shadow-split-widget.vbox > .shadow-split-widget-sidebar.no-default-splitter{border:0!important}.shadow-split-widget.vbox > .shadow-split-widget-sidebar:not(.maximized){border:0;border-top:1px solid var(--sys-color-divider)}.shadow-split-widget.hbox > .shadow-split-widget-sidebar:not(.maximized){border:0;border-left:1px solid var(--sys-color-divider)}.shadow-split-widget.vbox > .shadow-split-widget-sidebar:first-child:not(.maximized){border:0;border-bottom:1px solid var(--sys-color-divider)}.shadow-split-widget.hbox > .shadow-split-widget-sidebar:first-child:not(.maximized){border:0;border-right:1px solid var(--sys-color-divider)}:host-context(.disable-resizer-for-elements-hack) .shadow-split-widget-resizer{pointer-events:none}"};class Lt extends HTMLElement{static get observedAttributes(){return["flex","padding","padding-top","padding-bottom","padding-left","padding-right","margin","margin-top","margin-bottom","margin-left","margin-right","overflow","overflow-x","overflow-y","font-size","color","background","background-color","border","border-top","border-bottom","border-left","border-right","max-width","max-height"]}attributeChangedCallback(e,t,i){if("flex"!==e)if(null===i){if(this.style.removeProperty(e),e.startsWith("padding-")||e.startsWith("margin-")||e.startsWith("border-")||e.startsWith("background-")||e.startsWith("overflow-")){const t=e.substring(0,e.indexOf("-")),i=this.getAttribute(t);null!==i&&this.style.setProperty(t,i)}}else this.style.setProperty(e,i);else null===i?this.style.removeProperty("flex"):"initial"===i||"auto"===i||"none"===i||-1!==i.indexOf(" ")?this.style.setProperty("flex",i):this.style.setProperty("flex","0 0 "+i)}}class Pt extends Lt{constructor(e){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction",e),this.style.setProperty("justify-content","flex-start")}static get observedAttributes(){return super.observedAttributes.concat(["x-start","x-center","x-stretch","x-baseline","justify-content"])}attributeChangedCallback(e,t,i){"x-start"!==e&&"x-center"!==e&&"x-stretch"!==e&&"x-baseline"!==e?super.attributeChangedCallback(e,t,i):null===i?this.style.removeProperty("align-items"):this.style.setProperty("align-items","x-start"===e?"flex-start":e.substr(2))}}customElements.define("x-vbox",class extends Pt{constructor(){super("column")}}),customElements.define("x-hbox",class extends Pt{constructor(){super("row")}}),customElements.define("x-cbox",class extends Lt{constructor(){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction","column"),this.style.setProperty("justify-content","center"),this.style.setProperty("align-items","center")}}),customElements.define("x-div",class extends Lt{constructor(){super(),this.style.setProperty("display","block")}}),customElements.define("x-span",class extends Lt{constructor(){super(),this.style.setProperty("display","inline")}}),customElements.define("x-text",class extends Lt{constructor(){super(),this.style.setProperty("display","inline"),this.style.setProperty("white-space","pre")}});var Dt=Object.freeze({__proto__:null,XElement:Lt});let At=null;const Rt=new WeakMap;class Bt extends Lt{visible;shadowRootInternal;defaultFocusedElement;elementsToRestoreScrollPositionsFor;onShownCallback;onHiddenCallback;onResizedCallback;constructor(){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction","column"),this.style.setProperty("align-items","stretch"),this.style.setProperty("justify-content","flex-start"),this.style.setProperty("contain","layout style"),this.visible=!1,this.defaultFocusedElement=null,this.elementsToRestoreScrollPositionsFor=[],At||(At=new ResizeObserver((e=>{for(const t of e){const e=t.target;e.visible&&e.onResizedCallback&&e.onResizedCallback.call(null)}}))),At.observe(this),this.setElementsToRestoreScrollPositionsFor([this])}isShowing(){return this.visible}setOnShown(e){this.onShownCallback=e}setOnHidden(e){this.onHiddenCallback=e}setOnResized(e){this.onResizedCallback=e}setElementsToRestoreScrollPositionsFor(e){for(const e of this.elementsToRestoreScrollPositionsFor)e.removeEventListener("scroll",Bt.storeScrollPosition,{capture:!1});this.elementsToRestoreScrollPositionsFor=e;for(const e of this.elementsToRestoreScrollPositionsFor)e.addEventListener("scroll",Bt.storeScrollPosition,{passive:!0,capture:!1})}restoreScrollPositions(){for(const e of this.elementsToRestoreScrollPositionsFor){const t=Rt.get(e);t&&(e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft)}}static storeScrollPosition(e){const t=e.currentTarget;Rt.set(t,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop})}setDefaultFocusedElement(e){if(e&&!this.isSelfOrAncestor(e))throw new Error("Default focus must be descendant");this.defaultFocusedElement=e}focus(){if(!this.visible)return;let e;if(this.defaultFocusedElement&&this.isSelfOrAncestor(this.defaultFocusedElement))e=this.defaultFocusedElement;else if(-1!==this.tabIndex)e=this;else{let t=this.traverseNextNode(this);for(;t;){if(t instanceof Bt&&t.visible){e=t;break}t=t.traverseNextNode(this)}}e&&!e.hasFocus()&&(e===this?HTMLElement.prototype.focus.call(this):e.focus())}connectedCallback(){this.visible=!0,this.restoreScrollPositions(),this.onShownCallback&&this.onShownCallback.call(null)}disconnectedCallback(){this.visible=!1,this.onHiddenCallback&&this.onHiddenCallback.call(null)}}customElements.define("x-widget",Bt);var Ot=Object.freeze({__proto__:null,XWidget:Bt});class Ft extends HTMLDivElement{__widget;__widgetCounter;constructor(){super()}}function zt(e,t){if(!e)throw new Error(t)}class Wt{element;contentElement;shadowRoot;isWebComponent;visibleInternal;isRoot;isShowingInternal;childrenInternal;hideOnDetach;notificationDepth;invalidationsSuspended;defaultFocusedChild;parentWidgetInternal;registeredCSSFiles;defaultFocusedElement;cachedConstraints;constraintsInternal;invalidationsRequested;externallyManaged;constructor(e,t){this.contentElement=document.createElement("div"),this.contentElement.classList.add("widget"),e?(this.element=document.createElement("div"),this.element.classList.add("vbox"),this.element.classList.add("flex-auto"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:void 0,delegatesFocus:t}),this.shadowRoot.appendChild(this.contentElement)):this.element=this.contentElement,this.isWebComponent=e,this.element.__widget=this,this.visibleInternal=!1,this.isRoot=!1,this.isShowingInternal=!1,this.childrenInternal=[],this.hideOnDetach=!1,this.notificationDepth=0,this.invalidationsSuspended=0,this.defaultFocusedChild=null,this.parentWidgetInternal=null,this.registeredCSSFiles=!1}static incrementWidgetCounter(e,t){const i=(t.__widgetCounter||0)+(t.__widget?1:0);if(!i)return;let n=e;for(;n;)n.__widgetCounter=(n.__widgetCounter||0)+i,n=Vt(n)}static decrementWidgetCounter(e,t){const i=(t.__widgetCounter||0)+(t.__widget?1:0);if(!i)return;let n=e;for(;n;)n.__widgetCounter&&(n.__widgetCounter-=i),n=Vt(n)}markAsRoot(){zt(!this.element.parentElement,"Attempt to mark as root attached node"),this.isRoot=!0}parentWidget(){return this.parentWidgetInternal}children(){return this.childrenInternal}childWasDetached(e){}isShowing(){return this.isShowingInternal}shouldHideOnDetach(){if(!this.element.parentElement)return!1;if(this.hideOnDetach)return!0;for(const e of this.childrenInternal)if(e.shouldHideOnDetach())return!0;return!1}setHideOnDetach(){this.hideOnDetach=!0}inNotification(){return Boolean(this.notificationDepth)||Boolean(this.parentWidgetInternal&&this.parentWidgetInternal.inNotification())}parentIsShowing(){return!!this.isRoot||null!==this.parentWidgetInternal&&this.parentWidgetInternal.isShowing()}callOnVisibleChildren(e){const t=this.childrenInternal.slice();for(let i=0;i<t.length;++i)t[i].parentWidgetInternal===this&&t[i].visibleInternal&&e.call(t[i])}processWillShow(){this.callOnVisibleChildren(this.processWillShow),this.isShowingInternal=!0}processWasShown(){this.inNotification()||(this.restoreScrollPositions(),this.notify(this.wasShown),this.callOnVisibleChildren(this.processWasShown))}processWillHide(){this.inNotification()||(this.storeScrollPositions(),this.callOnVisibleChildren(this.processWillHide),this.notify(this.willHide),this.isShowingInternal=!1)}processWasHidden(){this.callOnVisibleChildren(this.processWasHidden)}processOnResize(){this.inNotification()||this.isShowing()&&(this.notify(this.onResize),this.callOnVisibleChildren(this.processOnResize))}notify(e){++this.notificationDepth;try{e.call(this)}finally{--this.notificationDepth}}wasShown(){}willHide(){}onResize(){}onLayout(){}onDetach(){}async ownerViewDisposed(){}show(e,t){if(zt(e,"Attempt to attach widget with no parent element"),!this.isRoot){let t=e;for(;t&&!t.__widget;)t=Vt(t);if(!t||!t.__widget)throw new Error("Attempt to attach widget to orphan node");this.attach(t.__widget)}this.showWidgetInternal(e,t)}attach(e){e!==this.parentWidgetInternal&&(this.parentWidgetInternal&&this.detach(),this.parentWidgetInternal=e,this.parentWidgetInternal.childrenInternal.push(this),this.isRoot=!1)}showWidget(){if(!this.visibleInternal){if(!this.element.parentElement)throw new Error("Attempt to show widget that is not hidden using hideWidget().");this.showWidgetInternal(this.element.parentElement,this.element.nextSibling)}}showWidgetInternal(e,t){let i=e;for(;i&&!i.__widget;)i=Vt(i);this.isRoot?zt(!i,"Attempt to show root widget under another widget"):zt(i&&i.__widget===this.parentWidgetInternal,"Attempt to show under node belonging to alien widget");const n=this.visibleInternal;n&&this.element.parentElement===e||(this.visibleInternal=!0,!n&&this.parentIsShowing()&&this.processWillShow(),this.element.classList.remove("hidden"),this.element.parentElement!==e&&(this.externallyManaged||Wt.incrementWidgetCounter(e,this.element),t?c.DOMExtension.originalInsertBefore.call(e,this.element,t):c.DOMExtension.originalAppendChild.call(e,this.element)),!n&&this.parentIsShowing()&&this.processWasShown(),this.parentWidgetInternal&&this.hasNonZeroConstraints()?this.parentWidgetInternal.invalidateConstraints():this.processOnResize())}hideWidget(){this.visibleInternal&&this.hideWidgetInternal(!1)}hideWidgetInternal(e){this.visibleInternal=!1;const t=this.element.parentElement;this.parentIsShowing()&&this.processWillHide(),e?(Wt.decrementWidgetCounter(t,this.element),c.DOMExtension.originalRemoveChild.call(t,this.element),this.onDetach()):this.element.classList.add("hidden"),this.parentIsShowing()&&this.processWasHidden(),this.parentWidgetInternal&&this.hasNonZeroConstraints()&&this.parentWidgetInternal.invalidateConstraints()}detach(e){if(!this.parentWidgetInternal&&!this.isRoot)return;const t=e||!this.shouldHideOnDetach();if(this.visibleInternal)this.hideWidgetInternal(t);else if(t&&this.element.parentElement){const e=this.element.parentElement;Wt.decrementWidgetCounter(e,this.element),c.DOMExtension.originalRemoveChild.call(e,this.element)}if(this.parentWidgetInternal){const e=this.parentWidgetInternal.childrenInternal.indexOf(this);zt(e>=0,"Attempt to remove non-child widget"),this.parentWidgetInternal.childrenInternal.splice(e,1),this.parentWidgetInternal.defaultFocusedChild===this&&(this.parentWidgetInternal.defaultFocusedChild=null),this.parentWidgetInternal.childWasDetached(this),this.parentWidgetInternal=null}else zt(this.isRoot,"Removing non-root widget from DOM")}detachChildWidgets(){const e=this.childrenInternal.slice();for(let t=0;t<e.length;++t)e[t].detach()}elementsToRestoreScrollPositionsFor(){return[this.element]}storeScrollPositions(){const e=this.elementsToRestoreScrollPositionsFor();for(const t of e)Ht.set(t,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop})}restoreScrollPositions(){const e=this.elementsToRestoreScrollPositionsFor();for(const t of e){const e=Ht.get(t);e&&(t.scrollLeft=e.scrollLeft,t.scrollTop=e.scrollTop)}}doResize(){this.isShowing()&&(this.inNotification()||this.callOnVisibleChildren(this.processOnResize))}doLayout(){this.isShowing()&&(this.notify(this.onLayout),this.doResize())}registerRequiredCSS(e){this.isWebComponent?m.ThemeSupport.instance().appendStyle(this.shadowRoot,e):m.ThemeSupport.instance().appendStyle(this.element,e)}registerCSSFiles(e){let t;t=this.isWebComponent&&void 0!==this.shadowRoot?this.shadowRoot:u.GetRootNode.getRootNode(this.contentElement),t.adoptedStyleSheets=t.adoptedStyleSheets.concat(e),this.registeredCSSFiles=!0}printWidgetHierarchy(){const e=[];this.collectWidgetHierarchy("",e),console.log(e.join("\n"))}collectWidgetHierarchy(e,t){t.push(e+"["+this.element.className+"]"+(this.childrenInternal.length?" {":""));for(let i=0;i<this.childrenInternal.length;++i)this.childrenInternal[i].collectWidgetHierarchy(e+" ",t);this.childrenInternal.length&&t.push(e+"}")}setDefaultFocusedElement(e){this.defaultFocusedElement=e}setDefaultFocusedChild(e){zt(e.parentWidgetInternal===this,"Attempt to set non-child widget as default focused."),this.defaultFocusedChild=e}focus(){if(!this.isShowing())return;const e=this.defaultFocusedElement;if(e)e.hasFocus()||e.focus();else if(this.defaultFocusedChild&&this.defaultFocusedChild.visibleInternal)this.defaultFocusedChild.focus();else{for(const e of this.childrenInternal)if(e.visibleInternal)return void e.focus();let e=this.contentElement.traverseNextNode(this.contentElement);for(;e;){if(e instanceof Bt)return void e.focus();e=e.traverseNextNode(this.contentElement)}}}hasFocus(){return this.element.hasFocus()}calculateConstraints(){return new je}constraints(){return void 0!==this.constraintsInternal?this.constraintsInternal:(void 0===this.cachedConstraints&&(this.cachedConstraints=this.calculateConstraints()),this.cachedConstraints)}setMinimumAndPreferredSizes(e,t,i,n){this.constraintsInternal=new je(new _e(e,t),new _e(i,n)),this.invalidateConstraints()}setMinimumSize(e,t){this.constraintsInternal=new je(new _e(e,t)),this.invalidateConstraints()}hasNonZeroConstraints(){const e=this.constraints();return Boolean(e.minimum.width||e.minimum.height||e.preferred.width||e.preferred.height)}suspendInvalidations(){++this.invalidationsSuspended}resumeInvalidations(){--this.invalidationsSuspended,!this.invalidationsSuspended&&this.invalidationsRequested&&this.invalidateConstraints()}invalidateConstraints(){if(this.invalidationsSuspended)return void(this.invalidationsRequested=!0);this.invalidationsRequested=!1;const e=this.cachedConstraints;delete this.cachedConstraints;!this.constraints().isEqual(e||null)&&this.parentWidgetInternal?this.parentWidgetInternal.invalidateConstraints():this.doLayout()}markAsExternallyManaged(){zt(!this.parentWidgetInternal,"Attempt to mark widget as externally managed after insertion to the DOM"),this.externallyManaged=!0}}const Ht=new WeakMap;class Nt extends Wt{constructor(e,t){super(e,t),this.contentElement.classList.add("vbox")}calculateConstraints(){let e=new je;return this.callOnVisibleChildren((function(){const t=this.constraints();e=e.widthToMax(t),e=e.addHeight(t)})),e}}class _t extends Wt{constructor(e){super(e),this.contentElement.classList.add("hbox")}calculateConstraints(){let e=new je;return this.callOnVisibleChildren((function(){const t=this.constraints();e=e.addWidth(t),e=e.heightToMax(t)})),e}}class jt{widget;previous;constructor(e){this.widget=e,this.previous=i.DOMUtilities.deepActiveElement(e.element.ownerDocument),e.focus()}restore(){this.widget&&(this.widget.hasFocus()&&this.previous&&this.previous.focus(),this.previous=null,this.widget=null)}}function Vt(e){return e.parentElementOrShadowHost()}var Ut=Object.freeze({__proto__:null,WidgetElement:Ft,Widget:Wt,VBox:Nt,HBox:_t,VBoxWithResizeCallback:class extends Nt{resizeCallback;constructor(e){super(),this.resizeCallback=e}onResize(){this.resizeCallback()}},WidgetFocusRestorer:jt});let Kt;class qt extends e.ObjectWrapper.ObjectWrapper{frontendHost;zoomFactorInternal;constructor(e,t){super(),this.frontendHost=t,this.zoomFactorInternal=this.frontendHost.zoomFactor(),e.addEventListener("resize",this.onWindowResize.bind(this),!0)}static instance(e={forceNew:null,win:null,frontendHost:null}){const{forceNew:t,win:i,frontendHost:n}=e;if(!Kt||t){if(!i||!n)throw new Error(`Unable to create zoom manager: window and frontendHost must be provided: ${(new Error).stack}`);Kt=new qt(i,n)}return Kt}static removeInstance(){Kt=void 0}zoomFactor(){return this.zoomFactorInternal}cssToDIP(e){return e*this.zoomFactorInternal}dipToCSS(e){return e/this.zoomFactorInternal}onWindowResize(){const e=this.zoomFactorInternal;this.zoomFactorInternal=this.frontendHost.zoomFactor(),e!==this.zoomFactorInternal&&this.dispatchEventToListeners("ZoomChanged",{from:e,to:this.zoomFactorInternal})}}var $t=Object.freeze({__proto__:null,ZoomManager:qt});class Gt extends(e.ObjectWrapper.eventMixin(Wt)){sidebarElementInternal;mainElement;resizerElementInternal;resizerElementSize;resizerWidget;defaultSidebarWidth;defaultSidebarHeight;constraintsInDip;resizeStartSizeDIP;setting;totalSizeCSS;totalSizeOtherDimensionCSS;mainWidgetInternal;sidebarWidgetInternal;animationFrameHandle;animationCallback;showSidebarButtonTitle;hideSidebarButtonTitle;shownSidebarString;hiddenSidebarString;showHideSidebarButton;isVerticalInternal;sidebarMinimized;detaching;sidebarSizeDIP;savedSidebarSizeDIP;secondIsSidebar;shouldSaveShowMode;savedVerticalMainSize;savedHorizontalMainSize;showModeInternal;savedShowMode;constructor(t,i,n,s,o,r){super(!0),this.element.classList.add("split-widget"),this.registerRequiredCSS(Mt),this.contentElement.classList.add("shadow-split-widget"),this.sidebarElementInternal=this.contentElement.createChild("div","shadow-split-widget-contents shadow-split-widget-sidebar vbox"),this.mainElement=this.contentElement.createChild("div","shadow-split-widget-contents shadow-split-widget-main vbox"),this.mainElement.createChild("slot").name="insertion-point-main",this.sidebarElementInternal.createChild("slot").name="insertion-point-sidebar",this.resizerElementInternal=this.contentElement.createChild("div","shadow-split-widget-resizer"),this.resizerElementSize=null,this.resizerWidget=new Tt,this.resizerWidget.setEnabled(!0),this.resizerWidget.addEventListener("ResizeStart",this.onResizeStart,this),this.resizerWidget.addEventListener("ResizeUpdatePosition",this.onResizeUpdate,this),this.resizerWidget.addEventListener("ResizeEnd",this.onResizeEnd,this),this.defaultSidebarWidth=s||200,this.defaultSidebarHeight=o||this.defaultSidebarWidth,this.constraintsInDip=Boolean(r),this.resizeStartSizeDIP=0,this.setting=n?e.Settings.Settings.instance().createSetting(n,{}):null,this.totalSizeCSS=0,this.totalSizeOtherDimensionCSS=0,this.mainWidgetInternal=null,this.sidebarWidgetInternal=null,this.animationFrameHandle=0,this.animationCallback=null,this.showSidebarButtonTitle=e.UIString.LocalizedEmptyString,this.hideSidebarButtonTitle=e.UIString.LocalizedEmptyString,this.shownSidebarString=e.UIString.LocalizedEmptyString,this.hiddenSidebarString=e.UIString.LocalizedEmptyString,this.showHideSidebarButton=null,this.isVerticalInternal=!1,this.sidebarMinimized=!1,this.detaching=!1,this.sidebarSizeDIP=-1,this.savedSidebarSizeDIP=this.sidebarSizeDIP,this.secondIsSidebar=!1,this.shouldSaveShowMode=!1,this.savedVerticalMainSize=null,this.savedHorizontalMainSize=null,this.setSecondIsSidebar(i),this.innerSetVertical(t),this.showModeInternal="Both",this.savedShowMode=this.showModeInternal,this.installResizer(this.resizerElementInternal)}isVertical(){return this.isVerticalInternal}setVertical(e){this.isVerticalInternal!==e&&(this.innerSetVertical(e),this.isShowing()&&this.updateLayout())}innerSetVertical(e){this.contentElement.classList.toggle("vbox",!e),this.contentElement.classList.toggle("hbox",e),this.isVerticalInternal=e,this.resizerElementSize=null,this.sidebarSizeDIP=-1,this.restoreSidebarSizeFromSettings(),this.shouldSaveShowMode&&this.restoreAndApplyShowModeFromSettings(),this.updateShowHideSidebarButton(),this.resizerWidget.setVertical(!e),this.invalidateConstraints()}updateLayout(e){this.totalSizeCSS=0,this.totalSizeOtherDimensionCSS=0,this.mainElement.style.removeProperty("width"),this.mainElement.style.removeProperty("height"),this.sidebarElementInternal.style.removeProperty("width"),this.sidebarElementInternal.style.removeProperty("height"),this.innerSetSidebarSizeDIP(this.preferredSidebarSizeDIP(),Boolean(e))}setMainWidget(e){this.mainWidgetInternal!==e&&(this.suspendInvalidations(),this.mainWidgetInternal&&this.mainWidgetInternal.detach(),this.mainWidgetInternal=e,e&&(e.element.slot="insertion-point-main","OnlyMain"!==this.showModeInternal&&"Both"!==this.showModeInternal||e.show(this.element)),this.resumeInvalidations())}setSidebarWidget(e){this.sidebarWidgetInternal!==e&&(this.suspendInvalidations(),this.sidebarWidgetInternal&&this.sidebarWidgetInternal.detach(),this.sidebarWidgetInternal=e,e&&(e.element.slot="insertion-point-sidebar","OnlySidebar"!==this.showModeInternal&&"Both"!==this.showModeInternal||e.show(this.element)),this.resumeInvalidations())}mainWidget(){return this.mainWidgetInternal}sidebarWidget(){return this.sidebarWidgetInternal}sidebarElement(){return this.sidebarElementInternal}childWasDetached(e){this.detaching||(this.mainWidgetInternal===e&&(this.mainWidgetInternal=null),this.sidebarWidgetInternal===e&&(this.sidebarWidgetInternal=null),this.invalidateConstraints())}isSidebarSecond(){return this.secondIsSidebar}enableShowModeSaving(){this.shouldSaveShowMode=!0,this.restoreAndApplyShowModeFromSettings()}showMode(){return this.showModeInternal}setSecondIsSidebar(e){e!==this.secondIsSidebar&&(this.secondIsSidebar=e,this.mainWidgetInternal&&this.mainWidgetInternal.shouldHideOnDetach()?this.sidebarWidgetInternal&&this.sidebarWidgetInternal.shouldHideOnDetach()?(console.error("Could not swap split widget side. Both children widgets contain iframes."),this.secondIsSidebar=!e):e?this.contentElement.insertBefore(this.sidebarElementInternal,this.resizerElementInternal):this.contentElement.insertBefore(this.sidebarElementInternal,this.mainElement):e?this.contentElement.insertBefore(this.mainElement,this.sidebarElementInternal):this.contentElement.insertBefore(this.mainElement,this.resizerElementInternal))}sidebarSide(){return"Both"!==this.showModeInternal?null:this.isVerticalInternal?this.secondIsSidebar?"right":"left":this.secondIsSidebar?"bottom":"top"}resizerElement(){return this.resizerElementInternal}hideMain(e){this.showOnly(this.sidebarWidgetInternal,this.mainWidgetInternal,this.sidebarElementInternal,this.mainElement,e),this.updateShowMode("OnlySidebar")}hideSidebar(e){this.showOnly(this.mainWidgetInternal,this.sidebarWidgetInternal,this.mainElement,this.sidebarElementInternal,e),this.updateShowMode("OnlyMain")}setSidebarMinimized(e){this.sidebarMinimized=e,this.invalidateConstraints()}isSidebarMinimized(){return this.sidebarMinimized}showOnly(e,t,i,n,s){function o(){e&&(e===this.mainWidgetInternal?this.mainWidgetInternal.show(this.element,this.sidebarWidgetInternal?this.sidebarWidgetInternal.element:null):this.sidebarWidgetInternal&&this.sidebarWidgetInternal.show(this.element)),t&&(this.detaching=!0,t.detach(),this.detaching=!1),this.resizerElementInternal.classList.add("hidden"),i.classList.remove("hidden"),i.classList.add("maximized"),n.classList.add("hidden"),n.classList.remove("maximized"),this.removeAllLayoutProperties(),this.doResize(),this.showFinishedForTest()}this.cancelAnimation(),s?this.animate(!0,o.bind(this)):o.call(this),this.sidebarSizeDIP=-1,this.setResizable(!1)}showFinishedForTest(){}removeAllLayoutProperties(){this.sidebarElementInternal.style.removeProperty("flexBasis"),this.mainElement.style.removeProperty("width"),this.mainElement.style.removeProperty("height"),this.sidebarElementInternal.style.removeProperty("width"),this.sidebarElementInternal.style.removeProperty("height"),this.resizerElementInternal.style.removeProperty("left"),this.resizerElementInternal.style.removeProperty("right"),this.resizerElementInternal.style.removeProperty("top"),this.resizerElementInternal.style.removeProperty("bottom"),this.resizerElementInternal.style.removeProperty("margin-left"),this.resizerElementInternal.style.removeProperty("margin-right"),this.resizerElementInternal.style.removeProperty("margin-top"),this.resizerElementInternal.style.removeProperty("margin-bottom")}showBoth(e){"Both"===this.showModeInternal&&(e=!1),this.cancelAnimation(),this.mainElement.classList.remove("maximized","hidden"),this.sidebarElementInternal.classList.remove("maximized","hidden"),this.resizerElementInternal.classList.remove("hidden"),this.setResizable(!0),this.suspendInvalidations(),this.sidebarWidgetInternal&&this.sidebarWidgetInternal.show(this.element),this.mainWidgetInternal&&this.mainWidgetInternal.show(this.element,this.sidebarWidgetInternal?this.sidebarWidgetInternal.element:null),this.resumeInvalidations(),this.setSecondIsSidebar(this.secondIsSidebar),this.sidebarSizeDIP=-1,this.updateShowMode("Both"),this.updateLayout(e)}setResizable(e){this.resizerWidget.setEnabled(e)}isResizable(){return this.resizerWidget.isEnabled()}setSidebarSize(e){const t=qt.instance().cssToDIP(e);this.savedSidebarSizeDIP=t,this.saveSetting(),this.innerSetSidebarSizeDIP(t,!1,!0)}sidebarSize(){const e=Math.max(0,this.sidebarSizeDIP);return qt.instance().dipToCSS(e)}totalSizeDIP(){return this.totalSizeCSS||(this.totalSizeCSS=this.isVerticalInternal?this.contentElement.offsetWidth:this.contentElement.offsetHeight,this.totalSizeOtherDimensionCSS=this.isVerticalInternal?this.contentElement.offsetHeight:this.contentElement.offsetWidth),qt.instance().cssToDIP(this.totalSizeCSS)}updateShowMode(e){this.showModeInternal=e,this.saveShowModeToSettings(),this.updateShowHideSidebarButton(),this.dispatchEventToListeners("ShowModeChanged",e),this.invalidateConstraints()}innerSetSidebarSizeDIP(e,t,i){if("Both"!==this.showModeInternal||!this.isShowing())return;if(e=this.applyConstraints(e,i),this.sidebarSizeDIP===e)return;this.resizerElementSize||(this.resizerElementSize=this.isVerticalInternal?this.resizerElementInternal.offsetWidth:this.resizerElementInternal.offsetHeight),this.removeAllLayoutProperties();const n=Math.round(qt.instance().dipToCSS(e)),s=n+"px",o=this.totalSizeCSS-n+"px";this.sidebarElementInternal.style.flexBasis=s,this.isVerticalInternal?(this.sidebarElementInternal.style.width=s,this.mainElement.style.width=o,this.sidebarElementInternal.style.height=this.totalSizeOtherDimensionCSS+"px",this.mainElement.style.height=this.totalSizeOtherDimensionCSS+"px"):(this.sidebarElementInternal.style.height=s,this.mainElement.style.height=o,this.sidebarElementInternal.style.width=this.totalSizeOtherDimensionCSS+"px",this.mainElement.style.width=this.totalSizeOtherDimensionCSS+"px"),this.isVerticalInternal?this.secondIsSidebar?(this.resizerElementInternal.style.right=s,this.resizerElementInternal.style.marginRight=-this.resizerElementSize/2+"px"):(this.resizerElementInternal.style.left=s,this.resizerElementInternal.style.marginLeft=-this.resizerElementSize/2+"px"):this.secondIsSidebar?(this.resizerElementInternal.style.bottom=s,this.resizerElementInternal.style.marginBottom=-this.resizerElementSize/2+"px"):(this.resizerElementInternal.style.top=s,this.resizerElementInternal.style.marginTop=-this.resizerElementSize/2+"px"),this.sidebarSizeDIP=e,t?this.animate(!1):(this.doResize(),this.dispatchEventToListeners("SidebarSizeChanged",this.sidebarSize()))}animate(e,t){let i;this.animationCallback=t||null,i=this.isVerticalInternal?this.secondIsSidebar?"margin-right":"margin-left":this.secondIsSidebar?"margin-bottom":"margin-top";const n=e?"0":"-"+qt.instance().dipToCSS(this.sidebarSizeDIP)+"px",s=e?"-"+qt.instance().dipToCSS(this.sidebarSizeDIP)+"px":"0";this.contentElement.style.setProperty(i,n),this.contentElement.style.setProperty("overflow","hidden"),e||(Yt(this.mainElement.offsetWidth),Yt(this.sidebarElementInternal.offsetWidth)),!e&&this.sidebarWidgetInternal&&this.sidebarWidgetInternal.doResize(),this.contentElement.style.setProperty("transition",i+" 50ms linear");const o=function(){if(this.animationFrameHandle=0,r){if(!(window.performance.now()<r+50))return this.cancelAnimation(),this.mainWidgetInternal&&this.mainWidgetInternal.doResize(),void this.dispatchEventToListeners("SidebarSizeChanged",this.sidebarSize());this.mainWidgetInternal&&this.mainWidgetInternal.doResize()}else this.contentElement.style.setProperty(i,s),r=window.performance.now();this.animationFrameHandle=this.contentElement.window().requestAnimationFrame(o)}.bind(this);let r=null;this.animationFrameHandle=this.contentElement.window().requestAnimationFrame(o)}cancelAnimation(){this.contentElement.style.removeProperty("margin-top"),this.contentElement.style.removeProperty("margin-right"),this.contentElement.style.removeProperty("margin-bottom"),this.contentElement.style.removeProperty("margin-left"),this.contentElement.style.removeProperty("transition"),this.contentElement.style.removeProperty("overflow"),this.animationFrameHandle&&(this.contentElement.window().cancelAnimationFrame(this.animationFrameHandle),this.animationFrameHandle=0),this.animationCallback&&(this.animationCallback(),this.animationCallback=null)}applyConstraints(e,t){const n=this.totalSizeDIP(),s=this.constraintsInDip?1:qt.instance().zoomFactor();let o=this.sidebarWidgetInternal?this.sidebarWidgetInternal.constraints():new je,r=this.isVertical()?o.minimum.width:o.minimum.height;r||(r=Xt),r*=s,this.sidebarMinimized&&(e=r);let a=this.isVertical()?o.preferred.width:o.preferred.height;a||(a=Xt),a*=s,e<a&&(a=Math.max(e,r)),a+=s,o=this.mainWidgetInternal?this.mainWidgetInternal.constraints():new je;let l=this.isVertical()?o.minimum.width:o.minimum.height;l||(l=Xt),l*=s;let h=this.isVertical()?o.preferred.width:o.preferred.height;h||(h=Xt),h*=s;const d=this.isVertical()?this.savedVerticalMainSize:this.savedHorizontalMainSize;null!==d&&(h=Math.min(h,d*s)),t&&(h=l);const c=h+a;if(c<=n)return i.NumberUtilities.clamp(e,a,n-h);if(l+r<=n){return e=a-(c-n)*a/c,i.NumberUtilities.clamp(e,r,n-l)}return Math.max(0,n-l)}wasShown(){this.forceUpdateLayout(),qt.instance().addEventListener("ZoomChanged",this.onZoomChanged,this)}willHide(){qt.instance().removeEventListener("ZoomChanged",this.onZoomChanged,this)}onResize(){this.updateLayout()}onLayout(){this.updateLayout()}calculateConstraints(){if("OnlyMain"===this.showModeInternal)return this.mainWidgetInternal?this.mainWidgetInternal.constraints():new je;if("OnlySidebar"===this.showModeInternal)return this.sidebarWidgetInternal?this.sidebarWidgetInternal.constraints():new je;let e=this.mainWidgetInternal?this.mainWidgetInternal.constraints():new je,t=this.sidebarWidgetInternal?this.sidebarWidgetInternal.constraints():new je;const i=Xt;return this.isVerticalInternal?(e=e.widthToMax(i).addWidth(1),t=t.widthToMax(i),e.addWidth(t).heightToMax(t)):(e=e.heightToMax(i).addHeight(1),t=t.heightToMax(i),e.widthToMax(t).addHeight(t))}onResizeStart(){this.resizeStartSizeDIP=this.sidebarSizeDIP}onResizeUpdate(e){const t=e.data.currentPosition-e.data.startPosition,i=qt.instance().cssToDIP(t),n=this.secondIsSidebar?this.resizeStartSizeDIP-i:this.resizeStartSizeDIP+i,s=this.applyConstraints(n,!0);this.savedSidebarSizeDIP=s,this.saveSetting(),this.innerSetSidebarSizeDIP(s,!1,!0),this.isVertical()?this.savedVerticalMainSize=this.totalSizeDIP()-this.sidebarSizeDIP:this.savedHorizontalMainSize=this.totalSizeDIP()-this.sidebarSizeDIP}onResizeEnd(){this.resizeStartSizeDIP=0}hideDefaultResizer(e){this.resizerElementInternal.classList.toggle("hidden",Boolean(e)),this.uninstallResizer(this.resizerElementInternal),this.sidebarElementInternal.classList.toggle("no-default-splitter",Boolean(e))}installResizer(e){this.resizerWidget.addElement(e)}uninstallResizer(e){this.resizerWidget.removeElement(e)}hasCustomResizer(){const e=this.resizerWidget.elements();return e.length>1||1===e.length&&e[0]!==this.resizerElementInternal}toggleResizer(e,t){t?this.installResizer(e):this.uninstallResizer(e)}settingForOrientation(){const e=this.setting?this.setting.get():{};return this.isVerticalInternal?e.vertical:e.horizontal}preferredSidebarSizeDIP(){let e=this.savedSidebarSizeDIP;return e||(e=this.isVerticalInternal?this.defaultSidebarWidth:this.defaultSidebarHeight,0<e&&e<1&&(e*=this.totalSizeDIP())),e}restoreSidebarSizeFromSettings(){const e=this.settingForOrientation();this.savedSidebarSizeDIP=e?e.size:0}restoreAndApplyShowModeFromSettings(){const e=this.settingForOrientation();switch(this.savedShowMode=e&&e.showMode?e.showMode:this.showModeInternal,this.showModeInternal=this.savedShowMode,this.savedShowMode){case"Both":this.showBoth();break;case"OnlyMain":this.hideSidebar();break;case"OnlySidebar":this.hideMain()}}saveShowModeToSettings(){this.savedShowMode=this.showModeInternal,this.saveSetting()}saveSetting(){if(!this.setting)return;const e=this.setting.get(),t=(this.isVerticalInternal?e.vertical:e.horizontal)||{};t.size=this.savedSidebarSizeDIP,this.shouldSaveShowMode&&(t.showMode=this.savedShowMode),this.isVerticalInternal?e.vertical=t:e.horizontal=t,this.setting.set(e)}forceUpdateLayout(){this.sidebarSizeDIP=-1,this.updateLayout()}onZoomChanged(){this.forceUpdateLayout()}createShowHideSidebarButton(e,t,i,n,s){return this.showSidebarButtonTitle=e,this.hideSidebarButtonTitle=t,this.shownSidebarString=i,this.hiddenSidebarString=n,this.showHideSidebarButton=new wn("",""),this.showHideSidebarButton.addEventListener("Click",(function(){this.toggleSidebar()}),this),s&&this.showHideSidebarButton.element.setAttribute("jslog",`${o.toggleSubpane().track({click:!0}).context(s)}`),this.updateShowHideSidebarButton(),this.showHideSidebarButton}toggleSidebar(){"Both"!==this.showModeInternal?(this.showBoth(!0),Se(this.shownSidebarString)):(this.hideSidebar(!0),Se(this.hiddenSidebarString))}updateShowHideSidebarButton(){if(!this.showHideSidebarButton)return;const e="OnlyMain"===this.showModeInternal;let t="";t=e?this.isVertical()?this.isSidebarSecond()?"right-panel-open":"left-panel-open":this.isSidebarSecond()?"bottom-panel-open":"top-panel-open":this.isVertical()?this.isSidebarSecond()?"right-panel-close":"left-panel-close":this.isSidebarSecond()?"bottom-panel-close":"top-panel-close",this.showHideSidebarButton.setGlyph(t),this.showHideSidebarButton.setTitle(e?this.showSidebarButtonTitle:this.hideSidebarButtonTitle)}}const Xt=20,Yt=function(e){};var Qt=Object.freeze({__proto__:null,SplitWidget:Gt}),Zt={cssContent:".tabbed-pane{flex:auto;overflow:hidden}.tabbed-pane-content{position:relative;overflow:auto;flex:auto;display:flex;flex-direction:column}.tabbed-pane-content.has-no-tabs{background-color:var(--sys-color-cdt-base-container)}.tabbed-pane-placeholder{font-size:14px;text-align:center;width:fit-content;margin:40px auto 0;text-shadow:var(--color-background-opacity-80) 0 1px 0;line-height:28px}.tabbed-pane-placeholder-row{margin-inline:10px;& span{display:inline-block;padding-inline:10px}&:has(.workspace){max-width:400px;border:2px dashed var(--sys-color-neutral-outline);margin-block-start:20px;padding:10px;margin-inline:20px}& button{cursor:pointer;color:var(--text-link);background:transparent;border:none;padding:0;text-decoration:underline;margin-inline:5px;&:focus-visible{outline:2px solid var(--sys-color-state-focus-ring);outline-offset:2px;border-radius:2px}}}.tabbed-pane-header{display:flex;flex:0 0 27px;border-bottom:1px solid var(--sys-color-divider);overflow:visible;width:100%;background-color:var(--app-color-toolbar-background);& > *{cursor:initial}}.tabbed-pane-header-contents{flex:auto;pointer-events:none;margin-left:0;position:relative;cursor:default}.tabbed-pane-header-contents > *{pointer-events:initial}.tabbed-pane-header-tab-icon{min-width:14px;display:flex;align-items:center;margin-right:2px}.tabbed-pane-header-tab-icon devtools-icon{margin-left:-1px}.tabbed-pane-header-tab{float:left;padding:2px 0.8em;height:26px;line-height:16px;white-space:nowrap;cursor:default;display:flex;align-items:center;color:var(--ui-text)}.tabbed-pane-header-tab.closeable{padding-right:4px}.tabbed-pane-header-tab.preview.closeable{padding-right:5px}.tabbed-pane-header-tab devtools-icon.dot::before{outline-color:var(--icon-gap-toolbar)}.tabbed-pane-header-tab:hover devtools-icon.dot::before{outline-color:var(--icon-gap-toolbar-hover)}.tabbed-pane-header-tab:hover,\n.tabbed-pane-shadow .tabbed-pane-header-tab:focus-visible{color:var(--sys-color-on-surface);background-color:var(--sys-color-state-hover-on-subtle)}.tabbed-pane-header-tab-title{text-overflow:ellipsis;overflow:hidden}.tabbed-pane-header-tab.measuring{visibility:hidden}.tabbed-pane-header-tab.selected{border-bottom:none;color:var(--sys-color-primary)}.tabbed-pane-header-tab.dragging{--override-dragging-box-shadow-color:rgb(0 0 0/37%);position:relative;box-shadow:0 1px 4px 0 var(--override-dragging-box-shadow-color);background-color:var(--sys-color-state-hover-on-subtle)}.-theme-with-dark-background .tabbed-pane-header-tab.dragging,\n:host-context(.-theme-with-dark-background) .tabbed-pane-header-tab.dragging{--override-dragging-box-shadow-color:rgb(230 230 230/37%)}.tabbed-pane-header-tab .tabbed-pane-close-button{margin:0 -3px 0 4px;visibility:hidden}.tabbed-pane-header-tab:hover .tabbed-pane-close-button,\n.tabbed-pane-header-tab.selected .tabbed-pane-close-button{visibility:visible}.tabbed-pane-header-tabs-drop-down-container{float:left;opacity:80%;display:flex;align-items:center;height:100%}.tabbed-pane-header-tabs-drop-down-container > .chevron-icon:hover,\n.tabbed-pane-header-tabs-drop-down-container > .chevron-icon:focus-visible{color:var(--icon-default-hover)}.tabbed-pane-header-tabs-drop-down-container:hover,\n.tabbed-pane-header-tabs-drop-down-container:focus-visible{background-color:var(--sys-color-state-hover-on-subtle)}.tabbed-pane-header-tabs-drop-down-container.measuring{visibility:hidden}.tabbed-pane-header-tabs-drop-down-container:active{opacity:80%}.tabbed-pane-shadow.vertical-tab-layout{flex-direction:row!important}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header{background-color:transparent;border:none transparent!important;width:auto;flex:0 0 auto;flex-direction:column;padding-top:10px;padding-right:4px;overflow:hidden}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-content{padding:10px 10px 10px 4px;overflow-x:hidden}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-contents{margin:0;flex:none}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tabs{display:flex;flex-direction:column;width:120px}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tab{border:none transparent;font-weight:normal;text-shadow:none;color:var(--sys-color-token-subtle);height:26px;padding-left:10px;margin:0;display:flex;align-items:center}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tab.selected{color:inherit;border:none transparent;background-color:var(--sys-color-neutral-container)}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tab:focus{background-color:var(--sys-color-tonal-container);color:var(--sys-color-on-tonal-container)}.tabbed-pane-tab-slider{height:2px;position:absolute;bottom:-1px;background-color:var(--sys-color-primary-bright);left:0;transform-origin:0 100%;transition:transform 150ms cubic-bezier(0,0,0.2,1);visibility:hidden}@media (-webkit-min-device-pixel-ratio: 1.1){.tabbed-pane-tab-slider{border-top:none}}.tabbed-pane-tab-slider.enabled{visibility:visible}.tabbed-pane-header-tab.disabled{opacity:50%;pointer-events:none}.tabbed-pane-left-toolbar{margin-right:-4px;flex:none}.tabbed-pane-right-toolbar{margin-left:-4px;flex:none}.preview-icon{--override-tabbed-pane-preview-icon-color:var(--icon-default);width:16px;height:16px;display:flex;align-items:center;justify-content:center;margin-left:3px;flex-shrink:0}.close-button{--tabbed-pane-close-icon-color:var(--icon-default);width:16px;height:16px;display:flex;align-items:center;justify-content:center;border-radius:50%;background-color:transparent;border:none}.close-button:hover,\n.close-button:active,\n.close-button:focus{background-color:var(--sys-color-state-hover-on-subtle)}.tabbed-pane-header-tab.preview.closeable .close-button{margin-left:0}@media (forced-colors: active){.tabbed-pane-tab-slider{forced-color-adjust:none;background-color:Highlight}.tabbed-pane-header{forced-color-adjust:none;border-bottom:1px solid transparent;background-color:ButtonFace}.tabbed-pane-header-contents .tabbed-pane-header-tabs .tabbed-pane-header-tab{background:ButtonFace;color:ButtonText}.tabbed-pane-header-tabs .tabbed-pane-header-tab:hover,\n .tabbed-pane-header-tabs .tabbed-pane-shadow .tabbed-pane-header-tab:focus-visible{background-color:Highlight;color:HighlightText}.tabbed-pane-header-tab .tabbed-pane-header-tab-title{color:inherit}.tabbed-pane-header-contents .tabbed-pane-header-tabs .tabbed-pane-header-tab.selected,\n .tabbed-pane-header-contents .tabbed-pane-header-tabs .tabbed-pane-header-tab.selected:focus-visible{background-color:Highlight;color:HighlightText}.tabbed-pane-header-tab:hover .tabbed-pane-close-button,\n .tabbed-pane-shadow .tabbed-pane-header-tab:focus-visible .tabbed-pane-close-button{color:HighlightText}.tabbed-pane-header-tabs-drop-down-container{opacity:100%}.tabbed-pane-header-tabs-drop-down-container:hover,\n .tabbed-pane-header-tabs-drop-down-container:focus-visible{background-color:Highlight}.tabbed-pane-header-tabs-drop-down-container > .chevron-icon{color:ButtonText}.tabbed-pane-header-tabs-drop-down-container:hover > .chevron-icon,\n .tabbed-pane-header-tabs-drop-down-container:focus-visible > .chevron-icon{color:HighlightText}.tabbed-pane-header-tabs .tabbed-pane-header-tab .preview-icon{--override-tabbed-pane-preview-icon-color:ButtonText}.tabbed-pane-header-tab.selected .preview-icon,\n .tabbed-pane-header-tab:hover .preview-icon{--override-tabbed-pane-preview-icon-color:HighlightText}.close-button{--tabbed-pane-close-icon-color:ButtonText;forced-color-adjust:none}.close-button:hover,\n .close-button:active{--tabbed-pane-close-icon-color:HighlightText;background-color:Highlight}.selected .close-button{--tabbed-pane-close-icon-color:HighlightText}}"};class Jt{static install(e,t){e.title=t||""}static installWithActionBinding(e,t,i){let n=t;const s=Bs.instance().shortcutsForAction(i);for(const e of s)n+=` - ${e.title()}`;e.title=n}}var ei=Object.freeze({__proto__:null,Tooltip:Jt});const ti={moreTabs:"More tabs",closeS:"Close {PH1}",close:"Close",closeOthers:"Close others",closeTabsToTheRight:"Close tabs to the right",closeAll:"Close all",previewFeature:"Preview feature"},ii=t.i18n.registerUIStrings("ui/legacy/TabbedPane.ts",ti),ni=t.i18n.getLocalizedString.bind(void 0,ii);class si extends(e.ObjectWrapper.eventMixin(Nt)){headerElementInternal;headerContentsElement;tabSlider;tabsElement;contentElementInternal;tabs;tabsHistory;tabsById;currentTabLocked;autoSelectFirstItemOnShow;triggerDropDownTimeout;dropDownButton;currentDevicePixelRatio;shrinkableTabs;verticalTabLayout;closeableTabs;delegate;currentTab;sliderEnabled;placeholderElement;focusedPlaceholderElement;placeholderContainerElement;lastSelectedOverflowTab;overflowDisabled;measuredDropDownButtonWidth;leftToolbarInternal;rightToolbarInternal;allowTabReorder;automaticReorder;constructor(){super(!0),this.registerRequiredCSS(Zt),this.element.classList.add("tabbed-pane"),this.contentElement.classList.add("tabbed-pane-shadow"),this.contentElement.tabIndex=-1,this.setDefaultFocusedElement(this.contentElement),this.headerElementInternal=this.contentElement.createChild("div","tabbed-pane-header"),this.headerContentsElement=this.headerElementInternal.createChild("div","tabbed-pane-header-contents"),this.tabSlider=document.createElement("div"),this.tabSlider.classList.add("tabbed-pane-tab-slider"),this.tabsElement=this.headerContentsElement.createChild("div","tabbed-pane-header-tabs"),this.tabsElement.setAttribute("role","tablist"),this.tabsElement.addEventListener("keydown",this.keyDown.bind(this),!1),this.contentElementInternal=this.contentElement.createChild("div","tabbed-pane-content"),this.contentElementInternal.createChild("slot"),this.tabs=[],this.tabsHistory=[],this.tabsById=new Map,this.currentTabLocked=!1,this.autoSelectFirstItemOnShow=!0,this.triggerDropDownTimeout=null,this.dropDownButton=this.createDropDownButton(),this.currentDevicePixelRatio=window.devicePixelRatio,qt.instance().addEventListener("ZoomChanged",this.zoomChanged,this),this.makeTabSlider()}setAccessibleName(e){be(this.tabsElement,e)}setCurrentTabLocked(e){this.currentTabLocked=e,this.headerElementInternal.classList.toggle("locked",this.currentTabLocked)}setAutoSelectFirstItemOnShow(e){this.autoSelectFirstItemOnShow=e}get visibleView(){return this.currentTab?this.currentTab.view:null}tabIds(){return this.tabs.map((e=>e.id))}tabIndex(e){return this.tabs.findIndex((t=>t.id===e))}tabViews(){return this.tabs.map((e=>e.view))}tabView(e){const t=this.tabsById.get(e);return t?t.view:null}get selectedTabId(){return this.currentTab?this.currentTab.id:null}setShrinkableTabs(e){this.shrinkableTabs=e}makeVerticalTabLayout(){this.verticalTabLayout=!0,this.setTabSlider(!1),this.contentElement.classList.add("vertical-tab-layout"),this.invalidateConstraints()}setCloseableTabs(e){this.closeableTabs=e}focus(){this.visibleView?this.visibleView.focus():this.contentElement.focus()}focusSelectedTabHeader(){const e=this.currentTab;e&&e.tabElement.focus()}headerElement(){return this.headerElementInternal}tabbedPaneContentElement(){return this.contentElementInternal}isTabCloseable(e){const t=this.tabsById.get(e);return!!t&&t.isCloseable()}setTabDelegate(e){const t=this.tabs.slice();for(let i=0;i<t.length;++i)t[i].setDelegate(e);this.delegate=e}appendTab(e,t,i,n,s,r,a,l){const h="boolean"==typeof r?r:Boolean(this.closeableTabs),d=new ri(this,e,t,h,Boolean(a),i,n);d.setDelegate(this.delegate),console.assert(!this.tabsById.has(e),`Tabbed pane already contains a tab with id '${e}'`),this.tabsById.set(e,d),d.tabElement.tabIndex=-1;const c="console-view"===e?"console":e;d.tabElement.setAttribute("jslog",`${o.panelTabHeader().track({click:!0,drag:!0}).context(c)}`),void 0!==l?this.tabs.splice(l,0,d):this.tabs.push(d),this.tabsHistory.push(d),this.tabsHistory[0]===d&&this.isShowing()&&this.selectTab(d.id,s),this.updateTabElements()}closeTab(e,t){this.closeTabs([e],t)}closeTabs(e,t){if(0===e.length)return;const i=this.hasFocus();for(let i=0;i<e.length;++i)this.innerCloseTab(e[i],t);this.updateTabElements(),this.tabsHistory.length&&this.selectTab(this.tabsHistory[0].id,!1),i&&this.focus()}innerCloseTab(e,t){const i=this.tabsById.get(e);if(!i)return;if(t&&!i.closeable)return;this.currentTab&&this.currentTab.id===e&&this.hideCurrentTab(),this.tabsById.delete(e),this.tabsHistory.splice(this.tabsHistory.indexOf(i),1),this.tabs.splice(this.tabs.indexOf(i),1),i.shown&&this.hideTabElement(i);const n={prevTabId:void 0,tabId:e,view:i.view,isUserGesture:t};return this.dispatchEventToListeners(oi.TabClosed,n),!0}hasTab(e){return this.tabsById.has(e)}otherTabs(e){const t=[];for(let i=0;i<this.tabs.length;++i)this.tabs[i].id!==e&&t.push(this.tabs[i].id);return t}tabsToTheRight(e){let t=-1;for(let i=0;i<this.tabs.length;++i)if(this.tabs[i].id===e){t=i;break}return-1===t?[]:this.tabs.slice(t+1).map((function(e){return e.id}))}viewHasFocus(){if(this.visibleView&&this.visibleView.hasFocus())return!0;const e=this.contentElement.getComponentRoot();return e instanceof Document&&this.contentElement===e.activeElement}selectTab(e,t,i){if(this.currentTabLocked)return!1;const n=this.viewHasFocus(),s=this.tabsById.get(e);if(!s)return!1;const o={prevTabId:this.currentTab?this.currentTab.id:void 0,tabId:e,view:s.view,isUserGesture:t};return this.dispatchEventToListeners(oi.TabInvoked,o),this.currentTab&&this.currentTab.id===e||(this.suspendInvalidations(),this.hideCurrentTab(),this.showTab(s),this.resumeInvalidations(),this.currentTab=s,this.tabsHistory.splice(this.tabsHistory.indexOf(s),1),this.tabsHistory.splice(0,0,s),this.updateTabElements(),(n||i)&&this.focus(),this.dispatchEventToListeners(oi.TabSelected,o)),!0}selectNextTab(){const e=this.tabs.indexOf(this.currentTab),t=i.NumberUtilities.mod(e+1,this.tabs.length);this.selectTab(this.tabs[t].id,!0)}selectPrevTab(){const e=this.tabs.indexOf(this.currentTab),t=i.NumberUtilities.mod(e-1,this.tabs.length);this.selectTab(this.tabs[t].id,!0)}lastOpenedTabIds(e){return this.tabsHistory.slice(0,e).map((function(e){return e.id}))}setTabIcon(e,t){const i=this.tabsById.get(e);i&&(i.setIcon(t),this.updateTabElements())}setTabEnabled(e,t){const i=this.tabsById.get(e);i&&i.tabElement.classList.toggle("disabled",!t)}toggleTabClass(e,t,i){const n=this.tabsById.get(e);n&&n.toggleClass(t,i)&&this.updateTabElements()}zoomChanged(){this.clearMeasuredWidths(),this.isShowing()&&this.updateTabElements()}clearMeasuredWidths(){for(let e=0;e<this.tabs.length;++e)delete this.tabs[e].measuredWidth}changeTabTitle(e,t,i){const n=this.tabsById.get(e);n&&void 0!==i&&(n.tooltip=i),n&&n.title!==t&&(n.title=t,be(n.tabElement,t),this.updateTabElements())}changeTabView(e,t){const i=this.tabsById.get(e);if(!i||i.view===t)return;this.suspendInvalidations();const n=this.currentTab&&this.currentTab.id===e,s=i.view.hasFocus();n&&this.hideTab(i),i.view=t,n&&this.showTab(i),s&&i.view.focus(),this.resumeInvalidations()}onResize(){this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.clearMeasuredWidths(),this.currentDevicePixelRatio=window.devicePixelRatio),this.updateTabElements()}headerResized(){this.updateTabElements()}wasShown(){const e=this.currentTab||this.tabsHistory[0];e&&this.autoSelectFirstItemOnShow&&this.selectTab(e.id)}makeTabSlider(){this.verticalTabLayout||this.setTabSlider(!0)}setTabSlider(e){this.sliderEnabled=e,this.tabSlider.classList.toggle("enabled",e)}calculateConstraints(){let e=super.calculateConstraints();const t=new je(new _e(0,0),new _e(50,50));return e=e.widthToMax(t).heightToMax(t),e=this.verticalTabLayout?e.addWidth(new je(new _e(120,0))):e.addHeight(new je(new _e(0,30))),e}updateTabElements(){ts(this,this.innerUpdateTabElements)}setPlaceholderElement(e,t){this.placeholderElement=e,t&&(this.focusedPlaceholderElement=t),this.placeholderContainerElement&&(this.placeholderContainerElement.removeChildren(),this.placeholderContainerElement.appendChild(e))}async waitForTabElementUpdate(){this.innerUpdateTabElements()}innerUpdateTabElements(){this.isShowing()&&(this.tabs.length?(this.contentElementInternal.classList.remove("has-no-tabs"),this.placeholderContainerElement&&(this.placeholderContainerElement.remove(),this.setDefaultFocusedElement(this.contentElement),delete this.placeholderContainerElement)):(this.contentElementInternal.classList.add("has-no-tabs"),this.placeholderElement&&!this.placeholderContainerElement&&(this.placeholderContainerElement=this.contentElementInternal.createChild("div","tabbed-pane-placeholder fill"),this.placeholderContainerElement.appendChild(this.placeholderElement),this.focusedPlaceholderElement&&this.setDefaultFocusedElement(this.focusedPlaceholderElement))),this.measureDropDownButton(),this.adjustToolbarWidth(),this.updateWidths(),this.updateTabsDropDown(),this.updateTabSlider())}adjustToolbarWidth(){if(!this.rightToolbarInternal||!this.measuredDropDownButtonWidth)return;const e=this.leftToolbarInternal?.element.getBoundingClientRect().width??0,t=this.rightToolbarInternal.element.getBoundingClientRect().width,i=this.headerElementInternal.getBoundingClientRect().width;!this.rightToolbarInternal.hasCompactLayout()&&i-t-e<this.measuredDropDownButtonWidth+10?this.rightToolbarInternal.setCompactLayout(!0):this.rightToolbarInternal.hasCompactLayout()&&i-2*t-e>this.measuredDropDownButtonWidth+10&&this.rightToolbarInternal.setCompactLayout(!1)}showTabElement(e,t){e>=this.tabsElement.children.length?this.tabsElement.appendChild(t.tabElement):this.tabsElement.insertBefore(t.tabElement,this.tabsElement.children[e]),t.shown=!0}hideTabElement(e){this.tabsElement.removeChild(e.tabElement),e.shown=!1}createDropDownButton(){const e=document.createElement("div");e.classList.add("tabbed-pane-header-tabs-drop-down-container"),e.setAttribute("jslog",`${o.dropDown("more-tabs").track({click:!0})}`);const t=a.Icon.create("chevron-double-right","chevron-icon"),i=ni(ti.moreTabs);return e.title=i,N(e),be(e,i),ae(e,!1),e.tabIndex=0,e.appendChild(t),e.addEventListener("click",this.dropDownClicked.bind(this)),e.addEventListener("keydown",this.dropDownKeydown.bind(this)),e.addEventListener("mousedown",(e=>{0!==e.button||this.triggerDropDownTimeout||(this.triggerDropDownTimeout=window.setTimeout(this.dropDownClicked.bind(this,e),200))})),e}dropDownClicked(e){const t=e;if(0!==t.button)return;this.triggerDropDownTimeout&&(clearTimeout(this.triggerDropDownTimeout),this.triggerDropDownTimeout=null);const i=this.dropDownButton.getBoundingClientRect(),n=new Ys(t,{useSoftMenu:!1,x:i.left,y:i.bottom,onSoftMenuClosed:()=>{ae(this.dropDownButton,!1)}});for(const e of this.tabs)e.shown||(0===this.numberOfTabsShown()&&this.tabsHistory[0]===e?n.defaultSection().appendCheckboxItem(e.title,this.dropDownMenuItemSelected.bind(this,e),{checked:!0,jslogContext:e.id}):n.defaultSection().appendItem(e.title,this.dropDownMenuItemSelected.bind(this,e),{jslogContext:e.id}));n.show().then((()=>ae(this.dropDownButton,n.isHostedMenuOpen())))}dropDownKeydown(e){i.KeyboardUtilities.isEnterOrSpaceKey(e)&&(this.dropDownButton.click(),e.consume(!0))}dropDownMenuItemSelected(e){this.lastSelectedOverflowTab=e,this.selectTab(e.id,!0,!0)}totalWidth(){return this.headerContentsElement.getBoundingClientRect().width}numberOfTabsShown(){let e=0;for(const t of this.tabs)t.shown&&e++;return e}disableOverflowMenu(){this.overflowDisabled=!0}updateTabsDropDown(){const e=this.tabsToShowIndexes(this.tabs,this.tabsHistory,this.totalWidth(),this.measuredDropDownButtonWidth||0);if(this.lastSelectedOverflowTab&&this.numberOfTabsShown()!==e.length)return delete this.lastSelectedOverflowTab,void this.updateTabsDropDown();for(let t=0;t<this.tabs.length;++t)this.tabs[t].shown&&-1===e.indexOf(t)&&this.hideTabElement(this.tabs[t]);for(let t=0;t<e.length;++t){const i=this.tabs[e[t]];i.shown||this.showTabElement(t,i)}this.overflowDisabled||this.maybeShowDropDown(e.length!==this.tabs.length)}maybeShowDropDown(e){e&&!this.dropDownButton.parentElement?this.headerContentsElement.appendChild(this.dropDownButton):!e&&this.dropDownButton.parentElement&&this.headerContentsElement.removeChild(this.dropDownButton)}measureDropDownButton(){this.overflowDisabled||this.measuredDropDownButtonWidth||(this.dropDownButton.classList.add("measuring"),this.headerContentsElement.appendChild(this.dropDownButton),this.measuredDropDownButtonWidth=this.dropDownButton.getBoundingClientRect().width,this.headerContentsElement.removeChild(this.dropDownButton),this.dropDownButton.classList.remove("measuring"))}updateWidths(){const e=this.measureWidths(),t=this.shrinkableTabs?this.calculateMaxWidth(e.slice(),this.totalWidth()):Number.MAX_VALUE;let i=0;for(const n of this.tabs)n.setWidth(this.verticalTabLayout?-1:Math.min(t,e[i++]))}measureWidths(){this.tabsElement.style.setProperty("width","2000px");const e=new Map;for(const t of this.tabs){if("number"==typeof t.measuredWidth)continue;const i=t.createTabElement(!0);e.set(i,t),this.tabsElement.appendChild(i)}for(const[t,i]of e){const e=t.getBoundingClientRect().width;i.measuredWidth=Math.ceil(e)}for(const t of e.keys())t.remove();const t=[];for(const e of this.tabs)t.push(e.measuredWidth||0);return this.tabsElement.style.removeProperty("width"),t}calculateMaxWidth(e,t){if(!e.length)return 0;e.sort((function(e,t){return e-t}));let i=0;for(let t=0;t<e.length;++t)i+=e[t];if(t>=i)return e[e.length-1];let n=0;for(let s=e.length-1;s>0;--s){const o=e[s]-e[s-1];if(n+=(e.length-s)*o,t+n>=i)return e[s-1]+(t+n-i)/(e.length-s)}return t/e.length}tabsToShowIndexes(e,t,i,n){const s=[];let o=0;const r=e.length,a=e.slice(0);void 0!==this.currentTab&&a.unshift(a.splice(a.indexOf(this.currentTab),1)[0]),void 0!==this.lastSelectedOverflowTab&&a.unshift(a.splice(a.indexOf(this.lastSelectedOverflowTab),1)[0]);for(let l=0;l<r;++l){const h=this.automaticReorder?t[l]:a[l];o+=h.width();let d=o;if(l!==r-1&&(d+=n),!this.verticalTabLayout&&d>i)break;s.push(e.indexOf(h))}return s.sort((function(e,t){return e-t})),s}hideCurrentTab(){this.currentTab&&(this.hideTab(this.currentTab),delete this.currentTab)}showTab(e){e.tabElement.tabIndex=0,e.tabElement.classList.add("selected"),ue(e.tabElement,!0),e.view.show(this.element),this.updateTabSlider()}updateTabSlider(){if(!this.sliderEnabled)return;if(!this.currentTab)return void(this.tabSlider.style.width="0");let e=0;for(let t=0;t<this.tabs.length&&this.currentTab!==this.tabs[t];t++)this.tabs[t].shown&&(e+=this.tabs[t].measuredWidth||0);const t=this.currentTab.shown?this.currentTab.measuredWidth:this.dropDownButton.offsetWidth,i=window.devicePixelRatio>=1.5?" scaleY(0.75)":"";this.tabSlider.style.transform="translateX("+e+"px)"+i,this.tabSlider.style.width=t+"px",this.tabSlider.parentElement!==this.headerContentsElement&&this.headerContentsElement.appendChild(this.tabSlider)}hideTab(e){e.tabElement.removeAttribute("tabIndex"),e.tabElement.classList.remove("selected"),e.tabElement.tabIndex=-1,e.tabElement.setAttribute("aria-selected","false"),e.view.detach()}elementsToRestoreScrollPositionsFor(){return[this.contentElementInternal]}insertBefore(e,t){this.tabsElement.insertBefore(e.tabElement,this.tabsElement.childNodes[t]);const i=this.tabs.indexOf(e);this.tabs.splice(i,1),i<t&&--t,this.tabs.splice(t,0,e);const n={prevTabId:void 0,tabId:e.id,view:e.view,isUserGesture:void 0};this.dispatchEventToListeners(oi.TabOrderChanged,n)}leftToolbar(){return this.leftToolbarInternal||(this.leftToolbarInternal=new gn("tabbed-pane-left-toolbar"),this.headerElementInternal.insertBefore(this.leftToolbarInternal.element,this.headerElementInternal.firstChild)),this.leftToolbarInternal}rightToolbar(){return this.rightToolbarInternal||(this.rightToolbarInternal=new gn("tabbed-pane-right-toolbar"),this.headerElementInternal.appendChild(this.rightToolbarInternal.element)),this.rightToolbarInternal}setAllowTabReorder(e,t){this.allowTabReorder=e,this.automaticReorder=t}keyDown(e){if(!this.currentTab)return;let t=null;switch(e.key){case"ArrowUp":case"ArrowLeft":t=this.currentTab.tabElement.previousElementSibling,t||this.dropDownButton.parentElement||(t=this.currentTab.tabElement.parentElement?this.currentTab.tabElement.parentElement.lastElementChild:null);break;case"ArrowDown":case"ArrowRight":t=this.currentTab.tabElement.nextElementSibling,t||this.dropDownButton.parentElement||(t=this.currentTab.tabElement.parentElement?this.currentTab.tabElement.parentElement.firstElementChild:null);break;case"Enter":case" ":return void this.currentTab.view.focus();default:return}if(!t)return void this.dropDownButton.click();const i=this.tabs.find((e=>e.tabElement===t));i&&this.selectTab(i.id,!0),t.focus()}}var oi;!function(e){e.TabInvoked="TabInvoked",e.TabSelected="TabSelected",e.TabClosed="TabClosed",e.TabOrderChanged="TabOrderChanged"}(oi||(oi={}));class ri{closeable;previewFeature=!1;tabbedPane;idInternal;titleInternal;tooltipInternal;viewInternal;shown;measuredWidth;tabElementInternal;icon=null;widthInternal;delegate;titleElement;dragStartX;constructor(e,t,i,n,s,o,r){this.closeable=n,this.previewFeature=s,this.tabbedPane=e,this.idInternal=t,this.titleInternal=i,this.tooltipInternal=r,this.viewInternal=o,this.shown=!1}get id(){return this.idInternal}get title(){return this.titleInternal}set title(e){if(e!==this.titleInternal){if(this.titleInternal=e,this.titleElement){this.titleElement.textContent=e;const t=this.tabElementInternal?.querySelector(".close-button");t?.setAttribute("title",ni(ti.closeS,{PH1:e})),t?.setAttribute("aria-label",ni(ti.closeS,{PH1:e}))}delete this.measuredWidth}}isCloseable(){return this.closeable}setIcon(e){this.icon=e,this.tabElementInternal&&this.titleElement&&this.createIconElement(this.tabElementInternal,this.titleElement,!1),delete this.measuredWidth}toggleClass(e,t){const i=this.tabElement;return i.classList.contains(e)!==t&&(i.classList.toggle(e,t),delete this.measuredWidth,!0)}get view(){return this.viewInternal}set view(e){this.viewInternal=e}get tooltip(){return this.tooltipInternal}set tooltip(e){this.tooltipInternal=e,this.titleElement&&Jt.install(this.titleElement,e||"")}get tabElement(){return this.tabElementInternal||(this.tabElementInternal=this.createTabElement(!1)),this.tabElementInternal}width(){return this.widthInternal||0}setWidth(e){this.tabElement.style.width=-1===e?"":e+"px",this.widthInternal=e}setDelegate(e){this.delegate=e}createIconElement(e,t,i){const n=ai.get(e);if(n&&(n.remove(),ai.delete(e)),!this.icon)return;const s=document.createElement("span");s.classList.add("tabbed-pane-header-tab-icon");const o=i?this.createMeasureClone(this.icon):this.icon;s.appendChild(o),e.insertBefore(s,t),ai.set(e,s)}createMeasureClone(e){const t=document.createElement("div");return t.style.width=e.style.width,t.style.height=e.style.height,t}createTabElement(e){const t=document.createElement("div");t.classList.add("tabbed-pane-header-tab"),t.id="tab-"+this.idInternal,_(t),ue(t,!1),be(t,this.title);const i=t.createChild("span","tabbed-pane-header-tab-title");if(i.textContent=this.title,Jt.install(i,this.tooltip||""),this.createIconElement(t,i,e),e||(this.titleElement=i),this.previewFeature){const e=this.createPreviewIcon();t.appendChild(e),t.classList.add("preview")}if(this.closeable){const e=this.createCloseIconButton();t.appendChild(e),t.classList.add("closeable")}return e?t.classList.add("measuring"):(t.addEventListener("click",this.tabClicked.bind(this),!1),t.addEventListener("auxclick",this.tabClicked.bind(this),!1),t.addEventListener("mousedown",this.tabMouseDown.bind(this),!1),t.addEventListener("mouseup",this.tabMouseUp.bind(this),!1),t.addEventListener("contextmenu",this.tabContextMenu.bind(this),!1),this.tabbedPane.allowTabReorder&&An(t,this.startTabDragging.bind(this),this.tabDragging.bind(this),this.endTabDragging.bind(this),null,null,200)),t}createCloseIconButton(){const e=document.createElement("button");e.classList.add("close-button","tabbed-pane-close-button"),e.setAttribute("jslog",`${o.close().track({click:!0})}`);const t=new a.Icon.Icon;return t.data={iconName:"cross",color:"var(--tabbed-pane-close-icon-color)",width:"16px"},e.appendChild(t),e.setAttribute("role","button"),e.setAttribute("title",ni(ti.closeS,{PH1:this.title})),e.setAttribute("aria-label",ni(ti.closeS,{PH1:this.title})),e}createPreviewIcon(){const e=document.createElement("div");e.classList.add("preview-icon");const t=new a.Icon.Icon;return t.data={iconName:"experiment",color:"var(--override-tabbed-pane-preview-icon-color)",width:"16px"},e.appendChild(t),e.setAttribute("title",ni(ti.previewFeature)),e.setAttribute("aria-label",ni(ti.previewFeature)),e}isCloseIconClicked(e){return e?.classList.contains("tabbed-pane-close-button")||e?.parentElement?.classList.contains("tabbed-pane-close-button")||!1}tabClicked(e){const t=e,i=1===t.button;this.closeable&&(i||this.isCloseIconClicked(t.target))?(this.closeTabs([this.id]),t.consume(!0)):this.tabbedPane.focus()}tabMouseDown(e){const t=e;this.isCloseIconClicked(t.target)||0!==t.button||this.tabbedPane.selectTab(this.id,!0)}tabMouseUp(e){const t=e;1===t.button&&t.consume(!0)}closeTabs(e){this.delegate?this.delegate.closeTabs(this.tabbedPane,e):this.tabbedPane.closeTabs(e,!0)}tabContextMenu(e){const t=new Ys(e);this.closeable&&(t.defaultSection().appendItem(ni(ti.close),function(){this.closeTabs([this.id])}.bind(this),{jslogContext:"close"}),t.defaultSection().appendItem(ni(ti.closeOthers),function(){this.closeTabs(this.tabbedPane.otherTabs(this.id))}.bind(this),{jslogContext:"close-others"}),t.defaultSection().appendItem(ni(ti.closeTabsToTheRight),function(){this.closeTabs(this.tabbedPane.tabsToTheRight(this.id))}.bind(this),{jslogContext:"close-tabs-to-the-right"}),t.defaultSection().appendItem(ni(ti.closeAll),function(){this.closeTabs(this.tabbedPane.tabIds())}.bind(this),{jslogContext:"close-all"})),this.delegate&&this.delegate.onContextMenu(this.id,t),t.show()}startTabDragging(e){const t=e;return!this.isCloseIconClicked(t.target)&&(this.dragStartX=t.pageX,this.tabElementInternal&&this.tabElementInternal.classList.add("dragging"),this.tabbedPane.tabSlider.remove(),!0)}tabDragging(e){const t=e,i=this.tabbedPane.tabsElement.childNodes;for(let e=0;e<i.length;++e){let n=i[e];if(!this.tabElementInternal||n===this.tabElementInternal)continue;if(!(n.offsetLeft+n.clientWidth>this.tabElementInternal.offsetLeft&&this.tabElementInternal.offsetLeft+this.tabElementInternal.clientWidth>n.offsetLeft))continue;const s=this.dragStartX;if(Math.abs(t.pageX-s)<n.clientWidth/2+5)break;t.pageX-s>0&&(n=n.nextSibling,++e);const o=this.tabElementInternal.offsetLeft;this.tabbedPane.insertBefore(this,e),this.dragStartX=s+this.tabElementInternal.offsetLeft-o;break}const n=this.dragStartX,s=this.tabElementInternal;!s.previousSibling&&t.pageX-n<0||!s.nextSibling&&t.pageX-n>0?s.style.setProperty("left","0px"):s.style.setProperty("left",t.pageX-n+"px")}endTabDragging(e){const t=this.tabElementInternal;t.classList.remove("dragging"),t.style.removeProperty("left"),delete this.dragStartX,this.tabbedPane.updateTabSlider()}}const ai=new WeakMap;var li=Object.freeze({__proto__:null,TabbedPane:si,get Events(){return oi},TabbedPaneTab:ri}),hi={cssContent:".expandable-view-title{display:flex;align-items:center;background-color:var(--sys-color-surface2);height:22px;padding:0 5px;white-space:nowrap;overflow:hidden;position:relative;border-bottom:1px solid transparent}.expandable-view-title.expanded,\n.expandable-view-title:last-child{border-bottom:1px solid var(--sys-color-divider)}.expandable-view-title .toolbar{margin-top:-3px}.expandable-view-title > .toolbar{position:absolute;right:0;top:0}.expandable-view-title:not(.expanded) .toolbar{display:none}.title-expand-icon{margin-right:2px;margin-bottom:-2px}.expandable-view-title:focus-visible{background-color:var(--sys-color-state-focus-highlight)}@media (forced-colors: active){.expandable-view-title:focus-visible{forced-color-adjust:none;color:HighlightText;background-color:Highlight;box-shadow:0 0 0 2px Highlight inset}.expandable-view-title:focus-visible .title-expand-icon{color:HighlightText}}"};const di={elements:"Elements",drawer:"Drawer",drawer_sidebar:"Drawer sidebar",panel:"Panel",network:"Network",settings:"Settings",sources:"Sources"},ci=t.i18n.registerUIStrings("ui/legacy/ViewRegistration.ts",di),ui=t.i18n.getLocalizedString.bind(void 0,ci),mi=[],pi=new Set;function gi(){return mi.filter((e=>n.Runtime.Runtime.isDescriptorEnabled({experiment:e.experiment(),condition:e.condition()})))}const bi=[],fi=new Set;function vi(){return bi}const wi={sPanel:"{PH1} panel"},xi=t.i18n.registerUIStrings("ui/legacy/ViewManager.ts",wi),Ei=t.i18n.getLocalizedString.bind(void 0,xi),Ii={security:!0};class yi{viewRegistration;widgetPromise;constructor(e){this.viewRegistration=e,this.widgetPromise=null}title(){return this.viewRegistration.title()}commandPrompt(){return this.viewRegistration.commandPrompt()}isCloseable(){return"closeable"===this.viewRegistration.persistence}isPreviewFeature(){return Boolean(this.viewRegistration.isPreviewFeature)}isTransient(){return"transient"===this.viewRegistration.persistence}viewId(){return this.viewRegistration.id}location(){return this.viewRegistration.location}order(){return this.viewRegistration.order}settings(){return this.viewRegistration.settings}tags(){if(this.viewRegistration.tags)return this.viewRegistration.tags.map((e=>e())).join("\0")}persistence(){return this.viewRegistration.persistence}async toolbarItems(){if(!this.viewRegistration.hasToolbar)return[];return(await this.widget()).toolbarItems()}widget(){return null===this.widgetPromise&&(this.widgetPromise=this.viewRegistration.loadView()),this.widgetPromise}async disposeView(){if(null===this.widgetPromise)return;const e=await this.widgetPromise;await e.ownerViewDisposed()}experiment(){return this.viewRegistration.experiment}condition(){return this.viewRegistration.condition}}let Si;class Ci{views;locationNameByViewId;locationOverrideSetting;constructor(){this.views=new Map,this.locationNameByViewId=new Map,this.locationOverrideSetting=e.Settings.Settings.instance().createSetting("views-location-override",{});const t=this.locationOverrideSetting.get(),n=new Map;for(const e of gi()){const t=e.location()||"none",i=n.get(t)||[];i.push(e),n.set(t,i)}let s=[];for(const e of n.values())e.sort(((e,t)=>{const i=e.order(),n=t.order();return void 0!==i&&void 0!==n?i-n:0})),s=s.concat(e);for(const e of s){const n=e.viewId(),s=e.location();if(this.views.has(n))throw new Error(`Duplicate view id '${n}'`);if(!i.StringUtilities.isExtendedKebabCase(n))throw new Error(`Invalid view ID '${n}'`);this.views.set(n,e);const o=t[n]||s;this.locationNameByViewId.set(n,o)}}static instance(e={forceNew:null}){const{forceNew:t}=e;return Si&&!t||(Si=new Ci),Si}static removeInstance(){Si=void 0}static createToolbar(e){if(!e.length)return null;const t=new gn("");for(const i of e)t.appendToolbarItem(i);return t.element}locationNameForViewId(e){const t=this.locationNameByViewId.get(e);if(!t)throw new Error(`No location name for view with id ${e}`);return t}moveView(e,t,i){const{shouldSelectTab:n,overrideSaving:s}=i||{shouldSelectTab:!0,overrideSaving:!1};if(!e||!t)return;const o=this.view(e);if(o){if(!s){this.locationNameByViewId.set(e,t);const i=this.locationOverrideSetting.get();i[e]=t,this.locationOverrideSetting.set(i)}this.resolveLocation(t).then((t=>{if(!t)throw new Error("Move view: Could not resolve location for view: "+e);return t.reveal(),t.showView(o,void 0,!0,!1,n)}))}}revealView(e){const t=Di.get(e);return t?(t.reveal(),t.showView(e)):Promise.resolve()}showViewInLocation(e,t,i=!0){this.moveView(e,t,{shouldSelectTab:i,overrideSaving:!0})}view(e){const t=this.views.get(e);if(!t)throw new Error(`No view with id ${e} found!`);return t}materializedWidget(e){const t=this.view(e);return t&&Ti.get(t)||null}async showView(e,t,i){const n=this.views.get(e);if(!n)return void console.error("Could not find view for id: '"+e+"' "+(new Error).stack);const s=Di.get(n)??await this.resolveLocation(this.locationNameByViewId.get(e));if(!s)throw new Error("Could not resolve location for view: "+e);s.reveal(),await s.showView(n,void 0,t,i)}async resolveLocation(e){if(!e)return Promise.resolve(null);const t=vi().filter((t=>t.name===e));if(t.length>1)throw new Error("Duplicate resolver for location: "+e);if(t.length){return(await t[0].loadResolver()).resolveLocation(e)}throw new Error("Unresolved location: "+e)}createTabbedLocation(e,t,i,n,s){return new Ai(this,e,t,i,n,s)}createStackLocation(e,t,i){return new Ri(this,e,t,i)}hasViewsForLocation(e){return Boolean(this.viewsForLocation(e).length)}viewsForLocation(e){const t=[];for(const[i,n]of this.views.entries())this.locationNameByViewId.get(i)===e&&t.push(n);return t}}const Ti=new WeakMap;class ki extends Nt{view;materializePromise;constructor(e){super(),this.element.classList.add("flex-auto","view-container","overflow-auto"),this.view=e,this.element.tabIndex=-1,j(this.element),be(this.element,Ei(wi.sPanel,{PH1:e.title()})),this.setDefaultFocusedElement(this.element)}materialize(){if(this.materializePromise)return this.materializePromise;const e=[];return e.push(this.view.toolbarItems().then((e=>{const t=Ci.createToolbar(e);t&&this.element.insertBefore(t,this.element.firstChild)}))),e.push(this.view.widget().then((e=>{const t=this.element.hasFocus();this.setDefaultFocusedElement(null),Ti.set(this.view,e),e.show(this.element),t&&e.focus()}))),this.materializePromise=Promise.all(e).then((()=>{})),this.materializePromise}wasShown(){this.materialize().then((()=>{const e=Ti.get(this.view);e&&(e.show(this.element),this.wasShownForTest())}))}wasShownForTest(){}}class Mi extends Nt{titleElement;titleExpandIcon;view;widget;materializePromise;constructor(e){super(!0),this.element.classList.add("flex-none"),this.registerRequiredCSS(hi),this.titleElement=document.createElement("div"),this.titleElement.classList.add("expandable-view-title"),this.titleElement.setAttribute("jslog",`${o.sectionHeader().context(e.viewId()).track({click:!0})}`),U(this.titleElement),this.titleExpandIcon=a.Icon.create("triangle-right","title-expand-icon"),this.titleElement.appendChild(this.titleExpandIcon);const t=e.title();ss(this.titleElement,t),be(this.titleElement,t),ae(this.titleElement,!1),this.titleElement.tabIndex=0,self.onInvokeElement(this.titleElement,this.toggleExpanded.bind(this)),this.titleElement.addEventListener("keydown",this.onTitleKeyDown.bind(this),!1),this.contentElement.insertBefore(this.titleElement,this.contentElement.firstChild),re(this.titleElement,this.contentElement.createChild("slot")),this.view=e,Li.set(e,this)}wasShown(){this.widget&&this.materializePromise&&this.materializePromise.then((()=>{this.titleElement.classList.contains("expanded")&&this.widget&&this.widget.show(this.element)}))}materialize(){if(this.materializePromise)return this.materializePromise;const e=[];return e.push(this.view.toolbarItems().then((e=>{const t=Ci.createToolbar(e);t&&this.titleElement.appendChild(t)}))),e.push(this.view.widget().then((e=>{this.widget=e,Ti.set(this.view,e),e.show(this.element)}))),this.materializePromise=Promise.all(e).then((()=>{})),this.materializePromise}expand(){return this.titleElement.classList.contains("expanded")?this.materialize():(this.titleElement.classList.add("expanded"),ae(this.titleElement,!0),this.titleExpandIcon.name="triangle-down",this.materialize().then((()=>{this.widget&&this.widget.show(this.element)})))}collapse(){this.titleElement.classList.contains("expanded")&&(this.titleElement.classList.remove("expanded"),ae(this.titleElement,!1),this.titleExpandIcon.name="triangle-right",this.materialize().then((()=>{this.widget&&this.widget.detach()})))}toggleExpanded(e){"keydown"===e.type&&e.target!==this.titleElement||(this.titleElement.classList.contains("expanded")?this.collapse():this.expand())}onTitleKeyDown(e){if(e.target!==this.titleElement)return;const t=e;"ArrowLeft"===t.key?this.collapse():"ArrowRight"===t.key&&(this.titleElement.classList.contains("expanded")?this.widget&&this.widget.focus():this.expand())}}const Li=new WeakMap;class Pi{manager;revealCallback;widgetInternal;constructor(e,t,i){this.manager=e,this.revealCallback=i,this.widgetInternal=t}widget(){return this.widgetInternal}reveal(){this.revealCallback&&this.revealCallback()}showView(e,t,i,n,s){throw new Error("not implemented")}removeView(e){throw new Error("not implemented")}}const Di=new WeakMap;class Ai extends Pi{tabbedPaneInternal;allowReorder;closeableTabSetting;tabOrderSetting;lastSelectedTabSetting;defaultTab;views;constructor(t,i,n,s,o,r){const a=new si;o&&a.setAllowTabReorder(!0),super(t,a,i),this.tabbedPaneInternal=a,this.allowReorder=o,this.tabbedPaneInternal.addEventListener(oi.TabSelected,this.tabSelected,this),this.tabbedPaneInternal.addEventListener(oi.TabClosed,this.tabClosed,this),this.closeableTabSetting=e.Settings.Settings.instance().createSetting("closeable-tabs",{}),this.setOrUpdateCloseableTabsSetting(),this.tabOrderSetting=e.Settings.Settings.instance().createSetting(n+"-tab-order",{}),this.tabbedPaneInternal.addEventListener(oi.TabOrderChanged,this.persistTabOrder,this),s&&(this.lastSelectedTabSetting=e.Settings.Settings.instance().createSetting(n+"-selected-tab","")),this.defaultTab=r,this.views=new Map,n&&this.appendApplicableItems(n)}setOrUpdateCloseableTabsSetting(){const e={...Ii,...this.closeableTabSetting.get()};this.closeableTabSetting.set(e)}widget(){return this.tabbedPaneInternal}tabbedPane(){return this.tabbedPaneInternal}enableMoreTabsButton(){const e=new En(this.appendTabsToMenu.bind(this),void 0,"more-tabs");return this.tabbedPaneInternal.leftToolbar().appendToolbarItem(e),this.tabbedPaneInternal.disableOverflowMenu(),e}appendApplicableItems(e){const t=this.manager.viewsForLocation(e);if(this.allowReorder){let e=0;const i=this.tabOrderSetting.get(),n=new Map;for(const s of t)n.set(s.viewId(),i[s.viewId()]||++e*Ai.orderStep);t.sort(((e,t)=>n.get(e.viewId())-n.get(t.viewId())))}for(const e of t){const t=e.viewId();this.views.set(t,e),Di.set(e,this),e.isTransient()||(e.isCloseable()?this.closeableTabSetting.get()[t]&&this.appendTab(e):this.appendTab(e))}if(this.defaultTab)if(this.tabbedPaneInternal.hasTab(this.defaultTab))this.tabbedPaneInternal.selectTab(this.defaultTab);else{const e=Array.from(this.views.values()).find((e=>e.viewId()===this.defaultTab));e&&this.showView(e)}else this.lastSelectedTabSetting&&this.tabbedPaneInternal.hasTab(this.lastSelectedTabSetting.get())&&this.tabbedPaneInternal.selectTab(this.lastSelectedTabSetting.get())}appendTabsToMenu(e){const t=Array.from(this.views.values());t.sort(((e,t)=>e.title().localeCompare(t.title())));for(const i of t){const t=i.title();"issues-pane"!==i.viewId()?e.defaultSection().appendItem(t,this.showView.bind(this,i,void 0,!0),{jslogContext:i.viewId()}):e.defaultSection().appendItem(t,(()=>{s.userMetrics.issuesPanelOpenedFrom(3),this.showView(i,void 0,!0)}),{jslogContext:"issues-pane"})}}appendTab(e,t){this.tabbedPaneInternal.appendTab(e.viewId(),e.title(),new ki(e),void 0,!1,e.isCloseable()||e.isTransient(),e.isPreviewFeature(),t)}appendView(e,t){if(this.tabbedPaneInternal.hasTab(e.viewId()))return;const i=Di.get(e);let n;i&&i!==this&&i.removeView(e),Di.set(e,this),this.manager.views.set(e.viewId(),e),this.views.set(e.viewId(),e);const s=this.tabbedPaneInternal.tabIds();if(this.allowReorder){const t=this.tabOrderSetting.get(),i=t[e.viewId()];for(let e=0;i&&e<s.length;++e)if(t[s[e]]&&t[s[e]]>i){n=e;break}}else if(t)for(let e=0;e<s.length;++e)if(s[e]===t.viewId()){n=e;break}if(this.appendTab(e,n),e.isCloseable()){const t=this.closeableTabSetting.get(),i=e.viewId();t[i]||(t[i]=!0,this.closeableTabSetting.set(t))}this.persistTabOrder()}async showView(e,t,i,n,s=!0){this.appendView(e,t),s&&this.tabbedPaneInternal.selectTab(e.viewId(),i),n||this.tabbedPaneInternal.focus();const o=this.tabbedPaneInternal.tabView(e.viewId());await o.materialize()}removeView(e){this.tabbedPaneInternal.hasTab(e.viewId())&&(Di.delete(e),this.manager.views.delete(e.viewId()),this.tabbedPaneInternal.closeTab(e.viewId()),this.views.delete(e.viewId()))}tabSelected(e){const{tabId:t}=e.data;this.lastSelectedTabSetting&&e.data.isUserGesture&&this.lastSelectedTabSetting.set(t)}tabClosed(e){const{tabId:t}=e.data,i=this.closeableTabSetting.get();i[t]&&(i[t]=!1,this.closeableTabSetting.set(i));const n=this.views.get(t);n&&n.disposeView()}persistTabOrder(){const e=this.tabbedPaneInternal.tabIds(),t={};for(let i=0;i<e.length;i++)t[e[i]]=(i+1)*Ai.orderStep;const i=this.tabOrderSetting.get(),n=Object.keys(i);n.sort(((e,t)=>i[e]-i[t]));let s=0;for(const e of n)e in t?s=t[e]:t[e]=++s;this.tabOrderSetting.set(t)}getCloseableTabSetting(){return this.closeableTabSetting.get()}static orderStep=10}class Ri extends Pi{vbox;expandableContainers;constructor(e,t,i,n){const s=new Nt;s.element.setAttribute("jslog",`${o.pane(n||"sidebar").track({resize:!0})}`),super(e,s,t),this.vbox=s,V(s.element),this.expandableContainers=new Map,i&&this.appendApplicableItems(i)}appendView(e,t){const i=Di.get(e);i&&i!==this&&i.removeView(e);let n=this.expandableContainers.get(e.viewId());if(!n){Di.set(e,this),this.manager.views.set(e.viewId(),e),n=new Mi(e);let i=null;if(t){const e=Li.get(t);i=e?e.element:null}n.show(this.vbox.contentElement,i),this.expandableContainers.set(e.viewId(),n)}}async showView(e,t){this.appendView(e,t);const i=this.expandableContainers.get(e.viewId());i&&await i.expand()}removeView(e){const t=this.expandableContainers.get(e.viewId());t&&(t.detach(),this.expandableContainers.delete(e.viewId()),Di.delete(e),this.manager.views.delete(e.viewId()))}appendApplicableItems(e){for(const t of this.manager.viewsForLocation(e))this.appendView(t)}}var Bi=Object.freeze({__proto__:null,defaultOptionsForTabs:Ii,PreRegisteredView:yi,ViewManager:Ci,ContainerWidget:ki,getRegisteredViewExtensions:gi,maybeRemoveViewExtension:function(e){const t=mi.findIndex((t=>t.viewId()===e));return!(t<0||!pi.delete(e))&&(mi.splice(t,1),!0)},registerViewExtension:function(e){const t=e.id;if(pi.has(t))throw new Error(`Duplicate view id '${t}'`);pi.add(t),mi.push(new yi(e))},getRegisteredLocationResolvers:vi,registerLocationResolver:function(e){const t=e.name;if(fi.has(t))throw new Error(`Duplicate view location name registration '${t}'`);fi.add(t),bi.push(e)},getLocalizedViewLocationCategory:function(e){switch(e){case"ELEMENTS":return ui(di.elements);case"DRAWER":return ui(di.drawer);case"DRAWER_SIDEBAR":return ui(di.drawer_sidebar);case"PANEL":return ui(di.panel);case"NETWORK":return ui(di.network);case"SETTINGS":return ui(di.settings);case"SOURCES":return ui(di.sources);case"":return t.i18n.lockedString("")}},resetViewRegistration:function(){mi.length=0,bi.length=0,fi.clear(),pi.clear()}});const Oi={moreTools:"More Tools",closeDrawer:"Close drawer",panels:"Panels",reloadDevtools:"Reload DevTools",moveToTop:"Move to top",moveToBottom:"Move to bottom",devToolsLanguageMissmatch:"DevTools is now available in {PH1}!",setToBrowserLanguage:"Always match Chrome's language",setToSpecificLanguage:"Switch DevTools to {PH1}",mainToolbar:"Main toolbar",drawer:"Tool drawer",drawerShown:"Drawer shown",drawerHidden:"Drawer hidden",selectOverrideFolder:"Select a folder to store override files in.",selectFolder:"Select folder"},Fi=t.i18n.registerUIStrings("ui/legacy/InspectorView.ts",Oi),zi=t.i18n.getLocalizedString.bind(void 0,Fi);let Wi=null;class Hi extends Nt{drawerSplitWidget;tabDelegate;drawerTabbedLocation;drawerTabbedPane;infoBarDiv;tabbedLocation;tabbedPane;keyDownBound;currentPanelLocked;focusRestorer;ownerSplitWidget;reloadRequiredInfobar;#t;constructor(){super(),Ts.setContainer(this.element),this.setMinimumSize(250,72),this.drawerSplitWidget=new Gt(!1,!0,"inspector.drawer-split-view-state",200,200),this.drawerSplitWidget.hideSidebar(),this.drawerSplitWidget.enableShowModeSaving(),this.drawerSplitWidget.show(this.element),this.tabDelegate=new ji,this.drawerTabbedLocation=Ci.instance().createTabbedLocation(this.showDrawer.bind(this,{focus:!1,hasTargetDrawer:!0}),"drawer-view",!0,!0);this.drawerTabbedLocation.enableMoreTabsButton().setTitle(zi(Oi.moreTools)),this.drawerTabbedPane=this.drawerTabbedLocation.tabbedPane(),this.drawerTabbedPane.setMinimumSize(0,27),this.drawerTabbedPane.element.classList.add("drawer-tabbed-pane"),this.drawerTabbedPane.element.setAttribute("jslog",`${o.drawer()}`);const i=new wn(zi(Oi.closeDrawer),"cross");i.element.setAttribute("jslog",`${o.close().track({click:!0})}`),i.addEventListener("Click",this.closeDrawer,this),this.drawerTabbedPane.addEventListener(oi.TabSelected,(e=>this.tabSelected(e.data.tabId,"drawer")),this);const r=this.drawerTabbedPane.selectedTabId;"OnlyMain"!==this.drawerSplitWidget.showMode()&&r&&(s.userMetrics.panelShown(r,!0),s.userMetrics.panelShownInLocation(r,"drawer")),this.drawerTabbedPane.setTabDelegate(this.tabDelegate);const a=this.drawerTabbedPane.element;Y(a),be(a,zi(Oi.drawer)),this.drawerSplitWidget.installResizer(this.drawerTabbedPane.headerElement()),this.drawerSplitWidget.setSidebarWidget(this.drawerTabbedPane),this.drawerTabbedPane.rightToolbar().appendToolbarItem(i),this.drawerTabbedPane.headerElement().setAttribute("jslog",`${o.toolbar("drawer").track({drag:!0})}`),this.tabbedLocation=Ci.instance().createTabbedLocation(s.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront.bind(s.InspectorFrontendHost.InspectorFrontendHostInstance),"panel",!0,!0,n.Runtime.Runtime.queryParam("panel")),this.tabbedPane=this.tabbedLocation.tabbedPane(),this.tabbedPane.element.classList.add("main-tabbed-pane");const l=n.Runtime.conditions.canDock()?"69px":"41px";this.tabbedPane.leftToolbar().element.style.minWidth=l,this.tabbedPane.registerRequiredCSS(St),this.tabbedPane.addEventListener(oi.TabSelected,(e=>this.tabSelected(e.data.tabId,"main")),this);const h=this.tabbedPane.selectedTabId;h&&(s.userMetrics.panelShown(h,!0),s.userMetrics.panelShownInLocation(h,"main")),this.tabbedPane.setAccessibleName(zi(Oi.panels)),this.tabbedPane.setTabDelegate(this.tabDelegate);const d=this.tabbedPane.headerElement();if(Q(d),be(d,zi(Oi.mainToolbar)),d.setAttribute("jslog",`${o.toolbar("main").track({drag:!0})}`),s.userMetrics.setLaunchPanel(this.tabbedPane.selectedTabId),s.InspectorFrontendHost.isUnderTest()&&this.tabbedPane.setAutoSelectFirstItemOnShow(!1),this.drawerSplitWidget.setMainWidget(this.tabbedPane),this.keyDownBound=this.keyDown.bind(this),s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.ShowPanel,function({data:e}){this.showPanel(e)}.bind(this)),function(){if(Ni().get())return!1;const i=e.Settings.Settings.instance().moduleSetting("language").get();if("en-US"!==i)return!1;return!t.DevToolsLocale.localeLanguagesMatch(navigator.language,i)&&t.DevToolsLocale.DevToolsLocale.instance().languageIsSupportedByDevTools(navigator.language)}()){const i=function(){const i=t.DevToolsLocale.DevToolsLocale.instance(),n=i.lookupClosestDevToolsLocale(navigator.language),s=new Intl.Locale(n),o=new Intl.DisplayNames([i.locale],{type:"language"}).of(s.language||"en")||"English",r=e.Settings.Settings.instance().moduleSetting("language");return new It("info",zi(Oi.devToolsLanguageMissmatch,{PH1:o}),[{text:zi(Oi.setToBrowserLanguage),highlight:!0,delegate:()=>{r.set("browserLanguage"),Ni().set(!0),_i()},dismiss:!0,jslogContext:"set-to-browser-language"},{text:zi(Oi.setToSpecificLanguage,{PH1:o}),highlight:!0,delegate:()=>{r.set(n),Ni().set(!0),_i()},dismiss:!0,jslogContext:"set-to-specific-language"}],Ni(),void 0,"language-mismatch")}();i.setParentView(this),this.attachInfobar(i)}}static instance(e={forceNew:null}){const{forceNew:t}=e;return Wi&&!t||(Wi=new Hi),Wi}static maybeGetInspectorViewInstance(){return Wi}static removeInstance(){Wi=null}wasShown(){this.element.ownerDocument.addEventListener("keydown",this.keyDownBound,!1)}willHide(){this.element.ownerDocument.removeEventListener("keydown",this.keyDownBound,!1)}resolveLocation(e){return"drawer-view"===e?this.drawerTabbedLocation:"panel"===e?this.tabbedLocation:null}async createToolbars(){await this.tabbedPane.leftToolbar().appendItemsAtLocation("main-toolbar-left"),await this.tabbedPane.rightToolbar().appendItemsAtLocation("main-toolbar-right")}addPanel(e){this.tabbedLocation.appendView(e)}hasPanel(e){return this.tabbedPane.hasTab(e)}async panel(e){const t=Ci.instance().view(e);if(!t)throw new Error(`Expected view for panel '${e}'`);return t.widget()}onSuspendStateChanged(e){this.currentPanelLocked=e,this.tabbedPane.setCurrentTabLocked(this.currentPanelLocked),this.tabbedPane.leftToolbar().setEnabled(!this.currentPanelLocked),this.tabbedPane.rightToolbar().setEnabled(!this.currentPanelLocked)}canSelectPanel(e){return!this.currentPanelLocked||this.tabbedPane.selectedTabId===e}async showPanel(e){await Ci.instance().showView(e)}setPanelWarnings(e,t){const i=this.getTabbedPaneForTabId(e);if(i){let n=null;if(0!==t.length){const e=1===t.length?t[0]:"· "+t.join("\n· ");n=a.Icon.create("warning-filled"),Jt.install(n,e)}i.setTabIcon(e,n)}}emitDrawerChangeEvent(e){const t=new CustomEvent("drawerchange",{bubbles:!0,cancelable:!0,detail:{isDrawerOpen:e}});document.body.dispatchEvent(t)}getTabbedPaneForTabId(e){return this.tabbedPane.hasTab(e)?this.tabbedPane:this.drawerTabbedPane.hasTab(e)?this.drawerTabbedPane:null}currentPanelDeprecated(){return Ci.instance().materializedWidget(this.tabbedPane.selectedTabId||"")}showDrawer({focus:e,hasTargetDrawer:t}){this.drawerTabbedPane.isShowing()||(this.drawerTabbedPane.setAutoSelectFirstItemOnShow(!t),this.drawerSplitWidget.showBoth(),this.focusRestorer=e?new jt(this.drawerTabbedPane):null,this.emitDrawerChangeEvent(!0),Se(zi(Oi.drawerShown)))}drawerVisible(){return this.drawerTabbedPane.isShowing()}closeDrawer(){this.drawerTabbedPane.isShowing()&&(this.focusRestorer&&this.focusRestorer.restore(),this.drawerSplitWidget.hideSidebar(!0),this.emitDrawerChangeEvent(!1),Se(zi(Oi.drawerHidden)))}setDrawerMinimized(e){this.drawerSplitWidget.setSidebarMinimized(e),this.drawerSplitWidget.setResizable(!e)}isDrawerMinimized(){return this.drawerSplitWidget.isSidebarMinimized()}closeDrawerTab(e,t){this.drawerTabbedPane.closeTab(e,t),s.userMetrics.panelClosed(e)}keyDown(t){const i=t;if(!Ke.eventHasCtrlEquivalentKey(i)||i.altKey||i.shiftKey)return;if(e.Settings.moduleSetting("shortcut-panel-switch").get()){let e=-1;if(i.keyCode>48&&i.keyCode<58?e=i.keyCode-49:i.keyCode>96&&i.keyCode<106&&i.location===KeyboardEvent.DOM_KEY_LOCATION_NUMPAD&&(e=i.keyCode-97),-1!==e){const i=this.tabbedPane.tabIds()[e];i&&(Ds.hasInstance()||this.currentPanelLocked||this.showPanel(i),t.consume(!0))}}}onResize(){Ts.containerMoved(this.element)}topResizerElement(){return this.tabbedPane.headerElement()}toolbarItemResized(){this.tabbedPane.headerResized()}tabSelected(e,t){s.userMetrics.panelShown(e),s.userMetrics.panelShownInLocation(e,t)}setOwnerSplit(e){this.ownerSplitWidget=e}ownerSplit(){return this.ownerSplitWidget||null}minimize(){this.ownerSplitWidget&&this.ownerSplitWidget.setSidebarMinimized(!0)}restore(){this.ownerSplitWidget&&this.ownerSplitWidget.setSidebarMinimized(!1)}displayReloadRequiredWarning(e){if(!this.reloadRequiredInfobar){const t=new It("info",e,[{text:zi(Oi.reloadDevtools),highlight:!0,delegate:()=>_i(),dismiss:!1,jslogContext:"main.debug-reload"}],void 0,void 0,"reload-required");t.setParentView(this),this.attachInfobar(t),this.reloadRequiredInfobar=t,t.setCloseCallback((()=>{delete this.reloadRequiredInfobar}))}}displaySelectOverrideFolderInfobar(e){if(!this.#t){const t=new It("info",zi(Oi.selectOverrideFolder),[{text:zi(Oi.selectFolder),highlight:!0,delegate:()=>e(),dismiss:!0,jslogContext:"select-folder"}],void 0,void 0,"select-override-folder");t.setParentView(this),this.attachInfobar(t),this.#t=t,t.setCloseCallback((()=>{this.#t=void 0}))}}createInfoBarDiv(){this.infoBarDiv||(this.infoBarDiv=document.createElement("div"),this.infoBarDiv.classList.add("flex-none"),this.contentElement.insertBefore(this.infoBarDiv,this.contentElement.firstChild))}attachInfobar(e){this.createInfoBarDiv(),this.infoBarDiv?.appendChild(e.element)}}function Ni(){return e.Settings.Settings.instance().createSetting("disable-locale-info-bar",!1)}function _i(){mt.instance().canDock()&&"undocked"===mt.instance().dockSide()&&s.InspectorFrontendHost.InspectorFrontendHostInstance.setIsDocked(!0,(function(){})),s.InspectorFrontendHost.InspectorFrontendHostInstance.reattach((()=>window.location.reload()))}class ji{closeTabs(e,t){e.closeTabs(t,!0),t.forEach((e=>{s.userMetrics.panelClosed(e)}))}moveToDrawer(e){s.userMetrics.actionTaken(s.UserMetrics.Action.TabMovedToDrawer),Ci.instance().moveView(e,"drawer-view")}moveToMainPanel(e){s.userMetrics.actionTaken(s.UserMetrics.Action.TabMovedToMainPanel),Ci.instance().moveView(e,"panel")}onContextMenu(e,t){if("console"===e||"console-view"===e)return;"drawer-view"===Ci.instance().locationNameForViewId(e)?t.defaultSection().appendItem(zi(Oi.moveToTop),this.moveToMainPanel.bind(this,e),{jslogContext:"move-to-top"}):t.defaultSection().appendItem(zi(Oi.moveToBottom),this.moveToDrawer.bind(this,e),{jslogContext:"move-to-bottom"})}}var Vi=Object.freeze({__proto__:null,InspectorView:Hi,ActionDelegate:class{handleAction(e,t){switch(t){case"main.toggle-drawer":return Hi.instance().drawerVisible()?Hi.instance().closeDrawer():Hi.instance().showDrawer({focus:!0,hasTargetDrawer:!1}),!0;case"main.next-tab":return Hi.instance().tabbedPane.selectNextTab(),Hi.instance().tabbedPane.focus(),!0;case"main.previous-tab":return Hi.instance().tabbedPane.selectPrevTab(),Hi.instance().tabbedPane.focus(),!0}return!1}},InspectorViewTabDelegate:ji});const Ui={srequiresReload:"*Requires reload",oneOrMoreSettingsHaveChanged:"One or more settings have changed which requires a reload to take effect."},Ki=t.i18n.registerUIStrings("ui/legacy/SettingsUI.ts",Ui),qi=t.i18n.getLocalizedString.bind(void 0,Ki),$i=function(e,t,i){const n=e;function o(){n.checked!==t.get()&&(n.checked=t.get())}t.addChangeListener(o),o(),n.addEventListener("change",(function(){t.get()!==n.checked&&t.set(n.checked),t.get()&&i?.enable&&s.userMetrics.actionTaken(i.enable),!t.get()&&i?.disable&&s.userMetrics.actionTaken(i.disable),i?.toggle&&s.userMetrics.actionTaken(i.toggle)}),!1)};var Gi,Xi=Object.freeze({__proto__:null,createSettingCheckbox:function(e,t,i,n){const s=ls.create(e,void 0,void 0,t.name);n&&Jt.install(s,n);const o=s.checkboxElement;if(o.name=e,$i(o,t),i)return s;const r=document.createElement("p");return r.appendChild(s),r},bindCheckbox:$i,createCustomSetting:function(e,t){const i=document.createElement("p");i.classList.add("settings-select");const n=i.createChild("label");return n.textContent=e,B(n,t),i.appendChild(t),i},createControlForSetting:function(e,t){const n=e.title();switch(e.type()){case"boolean":{const t=new h.SettingCheckbox.SettingCheckbox;return t.data={setting:e},t.onchange=()=>{Hi.instance().displayReloadRequiredWarning(qi(Ui.oneOrMoreSettingsHaveChanged))},t}case"enum":return Array.isArray(e.options())?function(e,t,n,s,r){const a=document.createElement("div"),l=a.createChild("p");l.classList.add("settings-select");const d=l.createChild("label"),c=l.createChild("select","chrome-select");d.textContent=e,r&&(a.classList.add("chrome-select-label"),d.createChild("p").textContent=r),c.setAttribute("jslog",`${o.dropDown().track({change:!0}).context(s.name)}`),B(d,c);for(const e of t)e.text&&"string"==typeof e.value&&c.add(as(e.text,e.value,i.StringUtilities.toKebabCase(e.value)));let u=null;n&&(u=a.createChild("span","reload-warning hidden"),u.textContent=qi(Ui.srequiresReload),O(u));const{deprecation:m}=s;if(m){const e=new h.SettingDeprecationWarning.SettingDeprecationWarning;e.data=m,d.appendChild(e)}return s.addChangeListener(p),p(),c.addEventListener("change",(function(){s.set(t[c.selectedIndex].value),u&&(u.classList.remove("hidden"),Hi.instance().displayReloadRequiredWarning(qi(Ui.oneOrMoreSettingsHaveChanged)))}),!1),a;function p(){const e=s.get();for(let i=0;i<t.length;i++)t[i].value===e&&(c.selectedIndex=i);c.disabled=s.disabled()}}(n,e.options(),e.reloadRequired(),e,t):(console.error("Enum setting defined without options"),null);default:return console.error("Invalid setting type: "+e.type()),null}}});!function(e){e.NonViewport="UI.ListMode.NonViewport",e.EqualHeightItems="UI.ListMode.EqualHeightItems",e.VariousHeightItems="UI.ListMode.VariousHeightItems"}(Gi||(Gi={}));class Yi{element;topElement;bottomElement;firstIndex;lastIndex;renderedHeight;topHeight;bottomHeight;model;itemToElement;selectedIndexInternal;selectedItemInternal;delegate;mode;fixedHeight;variableOffsets;constructor(e,t,i){this.element=document.createElement("div"),this.element.style.overflowY="auto",this.topElement=this.element.createChild("div"),this.bottomElement=this.element.createChild("div"),this.firstIndex=0,this.lastIndex=0,this.renderedHeight=0,this.topHeight=0,this.bottomHeight=0,this.model=e,this.model.addEventListener("ItemsReplaced",this.replacedItemsInRange,this),this.itemToElement=new Map,this.selectedIndexInternal=-1,this.selectedItemInternal=null,this.element.tabIndex=-1,this.element.addEventListener("click",this.onClick.bind(this),!1),this.element.addEventListener("keydown",this.onKeyDown.bind(this),!1),Z(this.element),this.delegate=t,this.mode=i||Gi.EqualHeightItems,this.fixedHeight=0,this.variableOffsets=new Int32Array(0),this.clearContents(),this.mode!==Gi.NonViewport&&this.element.addEventListener("scroll",(()=>{this.updateViewport(this.element.scrollTop,this.element.offsetHeight)}),!1)}setModel(e){this.itemToElement.clear();const t=this.model.length;this.model.removeEventListener("ItemsReplaced",this.replacedItemsInRange,this),this.model=e,this.model.addEventListener("ItemsReplaced",this.replacedItemsInRange,this),this.invalidateRange(0,t)}replacedItemsInRange(e){const t=e.data,i=t.index,n=i+t.removed.length,s=t.keepSelectedIndex,o=this.selectedItemInternal,r=null!==o&&this.itemToElement.get(o)||null;for(let e=0;e<t.removed.length;e++)this.itemToElement.delete(t.removed[e]);if(this.invalidate(i,n,t.inserted),this.selectedIndexInternal>=n)this.selectedIndexInternal+=t.inserted-(n-i),this.selectedItemInternal=this.model.at(this.selectedIndexInternal);else if(this.selectedIndexInternal>=i){const e=s?i:i+t.inserted;let n=this.findFirstSelectable(e,1,!1);if(-1===n){const e=s?i:i-1;n=this.findFirstSelectable(e,-1,!1)}this.select(n,o,r)}}refreshItem(e){const t=this.model.indexOf(e);-1!==t?this.refreshItemByIndex(t):console.error("Item to refresh is not present")}refreshItemByIndex(e){const t=this.model.at(e);this.itemToElement.delete(t),this.invalidateRange(e,e+1),-1!==this.selectedIndexInternal&&this.select(this.selectedIndexInternal,null,null)}refreshAllItems(){this.itemToElement.clear(),this.invalidateRange(0,this.model.length),-1!==this.selectedIndexInternal&&this.select(this.selectedIndexInternal,null,null)}invalidateRange(e,t){this.invalidate(e,t,t-e)}viewportResized(){if(this.mode===Gi.NonViewport)return;const e=this.element.scrollTop,t=this.element.offsetHeight;this.clearViewport(),this.updateViewport(i.NumberUtilities.clamp(e,0,this.totalHeight()-t),t)}invalidateItemHeight(){this.mode===Gi.EqualHeightItems?(this.fixedHeight=0,this.model.length&&(this.itemToElement.clear(),this.invalidate(0,this.model.length,this.model.length))):console.error("Only supported in equal height items mode")}itemForNode(e){for(;e&&e.parentNodeOrShadowHost()!==this.element;)e=e.parentNodeOrShadowHost();if(!e)return null;const t=e,i=this.model.findIndex((e=>this.itemToElement.get(e)===t));return-1!==i?this.model.at(i):null}scrollItemIntoView(e,t){const i=this.model.indexOf(e);-1!==i?this.scrollIntoView(i,t):console.error("Attempt to scroll onto missing item")}selectedItem(){return this.selectedItemInternal}selectedIndex(){return this.selectedIndexInternal}selectItem(e,t,i){let n=-1;if(null!==e){if(n=this.model.indexOf(e),-1===n)return void console.error("Attempt to select missing item");if(!this.delegate.isItemSelectable(e))return void console.error("Attempt to select non-selectable item")}-1===n||i||this.scrollIntoView(n,t),this.selectedIndexInternal!==n&&this.select(n)}selectPreviousItem(e,t){if(-1===this.selectedIndexInternal&&!e)return!1;let i=-1===this.selectedIndexInternal?this.model.length-1:this.selectedIndexInternal-1;return i=this.findFirstSelectable(i,-1,Boolean(e)),-1!==i&&(this.scrollIntoView(i,t),this.select(i),!0)}selectNextItem(e,t){if(-1===this.selectedIndexInternal&&!e)return!1;let i=-1===this.selectedIndexInternal?0:this.selectedIndexInternal+1;return i=this.findFirstSelectable(i,1,Boolean(e)),-1!==i&&(this.scrollIntoView(i,t),this.select(i),!0)}selectItemPreviousPage(e){if(this.mode===Gi.NonViewport)return!1;let t=-1===this.selectedIndexInternal?this.model.length-1:this.selectedIndexInternal;return t=this.findPageSelectable(t,-1),-1!==t&&(this.scrollIntoView(t,e),this.select(t),!0)}selectItemNextPage(e){if(this.mode===Gi.NonViewport)return!1;let t=-1===this.selectedIndexInternal?0:this.selectedIndexInternal;return t=this.findPageSelectable(t,1),-1!==t&&(this.scrollIntoView(t,e),this.select(t),!0)}scrollIntoView(e,t){if(this.mode===Gi.NonViewport)return void this.elementAtIndex(e).scrollIntoViewIfNeeded(Boolean(t));const n=this.offsetAtIndex(e),s=this.offsetAtIndex(e+1),o=this.element.offsetHeight;if(t){const e=(n+s)/2-o/2;return void this.updateViewport(i.NumberUtilities.clamp(e,0,this.totalHeight()-o),o)}const r=this.element.scrollTop;n<r?this.updateViewport(n,o):s>r+o&&this.updateViewport(s-o,o)}onClick(e){const t=this.itemForNode(e.target);null!==t&&this.delegate.isItemSelectable(t)&&this.selectItem(t)}onKeyDown(e){const t=e;let i=!1;switch(t.key){case"ArrowUp":i=this.selectPreviousItem(!0,!1);break;case"ArrowDown":i=this.selectNextItem(!0,!1);break;case"PageUp":i=this.selectItemPreviousPage(!1);break;case"PageDown":i=this.selectItemNextPage(!1)}i&&t.consume(!0)}totalHeight(){return this.offsetAtIndex(this.model.length)}indexAtOffset(e){if(this.mode===Gi.NonViewport)throw"There should be no offset conversions in non-viewport mode";return!this.model.length||e<0?0:this.mode===Gi.VariousHeightItems?Math.min(this.model.length-1,i.ArrayUtilities.lowerBound(this.variableOffsets,e,i.ArrayUtilities.DEFAULT_COMPARATOR,0,this.model.length)):(this.fixedHeight||this.measureHeight(),Math.min(this.model.length-1,Math.floor(e/this.fixedHeight)))}elementAtIndex(e){const t=this.model.at(e);let i=this.itemToElement.get(t);return i||(i=this.delegate.createElementForItem(t),i.hasAttribute("jslog")||i.setAttribute("jslog",`${o.item().track({click:!0})}`),this.itemToElement.set(t,i),this.updateElementARIA(i,e)),i}refreshARIA(){for(let e=this.firstIndex;e<=this.lastIndex;e++){const t=this.model.at(e),i=this.itemToElement.get(t);i&&this.updateElementARIA(i,e)}}updateElementARIA(e,t){ne(e)||ee(e),we(e,this.model.length),xe(e,t+1)}offsetAtIndex(e){if(this.mode===Gi.NonViewport)throw new Error("There should be no offset conversions in non-viewport mode");return this.model.length?this.mode===Gi.VariousHeightItems?this.variableOffsets[e]:(this.fixedHeight||this.measureHeight(),e*this.fixedHeight):0}measureHeight(){this.fixedHeight=this.delegate.heightForItem(this.model.at(0)),this.fixedHeight||(this.fixedHeight=Qn(this.elementAtIndex(0),this.element).height)}select(e,t,i){void 0===t&&(t=this.selectedItemInternal),void 0===i&&(i=this.itemToElement.get(t)||null),this.selectedIndexInternal=e,this.selectedItemInternal=-1===e?null:this.model.at(e);const n=this.selectedItemInternal,s=-1!==this.selectedIndexInternal?this.elementAtIndex(e):null;this.delegate.selectedItemChanged(t,n,i,s),this.delegate.updateSelectedItemARIA(i,s)||(i&&ue(i,!1),s&&ue(s,!0),ve(this.element,s))}findFirstSelectable(e,t,i){const n=this.model.length;if(!n)return-1;for(let s=0;s<=n;s++){if(e<0||e>=n){if(!i)return-1;e=(e+n)%n}if(this.delegate.isItemSelectable(this.model.at(e)))return e;e+=t}return-1}findPageSelectable(e,t){let i=-1;const n=this.offsetAtIndex(e),s=this.element.offsetHeight-1;for(;e>=0&&e<this.model.length;){if(this.delegate.isItemSelectable(this.model.at(e))){if(Math.abs(this.offsetAtIndex(e)-n)>=s)return e;i=e}e+=t}return i}reallocateVariableOffsets(e,t){if(this.variableOffsets.length<e){const i=new Int32Array(Math.max(e,2*this.variableOffsets.length));i.set(this.variableOffsets.slice(0,t),0),this.variableOffsets=i}else if(this.variableOffsets.length>=2*e){const i=new Int32Array(e);i.set(this.variableOffsets.slice(0,t),0),this.variableOffsets=i}}invalidate(e,t,n){if(this.mode===Gi.NonViewport)return void this.invalidateNonViewportMode(e,t-e,n);if(this.mode===Gi.VariousHeightItems){this.reallocateVariableOffsets(this.model.length+1,e+1);for(let t=e+1;t<=this.model.length;t++)this.variableOffsets[t]=this.variableOffsets[t-1]+this.delegate.heightForItem(this.model.at(t-1))}const s=this.element.offsetHeight,o=this.totalHeight(),r=this.element.scrollTop;if(this.renderedHeight<s||o<s)return this.clearViewport(),void this.updateViewport(i.NumberUtilities.clamp(r,0,o-s),s);const a=o-this.renderedHeight;if(t<=this.firstIndex){const i=this.topHeight+a;this.topElement.style.height=i+"px",this.element.scrollTop=r+a,this.topHeight=i,this.renderedHeight=o;const s=n-(t-e);return this.firstIndex+=s,void(this.lastIndex+=s)}if(e>=this.lastIndex){const e=this.bottomHeight+a;return this.bottomElement.style.height=e+"px",this.bottomHeight=e,void(this.renderedHeight=o)}this.clearViewport(),this.updateViewport(i.NumberUtilities.clamp(r,0,o-s),s),this.refreshARIA()}invalidateNonViewportMode(e,t,i){let n=this.topElement;for(let t=0;t<e;t++)n=n.nextElementSibling;for(;t--;)n.nextElementSibling.remove();for(;i--;)this.element.insertBefore(this.elementAtIndex(e+i),n.nextElementSibling)}clearViewport(){this.mode!==Gi.NonViewport?(this.firstIndex=0,this.lastIndex=0,this.renderedHeight=0,this.topHeight=0,this.bottomHeight=0,this.clearContents()):console.error("There should be no viewport updates in non-viewport mode")}clearContents(){this.topElement.style.height="0",this.bottomElement.style.height="0",this.element.removeChildren(),this.element.appendChild(this.topElement),this.element.appendChild(this.bottomElement)}updateViewport(e,t){if(this.mode===Gi.NonViewport)return void console.error("There should be no viewport updates in non-viewport mode");const i=this.totalHeight();if(!i)return this.firstIndex=0,this.lastIndex=0,this.topHeight=0,this.bottomHeight=0,this.renderedHeight=0,this.topElement.style.height="0",void(this.bottomElement.style.height="0");const n=this.indexAtOffset(e-t),s=this.indexAtOffset(e+2*t)+1;for(;this.firstIndex<Math.min(n,this.lastIndex);)this.elementAtIndex(this.firstIndex).remove(),this.firstIndex++;for(;this.lastIndex>Math.max(s,this.firstIndex);)this.elementAtIndex(this.lastIndex-1).remove(),this.lastIndex--;this.firstIndex=Math.min(this.firstIndex,s),this.lastIndex=Math.max(this.lastIndex,n);for(let e=this.firstIndex-1;e>=n;e--){const t=this.elementAtIndex(e);this.element.insertBefore(t,this.topElement.nextSibling)}for(let e=this.lastIndex;e<s;e++){const t=this.elementAtIndex(e);this.element.insertBefore(t,this.bottomElement)}this.firstIndex=n,this.lastIndex=s,this.topHeight=this.offsetAtIndex(n),this.topElement.style.height=this.topHeight+"px",this.bottomHeight=i-this.offsetAtIndex(s),this.bottomElement.style.height=this.bottomHeight+"px",this.renderedHeight=i,this.element.scrollTop=e}}var Qi=Object.freeze({__proto__:null,get ListMode(){return Gi},ListControl:Yi});class Zi extends e.ObjectWrapper.ObjectWrapper{items;constructor(e){super(),this.items=e||[]}[Symbol.iterator](){return this.items[Symbol.iterator]()}get length(){return this.items.length}at(e){return this.items[e]}every(e){return this.items.every(e)}filter(e){return this.items.filter(e)}find(e){return this.items.find(e)}findIndex(e){return this.items.findIndex(e)}indexOf(e,t){return this.items.indexOf(e,t)}insert(e,t){this.items.splice(e,0,t),this.replaced(e,[],1)}insertWithComparator(e,t){this.insert(i.ArrayUtilities.lowerBound(this.items,e,t),e)}join(e){return this.items.join(e)}remove(e){const t=this.items[e];return this.items.splice(e,1),this.replaced(e,[t],0),t}replace(e,t,i){const n=this.items[e];return this.items[e]=t,this.replaced(e,[n],1,i),n}replaceRange(e,t,i){let n;if(i.length<1e4)n=this.items.splice(e,t-e,...i);else{n=this.items.slice(e,t);const s=this.items.slice(0,e),o=this.items.slice(t);this.items=[...s,...i,...o]}return this.replaced(e,n,i.length),n}replaceAll(e){const t=this.items.slice();return this.items=e,this.replaced(0,t,e.length),t}slice(e,t){return this.items.slice(e,t)}some(e){return this.items.some(e)}replaced(e,t,i,n){this.dispatchEventToListeners("ItemsReplaced",{index:e,removed:t,inserted:i,keepSelectedIndex:n})}}var Ji=Object.freeze({__proto__:null,ListModel:Zi}),en={cssContent:":host{display:flex;flex:auto}.suggest-box{flex:auto;background-color:var(--sys-color-cdt-base-container);pointer-events:auto;margin-left:-3px;box-shadow:var(--drop-shadow);overflow-x:hidden}.suggest-box-content-item{padding:1px 0 1px 1px;margin:0;border:1px solid transparent;white-space:nowrap;display:flex;align-items:center;justify-content:space-between}.suggest-box-content-item.secondary{background-color:var(--sys-color-neutral-container);justify-content:normal}.suggestion-title{overflow:hidden;text-overflow:ellipsis}.suggestion-title span{white-space:pre}.suggestion-subtitle{flex:auto;text-align:right;color:var(--sys-color-token-subtle);margin-right:3px;overflow:hidden;text-overflow:ellipsis}.suggest-box-content-item devtools-icon{color:var(--sys-color-on-surface-subtle);margin-right:1px}.suggest-box-content-item .query{font-weight:bold}.suggest-box-content-item .spacer{display:inline-block;width:20px}.suggest-box-content-item.selected{background-color:var(--sys-color-tonal-container)}.suggest-box-content-item.selected .suggestion-subtitle,\n.suggest-box-content-item.selected > span{color:var(--sys-color-on-tonal-container)}.suggest-box-content-item:hover:not(.selected){background-color:var(--sys-color-state-hover-on-subtle)}@media (forced-colors: active){.suggest-box-content-item.selected{forced-color-adjust:none;background-color:Highlight}.suggest-box-content-item.selected > span{color:HighlightText}}"};const tn={sSuggestionSOfS:"{PH1}, suggestion {PH2} of {PH3}",sSuggestionSSelected:"{PH1}, suggestion selected"},nn=t.i18n.registerUIStrings("ui/legacy/SuggestBox.ts",tn),sn=t.i18n.getLocalizedString.bind(void 0,nn);class on{suggestBoxDelegate;maxItemsHeight;rowHeight;userEnteredText;defaultSelectionIsDimmed;onlyCompletion;items;list;element;glassPane;constructor(e,t){this.suggestBoxDelegate=e,this.maxItemsHeight=t,this.rowHeight=17,this.userEnteredText="",this.defaultSelectionIsDimmed=!1,this.onlyCompletion=null,this.items=new Zi,this.list=new Yi(this.items,this,Gi.EqualHeightItems),this.element=this.list.element,this.element.classList.add("suggest-box"),this.element.addEventListener("mousedown",(e=>e.preventDefault()),!0),this.element.addEventListener("click",this.onClick.bind(this),!1),this.glassPane=new Ts,this.glassPane.setAnchorBehavior("PreferBottom"),this.glassPane.setOutsideClickCallback(this.hide.bind(this));d.createShadowRootWithCoreStyles(this.glassPane.contentElement,{cssFile:en,delegatesFocus:void 0}).appendChild(this.element)}visible(){return this.glassPane.isShowing()}setPosition(e){this.glassPane.setContentAnchorBox(e)}setAnchorBehavior(e){this.glassPane.setAnchorBehavior(e)}updateMaxSize(e){const t=this.maxWidth(e),i=(this.maxItemsHeight?Math.min(this.maxItemsHeight,e.length):e.length)*this.rowHeight;this.glassPane.setMaxContentSize(new _e(t,i))}maxWidth(e){if(!e.length)return 300;let t,i=-1/0;for(let n=0;n<e.length;n++){const s=(e[n].title||e[n].text).length+(e[n].subtitle||"").length;s>i&&(i=s,t=e[n])}const n=Qn(this.createElementForItem(t),this.element).width+d.measuredScrollbarWidth(this.element.ownerDocument);return Math.min(300,n)}show(){if(this.visible())return;this.glassPane.show(document);this.rowHeight=Qn(this.createElementForItem({text:"1",subtitle:"12"}),this.element).height,re(this.suggestBoxDelegate.ariaControlledBy(),this.element),ae(this.suggestBoxDelegate.ariaControlledBy(),!0)}hide(){this.visible()&&(this.glassPane.hide(),re(this.suggestBoxDelegate.ariaControlledBy(),null),ae(this.suggestBoxDelegate.ariaControlledBy(),!1))}applySuggestion(e){if(this.onlyCompletion)return Se(e?sn(tn.sSuggestionSOfS,{PH1:this.onlyCompletion.text,PH2:this.list.selectedIndex()+1,PH3:this.items.length}):sn(tn.sSuggestionSSelected,{PH1:this.onlyCompletion.text})),this.suggestBoxDelegate.applySuggestion(this.onlyCompletion,e),!0;const t=this.list.selectedItem();return t&&t.text&&Se(e?sn(tn.sSuggestionSOfS,{PH1:t.title||t.text,PH2:this.list.selectedIndex()+1,PH3:this.items.length}):sn(tn.sSuggestionSSelected,{PH1:t.title||t.text})),this.suggestBoxDelegate.applySuggestion(t,e),this.visible()&&Boolean(t)}acceptSuggestion(){const e=this.applySuggestion();return this.hide(),!!e&&(this.suggestBoxDelegate.acceptSuggestion(),!0)}createElementForItem(e){const t=this.userEnteredText,n=document.createElement("div");n.classList.add("suggest-box-content-item"),n.classList.add("source-code"),e.isSecondary&&n.classList.add("secondary"),n.tabIndex=-1;const s=50+t.length,o=i.StringUtilities.trimEndWithMaxLength((e.title||e.text).trim(),s).replace(/\n/g,"↵"),r=n.createChild("span","suggestion-title"),a=o.toLowerCase().indexOf(t.toLowerCase());if(a>0&&(r.createChild("span").textContent=o.substring(0,a)),a>-1&&(r.createChild("span","query").textContent=o.substring(a,a+t.length)),r.createChild("span").textContent=o.substring(a>-1?a+t.length:0),r.createChild("span","spacer"),e.subtitleRenderer){const t=e.subtitleRenderer.call(null);t.classList.add("suggestion-subtitle"),n.appendChild(t)}else if(e.subtitle){n.createChild("span","suggestion-subtitle").textContent=i.StringUtilities.trimEndWithMaxLength(e.subtitle,s-o.length)}return e.iconElement&&n.appendChild(e.iconElement),n}heightForItem(e){return this.rowHeight}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,n){i&&i.classList.remove("selected","force-white-icons"),n&&(n.classList.add("selected"),n.classList.add("force-white-icons")),this.applySuggestion(!0)}updateSelectedItemARIA(e,t){return!1}onClick(e){const t=this.list.itemForNode(e.target);t&&(this.list.selectItem(t),this.acceptSuggestion(),e.consume(!0))}canShowBox(e,t,i,n){return!(!e||!e.length)&&(e.length>1||(!(t&&!t.isSecondary&&t.text.startsWith(n))||i&&t.text!==n))}updateSuggestions(e,t,i,n,s){this.onlyCompletion=null;const o=i?t.reduce(((e,t)=>(e.priority||0)>=(t.priority||0)?e:t)):null;this.canShowBox(t,o,n,s)?(this.userEnteredText=s,this.show(),this.updateMaxSize(t),this.glassPane.setContentAnchorBox(e),this.list.invalidateItemHeight(),this.items.replaceAll(t),o&&!o.isSecondary?this.list.selectItem(o,!0):this.list.selectItem(null)):(1===t.length&&(this.onlyCompletion=t[0],this.applySuggestion(!0)),this.hide())}keyPressed(e){switch(e.key){case"Enter":return this.enterKeyPressed();case"ArrowUp":return this.list.selectPreviousItem(!0,!1);case"ArrowDown":return this.list.selectNextItem(!0,!1);case"PageUp":return this.list.selectItemPreviousPage(!1);case"PageDown":return this.list.selectItemNextPage(!1)}return!1}enterKeyPressed(){const e=Boolean(this.list.selectedItem())||Boolean(this.onlyCompletion);return this.acceptSuggestion(),e}}var rn=Object.freeze({__proto__:null,SuggestBox:on}),an={cssContent:'.text-prompt-root{display:flex;align-items:center}.text-prompt-editing{box-shadow:var(--drop-shadow);background-color:var(--sys-color-cdt-base-container);text-overflow:clip!important;margin:0 -2px -1px;padding:0 2px 1px;opacity:100%!important}.text-prompt{cursor:text;overflow-x:visible}.text-prompt::-webkit-scrollbar{display:none}.text-prompt-editing > .text-prompt{color:var(--sys-color-on-surface)!important;text-decoration:none!important;white-space:pre}.text-prompt > .auto-complete-text{color:var(--sys-color-token-subtle)!important}.text-prompt[data-placeholder]:empty::before{content:attr(data-placeholder);color:var(--sys-color-token-subtle)}.text-prompt:not([data-placeholder]):empty::after{content:"\\00A0";width:0;display:block}.text-prompt.disabled{opacity:50%;cursor:default}.text-prompt-editing br{display:none}.text-prompt-root:not(:focus-within) ::selection{background:transparent}@media (forced-colors: active){.text-prompt[data-placeholder]:empty::before{color:GrayText!important}.text-prompt.disabled{opacity:100%}}'};class ln extends e.ObjectWrapper.ObjectWrapper{proxyElement;proxyElementDisplay;autocompletionTimeout;titleInternal;queryRange;previousText;currentSuggestion;completionRequestId;ghostTextElement;leftParenthesesIndices;loadCompletions;completionStopCharacters;usesSuggestionBuilder;elementInternal;boundOnKeyDown;boundOnInput;boundOnMouseWheel;boundClearAutocomplete;contentElement;suggestBox;isEditing;focusRestorer;blurListener;oldTabIndex;completeTimeout;disableDefaultSuggestionForEmptyInputInternal;jslogContext=void 0;constructor(){super(),this.proxyElementDisplay="inline-block",this.autocompletionTimeout=hn,this.titleInternal="",this.queryRange=null,this.previousText="",this.currentSuggestion=null,this.completionRequestId=0,this.ghostTextElement=document.createElement("span"),this.ghostTextElement.classList.add("auto-complete-text"),this.ghostTextElement.setAttribute("contenteditable","false"),this.leftParenthesesIndices=[],te(this.ghostTextElement)}initialize(e,t,i){this.loadCompletions=e,this.completionStopCharacters=t||" =:[({;,!+-*/&|^<>.",this.usesSuggestionBuilder=i||!1}setAutocompletionTimeout(e){this.autocompletionTimeout=e}renderAsBlock(){this.proxyElementDisplay="block"}attach(e){return this.attachInternal(e)}attachAndStartEditing(e,t){const i=this.attachInternal(e);return this.startEditing(t),i}attachInternal(e){if(this.proxyElement)throw"Cannot attach an attached TextPrompt";this.elementInternal=e,this.boundOnKeyDown=this.onKeyDown.bind(this),this.boundOnInput=this.onInput.bind(this),this.boundOnMouseWheel=this.onMouseWheel.bind(this),this.boundClearAutocomplete=this.clearAutocomplete.bind(this),this.proxyElement=e.ownerDocument.createElement("span"),m.ThemeSupport.instance().appendStyle(this.proxyElement,an),this.contentElement=this.proxyElement.createChild("div","text-prompt-root"),this.proxyElement.style.display=this.proxyElementDisplay,e.parentElement&&e.parentElement.insertBefore(this.proxyElement,e),this.contentElement.appendChild(e);let t=o.textField().track({keydown:!0});return this.jslogContext&&(t=t.context(this.jslogContext)),this.elementInternal.setAttribute("jslog",`${t}`),this.elementInternal.classList.add("text-prompt"),K(this.elementInternal),he(this.elementInternal,"both"),ce(this.elementInternal,"listbox"),this.elementInternal.setAttribute("contenteditable","plaintext-only"),this.element().addEventListener("keydown",this.boundOnKeyDown,!1),this.elementInternal.addEventListener("input",this.boundOnInput,!1),this.elementInternal.addEventListener("wheel",this.boundOnMouseWheel,!1),this.elementInternal.addEventListener("selectstart",this.boundClearAutocomplete,!1),this.elementInternal.addEventListener("blur",this.boundClearAutocomplete,!1),this.suggestBox=new on(this,20),this.titleInternal&&Jt.install(this.proxyElement,this.titleInternal),this.proxyElement}element(){if(!this.elementInternal)throw new Error("Expected an already attached element!");return this.elementInternal}detach(){this.removeFromElement(),this.focusRestorer&&this.focusRestorer.restore(),this.proxyElement&&this.proxyElement.parentElement&&(this.proxyElement.parentElement.insertBefore(this.element(),this.proxyElement),this.proxyElement.remove()),delete this.proxyElement,this.element().classList.remove("text-prompt"),this.element().removeAttribute("contenteditable"),this.element().removeAttribute("role"),de(this.element()),ce(this.element(),"false")}textWithCurrentSuggestion(){const e=this.text();if(!this.queryRange||!this.currentSuggestion)return e;const t=this.currentSuggestion.text;return e.substring(0,this.queryRange.startColumn)+t+e.substring(this.queryRange.endColumn)}text(){let e=this.element().textContent||"";if(this.ghostTextElement.parentNode){const t=this.ghostTextElement.textContent||"";e=e.substring(0,e.length-t.length)}return e}setText(e){this.clearAutocomplete(),this.element().textContent=e,this.previousText=this.text(),this.element().hasFocus()&&(this.moveCaretToEndOfPrompt(),this.element().scrollIntoView())}setSelectedRange(e,t){if(e<0)throw new RangeError("Selected range start must be a nonnegative integer");const i=this.element().textContent,n=i?i.length:0;t>n&&(t=n),t<e&&(t=e);const s=this.element().childNodes[0],o=new Range;o.setStart(s,e),o.setEnd(s,t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(o))}focus(){this.element().focus()}title(){return this.titleInternal}setTitle(e){this.titleInternal=e,this.proxyElement&&Jt.install(this.proxyElement,e)}setPlaceholder(e,t){e?(this.element().setAttribute("data-placeholder",e),se(this.element(),t||e)):(this.element().removeAttribute("data-placeholder"),se(this.element(),null))}setEnabled(e){e?this.element().setAttribute("contenteditable","plaintext-only"):this.element().removeAttribute("contenteditable"),this.element().classList.toggle("disabled",!e)}removeFromElement(){this.clearAutocomplete(),this.element().removeEventListener("keydown",this.boundOnKeyDown,!1),this.element().removeEventListener("input",this.boundOnInput,!1),this.element().removeEventListener("selectstart",this.boundClearAutocomplete,!1),this.element().removeEventListener("blur",this.boundClearAutocomplete,!1),this.isEditing&&this.stopEditing(),this.suggestBox&&this.suggestBox.hide()}startEditing(e){this.isEditing=!0,this.contentElement&&this.contentElement.classList.add("text-prompt-editing"),this.focusRestorer=new Gn(this.element()),e&&(this.blurListener=e,this.element().addEventListener("blur",this.blurListener,!1)),this.oldTabIndex=this.element().tabIndex,this.element().tabIndex<0&&(this.element().tabIndex=0),this.text()||this.autoCompleteSoon()}stopEditing(){this.element().tabIndex=this.oldTabIndex,this.blurListener&&this.element().removeEventListener("blur",this.blurListener,!1),this.contentElement&&this.contentElement.classList.remove("text-prompt-editing"),delete this.isEditing}onMouseWheel(e){}onKeyDown(e){let t=!1;const i=e;if(this.isSuggestBoxVisible()&&this.suggestBox&&this.suggestBox.keyPressed(i))i.consume(!0);else{switch(i.key){case"Tab":t=this.tabKeyPressed(i);break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Home":this.clearAutocomplete();break;case"PageDown":case"ArrowRight":case"ArrowDown":case"End":this.isCaretAtEndOfPrompt()?t=this.acceptAutoComplete():this.clearAutocomplete();break;case"Escape":this.isSuggestBoxVisible()&&(this.clearAutocomplete(),t=!0);break;case" ":!i.ctrlKey||i.metaKey||i.altKey||i.shiftKey||(this.autoCompleteSoon(!0),t=!0)}"Enter"===i.key&&i.preventDefault(),t&&i.consume(!0)}}acceptSuggestionOnStopCharacters(e){if(!(this.currentSuggestion&&this.queryRange&&1===e.length&&this.completionStopCharacters&&this.completionStopCharacters.includes(e)))return!1;const t=this.text().substring(this.queryRange.startColumn,this.queryRange.endColumn);return!(!t||!this.currentSuggestion.text.startsWith(t+e))&&(this.queryRange.endColumn+=1,this.acceptAutoComplete())}onInput(e){const t=e;let n=this.text();const s=t.data;"insertFromPaste"===t.inputType&&n.includes("\n")&&(n=i.StringUtilities.stripLineBreaks(n),this.setText(n));const o=this.getCaretPosition();if(")"===s&&o>=0&&this.leftParenthesesIndices.length>0){if(")"===n[o]&&this.tryMatchingLeftParenthesis(o))return n=n.substring(0,o)+n.substring(o+1),void this.setText(n)}if(s&&!this.acceptSuggestionOnStopCharacters(s)){const e=n.startsWith(this.previousText)||this.previousText.startsWith(n);this.queryRange&&e&&(this.queryRange.endColumn+=n.length-this.previousText.length)}this.refreshGhostText(),this.previousText=n,this.dispatchEventToListeners("TextChanged"),this.autoCompleteSoon()}acceptAutoComplete(){let e=!1;return this.isSuggestBoxVisible()&&this.suggestBox&&(e=this.suggestBox.acceptSuggestion()),e||(e=this.acceptSuggestionInternal()),this.usesSuggestionBuilder&&e&&this.autoCompleteSoon(),e}clearAutocomplete(){const e=this.textWithCurrentSuggestion();this.isSuggestBoxVisible()&&this.suggestBox&&this.suggestBox.hide(),this.clearAutocompleteTimeout(),this.queryRange=null,this.refreshGhostText(),e!==this.textWithCurrentSuggestion()&&this.dispatchEventToListeners("TextChanged")}refreshGhostText(){this.currentSuggestion&&this.currentSuggestion.hideGhostText?this.ghostTextElement.remove():this.queryRange&&this.currentSuggestion&&this.isCaretAtEndOfPrompt()&&this.currentSuggestion.text.startsWith(this.text().substring(this.queryRange.startColumn))?(this.ghostTextElement.textContent=this.currentSuggestion.text.substring(this.queryRange.endColumn-this.queryRange.startColumn),this.element().appendChild(this.ghostTextElement)):this.ghostTextElement.remove()}clearAutocompleteTimeout(){this.completeTimeout&&(clearTimeout(this.completeTimeout),delete this.completeTimeout),this.completionRequestId++}autoCompleteSoon(e){const t=this.isSuggestBoxVisible()||e;this.completeTimeout||(this.completeTimeout=window.setTimeout(this.complete.bind(this,e),t?0:this.autocompletionTimeout))}async complete(e){this.clearAutocompleteTimeout();const t=this.element().getComponentSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0);let s;if((e||this.isCaretAtEndOfPrompt()||this.isSuggestBoxVisible())&&t.isCollapsed||(s=!0),s)return void this.clearAutocomplete();const o=i.DOMUtilities.rangeOfWord(n.startContainer,n.startOffset,this.completionStopCharacters,this.element(),"backward"),r=o.cloneRange();r.collapse(!0),r.setStartBefore(this.element());const a=++this.completionRequestId,l=await this.loadCompletions.call(null,r.toString(),o.toString(),Boolean(e));this.completionsReady(a,t,o,Boolean(e),l)}disableDefaultSuggestionForEmptyInput(){this.disableDefaultSuggestionForEmptyInputInternal=!0}boxForAnchorAtStart(e,t){const i=e.getRangeAt(0).cloneRange(),n=document.createElement("span");n.textContent="",t.insertNode(n);const s=n.boxInWindow(window);return n.remove(),e.removeAllRanges(),e.addRange(i),s}additionalCompletions(e){return[]}completionsReady(e,t,i,n,s){if(this.completionRequestId!==e)return;const o=i.toString(),a=new Set;if(s=s.filter((e=>!a.has(e.text)&&Boolean(a.add(e.text)))),(o||n)&&(s=o?s.concat(this.additionalCompletions(o)):this.additionalCompletions(o).concat(s)),!s.length)return void this.clearAutocomplete();const l=t.getRangeAt(0),h=document.createRange();if(h.setStart(i.startContainer,i.startOffset),h.setEnd(l.endContainer,l.endOffset),o+l.toString()!==h.toString())return;const d=document.createRange();d.setStart(this.element(),0),d.setEnd(h.startContainer,h.startOffset),this.queryRange=new r.TextRange.TextRange(0,d.toString().length,0,d.toString().length+h.toString().length);const c=!this.disableDefaultSuggestionForEmptyInputInternal||Boolean(this.text());this.suggestBox&&this.suggestBox.updateSuggestions(this.boxForAnchorAtStart(t,h),s,c,!this.isCaretAtEndOfPrompt(),this.text())}applySuggestion(e,t){this.currentSuggestion=e,this.refreshGhostText(),t&&this.dispatchEventToListeners("TextChanged")}acceptSuggestion(){this.acceptSuggestionInternal()}acceptSuggestionInternal(){if(!this.queryRange)return!1;const e=this.currentSuggestion?this.currentSuggestion.text.length:0,t=this.currentSuggestion?this.currentSuggestion.selectionRange:null,i=t?t.endColumn:e,n=t?t.startColumn:e;return this.element().textContent=this.textWithCurrentSuggestion(),this.setDOMSelection(this.queryRange.startColumn+n,this.queryRange.startColumn+i),this.updateLeftParenthesesIndices(),this.clearAutocomplete(),this.dispatchEventToListeners("TextChanged"),!0}ariaControlledBy(){return this.element()}setDOMSelection(e,t){this.element().normalize();const i=this.element().childNodes[0];if(!i||i===this.ghostTextElement)return;const n=document.createRange();n.setStart(i,e),n.setEnd(i,t);const s=this.element().getComponentSelection();s&&(s.removeAllRanges(),s.addRange(n))}isSuggestBoxVisible(){return void 0!==this.suggestBox&&this.suggestBox.visible()}isCaretInsidePrompt(){const e=this.element().getComponentSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;return e.getRangeAt(0).startContainer.isSelfOrDescendant(this.element())}isCaretAtEndOfPrompt(){const e=this.element().getComponentSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;const t=e.getRangeAt(0);let i=t.startContainer;if(!i.isSelfOrDescendant(this.element()))return!1;if(this.ghostTextElement.isAncestor(i))return!0;if(i.nodeType===Node.TEXT_NODE&&t.startOffset<(i.nodeValue||"").length)return!1;let n=!1;for(;i;){if(i.nodeType===Node.TEXT_NODE&&i.nodeValue&&i.nodeValue.length){if(n&&!this.ghostTextElement.isAncestor(i))return!1;n=!0}i=i.traverseNextNode(this.elementInternal)}return!0}moveCaretToEndOfPrompt(){const e=this.element().getComponentSelection(),t=document.createRange();let i=this.element();for(;i.lastChild;)i=i.lastChild;let n=0;if(i.nodeType===Node.TEXT_NODE){n=(i.textContent||"").length}t.setStart(i,n),t.setEnd(i,n),e&&(e.removeAllRanges(),e.addRange(t))}getCaretPosition(){if(!this.element().hasFocus())return-1;const e=this.element().getComponentSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return-1;const t=e.getRangeAt(0);return t.startOffset!==t.endOffset?-1:t.startOffset}tabKeyPressed(e){return this.acceptAutoComplete()}proxyElementForTests(){return this.proxyElement||null}tryMatchingLeftParenthesis(e){const t=this.leftParenthesesIndices;if(0===t.length||e<0)return!1;for(let i=t.length-1;i>=0;--i)if(t[i]<e)return t.splice(i,1),!0;return!1}updateLeftParenthesesIndices(){const e=this.text(),t=this.leftParenthesesIndices=[];for(let i=0;i<e.length;++i)"("===e[i]&&t.push(i)}suggestBoxForTest(){return this.suggestBox}}const hn=250;var dn=Object.freeze({__proto__:null,TextPrompt:ln}),cn={cssContent:':host{flex:none;padding:0 2px;--toolbar-height:26px}.toolbar-shadow{position:relative;white-space:nowrap;height:var(--toolbar-height);overflow:hidden;display:flex;flex:none;align-items:center;z-index:0}.toolbar-shadow.wrappable{flex-wrap:wrap;overflow:visible}.toolbar-shadow.toolbar-grow-vertical{height:initial}.toolbar-shadow.vertical{flex-direction:column;height:auto;align-items:flex-start}.toolbar-item{position:relative;display:flex;background-color:transparent;flex:none;align-items:center;justify-content:center;padding:0;height:var(--toolbar-height);border:none;white-space:pre;overflow:hidden;max-width:100%}devtools-adorner.fix-perf-icon{--override-adorner-text-color:transparent;--override-adorner-border-color:transparent;--override-adorner-background-color:transparent}.toolbar-item,\n.toolbar-item .devtools-link{color:var(--icon-default)}.toolbar-shadow.vertical .toolbar-item{height:auto;min-height:var(--toolbar-height);white-space:normal}devtools-issue-counter.toolbar-item{margin-top:-4px;padding-left:1px}devtools-issue-counter.main-toolbar{margin-top:1px;margin-left:1px;margin-right:1px}.toolbar-dropdown-arrow{pointer-events:none;flex:none;margin-left:-4px}.toolbar-button.dark-text .toolbar-dropdown-arrow{color:var(--sys-color-on-surface)}select.toolbar-item:disabled + .toolbar-dropdown-arrow{opacity:50%}.toolbar-button{white-space:nowrap;overflow:hidden;min-width:28px;background:transparent;border-radius:0}.toolbar-item-search{min-width:5.2em;max-width:300px;flex:1 1 auto;justify-content:start;overflow:revert}.toolbar-text{margin:0 5px;flex:none;color:var(--ui-text)}.toolbar-text:empty{margin:0}.toolbar-has-dropdown{justify-content:space-between;padding:0 3px 0 5px;border:1px solid transparent}.toolbar-has-dropdown-shrinkable{flex-shrink:1}.toolbar-has-dropdown .toolbar-text{margin:0 4px 0 0;text-overflow:ellipsis;flex:auto;overflow:hidden;text-align:right}.toolbar-render-as-links *{font-weight:initial;color:var(--sys-color-primary);text-decoration:underline;cursor:pointer}.toolbar-render-as-links button{height:15px;margin:2px}.toolbar-render-as-links button:focus-visible{outline:auto 5px -webkit-focus-ring-color}:not(.toolbar-render-as-links) .toolbar-button:focus-visible::before{position:absolute;top:2px;bottom:2px;left:2px;right:2px;background-color:var(--sys-color-state-focus-highlight);border-radius:2px;content:"";z-index:-1}.toolbar-glyph{flex:none}.toolbar-button:disabled{opacity:50%}.toolbar-button.close-devtools{position:absolute;right:0}:host-context(.right) .toolbar-button.main-menu,\n:host-context(.left) .toolbar-button.main-menu,\n:host-context(.bottom) .toolbar-button.main-menu{margin-inline-end:28px}.toolbar-button.copied-to-clipboard::after{content:attr(data-content);position:fixed;margin-top:calc(2 * var(--toolbar-height));padding:3px 5px;color:var(--sys-color-token-subtle);background:var(--sys-color-cdt-base-container);animation:2s fade-out;font-weight:normal;border:1px solid var(--sys-color-divider);border-radius:3px}@keyframes fade-out{from{opacity:100%}to{opacity:0%}}.toolbar-button.toolbar-state-on .toolbar-glyph{color:var(--icon-toggled)}.toolbar-state-on.toolbar-toggle-with-dot .toolbar-text::after{content:"";position:absolute;bottom:2px;background-color:var(--sys-color-primary-bright);width:4.5px;height:4.5px;border:2px solid var(--override-toolbar-background-color,--sys-color-cdt-base-container);border-radius:50%;right:0}.toolbar-button.toolbar-state-on.toolbar-toggle-with-red-color .toolbar-glyph,\n.toolbar-button.toolbar-state-off.toolbar-default-with-red-color .toolbar-glyph{color:var(--icon-error)!important}.toolbar-button:not(.toolbar-has-glyph):not(.toolbar-has-dropdown):not(.largeicon-menu):not(.toolbar-button-secondary){font-weight:bold}.toolbar-button.dark-text .toolbar-text{color:var(--sys-color-on-surface)!important}.toolbar-button.toolbar-state-on .toolbar-text{color:var(--sys-color-primary)}.toolbar-button.toolbar-state-on:enabled:active .toolbar-text{color:var(--sys-color-primary-bright)}.toolbar-blue-on-hover .toolbar-button:not(.toolbar-state-on):enabled:hover:not(:active){background-color:var(--sys-color-state-hover-on-subtle)}.toolbar-blue-on-hover .toolbar-button:not(.toolbar-state-on):enabled:active:hover{background-color:var(--sys-color-state-hover-on-subtle)}.toolbar-toggled-gray:not(.toolbar-render-as-links) .toolbar-button:not(.toolbar-has-glyph):not(.toolbar-has-dropdown):not(.largeicon-menu):hover{background-color:var(--sys-color-state-hover-on-subtle)}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-glyph{color:var(--sys-color-on-surface)}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-text{color:var(--sys-color-on-surface)}.toolbar-blue-on-hover .toolbar-button:not(.toolbar-state-on):enabled:hover .toolbar-text{color:var(--sys-color-on-surface)}.toolbar-button.toolbar-state-on:enabled:hover:not(:active) .toolbar-glyph{color:var(--sys-color-primary)}.toolbar-button.toolbar-state-on:enabled:hover:not(:active) .toolbar-text{color:var(--sys-color-primary)}.toolbar-toggled-gray .toolbar-button.toolbar-state-on{background-color:var(--sys-color-neutral-container)!important}.toolbar-item.checkbox{padding:0 5px 0 2px}.toolbar-select-container{display:inline-flex;flex-shrink:0;margin-right:6px}select.toolbar-item{min-width:38px;appearance:none;border:1px solid transparent;padding:0 13px 0 5px;margin-right:-17px;position:relative;height:22px;margin-top:2px;margin-bottom:2px}select.toolbar-item:disabled{opacity:50%}button.toolbar-item:focus-visible,\nselect.toolbar-item:focus-visible{background:var(--sys-color-state-hover-on-subtle);border-radius:2px}select.toolbar-item:focus-visible > *{background:var(--sys-color-cdt-base-container);border-radius:7px}.toolbar-input{width:120px;height:19px;padding:4px 3px 3px;margin:1px 3px;background:var(--sys-color-cdt-base-container);border:1px solid var(--sys-color-neutral-outline);border-radius:4px;min-width:35px;&.focused,\n &:not(.toolbar-input-empty){border-color:var(--sys-color-state-focus-ring)}&:hover:not(.focused){background:var(--sys-color-state-hover-on-subtle)}& > input{border:none;flex-grow:1}}.toolbar-input-clear-button{opacity:70%;flex-basis:13px;flex-shrink:0;height:16px}.toolbar-input-clear-button > .search-cancel-button{display:block}.toolbar-input-clear-button:hover{opacity:99%}.toolbar-input-empty .toolbar-input-clear-button{display:none}.toolbar-prompt-proxy{flex:1}.toolbar-input-prompt{flex:1;overflow:hidden;white-space:nowrap;cursor:auto;color:var(--sys-color-on-surface)}.toolbar-divider{background-color:var(--sys-color-on-base-divider);width:1px;margin:5px 4px;height:16px}.toolbar-spacer{flex:auto}.long-click-glyph{position:absolute;top:2px;left:3px}.toolbar-button.emulate-active{background-color:var(--sys-color-surface-variant)}.toolbar-shadow.floating{flex-direction:column;height:auto;background-color:var(--sys-color-cdt-base-container);border:1px solid var(--sys-color-divider);margin-top:-1px;width:28px;left:-2px}.toolbar-shadow:not(.floating) .toolbar-item:last-child:not(:first-child, .toolbar-select-container){flex-shrink:1;justify-content:left}.toolbar-shadow:not(.floating) .toolbar-button.toolbar-item:last-child:not(:first-child, .toolbar-select-container){justify-content:center;margin-right:2px}input[is="history-input"]{margin:0 1px;border:1px solid var(--sys-color-neutral-outline);border-radius:4px;line-height:16px;padding:1px 1px 1px 3px;color:var(--sys-color-on-surface)}input[is="history-input"]:focus,\ninput[is="history-input"]:not(:placeholder-shown){border-color:var(--sys-color-state-focus-ring)}input[is="history-input"]:hover:not(:focus){background-color:var(--sys-color-state-hover-on-subtle)}.toolbar-item.highlight::before{content:"";position:absolute;top:2px;left:2px;right:2px;bottom:2px;border-radius:2px;background:var(--sys-color-neutral-container);z-index:-1}.toolbar-item.highlight:focus-visible{background:var(--sys-color-tonal-container);& > .title{color:var(--sys-color-on-tonal-container)}}devtools-icon.leading-issue-icon{margin:0 7px}@media (forced-colors: active){.toolbar-button:disabled{opacity:100%;color:Graytext}.toolbar-item,\n .toolbar-text{color:ButtonText}.toolbar-button:disabled .toolbar-text{color:Graytext}select.toolbar-item:disabled,\n select.toolbar-item:disabled + .toolbar-dropdown-arrow{opacity:100%;color:Graytext}.toolbar-button.toolbar-state-on .toolbar-glyph{forced-color-adjust:none;color:Highlight}.toolbar-button.toolbar-state-on .toolbar-text{forced-color-adjust:none;color:Highlight}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-text,\n :not(.toolbar-render-as-links) .toolbar-button:enabled:focus:not(:active) .toolbar-text{color:HighlightText}.toolbar-button:disabled devtools-icon{color:GrayText}:not(.toolbar-render-as-links) .toolbar-button:disabled .toolbar-glyph{color:GrayText}.toolbar-button:enabled.hover:not(:active) .toolbar-glyph{forced-color-adjust:none;color:Highlight}.toolbar-button:focus,\n .toolbar-button:hover:enabled,\n .toolbar-toggled-gray:not(.toolbar-render-as-links) .toolbar-button:not(.toolbar-has-glyph):not(.toolbar-has-dropdown):not(.largeicon-menu):hover{forced-color-adjust:none;background-color:Highlight}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover .toolbar-glyph,\n :not(.toolbar-render-as-links) .toolbar-button:enabled:focus .toolbar-glyph,\n :not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-glyph,\n .toolbar-button:enabled:hover devtools-icon,\n .toolbar-button:enabled:focus devtools-icon{color:HighlightText}.toolbar-input{forced-color-adjust:none;background:canvas;box-shadow:var(--legacy-focus-ring-inactive-shadow)}.toolbar-input.focused,\n .toolbar-input:not(.toolbar-input-empty){forced-color-adjust:none;background:canvas;box-shadow:var(--legacy-focus-ring-active-shadow)}.toolbar-input:hover{box-shadow:var(--legacy-focus-ring-active-shadow)}.toolbar-item .devtools-link{color:linktext}.toolbar-has-dropdown{forced-color-adjust:none;background:ButtonFace;color:ButtonText}}[aria-label="[FB-only] Send feedback"]{height:20px;padding:0 4px;border-radius:4px;background:color-mix(in srgb,var(--color-green) 80%,transparent)}[aria-label="[FB-only] Send feedback"]:hover{background:color-mix(in srgb,var(--color-green) 90%,transparent)}[aria-label="[FB-only] Send feedback"] .toolbar-text,\n[aria-label="[FB-only] Send feedback"] .toolbar-glyph{color:white!important}.fusebox-connection-status{margin:4px;height:20px;padding:0 4px;border-radius:4px;background:color-mix(in srgb,var(--color-red) 80%,transparent)}.fusebox-connection-status:hover{background:color-mix(in srgb,var(--color-red) 90%,transparent)}.fusebox-connection-status .toolbar-text,\n.fusebox-connection-status .toolbar-glyph{color:white!important}'};const un={pressed:"pressed",notPressed:"not pressed",clearInput:"Clear input"},mn=t.i18n.registerUIStrings("ui/legacy/Toolbar.ts",un),pn=t.i18n.getLocalizedString.bind(void 0,mn);class gn{items;element;enabled;shadowRoot;contentElement;compactLayout=!1;constructor(e,t){this.items=[],this.element=t?t.createChild("div"):document.createElement("div"),this.element.className=e,this.element.classList.add("toolbar"),this.enabled=!0,this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:cn,delegatesFocus:void 0}),this.contentElement=this.shadowRoot.createChild("div","toolbar-shadow")}hasCompactLayout(){return this.compactLayout}registerCSSFiles(e){this.shadowRoot.adoptedStyleSheets=this.shadowRoot.adoptedStyleSheets.concat(e)}setCompactLayout(e){if(this.compactLayout!==e){this.compactLayout=e;for(const t of this.items)t.setCompactLayout(e)}}static createLongPressActionButton(e,t,i){const n=gn.createActionButton(e),s=gn.createActionButton(e);let o=null,r=null,l=null;return e.addEventListener("Toggled",h),h(),n;function h(){const s=e.toggled()?t||null:i||null;s&&s.length?o||(o=new is(n.element,d),l=a.Icon.create("triangle-bottom-right","long-click-glyph"),n.element.appendChild(l),r=s):o&&(o.dispose(),o=null,l&&l.remove(),l=null,r=null)}function d(){let e=r?r.slice():[];e.push(s);const t=n.element.ownerDocument;t.documentElement.addEventListener("mouseup",(function n(s){if(1!==s.which)return;i.hide(),t.documentElement.removeEventListener("mouseup",n,!1);for(let t=0;t<e.length;++t)if(e[t].element.classList.contains("emulate-active")){e[t].element.classList.remove("emulate-active"),e[t].clicked(s);break}}),!1);const i=new Ts;i.setPointerEventsBehavior("BlockedByGlassPane"),i.show(t);const o=new gn("fill",i.contentElement);o.contentElement.classList.add("floating");const a=n.element.boxInWindow().relativeToElement(Ts.container(t)),l=a.y+26*e.length<t.documentElement.offsetHeight;l&&(e=e.reverse()),o.element.style.height=26*e.length+"px",o.element.style.top=l?a.y-5+"px":a.y-26*(e.length-1)-6+"px",o.element.style.left=a.x-5+"px";for(let t=0;t<e.length;++t)e[t].element.addEventListener("mousemove",d,!1),e[t].element.addEventListener("mouseout",c,!1),o.appendToolbarItem(e[t]);const h=l?0:e.length-1;function d(e){if(1===e.which&&e.target instanceof HTMLElement){e.target.enclosingNodeOrSelfWithClass("toolbar-item").classList.add("emulate-active")}}function c(e){if(1===e.which&&e.target instanceof HTMLElement){e.target.enclosingNodeOrSelfWithClass("toolbar-item").classList.remove("emulate-active")}}e[h].element.classList.add("emulate-active")}}static createActionButton(e,t=bn){const i=e.toggleable()?function(){const t=new xn(e.title(),e.icon(),e.toggledIcon(),e.id());return t.setToggleWithRedColor(e.toggleWithRedColor()),e.addEventListener("Toggled",i),i(),t;function i(){t.setToggled(e.toggled()),e.title()&&(t.setTitle(e.title()),Jt.installWithActionBinding(t.element,e.title(),e.id()))}}():function(){const t=new wn(e.title(),e.icon(),void 0,e.id());e.title()&&Jt.installWithActionBinding(t.element,e.title(),e.id());return t}();t.showLabel&&i.setText(t.label?.()||e.title());let n=t=>{e.execute()};if(t.userActionCode){const i=t.userActionCode;n=()=>{s.userMetrics.actionTaken(i),e.execute()}}return i.addEventListener("Click",n,e),e.addEventListener("Enabled",(function(e){i.setEnabled(e.data)})),i.setEnabled(e.enabled()),i}static createActionButtonForId(e,t){const i=M.instance().getAction(e);return gn.createActionButton(i,t)}gripElementForResize(){return this.contentElement}makeWrappable(e){this.contentElement.classList.add("wrappable"),e&&this.contentElement.classList.add("toolbar-grow-vertical")}makeVertical(){this.contentElement.classList.add("vertical")}makeBlueOnHover(){this.contentElement.classList.add("toolbar-blue-on-hover")}makeToggledGray(){this.contentElement.classList.add("toolbar-toggled-gray")}renderAsLinks(){this.contentElement.classList.add("toolbar-render-as-links")}empty(){return!this.items.length}setEnabled(e){this.enabled=e;for(const e of this.items)e.applyEnabledState(this.enabled&&e.enabled)}appendToolbarItem(e){this.items.push(e),e.toolbar=this,e.setCompactLayout(this.hasCompactLayout()),this.enabled||e.applyEnabledState(!1),this.contentElement.appendChild(e.element),this.hideSeparatorDupes()}appendSeparator(){this.appendToolbarItem(new yn)}appendSpacer(){this.appendToolbarItem(new yn(!0))}appendText(e){this.appendToolbarItem(new vn(e))}removeToolbarItem(e){const t=[];for(const i of this.items)i===e?i.element.remove():t.push(i);this.items=t}removeToolbarItems(){for(const e of this.items)e.toolbar=null;this.items=[],this.contentElement.removeChildren()}setColor(e){const t=document.createElement("style");t.textContent=".toolbar-glyph { background-color: "+e+" !important }",this.shadowRoot.appendChild(t)}setToggledColor(e){const t=document.createElement("style");t.textContent=".toolbar-button.toolbar-state-on .toolbar-glyph { background-color: "+e+" !important }",this.shadowRoot.appendChild(t)}hideSeparatorDupes(){if(!this.items.length)return;let e,t=!1,i=!1;for(let n=0;n<this.items.length;++n)this.items[n]instanceof yn?(this.items[n].setVisible(!t),t=!0,e=this.items[n]):this.items[n].visible()&&(t=!1,e=null,i=!0);e&&e!==this.items[this.items.length-1]&&e.setVisible(!1),this.element.classList.toggle("hidden",null!=e&&e.visible()&&!i)}async appendItemsAtLocation(e){const t=Tn.filter((e=>n.Runtime.Runtime.isDescriptorEnabled({experiment:e.experiment,condition:e.condition})));t.sort(((e,t)=>(e.order||0)-(t.order||0)));const i=t.filter((t=>t.location===e)),s=await Promise.all(i.map((e=>{const{separator:t,actionId:i,showLabel:n,label:s,loadItem:o}=e;if(t)return new yn;if(i)return gn.createActionButtonForId(i,{label:s,showLabel:Boolean(n),userActionCode:void 0});if(!o)throw new Error("Could not load a toolbar item registration with no loadItem function");return o().then((e=>e.item()))})));for(const e of s)e&&this.appendToolbarItem(e)}}const bn={showLabel:!1,userActionCode:void 0};class fn extends e.ObjectWrapper.ObjectWrapper{element;visibleInternal;enabled;toolbar;title;constructor(e){super(),this.element=e,this.element.classList.add("toolbar-item"),this.visibleInternal=!0,this.enabled=!0,this.toolbar=null}setTitle(e,t=void 0){this.title!==e&&(this.title=e,be(this.element,e),void 0===t?Jt.install(this.element,e):Jt.installWithActionBinding(this.element,e,t))}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.applyEnabledState(this.enabled&&(!this.toolbar||this.toolbar.enabled)))}applyEnabledState(e){this.element.disabled=!e}visible(){return this.visibleInternal}setVisible(e){this.visibleInternal!==e&&(this.element.classList.toggle("hidden",!e),this.visibleInternal=e,!this.toolbar||this instanceof yn||this.toolbar.hideSeparatorDupes())}setRightAligned(e){this.element.classList.toggle("toolbar-item-right-aligned",e)}setCompactLayout(e){}}class vn extends fn{constructor(e){const t=document.createElement("div");t.classList.add("toolbar-text"),super(t),this.element.classList.add("toolbar-text"),this.setText(e||"")}text(){return this.element.textContent||""}setText(e){this.element.textContent=e}}class wn extends fn{glyphElement;textElement;text;glyph;adorner;constructor(e,t,i,n){const s=document.createElement("button");s.classList.add("toolbar-button"),super(s),this.element.addEventListener("click",this.clicked.bind(this),!1),this.element.addEventListener("mousedown",this.mouseDown.bind(this),!1),this.glyphElement=new a.Icon.Icon,this.glyphElement.className="toolbar-glyph hidden",this.element.appendChild(this.glyphElement),this.textElement=this.element.createChild("div","toolbar-text hidden"),this.setTitle(e),t&&this.setGlyphOrAdorner(t),this.setText(i||""),n&&this.element.setAttribute("jslog",`${o.action().track({click:!0}).context(n)}`),this.title=""}focus(){this.element.focus()}setText(e){this.text!==e&&(this.textElement.textContent=e,this.textElement.classList.toggle("hidden",!e),this.text=e)}setGlyphOrAdorner(e){e instanceof l.Adorner.Adorner?(this.adorner?this.adorner.replaceWith(e):this.element.prepend(e),this.adorner=e):this.setGlyph(e)}setGlyph(e){this.glyph!==e&&(this.glyphElement.name=e||null,this.glyphElement.classList.toggle("hidden",!e),this.element.classList.toggle("toolbar-has-glyph",Boolean(e)),this.glyph=e)}setBackgroundImage(e){this.element.style.backgroundImage="url("+e+")"}setSecondary(){this.element.classList.add("toolbar-button-secondary")}setDarkText(){this.element.classList.add("dark-text")}turnIntoSelect(e=!1){this.element.classList.add("toolbar-has-dropdown"),e&&this.element.classList.add("toolbar-has-dropdown-shrinkable");const t=a.Icon.create("triangle-down","toolbar-dropdown-arrow");this.element.appendChild(t)}clicked(e){this.enabled&&(this.dispatchEventToListeners("Click",e),e.consume())}mouseDown(e){this.enabled&&this.dispatchEventToListeners("MouseDown",e)}}class xn extends wn{toggledInternal;untoggledGlyph;toggledGlyph;constructor(e,t,i,n){super(e,t,""),this.toggledInternal=!1,this.untoggledGlyph=t,this.toggledGlyph=i,this.element.classList.add("toolbar-state-off"),ge(this.element,!1),n&&this.element.setAttribute("jslog",`${o.toggle().track({click:!0}).context(n)}`)}toggled(){return this.toggledInternal}setToggled(e){this.toggledInternal!==e&&(this.toggledInternal=e,this.element.classList.toggle("toolbar-state-on",e),this.element.classList.toggle("toolbar-state-off",!e),ge(this.element,e),this.toggledGlyph&&this.untoggledGlyph&&this.setGlyph(e?this.toggledGlyph:this.untoggledGlyph))}setDefaultWithRedColor(e){this.element.classList.toggle("toolbar-default-with-red-color",e)}setToggleWithRedColor(e){this.element.classList.toggle("toolbar-toggle-with-red-color",e)}setToggleWithDot(e){this.element.classList.toggle("toolbar-toggle-with-dot",e)}}class En extends wn{contextMenuHandler;useSoftMenu;triggerTimeout;constructor(e,t,i){super("","dots-vertical",void 0,i),i&&this.element.setAttribute("jslog",`${o.dropDown().track({click:!0}).context(i)}`),this.contextMenuHandler=e,this.useSoftMenu=Boolean(t),N(this.element)}mouseDown(e){1===e.buttons?this.triggerTimeout||(this.triggerTimeout=window.setTimeout(this.trigger.bind(this,e),200)):super.mouseDown(e)}trigger(e){delete this.triggerTimeout;const t=new Ys(e,{useSoftMenu:this.useSoftMenu,x:this.element.getBoundingClientRect().left,y:this.element.getBoundingClientRect().top+this.element.offsetHeight});this.contextMenuHandler(t),t.show()}clicked(e){this.triggerTimeout&&clearTimeout(this.triggerTimeout),this.trigger(e)}}class In extends xn{defaultTitle;setting;willAnnounceState;constructor(e,t,i,n,s){super(i,t,n,s),this.defaultTitle=i,this.setting=e,this.settingChanged(),this.setting.addChangeListener(this.settingChanged,this),this.willAnnounceState=!1}settingChanged(){const e=this.setting.get();this.setToggled(e);const t=pn(e?un.pressed:un.notPressed);this.willAnnounceState&&Se(t),this.willAnnounceState=!1,this.setTitle(this.defaultTitle)}clicked(e){this.willAnnounceState=!0,this.setting.set(!this.toggled()),super.clicked(e)}}class yn extends fn{constructor(e){const t=document.createElement("div");t.classList.add(e?"toolbar-spacer":"toolbar-divider"),super(t)}}class Sn extends fn{selectElementInternal;constructor(e,t,i,n){const s=document.createElement("span");s.classList.add("toolbar-select-container"),super(s),this.selectElementInternal=this.element.createChild("select","toolbar-item");const r=a.Icon.create("triangle-down","toolbar-dropdown-arrow");this.element.appendChild(r),e&&this.selectElementInternal.addEventListener("change",e,!1),be(this.selectElementInternal,t),super.setTitle(t),i&&this.selectElementInternal.classList.add(i),n&&this.selectElementInternal.setAttribute("jslog",`${o.dropDown().track({change:!0}).context(n)}`)}selectElement(){return this.selectElementInternal}size(){return this.selectElementInternal.childElementCount}options(){return Array.prototype.slice.call(this.selectElementInternal.children,0)}addOption(e){this.selectElementInternal.appendChild(e)}createOption(e,t){const n=this.selectElementInternal.createChild("option");n.text=e,void 0!==t&&(n.value=t);const s=t?i.StringUtilities.toKebabCase(t):void 0;return n.setAttribute("jslog",`${o.item(s).track({click:!0})}`),n}applyEnabledState(e){super.applyEnabledState(e),this.selectElementInternal.disabled=!e}removeOption(e){this.selectElementInternal.removeChild(e)}removeOptions(){this.selectElementInternal.removeChildren()}selectedOption(){return this.selectElementInternal.selectedIndex>=0?this.selectElementInternal[this.selectElementInternal.selectedIndex]:null}select(e){this.selectElementInternal.selectedIndex=Array.prototype.indexOf.call(this.selectElementInternal,e)}setSelectedIndex(e){this.selectElementInternal.selectedIndex=e}selectedIndex(){return this.selectElementInternal.selectedIndex}setMaxWidth(e){this.selectElementInternal.style.maxWidth=e+"px"}setMinWidth(e){this.selectElementInternal.style.minWidth=e+"px"}}class Cn extends fn{inputElement;constructor(e,t,i,n){super(ls.create(e)),this.element.classList.add("checkbox"),this.inputElement=this.element.checkboxElement,t&&(Jt.install(this.inputElement,t),Jt.install(this.element.textElement,t)),i&&this.inputElement.addEventListener("click",i,!1),n&&this.inputElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(n)}`)}checked(){return this.inputElement.checked}setChecked(e){this.inputElement.checked=e}applyEnabledState(e){super.applyEnabledState(e),this.inputElement.disabled=!e}setIndeterminate(e){this.inputElement.indeterminate=e}}const Tn=[];var kn=Object.freeze({__proto__:null,Toolbar:gn,ToolbarItem:fn,ToolbarItemWithCompactLayout:class extends fn{constructor(e){super(e)}setCompactLayout(e){this.dispatchEventToListeners("CompactLayoutUpdated",e)}},ToolbarText:vn,ToolbarButton:wn,ToolbarInput:class extends fn{prompt;proxyElement;constructor(e,t,i,n,s,o,r,l){const h=document.createElement("div");h.classList.add("toolbar-input"),super(h);const d=this.element.createChild("div","toolbar-input-prompt");be(d,t||e),d.addEventListener("focus",(()=>this.element.classList.add("focused"))),d.addEventListener("blur",(()=>this.element.classList.remove("focused"))),this.prompt=new ln,this.prompt.jslogContext=l,this.proxyElement=this.prompt.attach(d),this.proxyElement.classList.add("toolbar-prompt-proxy"),this.proxyElement.addEventListener("keydown",(e=>this.onKeydownCallback(e))),this.prompt.initialize(o||(()=>Promise.resolve([]))," ",r),s&&this.prompt.setTitle(s),this.prompt.setPlaceholder(e,t),this.prompt.addEventListener("TextChanged",this.onChangeCallback.bind(this)),i&&(this.element.style.flexGrow=String(i)),n&&(this.element.style.flexShrink=String(n));const c=this.element.createChild("div","toolbar-input-clear-button");c.title=un.clearInput;const u=new a.Icon.Icon;u.data={color:"var(--icon-default)",width:"16px",height:"16px",iconName:"cross-circle-filled"},u.classList.add("search-cancel-button"),c.appendChild(u),c.addEventListener("click",(()=>{this.setValue("",!0),this.prompt.focus()})),this.updateEmptyStyles()}applyEnabledState(e){this.prompt.setEnabled(e)}setValue(e,t){this.prompt.setText(e),t&&this.onChangeCallback(),this.updateEmptyStyles()}value(){return this.prompt.textWithCurrentSuggestion()}valueWithoutSuggestion(){return this.prompt.text()}onKeydownCallback(e){"Enter"===e.key&&this.prompt.text()&&this.dispatchEventToListeners("EnterPressed",this.prompt.text()),i.KeyboardUtilities.isEscKey(e)&&this.prompt.text()&&(this.setValue("",!0),e.consume(!0))}onChangeCallback(){this.updateEmptyStyles(),this.dispatchEventToListeners("TextChanged",this.prompt.text())}updateEmptyStyles(){this.element.classList.toggle("toolbar-input-empty",!this.prompt.text())}},ToolbarToggle:xn,ToolbarMenuButton:En,ToolbarSettingToggle:In,ToolbarSeparator:yn,ToolbarComboBox:Sn,ToolbarSettingComboBox:class extends Sn{optionsInternal;setting;muteSettingListener;constructor(e,t,i){super(null,i),this.optionsInternal=e,this.setting=t,this.selectElementInternal.addEventListener("change",this.valueChanged.bind(this),!1),this.setOptions(e),t.addChangeListener(this.settingChanged,this)}setOptions(e){this.optionsInternal=e,this.selectElementInternal.removeChildren();for(let t=0;t<e.length;++t){const i=e[t],n=this.createOption(i.label,i.value);this.selectElementInternal.appendChild(n),this.setting.get()===i.value&&this.setSelectedIndex(t)}}value(){return this.optionsInternal[this.selectedIndex()].value}settingChanged(){if(this.muteSettingListener)return;const e=this.setting.get();for(let t=0;t<this.optionsInternal.length;++t)if(e===this.optionsInternal[t].value){this.setSelectedIndex(t);break}}valueChanged(e){const t=this.optionsInternal[this.selectedIndex()];this.muteSettingListener=!0,this.setting.set(t.value),this.muteSettingListener=!1}},ToolbarCheckbox:Cn,ToolbarSettingCheckbox:class extends Cn{constructor(e,t,i){super(i||e.title()||"",t,void 0,e.name),$i(this.inputElement,e)}},registerToolbarItem:function(e){Tn.push(e)}});const Mn={openInNewTab:"Open in new tab",copyLinkAddress:"Copy link address",copyFileName:"Copy file name",anotherProfilerIsAlreadyActive:"Another profiler is already active",promiseResolvedAsync:"Promise resolved (async)",promiseRejectedAsync:"Promise rejected (async)",sAsync:"{PH1} (async)",asyncCall:"Async Call",anonymous:"(anonymous)",close:"Close",ok:"OK",cancel:"Cancel"},Ln=t.i18n.registerUIStrings("ui/legacy/UIUtils.ts",Mn),Pn=t.i18n.getLocalizedString.bind(void 0,Ln),Dn="highlighted-search-result";function An(e,t,i,n,s,o,r){let a;e.addEventListener("pointerdown",(function(o){const l=new Bn,h=()=>l.elementDragStart(e,t,i,n,s,o);r?a=window.setTimeout(h,r):h()}),!1),r&&e.addEventListener("pointerup",(function(){a&&window.clearTimeout(a),a=null}),!1),null!==o&&(e.style.cursor=o||s||"")}function Rn(e,t,i,n,s,o){(new Bn).elementDragStart(e,t,i,n,s,o)}class Bn{glassPaneInUse;elementDraggingEventListener;elementEndDraggingEventListener;dragEventsTargetDocument;dragEventsTargetDocumentTop;restoreCursorAfterDrag;constructor(){this.elementDragMove=this.elementDragMove.bind(this),this.elementDragEnd=this.elementDragEnd.bind(this),this.mouseOutWhileDragging=this.mouseOutWhileDragging.bind(this)}createGlassPane(){this.glassPaneInUse=!0,Bn.glassPaneUsageCount++||(Bn.glassPane=new Ts,Bn.glassPane.setPointerEventsBehavior("BlockedByGlassPane"),Bn.documentForMouseOut&&Bn.glassPane.show(Bn.documentForMouseOut))}disposeGlassPane(){this.glassPaneInUse&&(this.glassPaneInUse=!1,--Bn.glassPaneUsageCount||(Bn.glassPane&&(Bn.glassPane.hide(),Bn.glassPane=null),Bn.documentForMouseOut=null,Bn.rootForMouseOut=null))}elementDragStart(e,t,i,n,o,r){const a=r;if(a.button||s.Platform.isMac()&&a.ctrlKey)return;if(this.elementDraggingEventListener)return;if(t&&!t(a))return;const l=a.target instanceof Node&&a.target.ownerDocument;this.elementDraggingEventListener=i,this.elementEndDraggingEventListener=n,console.assert((Bn.documentForMouseOut||l)===l,"Dragging on multiple documents."),Bn.documentForMouseOut=l,Bn.rootForMouseOut=a.target instanceof Node&&a.target.getRootNode()||null,this.dragEventsTargetDocument=l;try{l.defaultView&&l.defaultView.top&&(this.dragEventsTargetDocumentTop=l.defaultView.top.document)}catch(e){this.dragEventsTargetDocumentTop=this.dragEventsTargetDocument}l.addEventListener("pointermove",this.elementDragMove,!0),l.addEventListener("pointerup",this.elementDragEnd,!0),Bn.rootForMouseOut&&Bn.rootForMouseOut.addEventListener("pointerout",this.mouseOutWhileDragging,{capture:!0}),this.dragEventsTargetDocumentTop&&l!==this.dragEventsTargetDocumentTop&&this.dragEventsTargetDocumentTop.addEventListener("pointerup",this.elementDragEnd,!0);const h=e;"string"==typeof o&&(this.restoreCursorAfterDrag=function(e){l.body.style.removeProperty("cursor"),h.style.cursor=e,this.restoreCursorAfterDrag=void 0}.bind(this,h.style.cursor),h.style.cursor=o,l.body.style.cursor=o),a.preventDefault()}mouseOutWhileDragging(){this.unregisterMouseOutWhileDragging(),this.createGlassPane()}unregisterMouseOutWhileDragging(){Bn.rootForMouseOut&&Bn.rootForMouseOut.removeEventListener("pointerout",this.mouseOutWhileDragging,{capture:!0})}unregisterDragEvents(){this.dragEventsTargetDocument&&(this.dragEventsTargetDocument.removeEventListener("pointermove",this.elementDragMove,!0),this.dragEventsTargetDocument.removeEventListener("pointerup",this.elementDragEnd,!0),this.dragEventsTargetDocumentTop&&this.dragEventsTargetDocument!==this.dragEventsTargetDocumentTop&&this.dragEventsTargetDocumentTop.removeEventListener("pointerup",this.elementDragEnd,!0),delete this.dragEventsTargetDocument,delete this.dragEventsTargetDocumentTop)}elementDragMove(e){1===e.buttons?this.elementDraggingEventListener&&this.elementDraggingEventListener(e)&&this.cancelDragEvents(e):this.elementDragEnd(e)}cancelDragEvents(e){this.unregisterDragEvents(),this.unregisterMouseOutWhileDragging(),this.restoreCursorAfterDrag&&this.restoreCursorAfterDrag(),this.disposeGlassPane(),delete this.elementDraggingEventListener,delete this.elementEndDraggingEventListener}elementDragEnd(e){const t=this.elementEndDraggingEventListener;this.cancelDragEvents(e),e.preventDefault(),t&&t(e)}static glassPaneUsageCount=0;static glassPane=null;static documentForMouseOut=null;static rootForMouseOut=null}function On(){if(zn.size)return!0;const e=i.DOMUtilities.deepActiveElement(document);return!!e&&(e.classList.contains("text-prompt")||"INPUT"===e.nodeName||"TEXTAREA"===e.nodeName||"true"===e.contentEditable||"plaintext-only"===e.contentEditable)}function Fn(e,t){if(t){if(zn.has(e))return!1;e.classList.add("being-edited"),zn.add(e)}else{if(!zn.has(e))return!1;e.classList.remove("being-edited"),zn.delete(e)}return!0}const zn=new Set,Wn=/^(-?(?:\d+(?:\.\d+)?|\.\d+))$/,Hn=" \t\n\"':;,/()";function Nn(e){let t=null;if("wheel"===e.type){const i=e;i.deltaY<0||i.deltaX<0?t="Up":(i.deltaY>0||i.deltaX>0)&&(t="Down")}else{const i=e;"ArrowUp"===i.key||"PageUp"===i.key?t="Up":"ArrowDown"!==i.key&&"PageDown"!==i.key||(t="Down")}return t}function _n(e,t,i){const n=Nn(t);if(!n)return null;const s=t;let o=1;Ke.eventHasCtrlEquivalentKey(s)?o=100:s.shiftKey?o=10:s.altKey&&(o=.1),"Down"===n&&(o*=-1),i&&(o*=i);const r=Number((e+o).toFixed(6));return String(r).match(Wn)?r:null}function jn(e,t,n){let s,o,r,a=null,l=/(.*#)([\da-fA-F]+)(.*)/.exec(e);return l&&l.length?(s=l[1],o=l[3],r=function(e,t){const n=Nn(t);if(!n)return null;const s=t,o=parseInt(e,16);if(isNaN(o)||!isFinite(o))return null;const r=e.length,a=r/3;if(1!==a&&2!==a)return null;let l=0;Ke.eventHasCtrlEquivalentKey(s)&&(l+=Math.pow(16,2*a)),s.shiftKey&&(l+=Math.pow(16,a)),s.altKey&&(l+=1),0===l&&(l=1),"Down"===n&&(l*=-1);const h=Math.pow(16,r)-1;let d=i.NumberUtilities.clamp(o+l,0,h).toString(16).toUpperCase();for(let e=0,t=r-d.length;e<t;++e)d="0"+d;return d}(l[2],t),null!==r&&(a=s+r+o)):(l=/(.*?)(-?(?:\d+(?:\.\d+)?|\.\d+))(.*)/.exec(e),l&&l.length&&(s=l[1],o=l[3],r=_n(parseFloat(l[2]),t),null!==r&&(a=n?n(s,r,o):s+r+o))),a}function Vn(e){const t="ArrowUp"===e.key||"ArrowDown"===e.key||"wheel"===e.type,i="PageUp"===e.key||"PageDown"===e.key;return t||i}function Un(){return Pn(Mn.openInNewTab)}function Kn(){return Pn(Mn.copyLinkAddress)}function qn(e,t){t.target instanceof Window&&t.target.document.nodeType===Node.DOCUMENT_NODE&&e.body.classList.remove("inactive")}function $n(e,t){t.target instanceof Window&&t.target.document.nodeType===Node.DOCUMENT_NODE&&e.body.classList.add("inactive")}class Gn{element;previous;constructor(e){this.element=e,this.previous=i.DOMUtilities.deepActiveElement(e.ownerDocument),e.focus()}restore(){this.element&&(this.element.hasFocus()&&this.previous&&this.previous.focus(),this.previous=null,this.element=null)}}function Xn(e,t,i){return Yn(e,t,Dn,i)}function Yn(e,t,i,n){n=n||[];const s=[],o=e.childTextNodes(),a=o.map((function(e){return e.textContent})).join(""),l=e.ownerDocument;if(0===o.length)return s;const h=[];let d=0;for(const e of o){const t=new r.TextRange.SourceRange(d,e.textContent?e.textContent.length:0);d=t.offset+t.length,h.push(t)}let c=0;for(let e=0;e<t.length;++e){const r=t[e].offset,d=r+t[e].length;for(;c<o.length&&h[c].offset+h[c].length<=r;)c++;let u=c;for(;u<o.length&&h[u].offset+h[u].length<d;)u++;if(u===o.length)break;const m=l.createElement("span");m.className=i,m.textContent=a.substring(r,d);const p=o[u],g=p.textContent||"";if(p.textContent=g.substring(d-h[u].offset),n.push({node:p,type:"changed",oldText:g,newText:p.textContent,nextSibling:void 0,parent:void 0}),c===u&&p.parentElement){p.parentElement.insertBefore(m,p),n.push({node:m,type:"added",nextSibling:p,parent:p.parentElement,oldText:void 0,newText:void 0}),s.push(m);const e=l.createTextNode(g.substring(0,r-h[c].offset));p.parentElement.insertBefore(e,m),n.push({node:e,type:"added",nextSibling:m,parent:p.parentElement,oldText:void 0,newText:void 0})}else{const e=o[c],t=e.textContent||"",i=e.nextSibling;e.parentElement&&(e.parentElement.insertBefore(m,i),n.push({node:m,type:"added",nextSibling:i||void 0,parent:e.parentElement,oldText:void 0,newText:void 0}),s.push(m)),e.textContent=t.substring(0,r-h[c].offset),n.push({node:e,type:"changed",oldText:t,newText:e.textContent,nextSibling:void 0,parent:void 0});for(let e=c+1;e<u;e++){const t=o[e],i=t.textContent;t.textContent="",n.push({node:t,type:"changed",oldText:i||void 0,newText:t.textContent,nextSibling:void 0,parent:void 0})}}c=u,h[c].offset=d,h[c].length=p.textContent.length}return s}function Qn(e,t){const i=e.parentElement,n=e.nextSibling;(t=t||e.ownerDocument.body).appendChild(e),e.positionAt(0,0);const s=e.getBoundingClientRect();return e.positionAt(void 0,void 0),i?i.insertBefore(e,n):e.remove(),new _e(s.width,s.height)}class Zn{handlers;autoInvoke;constructor(e){this.handlers=null,this.autoInvoke=e}add(e,t){this.handlers||(this.handlers=new Map,this.autoInvoke&&this.scheduleInvoke());let i=this.handlers.get(e);i||(i=new Set,this.handlers.set(e,i)),i.add(t)}scheduleInvoke(){this.handlers&&requestAnimationFrame(this.invoke.bind(this))}invoke(){const e=this.handlers;if(this.handlers=null,e)for(const[t,i]of e)for(const e of i)e.call(t)}}let Jn=0,es=null;function ts(e,t){es||(es=new Zn(!0)),es.add(e,t)}class is{element;callback;editKey;longClickData;longClickInterval;constructor(e,t,n=(e=>i.KeyboardUtilities.isEnterOrSpaceKey(e))){this.element=e,this.callback=t,this.editKey=n,this.enable()}reset(){this.longClickInterval&&(clearInterval(this.longClickInterval),delete this.longClickInterval)}enable(){if(this.longClickData)return;const e=function(e){if(this.editKey(e)){const t=this.callback;this.longClickInterval=window.setTimeout(t.bind(null,e),is.TIME_MS)}}.bind(this),t=function(e){this.editKey(e)&&this.reset()}.bind(this),i=function(e){if(1!==e.which)return;const t=this.callback;this.longClickInterval=window.setTimeout(t.bind(null,e),is.TIME_MS)}.bind(this),n=function(e){if(1!==e.which)return;this.reset()}.bind(this),s=this.reset.bind(this);this.element.addEventListener("keydown",e,!1),this.element.addEventListener("keyup",t,!1),this.element.addEventListener("pointerdown",i,!1),this.element.addEventListener("pointerout",s,!1),this.element.addEventListener("pointerup",n,!1),this.element.addEventListener("click",s,!0),this.longClickData={mouseUp:n,mouseDown:i,reset:s}}dispose(){this.longClickData&&(this.element.removeEventListener("pointerdown",this.longClickData.mouseDown,!1),this.element.removeEventListener("pointerout",this.longClickData.reset,!1),this.element.removeEventListener("pointerup",this.longClickData.mouseUp,!1),this.element.addEventListener("click",this.longClickData.reset,!0),delete this.longClickData)}static TIME_MS=200}function ns(e){return e||Pn(Mn.anonymous)}const ss=(e,t)=>{const i=e.ownerDocument.createTextNode(t);return e.appendChild(i),i};function os(e,t,i){const n=document.createElement("button");return i?.className&&(n.className=i.className),n.textContent=e,n.classList.add("text-button"),i?.primary&&n.classList.add("primary-button"),t&&n.addEventListener("click",t),i?.jslogContext&&n.setAttribute("jslog",`${o.action().track({click:!0}).context(i.jslogContext)}`),n.type="button",n}function rs(e,t,i){const n=document.createElement("input");return e&&(n.className=e),n.spellcheck=!1,n.classList.add("harmony-input"),t&&(n.type=t),i&&n.setAttribute("jslog",`${o.textField().track({keydown:!0}).context(i)}`),n}function as(e,t,i){const n=new Option(e,t||e);return i&&n.setAttribute("jslog",`${o.item(i).track({click:!0})}`),n}class ls extends HTMLSpanElement{shadowRootInternal;checkboxElement;textElement;constructor(){super(),ls.lastId=ls.lastId+1;const e="ui-checkbox-label"+ls.lastId;this.shadowRootInternal=d.createShadowRootWithCoreStyles(this,{cssFile:Le,delegatesFocus:void 0}),this.checkboxElement=this.shadowRootInternal.createChild("input"),this.checkboxElement.type="checkbox",this.checkboxElement.setAttribute("id",e),this.textElement=this.shadowRootInternal.createChild("label","dt-checkbox-text"),this.textElement.setAttribute("for",e),this.shadowRootInternal.createChild("slot")}static create(e,t,i,n){ls.constructorInternal||(ls.constructorInternal=d.registerCustomElement("span","dt-checkbox",ls));const s=ls.constructorInternal();return s.checkboxElement.checked=Boolean(t),n&&s.checkboxElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(n)}`),void 0!==e&&(s.textElement.textContent=e,s.checkboxElement.title=e,void 0!==i&&(s.textElement.createChild("div","dt-checkbox-subtitle").textContent=i)),s}static lastId=0;static constructorInternal=null}class hs extends HTMLSpanElement{#i;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:void 0,delegatesFocus:void 0});this.#i=new a.Icon.Icon,this.#i.style.setProperty("margin-right","4px"),this.#i.style.setProperty("vertical-align","baseline"),e.appendChild(this.#i),e.createChild("slot")}set data(e){this.#i.data=e,"14px"===e.height?this.#i.style.setProperty("margin-bottom","-2px"):"20px"===e.height&&this.#i.style.setProperty("margin-bottom","2px")}}let ds=0;class cs extends HTMLSpanElement{radioElement;labelElement;constructor(){super(),this.radioElement=this.createChild("input","dt-radio-button"),this.labelElement=this.createChild("label");const e="dt-radio-button-id"+ ++ds;this.radioElement.id=e,this.radioElement.type="radio",this.labelElement.htmlFor=e;d.createShadowRootWithCoreStyles(this,{cssFile:rt,delegatesFocus:void 0}).createChild("slot"),this.addEventListener("click",this.radioClickHandler.bind(this),!1)}radioClickHandler(){this.radioElement.checked||this.radioElement.disabled||(this.radioElement.checked=!0,this.radioElement.dispatchEvent(new Event("change")))}}d.registerCustomElement("span","dt-radio",cs),d.registerCustomElement("span","dt-icon-label",hs);class us extends HTMLSpanElement{sliderElement;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:at,delegatesFocus:void 0});this.sliderElement=document.createElement("input"),this.sliderElement.classList.add("dt-range-input"),this.sliderElement.type="range",e.appendChild(this.sliderElement)}set value(e){this.sliderElement.value=String(e)}get value(){return Number(this.sliderElement.value)}}d.registerCustomElement("span","dt-slider",us);class ms extends HTMLSpanElement{textElement;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:lt,delegatesFocus:void 0});this.textElement=e.createChild("div"),this.textElement.className="info",this.textElement.createChild("slot")}set type(e){this.textElement.className=e}}d.registerCustomElement("span","dt-small-bubble",ms);class ps extends HTMLDivElement{buttonElement;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:Pe,delegatesFocus:void 0});this.buttonElement=e.createChild("div","close-button"),this.buttonElement.setAttribute("jslog",`${o.close().track({click:!0})}`),Jt.install(this.buttonElement,Pn(Mn.close)),be(this.buttonElement,Pn(Mn.close)),F(this.buttonElement);const t=a.Icon.create("cross");this.buttonElement.appendChild(t)}setAccessibleName(e){be(this.buttonElement,e)}setTabbable(e){this.buttonElement.tabIndex=e?0:-1}}function gs(e,t,i,n){if(i<=10)return"";t.length>200&&(t=n(t,200));const s=bs(e,t);if(s<=i)return t;let o=0,r=t.length,a=0,l=s;for(;o<r&&a!==l&&a!==i;){const s=Math.ceil(o+(r-o)*(i-a)/(l-a)),h=bs(e,n(t,s));h<=i?(o=s,a=h):(r=s-1,l=h)}return"…"!==(t=n(t,o))?t:""}function bs(e,t){if(t.length>200)return e.measureText(t).width;fs||(fs=new Map);const i=e.font;let n=fs.get(i);n||(n=new Map,fs.set(i,n));let s=n.get(t);return s||(s=e.measureText(t).width,n.set(t,s)),s}d.registerCustomElement("div","dt-close-button",ps);let fs=null;function vs(e){return/(\?|&)utm_source=devtools/.test(e)?e:-1===e.indexOf("?")?e.replace(/^([^#]*)(#.*)?$/g,"$1?utm_source=devtools$2"):e.replace(/^([^#]*)(#.*)?$/g,"$1&utm_source=devtools$2")}function ws(e){return/(\/\/developers.google.com\/|\/\/web.dev\/|\/\/developer.chrome.com\/)/.test(e)?vs(e):e}const xs=(e,t)=>{let i=e;for(;i&&i!==e.ownerDocument;i=i.parentNodeOrShadowHost())for(let e=0;e<t.length;++e)if(i.nodeName.toLowerCase()===t[e].toLowerCase())return i;return null},Es=(e,t,i)=>{let n=e,s=null;for(;n;){const e=n.elementFromPoint(t,i);if(!e||s===e)break;s=e,n=s.shadowRoot}return s},Is=e=>{const t=e;if(!(t.which||t.pageX||t.pageY||t.clientX||t.clientY||t.movementX||t.movementY))return null;const i=t.target&&t.target.getComponentRoot();return i?Es(i,t.pageX,t.pageY):null},ys=[];function Ss(e){return ys.filter((function(t){if(!t.contextTypes)return!0;for(const i of t.contextTypes())if(e instanceof i)return!0;return!1}))}var Cs=Object.freeze({__proto__:null,highlightedSearchResultClassName:Dn,highlightedCurrentSearchResultClassName:"current-search-result",installDragHandle:An,elementDragStart:Rn,isBeingEdited:function(e){if(!e||e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;if(t.classList.contains("text-prompt")||"INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)return!0;if(!zn.size)return!1;let i=t;for(;i;){if(zn.has(t))return!0;i=i.parentElementOrShadowHost()}return!1},isEditing:On,markBeingEdited:Fn,StyleValueDelimiters:Hn,getValueModificationDirection:Nn,modifiedFloatNumber:_n,createReplacementString:jn,isElementValueModification:Vn,handleElementValueModifications:function(e,t,n,s,r){if(!Vn(e))return!1;o.logKeyDown(e,"element-value-modification");const a=t.getComponentSelection();if(!a||!a.rangeCount)return!1;const l=a.getRangeAt(0);if(!l.commonAncestorContainer.isSelfOrDescendant(t))return!1;const h=t.textContent,d=i.DOMUtilities.rangeOfWord(l.startContainer,l.startOffset,Hn,t),c=d.toString();if(s&&s(c))return!1;const u=jn(c,e,r);if(u){const t=document.createTextNode(u);d.deleteContents(),d.insertNode(t);const i=document.createRange();return i.setStart(t,0),i.setEnd(t,u.length),a.removeAllRanges(),a.addRange(i),e.handled=!0,e.preventDefault(),n&&n(h||"",u),!0}return!1},openLinkExternallyLabel:Un,copyLinkAddressLabel:Kn,copyFileNameLabel:function(){return Pn(Mn.copyFileName)},anotherProfilerActiveLabel:function(){return Pn(Mn.anotherProfilerIsAlreadyActive)},asyncStackTraceLabel:function(e,t){if(e){if("Promise.resolve"===e)return Pn(Mn.promiseResolvedAsync);if("Promise.reject"===e)return Pn(Mn.promiseRejectedAsync);if(("await"===e||"async function"===e)&&0!==t.length){e=`await in ${ns(t[t.length-1].functionName)}`}return Pn(Mn.sAsync,{PH1:e})}return Pn(Mn.asyncCall)},installComponentRootStyles:function(e){d.injectCoreStyles(e),e.classList.add("platform-"+s.Platform.platform()),s.Platform.isMac()||0!==d.measuredScrollbarWidth(e.ownerDocument)||e.classList.add("overlay-scrollbar-enabled")},ElementFocusRestorer:Gn,highlightSearchResult:function(e,t,i,n){const s=Xn(e,[new r.TextRange.SourceRange(t,i)],n);return s.length?s[0]:null},highlightSearchResults:Xn,runCSSAnimationOnce:function(e,t){e.classList.contains(t)&&e.classList.remove(t),e.addEventListener("webkitAnimationEnd",(function i(){e.classList.remove(t),e.removeEventListener("webkitAnimationEnd",i,!1)}),!1),e.classList.add(t)},highlightRangesWithStyleClass:Yn,applyDomChanges:function(e){for(let t=0,i=e.length;t<i;++t){const i=e[t];switch(i.type){case"added":i.parent?.insertBefore(i.node,i.nextSibling??null);break;case"changed":i.node.textContent=i.newText??null}}},revertDomChanges:function(e){for(let t=e.length-1;t>=0;--t){const i=e[t];switch(i.type){case"added":i.node.remove();break;case"changed":i.node.textContent=i.oldText??null}}},measurePreferredSize:Qn,startBatchUpdate:function(){Jn++||(es=new Zn(!1))},endBatchUpdate:function(){--Jn||es&&(es.scheduleInvoke(),es=null)},invokeOnceAfterBatchUpdate:ts,animateFunction:function(e,t,n,s,o){const r=e.performance.now();let a=e.requestAnimationFrame((function l(h){const d=i.NumberUtilities.clamp((h-r)/s,0,1);t(...n.map((e=>e.from+(e.to-e.from)*d))),d<1?a=e.requestAnimationFrame(l):o&&o()}));return()=>e.cancelAnimationFrame(a)},LongClickController:is,initializeUIUtils:function(e){e.body.classList.toggle("inactive",!e.hasFocus()),e.defaultView&&(e.defaultView.addEventListener("focus",qn.bind(void 0,e),!1),e.defaultView.addEventListener("blur",$n.bind(void 0,e),!1)),e.addEventListener("focus",d.focusChanged.bind(void 0),!0);const t=e.body;Ts.setContainer(t)},beautifyFunctionName:ns,createTextChild:ss,createTextChildren:(e,...t)=>{for(const i of t)ss(e,i)},createTextButton:os,createInput:rs,createSelect:function(e,t){const n=document.createElement("select");n.classList.add("chrome-select"),be(n,e);for(const e of t)if(e instanceof Map)for(const[t,s]of e){const e=n.createChild("optgroup");e.label=t;for(const t of s)"string"==typeof t&&e.appendChild(as(t,t,i.StringUtilities.toKebabCase(t)))}else"string"==typeof e&&n.add(as(e,e,i.StringUtilities.toKebabCase(e)));return n},createOption:as,createLabel:function(e,t,i){const n=document.createElement("label");return t&&(n.className=t),n.textContent=e,i&&B(n,i),n},createRadioLabel:function(e,t,i,n){const s=document.createElement("span",{is:"dt-radio"});return s.radioElement.name=e,s.radioElement.checked=Boolean(i),ss(s.labelElement,t),n&&s.radioElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(n)}`),s},createIconLabel:function(e){const t=document.createElement("span",{is:"dt-icon-label"});return e.title&&(t.createChild("span").textContent=e.title),t.data={iconName:e.iconName,color:e.color??"var(--icon-default)",width:e.width??"14px",height:e.height??"14px"},t},createSlider:function(e,t,i){const n=document.createElement("span",{is:"dt-slider"});return n.sliderElement.min=String(e),n.sliderElement.max=String(t),n.sliderElement.step=String(1),n.sliderElement.tabIndex=i,n},setTitle:function(e,t){be(e,t),Jt.install(e,t)},CheckboxLabel:ls,DevToolsIconLabel:hs,DevToolsRadioButton:cs,DevToolsSlider:us,DevToolsSmallBubble:ms,DevToolsCloseButton:ps,bindInput:function(e,t,i,n,s){function o(t){if(t===e.value)return;const{valid:n}=i(t);e.classList.toggle("error-input",!n),e.value=t}return e.addEventListener("change",(function(){const{valid:n}=i(e.value);e.classList.toggle("error-input",!n),n&&t(e.value)}),!1),e.addEventListener("input",(function(){e.classList.toggle("error-input",!i(e.value))}),!1),e.addEventListener("keydown",(function(r){if("Enter"===r.key){const{valid:n}=i(e.value);return n&&t(e.value),void r.preventDefault()}if(!n)return;const a=_n(parseFloat(e.value),r,s);if(null===a)return;const l=String(a),{valid:h}=i(l);h&&o(l);r.preventDefault()}),!1),e.addEventListener("focus",e.select.bind(e),!1),o},trimText:gs,trimTextMiddle:function(e,t,n){return gs(e,t,n,((e,t)=>i.StringUtilities.trimMiddle(e,t)))},trimTextEnd:function(e,t,n){return gs(e,t,n,((e,t)=>i.StringUtilities.trimEndWithMaxLength(e,t)))},measureTextWidth:bs,addReferrerToURL:vs,addReferrerToURLIfNecessary:ws,loadImage:function(e){return new Promise((t=>{const i=new Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(()=>t(null))),i.src=e}))},createFileSelectorElement:function(e){const t=document.createElement("input");return t.type="file",t.style.display="none",t.tabIndex=-1,t.onchange=()=>{t.files&&e(t.files[0])},t},MaxLengthForDisplayedURLs:150,MessageDialog:class{static async show(e,t,i){const n=new Ds(i);n.setSizeBehavior("MeasureContent"),n.setDimmed(!0);const s=d.createShadowRootWithCoreStyles(n.contentElement,{cssFile:De,delegatesFocus:void 0}).createChild("div","widget");await new Promise((i=>{const o=os(Pn(Mn.ok),i,{jslogContext:"confirm",primary:!0});s.createChild("div","message").createChild("span").textContent=e,s.createChild("div","button").appendChild(o),n.setOutsideClickCallback((e=>{e.consume(),i(void 0)})),n.show(t),o.focus()})),n.hide()}},ConfirmDialog:class{static async show(e,t,i){const n=new Ds(i?.jslogContext);n.setSizeBehavior("MeasureContent"),n.setDimmed(!0),be(n.contentElement,e);const s=d.createShadowRootWithCoreStyles(n.contentElement,{cssFile:De,delegatesFocus:void 0}).createChild("div","widget");s.createChild("div","message").createChild("span").textContent=e;const o=s.createChild("div","button"),r=await new Promise((e=>{const s=os(i?.okButtonLabel||Pn(Mn.ok),(()=>e(!0)),{jslogContext:"confirm",primary:!0});o.appendChild(s),o.appendChild(os(i?.cancelButtonLabel||Pn(Mn.cancel),(()=>e(!1)),{jslogContext:"cancel"})),n.setOutsideClickCallback((t=>{t.consume(),e(!1)})),n.show(t),s.focus()}));return n.hide(),r}},createInlineButton:function(e){const t=document.createElement("span"),i=d.createShadowRootWithCoreStyles(t,{cssFile:Ue,delegatesFocus:void 0});t.classList.add("inline-button");const n=new gn("");return n.appendToolbarItem(e),i.appendChild(n.element),t},Renderer:class{static async render(e,t){if(!e)throw new Error("Can't render "+e);const i=Ss(e)[0];if(!i)return null;return(await i.loadRenderer()).render(e,t)}},formatTimestamp:function(e,t){const i=new Date(e),n=i.getFullYear()+"-"+o(i.getMonth()+1,2)+"-"+o(i.getDate(),2),s=o(i.getHours(),2)+":"+o(i.getMinutes(),2)+":"+o(i.getSeconds(),2)+"."+o(i.getMilliseconds(),3);return t?n+" "+s:s;function o(e,t){return String(e).padStart(t,"0")}},isScrolledToBottom:e=>Math.abs(e.scrollTop+e.clientHeight-e.scrollHeight)<=2,createSVGChild:function(e,t,i){const n=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg",t);return i&&n.setAttribute("class",i),e.appendChild(n),n},enclosingNodeOrSelfWithNodeNameInArray:xs,enclosingNodeOrSelfWithNodeName:function(e,t){return xs(e,[t])},deepElementFromPoint:Es,deepElementFromEvent:Is,registerRenderer:function(e){ys.push(e)},getApplicableRegisteredRenderers:Ss});class Ts{widgetInternal;element;contentElement;arrowElement;onMouseDownBound;onClickOutsideCallback;maxSize;positionX;positionY;anchorBox;anchorBehavior;sizeBehavior;marginBehavior;#n=!1;constructor(e){this.widgetInternal=new Wt(!0),this.widgetInternal.markAsRoot(),this.element=this.widgetInternal.element,this.contentElement=this.widgetInternal.contentElement,e&&this.contentElement.setAttribute("jslog",e),this.arrowElement=document.createElement("span"),this.arrowElement.classList.add("arrow","hidden"),this.element.shadowRoot&&this.element.shadowRoot.appendChild(this.arrowElement),this.registerRequiredCSS(Me),this.setPointerEventsBehavior("PierceGlassPane"),this.onMouseDownBound=this.onMouseDown.bind(this),this.onClickOutsideCallback=null,this.maxSize=null,this.positionX=null,this.positionY=null,this.anchorBox=null,this.anchorBehavior="PreferTop",this.sizeBehavior="SetExactSize",this.marginBehavior="DefaultMargin"}setJsLog(e){this.contentElement.setAttribute("jslog",e)}isShowing(){return this.widgetInternal.isShowing()}registerRequiredCSS(e){this.widgetInternal.registerRequiredCSS(e)}registerCSSFiles(e){this.widgetInternal.registerCSSFiles(e)}setDefaultFocusedElement(e){this.widgetInternal.setDefaultFocusedElement(e)}setDimmed(e){this.element.classList.toggle("dimmed-pane",e)}setPointerEventsBehavior(e){this.element.classList.toggle("no-pointer-events","BlockedByGlassPane"!==e),this.contentElement.classList.toggle("no-pointer-events","PierceContents"===e)}setOutsideClickCallback(e){this.onClickOutsideCallback=e}setMaxContentSize(e){this.maxSize=e,this.positionContent()}setSizeBehavior(e){this.sizeBehavior=e,this.positionContent()}setContentPosition(e,t){this.positionX=e,this.positionY=t,this.positionContent()}setContentAnchorBox(e){this.anchorBox=e,this.positionContent()}setAnchorBehavior(e){this.anchorBehavior=e}setMarginBehavior(e){this.marginBehavior=e,this.arrowElement.classList.toggle("hidden","Arrow"!==e)}setIgnoreLeftMargin(e){this.#n=e}show(e){this.isShowing()||(this.element.style.zIndex=""+(3e3+1e3*Ms.size),this.element.setAttribute("data-devtools-glass-pane",""),e.body.addEventListener("mousedown",this.onMouseDownBound,!0),e.body.addEventListener("pointerdown",this.onMouseDownBound,!0),this.widgetInternal.show(e.body),Ms.add(this),this.positionContent())}hide(){this.isShowing()&&(Ms.delete(this),this.element.ownerDocument.body.removeEventListener("mousedown",this.onMouseDownBound,!0),this.element.ownerDocument.body.removeEventListener("pointerdown",this.onMouseDownBound,!0),this.widgetInternal.detach())}onMouseDown(e){if(!this.onClickOutsideCallback)return;const t=Is(e);t&&!this.contentElement.isSelfOrAncestor(t)&&this.onClickOutsideCallback.call(null,e)}positionContent(){if(!this.isShowing())return;const e="Arrow"===this.marginBehavior,t=e?8:"NoMargin"===this.marginBehavior?0:3,n=d.measuredScrollbarWidth(this.element.ownerDocument),s=10,o=ks.get(this.element.ownerDocument);"MeasureContent"===this.sizeBehavior&&(this.contentElement.positionAt(0,0),this.contentElement.style.width="",this.contentElement.style.maxWidth="",this.contentElement.style.height="",this.contentElement.style.maxHeight="");const r=o.offsetWidth,a=o.offsetHeight;let l=r-2*t,h=a-2*t,c=t,u=t;if(this.maxSize&&(l=Math.min(l,this.maxSize.width),h=Math.min(h,this.maxSize.height)),"MeasureContent"===this.sizeBehavior){const e=this.contentElement.getBoundingClientRect(),t=h<e.height?n:0,i=l<e.width?n:0;l=Math.min(l,e.width+t),h=Math.min(h,e.height+i)}if(this.anchorBox){const n=this.anchorBox.relativeToElement(o);let d=this.anchorBehavior;if(this.arrowElement.classList.remove("arrow-none","arrow-top","arrow-bottom","arrow-left","arrow-right"),"PreferTop"===d||"PreferBottom"===d){const m=n.y-2*t,p=a-n.y-n.height-2*t;let g;"PreferTop"===d&&m<h&&p>m&&(d="PreferBottom"),"PreferBottom"===d&&p<h&&m>p&&(d="PreferTop");let b=!0;if("PreferTop"===d){u=Math.max(t,n.y-h-t);const e=n.y-u-t;"MeasureContent"===this.sizeBehavior?h>e&&(this.arrowElement.classList.add("arrow-none"),b=!1):h=Math.min(h,e),this.arrowElement.classList.add("arrow-bottom"),g=n.y-t}else{u=n.y+n.height+t;const e=a-u-t;"MeasureContent"===this.sizeBehavior?h>e&&(this.arrowElement.classList.add("arrow-none"),u=a-t-h,b=!1):h=Math.min(h,e),this.arrowElement.classList.add("arrow-top"),g=n.y+n.height+t}const f=Math.min(n.x,r-l-t);if(c=Math.max(t,f),this.#n&&t>f&&(c=0),b?e&&c-s>=t&&(c-=s):c=Math.min(c+s,r-l-t),l=Math.min(l,r-c-t),20>=l)this.arrowElement.classList.add("arrow-none");else{let e=n.x+Math.min(50,Math.floor(n.width/2));e=i.NumberUtilities.clamp(e,c+s,c+l-s),this.arrowElement.positionAt(e,g,o)}}else{const m=n.x-2*t,p=r-n.x-n.width-2*t;let g;"PreferLeft"===d&&m<l&&p>m&&(d="PreferRight"),"PreferRight"===d&&p<l&&m>p&&(d="PreferLeft");let b=!0;if("PreferLeft"===d){c=Math.max(t,n.x-l-t);const e=n.x-c-t;"MeasureContent"===this.sizeBehavior?l>e&&(this.arrowElement.classList.add("arrow-none"),b=!1):l=Math.min(l,e),this.arrowElement.classList.add("arrow-right"),g=n.x-t}else{c=n.x+n.width+t;const e=r-c-t;"MeasureContent"===this.sizeBehavior?l>e&&(this.arrowElement.classList.add("arrow-none"),c=r-t-l,b=!1):l=Math.min(l,e),this.arrowElement.classList.add("arrow-left"),g=n.x+n.width+t}if(u=Math.max(t,Math.min(n.y,a-h-t)),b?e&&u-s>=t&&(u-=s):u=Math.min(u+s,a-h-t),h=Math.min(h,a-u-t),20>=h)this.arrowElement.classList.add("arrow-none");else{let e=n.y+Math.min(50,Math.floor(n.height/2));e=i.NumberUtilities.clamp(e,u+s,u+h-s),this.arrowElement.positionAt(g,e,o)}}}else c=null!==this.positionX?this.positionX:(r-l)/2,u=null!==this.positionY?this.positionY:(a-h)/2,l=Math.min(l,r-c-t),h=Math.min(h,a-u-t),this.arrowElement.classList.add("arrow-none");this.contentElement.style.width=l+"px","SetExactWidthMaxHeight"===this.sizeBehavior?this.contentElement.style.maxHeight=h+"px":this.contentElement.style.height=h+"px",this.contentElement.positionAt(c,u,o),this.widgetInternal.doResize()}widget(){return this.widgetInternal}static setContainer(e){ks.set(e.ownerDocument,e),Ts.containerMoved(e)}static container(e){return ks.get(e)}static containerMoved(e){for(const t of Ms)t.isShowing()&&t.element.ownerDocument===e.ownerDocument&&t.positionContent()}}const ks=new Map,Ms=new Set,Ls=Ms;var Ps=Object.freeze({__proto__:null,GlassPane:Ts,GlassPanePanes:Ls});class Ds extends(e.ObjectWrapper.eventMixin(Ts)){tabIndexBehavior;tabIndexMap;focusRestorer;closeOnEscape;targetDocument;targetDocumentKeyDownHandler;escapeKeyCallback;constructor(e){super(),this.registerRequiredCSS(ke),this.contentElement.tabIndex=0,this.contentElement.addEventListener("focus",(()=>this.widget().focus()),!1),e&&this.contentElement.setAttribute("jslog",`${o.dialog(e).track({resize:!0})}`),this.widget().setDefaultFocusedElement(this.contentElement),this.setPointerEventsBehavior("BlockedByGlassPane"),this.setOutsideClickCallback((e=>{this.hide(),e.consume(!0)})),z(this.contentElement),this.tabIndexBehavior="DisableAllTabIndex",this.tabIndexMap=new Map,this.focusRestorer=null,this.closeOnEscape=!0,this.targetDocumentKeyDownHandler=this.onKeyDown.bind(this),this.escapeKeyCallback=null}static hasInstance(){return Boolean(Ds.instance)}show(e){const t=e instanceof Document?e:(e||Hi.instance().element).ownerDocument;this.targetDocument=t,this.targetDocument.addEventListener("keydown",this.targetDocumentKeyDownHandler,!0),Ds.instance&&Ds.instance.hide(),Ds.instance=this,this.disableTabIndexOnElements(t),super.show(t),this.focusRestorer=new jt(this.widget())}hide(){this.focusRestorer&&this.focusRestorer.restore(),super.hide(),this.targetDocument&&this.targetDocument.removeEventListener("keydown",this.targetDocumentKeyDownHandler,!0),this.restoreTabIndexOnElements(),this.dispatchEventToListeners("hidden"),Ds.instance=null}setCloseOnEscape(e){this.closeOnEscape=e}setEscapeKeyCallback(e){this.escapeKeyCallback=e}addCloseButton(){this.contentElement.createChild("div","dialog-close-button","dt-close-button").addEventListener("click",(()=>this.hide()),!1)}setOutsideTabIndexBehavior(e){this.tabIndexBehavior=e}disableTabIndexOnElements(e){if("PreserveTabIndex"===this.tabIndexBehavior)return;let t=null;"PreserveMainViewTabIndex"===this.tabIndexBehavior&&(t=this.getMainWidgetTabIndexElements(Hi.instance().ownerSplit())),this.tabIndexMap.clear();let i=e;for(;i;i=i.traverseNextNode(e))if(i instanceof HTMLElement){const e=i,n=e.tabIndex;t?.has(e)||(n>=0?(this.tabIndexMap.set(e,n),e.tabIndex=-1):e.hasAttribute("contenteditable")&&(this.tabIndexMap.set(e,e.hasAttribute("tabindex")?n:0),e.tabIndex=-1))}}getMainWidgetTabIndexElements(e){const t=new Set;if(!e)return t;const i=e.mainWidget();if(!i||!i.element)return t;let n=i.element;for(;n;n=n.traverseNextNode(i.element)){if(!(n instanceof HTMLElement))continue;const e=n;e.tabIndex<0||t.add(e)}return t}restoreTabIndexOnElements(){for(const e of this.tabIndexMap.keys())e.tabIndex=this.tabIndexMap.get(e);this.tabIndexMap.clear()}onKeyDown(e){if(e.keyCode===nt.Esc.code&&Ke.hasNoModifiers(e)){if(this.escapeKeyCallback&&this.escapeKeyCallback(e),e.handled)return;this.closeOnEscape&&(e.consume(!0),this.hide())}}static instance=null}var As=Object.freeze({__proto__:null,Dialog:Ds});let Rs;class Bs{actionRegistry;actionToShortcut;keyMap;activePrefixKey;activePrefixTimeout;consumePrefix;devToolsDefaultShortcutActions;disabledDefaultShortcutsForAction;keybindSetSetting;userShortcutsSetting;constructor(t){this.actionRegistry=t,this.actionToShortcut=new i.MapUtilities.Multimap,this.keyMap=new Os(0,0),this.activePrefixKey=null,this.activePrefixTimeout=null,this.consumePrefix=null,this.devToolsDefaultShortcutActions=new Set,this.disabledDefaultShortcutsForAction=new i.MapUtilities.Multimap,this.keybindSetSetting=e.Settings.Settings.instance().moduleSetting("active-keybind-set"),this.keybindSetSetting.addChangeListener((e=>{s.userMetrics.keybindSetSettingChanged(e.data),this.registerBindings()})),this.userShortcutsSetting=e.Settings.Settings.instance().moduleSetting("user-shortcuts"),this.userShortcutsSetting.addChangeListener(this.registerBindings,this),this.registerBindings()}static instance(e={forceNew:null,actionRegistry:null}){const{forceNew:t,actionRegistry:i}=e;if(!Rs||t){if(!i)throw new Error("Missing actionRegistry for shortcutRegistry");Rs=new Bs(i)}return Rs}static removeInstance(){Rs=void 0}applicableActions(e,t={}){let i=[];const n=(this.activePrefixKey||this.keyMap).getNode(e);n&&(i=n.actions());const s=this.actionRegistry.applicableActions(i,b.instance());if(n)for(const e of Object.keys(t))if(n.actions().indexOf(e)>=0&&this.actionRegistry.hasAction(e)){const t=this.actionRegistry.getAction(e);s.push(t)}return s}shortcutsForAction(e){return[...this.actionToShortcut.get(e)]}actionsForDescriptors(e){let t=this.keyMap;for(const{key:i}of e){if(!t)return[];t=t.getNode(i)}return t?t.actions():[]}globalShortcutKeys(){const e=[];for(const t of this.keyMap.chords().values()){const i=t.actions();(this.actionRegistry.applicableActions(i,b.instance()).length||t.hasChords())&&e.push(t.key())}return e}keysForActions(e){const t=e.flatMap((e=>[...this.actionToShortcut.get(e)].flatMap((e=>e.descriptors.map((e=>e.key))))));return[...new Set(t)]}shortcutTitleForAction(e){for(const t of this.actionToShortcut.get(e))return t.title()}handleShortcut(e,t){this.handleKey(Ke.makeKeyFromEvent(e),e.key,e,t)}actionHasDefaultShortcut(e){return this.devToolsDefaultShortcutActions.has(e)}getShortcutListener(e){const t=Object.keys(e).flatMap((e=>[...this.actionToShortcut.get(e)])),i=new Os(0,0);return t.forEach((e=>{i.addKeyMapping(e.descriptors.map((e=>e.key)),e.action)})),t=>{const n=Ke.makeKeyFromEvent(t),s=this.activePrefixKey?i.getNode(this.activePrefixKey.key()):i;s&&s.getNode(n)&&this.handleShortcut(t,e)}}addShortcutListener(e,t){const i=this.getShortcutListener(t);return e.addEventListener("keydown",i),i}async handleKey(e,t,i,n){const o=e>>8,r=Boolean(n)||Boolean(this.activePrefixKey),a=this.keyMap.getNode(e),l=this.applicableActions(e,n).length>0||a&&a.hasChords();if((r||!function(){if(!i||!On()||/^F\d+|Control|Shift|Alt|Meta|Escape|Win|U\+001B$/.test(t))return!1;if(!o)return!0;const n=qe;if(s.Platform.isMac()){if(Ke.makeKey("z",n.Meta)===e)return!0;if(Ke.makeKey("z",n.Meta|n.Shift)===e)return!0}else{if(Ke.makeKey("z",n.Ctrl)===e)return!0;if(Ke.makeKey("y",n.Ctrl)===e)return!0;if(!s.Platform.isWin()&&Ke.makeKey("z",n.Ctrl|n.Shift)===e)return!0}if((o&(n.Ctrl|n.Alt))==(n.Ctrl|n.Alt))return s.Platform.isWin();return!h(n.Ctrl)&&!h(n.Alt)&&!h(n.Meta)}())&&l&&!Ke.isModifier(Ke.keyCodeAndModifiersFromKey(e).keyCode)&&(i&&i.consume(!0),r||!Ds.hasInstance())){if(this.activePrefixTimeout){clearTimeout(this.activePrefixTimeout);const e=await d.call(this);if(this.activePrefixKey=null,this.activePrefixTimeout=null,e)return;this.consumePrefix&&await this.consumePrefix()}a&&a.hasChords()?(this.activePrefixKey=a,this.consumePrefix=async()=>{this.activePrefixKey=null,this.activePrefixTimeout=null,await d.call(this)},this.activePrefixTimeout=window.setTimeout(this.consumePrefix,Ws)):await d.call(this)}function h(e){return Boolean(o&e)}async function d(){const t=this.applicableActions(e,n);if(!t.length)return!1;for(const e of t){let t;if(n&&n[e.id()]&&(t=await n[e.id()]()),n||(t=await e.execute()),t)return s.userMetrics.keyboardShortcutFired(e.id()),!0}return!1}}registerUserShortcut(e){for(const t of this.disabledDefaultShortcutsForAction.get(e.action))if(t.descriptorsMatch(e.descriptors)&&t.hasKeybindSet(this.keybindSetSetting.get()))return void this.removeShortcut(t);for(const t of this.actionToShortcut.get(e.action))if(t.descriptorsMatch(e.descriptors))return;this.addShortcutToSetting(e)}removeShortcut(e){"DefaultShortcut"===e.type||"KeybindSetShortcut"===e.type?this.addShortcutToSetting(e.changeType("DisabledDefault")):this.removeShortcutFromSetting(e)}disabledDefaultsForAction(e){return this.disabledDefaultShortcutsForAction.get(e)}addShortcutToSetting(e){const t=this.userShortcutsSetting.get();t.push(e),this.userShortcutsSetting.set(t)}removeShortcutFromSetting(e){const t=this.userShortcutsSetting.get(),i=t.findIndex(e.equals,e);-1!==i&&(t.splice(i,1),this.userShortcutsSetting.set(t))}registerShortcut(e){this.actionToShortcut.set(e.action,e),this.keyMap.addKeyMapping(e.descriptors.map((e=>e.key)),e.action)}registerBindings(){this.actionToShortcut.clear(),this.keyMap.clear();const e=this.keybindSetSetting.get();this.disabledDefaultShortcutsForAction.clear(),this.devToolsDefaultShortcutActions.clear();const t=[],i=this.userShortcutsSetting.get();for(const e of i){const i=Ke.createShortcutFromSettingObject(e);"DisabledDefault"===i.type?this.disabledDefaultShortcutsForAction.set(i.action,i):(zs.has(i.action)&&t.push(...i.descriptors.map((e=>Ke.keyCodeAndModifiersFromKey(e.key)))),this.registerShortcut(i))}for(const e of C()){const i=e.id(),s=e.bindings();for(let e=0;s&&e<s.length;++e){const r=s[e].keybindSets;if(!n(s[e].platform)||!o(r))continue;const a=s[e].shortcut.split(/\s+/).map(Ke.makeDescriptorFromBindingShortcut);if(a.length>0){if(this.isDisabledDefault(a,i)){this.devToolsDefaultShortcutActions.add(i);continue}zs.has(i)&&t.push(...a.map((e=>Ke.keyCodeAndModifiersFromKey(e.key)))),r?(r.includes("devToolsDefault")&&this.devToolsDefaultShortcutActions.add(i),this.registerShortcut(new Ke(a,i,"KeybindSetShortcut",new Set(r)))):(this.devToolsDefaultShortcutActions.add(i),this.registerShortcut(new Ke(a,i,"DefaultShortcut")))}}}function n(e){if(!e)return!0;const t=e.split(",");let i=!1;const n=s.Platform.platform();for(let e=0;!i&&e<t.length;++e)i=t[e]===n;return i}function o(t){return!t||t.includes(e)}s.InspectorFrontendHost.InspectorFrontendHostInstance.setWhitelistedShortcuts(JSON.stringify(t))}isDisabledDefault(e,t){const i=this.disabledDefaultShortcutsForAction.get(t);for(const t of i)if(t.descriptorsMatch(e))return!0;return!1}}class Os{keyInternal;actionsInternal;chordsInternal;depth;constructor(e,t=0){this.keyInternal=e,this.actionsInternal=[],this.chordsInternal=new Map,this.depth=t}addAction(e){this.actionsInternal.push(e)}key(){return this.keyInternal}chords(){return this.chordsInternal}hasChords(){return this.chordsInternal.size>0}addKeyMapping(e,t){if(!(e.length<this.depth))if(e.length===this.depth)this.addAction(t);else{const i=e[this.depth];this.chordsInternal.has(i)||this.chordsInternal.set(i,new Os(i,this.depth+1)),this.chordsInternal.get(i).addKeyMapping(e,t)}}getNode(e){return this.chordsInternal.get(e)||null}actions(){return this.actionsInternal}clear(){this.actionsInternal=[],this.chordsInternal=new Map}}class Fs{static instance=new Fs}const zs=new Set(["main.toggle-dock","debugger.toggle-breakpoints-active","debugger.toggle-pause","quick-open.show-command-menu","console.toggle"]),Ws=1e3,Hs="devToolsDefault";var Ns=Object.freeze({__proto__:null,ShortcutRegistry:Bs,ShortcutTreeNode:Os,ForwardedShortcut:Fs,ForwardedActions:zs,KeyTimeout:Ws,DefaultShortcutSetting:Hs}),_s={cssContent:".soft-context-menu{overflow-y:auto;min-width:160px!important;padding:4px 0;border:1px solid var(--sys-color-neutral-outline);border-radius:7px;background-color:var(--sys-color-cdt-base-container);box-shadow:var(--drop-shadow)}:host-context(.-theme-with-dark-background) .soft-context-menu{border:none}.dockside-title{padding-right:13px}.soft-context-menu-item{display:flex;width:100%;font-size:12px;padding:3px 7px 3px 8px;white-space:nowrap;align-items:center;&.soft-context-menu-item-mouse-over{background-color:var(--sys-color-state-hover-on-subtle)}& devtools-icon{width:16px;height:16px;pointer-events:none;&.checkmark{margin:-1px 5px -1px 0;opacity:0%;.soft-context-menu-item[checked] &{opacity:100%}}}}.soft-context-menu-disabled{color:var(--sys-color-state-disabled);pointer-events:none}.soft-context-menu-separator{height:10px;margin:0 1px;& > .separator-line{margin:0;height:5px;border-bottom:1px solid var(--sys-color-divider);pointer-events:none}}.soft-context-menu-item-submenu-arrow{pointer-events:none;font-size:11px;text-align:right;align-self:center;margin-left:auto}.soft-context-menu-custom-item{display:inline-flex;justify-content:center;align-items:center;flex:auto}.soft-context-menu-shortcut{color:var(--sys-color-token-subtle);pointer-events:none;flex:1 1 auto;text-align:right;padding-left:10px;.soft-context-menu-item-mouse-over &{color:inherit}}@media (forced-colors: active){.soft-context-menu-item{color:canvastext}.soft-context-menu-item.soft-context-menu-item-mouse-over,\n .-theme-with-dark-background .soft-context-menu-item.soft-context-menu-item-mouse-over,\n :host-context(.-theme-with-dark-background) .soft-context-menu-item.soft-context-menu-item-mouse-over{background-color:Highlight;color:HighlightText;forced-color-adjust:none}.soft-context-menu .soft-context-menu-item devtools-icon,\n .soft-context-menu .soft-context-menu-item .soft-context-menu-shortcut{color:ButtonText}.soft-context-menu .soft-context-menu-item.soft-context-menu-item-mouse-over devtools-icon,\n .soft-context-menu .soft-context-menu-item.soft-context-menu-item-mouse-over .soft-context-menu-shortcut{color:HighlightText}.soft-context-menu:focus-visible{forced-color-adjust:none;background:canvas;border-color:Highlight}.soft-context-menu-separator > .separator-line{border-bottom-color:ButtonText}}"};const js={checked:"checked",unchecked:"unchecked",sSS:"{PH1}, {PH2}, {PH3}",sS:"{PH1}, {PH2}"},Vs=t.i18n.registerUIStrings("ui/legacy/SoftContextMenu.ts",js),Us=t.i18n.getLocalizedString.bind(void 0,Vs);class Ks{items;itemSelectedCallback;parentMenu;highlightedMenuItemElement;detailsForElementMap;document;glassPane;contextMenuElement;focusRestorer;hideOnUserMouseDownUnlessInMenu;activeSubMenuElement;subMenu;onMenuClosed;focusOnTheFirstItem=!0;keepOpen;loggableParent;constructor(e,t,i,n,s,o){this.items=e,this.itemSelectedCallback=t,this.parentMenu=n,this.highlightedMenuItemElement=null,this.detailsForElementMap=new WeakMap,this.onMenuClosed=s,this.keepOpen=i,this.loggableParent=o||null}getItems(){return this.items}show(e,t){if(!this.items.length)return;this.document=e,this.glassPane=new Ts,this.glassPane.setPointerEventsBehavior(this.parentMenu?"PierceGlassPane":"BlockedByGlassPane"),this.glassPane.registerRequiredCSS(_s),this.glassPane.setContentAnchorBox(t),this.glassPane.setSizeBehavior("MeasureContent"),this.glassPane.setMarginBehavior("NoMargin"),this.glassPane.setAnchorBehavior(this.parentMenu?"PreferRight":"PreferBottom"),this.contextMenuElement=this.glassPane.contentElement.createChild("div","soft-context-menu"),this.contextMenuElement.setAttribute("jslog",`${o.menu().track({resize:!0}).parent("mapped")}`),this.loggableParent&&o.setMappedParent(this.contextMenuElement,this.loggableParent),this.contextMenuElement.tabIndex=-1,q(this.contextMenuElement),this.contextMenuElement.addEventListener("mouseup",(e=>e.consume()),!1),this.contextMenuElement.addEventListener("keydown",this.menuKeyDown.bind(this),!1);const i=!!this.items.find((e=>"checkbox"===e.type));for(let e=0;e<this.items.length;++e)this.contextMenuElement.appendChild(this.createMenuItem(this.items[e],i));if(this.glassPane.show(e),this.focusRestorer=new Gn(this.contextMenuElement),!this.parentMenu){this.hideOnUserMouseDownUnlessInMenu=e=>{let t=this.subMenu;for(;t;){if(t.contextMenuElement===e.composedPath()[0])return;t=t.subMenu}this.discard(),e.consume(!0)},this.document.body.addEventListener("mousedown",this.hideOnUserMouseDownUnlessInMenu,!1);const e=Hi.maybeGetInspectorViewInstance()?.element;if(e){let t=!1;const i=new ResizeObserver((()=>{if(t)return i.disconnect(),void this.discard();t=!0}));i.observe(e)}if(this.contextMenuElement.children&&this.focusOnTheFirstItem){const e=this.contextMenuElement.children[0];this.highlightMenuItem(e,!1)}}}setContextMenuElementLabel(e){this.contextMenuElement&&be(this.contextMenuElement,e)}discard(){this.subMenu&&this.subMenu.discard(),this.focusRestorer&&this.focusRestorer.restore(),this.glassPane&&(this.glassPane.hide(),delete this.glassPane,this.hideOnUserMouseDownUnlessInMenu&&(this.document&&this.document.body.removeEventListener("mousedown",this.hideOnUserMouseDownUnlessInMenu,!1),delete this.hideOnUserMouseDownUnlessInMenu)),this.parentMenu&&(delete this.parentMenu.subMenu,this.parentMenu.activeSubMenuElement&&(ae(this.parentMenu.activeSubMenuElement,!1),delete this.parentMenu.activeSubMenuElement)),this.onMenuClosed?.()}createMenuItem(e,t){if("separator"===e.type)return this.createSeparator();if("subMenu"===e.type)return this.createSubMenu(e,t);const i=document.createElement("div");if(i.classList.add("soft-context-menu-item"),i.tabIndex=-1,$(i),e.checked&&i.setAttribute("checked",""),void 0!==e.id&&i.setAttribute("data-action-id",e.id.toString()),t){const e=a.Icon.create("checkmark","checkmark");i.appendChild(e)}e.tooltip&&Jt.install(i,e.tooltip);const n={actionId:void 0,isSeparator:void 0,customElement:void 0,subItems:void 0,subMenuTimer:void 0};if(e.jslogContext&&!e.element?.hasAttribute("jslog")&&("checkbox"===e.type?i.setAttribute("jslog",`${o.toggle().track({click:!0}).context(e.jslogContext)}`):i.setAttribute("jslog",`${o.action().track({click:!0}).context(e.jslogContext)}`)),e.element&&!e.label){if(i.createChild("div","soft-context-menu-custom-item").appendChild(e.element),e.element?.classList.contains("location-menu")){const t=e.element.ariaLabel||"";e.element.ariaLabel="",be(i,t)}return n.customElement=e.element,this.detailsForElementMap.set(i,n),i}e.enabled||i.classList.add("soft-context-menu-disabled"),ss(i,e.label||""),e.element&&i.appendChild(e.element),i.createChild("span","soft-context-menu-shortcut").textContent=e.shortcut||"",i.addEventListener("mousedown",this.menuItemMouseDown.bind(this),!1),i.addEventListener("mouseup",this.menuItemMouseUp.bind(this),!1),i.addEventListener("mouseover",this.menuItemMouseOver.bind(this),!1),i.addEventListener("mouseleave",this.menuItemMouseLeave.bind(this),!1),n.actionId=e.id;let s=e.label||"";if("checkbox"===e.type){const t=e.checked?Us(js.checked):Us(js.unchecked);s=e.shortcut?Us(js.sSS,{PH1:String(e.label),PH2:e.shortcut,PH3:t}):Us(js.sS,{PH1:String(e.label),PH2:t})}else e.shortcut&&(s=Us(js.sS,{PH1:String(e.label),PH2:e.shortcut}));return be(i,s),this.detailsForElementMap.set(i,n),i}createSubMenu(e,t){const i=document.createElement("div");if(i.classList.add("soft-context-menu-item"),i.tabIndex=-1,X(i),this.detailsForElementMap.set(i,{subItems:e.subItems,actionId:void 0,isSeparator:void 0,customElement:void 0,subMenuTimer:void 0}),t){const e=a.Icon.create("checkmark","checkmark soft-context-menu-item-checkmark");i.appendChild(e)}if(ss(i,e.label||""),ae(i,!1),s.Platform.isMac()&&!m.ThemeSupport.instance().hasTheme()){const e=i.createChild("span","soft-context-menu-item-submenu-arrow");te(e),e.textContent="▶"}else{const e=a.Icon.create("triangle-right","soft-context-menu-item-submenu-arrow");i.appendChild(e)}return i.addEventListener("mousedown",this.menuItemMouseDown.bind(this),!1),i.addEventListener("mouseup",this.menuItemMouseUp.bind(this),!1),i.addEventListener("mouseover",this.menuItemMouseOver.bind(this),!1),i.addEventListener("mouseleave",this.menuItemMouseLeave.bind(this),!1),e.jslogContext&&i.setAttribute("jslog",`${o.item().context(e.jslogContext)}`),i}createSeparator(){const e=document.createElement("div");return e.classList.add("soft-context-menu-separator"),this.detailsForElementMap.set(e,{subItems:void 0,actionId:void 0,isSeparator:!0,customElement:void 0,subMenuTimer:void 0}),e.createChild("div","separator-line"),e}menuItemMouseDown(e){e.consume(!0)}menuItemMouseUp(e){this.triggerAction(e.target,e),e.consume()}root(){let e=this;for(;e.parentMenu;)e=e.parentMenu;return e}setChecked(e,t){e.checked=t;const i=this.contextMenuElement?.querySelector(`[data-action-id="${e.id}"]`);if(!i)return;t?i.setAttribute("checked",""):i.removeAttribute("checked");const n=e.checked?Us(js.checked):Us(js.unchecked);be(i,e.shortcut?Us(js.sSS,{PH1:String(e.label),PH2:e.shortcut,PH3:n}):Us(js.sS,{PH1:String(e.label),PH2:n}))}triggerAction(e,t){const i=this.detailsForElementMap.get(e);if(!i||i.subItems)return this.showSubMenu(e),void t.consume();if(this.keepOpen){t.consume(!0);const e=this.items.find((e=>e.id===i.actionId));void 0!==e?.id&&(this.setChecked(e,!e.checked),this.itemSelectedCallback(e.id))}else this.root().discard(),t.consume(!0),void 0!==i.actionId&&(this.itemSelectedCallback(i.actionId),delete i.actionId)}showSubMenu(e){const t=this.detailsForElementMap.get(e);if(!t)return;if(t.subMenuTimer&&(window.clearTimeout(t.subMenuTimer),delete t.subMenuTimer),this.subMenu||!this.document)return;if(this.activeSubMenuElement=e,ae(e,!0),!t.subItems)return;this.subMenu=new Ks(t.subItems,this.itemSelectedCallback,!1,this);const i=e.boxInWindow();i.y-=5,i.x+=3,i.width-=6,i.height+=10,this.subMenu.show(this.document,i)}menuItemMouseOver(e){this.highlightMenuItem(e.target,!0)}menuItemMouseLeave(e){if(!this.subMenu||!e.relatedTarget)return void this.highlightMenuItem(null,!0);e.relatedTarget===this.contextMenuElement&&this.highlightMenuItem(null,!0)}highlightMenuItem(e,t){if(this.highlightedMenuItemElement!==e){if(this.subMenu&&this.subMenu.discard(),this.highlightedMenuItemElement){const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);this.highlightedMenuItemElement.classList.remove("force-white-icons"),this.highlightedMenuItemElement.classList.remove("soft-context-menu-item-mouse-over"),e&&e.subItems&&e.subMenuTimer&&(window.clearTimeout(e.subMenuTimer),delete e.subMenuTimer)}if(this.highlightedMenuItemElement=e,this.highlightedMenuItemElement){this.highlightedMenuItemElement.classList.add("force-white-icons"),this.highlightedMenuItemElement.classList.add("soft-context-menu-item-mouse-over");const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);e&&e.customElement&&!e.customElement.classList.contains("location-menu")?e.customElement.focus():this.highlightedMenuItemElement.focus(),t&&e&&e.subItems&&!e.subMenuTimer&&(e.subMenuTimer=window.setTimeout(this.showSubMenu.bind(this,this.highlightedMenuItemElement),150))}this.contextMenuElement&&ve(this.contextMenuElement,e)}}highlightPrevious(){let e=this.highlightedMenuItemElement?this.highlightedMenuItemElement.previousSibling:this.contextMenuElement?this.contextMenuElement.lastChild:null,t=e?this.detailsForElementMap.get(e):void 0;for(;e&&t&&(t.isSeparator||e.classList.contains("soft-context-menu-disabled"));)e=e.previousSibling,t=e?this.detailsForElementMap.get(e):void 0;e&&this.highlightMenuItem(e,!1)}highlightNext(){let e=this.highlightedMenuItemElement?this.highlightedMenuItemElement.nextSibling:this.contextMenuElement?this.contextMenuElement.firstChild:null,t=e?this.detailsForElementMap.get(e):void 0;for(;e&&(t&&t.isSeparator||e.classList.contains("soft-context-menu-disabled"));)e=e.nextSibling,t=e?this.detailsForElementMap.get(e):void 0;e&&this.highlightMenuItem(e,!1)}menuKeyDown(e){const t=e;function i(){if(!this.highlightedMenuItemElement)return;const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);e&&!e.customElement&&(this.triggerAction(this.highlightedMenuItemElement,t),e.subItems&&this.subMenu&&this.subMenu.highlightNext(),t.consume(!0))}switch(t.key){case"ArrowUp":this.highlightPrevious(),t.consume(!0);break;case"ArrowDown":this.highlightNext(),t.consume(!0);break;case"ArrowLeft":this.parentMenu&&(this.highlightMenuItem(null,!1),this.discard()),t.consume(!0);break;case"ArrowRight":{if(!this.highlightedMenuItemElement)break;const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);e&&e.subItems&&(this.showSubMenu(this.highlightedMenuItemElement),this.subMenu&&this.subMenu.highlightNext()),e?.customElement?.classList.contains("location-menu")&&(e.customElement.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowRight"})),this.highlightMenuItem(null,!0)),t.consume(!0);break}case"Escape":this.discard(),t.consume(!0);break;case"Enter":if("Enter"!==t.key)return;i.call(this);break;case" ":i.call(this);break;default:t.consume(!0)}}markAsMenuItemCheckBox(){if(this.contextMenuElement)for(const e of this.contextMenuElement.children)"soft-context-menu-separator"!==e.className&&G(e)}setFocusOnTheFirstItem(e){this.focusOnTheFirstItem=e}}var qs=Object.freeze({__proto__:null,SoftContextMenu:Ks});class $s{typeInternal;label;disabled;checked;contextMenu;idInternal;customElement;shortcut;#s;jslogContext;constructor(e,t,i,n,s,o,r){this.typeInternal=t,this.label=i,this.disabled=n,this.checked=s,this.contextMenu=e,this.idInternal=void 0,this.#s=o,"item"!==t&&"checkbox"!==t||(this.idInternal=e?e.nextId():0),this.jslogContext=r}id(){if(void 0===this.idInternal)throw new Error("Tried to access a ContextMenu Item ID but none was set.");return this.idInternal}type(){return this.typeInternal}isEnabled(){return!this.disabled}setEnabled(e){this.disabled=!e}buildDescriptor(){switch(this.typeInternal){case"item":{const e={type:"item",id:this.idInternal,label:this.label,enabled:!this.disabled,checked:void 0,subItems:void 0,tooltip:this.#s,jslogContext:this.jslogContext};return this.customElement&&(e.element=this.customElement),this.shortcut&&(e.shortcut=this.shortcut),e}case"separator":return{type:"separator",id:void 0,label:void 0,enabled:void 0,checked:void 0,subItems:void 0};case"checkbox":{const e={type:"checkbox",id:this.idInternal,label:this.label,checked:Boolean(this.checked),enabled:!this.disabled,subItems:void 0,tooltip:this.#s,jslogContext:this.jslogContext};return this.customElement&&(e.element=this.customElement),e}}throw new Error("Invalid item type:"+this.typeInternal)}setShortcut(e){this.shortcut=e}}class Gs{contextMenu;items;constructor(e){this.contextMenu=e,this.items=[]}appendItem(e,t,i){const n=new $s(this.contextMenu,"item",e,i?.disabled,void 0,i?.tooltip,i?.jslogContext);return i?.additionalElement&&(n.customElement=i?.additionalElement),this.items.push(n),this.contextMenu&&this.contextMenu.setHandler(n.id(),t),n}appendCustomItem(e,t){const i=new $s(this.contextMenu,"item",void 0,void 0,void 0,void 0,t);return i.customElement=e,this.items.push(i),i}appendSeparator(){const e=new $s(this.contextMenu,"separator");return this.items.push(e),e}appendAction(e,t,i){if(i&&!M.instance().hasAction(e))return;const n=M.instance().getAction(e);t||(t=n.title());const s=this.appendItem(t,n.execute.bind(n),{disabled:!n.enabled(),jslogContext:e}),o=Bs.instance().shortcutTitleForAction(e);o&&s.setShortcut(o)}appendSubMenuItem(e,t,i){const n=new Xs(this.contextMenu,e,t,i);return n.init(),this.items.push(n),n}appendCheckboxItem(e,t,i){const n=new $s(this.contextMenu,"checkbox",e,i?.disabled,i?.checked,i?.tooltip,i?.jslogContext);return this.items.push(n),this.contextMenu&&this.contextMenu.setHandler(n.id(),t),i?.additionalElement&&(n.customElement=i?.additionalElement),n}}class Xs extends $s{sections;sectionList;constructor(e,t,i,n){super(e,"subMenu",t,i,void 0,void 0,n),this.sections=new Map,this.sectionList=[]}init(){Ys.groupWeights.forEach((e=>this.section(e)))}section(e){let t=e?this.sections.get(e):null;return t||(t=new Gs(this.contextMenu),e?(this.sections.set(e,t),this.sectionList.push(t)):this.sectionList.splice(Ys.groupWeights.indexOf("default"),0,t)),t}headerSection(){return this.section("header")}newSection(){return this.section("new")}revealSection(){return this.section("reveal")}clipboardSection(){return this.section("clipboard")}editSection(){return this.section("edit")}debugSection(){return this.section("debug")}viewSection(){return this.section("view")}defaultSection(){return this.section("default")}overrideSection(){return this.section("override")}saveSection(){return this.section("save")}footerSection(){return this.section("footer")}buildDescriptor(){const e={type:"subMenu",label:this.label,enabled:!this.disabled,subItems:[],id:void 0,checked:void 0,jslogContext:this.jslogContext},t=this.sectionList.filter((e=>Boolean(e.items.length)));for(const i of t){for(const t of i.items)e.subItems||(e.subItems=[]),e.subItems.push(t.buildDescriptor());i!==t[t.length-1]&&(e.subItems||(e.subItems=[]),e.subItems.push({type:"separator",id:void 0,subItems:void 0,checked:void 0,enabled:void 0,label:void 0}))}return e}appendItemsAtLocation(e){const t=Zs;t.sort(((e,t)=>(e.order||0)-(t.order||0)));for(const i of t){if(i.experiment&&!n.Runtime.experiments.isEnabled(i.experiment))continue;const t=i.location,s=i.actionId;if(!t||!t.startsWith(e+"/"))continue;const o=t.substr(e.length+1);o&&!o.includes("/")&&(s&&this.section(o).appendAction(s))}}static uniqueSectionName=0}class Ys extends Xs{contextMenu;pendingTargets;event;useSoftMenu;keepOpen;x;y;onSoftMenuClosed;jsLogContext;handlers;idInternal;softMenu;contextMenuLabel;openHostedMenu;eventTarget;loggableParent=null;constructor(e,t={}){super(null);const i=e;this.contextMenu=this,super.init(),this.pendingTargets=[],this.event=i,this.eventTarget=this.event.target,this.useSoftMenu=Boolean(t.useSoftMenu),this.keepOpen=Boolean(t.keepOpen),this.x=void 0===t.x?i.x:t.x,this.y=void 0===t.y?i.y:t.y,this.onSoftMenuClosed=t.onSoftMenuClosed,this.handlers=new Map,this.idInternal=0,this.openHostedMenu=null;let n=Is(e)||e.target;if(n){for(this.appendApplicableItems(n);n instanceof Element&&!n.hasAttribute("jslog");)n=n.parentElementOrShadowHost()??null;this.loggableParent=n}}static initialize(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.SetUseSoftMenu,(function(e){Ys.useSoftMenu=e.data}))}static installHandler(e){e.body.addEventListener("contextmenu",(function(e){new Ys(e).show()}),!1)}nextId(){return this.idInternal++}isHostedMenuOpen(){return Boolean(this.openHostedMenu)}getItems(){return this.softMenu?.getItems()||[]}setChecked(e,t){this.softMenu?.setChecked(e,t)}async show(){Ys.pendingMenu=this,this.event.consume(!0);const e=await Promise.all(this.pendingTargets.map((async e=>{const t=await async function(e){const t=[];for(const i of Qs)if(n.Runtime.Runtime.isDescriptorEnabled({experiment:i.experiment,condition:void 0})&&i.contextTypes)for(const n of i.contextTypes())e instanceof n&&t.push(await i.loadProvider());return t}(e);return{target:e,providers:t}})));if(Ys.pendingMenu===this){Ys.pendingMenu=null;for(const{target:t,providers:i}of e)for(const e of i)e.appendApplicableItems(this.event,this,t);this.pendingTargets=[],this.innerShow()}}discard(){this.softMenu&&this.softMenu.discard()}registerLoggablesWithin(e,t){for(const i of e)i.jslogContext&&("checkbox"===i.type?o.registerLoggable(i,`${o.toggle().track({click:!0}).context(i.jslogContext)}`,t||e):"item"===i.type?o.registerLoggable(i,`${o.action().track({click:!0}).context(i.jslogContext)}`,t||e):"subMenu"===i.type&&o.registerLoggable(i,`${o.item().context(i.jslogContext)}`,t||e),i.subItems&&this.registerLoggablesWithin(i.subItems,i))}innerShow(){const e=this.buildMenuDescriptors();if(!this.eventTarget)return;const t=this.eventTarget.ownerDocument;if(this.useSoftMenu||Ys.useSoftMenu||s.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode()){this.softMenu=new Ks(e,this.itemSelected.bind(this),this.keepOpen,void 0,this.onSoftMenuClosed,this.loggableParent);const i="mouse"===this.event.pointerType&&this.event.button>=0;this.softMenu.setFocusOnTheFirstItem(!i),this.softMenu.show(t,new AnchorBox(this.x,this.y,0,0)),this.contextMenuLabel&&this.softMenu.setContextMenuElementLabel(this.contextMenuLabel)}else{function n(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuCleared,this.menuCleared,this),s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuItemSelected,this.onItemSelected,this)}s.InspectorFrontendHost.InspectorFrontendHostInstance.showContextMenuAtPoint(this.x,this.y,e,t),o.registerLoggable(e,`${o.menu()}`,this.loggableParent),this.registerLoggablesWithin(e),this.openHostedMenu=e,queueMicrotask(n.bind(this))}}setContextMenuLabel(e){this.contextMenuLabel=e}setX(e){this.x=e}setY(e){this.y=e}setHandler(e,t){t&&this.handlers.set(e,t)}buildMenuDescriptors(){return super.buildDescriptor().subItems}onItemSelected(e){this.itemSelected(e.data)}itemSelected(e){const t=this.handlers.get(e);if(t&&t.call(this),this.openHostedMenu){const t=(e,i)=>{for(const n of e){if(n.id===i)return n;const e=n.subItems&&t(n.subItems,i);if(e)return e}return null},i=t(this.openHostedMenu,e);i&&i.jslogContext&&o.logClick(i,new MouseEvent("click"))}this.menuCleared()}menuCleared(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.removeEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuCleared,this.menuCleared,this),s.InspectorFrontendHost.InspectorFrontendHostInstance.events.removeEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuItemSelected,this.onItemSelected,this),this.openHostedMenu&&o.logResize(this.openHostedMenu,new DOMRect(0,0,0,0)),this.openHostedMenu=null,this.keepOpen||this.onSoftMenuClosed?.()}appendApplicableItems(e){this.pendingTargets.includes(e)||this.pendingTargets.push(e)}markAsMenuItemCheckBox(){this.softMenu&&this.softMenu.markAsMenuItemCheckBox()}static pendingMenu=null;static useSoftMenu=!1;static groupWeights=["header","new","reveal","edit","clipboard","debug","view","default","override","save","footer"]}const Qs=[];const Zs=[];var Js=Object.freeze({__proto__:null,Item:$s,Section:Gs,SubMenu:Xs,ContextMenu:Ys,registerProvider:function(e){Qs.push(e)},registerItem:function(e){Zs.push(e)},maybeRemoveItem:function(e){const t=Zs.findIndex((t=>t.actionId===e.actionId&&t.location===e.location));return!(t<0)&&(Zs.splice(t,1),!0)}}),eo={cssContent:":host{position:absolute;top:0;bottom:0;left:0;right:0;display:flex;background-color:var(--color-background-opacity-80);z-index:1000}.drop-target-message{flex:auto;font-size:30px;color:var(--sys-color-token-subtle);display:flex;justify-content:center;align-items:center;margin:20px;border:4px dashed var(--sys-color-neutral-outline);pointer-events:none}"};var to=Object.freeze({__proto__:null,DropTarget:class{element;transferTypes;messageText;handleDrop;enabled;dragMaskElement;constructor(e,t,i,n){e.addEventListener("dragenter",this.onDragEnter.bind(this),!0),e.addEventListener("dragover",this.onDragOver.bind(this),!0),this.element=e,this.transferTypes=t,this.messageText=i,this.handleDrop=n,this.enabled=!0,this.dragMaskElement=null}setEnabled(e){this.enabled=e}onDragEnter(e){this.enabled&&this.hasMatchingType(e)&&e.consume(!0)}hasMatchingType(e){const t=e;if(!t.dataTransfer)return!1;for(const e of this.transferTypes){if(Array.from(t.dataTransfer.items).find((t=>e.kind===t.kind&&Boolean(e.type.exec(t.type)))))return!0}return!1}onDragOver(e){const t=e;if(!this.enabled||!this.hasMatchingType(t))return;if(t.dataTransfer&&(t.dataTransfer.dropEffect="copy"),t.consume(!0),this.dragMaskElement)return;this.dragMaskElement=this.element.createChild("div","");d.createShadowRootWithCoreStyles(this.dragMaskElement,{cssFile:eo,delegatesFocus:void 0}).createChild("div","drop-target-message").textContent=this.messageText,this.dragMaskElement.addEventListener("drop",this.onDrop.bind(this),!0),this.dragMaskElement.addEventListener("dragleave",this.onDragLeave.bind(this),!0)}onDrop(e){const t=e;t.consume(!0),this.removeMask(),this.enabled&&t.dataTransfer&&this.handleDrop(t.dataTransfer)}onDragLeave(e){e.consume(!0),this.removeMask()}removeMask(){this.dragMaskElement&&(this.dragMaskElement.remove(),this.dragMaskElement=null)}},Type:{URI:{kind:"string",type:/text\/uri-list/},Folder:{kind:"file",type:/$^/},File:{kind:"file",type:/.*/},WebFile:{kind:"file",type:/[\w]+/},ImageFile:{kind:"file",type:/image\/.*/}}}),io={cssContent:".empty-bold-text{display:block;font-size:1.5em;margin:0.83em 0;font-weight:bold}.empty-view{color:var(--sys-color-token-subtle);padding:30px;text-align:center;min-width:70px}.empty-view-scroller{justify-content:center;overflow:auto}.empty-view p{white-space:initial;line-height:18px;max-width:300px;flex-shrink:0}"};function no(e){return e.data}function so(e,t){e.data=t}class oo{elementInternal;elementsById;constructor(e){this.elementInternal=e,this.elementsById=new Map}element(){return this.elementInternal}$(e){return this.elementsById.get(e)}static build(e,...t){return oo.render(oo.template(e),t)}static cached(e,...t){let i=uo.get(e);return i||(i=oo.template(e),uo.set(e,i)),oo.render(i,t)}static template(e){let t="",i=!0;for(let n=0;n<e.length-1;n++){t+=e[n];const s=e[n].lastIndexOf(">"),o=e[n].indexOf("<",s+1);-1!==s&&-1===o?i=!0:-1!==o&&(i=!1),t+=i?ro:lo(n)}t+=e[e.length-1];const n=document.createElement("template");n.innerHTML=t;const s=n.ownerDocument.createTreeWalker(n.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);let o=0;const r=[],a=[],l=[];for(;s.nextNode();){const e=s.currentNode;if(e.nodeType===Node.ELEMENT_NODE&&e.hasAttributes()){e.hasAttribute("$")&&(l.push(e),a.push({replaceNodeIndex:void 0,attr:void 0,elementId:e.getAttribute("$")||""}),e.removeAttribute("$"));const t=[];for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i].name;if(!ho.test(n)&&!ho.test(e.attributes[i].value))continue;t.push(n),l.push(e);const s={index:o,names:n.split(ho),values:e.attributes[i].value.split(ho)};o+=s.names.length-1,o+=s.values.length-1;const r={elementId:void 0,replaceNodeIndex:void 0,attr:s};a.push(r)}for(let i=0;i<t.length;i++)e.removeAttribute(t[i])}if(e.nodeType===Node.TEXT_NODE&&-1!==no(e).indexOf(ro)){const t=no(e).split(ao);so(e,t[t.length-1]);const i=e.parentNode;for(let n=0;n<t.length-1;n++){t[n]&&i.insertBefore(document.createTextNode(t[n]),e);const s=document.createElement("span");l.push(s),a.push({attr:void 0,elementId:void 0,replaceNodeIndex:o++}),i.insertBefore(s,e)}}e.nodeType!==Node.TEXT_NODE||e.previousSibling&&e.previousSibling.nodeType!==Node.ELEMENT_NODE||e.nextSibling&&e.nextSibling.nodeType!==Node.ELEMENT_NODE||!/^\s*$/.test(no(e))||r.push(e)}for(let e=0;e<l.length;e++)l[e].classList.add(co(e));for(const e of r)e.remove();return{template:n,binds:a}}static render(e,t){const i=e.template.ownerDocument.importNode(e.template.content,!0),n=i.firstChild===i.lastChild?i.firstChild:i,s=new oo(n),o=[];for(let t=0;t<e.binds.length;t++){const e=co(t),n=i.querySelector("."+e);n.classList.remove(e),o.push(n)}for(let i=0;i<e.binds.length;i++){const n=e.binds[i],r=o[i];if(void 0!==n.elementId)s.elementsById.set(n.elementId,r);else if(void 0!==n.replaceNodeIndex){const e=t[n.replaceNodeIndex];r.parentNode.replaceChild(this.nodeForValue(e),r)}else{if(void 0===n.attr)throw new Error("Unexpected bind");if(2===n.attr.names.length&&1===n.attr.values.length&&"function"==typeof t[n.attr.index])t[n.attr.index].call(null,r);else{let e=n.attr.names[0];for(let i=1;i<n.attr.names.length;i++)e+=t[n.attr.index+i-1],e+=n.attr.names[i];if(e){let i=n.attr.values[0];for(let e=1;e<n.attr.values.length;e++)i+=t[n.attr.index+n.attr.names.length-1+e-1],i+=n.attr.values[e];r.setAttribute(e,i)}}}}return s}static nodeForValue(e){if(e instanceof Node)return e;if(e instanceof oo)return e.elementInternal;if(Array.isArray(e)){const t=document.createDocumentFragment();for(const i of e)t.appendChild(this.nodeForValue(i));return t}return document.createTextNode(String(e))}}const ro="{{template-text}}",ao=/{{template-text}}/,lo=e=>"template-attribute"+e,ho=/template-attribute\d+/,co=e=>"template-class-"+e,uo=new Map,mo=(e,...t)=>oo.cached(e,...t).element();var po=Object.freeze({__proto__:null,Fragment:oo,textMarker:ro,attributeMarker:lo,html:mo});class go extends Lt{hrefInternal;clickable;onClick;onKeyDown;static create(e,t,n,s,r){t||(t=e);return mo` +import*as e from"../../core/common/common.js";import*as t from"../../core/i18n/i18n.js";import*as i from"../../core/platform/platform.js";import*as n from"../../core/root/root.js";import*as s from"../../core/host/host.js";import*as o from"../visual_logging/visual_logging.js";import*as r from"../../models/text_utils/text_utils.js";import*as a from"../components/icon_button/icon_button.js";import*as l from"../components/adorners/adorners.js";import*as h from"../components/settings/settings.js";import*as d from"./utils/utils.js";export{d as Utils};import*as c from"../../core/dom_extension/dom_extension.js";import*as u from"../components/helpers/helpers.js";import*as m from"./theme_support/theme_support.js";import*as p from"../lit-html/lit-html.js";let g;class b{flavorsInternal;eventDispatchers;constructor(){this.flavorsInternal=new Map,this.eventDispatchers=new Map}static instance(e={forceNew:null}){const{forceNew:t}=e;return g&&!t||(g=new b),g}static removeInstance(){g=void 0}setFlavor(e,t){(this.flavorsInternal.get(e)||null)!==t&&(t?this.flavorsInternal.set(e,t):this.flavorsInternal.delete(e),this.dispatchFlavorChange(e,t))}dispatchFlavorChange(e,t){for(const i of f)i.contextTypes().includes(e)&&i.loadListener().then((e=>e.flavorChanged(t)));const i=this.eventDispatchers.get(e);i&&i.dispatchEventToListeners("FlavorChanged",t)}addFlavorChangeListener(t,i,n){let s=this.eventDispatchers.get(t);s||(s=new e.ObjectWrapper.ObjectWrapper,this.eventDispatchers.set(t,s)),s.addEventListener("FlavorChanged",i,n)}removeFlavorChangeListener(e,t,i){const n=this.eventDispatchers.get(e);n&&(n.removeEventListener("FlavorChanged",t,i),n.hasEventListeners("FlavorChanged")||this.eventDispatchers.delete(e))}flavor(e){return this.flavorsInternal.get(e)||null}flavors(){return new Set(this.flavorsInternal.keys())}}const f=[];var v=Object.freeze({__proto__:null,Context:b,registerListener:function(e){f.push(e)}});const w={elements:"Elements",screenshot:"Screenshot",network:"Network",memory:"Memory",javascript_profiler:"JavaScript Profiler",console:"Console",performance:"Performance",mobile:"Mobile",help:"Help",layers:"Layers",navigation:"Navigation",drawer:"Drawer",global:"Global",resources:"Resources",background_services:"Background Services",settings:"Settings",debugger:"Debugger",sources:"Sources",rendering:"Rendering",recorder:"Recorder",changes:"Changes"},x=t.i18n.registerUIStrings("ui/legacy/ActionRegistration.ts",w),E=t.i18n.getLocalizedString.bind(void 0,x);class I extends e.ObjectWrapper.ObjectWrapper{enabledInternal=!0;toggledInternal=!1;actionRegistration;constructor(e){super(),this.actionRegistration=e}id(){return this.actionRegistration.actionId}async execute(){if(!this.actionRegistration.loadActionDelegate)return!1;const e=await this.actionRegistration.loadActionDelegate(),t=this.id();return e.handleAction(b.instance(),t)}icon(){return this.actionRegistration.iconClass}toggledIcon(){return this.actionRegistration.toggledIconClass}toggleWithRedColor(){return Boolean(this.actionRegistration.toggleWithRedColor)}setEnabled(e){this.enabledInternal!==e&&(this.enabledInternal=e,this.dispatchEventToListeners("Enabled",e))}enabled(){return this.enabledInternal}category(){return this.actionRegistration.category}tags(){if(this.actionRegistration.tags)return this.actionRegistration.tags.map((e=>e())).join("\0")}toggleable(){return Boolean(this.actionRegistration.toggleable)}title(){let e=this.actionRegistration.title?this.actionRegistration.title():t.i18n.lockedString("");const i=this.actionRegistration.options;if(i)for(const t of i)t.value!==this.toggledInternal&&(e=t.title());return e}toggled(){return this.toggledInternal}setToggled(e){console.assert(this.toggleable(),"Shouldn't be toggling an untoggleable action",this.id()),this.toggledInternal!==e&&(this.toggledInternal=e,this.dispatchEventToListeners("Toggled",e))}options(){return this.actionRegistration.options}contextTypes(){if(this.actionRegistration.contextTypes)return this.actionRegistration.contextTypes()}canInstantiate(){return Boolean(this.actionRegistration.loadActionDelegate)}bindings(){return this.actionRegistration.bindings}experiment(){return this.actionRegistration.experiment}setting(){return this.actionRegistration.setting}condition(){return this.actionRegistration.condition}order(){return this.actionRegistration.order}}const y=new Map;function S(){y.clear()}function C(){return Array.from(y.values()).filter((t=>{const i=t.setting();try{if(i&&!e.Settings.moduleSetting(i).get())return!1}catch(e){if(e.message.startsWith("No setting registered"))return!1}return n.Runtime.Runtime.isDescriptorEnabled({experiment:t.experiment(),condition:t.condition()})})).sort(((e,t)=>(e.order()||0)-(t.order()||0)))}var T=Object.freeze({__proto__:null,Action:I,registerActionExtension:function(e){const t=e.actionId;if(y.has(t))throw new Error(`Duplicate action ID '${t}'`);if(!i.StringUtilities.isExtendedKebabCase(t))throw new Error(`Invalid action ID '${t}'`);y.set(t,new I(e))},reset:S,getRegisteredActionExtensions:C,maybeRemoveActionExtension:function(e){return y.delete(e)},getLocalizedActionCategory:function(e){switch(e){case"ELEMENTS":return E(w.elements);case"SCREENSHOT":return E(w.screenshot);case"NETWORK":return E(w.network);case"MEMORY":return E(w.memory);case"JAVASCRIPT_PROFILER":return E(w.javascript_profiler);case"CONSOLE":return E(w.console);case"PERFORMANCE":return E(w.performance);case"MOBILE":return E(w.mobile);case"HELP":return E(w.help);case"LAYERS":return E(w.layers);case"NAVIGATION":return E(w.navigation);case"DRAWER":return E(w.drawer);case"GLOBAL":return E(w.global);case"RESOURCES":return E(w.resources);case"BACKGROUND_SERVICES":return E(w.background_services);case"SETTINGS":return E(w.settings);case"DEBUGGER":return E(w.debugger);case"SOURCES":return E(w.sources);case"RENDERING":return E(w.rendering);case"RECORDER":return E(w.recorder);case"CHANGES":return E(w.changes);case"":return t.i18n.lockedString("")}return t.i18n.lockedString(e)}});let k;class M{actionsById;constructor(){this.actionsById=new Map,this.registerActions()}static instance(e={forceNew:null}){const{forceNew:t}=e;return k&&!t||(k=new M),k}static removeInstance(){k=void 0}static reset(){M.removeInstance(),S()}registerActions(){for(const e of C())this.actionsById.set(e.id(),e),e.canInstantiate()||e.setEnabled(!1)}availableActions(){return this.applicableActions([...this.actionsById.keys()],b.instance())}actions(){return[...this.actionsById.values()]}applicableActions(e,t){const i=[];for(const s of e){const e=this.actionsById.get(s);e&&e.enabled()&&n(e,t.flavors())&&i.push(e)}return i;function n(e,t){const i=e.contextTypes();if(!i)return!0;for(let e=0;e<i.length;++e){const n=i[e];if(Boolean(n)&&t.has(n))return!0}return!1}}hasAction(e){return this.actionsById.has(e)}getAction(e){const t=this.actionsById.get(e);if(t)return t;throw new Error(`Cannot find registered action with ID '${e}'`)}}var L=Object.freeze({__proto__:null,ActionRegistry:M});let P,D,A=0;function R(e){return(e||"")+ ++A}function B(e,t){const i=R("labelledControl");t.id=i,e.setAttribute("for",i)}function O(e){e.setAttribute("role","alert"),e.setAttribute("aria-live","polite")}function F(e){e.setAttribute("role","button")}function z(e){e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")}function W(e){e.setAttribute("role","group")}function H(e){e.setAttribute("role","link")}function N(e){F(e),e.setAttribute("aria-haspopup","true")}function _(e){e.setAttribute("role","tab")}function j(e){e.setAttribute("role","tabpanel")}function V(e){e.setAttribute("role","tree")}function U(e){e.setAttribute("role","treeitem")}function K(e){e.setAttribute("role","textbox")}function q(e){e.setAttribute("role","menu")}function $(e){e.setAttribute("role","menuitem")}function G(e){e.setAttribute("role","menuitemcheckbox")}function X(e){$(e),e.setAttribute("aria-haspopup","true")}function Y(e){e.setAttribute("role","complementary")}function Q(e){e.setAttribute("role","navigation")}function Z(e){e.setAttribute("role","listbox")}function J(e){e.setAttribute("aria-multiselectable","true")}function ee(e){e.setAttribute("role","option")}function te(e){e.setAttribute("aria-hidden","true")}function ie(e,t){e.setAttribute("role","heading"),e.setAttribute("aria-level",t.toString())}function ne(e){return e.hasAttribute("role")}function se(e,t){t?e.setAttribute("aria-placeholder",t):e.removeAttribute("aria-placeholder")}function oe(e){e.id||(e.id=R("ariaElement"))}function re(e,t){t?(oe(t),e.setAttribute("aria-controls",t.id)):e.removeAttribute("aria-controls")}function ae(e,t){e.setAttribute("aria-expanded",Boolean(t).toString())}function le(e){e.removeAttribute("aria-expanded")}function he(e,t="none"){e.setAttribute("aria-autocomplete",t)}function de(e){e.removeAttribute("aria-autocomplete")}function ce(e,t="false"){"false"!==t?e.setAttribute("aria-haspopup",t):e.removeAttribute("aria-haspopup")}function ue(e,t){e.setAttribute("aria-selected",Boolean(t).toString())}function me(e){e.removeAttribute("aria-selected")}function pe(e,t){t?e.setAttribute("aria-invalid",t.toString()):e.removeAttribute("aria-invalid")}function ge(e,t){e.setAttribute("aria-pressed",Boolean(t).toString())}function be(e,t){e.setAttribute("aria-label",t)}function fe(e,t){e.setAttribute("aria-description",t)}function ve(e,t){t?(t.isConnected&&e.isConnected&&console.assert(i.DOMUtilities.getEnclosingShadowRootForNode(t)===i.DOMUtilities.getEnclosingShadowRootForNode(e),"elements are not in the same shadow dom"),oe(t),e.setAttribute("aria-activedescendant",t.id)):e.removeAttribute("aria-activedescendant")}function we(e,t){e.setAttribute("aria-setsize",t.toString())}function xe(e,t){e.setAttribute("aria-posinset",t.toString())}function Ee(e){e.style.position="absolute",e.style.left="-999em",e.style.width="100em",e.style.overflow="hidden"}let Ie=!1;function ye(){if(!P){const e=document.body.createChild("div");Ee(e),e.setAttribute("role","alert"),e.setAttribute("aria-atomic","true"),P=e}if(!D){const e=document.body.createChild("div");Ee(e),e.setAttribute("role","alert"),e.setAttribute("aria-atomic","true"),D=e}return Ie=!Ie,Ie?(D.textContent="",P):(P.textContent="",D)}function Se(e){ye().textContent=i.StringUtilities.trimEndWithMaxLength(e,1e4)}var Ce=Object.freeze({__proto__:null,nextId:R,bindLabelToControl:B,markAsAlert:O,markAsApplication:function(e){e.setAttribute("role","application")},markAsButton:F,markAsCheckbox:function(e){e.setAttribute("role","checkbox")},markAsCombobox:function(e){e.setAttribute("role","combobox")},markAsModalDialog:z,markAsGroup:W,markAsLink:H,markAsMenuButton:N,markAsProgressBar:function(e,t=0,i=100){e.setAttribute("role","progressbar"),e.setAttribute("aria-valuemin",t.toString()),e.setAttribute("aria-valuemax",i.toString())},markAsTab:_,markAsTablist:function(e){e.setAttribute("role","tablist")},markAsTabpanel:j,markAsTree:V,markAsTreeitem:U,markAsTextBox:K,markAsMenu:q,markAsMenuItem:$,markAsMenuItemCheckBox:G,markAsMenuItemSubMenu:X,markAsList:function(e){e.setAttribute("role","list")},markAsListitem:function(e){e.setAttribute("role","listitem")},markAsMain:function(e){e.setAttribute("role","main")},markAsComplementary:Y,markAsNavigation:Q,markAsListBox:Z,markAsMultiSelectable:J,markAsOption:ee,markAsRadioGroup:function(e){e.setAttribute("role","radiogroup")},markAsHidden:te,markAsSlider:function(e,t=0,i=100){e.setAttribute("role","slider"),e.setAttribute("aria-valuemin",String(t)),e.setAttribute("aria-valuemax",String(i))},markAsHeading:ie,markAsPoliteLiveRegion:function(e,t){e.setAttribute("aria-live","polite"),t&&e.setAttribute("aria-atomic","true")},markAsLog:function(e){e.setAttribute("role","log")},hasRole:ne,removeRole:function(e){e.removeAttribute("role")},setPlaceholder:se,markAsPresentation:function(e){e.setAttribute("role","presentation")},markAsStatus:function(e){e.setAttribute("role","status")},ensureId:oe,setAriaValueText:function(e,t){e.setAttribute("aria-valuetext",t)},setAriaValueNow:function(e,t){e.setAttribute("aria-valuenow",t)},setAriaValueMinMax:function(e,t,i){e.setAttribute("aria-valuemin",t),e.setAttribute("aria-valuemax",i)},setControls:re,setChecked:function(e,t){e.setAttribute("aria-checked",Boolean(t).toString())},setCheckboxAsIndeterminate:function(e){e.setAttribute("aria-checked","mixed")},setDisabled:function(e,t){e.setAttribute("aria-disabled",Boolean(t).toString())},setExpanded:ae,unsetExpandable:le,setHidden:function(e,t){e.setAttribute("aria-hidden",Boolean(t).toString())},setLevel:function(e,t){e.setAttribute("aria-level",t.toString())},setAutocomplete:he,clearAutocomplete:de,setHasPopup:ce,setSelected:ue,clearSelected:me,setInvalid:pe,setPressed:ge,setValueNow:function(e,t){e.setAttribute("aria-valuenow",t.toString())},setValueText:function(e,t){e.setAttribute("aria-valuetext",t.toString())},setProgressBarValue:function(e,t,i){e.setAttribute("aria-valuenow",t.toString()),i&&e.setAttribute("aria-valuetext",i)},setLabel:be,setDescription:fe,setActiveDescendant:ve,setSetSize:we,setPositionInSet:xe,alertElementInstance:ye,alert:Se}),Te=Object.freeze({__proto__:null}),ke={cssContent:".widget{box-shadow:var(--drop-shadow);background:var(--sys-color-cdt-base-container);justify-content:flex-start;align-items:stretch;display:flex}.dialog-close-button{position:absolute;right:9px;top:9px;z-index:1}"},Me={cssContent:":host{position:absolute!important;top:0;bottom:0;left:0;right:0;overflow:hidden;contain:strict;background-color:transparent}:host-context(.dimmed-pane){background-color:var(--color-background-opacity-50)}:host-context(.no-pointer-events){pointer-events:none}.widget{display:flex;background-color:transparent;pointer-events:auto;flex:none}.no-pointer-events{pointer-events:none}.arrow{background-image:var(--image-file-popoverArrows);width:19px;height:19px}.arrow-top{background-position:0 76px;margin-top:-19px;margin-left:-9px}.arrow-bottom{background-position:0 57px;margin-left:-9px}.arrow-left{background-position:0 38px;margin-left:-19px;margin-top:-9px}.arrow-right{background-position:0 19px;margin-top:-9px}.arrow-none{display:none}:host-context(.-theme-with-dark-background) .arrow{filter:invert(80%)}"},Le={cssContent:":host{padding:0;margin:0;display:inline-flex;flex-shrink:0;align-items:center!important;overflow:hidden;white-space:nowrap}input{height:12px;width:12px;flex-shrink:0;accent-color:var(--sys-color-primary-bright);color:var(--sys-color-on-primary);&:focus{outline:auto 5px -webkit-focus-ring-color}}input.inside-datagrid{height:10px;width:10px}.dt-checkbox-text{margin-left:3px;overflow:hidden;text-overflow:ellipsis}.dt-checkbox-subtitle{color:var(--sys-color-token-subtle);white-space:break-spaces}@media (forced-colors: active){input.dt-checkbox-theme-preserve{forced-color-adjust:none}input.dt-checkbox-theme-preserve:active{background:HighlightText}input.dt-checkbox-theme-preserve:checked,\n input.dt-checkbox-theme-preserve:active:checked{background:Highlight;border-color:Highlight}input.dt-checkbox-theme-preserve:hover:enabled{border-color:Highlight}input.dt-checkbox-theme-preserve:active::before,\n input.dt-checkbox-theme-preserve:active::after{background-color:Highlight}input.dt-checkbox-theme-preserve:checked::before,\n input.dt-checkbox-theme-preserve:checked::after,\n input.dt-checkbox-theme-preserve:active:checked::before,\n input.dt-checkbox-theme-preserve:active:checked::after{background-color:HighlightText}input.dt-checkbox-theme-preserve:hover:checked::before,\n input.dt-checkbox-theme-preserve:hover:checked::after{background-color:Highlight!important}input.dt-checkbox-theme-preserve:hover:checked{background:HighlightText}}"},Pe={cssContent:".close-button{width:20px;height:20px;display:flex;align-items:center;justify-content:center}.close-button:hover devtools-icon,\n.close-button:focus-visible devtools-icon{color:var(--icon-default-hover)}.close-button:focus{outline:2px solid var(--sys-color-state-focus-ring)}@media (forced-colors: active) and (prefers-color-scheme: dark){.close-button{filter:brightness(100)}}"},De={cssContent:".widget{padding:20px;box-sizing:border-box;max-width:400px;overflow:hidden}.message{text-align:center}.message,\n.button{font-size:larger;white-space:pre;margin:10px 0}.button{text-align:center;margin-top:20px}.button button{min-width:100px}.reason{color:var(--sys-color-error);margin-top:10px}.message span{white-space:normal;word-wrap:break-word;max-width:100%;display:inline-block;overflow:hidden;text-overflow:ellipsis;padding:5px;margin:0}"};const Ae=1e-5;class Re{x;y;z;constructor(e,t,i){this.x=e,this.y=t,this.z=i}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const e=this.length();e<=Ae||(this.x/=e,this.y/=e,this.z/=e)}}class Be{x;y;constructor(e,t){this.x=e,this.y=t}distanceTo(e){return Math.sqrt(Math.pow(e.x-this.x,2)+Math.pow(e.y-this.y,2))}projectOn(e){return 0===e.x&&0===e.y?new Be(0,0):e.scale((this.x*e.x+this.y*e.y)/(Math.pow(e.x,2)+Math.pow(e.y,2)))}scale(e){return new Be(this.x*e,this.y*e)}toString(){return Math.round(100*this.x)/100+", "+Math.round(100*this.y)/100}}class Oe{controlPoints;constructor(e,t){this.controlPoints=[e,t]}static parse(e){const t=Oe.KeywordValues,i=e.toLowerCase().replace(/\s+/g,"");if(t.has(i))return Oe.parse(t.get(i));const n=i.match(/^cubic-bezier\(([^,]+),([^,]+),([^,]+),([^,]+)\)$/);if(n){const e=new Be(parseFloat(n[1]),parseFloat(n[2])),t=new Be(parseFloat(n[3]),parseFloat(n[4]));return new Oe(e,t)}return null}evaluateAt(e){function t(e,t,i){return 3*(1-i)*(1-i)*i*e+3*(1-i)*i*i*t+Math.pow(i,3)}const i=t(this.controlPoints[0].x,this.controlPoints[1].x,e),n=t(this.controlPoints[0].y,this.controlPoints[1].y,e);return new Be(i,n)}asCSSText(){const e="cubic-bezier("+this.controlPoints.join(", ")+")",t=Oe.KeywordValues;for(const[i,n]of t)if(e===n&&"linear"!==i)return i;return e}static Regex=/((cubic-bezier\([^)]+\))|\b(linear(?![-\(])|ease-in-out|ease-in|ease-out|ease)\b)|(linear\([^)]+\))/g;static KeywordValues=new Map([["linear","cubic-bezier(0, 0, 1, 1)"],["ease","cubic-bezier(0.25, 0.1, 0.25, 1)"],["ease-in","cubic-bezier(0.42, 0, 1, 1)"],["ease-in-out","cubic-bezier(0.42, 0, 0.58, 1)"],["ease-out","cubic-bezier(0, 0, 0.58, 1)"]])}const Fe=new Oe(new Be(0,0),new Be(1,1));class ze{alpha;beta;gamma;constructor(e,t,i){this.alpha=e,this.beta=t,this.gamma=i}static fromDeviceOrientationRotationMatrix(e){let t,i,n;return Math.abs(e.m33)<Ae?Math.abs(e.m13)<Ae?(t=Math.atan2(e.m12,e.m11),i=e.m23>0?Math.PI/2:-Math.PI/2,n=0):e.m13>0?(t=Math.atan2(-e.m21,e.m22),i=Math.asin(e.m23),n=-Math.PI/2):(t=Math.atan2(e.m21,-e.m22),i=-Math.asin(e.m23),i+=i>0||Math.abs(i)<Ae?-Math.PI:Math.PI,n=-Math.PI/2):e.m33>0?(t=Math.atan2(-e.m21,e.m22),i=Math.asin(e.m23),n=Math.atan2(-e.m13,e.m33)):(t=Math.atan2(e.m21,-e.m22),i=-Math.asin(e.m23),i+=i>0||Math.abs(i)<Ae?-Math.PI:Math.PI,n=Math.atan2(e.m13,-e.m33)),t<-Ae&&(t+=2*Math.PI),t=Number(Ne(t).toFixed(6)),i=Number(Ne(i).toFixed(6)),n=Number(Ne(n).toFixed(6)),new ze(t,i,n)}}const We=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},He=function(e,t){const i=e.x*t.m14+e.y*t.m24+e.z*t.m34+t.m44,n=(e.x*t.m11+e.y*t.m21+e.z*t.m31+t.m41)/i,s=(e.x*t.m12+e.y*t.m22+e.z*t.m32+t.m42)/i,o=(e.x*t.m13+e.y*t.m23+e.z*t.m33+t.m43)/i;return new Re(n,s,o)},Ne=function(e){return 180*e/Math.PI};class _e{width;height;constructor(e,t){this.width=e,this.height=t}clipTo(e){return e?new _e(Math.min(this.width,e.width),Math.min(this.height,e.height)):this}scale(e){return new _e(this.width*e,this.height*e)}isEqual(e){return null!==e&&this.width===e.width&&this.height===e.height}widthToMax(e){return new _e(Math.max(this.width,"number"==typeof e?e:e.width),this.height)}addWidth(e){return new _e(this.width+("number"==typeof e?e:e.width),this.height)}heightToMax(e){return new _e(this.width,Math.max(this.height,"number"==typeof e?e:e.height))}addHeight(e){return new _e(this.width,this.height+("number"==typeof e?e:e.height))}}class je{minimum;preferred;constructor(e,t){if(this.minimum=e||new _e(0,0),this.preferred=t||this.minimum,this.minimum.width>this.preferred.width||this.minimum.height>this.preferred.height)throw new Error("Minimum size is greater than preferred.")}isEqual(e){return null!==e&&this.minimum.isEqual(e.minimum)&&this.preferred.isEqual(e.preferred)}widthToMax(e){return"number"==typeof e?new je(this.minimum.widthToMax(e),this.preferred.widthToMax(e)):new je(this.minimum.widthToMax(e.minimum),this.preferred.widthToMax(e.preferred))}addWidth(e){return"number"==typeof e?new je(this.minimum.addWidth(e),this.preferred.addWidth(e)):new je(this.minimum.addWidth(e.minimum),this.preferred.addWidth(e.preferred))}heightToMax(e){return"number"==typeof e?new je(this.minimum.heightToMax(e),this.preferred.heightToMax(e)):new je(this.minimum.heightToMax(e.minimum),this.preferred.heightToMax(e.preferred))}addHeight(e){return"number"==typeof e?new je(this.minimum.addHeight(e),this.preferred.addHeight(e)):new je(this.minimum.addHeight(e.minimum),this.preferred.addHeight(e.preferred))}}var Ve=Object.freeze({__proto__:null,_Eps:Ae,Vector:Re,Point:Be,CubicBezier:Oe,LINEAR_BEZIER:Fe,EulerAngles:ze,scalarProduct:We,crossProduct:function(e,t){const i=e.y*t.z-e.z*t.y,n=e.z*t.x-e.x*t.z,s=e.x*t.y-e.y*t.x;return new Re(i,n,s)},subtract:function(e,t){const i=e.x-t.x,n=e.y-t.y,s=e.z-t.z;return new Re(i,n,s)},multiplyVectorByMatrixAndNormalize:He,calculateAngle:function(e,t){const i=e.length(),n=t.length();if(i<=Ae||n<=Ae)return 0;const s=We(e,t)/i/n;return Math.abs(s)>1?0:Ne(Math.acos(s))},degreesToRadians:function(e){return e*Math.PI/180},degreesToGradians:function(e){return e/9*10},degreesToTurns:function(e){return e/360},radiansToDegrees:Ne,radiansToGradians:function(e){return 200*e/Math.PI},radiansToTurns:function(e){return e/(2*Math.PI)},gradiansToRadians:function(e){return e*Math.PI/200},turnsToRadians:function(e){return 2*e*Math.PI},boundsForTransformedPoints:function(e,t,i){i||(i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0}),t.length%3&&console.warn("Invalid size of points array");for(let n=0;n<t.length;n+=3){let s=new Re(t[n],t[n+1],t[n+2]);s=He(s,e),i.minX=Math.min(i.minX,s.x),i.maxX=Math.max(i.maxX,s.x),i.minY=Math.min(i.minY,s.y),i.maxY=Math.max(i.maxY,s.y)}return i},Size:_e,Constraints:je}),Ue={cssContent:":host{display:inline-flex;border:1px solid var(--sys-color-neutral-outline);border-radius:4px;position:relative;vertical-align:sub;margin:2px;background-color:var(--sys-color-cdt-base-container);justify-content:center;width:28px}:host:hover{border:none;background-color:var(--sys-color-state-hover-on-subtle)}"};class Ke{descriptors;action;type;keybindSets;constructor(e,t,i,n){this.descriptors=e,this.action=t,this.type=i,this.keybindSets=n||new Set}title(){return this.descriptors.map((e=>e.name)).join(" ")}isDefault(){return"DefaultShortcut"===this.type||"DisabledDefault"===this.type||"KeybindSetShortcut"===this.type&&this.keybindSets.has(Hs)}changeType(e){return new Ke(this.descriptors,this.action,e)}changeKeys(e){return this.descriptors=e,this}descriptorsMatch(e){return e.length===this.descriptors.length&&e.every(((e,t)=>e.key===this.descriptors[t].key))}hasKeybindSet(e){return!this.keybindSets||this.keybindSets.has(e)}equals(e){return this.descriptorsMatch(e.descriptors)&&this.type===e.type&&this.action===e.action}static createShortcutFromSettingObject(e){return new Ke(e.descriptors,e.action,e.type)}static makeKey(e,t){return"string"==typeof e&&(e=e.charCodeAt(0)-(/^[a-z]/.test(e)?32:0)),t=t||qe.None,Ke.makeKeyFromCodeAndModifiers(e,t)}static makeKeyFromEvent(e){let t=qe.None;e.shiftKey&&(t|=qe.Shift),e.ctrlKey&&(t|=qe.Ctrl),e.altKey&&(t|=qe.Alt),e.metaKey&&(t|=qe.Meta);const i=e.keyCode||e.__keyCode;return Ke.makeKeyFromCodeAndModifiers(i,t)}static makeKeyFromEventIgnoringModifiers(e){const t=e.keyCode||e.__keyCode;return Ke.makeKeyFromCodeAndModifiers(t,qe.None)}static eventHasCtrlEquivalentKey(e){return s.Platform.isMac()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}static eventHasEitherCtrlOrMeta(e){return e.metaKey||e.ctrlKey}static hasNoModifiers(e){const t=e;return!(t.ctrlKey||t.shiftKey||t.altKey||t.metaKey)}static makeDescriptor(e,t){return{key:Ke.makeKey("string"==typeof e?e:e.code,t),name:Ke.shortcutToString(e,t)}}static makeDescriptorFromBindingShortcut(e){const[t,...i]=e.split(/\+(?!$)/).reverse();let n=0;for(const t of i){const i=qe[t];console.assert(void 0!==i,`Only one key other than modifier is allowed in shortcut <${e}>`),n|=i}console.assert(t.length>0,`Modifiers-only shortcuts are not allowed (encountered <${e}>)`);const s=nt[t]||st[t];return s&&"shiftKey"in s&&s.shiftKey&&(n|=qe.Shift),Ke.makeDescriptor(s||t,n)}static shortcutToString(e,t){return"string"!=typeof e&&Ke.isModifier(e.code)?Ke.modifiersToString(t):Ke.modifiersToString(t)+Ke.keyName(e)}static keyName(e){return"string"==typeof e?e.toUpperCase():"string"==typeof e.name?e.name:e.name[s.Platform.platform()]||e.name.other||""}static makeKeyFromCodeAndModifiers(e,t){return 255&e|(t||0)<<8}static keyCodeAndModifiersFromKey(e){return{keyCode:255&e,modifiers:e>>8}}static isModifier(e){const{keyCode:t}=Ke.keyCodeAndModifiersFromKey(e);return t===nt.Shift.code||t===nt.Ctrl.code||t===nt.Alt.code||t===nt.Meta.code}static modifiersToString(e){const t=s.Platform.isMac(),i=qe,n=new Map([[i.Ctrl,t?"Ctrl ":"Ctrl + "],[i.Alt,t?"⌥ ":"Alt + "],[i.Shift,t?"⇧ ":"Shift + "],[i.Meta,t?"⌘ ":"Win + "]]);return[i.Meta,i.Ctrl,i.Alt,i.Shift].map((function(t){return(e||0)&t?n.get(t):""})).join("")}}const qe={None:0,Shift:1,Ctrl:2,Alt:4,Meta:8,CtrlOrMeta:s.Platform.isMac()?8:2,ShiftOrOption:s.Platform.isMac()?4:1},$e={code:37,name:"←"},Ge={code:38,name:"↑"},Xe={code:39,name:"→"},Ye={code:40,name:"↓"},Qe={code:17,name:"Ctrl"},Ze={code:27,name:"Esc"},Je={code:32,name:"Space"},et={code:187,name:"+"},tt={code:192,name:"`"},it={code:222,name:"'"},nt={Backspace:{code:8,name:"↤"},Tab:{code:9,name:{mac:"⇥",other:"Tab"}},Enter:{code:13,name:{mac:"↩",other:"Enter"}},Shift:{code:16,name:{mac:"⇧",other:"Shift"}},Ctrl:Qe,Control:Qe,Alt:{code:18,name:"Alt"},Esc:Ze,Escape:Ze,Space:Je," ":Je,PageUp:{code:33,name:{mac:"⇞",other:"PageUp"}},PageDown:{code:34,name:{mac:"⇟",other:"PageDown"}},End:{code:35,name:{mac:"↗",other:"End"}},Home:{code:36,name:{mac:"↖",other:"Home"}},Left:$e,Up:Ge,Right:Xe,Down:Ye,ArrowLeft:$e,ArrowUp:Ge,ArrowRight:Xe,ArrowDown:Ye,Delete:{code:46,name:"Del"},Zero:{code:48,name:"0"},H:{code:72,name:"H"},N:{code:78,name:"N"},P:{code:80,name:"P"},Meta:{code:91,name:"Meta"},F1:{code:112,name:"F1"},F2:{code:113,name:"F2"},F3:{code:114,name:"F3"},F4:{code:115,name:"F4"},F5:{code:116,name:"F5"},F6:{code:117,name:"F6"},F7:{code:118,name:"F7"},F8:{code:119,name:"F8"},F9:{code:120,name:"F9"},F10:{code:121,name:"F10"},F11:{code:122,name:"F11"},F12:{code:123,name:"F12"},Semicolon:{code:186,name:";"},NumpadPlus:{code:107,name:"Numpad +"},NumpadMinus:{code:109,name:"Numpad -"},Numpad0:{code:96,name:"Numpad 0"},Plus:et,Equal:et,Comma:{code:188,name:","},Minus:{code:189,name:"-"},Period:{code:190,name:"."},Slash:{code:191,name:"/"},QuestionMark:{code:191,name:"?"},Apostrophe:tt,Tilde:{code:192,name:"Tilde"},Backquote:tt,IntlBackslash:tt,LeftSquareBracket:{code:219,name:"["},RightSquareBracket:{code:221,name:"]"},Backslash:{code:220,name:"\\"},SingleQuote:it,Quote:it,get CtrlOrMeta(){return s.Platform.isMac()?this.Meta:this.Ctrl}},st={};!function(){for(const e in nt){const t=nt[e];if("object"==typeof t&&t.code){const i="string"==typeof t.name?t.name:e;st[i]=t}}}();var ot=Object.freeze({__proto__:null,KeyboardShortcut:Ke,Modifiers:qe,Keys:nt,KeyBindings:st}),rt={cssContent:"::slotted(input.dt-radio-button){height:17px;width:17px;min-width:17px;border-radius:8px;vertical-align:middle;margin:0 5px 5px 0;accent-color:var(--sys-color-primary-bright);color:var(--sys-color-on-primary)}::slotted(input.dt-radio-button:focus){box-shadow:var(--legacy-focus-ring-active-shadow)}@media (forced-colors: active){::slotted(input.dt-radio-button){--gradient-start:ButtonFace;--gradient-end:ButtonFace}::slotted(input.dt-radio-button:checked){--gradient-start:Highlight;--gradient-end:Highlight}}"},at={cssContent:".dt-range-input{appearance:none;margin:0;padding:0;height:10px;width:88px;outline:none;background:none}.dt-range-input::-webkit-slider-thumb,\n.-theme-preserve{appearance:none;margin:0;padding:0;border:0;width:12px;height:12px;margin-top:-5px;border-radius:50%;background-color:var(--sys-color-primary)}.dt-range-input::-webkit-slider-runnable-track{appearance:none;margin:0;padding:0;width:100%;height:2px;background-color:var(--sys-color-surface-variant)}.dt-range-input:focus::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--sys-color-inverse-primary)}.dt-range-input:disabled::-webkit-slider-thumb{background-color:var(--sys-color-state-disabled)}@media (forced-colors: active){.dt-range-input{forced-color-adjust:none}}"},lt={cssContent:"div{display:inline-flex;height:14px;align-items:center;vertical-align:middle;white-space:nowrap;padding:1px 4px;text-align:left;font-size:11px;line-height:normal;font-weight:bold;text-shadow:none;color:var(--sys-color-inverse-on-surface);border-radius:7px}div.verbose{background-color:var(--sys-color-token-attribute-value)}:host-context(.-theme-with-dark-background) div.verbose{background-color:var(--sys-color-token-tag)}div.info{background-color:var(--sys-color-token-meta)}div.warning{background-color:var(--sys-color-token-attribute)}:host-context(.-theme-with-dark-background) div.warning{background-color:var(--sys-color-token-attribute-value)}div.error{background-color:var(--sys-color-error-bright)}"};const ht={close:"Close",dockToRight:"Dock to right",dockToBottom:"Dock to bottom",dockToLeft:"Dock to left",undockIntoSeparateWindow:"Undock into separate window",devtoolsUndocked:"DevTools is undocked",devToolsDockedTo:"DevTools is docked to {PH1}"},dt=t.i18n.registerUIStrings("ui/legacy/DockController.ts",ht),ct=t.i18n.getLocalizedString.bind(void 0,dt);let ut;class mt extends e.ObjectWrapper.ObjectWrapper{canDockInternal;closeButton;currentDockStateSetting;lastDockStateSetting;dockSideInternal=void 0;titles;savedFocus;constructor(t){if(super(),this.canDockInternal=t,this.closeButton=new wn(ct(ht.close),"cross"),this.closeButton.element.setAttribute("jslog",`${o.close().track({click:!0})}`),this.closeButton.element.classList.add("close-devtools"),this.closeButton.addEventListener("Click",s.InspectorFrontendHost.InspectorFrontendHostInstance.closeWindow.bind(s.InspectorFrontendHost.InspectorFrontendHostInstance)),this.currentDockStateSetting=e.Settings.Settings.instance().moduleSetting("currentDockState"),this.lastDockStateSetting=e.Settings.Settings.instance().createSetting("last-dock-state","bottom"),!t)return this.dockSideInternal="undocked",void this.closeButton.setVisible(!1);this.currentDockStateSetting.addChangeListener(this.dockSideChanged,this),-1===pt.indexOf(this.currentDockStateSetting.get())&&this.currentDockStateSetting.set("right"),-1===pt.indexOf(this.lastDockStateSetting.get())&&this.currentDockStateSetting.set("bottom")}static instance(e={forceNew:null,canDock:!1}){const{forceNew:t,canDock:i}=e;return ut&&!t||(ut=new mt(i)),ut}initialize(){this.canDockInternal&&(this.titles=[ct(ht.dockToRight),ct(ht.dockToBottom),ct(ht.dockToLeft),ct(ht.undockIntoSeparateWindow)],this.dockSideChanged())}dockSideChanged(){this.setDockSide(this.currentDockStateSetting.get()),setTimeout(this.announceDockLocation.bind(this),2e3)}dockSide(){return this.dockSideInternal}canDock(){return this.canDockInternal}isVertical(){return"right"===this.dockSideInternal||"left"===this.dockSideInternal}setDockSide(e){if(-1===pt.indexOf(e)&&(e=pt[0]),this.dockSideInternal===e)return;void 0!==this.dockSideInternal&&document.body.classList.remove(this.dockSideInternal),document.body.classList.add(e),this.dockSideInternal&&this.lastDockStateSetting.set(this.dockSideInternal),this.savedFocus=i.DOMUtilities.deepActiveElement(document);const t={from:this.dockSideInternal,to:e};this.dispatchEventToListeners("BeforeDockSideChanged",t),console.timeStamp("DockController.setIsDocked"),this.dockSideInternal=e,this.currentDockStateSetting.set(e),s.InspectorFrontendHost.InspectorFrontendHostInstance.setIsDocked("undocked"!==e,this.setIsDockedResponse.bind(this,t)),this.closeButton.setVisible("undocked"!==this.dockSideInternal),this.dispatchEventToListeners("DockSideChanged",t)}setIsDockedResponse(e){this.dispatchEventToListeners("AfterDockSideChanged",e),this.savedFocus&&(this.savedFocus.focus(),this.savedFocus=null)}toggleDockSide(){if(this.lastDockStateSetting.get()===this.currentDockStateSetting.get()){const e=pt.indexOf(this.currentDockStateSetting.get())||0;this.lastDockStateSetting.set(pt[(e+1)%pt.length])}this.setDockSide(this.lastDockStateSetting.get())}announceDockLocation(){"undocked"===this.dockSideInternal?Se(ct(ht.devtoolsUndocked)):Se(ct(ht.devToolsDockedTo,{PH1:this.dockSideInternal||""}))}}const pt=["right","bottom","left","undocked"];let gt;class bt{static instance(e={forceNew:null}){const{forceNew:t}=e;return gt&&!t||(gt=new bt),gt}item(){return mt.instance().closeButton}}var ft=Object.freeze({__proto__:null,DockController:mt,ToggleDockActionDelegate:class{handleAction(e,t){return mt.instance().toggleDockSide(),!0}},CloseButtonProvider:bt}),vt={cssContent:".infobar{color:var(--sys-color-on-surface);display:flex;flex:auto;flex-direction:column;position:relative;padding:6px;min-width:fit-content}.infobar:focus{outline:2px solid var(--sys-color-state-focus-ring);outline-offset:-2px}.infobar-warning{background-color:var(--sys-color-surface-yellow);color:var(--sys-color-on-surface-yellow)}.infobar-error{--override-infobar-error-background:var(--sys-color-surface-error);--override-infobar-error-text:var(--sys-color-on-surface-error);background-color:var(--override-infobar-error-background);color:var(--override-infobar-error-text)}.infobar-main-row{display:flex;flex-direction:row;justify-content:flex-start;min-height:25px}.infobar-info-container{display:flex;align-items:center;flex-grow:1;flex-wrap:wrap}.infobar-info-message{display:flex;margin:5px 0}.infobar-info-text{display:flex;align-items:center;margin:0 4px}.infobar-details-rows{padding:5px 5px 0}.infobar-details-row{display:flex;flex-direction:column;line-height:18px;padding-bottom:6px}.infobar-close-container{display:flex;flex-shrink:0;align-items:center}.infobar-close-container > .infobar-button.link-style{margin:4px}.infobar-selectable{user-select:text}.infobar-button{color:var(--sys-color-token-subtle);padding:0 4px}.info-icon{mask-image:var(--image-file-info);background-color:var(--icon-info)}.warning-icon{mask-image:var(--image-file-warning);background-color:var(--icon-warning)}.error-icon{mask-image:var(--image-file-cross-circle);background-color:var(--icon-error)}.issue-icon{mask-image:var(--image-file-issue-text-filled);background-color:var(--icon-info)}.icon{mask-size:20px 20px;width:20px;height:20px;flex-shrink:0}.devtools-link.text-button:hover,\n.devtools-link.text-button:focus,\n.devtools-link.text-button:active{background-color:transparent;box-shadow:none}"};const wt={dontShowAgain:"Don't show again",showMore:"Show more",close:"Close"},xt=t.i18n.registerUIStrings("ui/legacy/Infobar.ts",wt),Et=t.i18n.getLocalizedString.bind(void 0,xt);class It{element;shadowRoot;contentElement;mainRow;detailsRows;hasDetails;detailsMessage;infoContainer;infoMessage;infoText;actionContainer;disableSetting;closeContainer;toggleElement;closeButton;closeCallback;#e=null;parentView;constructor(e,t,i,n,s=!0,r){if(this.element=document.createElement("div"),r&&this.element.setAttribute("jslog",`${o.dialog(r).track({resize:!0})}`),this.element.classList.add("flex-none"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:vt,delegatesFocus:void 0}),this.contentElement=this.shadowRoot.createChild("div","infobar infobar-"+e),this.mainRow=this.contentElement.createChild("div","infobar-main-row"),this.detailsRows=this.contentElement.createChild("div","infobar-details-rows hidden"),this.hasDetails=!1,this.detailsMessage="",this.infoContainer=this.mainRow.createChild("div","infobar-info-container"),this.infoMessage=this.infoContainer.createChild("div","infobar-info-message"),this.infoMessage.createChild("div",e+"-icon icon"),this.infoText=this.infoMessage.createChild("div","infobar-info-text"),this.infoText.textContent=t,O(this.infoText),this.actionContainer=this.infoContainer.createChild("div","infobar-info-actions"),i){this.contentElement.setAttribute("role","group");for(const e of i){const t=this.actionCallbackFactory(e);let i="infobar-button";e.highlight&&(i+=" primary-button");const n=os(e.text,t,{className:i,jslogContext:e.jslogContext});e.highlight&&!this.#e&&(this.#e=n),this.actionContainer.appendChild(n)}}if(this.disableSetting=n||null,n){const e=os(Et(wt.dontShowAgain),this.onDisable.bind(this),{className:"infobar-button"});this.actionContainer.appendChild(e)}this.closeContainer=this.mainRow.createChild("div","infobar-close-container"),this.toggleElement=os(Et(wt.showMore),this.onToggleDetails.bind(this),{className:"link-style devtools-link hidden",jslogContext:"show-more"}),this.toggleElement.setAttribute("role","link"),this.closeContainer.appendChild(this.toggleElement),this.closeButton=this.closeContainer.createChild("div","close-button","dt-close-button"),this.closeButton.hidden=!s,this.closeButton.setTabbable(!0),fe(this.closeButton,Et(wt.close)),self.onInvokeElement(this.closeButton,this.dispose.bind(this)),"issue"!==e&&(this.contentElement.tabIndex=0),be(this.contentElement,t),this.contentElement.addEventListener("keydown",(e=>e.keyCode===nt.Esc.code?(this.dispose(),void e.consume()):e.target===this.contentElement&&"Enter"===e.key&&this.hasDetails?(this.onToggleDetails(),void e.consume()):void 0)),this.closeCallback=null}static create(e,t,i,n,s){return n&&n.get()?null:new It(e,t,i,n,void 0,s)}dispose(){this.element.remove(),this.onResize(),this.closeCallback&&this.closeCallback.call(null)}setText(e){this.infoText.textContent=e,this.onResize()}setCloseCallback(e){this.closeCallback=e}setParentView(e){this.parentView=e}actionCallbackFactory(e){return e.delegate?e.dismiss?(()=>{e.delegate&&e.delegate(),this.dispose()}).bind(this):e.delegate:e.dismiss?this.dispose.bind(this):()=>{}}onResize(){this.parentView&&this.parentView.doResize()}onDisable(){this.disableSetting&&this.disableSetting.set(!0),this.dispose()}onToggleDetails(){this.detailsRows.classList.remove("hidden"),this.toggleElement.remove(),this.onResize(),Se("string"==typeof this.detailsMessage?this.detailsMessage:this.detailsMessage.textContent||""),this.#e?this.#e.focus():this.closeButton.focus()}createDetailsRowMessage(e){this.hasDetails=!0,this.detailsMessage=e,this.toggleElement.classList.remove("hidden");const t=this.detailsRows.createChild("div","infobar-details-row").createChild("span","infobar-row-message");return"string"==typeof e?t.textContent=e:t.appendChild(e),t}}var yt=Object.freeze({__proto__:null,Infobar:It}),St={cssContent:".tabbed-pane-header-tab{height:26px;margin:0;border:none;border-left:2px solid transparent;border-right:2px solid transparent;&.selected{border-width:0 2px}& > .tabbed-pane-header-tab-icon > devtools-icon{width:14px;height:14px;color:var(--icon-warning)}}.tabbed-pane-header-contents{margin-left:0;min-width:min-content}.tabbed-pane-left-toolbar{margin-right:0!important}"};class Ct extends e.ObjectWrapper.ObjectWrapper{isEnabledInternal;elementsInternal;installDragOnMouseDownBound;cursorInternal;startX;startY;constructor(){super(),this.isEnabledInternal=!0,this.elementsInternal=new Set,this.installDragOnMouseDownBound=this.installDragOnMouseDown.bind(this),this.cursorInternal="nwse-resize"}isEnabled(){return this.isEnabledInternal}setEnabled(e){this.isEnabledInternal=e,this.updateElementCursors()}elements(){return[...this.elementsInternal]}addElement(e){this.elementsInternal.has(e)||(this.elementsInternal.add(e),e.addEventListener("pointerdown",this.installDragOnMouseDownBound,!1),this.updateElementCursor(e))}removeElement(e){this.elementsInternal.has(e)&&(this.elementsInternal.delete(e),e.removeEventListener("pointerdown",this.installDragOnMouseDownBound,!1),e.style.removeProperty("cursor"))}updateElementCursors(){this.elementsInternal.forEach(this.updateElementCursor.bind(this))}updateElementCursor(e){this.isEnabledInternal?(e.style.setProperty("cursor",this.cursor()),e.style.setProperty("touch-action","none")):(e.style.removeProperty("cursor"),e.style.removeProperty("touch-action"))}cursor(){return this.cursorInternal}setCursor(e){this.cursorInternal=e,this.updateElementCursors()}installDragOnMouseDown(e){const t=e.target;if(!this.elementsInternal.has(t))return!1;Rn(t,this.dragStart.bind(this),(e=>{this.drag(e)}),this.dragEnd.bind(this),this.cursor(),e)}dragStart(e){return!!this.isEnabledInternal&&(this.startX=e.pageX,this.startY=e.pageY,this.sendDragStart(this.startX,this.startY),!0)}sendDragStart(e,t){this.dispatchEventToListeners("ResizeStart",{startX:e,currentX:e,startY:t,currentY:t})}drag(e){return this.isEnabledInternal?(this.sendDragMove(this.startX,e.pageX,this.startY,e.pageY,e.shiftKey),e.preventDefault(),!1):(this.dragEnd(e),!0)}sendDragMove(e,t,i,n,s){this.dispatchEventToListeners("ResizeUpdateXY",{startX:e,currentX:t,startY:i,currentY:n,shiftKey:s})}dragEnd(e){this.dispatchEventToListeners("ResizeEnd"),delete this.startX,delete this.startY}}class Tt extends Ct{isVerticalInternal;constructor(){super(),this.isVerticalInternal=!0}isVertical(){return this.isVerticalInternal}setVertical(e){this.isVerticalInternal=e,this.updateElementCursors()}cursor(){return this.isVerticalInternal?"ns-resize":"ew-resize"}sendDragStart(e,t){const i=this.isVerticalInternal?t:e;this.dispatchEventToListeners("ResizeStart",{startPosition:i,currentPosition:i})}sendDragMove(e,t,i,n,s){this.isVerticalInternal?this.dispatchEventToListeners("ResizeUpdatePosition",{startPosition:i,currentPosition:n,shiftKey:s}):this.dispatchEventToListeners("ResizeUpdatePosition",{startPosition:e,currentPosition:t,shiftKey:s})}}var kt=Object.freeze({__proto__:null,ResizerWidget:Ct,SimpleResizerWidget:Tt}),Mt={cssContent:".shadow-split-widget{display:flex;overflow:hidden}.shadow-split-widget-contents{display:flex;position:relative;flex-direction:column;contain:layout size style}.shadow-split-widget-sidebar{flex:none}.shadow-split-widget-main,\n.shadow-split-widget-sidebar.maximized{flex:auto}.shadow-split-widget.hbox > .shadow-split-widget-resizer{position:absolute;top:0;bottom:0;width:6px;z-index:4000}.shadow-split-widget.vbox > .shadow-split-widget-resizer{position:absolute;left:0;right:0;height:6px;z-index:4000}.shadow-split-widget.vbox > .shadow-split-widget-sidebar.no-default-splitter{border:0!important}.shadow-split-widget.vbox > .shadow-split-widget-sidebar:not(.maximized){border:0;border-top:1px solid var(--sys-color-divider)}.shadow-split-widget.hbox > .shadow-split-widget-sidebar:not(.maximized){border:0;border-left:1px solid var(--sys-color-divider)}.shadow-split-widget.vbox > .shadow-split-widget-sidebar:first-child:not(.maximized){border:0;border-bottom:1px solid var(--sys-color-divider)}.shadow-split-widget.hbox > .shadow-split-widget-sidebar:first-child:not(.maximized){border:0;border-right:1px solid var(--sys-color-divider)}:host-context(.disable-resizer-for-elements-hack) .shadow-split-widget-resizer{pointer-events:none}"};class Lt extends HTMLElement{static get observedAttributes(){return["flex","padding","padding-top","padding-bottom","padding-left","padding-right","margin","margin-top","margin-bottom","margin-left","margin-right","overflow","overflow-x","overflow-y","font-size","color","background","background-color","border","border-top","border-bottom","border-left","border-right","max-width","max-height"]}attributeChangedCallback(e,t,i){if("flex"!==e)if(null===i){if(this.style.removeProperty(e),e.startsWith("padding-")||e.startsWith("margin-")||e.startsWith("border-")||e.startsWith("background-")||e.startsWith("overflow-")){const t=e.substring(0,e.indexOf("-")),i=this.getAttribute(t);null!==i&&this.style.setProperty(t,i)}}else this.style.setProperty(e,i);else null===i?this.style.removeProperty("flex"):"initial"===i||"auto"===i||"none"===i||-1!==i.indexOf(" ")?this.style.setProperty("flex",i):this.style.setProperty("flex","0 0 "+i)}}class Pt extends Lt{constructor(e){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction",e),this.style.setProperty("justify-content","flex-start")}static get observedAttributes(){return super.observedAttributes.concat(["x-start","x-center","x-stretch","x-baseline","justify-content"])}attributeChangedCallback(e,t,i){"x-start"!==e&&"x-center"!==e&&"x-stretch"!==e&&"x-baseline"!==e?super.attributeChangedCallback(e,t,i):null===i?this.style.removeProperty("align-items"):this.style.setProperty("align-items","x-start"===e?"flex-start":e.substr(2))}}customElements.define("x-vbox",class extends Pt{constructor(){super("column")}}),customElements.define("x-hbox",class extends Pt{constructor(){super("row")}}),customElements.define("x-cbox",class extends Lt{constructor(){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction","column"),this.style.setProperty("justify-content","center"),this.style.setProperty("align-items","center")}}),customElements.define("x-div",class extends Lt{constructor(){super(),this.style.setProperty("display","block")}}),customElements.define("x-span",class extends Lt{constructor(){super(),this.style.setProperty("display","inline")}}),customElements.define("x-text",class extends Lt{constructor(){super(),this.style.setProperty("display","inline"),this.style.setProperty("white-space","pre")}});var Dt=Object.freeze({__proto__:null,XElement:Lt});let At=null;const Rt=new WeakMap;class Bt extends Lt{visible;shadowRootInternal;defaultFocusedElement;elementsToRestoreScrollPositionsFor;onShownCallback;onHiddenCallback;onResizedCallback;constructor(){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction","column"),this.style.setProperty("align-items","stretch"),this.style.setProperty("justify-content","flex-start"),this.style.setProperty("contain","layout style"),this.visible=!1,this.defaultFocusedElement=null,this.elementsToRestoreScrollPositionsFor=[],At||(At=new ResizeObserver((e=>{for(const t of e){const e=t.target;e.visible&&e.onResizedCallback&&e.onResizedCallback.call(null)}}))),At.observe(this),this.setElementsToRestoreScrollPositionsFor([this])}isShowing(){return this.visible}setOnShown(e){this.onShownCallback=e}setOnHidden(e){this.onHiddenCallback=e}setOnResized(e){this.onResizedCallback=e}setElementsToRestoreScrollPositionsFor(e){for(const e of this.elementsToRestoreScrollPositionsFor)e.removeEventListener("scroll",Bt.storeScrollPosition,{capture:!1});this.elementsToRestoreScrollPositionsFor=e;for(const e of this.elementsToRestoreScrollPositionsFor)e.addEventListener("scroll",Bt.storeScrollPosition,{passive:!0,capture:!1})}restoreScrollPositions(){for(const e of this.elementsToRestoreScrollPositionsFor){const t=Rt.get(e);t&&(e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft)}}static storeScrollPosition(e){const t=e.currentTarget;Rt.set(t,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop})}setDefaultFocusedElement(e){if(e&&!this.isSelfOrAncestor(e))throw new Error("Default focus must be descendant");this.defaultFocusedElement=e}focus(){if(!this.visible)return;let e;if(this.defaultFocusedElement&&this.isSelfOrAncestor(this.defaultFocusedElement))e=this.defaultFocusedElement;else if(-1!==this.tabIndex)e=this;else{let t=this.traverseNextNode(this);for(;t;){if(t instanceof Bt&&t.visible){e=t;break}t=t.traverseNextNode(this)}}e&&!e.hasFocus()&&(e===this?HTMLElement.prototype.focus.call(this):e.focus())}connectedCallback(){this.visible=!0,this.restoreScrollPositions(),this.onShownCallback&&this.onShownCallback.call(null)}disconnectedCallback(){this.visible=!1,this.onHiddenCallback&&this.onHiddenCallback.call(null)}}customElements.define("x-widget",Bt);var Ot=Object.freeze({__proto__:null,XWidget:Bt});class Ft extends HTMLDivElement{__widget;__widgetCounter;constructor(){super()}}function zt(e,t){if(!e)throw new Error(t)}class Wt{element;contentElement;shadowRoot;isWebComponent;visibleInternal;isRoot;isShowingInternal;childrenInternal;hideOnDetach;notificationDepth;invalidationsSuspended;defaultFocusedChild;parentWidgetInternal;registeredCSSFiles;defaultFocusedElement;cachedConstraints;constraintsInternal;invalidationsRequested;externallyManaged;constructor(e,t){this.contentElement=document.createElement("div"),this.contentElement.classList.add("widget"),e?(this.element=document.createElement("div"),this.element.classList.add("vbox"),this.element.classList.add("flex-auto"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:void 0,delegatesFocus:t}),this.shadowRoot.appendChild(this.contentElement)):this.element=this.contentElement,this.isWebComponent=e,this.element.__widget=this,this.visibleInternal=!1,this.isRoot=!1,this.isShowingInternal=!1,this.childrenInternal=[],this.hideOnDetach=!1,this.notificationDepth=0,this.invalidationsSuspended=0,this.defaultFocusedChild=null,this.parentWidgetInternal=null,this.registeredCSSFiles=!1}static incrementWidgetCounter(e,t){const i=(t.__widgetCounter||0)+(t.__widget?1:0);if(!i)return;let n=e;for(;n;)n.__widgetCounter=(n.__widgetCounter||0)+i,n=Vt(n)}static decrementWidgetCounter(e,t){const i=(t.__widgetCounter||0)+(t.__widget?1:0);if(!i)return;let n=e;for(;n;)n.__widgetCounter&&(n.__widgetCounter-=i),n=Vt(n)}markAsRoot(){zt(!this.element.parentElement,"Attempt to mark as root attached node"),this.isRoot=!0}parentWidget(){return this.parentWidgetInternal}children(){return this.childrenInternal}childWasDetached(e){}isShowing(){return this.isShowingInternal}shouldHideOnDetach(){if(!this.element.parentElement)return!1;if(this.hideOnDetach)return!0;for(const e of this.childrenInternal)if(e.shouldHideOnDetach())return!0;return!1}setHideOnDetach(){this.hideOnDetach=!0}inNotification(){return Boolean(this.notificationDepth)||Boolean(this.parentWidgetInternal&&this.parentWidgetInternal.inNotification())}parentIsShowing(){return!!this.isRoot||null!==this.parentWidgetInternal&&this.parentWidgetInternal.isShowing()}callOnVisibleChildren(e){const t=this.childrenInternal.slice();for(let i=0;i<t.length;++i)t[i].parentWidgetInternal===this&&t[i].visibleInternal&&e.call(t[i])}processWillShow(){this.callOnVisibleChildren(this.processWillShow),this.isShowingInternal=!0}processWasShown(){this.inNotification()||(this.restoreScrollPositions(),this.notify(this.wasShown),this.callOnVisibleChildren(this.processWasShown))}processWillHide(){this.inNotification()||(this.storeScrollPositions(),this.callOnVisibleChildren(this.processWillHide),this.notify(this.willHide),this.isShowingInternal=!1)}processWasHidden(){this.callOnVisibleChildren(this.processWasHidden)}processOnResize(){this.inNotification()||this.isShowing()&&(this.notify(this.onResize),this.callOnVisibleChildren(this.processOnResize))}notify(e){++this.notificationDepth;try{e.call(this)}finally{--this.notificationDepth}}wasShown(){}willHide(){}onResize(){}onLayout(){}onDetach(){}async ownerViewDisposed(){}show(e,t){if(zt(e,"Attempt to attach widget with no parent element"),!this.isRoot){let t=e;for(;t&&!t.__widget;)t=Vt(t);if(!t||!t.__widget)throw new Error("Attempt to attach widget to orphan node");this.attach(t.__widget)}this.showWidgetInternal(e,t)}attach(e){e!==this.parentWidgetInternal&&(this.parentWidgetInternal&&this.detach(),this.parentWidgetInternal=e,this.parentWidgetInternal.childrenInternal.push(this),this.isRoot=!1)}showWidget(){if(!this.visibleInternal){if(!this.element.parentElement)throw new Error("Attempt to show widget that is not hidden using hideWidget().");this.showWidgetInternal(this.element.parentElement,this.element.nextSibling)}}showWidgetInternal(e,t){let i=e;for(;i&&!i.__widget;)i=Vt(i);this.isRoot?zt(!i,"Attempt to show root widget under another widget"):zt(i&&i.__widget===this.parentWidgetInternal,"Attempt to show under node belonging to alien widget");const n=this.visibleInternal;n&&this.element.parentElement===e||(this.visibleInternal=!0,!n&&this.parentIsShowing()&&this.processWillShow(),this.element.classList.remove("hidden"),this.element.parentElement!==e&&(this.externallyManaged||Wt.incrementWidgetCounter(e,this.element),t?c.DOMExtension.originalInsertBefore.call(e,this.element,t):c.DOMExtension.originalAppendChild.call(e,this.element)),!n&&this.parentIsShowing()&&this.processWasShown(),this.parentWidgetInternal&&this.hasNonZeroConstraints()?this.parentWidgetInternal.invalidateConstraints():this.processOnResize())}hideWidget(){this.visibleInternal&&this.hideWidgetInternal(!1)}hideWidgetInternal(e){this.visibleInternal=!1;const t=this.element.parentElement;this.parentIsShowing()&&this.processWillHide(),e?(Wt.decrementWidgetCounter(t,this.element),c.DOMExtension.originalRemoveChild.call(t,this.element),this.onDetach()):this.element.classList.add("hidden"),this.parentIsShowing()&&this.processWasHidden(),this.parentWidgetInternal&&this.hasNonZeroConstraints()&&this.parentWidgetInternal.invalidateConstraints()}detach(e){if(!this.parentWidgetInternal&&!this.isRoot)return;const t=e||!this.shouldHideOnDetach();if(this.visibleInternal)this.hideWidgetInternal(t);else if(t&&this.element.parentElement){const e=this.element.parentElement;Wt.decrementWidgetCounter(e,this.element),c.DOMExtension.originalRemoveChild.call(e,this.element)}if(this.parentWidgetInternal){const e=this.parentWidgetInternal.childrenInternal.indexOf(this);zt(e>=0,"Attempt to remove non-child widget"),this.parentWidgetInternal.childrenInternal.splice(e,1),this.parentWidgetInternal.defaultFocusedChild===this&&(this.parentWidgetInternal.defaultFocusedChild=null),this.parentWidgetInternal.childWasDetached(this),this.parentWidgetInternal=null}else zt(this.isRoot,"Removing non-root widget from DOM")}detachChildWidgets(){const e=this.childrenInternal.slice();for(let t=0;t<e.length;++t)e[t].detach()}elementsToRestoreScrollPositionsFor(){return[this.element]}storeScrollPositions(){const e=this.elementsToRestoreScrollPositionsFor();for(const t of e)Ht.set(t,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop})}restoreScrollPositions(){const e=this.elementsToRestoreScrollPositionsFor();for(const t of e){const e=Ht.get(t);e&&(t.scrollLeft=e.scrollLeft,t.scrollTop=e.scrollTop)}}doResize(){this.isShowing()&&(this.inNotification()||this.callOnVisibleChildren(this.processOnResize))}doLayout(){this.isShowing()&&(this.notify(this.onLayout),this.doResize())}registerRequiredCSS(e){this.isWebComponent?m.ThemeSupport.instance().appendStyle(this.shadowRoot,e):m.ThemeSupport.instance().appendStyle(this.element,e)}registerCSSFiles(e){let t;t=this.isWebComponent&&void 0!==this.shadowRoot?this.shadowRoot:u.GetRootNode.getRootNode(this.contentElement),t.adoptedStyleSheets=t.adoptedStyleSheets.concat(e),this.registeredCSSFiles=!0}printWidgetHierarchy(){const e=[];this.collectWidgetHierarchy("",e),console.log(e.join("\n"))}collectWidgetHierarchy(e,t){t.push(e+"["+this.element.className+"]"+(this.childrenInternal.length?" {":""));for(let i=0;i<this.childrenInternal.length;++i)this.childrenInternal[i].collectWidgetHierarchy(e+" ",t);this.childrenInternal.length&&t.push(e+"}")}setDefaultFocusedElement(e){this.defaultFocusedElement=e}setDefaultFocusedChild(e){zt(e.parentWidgetInternal===this,"Attempt to set non-child widget as default focused."),this.defaultFocusedChild=e}focus(){if(!this.isShowing())return;const e=this.defaultFocusedElement;if(e)e.hasFocus()||e.focus();else if(this.defaultFocusedChild&&this.defaultFocusedChild.visibleInternal)this.defaultFocusedChild.focus();else{for(const e of this.childrenInternal)if(e.visibleInternal)return void e.focus();let e=this.contentElement.traverseNextNode(this.contentElement);for(;e;){if(e instanceof Bt)return void e.focus();e=e.traverseNextNode(this.contentElement)}}}hasFocus(){return this.element.hasFocus()}calculateConstraints(){return new je}constraints(){return void 0!==this.constraintsInternal?this.constraintsInternal:(void 0===this.cachedConstraints&&(this.cachedConstraints=this.calculateConstraints()),this.cachedConstraints)}setMinimumAndPreferredSizes(e,t,i,n){this.constraintsInternal=new je(new _e(e,t),new _e(i,n)),this.invalidateConstraints()}setMinimumSize(e,t){this.constraintsInternal=new je(new _e(e,t)),this.invalidateConstraints()}hasNonZeroConstraints(){const e=this.constraints();return Boolean(e.minimum.width||e.minimum.height||e.preferred.width||e.preferred.height)}suspendInvalidations(){++this.invalidationsSuspended}resumeInvalidations(){--this.invalidationsSuspended,!this.invalidationsSuspended&&this.invalidationsRequested&&this.invalidateConstraints()}invalidateConstraints(){if(this.invalidationsSuspended)return void(this.invalidationsRequested=!0);this.invalidationsRequested=!1;const e=this.cachedConstraints;delete this.cachedConstraints;!this.constraints().isEqual(e||null)&&this.parentWidgetInternal?this.parentWidgetInternal.invalidateConstraints():this.doLayout()}markAsExternallyManaged(){zt(!this.parentWidgetInternal,"Attempt to mark widget as externally managed after insertion to the DOM"),this.externallyManaged=!0}}const Ht=new WeakMap;class Nt extends Wt{constructor(e,t){super(e,t),this.contentElement.classList.add("vbox")}calculateConstraints(){let e=new je;return this.callOnVisibleChildren((function(){const t=this.constraints();e=e.widthToMax(t),e=e.addHeight(t)})),e}}class _t extends Wt{constructor(e){super(e),this.contentElement.classList.add("hbox")}calculateConstraints(){let e=new je;return this.callOnVisibleChildren((function(){const t=this.constraints();e=e.addWidth(t),e=e.heightToMax(t)})),e}}class jt{widget;previous;constructor(e){this.widget=e,this.previous=i.DOMUtilities.deepActiveElement(e.element.ownerDocument),e.focus()}restore(){this.widget&&(this.widget.hasFocus()&&this.previous&&this.previous.focus(),this.previous=null,this.widget=null)}}function Vt(e){return e.parentElementOrShadowHost()}var Ut=Object.freeze({__proto__:null,WidgetElement:Ft,Widget:Wt,VBox:Nt,HBox:_t,VBoxWithResizeCallback:class extends Nt{resizeCallback;constructor(e){super(),this.resizeCallback=e}onResize(){this.resizeCallback()}},WidgetFocusRestorer:jt});let Kt;class qt extends e.ObjectWrapper.ObjectWrapper{frontendHost;zoomFactorInternal;constructor(e,t){super(),this.frontendHost=t,this.zoomFactorInternal=this.frontendHost.zoomFactor(),e.addEventListener("resize",this.onWindowResize.bind(this),!0)}static instance(e={forceNew:null,win:null,frontendHost:null}){const{forceNew:t,win:i,frontendHost:n}=e;if(!Kt||t){if(!i||!n)throw new Error(`Unable to create zoom manager: window and frontendHost must be provided: ${(new Error).stack}`);Kt=new qt(i,n)}return Kt}static removeInstance(){Kt=void 0}zoomFactor(){return this.zoomFactorInternal}cssToDIP(e){return e*this.zoomFactorInternal}dipToCSS(e){return e/this.zoomFactorInternal}onWindowResize(){const e=this.zoomFactorInternal;this.zoomFactorInternal=this.frontendHost.zoomFactor(),e!==this.zoomFactorInternal&&this.dispatchEventToListeners("ZoomChanged",{from:e,to:this.zoomFactorInternal})}}var $t=Object.freeze({__proto__:null,ZoomManager:qt});class Gt extends(e.ObjectWrapper.eventMixin(Wt)){sidebarElementInternal;mainElement;resizerElementInternal;resizerElementSize;resizerWidget;defaultSidebarWidth;defaultSidebarHeight;constraintsInDip;resizeStartSizeDIP;setting;totalSizeCSS;totalSizeOtherDimensionCSS;mainWidgetInternal;sidebarWidgetInternal;animationFrameHandle;animationCallback;showSidebarButtonTitle;hideSidebarButtonTitle;shownSidebarString;hiddenSidebarString;showHideSidebarButton;isVerticalInternal;sidebarMinimized;detaching;sidebarSizeDIP;savedSidebarSizeDIP;secondIsSidebar;shouldSaveShowMode;savedVerticalMainSize;savedHorizontalMainSize;showModeInternal;savedShowMode;constructor(t,i,n,s,o,r){super(!0),this.element.classList.add("split-widget"),this.registerRequiredCSS(Mt),this.contentElement.classList.add("shadow-split-widget"),this.sidebarElementInternal=this.contentElement.createChild("div","shadow-split-widget-contents shadow-split-widget-sidebar vbox"),this.mainElement=this.contentElement.createChild("div","shadow-split-widget-contents shadow-split-widget-main vbox"),this.mainElement.createChild("slot").name="insertion-point-main",this.sidebarElementInternal.createChild("slot").name="insertion-point-sidebar",this.resizerElementInternal=this.contentElement.createChild("div","shadow-split-widget-resizer"),this.resizerElementSize=null,this.resizerWidget=new Tt,this.resizerWidget.setEnabled(!0),this.resizerWidget.addEventListener("ResizeStart",this.onResizeStart,this),this.resizerWidget.addEventListener("ResizeUpdatePosition",this.onResizeUpdate,this),this.resizerWidget.addEventListener("ResizeEnd",this.onResizeEnd,this),this.defaultSidebarWidth=s||200,this.defaultSidebarHeight=o||this.defaultSidebarWidth,this.constraintsInDip=Boolean(r),this.resizeStartSizeDIP=0,this.setting=n?e.Settings.Settings.instance().createSetting(n,{}):null,this.totalSizeCSS=0,this.totalSizeOtherDimensionCSS=0,this.mainWidgetInternal=null,this.sidebarWidgetInternal=null,this.animationFrameHandle=0,this.animationCallback=null,this.showSidebarButtonTitle=e.UIString.LocalizedEmptyString,this.hideSidebarButtonTitle=e.UIString.LocalizedEmptyString,this.shownSidebarString=e.UIString.LocalizedEmptyString,this.hiddenSidebarString=e.UIString.LocalizedEmptyString,this.showHideSidebarButton=null,this.isVerticalInternal=!1,this.sidebarMinimized=!1,this.detaching=!1,this.sidebarSizeDIP=-1,this.savedSidebarSizeDIP=this.sidebarSizeDIP,this.secondIsSidebar=!1,this.shouldSaveShowMode=!1,this.savedVerticalMainSize=null,this.savedHorizontalMainSize=null,this.setSecondIsSidebar(i),this.innerSetVertical(t),this.showModeInternal="Both",this.savedShowMode=this.showModeInternal,this.installResizer(this.resizerElementInternal)}isVertical(){return this.isVerticalInternal}setVertical(e){this.isVerticalInternal!==e&&(this.innerSetVertical(e),this.isShowing()&&this.updateLayout())}innerSetVertical(e){this.contentElement.classList.toggle("vbox",!e),this.contentElement.classList.toggle("hbox",e),this.isVerticalInternal=e,this.resizerElementSize=null,this.sidebarSizeDIP=-1,this.restoreSidebarSizeFromSettings(),this.shouldSaveShowMode&&this.restoreAndApplyShowModeFromSettings(),this.updateShowHideSidebarButton(),this.resizerWidget.setVertical(!e),this.invalidateConstraints()}updateLayout(e){this.totalSizeCSS=0,this.totalSizeOtherDimensionCSS=0,this.mainElement.style.removeProperty("width"),this.mainElement.style.removeProperty("height"),this.sidebarElementInternal.style.removeProperty("width"),this.sidebarElementInternal.style.removeProperty("height"),this.innerSetSidebarSizeDIP(this.preferredSidebarSizeDIP(),Boolean(e))}setMainWidget(e){this.mainWidgetInternal!==e&&(this.suspendInvalidations(),this.mainWidgetInternal&&this.mainWidgetInternal.detach(),this.mainWidgetInternal=e,e&&(e.element.slot="insertion-point-main","OnlyMain"!==this.showModeInternal&&"Both"!==this.showModeInternal||e.show(this.element)),this.resumeInvalidations())}setSidebarWidget(e){this.sidebarWidgetInternal!==e&&(this.suspendInvalidations(),this.sidebarWidgetInternal&&this.sidebarWidgetInternal.detach(),this.sidebarWidgetInternal=e,e&&(e.element.slot="insertion-point-sidebar","OnlySidebar"!==this.showModeInternal&&"Both"!==this.showModeInternal||e.show(this.element)),this.resumeInvalidations())}mainWidget(){return this.mainWidgetInternal}sidebarWidget(){return this.sidebarWidgetInternal}sidebarElement(){return this.sidebarElementInternal}childWasDetached(e){this.detaching||(this.mainWidgetInternal===e&&(this.mainWidgetInternal=null),this.sidebarWidgetInternal===e&&(this.sidebarWidgetInternal=null),this.invalidateConstraints())}isSidebarSecond(){return this.secondIsSidebar}enableShowModeSaving(){this.shouldSaveShowMode=!0,this.restoreAndApplyShowModeFromSettings()}showMode(){return this.showModeInternal}setSecondIsSidebar(e){e!==this.secondIsSidebar&&(this.secondIsSidebar=e,this.mainWidgetInternal&&this.mainWidgetInternal.shouldHideOnDetach()?this.sidebarWidgetInternal&&this.sidebarWidgetInternal.shouldHideOnDetach()?(console.error("Could not swap split widget side. Both children widgets contain iframes."),this.secondIsSidebar=!e):e?this.contentElement.insertBefore(this.sidebarElementInternal,this.resizerElementInternal):this.contentElement.insertBefore(this.sidebarElementInternal,this.mainElement):e?this.contentElement.insertBefore(this.mainElement,this.sidebarElementInternal):this.contentElement.insertBefore(this.mainElement,this.resizerElementInternal))}sidebarSide(){return"Both"!==this.showModeInternal?null:this.isVerticalInternal?this.secondIsSidebar?"right":"left":this.secondIsSidebar?"bottom":"top"}resizerElement(){return this.resizerElementInternal}hideMain(e){this.showOnly(this.sidebarWidgetInternal,this.mainWidgetInternal,this.sidebarElementInternal,this.mainElement,e),this.updateShowMode("OnlySidebar")}hideSidebar(e){this.showOnly(this.mainWidgetInternal,this.sidebarWidgetInternal,this.mainElement,this.sidebarElementInternal,e),this.updateShowMode("OnlyMain")}setSidebarMinimized(e){this.sidebarMinimized=e,this.invalidateConstraints()}isSidebarMinimized(){return this.sidebarMinimized}showOnly(e,t,i,n,s){function o(){e&&(e===this.mainWidgetInternal?this.mainWidgetInternal.show(this.element,this.sidebarWidgetInternal?this.sidebarWidgetInternal.element:null):this.sidebarWidgetInternal&&this.sidebarWidgetInternal.show(this.element)),t&&(this.detaching=!0,t.detach(),this.detaching=!1),this.resizerElementInternal.classList.add("hidden"),i.classList.remove("hidden"),i.classList.add("maximized"),n.classList.add("hidden"),n.classList.remove("maximized"),this.removeAllLayoutProperties(),this.doResize(),this.showFinishedForTest()}this.cancelAnimation(),s?this.animate(!0,o.bind(this)):o.call(this),this.sidebarSizeDIP=-1,this.setResizable(!1)}showFinishedForTest(){}removeAllLayoutProperties(){this.sidebarElementInternal.style.removeProperty("flexBasis"),this.mainElement.style.removeProperty("width"),this.mainElement.style.removeProperty("height"),this.sidebarElementInternal.style.removeProperty("width"),this.sidebarElementInternal.style.removeProperty("height"),this.resizerElementInternal.style.removeProperty("left"),this.resizerElementInternal.style.removeProperty("right"),this.resizerElementInternal.style.removeProperty("top"),this.resizerElementInternal.style.removeProperty("bottom"),this.resizerElementInternal.style.removeProperty("margin-left"),this.resizerElementInternal.style.removeProperty("margin-right"),this.resizerElementInternal.style.removeProperty("margin-top"),this.resizerElementInternal.style.removeProperty("margin-bottom")}showBoth(e){"Both"===this.showModeInternal&&(e=!1),this.cancelAnimation(),this.mainElement.classList.remove("maximized","hidden"),this.sidebarElementInternal.classList.remove("maximized","hidden"),this.resizerElementInternal.classList.remove("hidden"),this.setResizable(!0),this.suspendInvalidations(),this.sidebarWidgetInternal&&this.sidebarWidgetInternal.show(this.element),this.mainWidgetInternal&&this.mainWidgetInternal.show(this.element,this.sidebarWidgetInternal?this.sidebarWidgetInternal.element:null),this.resumeInvalidations(),this.setSecondIsSidebar(this.secondIsSidebar),this.sidebarSizeDIP=-1,this.updateShowMode("Both"),this.updateLayout(e)}setResizable(e){this.resizerWidget.setEnabled(e)}isResizable(){return this.resizerWidget.isEnabled()}setSidebarSize(e){const t=qt.instance().cssToDIP(e);this.savedSidebarSizeDIP=t,this.saveSetting(),this.innerSetSidebarSizeDIP(t,!1,!0)}sidebarSize(){const e=Math.max(0,this.sidebarSizeDIP);return qt.instance().dipToCSS(e)}totalSizeDIP(){return this.totalSizeCSS||(this.totalSizeCSS=this.isVerticalInternal?this.contentElement.offsetWidth:this.contentElement.offsetHeight,this.totalSizeOtherDimensionCSS=this.isVerticalInternal?this.contentElement.offsetHeight:this.contentElement.offsetWidth),qt.instance().cssToDIP(this.totalSizeCSS)}updateShowMode(e){this.showModeInternal=e,this.saveShowModeToSettings(),this.updateShowHideSidebarButton(),this.dispatchEventToListeners("ShowModeChanged",e),this.invalidateConstraints()}innerSetSidebarSizeDIP(e,t,i){if("Both"!==this.showModeInternal||!this.isShowing())return;if(e=this.applyConstraints(e,i),this.sidebarSizeDIP===e)return;this.resizerElementSize||(this.resizerElementSize=this.isVerticalInternal?this.resizerElementInternal.offsetWidth:this.resizerElementInternal.offsetHeight),this.removeAllLayoutProperties();const n=Math.round(qt.instance().dipToCSS(e)),s=n+"px",o=this.totalSizeCSS-n+"px";this.sidebarElementInternal.style.flexBasis=s,this.isVerticalInternal?(this.sidebarElementInternal.style.width=s,this.mainElement.style.width=o,this.sidebarElementInternal.style.height=this.totalSizeOtherDimensionCSS+"px",this.mainElement.style.height=this.totalSizeOtherDimensionCSS+"px"):(this.sidebarElementInternal.style.height=s,this.mainElement.style.height=o,this.sidebarElementInternal.style.width=this.totalSizeOtherDimensionCSS+"px",this.mainElement.style.width=this.totalSizeOtherDimensionCSS+"px"),this.isVerticalInternal?this.secondIsSidebar?(this.resizerElementInternal.style.right=s,this.resizerElementInternal.style.marginRight=-this.resizerElementSize/2+"px"):(this.resizerElementInternal.style.left=s,this.resizerElementInternal.style.marginLeft=-this.resizerElementSize/2+"px"):this.secondIsSidebar?(this.resizerElementInternal.style.bottom=s,this.resizerElementInternal.style.marginBottom=-this.resizerElementSize/2+"px"):(this.resizerElementInternal.style.top=s,this.resizerElementInternal.style.marginTop=-this.resizerElementSize/2+"px"),this.sidebarSizeDIP=e,t?this.animate(!1):(this.doResize(),this.dispatchEventToListeners("SidebarSizeChanged",this.sidebarSize()))}animate(e,t){let i;this.animationCallback=t||null,i=this.isVerticalInternal?this.secondIsSidebar?"margin-right":"margin-left":this.secondIsSidebar?"margin-bottom":"margin-top";const n=e?"0":"-"+qt.instance().dipToCSS(this.sidebarSizeDIP)+"px",s=e?"-"+qt.instance().dipToCSS(this.sidebarSizeDIP)+"px":"0";this.contentElement.style.setProperty(i,n),this.contentElement.style.setProperty("overflow","hidden"),e||(Yt(this.mainElement.offsetWidth),Yt(this.sidebarElementInternal.offsetWidth)),!e&&this.sidebarWidgetInternal&&this.sidebarWidgetInternal.doResize(),this.contentElement.style.setProperty("transition",i+" 50ms linear");const o=function(){if(this.animationFrameHandle=0,r){if(!(window.performance.now()<r+50))return this.cancelAnimation(),this.mainWidgetInternal&&this.mainWidgetInternal.doResize(),void this.dispatchEventToListeners("SidebarSizeChanged",this.sidebarSize());this.mainWidgetInternal&&this.mainWidgetInternal.doResize()}else this.contentElement.style.setProperty(i,s),r=window.performance.now();this.animationFrameHandle=this.contentElement.window().requestAnimationFrame(o)}.bind(this);let r=null;this.animationFrameHandle=this.contentElement.window().requestAnimationFrame(o)}cancelAnimation(){this.contentElement.style.removeProperty("margin-top"),this.contentElement.style.removeProperty("margin-right"),this.contentElement.style.removeProperty("margin-bottom"),this.contentElement.style.removeProperty("margin-left"),this.contentElement.style.removeProperty("transition"),this.contentElement.style.removeProperty("overflow"),this.animationFrameHandle&&(this.contentElement.window().cancelAnimationFrame(this.animationFrameHandle),this.animationFrameHandle=0),this.animationCallback&&(this.animationCallback(),this.animationCallback=null)}applyConstraints(e,t){const n=this.totalSizeDIP(),s=this.constraintsInDip?1:qt.instance().zoomFactor();let o=this.sidebarWidgetInternal?this.sidebarWidgetInternal.constraints():new je,r=this.isVertical()?o.minimum.width:o.minimum.height;r||(r=Xt),r*=s,this.sidebarMinimized&&(e=r);let a=this.isVertical()?o.preferred.width:o.preferred.height;a||(a=Xt),a*=s,e<a&&(a=Math.max(e,r)),a+=s,o=this.mainWidgetInternal?this.mainWidgetInternal.constraints():new je;let l=this.isVertical()?o.minimum.width:o.minimum.height;l||(l=Xt),l*=s;let h=this.isVertical()?o.preferred.width:o.preferred.height;h||(h=Xt),h*=s;const d=this.isVertical()?this.savedVerticalMainSize:this.savedHorizontalMainSize;null!==d&&(h=Math.min(h,d*s)),t&&(h=l);const c=h+a;if(c<=n)return i.NumberUtilities.clamp(e,a,n-h);if(l+r<=n){return e=a-(c-n)*a/c,i.NumberUtilities.clamp(e,r,n-l)}return Math.max(0,n-l)}wasShown(){this.forceUpdateLayout(),qt.instance().addEventListener("ZoomChanged",this.onZoomChanged,this)}willHide(){qt.instance().removeEventListener("ZoomChanged",this.onZoomChanged,this)}onResize(){this.updateLayout()}onLayout(){this.updateLayout()}calculateConstraints(){if("OnlyMain"===this.showModeInternal)return this.mainWidgetInternal?this.mainWidgetInternal.constraints():new je;if("OnlySidebar"===this.showModeInternal)return this.sidebarWidgetInternal?this.sidebarWidgetInternal.constraints():new je;let e=this.mainWidgetInternal?this.mainWidgetInternal.constraints():new je,t=this.sidebarWidgetInternal?this.sidebarWidgetInternal.constraints():new je;const i=Xt;return this.isVerticalInternal?(e=e.widthToMax(i).addWidth(1),t=t.widthToMax(i),e.addWidth(t).heightToMax(t)):(e=e.heightToMax(i).addHeight(1),t=t.heightToMax(i),e.widthToMax(t).addHeight(t))}onResizeStart(){this.resizeStartSizeDIP=this.sidebarSizeDIP}onResizeUpdate(e){const t=e.data.currentPosition-e.data.startPosition,i=qt.instance().cssToDIP(t),n=this.secondIsSidebar?this.resizeStartSizeDIP-i:this.resizeStartSizeDIP+i,s=this.applyConstraints(n,!0);this.savedSidebarSizeDIP=s,this.saveSetting(),this.innerSetSidebarSizeDIP(s,!1,!0),this.isVertical()?this.savedVerticalMainSize=this.totalSizeDIP()-this.sidebarSizeDIP:this.savedHorizontalMainSize=this.totalSizeDIP()-this.sidebarSizeDIP}onResizeEnd(){this.resizeStartSizeDIP=0}hideDefaultResizer(e){this.resizerElementInternal.classList.toggle("hidden",Boolean(e)),this.uninstallResizer(this.resizerElementInternal),this.sidebarElementInternal.classList.toggle("no-default-splitter",Boolean(e))}installResizer(e){this.resizerWidget.addElement(e)}uninstallResizer(e){this.resizerWidget.removeElement(e)}hasCustomResizer(){const e=this.resizerWidget.elements();return e.length>1||1===e.length&&e[0]!==this.resizerElementInternal}toggleResizer(e,t){t?this.installResizer(e):this.uninstallResizer(e)}settingForOrientation(){const e=this.setting?this.setting.get():{};return this.isVerticalInternal?e.vertical:e.horizontal}preferredSidebarSizeDIP(){let e=this.savedSidebarSizeDIP;return e||(e=this.isVerticalInternal?this.defaultSidebarWidth:this.defaultSidebarHeight,0<e&&e<1&&(e*=this.totalSizeDIP())),e}restoreSidebarSizeFromSettings(){const e=this.settingForOrientation();this.savedSidebarSizeDIP=e?e.size:0}restoreAndApplyShowModeFromSettings(){const e=this.settingForOrientation();switch(this.savedShowMode=e&&e.showMode?e.showMode:this.showModeInternal,this.showModeInternal=this.savedShowMode,this.savedShowMode){case"Both":this.showBoth();break;case"OnlyMain":this.hideSidebar();break;case"OnlySidebar":this.hideMain()}}saveShowModeToSettings(){this.savedShowMode=this.showModeInternal,this.saveSetting()}saveSetting(){if(!this.setting)return;const e=this.setting.get(),t=(this.isVerticalInternal?e.vertical:e.horizontal)||{};t.size=this.savedSidebarSizeDIP,this.shouldSaveShowMode&&(t.showMode=this.savedShowMode),this.isVerticalInternal?e.vertical=t:e.horizontal=t,this.setting.set(e)}forceUpdateLayout(){this.sidebarSizeDIP=-1,this.updateLayout()}onZoomChanged(){this.forceUpdateLayout()}createShowHideSidebarButton(e,t,i,n,s){return this.showSidebarButtonTitle=e,this.hideSidebarButtonTitle=t,this.shownSidebarString=i,this.hiddenSidebarString=n,this.showHideSidebarButton=new wn("",""),this.showHideSidebarButton.addEventListener("Click",(function(){this.toggleSidebar()}),this),s&&this.showHideSidebarButton.element.setAttribute("jslog",`${o.toggleSubpane().track({click:!0}).context(s)}`),this.updateShowHideSidebarButton(),this.showHideSidebarButton}toggleSidebar(){"Both"!==this.showModeInternal?(this.showBoth(!0),Se(this.shownSidebarString)):(this.hideSidebar(!0),Se(this.hiddenSidebarString))}updateShowHideSidebarButton(){if(!this.showHideSidebarButton)return;const e="OnlyMain"===this.showModeInternal;let t="";t=e?this.isVertical()?this.isSidebarSecond()?"right-panel-open":"left-panel-open":this.isSidebarSecond()?"bottom-panel-open":"top-panel-open":this.isVertical()?this.isSidebarSecond()?"right-panel-close":"left-panel-close":this.isSidebarSecond()?"bottom-panel-close":"top-panel-close",this.showHideSidebarButton.setGlyph(t),this.showHideSidebarButton.setTitle(e?this.showSidebarButtonTitle:this.hideSidebarButtonTitle)}}const Xt=20,Yt=function(e){};var Qt=Object.freeze({__proto__:null,SplitWidget:Gt}),Zt={cssContent:".tabbed-pane{flex:auto;overflow:hidden}.tabbed-pane-content{position:relative;overflow:auto;flex:auto;display:flex;flex-direction:column}.tabbed-pane-content.has-no-tabs{background-color:var(--sys-color-cdt-base-container)}.tabbed-pane-placeholder{font-size:14px;text-align:center;width:fit-content;margin:40px auto 0;text-shadow:var(--color-background-opacity-80) 0 1px 0;line-height:28px}.tabbed-pane-placeholder-row{margin-inline:10px;& span{display:inline-block;padding-inline:10px}&:has(.workspace){max-width:400px;border:2px dashed var(--sys-color-neutral-outline);margin-block-start:20px;padding:10px;margin-inline:20px}& button{cursor:pointer;color:var(--text-link);background:transparent;border:none;padding:0;text-decoration:underline;margin-inline:5px;&:focus-visible{outline:2px solid var(--sys-color-state-focus-ring);outline-offset:2px;border-radius:2px}}}.tabbed-pane-header{display:flex;flex:0 0 27px;border-bottom:1px solid var(--sys-color-divider);overflow:visible;width:100%;background-color:var(--app-color-toolbar-background);& > *{cursor:initial}}.tabbed-pane-header-contents{flex:auto;pointer-events:none;margin-left:0;position:relative;cursor:default}.tabbed-pane-header-contents > *{pointer-events:initial}.tabbed-pane-header-tab-icon{min-width:14px;display:flex;align-items:center;margin-right:2px}.tabbed-pane-header-tab-icon devtools-icon{margin-left:-1px}.tabbed-pane-header-tab{float:left;padding:2px 0.8em;height:26px;line-height:16px;white-space:nowrap;cursor:default;display:flex;align-items:center;color:var(--ui-text)}.tabbed-pane-header-tab.closeable{padding-right:4px}.tabbed-pane-header-tab.preview.closeable{padding-right:5px}.tabbed-pane-header-tab devtools-icon.dot::before{outline-color:var(--icon-gap-toolbar)}.tabbed-pane-header-tab:hover devtools-icon.dot::before{outline-color:var(--icon-gap-toolbar-hover)}.tabbed-pane-header-tab:hover,\n.tabbed-pane-shadow .tabbed-pane-header-tab:focus-visible{color:var(--sys-color-on-surface);background-color:var(--sys-color-state-hover-on-subtle)}.tabbed-pane-header-tab-title{text-overflow:ellipsis;overflow:hidden}.tabbed-pane-header-tab.measuring{visibility:hidden}.tabbed-pane-header-tab.selected{border-bottom:none;color:var(--sys-color-primary)}.tabbed-pane-header-tab.dragging{--override-dragging-box-shadow-color:rgb(0 0 0/37%);position:relative;box-shadow:0 1px 4px 0 var(--override-dragging-box-shadow-color);background-color:var(--sys-color-state-hover-on-subtle)}.-theme-with-dark-background .tabbed-pane-header-tab.dragging,\n:host-context(.-theme-with-dark-background) .tabbed-pane-header-tab.dragging{--override-dragging-box-shadow-color:rgb(230 230 230/37%)}.tabbed-pane-header-tab .tabbed-pane-close-button{margin:0 -3px 0 4px;visibility:hidden}.tabbed-pane-header-tab:hover .tabbed-pane-close-button,\n.tabbed-pane-header-tab.selected .tabbed-pane-close-button{visibility:visible}.tabbed-pane-header-tabs-drop-down-container{float:left;opacity:80%;display:flex;align-items:center;height:100%}.tabbed-pane-header-tabs-drop-down-container > .chevron-icon:hover,\n.tabbed-pane-header-tabs-drop-down-container > .chevron-icon:focus-visible{color:var(--icon-default-hover)}.tabbed-pane-header-tabs-drop-down-container:hover,\n.tabbed-pane-header-tabs-drop-down-container:focus-visible{background-color:var(--sys-color-state-hover-on-subtle)}.tabbed-pane-header-tabs-drop-down-container.measuring{visibility:hidden}.tabbed-pane-header-tabs-drop-down-container:active{opacity:80%}.tabbed-pane-shadow.vertical-tab-layout{flex-direction:row!important}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header{background-color:transparent;border:none transparent!important;width:auto;flex:0 0 auto;flex-direction:column;padding-top:10px;padding-right:4px;overflow:hidden}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-content{padding:10px 10px 10px 4px;overflow-x:hidden}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-contents{margin:0;flex:none}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tabs{display:flex;flex-direction:column;width:120px}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tab{border:none transparent;font-weight:normal;text-shadow:none;color:var(--sys-color-token-subtle);height:26px;padding-left:10px;margin:0;display:flex;align-items:center}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tab.selected{color:inherit;border:none transparent;background-color:var(--sys-color-neutral-container)}.tabbed-pane-shadow.vertical-tab-layout .tabbed-pane-header-tab:focus{background-color:var(--sys-color-tonal-container);color:var(--sys-color-on-tonal-container)}.tabbed-pane-tab-slider{height:2px;position:absolute;bottom:-1px;background-color:var(--sys-color-primary-bright);left:0;transform-origin:0 100%;transition:transform 150ms cubic-bezier(0,0,0.2,1);visibility:hidden}@media (-webkit-min-device-pixel-ratio: 1.1){.tabbed-pane-tab-slider{border-top:none}}.tabbed-pane-tab-slider.enabled{visibility:visible}.tabbed-pane-header-tab.disabled{opacity:50%;pointer-events:none}.tabbed-pane-left-toolbar{margin-right:-4px;flex:none}.tabbed-pane-right-toolbar{margin-left:-4px;flex:none}.preview-icon{--override-tabbed-pane-preview-icon-color:var(--icon-default);width:16px;height:16px;display:flex;align-items:center;justify-content:center;margin-left:3px;flex-shrink:0}.close-button{--tabbed-pane-close-icon-color:var(--icon-default);width:16px;height:16px;display:flex;align-items:center;justify-content:center;border-radius:50%;background-color:transparent;border:none}.close-button:hover,\n.close-button:active,\n.close-button:focus{background-color:var(--sys-color-state-hover-on-subtle)}.tabbed-pane-header-tab.preview.closeable .close-button{margin-left:0}@media (forced-colors: active){.tabbed-pane-tab-slider{forced-color-adjust:none;background-color:Highlight}.tabbed-pane-header{forced-color-adjust:none;border-bottom:1px solid transparent;background-color:ButtonFace}.tabbed-pane-header-contents .tabbed-pane-header-tabs .tabbed-pane-header-tab{background:ButtonFace;color:ButtonText}.tabbed-pane-header-tabs .tabbed-pane-header-tab:hover,\n .tabbed-pane-header-tabs .tabbed-pane-shadow .tabbed-pane-header-tab:focus-visible{background-color:Highlight;color:HighlightText}.tabbed-pane-header-tab .tabbed-pane-header-tab-title{color:inherit}.tabbed-pane-header-contents .tabbed-pane-header-tabs .tabbed-pane-header-tab.selected,\n .tabbed-pane-header-contents .tabbed-pane-header-tabs .tabbed-pane-header-tab.selected:focus-visible{background-color:Highlight;color:HighlightText}.tabbed-pane-header-tab:hover .tabbed-pane-close-button,\n .tabbed-pane-shadow .tabbed-pane-header-tab:focus-visible .tabbed-pane-close-button{color:HighlightText}.tabbed-pane-header-tabs-drop-down-container{opacity:100%}.tabbed-pane-header-tabs-drop-down-container:hover,\n .tabbed-pane-header-tabs-drop-down-container:focus-visible{background-color:Highlight}.tabbed-pane-header-tabs-drop-down-container > .chevron-icon{color:ButtonText}.tabbed-pane-header-tabs-drop-down-container:hover > .chevron-icon,\n .tabbed-pane-header-tabs-drop-down-container:focus-visible > .chevron-icon{color:HighlightText}.tabbed-pane-header-tabs .tabbed-pane-header-tab .preview-icon{--override-tabbed-pane-preview-icon-color:ButtonText}.tabbed-pane-header-tab.selected .preview-icon,\n .tabbed-pane-header-tab:hover .preview-icon{--override-tabbed-pane-preview-icon-color:HighlightText}.close-button{--tabbed-pane-close-icon-color:ButtonText;forced-color-adjust:none}.close-button:hover,\n .close-button:active{--tabbed-pane-close-icon-color:HighlightText;background-color:Highlight}.selected .close-button{--tabbed-pane-close-icon-color:HighlightText}}"};class Jt{static install(e,t){e.title=t||""}static installWithActionBinding(e,t,i){let n=t;const s=Bs.instance().shortcutsForAction(i);for(const e of s)n+=` - ${e.title()}`;e.title=n}}var ei=Object.freeze({__proto__:null,Tooltip:Jt});const ti={moreTabs:"More tabs",closeS:"Close {PH1}",close:"Close",closeOthers:"Close others",closeTabsToTheRight:"Close tabs to the right",closeAll:"Close all",previewFeature:"Preview feature"},ii=t.i18n.registerUIStrings("ui/legacy/TabbedPane.ts",ti),ni=t.i18n.getLocalizedString.bind(void 0,ii);class si extends(e.ObjectWrapper.eventMixin(Nt)){headerElementInternal;headerContentsElement;tabSlider;tabsElement;contentElementInternal;tabs;tabsHistory;tabsById;currentTabLocked;autoSelectFirstItemOnShow;triggerDropDownTimeout;dropDownButton;currentDevicePixelRatio;shrinkableTabs;verticalTabLayout;closeableTabs;delegate;currentTab;sliderEnabled;placeholderElement;focusedPlaceholderElement;placeholderContainerElement;lastSelectedOverflowTab;overflowDisabled;measuredDropDownButtonWidth;leftToolbarInternal;rightToolbarInternal;allowTabReorder;automaticReorder;constructor(){super(!0),this.registerRequiredCSS(Zt),this.element.classList.add("tabbed-pane"),this.contentElement.classList.add("tabbed-pane-shadow"),this.contentElement.tabIndex=-1,this.setDefaultFocusedElement(this.contentElement),this.headerElementInternal=this.contentElement.createChild("div","tabbed-pane-header"),this.headerContentsElement=this.headerElementInternal.createChild("div","tabbed-pane-header-contents"),this.tabSlider=document.createElement("div"),this.tabSlider.classList.add("tabbed-pane-tab-slider"),this.tabsElement=this.headerContentsElement.createChild("div","tabbed-pane-header-tabs"),this.tabsElement.setAttribute("role","tablist"),this.tabsElement.addEventListener("keydown",this.keyDown.bind(this),!1),this.contentElementInternal=this.contentElement.createChild("div","tabbed-pane-content"),this.contentElementInternal.createChild("slot"),this.tabs=[],this.tabsHistory=[],this.tabsById=new Map,this.currentTabLocked=!1,this.autoSelectFirstItemOnShow=!0,this.triggerDropDownTimeout=null,this.dropDownButton=this.createDropDownButton(),this.currentDevicePixelRatio=window.devicePixelRatio,qt.instance().addEventListener("ZoomChanged",this.zoomChanged,this),this.makeTabSlider()}setAccessibleName(e){be(this.tabsElement,e)}setCurrentTabLocked(e){this.currentTabLocked=e,this.headerElementInternal.classList.toggle("locked",this.currentTabLocked)}setAutoSelectFirstItemOnShow(e){this.autoSelectFirstItemOnShow=e}get visibleView(){return this.currentTab?this.currentTab.view:null}tabIds(){return this.tabs.map((e=>e.id))}tabIndex(e){return this.tabs.findIndex((t=>t.id===e))}tabViews(){return this.tabs.map((e=>e.view))}tabView(e){const t=this.tabsById.get(e);return t?t.view:null}get selectedTabId(){return this.currentTab?this.currentTab.id:null}setShrinkableTabs(e){this.shrinkableTabs=e}makeVerticalTabLayout(){this.verticalTabLayout=!0,this.setTabSlider(!1),this.contentElement.classList.add("vertical-tab-layout"),this.invalidateConstraints()}setCloseableTabs(e){this.closeableTabs=e}focus(){this.visibleView?this.visibleView.focus():this.contentElement.focus()}focusSelectedTabHeader(){const e=this.currentTab;e&&e.tabElement.focus()}headerElement(){return this.headerElementInternal}tabbedPaneContentElement(){return this.contentElementInternal}isTabCloseable(e){const t=this.tabsById.get(e);return!!t&&t.isCloseable()}setTabDelegate(e){const t=this.tabs.slice();for(let i=0;i<t.length;++i)t[i].setDelegate(e);this.delegate=e}appendTab(e,t,i,n,s,r,a,l){const h="boolean"==typeof r?r:Boolean(this.closeableTabs),d=new ri(this,e,t,h,Boolean(a),i,n);d.setDelegate(this.delegate),console.assert(!this.tabsById.has(e),`Tabbed pane already contains a tab with id '${e}'`),this.tabsById.set(e,d),d.tabElement.tabIndex=-1;const c="console-view"===e?"console":e;d.tabElement.setAttribute("jslog",`${o.panelTabHeader().track({click:!0,drag:!0}).context(c)}`),void 0!==l?this.tabs.splice(l,0,d):this.tabs.push(d),this.tabsHistory.push(d),this.tabsHistory[0]===d&&this.isShowing()&&this.selectTab(d.id,s),this.updateTabElements()}closeTab(e,t){this.closeTabs([e],t)}closeTabs(e,t){if(0===e.length)return;const i=this.hasFocus();for(let i=0;i<e.length;++i)this.innerCloseTab(e[i],t);this.updateTabElements(),this.tabsHistory.length&&this.selectTab(this.tabsHistory[0].id,!1),i&&this.focus()}innerCloseTab(e,t){const i=this.tabsById.get(e);if(!i)return;if(t&&!i.closeable)return;this.currentTab&&this.currentTab.id===e&&this.hideCurrentTab(),this.tabsById.delete(e),this.tabsHistory.splice(this.tabsHistory.indexOf(i),1),this.tabs.splice(this.tabs.indexOf(i),1),i.shown&&this.hideTabElement(i);const n={prevTabId:void 0,tabId:e,view:i.view,isUserGesture:t};return this.dispatchEventToListeners(oi.TabClosed,n),!0}hasTab(e){return this.tabsById.has(e)}otherTabs(e){const t=[];for(let i=0;i<this.tabs.length;++i)this.tabs[i].id!==e&&t.push(this.tabs[i].id);return t}tabsToTheRight(e){let t=-1;for(let i=0;i<this.tabs.length;++i)if(this.tabs[i].id===e){t=i;break}return-1===t?[]:this.tabs.slice(t+1).map((function(e){return e.id}))}viewHasFocus(){if(this.visibleView&&this.visibleView.hasFocus())return!0;const e=this.contentElement.getComponentRoot();return e instanceof Document&&this.contentElement===e.activeElement}selectTab(e,t,i){if(this.currentTabLocked)return!1;const n=this.viewHasFocus(),s=this.tabsById.get(e);if(!s)return!1;const o={prevTabId:this.currentTab?this.currentTab.id:void 0,tabId:e,view:s.view,isUserGesture:t};return this.dispatchEventToListeners(oi.TabInvoked,o),this.currentTab&&this.currentTab.id===e||(this.suspendInvalidations(),this.hideCurrentTab(),this.showTab(s),this.resumeInvalidations(),this.currentTab=s,this.tabsHistory.splice(this.tabsHistory.indexOf(s),1),this.tabsHistory.splice(0,0,s),this.updateTabElements(),(n||i)&&this.focus(),this.dispatchEventToListeners(oi.TabSelected,o)),!0}selectNextTab(){const e=this.tabs.indexOf(this.currentTab),t=i.NumberUtilities.mod(e+1,this.tabs.length);this.selectTab(this.tabs[t].id,!0)}selectPrevTab(){const e=this.tabs.indexOf(this.currentTab),t=i.NumberUtilities.mod(e-1,this.tabs.length);this.selectTab(this.tabs[t].id,!0)}lastOpenedTabIds(e){return this.tabsHistory.slice(0,e).map((function(e){return e.id}))}setTabIcon(e,t){const i=this.tabsById.get(e);i&&(i.setIcon(t),this.updateTabElements())}setTabEnabled(e,t){const i=this.tabsById.get(e);i&&i.tabElement.classList.toggle("disabled",!t)}toggleTabClass(e,t,i){const n=this.tabsById.get(e);n&&n.toggleClass(t,i)&&this.updateTabElements()}zoomChanged(){this.clearMeasuredWidths(),this.isShowing()&&this.updateTabElements()}clearMeasuredWidths(){for(let e=0;e<this.tabs.length;++e)delete this.tabs[e].measuredWidth}changeTabTitle(e,t,i){const n=this.tabsById.get(e);n&&void 0!==i&&(n.tooltip=i),n&&n.title!==t&&(n.title=t,be(n.tabElement,t),this.updateTabElements())}changeTabView(e,t){const i=this.tabsById.get(e);if(!i||i.view===t)return;this.suspendInvalidations();const n=this.currentTab&&this.currentTab.id===e,s=i.view.hasFocus();n&&this.hideTab(i),i.view=t,n&&this.showTab(i),s&&i.view.focus(),this.resumeInvalidations()}onResize(){this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.clearMeasuredWidths(),this.currentDevicePixelRatio=window.devicePixelRatio),this.updateTabElements()}headerResized(){this.updateTabElements()}wasShown(){const e=this.currentTab||this.tabsHistory[0];e&&this.autoSelectFirstItemOnShow&&this.selectTab(e.id)}makeTabSlider(){this.verticalTabLayout||this.setTabSlider(!0)}setTabSlider(e){this.sliderEnabled=e,this.tabSlider.classList.toggle("enabled",e)}calculateConstraints(){let e=super.calculateConstraints();const t=new je(new _e(0,0),new _e(50,50));return e=e.widthToMax(t).heightToMax(t),e=this.verticalTabLayout?e.addWidth(new je(new _e(120,0))):e.addHeight(new je(new _e(0,30))),e}updateTabElements(){ts(this,this.innerUpdateTabElements)}setPlaceholderElement(e,t){this.placeholderElement=e,t&&(this.focusedPlaceholderElement=t),this.placeholderContainerElement&&(this.placeholderContainerElement.removeChildren(),this.placeholderContainerElement.appendChild(e))}async waitForTabElementUpdate(){this.innerUpdateTabElements()}innerUpdateTabElements(){this.isShowing()&&(this.tabs.length?(this.contentElementInternal.classList.remove("has-no-tabs"),this.placeholderContainerElement&&(this.placeholderContainerElement.remove(),this.setDefaultFocusedElement(this.contentElement),delete this.placeholderContainerElement)):(this.contentElementInternal.classList.add("has-no-tabs"),this.placeholderElement&&!this.placeholderContainerElement&&(this.placeholderContainerElement=this.contentElementInternal.createChild("div","tabbed-pane-placeholder fill"),this.placeholderContainerElement.appendChild(this.placeholderElement),this.focusedPlaceholderElement&&this.setDefaultFocusedElement(this.focusedPlaceholderElement))),this.measureDropDownButton(),this.adjustToolbarWidth(),this.updateWidths(),this.updateTabsDropDown(),this.updateTabSlider())}adjustToolbarWidth(){if(!this.rightToolbarInternal||!this.measuredDropDownButtonWidth)return;const e=this.leftToolbarInternal?.element.getBoundingClientRect().width??0,t=this.rightToolbarInternal.element.getBoundingClientRect().width,i=this.headerElementInternal.getBoundingClientRect().width;!this.rightToolbarInternal.hasCompactLayout()&&i-t-e<this.measuredDropDownButtonWidth+10?this.rightToolbarInternal.setCompactLayout(!0):this.rightToolbarInternal.hasCompactLayout()&&i-2*t-e>this.measuredDropDownButtonWidth+10&&this.rightToolbarInternal.setCompactLayout(!1)}showTabElement(e,t){e>=this.tabsElement.children.length?this.tabsElement.appendChild(t.tabElement):this.tabsElement.insertBefore(t.tabElement,this.tabsElement.children[e]),t.shown=!0}hideTabElement(e){this.tabsElement.removeChild(e.tabElement),e.shown=!1}createDropDownButton(){const e=document.createElement("div");e.classList.add("tabbed-pane-header-tabs-drop-down-container"),e.setAttribute("jslog",`${o.dropDown("more-tabs").track({click:!0})}`);const t=a.Icon.create("chevron-double-right","chevron-icon"),i=ni(ti.moreTabs);return e.title=i,N(e),be(e,i),ae(e,!1),e.tabIndex=0,e.appendChild(t),e.addEventListener("click",this.dropDownClicked.bind(this)),e.addEventListener("keydown",this.dropDownKeydown.bind(this)),e.addEventListener("mousedown",(e=>{0!==e.button||this.triggerDropDownTimeout||(this.triggerDropDownTimeout=window.setTimeout(this.dropDownClicked.bind(this,e),200))})),e}dropDownClicked(e){const t=e;if(0!==t.button)return;this.triggerDropDownTimeout&&(clearTimeout(this.triggerDropDownTimeout),this.triggerDropDownTimeout=null);const i=this.dropDownButton.getBoundingClientRect(),n=new Ys(t,{useSoftMenu:!1,x:i.left,y:i.bottom,onSoftMenuClosed:()=>{ae(this.dropDownButton,!1)}});for(const e of this.tabs)e.shown||(0===this.numberOfTabsShown()&&this.tabsHistory[0]===e?n.defaultSection().appendCheckboxItem(e.title,this.dropDownMenuItemSelected.bind(this,e),{checked:!0,jslogContext:e.id}):n.defaultSection().appendItem(e.title,this.dropDownMenuItemSelected.bind(this,e),{jslogContext:e.id}));n.show().then((()=>ae(this.dropDownButton,n.isHostedMenuOpen())))}dropDownKeydown(e){i.KeyboardUtilities.isEnterOrSpaceKey(e)&&(this.dropDownButton.click(),e.consume(!0))}dropDownMenuItemSelected(e){this.lastSelectedOverflowTab=e,this.selectTab(e.id,!0,!0)}totalWidth(){return this.headerContentsElement.getBoundingClientRect().width}numberOfTabsShown(){let e=0;for(const t of this.tabs)t.shown&&e++;return e}disableOverflowMenu(){this.overflowDisabled=!0}updateTabsDropDown(){const e=this.tabsToShowIndexes(this.tabs,this.tabsHistory,this.totalWidth(),this.measuredDropDownButtonWidth||0);if(this.lastSelectedOverflowTab&&this.numberOfTabsShown()!==e.length)return delete this.lastSelectedOverflowTab,void this.updateTabsDropDown();for(let t=0;t<this.tabs.length;++t)this.tabs[t].shown&&-1===e.indexOf(t)&&this.hideTabElement(this.tabs[t]);for(let t=0;t<e.length;++t){const i=this.tabs[e[t]];i.shown||this.showTabElement(t,i)}this.overflowDisabled||this.maybeShowDropDown(e.length!==this.tabs.length)}maybeShowDropDown(e){e&&!this.dropDownButton.parentElement?this.headerContentsElement.appendChild(this.dropDownButton):!e&&this.dropDownButton.parentElement&&this.headerContentsElement.removeChild(this.dropDownButton)}measureDropDownButton(){this.overflowDisabled||this.measuredDropDownButtonWidth||(this.dropDownButton.classList.add("measuring"),this.headerContentsElement.appendChild(this.dropDownButton),this.measuredDropDownButtonWidth=this.dropDownButton.getBoundingClientRect().width,this.headerContentsElement.removeChild(this.dropDownButton),this.dropDownButton.classList.remove("measuring"))}updateWidths(){const e=this.measureWidths(),t=this.shrinkableTabs?this.calculateMaxWidth(e.slice(),this.totalWidth()):Number.MAX_VALUE;let i=0;for(const n of this.tabs)n.setWidth(this.verticalTabLayout?-1:Math.min(t,e[i++]))}measureWidths(){this.tabsElement.style.setProperty("width","2000px");const e=new Map;for(const t of this.tabs){if("number"==typeof t.measuredWidth)continue;const i=t.createTabElement(!0);e.set(i,t),this.tabsElement.appendChild(i)}for(const[t,i]of e){const e=t.getBoundingClientRect().width;i.measuredWidth=Math.ceil(e)}for(const t of e.keys())t.remove();const t=[];for(const e of this.tabs)t.push(e.measuredWidth||0);return this.tabsElement.style.removeProperty("width"),t}calculateMaxWidth(e,t){if(!e.length)return 0;e.sort((function(e,t){return e-t}));let i=0;for(let t=0;t<e.length;++t)i+=e[t];if(t>=i)return e[e.length-1];let n=0;for(let s=e.length-1;s>0;--s){const o=e[s]-e[s-1];if(n+=(e.length-s)*o,t+n>=i)return e[s-1]+(t+n-i)/(e.length-s)}return t/e.length}tabsToShowIndexes(e,t,i,n){const s=[];let o=0;const r=e.length,a=e.slice(0);void 0!==this.currentTab&&a.unshift(a.splice(a.indexOf(this.currentTab),1)[0]),void 0!==this.lastSelectedOverflowTab&&a.unshift(a.splice(a.indexOf(this.lastSelectedOverflowTab),1)[0]);for(let l=0;l<r;++l){const h=this.automaticReorder?t[l]:a[l];o+=h.width();let d=o;if(l!==r-1&&(d+=n),!this.verticalTabLayout&&d>i)break;s.push(e.indexOf(h))}return s.sort((function(e,t){return e-t})),s}hideCurrentTab(){this.currentTab&&(this.hideTab(this.currentTab),delete this.currentTab)}showTab(e){e.tabElement.tabIndex=0,e.tabElement.classList.add("selected"),ue(e.tabElement,!0),e.view.show(this.element),this.updateTabSlider()}updateTabSlider(){if(!this.sliderEnabled)return;if(!this.currentTab)return void(this.tabSlider.style.width="0");let e=0;for(let t=0;t<this.tabs.length&&this.currentTab!==this.tabs[t];t++)this.tabs[t].shown&&(e+=this.tabs[t].measuredWidth||0);const t=this.currentTab.shown?this.currentTab.measuredWidth:this.dropDownButton.offsetWidth,i=window.devicePixelRatio>=1.5?" scaleY(0.75)":"";this.tabSlider.style.transform="translateX("+e+"px)"+i,this.tabSlider.style.width=t+"px",this.tabSlider.parentElement!==this.headerContentsElement&&this.headerContentsElement.appendChild(this.tabSlider)}hideTab(e){e.tabElement.removeAttribute("tabIndex"),e.tabElement.classList.remove("selected"),e.tabElement.tabIndex=-1,e.tabElement.setAttribute("aria-selected","false"),e.view.detach()}elementsToRestoreScrollPositionsFor(){return[this.contentElementInternal]}insertBefore(e,t){this.tabsElement.insertBefore(e.tabElement,this.tabsElement.childNodes[t]);const i=this.tabs.indexOf(e);this.tabs.splice(i,1),i<t&&--t,this.tabs.splice(t,0,e);const n={prevTabId:void 0,tabId:e.id,view:e.view,isUserGesture:void 0};this.dispatchEventToListeners(oi.TabOrderChanged,n)}leftToolbar(){return this.leftToolbarInternal||(this.leftToolbarInternal=new gn("tabbed-pane-left-toolbar"),this.headerElementInternal.insertBefore(this.leftToolbarInternal.element,this.headerElementInternal.firstChild)),this.leftToolbarInternal}rightToolbar(){return this.rightToolbarInternal||(this.rightToolbarInternal=new gn("tabbed-pane-right-toolbar"),this.headerElementInternal.appendChild(this.rightToolbarInternal.element)),this.rightToolbarInternal}setAllowTabReorder(e,t){this.allowTabReorder=e,this.automaticReorder=t}keyDown(e){if(!this.currentTab)return;let t=null;switch(e.key){case"ArrowUp":case"ArrowLeft":t=this.currentTab.tabElement.previousElementSibling,t||this.dropDownButton.parentElement||(t=this.currentTab.tabElement.parentElement?this.currentTab.tabElement.parentElement.lastElementChild:null);break;case"ArrowDown":case"ArrowRight":t=this.currentTab.tabElement.nextElementSibling,t||this.dropDownButton.parentElement||(t=this.currentTab.tabElement.parentElement?this.currentTab.tabElement.parentElement.firstElementChild:null);break;case"Enter":case" ":return void this.currentTab.view.focus();default:return}if(!t)return void this.dropDownButton.click();const i=this.tabs.find((e=>e.tabElement===t));i&&this.selectTab(i.id,!0),t.focus()}}var oi;!function(e){e.TabInvoked="TabInvoked",e.TabSelected="TabSelected",e.TabClosed="TabClosed",e.TabOrderChanged="TabOrderChanged"}(oi||(oi={}));class ri{closeable;previewFeature=!1;tabbedPane;idInternal;titleInternal;tooltipInternal;viewInternal;shown;measuredWidth;tabElementInternal;icon=null;widthInternal;delegate;titleElement;dragStartX;constructor(e,t,i,n,s,o,r){this.closeable=n,this.previewFeature=s,this.tabbedPane=e,this.idInternal=t,this.titleInternal=i,this.tooltipInternal=r,this.viewInternal=o,this.shown=!1}get id(){return this.idInternal}get title(){return this.titleInternal}set title(e){if(e!==this.titleInternal){if(this.titleInternal=e,this.titleElement){this.titleElement.textContent=e;const t=this.tabElementInternal?.querySelector(".close-button");t?.setAttribute("title",ni(ti.closeS,{PH1:e})),t?.setAttribute("aria-label",ni(ti.closeS,{PH1:e}))}delete this.measuredWidth}}isCloseable(){return this.closeable}setIcon(e){this.icon=e,this.tabElementInternal&&this.titleElement&&this.createIconElement(this.tabElementInternal,this.titleElement,!1),delete this.measuredWidth}toggleClass(e,t){const i=this.tabElement;return i.classList.contains(e)!==t&&(i.classList.toggle(e,t),delete this.measuredWidth,!0)}get view(){return this.viewInternal}set view(e){this.viewInternal=e}get tooltip(){return this.tooltipInternal}set tooltip(e){this.tooltipInternal=e,this.titleElement&&Jt.install(this.titleElement,e||"")}get tabElement(){return this.tabElementInternal||(this.tabElementInternal=this.createTabElement(!1)),this.tabElementInternal}width(){return this.widthInternal||0}setWidth(e){this.tabElement.style.width=-1===e?"":e+"px",this.widthInternal=e}setDelegate(e){this.delegate=e}createIconElement(e,t,i){const n=ai.get(e);if(n&&(n.remove(),ai.delete(e)),!this.icon)return;const s=document.createElement("span");s.classList.add("tabbed-pane-header-tab-icon");const o=i?this.createMeasureClone(this.icon):this.icon;s.appendChild(o),e.insertBefore(s,t),ai.set(e,s)}createMeasureClone(e){const t=document.createElement("div");return t.style.width=e.style.width,t.style.height=e.style.height,t}createTabElement(e){const t=document.createElement("div");t.classList.add("tabbed-pane-header-tab"),t.id="tab-"+this.idInternal,_(t),ue(t,!1),be(t,this.title);const i=t.createChild("span","tabbed-pane-header-tab-title");if(i.textContent=this.title,Jt.install(i,this.tooltip||""),this.createIconElement(t,i,e),e||(this.titleElement=i),this.previewFeature){const e=this.createPreviewIcon();t.appendChild(e),t.classList.add("preview")}if(this.closeable){const e=this.createCloseIconButton();t.appendChild(e),t.classList.add("closeable")}return e?t.classList.add("measuring"):(t.addEventListener("click",this.tabClicked.bind(this),!1),t.addEventListener("auxclick",this.tabClicked.bind(this),!1),t.addEventListener("mousedown",this.tabMouseDown.bind(this),!1),t.addEventListener("mouseup",this.tabMouseUp.bind(this),!1),t.addEventListener("contextmenu",this.tabContextMenu.bind(this),!1),this.tabbedPane.allowTabReorder&&An(t,this.startTabDragging.bind(this),this.tabDragging.bind(this),this.endTabDragging.bind(this),null,null,200)),t}createCloseIconButton(){const e=document.createElement("button");e.classList.add("close-button","tabbed-pane-close-button"),e.setAttribute("jslog",`${o.close().track({click:!0})}`);const t=new a.Icon.Icon;return t.data={iconName:"cross",color:"var(--tabbed-pane-close-icon-color)",width:"16px"},e.appendChild(t),e.setAttribute("role","button"),e.setAttribute("title",ni(ti.closeS,{PH1:this.title})),e.setAttribute("aria-label",ni(ti.closeS,{PH1:this.title})),e}createPreviewIcon(){const e=document.createElement("div");e.classList.add("preview-icon");const t=new a.Icon.Icon;return t.data={iconName:"experiment",color:"var(--override-tabbed-pane-preview-icon-color)",width:"16px"},e.appendChild(t),e.setAttribute("title",ni(ti.previewFeature)),e.setAttribute("aria-label",ni(ti.previewFeature)),e}isCloseIconClicked(e){return e?.classList.contains("tabbed-pane-close-button")||e?.parentElement?.classList.contains("tabbed-pane-close-button")||!1}tabClicked(e){const t=e,i=1===t.button;this.closeable&&(i||this.isCloseIconClicked(t.target))?(this.closeTabs([this.id]),t.consume(!0)):this.tabbedPane.focus()}tabMouseDown(e){const t=e;this.isCloseIconClicked(t.target)||0!==t.button||this.tabbedPane.selectTab(this.id,!0)}tabMouseUp(e){const t=e;1===t.button&&t.consume(!0)}closeTabs(e){this.delegate?this.delegate.closeTabs(this.tabbedPane,e):this.tabbedPane.closeTabs(e,!0)}tabContextMenu(e){const t=new Ys(e);this.closeable&&(t.defaultSection().appendItem(ni(ti.close),function(){this.closeTabs([this.id])}.bind(this),{jslogContext:"close"}),t.defaultSection().appendItem(ni(ti.closeOthers),function(){this.closeTabs(this.tabbedPane.otherTabs(this.id))}.bind(this),{jslogContext:"close-others"}),t.defaultSection().appendItem(ni(ti.closeTabsToTheRight),function(){this.closeTabs(this.tabbedPane.tabsToTheRight(this.id))}.bind(this),{jslogContext:"close-tabs-to-the-right"}),t.defaultSection().appendItem(ni(ti.closeAll),function(){this.closeTabs(this.tabbedPane.tabIds())}.bind(this),{jslogContext:"close-all"})),this.delegate&&this.delegate.onContextMenu(this.id,t),t.show()}startTabDragging(e){const t=e;return!this.isCloseIconClicked(t.target)&&(this.dragStartX=t.pageX,this.tabElementInternal&&this.tabElementInternal.classList.add("dragging"),this.tabbedPane.tabSlider.remove(),!0)}tabDragging(e){const t=e,i=this.tabbedPane.tabsElement.childNodes;for(let e=0;e<i.length;++e){let n=i[e];if(!this.tabElementInternal||n===this.tabElementInternal)continue;if(!(n.offsetLeft+n.clientWidth>this.tabElementInternal.offsetLeft&&this.tabElementInternal.offsetLeft+this.tabElementInternal.clientWidth>n.offsetLeft))continue;const s=this.dragStartX;if(Math.abs(t.pageX-s)<n.clientWidth/2+5)break;t.pageX-s>0&&(n=n.nextSibling,++e);const o=this.tabElementInternal.offsetLeft;this.tabbedPane.insertBefore(this,e),this.dragStartX=s+this.tabElementInternal.offsetLeft-o;break}const n=this.dragStartX,s=this.tabElementInternal;!s.previousSibling&&t.pageX-n<0||!s.nextSibling&&t.pageX-n>0?s.style.setProperty("left","0px"):s.style.setProperty("left",t.pageX-n+"px")}endTabDragging(e){const t=this.tabElementInternal;t.classList.remove("dragging"),t.style.removeProperty("left"),delete this.dragStartX,this.tabbedPane.updateTabSlider()}}const ai=new WeakMap;var li=Object.freeze({__proto__:null,TabbedPane:si,get Events(){return oi},TabbedPaneTab:ri}),hi={cssContent:".expandable-view-title{display:flex;align-items:center;background-color:var(--sys-color-surface2);height:22px;padding:0 5px;white-space:nowrap;overflow:hidden;position:relative;border-bottom:1px solid transparent}.expandable-view-title.expanded,\n.expandable-view-title:last-child{border-bottom:1px solid var(--sys-color-divider)}.expandable-view-title .toolbar{margin-top:-3px}.expandable-view-title > .toolbar{position:absolute;right:0;top:0}.expandable-view-title:not(.expanded) .toolbar{display:none}.title-expand-icon{margin-right:2px;margin-bottom:-2px}.expandable-view-title:focus-visible{background-color:var(--sys-color-state-focus-highlight)}@media (forced-colors: active){.expandable-view-title:focus-visible{forced-color-adjust:none;color:HighlightText;background-color:Highlight;box-shadow:0 0 0 2px Highlight inset}.expandable-view-title:focus-visible .title-expand-icon{color:HighlightText}}"};const di={elements:"Elements",drawer:"Drawer",drawer_sidebar:"Drawer sidebar",panel:"Panel",network:"Network",settings:"Settings",sources:"Sources"},ci=t.i18n.registerUIStrings("ui/legacy/ViewRegistration.ts",di),ui=t.i18n.getLocalizedString.bind(void 0,ci),mi=[],pi=new Set;function gi(){return mi.filter((e=>n.Runtime.Runtime.isDescriptorEnabled({experiment:e.experiment(),condition:e.condition()})))}const bi=[],fi=new Set;function vi(){return bi}const wi={sPanel:"{PH1} panel"},xi=t.i18n.registerUIStrings("ui/legacy/ViewManager.ts",wi),Ei=t.i18n.getLocalizedString.bind(void 0,xi),Ii={security:!0};class yi{viewRegistration;widgetPromise;constructor(e){this.viewRegistration=e,this.widgetPromise=null}title(){return this.viewRegistration.title()}commandPrompt(){return this.viewRegistration.commandPrompt()}isCloseable(){return"closeable"===this.viewRegistration.persistence}isPreviewFeature(){return Boolean(this.viewRegistration.isPreviewFeature)}isTransient(){return"transient"===this.viewRegistration.persistence}viewId(){return this.viewRegistration.id}location(){return this.viewRegistration.location}order(){return this.viewRegistration.order}settings(){return this.viewRegistration.settings}tags(){if(this.viewRegistration.tags)return this.viewRegistration.tags.map((e=>e())).join("\0")}persistence(){return this.viewRegistration.persistence}async toolbarItems(){if(!this.viewRegistration.hasToolbar)return[];return(await this.widget()).toolbarItems()}widget(){return null===this.widgetPromise&&(this.widgetPromise=this.viewRegistration.loadView()),this.widgetPromise}async disposeView(){if(null===this.widgetPromise)return;const e=await this.widgetPromise;await e.ownerViewDisposed()}experiment(){return this.viewRegistration.experiment}condition(){return this.viewRegistration.condition}}let Si;class Ci{views;locationNameByViewId;locationOverrideSetting;constructor(){this.views=new Map,this.locationNameByViewId=new Map,this.locationOverrideSetting=e.Settings.Settings.instance().createSetting("views-location-override",{});const t=this.locationOverrideSetting.get(),n=new Map;for(const e of gi()){const t=e.location()||"none",i=n.get(t)||[];i.push(e),n.set(t,i)}let s=[];for(const e of n.values())e.sort(((e,t)=>{const i=e.order(),n=t.order();return void 0!==i&&void 0!==n?i-n:0})),s=s.concat(e);for(const e of s){const n=e.viewId(),s=e.location();if(this.views.has(n))throw new Error(`Duplicate view id '${n}'`);if(!i.StringUtilities.isExtendedKebabCase(n))throw new Error(`Invalid view ID '${n}'`);this.views.set(n,e);const o=t[n]||s;this.locationNameByViewId.set(n,o)}}static instance(e={forceNew:null}){const{forceNew:t}=e;return Si&&!t||(Si=new Ci),Si}static removeInstance(){Si=void 0}static createToolbar(e){if(!e.length)return null;const t=new gn("");for(const i of e)t.appendToolbarItem(i);return t.element}locationNameForViewId(e){const t=this.locationNameByViewId.get(e);if(!t)throw new Error(`No location name for view with id ${e}`);return t}moveView(e,t,i){const{shouldSelectTab:n,overrideSaving:s}=i||{shouldSelectTab:!0,overrideSaving:!1};if(!e||!t)return;const o=this.view(e);if(o){if(!s){this.locationNameByViewId.set(e,t);const i=this.locationOverrideSetting.get();i[e]=t,this.locationOverrideSetting.set(i)}this.resolveLocation(t).then((t=>{if(!t)throw new Error("Move view: Could not resolve location for view: "+e);return t.reveal(),t.showView(o,void 0,!0,!1,n)}))}}revealView(e){const t=Di.get(e);return t?(t.reveal(),t.showView(e)):Promise.resolve()}showViewInLocation(e,t,i=!0){this.moveView(e,t,{shouldSelectTab:i,overrideSaving:!0})}view(e){const t=this.views.get(e);if(!t)throw new Error(`No view with id ${e} found!`);return t}materializedWidget(e){const t=this.view(e);return t&&Ti.get(t)||null}async showView(e,t,i){const n=this.views.get(e);if(!n)return void console.error("Could not find view for id: '"+e+"' "+(new Error).stack);const s=Di.get(n)??await this.resolveLocation(this.locationNameByViewId.get(e));if(!s)throw new Error("Could not resolve location for view: "+e);s.reveal(),await s.showView(n,void 0,t,i)}async resolveLocation(e){if(!e)return Promise.resolve(null);const t=vi().filter((t=>t.name===e));if(t.length>1)throw new Error("Duplicate resolver for location: "+e);if(t.length){return(await t[0].loadResolver()).resolveLocation(e)}throw new Error("Unresolved location: "+e)}createTabbedLocation(e,t,i,n,s){return new Ai(this,e,t,i,n,s)}createStackLocation(e,t,i){return new Ri(this,e,t,i)}hasViewsForLocation(e){return Boolean(this.viewsForLocation(e).length)}viewsForLocation(e){const t=[];for(const[i,n]of this.views.entries())this.locationNameByViewId.get(i)===e&&t.push(n);return t}}const Ti=new WeakMap;class ki extends Nt{view;materializePromise;constructor(e){super(),this.element.classList.add("flex-auto","view-container","overflow-auto"),this.view=e,this.element.tabIndex=-1,j(this.element),be(this.element,Ei(wi.sPanel,{PH1:e.title()})),this.setDefaultFocusedElement(this.element)}materialize(){if(this.materializePromise)return this.materializePromise;const e=[];return e.push(this.view.toolbarItems().then((e=>{const t=Ci.createToolbar(e);t&&this.element.insertBefore(t,this.element.firstChild)}))),e.push(this.view.widget().then((e=>{const t=this.element.hasFocus();this.setDefaultFocusedElement(null),Ti.set(this.view,e),e.show(this.element),t&&e.focus()}))),this.materializePromise=Promise.all(e).then((()=>{})),this.materializePromise}wasShown(){this.materialize().then((()=>{const e=Ti.get(this.view);e&&(e.show(this.element),this.wasShownForTest())}))}wasShownForTest(){}}class Mi extends Nt{titleElement;titleExpandIcon;view;widget;materializePromise;constructor(e){super(!0),this.element.classList.add("flex-none"),this.registerRequiredCSS(hi),this.titleElement=document.createElement("div"),this.titleElement.classList.add("expandable-view-title"),this.titleElement.setAttribute("jslog",`${o.sectionHeader().context(e.viewId()).track({click:!0})}`),U(this.titleElement),this.titleExpandIcon=a.Icon.create("triangle-right","title-expand-icon"),this.titleElement.appendChild(this.titleExpandIcon);const t=e.title();ss(this.titleElement,t),be(this.titleElement,t),ae(this.titleElement,!1),this.titleElement.tabIndex=0,self.onInvokeElement(this.titleElement,this.toggleExpanded.bind(this)),this.titleElement.addEventListener("keydown",this.onTitleKeyDown.bind(this),!1),this.contentElement.insertBefore(this.titleElement,this.contentElement.firstChild),re(this.titleElement,this.contentElement.createChild("slot")),this.view=e,Li.set(e,this)}wasShown(){this.widget&&this.materializePromise&&this.materializePromise.then((()=>{this.titleElement.classList.contains("expanded")&&this.widget&&this.widget.show(this.element)}))}materialize(){if(this.materializePromise)return this.materializePromise;const e=[];return e.push(this.view.toolbarItems().then((e=>{const t=Ci.createToolbar(e);t&&this.titleElement.appendChild(t)}))),e.push(this.view.widget().then((e=>{this.widget=e,Ti.set(this.view,e),e.show(this.element)}))),this.materializePromise=Promise.all(e).then((()=>{})),this.materializePromise}expand(){return this.titleElement.classList.contains("expanded")?this.materialize():(this.titleElement.classList.add("expanded"),ae(this.titleElement,!0),this.titleExpandIcon.name="triangle-down",this.materialize().then((()=>{this.widget&&this.widget.show(this.element)})))}collapse(){this.titleElement.classList.contains("expanded")&&(this.titleElement.classList.remove("expanded"),ae(this.titleElement,!1),this.titleExpandIcon.name="triangle-right",this.materialize().then((()=>{this.widget&&this.widget.detach()})))}toggleExpanded(e){"keydown"===e.type&&e.target!==this.titleElement||(this.titleElement.classList.contains("expanded")?this.collapse():this.expand())}onTitleKeyDown(e){if(e.target!==this.titleElement)return;const t=e;"ArrowLeft"===t.key?this.collapse():"ArrowRight"===t.key&&(this.titleElement.classList.contains("expanded")?this.widget&&this.widget.focus():this.expand())}}const Li=new WeakMap;class Pi{manager;revealCallback;widgetInternal;constructor(e,t,i){this.manager=e,this.revealCallback=i,this.widgetInternal=t}widget(){return this.widgetInternal}reveal(){this.revealCallback&&this.revealCallback()}showView(e,t,i,n,s){throw new Error("not implemented")}removeView(e){throw new Error("not implemented")}}const Di=new WeakMap;class Ai extends Pi{tabbedPaneInternal;allowReorder;closeableTabSetting;tabOrderSetting;lastSelectedTabSetting;defaultTab;views;constructor(t,i,n,s,o,r){const a=new si;o&&a.setAllowTabReorder(!0),super(t,a,i),this.tabbedPaneInternal=a,this.allowReorder=o,this.tabbedPaneInternal.addEventListener(oi.TabSelected,this.tabSelected,this),this.tabbedPaneInternal.addEventListener(oi.TabClosed,this.tabClosed,this),this.closeableTabSetting=e.Settings.Settings.instance().createSetting("closeable-tabs",{}),this.setOrUpdateCloseableTabsSetting(),this.tabOrderSetting=e.Settings.Settings.instance().createSetting(n+"-tab-order",{}),this.tabbedPaneInternal.addEventListener(oi.TabOrderChanged,this.persistTabOrder,this),s&&(this.lastSelectedTabSetting=e.Settings.Settings.instance().createSetting(n+"-selected-tab","")),this.defaultTab=r,this.views=new Map,n&&this.appendApplicableItems(n)}setOrUpdateCloseableTabsSetting(){const e={...Ii,...this.closeableTabSetting.get()};this.closeableTabSetting.set(e)}widget(){return this.tabbedPaneInternal}tabbedPane(){return this.tabbedPaneInternal}enableMoreTabsButton(){const e=new En(this.appendTabsToMenu.bind(this),void 0,"more-tabs");return this.tabbedPaneInternal.leftToolbar().appendToolbarItem(e),this.tabbedPaneInternal.disableOverflowMenu(),e}appendApplicableItems(e){const t=this.manager.viewsForLocation(e);if(this.allowReorder){let e=0;const i=this.tabOrderSetting.get(),n=new Map;for(const s of t)n.set(s.viewId(),i[s.viewId()]||++e*Ai.orderStep);t.sort(((e,t)=>n.get(e.viewId())-n.get(t.viewId())))}for(const e of t){const t=e.viewId();this.views.set(t,e),Di.set(e,this),e.isTransient()||(e.isCloseable()?this.closeableTabSetting.get()[t]&&this.appendTab(e):this.appendTab(e))}if(this.defaultTab)if(this.tabbedPaneInternal.hasTab(this.defaultTab))this.tabbedPaneInternal.selectTab(this.defaultTab);else{const e=Array.from(this.views.values()).find((e=>e.viewId()===this.defaultTab));e&&this.showView(e)}else this.lastSelectedTabSetting&&this.tabbedPaneInternal.hasTab(this.lastSelectedTabSetting.get())&&this.tabbedPaneInternal.selectTab(this.lastSelectedTabSetting.get())}appendTabsToMenu(e){const t=Array.from(this.views.values());t.sort(((e,t)=>e.title().localeCompare(t.title())));for(const i of t){const t=i.title();"issues-pane"!==i.viewId()?e.defaultSection().appendItem(t,this.showView.bind(this,i,void 0,!0),{jslogContext:i.viewId()}):e.defaultSection().appendItem(t,(()=>{s.userMetrics.issuesPanelOpenedFrom(3),this.showView(i,void 0,!0)}),{jslogContext:"issues-pane"})}}appendTab(e,t){this.tabbedPaneInternal.appendTab(e.viewId(),e.title(),new ki(e),void 0,!1,e.isCloseable()||e.isTransient(),e.isPreviewFeature(),t)}appendView(e,t){if(this.tabbedPaneInternal.hasTab(e.viewId()))return;const i=Di.get(e);let n;i&&i!==this&&i.removeView(e),Di.set(e,this),this.manager.views.set(e.viewId(),e),this.views.set(e.viewId(),e);const s=this.tabbedPaneInternal.tabIds();if(this.allowReorder){const t=this.tabOrderSetting.get(),i=t[e.viewId()];for(let e=0;i&&e<s.length;++e)if(t[s[e]]&&t[s[e]]>i){n=e;break}}else if(t)for(let e=0;e<s.length;++e)if(s[e]===t.viewId()){n=e;break}if(this.appendTab(e,n),e.isCloseable()){const t=this.closeableTabSetting.get(),i=e.viewId();t[i]||(t[i]=!0,this.closeableTabSetting.set(t))}this.persistTabOrder()}async showView(e,t,i,n,s=!0){this.appendView(e,t),s&&this.tabbedPaneInternal.selectTab(e.viewId(),i),n||this.tabbedPaneInternal.focus();const o=this.tabbedPaneInternal.tabView(e.viewId());await o.materialize()}removeView(e){this.tabbedPaneInternal.hasTab(e.viewId())&&(Di.delete(e),this.manager.views.delete(e.viewId()),this.tabbedPaneInternal.closeTab(e.viewId()),this.views.delete(e.viewId()))}tabSelected(e){const{tabId:t}=e.data;this.lastSelectedTabSetting&&e.data.isUserGesture&&this.lastSelectedTabSetting.set(t)}tabClosed(e){const{tabId:t}=e.data,i=this.closeableTabSetting.get();i[t]&&(i[t]=!1,this.closeableTabSetting.set(i));const n=this.views.get(t);n&&n.disposeView()}persistTabOrder(){const e=this.tabbedPaneInternal.tabIds(),t={};for(let i=0;i<e.length;i++)t[e[i]]=(i+1)*Ai.orderStep;const i=this.tabOrderSetting.get(),n=Object.keys(i);n.sort(((e,t)=>i[e]-i[t]));let s=0;for(const e of n)e in t?s=t[e]:t[e]=++s;this.tabOrderSetting.set(t)}getCloseableTabSetting(){return this.closeableTabSetting.get()}static orderStep=10}class Ri extends Pi{vbox;expandableContainers;constructor(e,t,i,n){const s=new Nt;s.element.setAttribute("jslog",`${o.pane(n||"sidebar").track({resize:!0})}`),super(e,s,t),this.vbox=s,V(s.element),this.expandableContainers=new Map,i&&this.appendApplicableItems(i)}appendView(e,t){const i=Di.get(e);i&&i!==this&&i.removeView(e);let n=this.expandableContainers.get(e.viewId());if(!n){Di.set(e,this),this.manager.views.set(e.viewId(),e),n=new Mi(e);let i=null;if(t){const e=Li.get(t);i=e?e.element:null}n.show(this.vbox.contentElement,i),this.expandableContainers.set(e.viewId(),n)}}async showView(e,t){this.appendView(e,t);const i=this.expandableContainers.get(e.viewId());i&&await i.expand()}removeView(e){const t=this.expandableContainers.get(e.viewId());t&&(t.detach(),this.expandableContainers.delete(e.viewId()),Di.delete(e),this.manager.views.delete(e.viewId()))}appendApplicableItems(e){for(const t of this.manager.viewsForLocation(e))this.appendView(t)}}var Bi=Object.freeze({__proto__:null,defaultOptionsForTabs:Ii,PreRegisteredView:yi,ViewManager:Ci,ContainerWidget:ki,getRegisteredViewExtensions:gi,maybeRemoveViewExtension:function(e){const t=mi.findIndex((t=>t.viewId()===e));return!(t<0||!pi.delete(e))&&(mi.splice(t,1),!0)},registerViewExtension:function(e){const t=e.id;if(pi.has(t))throw new Error(`Duplicate view id '${t}'`);pi.add(t),mi.push(new yi(e))},getRegisteredLocationResolvers:vi,registerLocationResolver:function(e){const t=e.name;if(fi.has(t))throw new Error(`Duplicate view location name registration '${t}'`);fi.add(t),bi.push(e)},getLocalizedViewLocationCategory:function(e){switch(e){case"ELEMENTS":return ui(di.elements);case"DRAWER":return ui(di.drawer);case"DRAWER_SIDEBAR":return ui(di.drawer_sidebar);case"PANEL":return ui(di.panel);case"NETWORK":return ui(di.network);case"SETTINGS":return ui(di.settings);case"SOURCES":return ui(di.sources);case"":return t.i18n.lockedString("")}},resetViewRegistration:function(){mi.length=0,bi.length=0,fi.clear(),pi.clear()}});const Oi={moreTools:"More Tools",closeDrawer:"Close drawer",panels:"Panels",reloadDevtools:"Reload DevTools",moveToTop:"Move to top",moveToBottom:"Move to bottom",devToolsLanguageMissmatch:"DevTools is now available in {PH1}!",setToBrowserLanguage:"Always match Chrome's language",setToSpecificLanguage:"Switch DevTools to {PH1}",mainToolbar:"Main toolbar",drawer:"Tool drawer",drawerShown:"Drawer shown",drawerHidden:"Drawer hidden",selectOverrideFolder:"Select a folder to store override files in.",selectFolder:"Select folder"},Fi=t.i18n.registerUIStrings("ui/legacy/InspectorView.ts",Oi),zi=t.i18n.getLocalizedString.bind(void 0,Fi);let Wi=null;class Hi extends Nt{drawerSplitWidget;tabDelegate;drawerTabbedLocation;drawerTabbedPane;infoBarDiv;tabbedLocation;tabbedPane;keyDownBound;currentPanelLocked;focusRestorer;ownerSplitWidget;reloadRequiredInfobar;#t;constructor(){super(),Ts.setContainer(this.element),this.setMinimumSize(250,72),this.drawerSplitWidget=new Gt(!1,!0,"inspector.drawer-split-view-state",200,200),this.drawerSplitWidget.hideSidebar(),this.drawerSplitWidget.enableShowModeSaving(),this.drawerSplitWidget.show(this.element),this.tabDelegate=new ji,this.drawerTabbedLocation=Ci.instance().createTabbedLocation(this.showDrawer.bind(this,{focus:!1,hasTargetDrawer:!0}),"drawer-view",!0,!0);this.drawerTabbedLocation.enableMoreTabsButton().setTitle(zi(Oi.moreTools)),this.drawerTabbedPane=this.drawerTabbedLocation.tabbedPane(),this.drawerTabbedPane.setMinimumSize(0,27),this.drawerTabbedPane.element.classList.add("drawer-tabbed-pane"),this.drawerTabbedPane.element.setAttribute("jslog",`${o.drawer()}`);const i=new wn(zi(Oi.closeDrawer),"cross");i.element.setAttribute("jslog",`${o.close().track({click:!0})}`),i.addEventListener("Click",this.closeDrawer,this),this.drawerTabbedPane.addEventListener(oi.TabSelected,(e=>this.tabSelected(e.data.tabId,"drawer")),this);const r=this.drawerTabbedPane.selectedTabId;"OnlyMain"!==this.drawerSplitWidget.showMode()&&r&&(s.userMetrics.panelShown(r,!0),s.userMetrics.panelShownInLocation(r,"drawer")),this.drawerTabbedPane.setTabDelegate(this.tabDelegate);const a=this.drawerTabbedPane.element;Y(a),be(a,zi(Oi.drawer)),this.drawerSplitWidget.installResizer(this.drawerTabbedPane.headerElement()),this.drawerSplitWidget.setSidebarWidget(this.drawerTabbedPane),this.drawerTabbedPane.rightToolbar().appendToolbarItem(i),this.drawerTabbedPane.headerElement().setAttribute("jslog",`${o.toolbar("drawer").track({drag:!0})}`),this.tabbedLocation=Ci.instance().createTabbedLocation(s.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront.bind(s.InspectorFrontendHost.InspectorFrontendHostInstance),"panel",!0,!0,n.Runtime.Runtime.queryParam("panel")),this.tabbedPane=this.tabbedLocation.tabbedPane(),this.tabbedPane.element.classList.add("main-tabbed-pane");const l=n.Runtime.conditions.canDock()?"69px":"41px";this.tabbedPane.leftToolbar().element.style.minWidth=l,this.tabbedPane.registerRequiredCSS(St),this.tabbedPane.addEventListener(oi.TabSelected,(e=>this.tabSelected(e.data.tabId,"main")),this);const h=this.tabbedPane.selectedTabId;h&&(s.userMetrics.panelShown(h,!0),s.userMetrics.panelShownInLocation(h,"main")),this.tabbedPane.setAccessibleName(zi(Oi.panels)),this.tabbedPane.setTabDelegate(this.tabDelegate);const d=this.tabbedPane.headerElement();if(Q(d),be(d,zi(Oi.mainToolbar)),d.setAttribute("jslog",`${o.toolbar("main").track({drag:!0})}`),s.userMetrics.setLaunchPanel(this.tabbedPane.selectedTabId),s.InspectorFrontendHost.isUnderTest()&&this.tabbedPane.setAutoSelectFirstItemOnShow(!1),this.drawerSplitWidget.setMainWidget(this.tabbedPane),this.keyDownBound=this.keyDown.bind(this),s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.ShowPanel,function({data:e}){this.showPanel(e)}.bind(this)),function(){if(Ni().get())return!1;const i=e.Settings.Settings.instance().moduleSetting("language").get();if("en-US"!==i)return!1;return!t.DevToolsLocale.localeLanguagesMatch(navigator.language,i)&&t.DevToolsLocale.DevToolsLocale.instance().languageIsSupportedByDevTools(navigator.language)}()){const i=function(){const i=t.DevToolsLocale.DevToolsLocale.instance(),n=i.lookupClosestDevToolsLocale(navigator.language),s=new Intl.Locale(n),o=new Intl.DisplayNames([i.locale],{type:"language"}).of(s.language||"en")||"English",r=e.Settings.Settings.instance().moduleSetting("language");return new It("info",zi(Oi.devToolsLanguageMissmatch,{PH1:o}),[{text:zi(Oi.setToBrowserLanguage),highlight:!0,delegate:()=>{r.set("browserLanguage"),Ni().set(!0),_i()},dismiss:!0,jslogContext:"set-to-browser-language"},{text:zi(Oi.setToSpecificLanguage,{PH1:o}),highlight:!0,delegate:()=>{r.set(n),Ni().set(!0),_i()},dismiss:!0,jslogContext:"set-to-specific-language"}],Ni(),void 0,"language-mismatch")}();i.setParentView(this),this.attachInfobar(i)}}static instance(e={forceNew:null}){const{forceNew:t}=e;return Wi&&!t||(Wi=new Hi),Wi}static maybeGetInspectorViewInstance(){return Wi}static removeInstance(){Wi=null}wasShown(){this.element.ownerDocument.addEventListener("keydown",this.keyDownBound,!1)}willHide(){this.element.ownerDocument.removeEventListener("keydown",this.keyDownBound,!1)}resolveLocation(e){return"drawer-view"===e?this.drawerTabbedLocation:"panel"===e?this.tabbedLocation:null}async createToolbars(){await this.tabbedPane.leftToolbar().appendItemsAtLocation("main-toolbar-left"),await this.tabbedPane.rightToolbar().appendItemsAtLocation("main-toolbar-right")}addPanel(e){this.tabbedLocation.appendView(e)}hasPanel(e){return this.tabbedPane.hasTab(e)}async panel(e){const t=Ci.instance().view(e);if(!t)throw new Error(`Expected view for panel '${e}'`);return t.widget()}onSuspendStateChanged(e){this.currentPanelLocked=e,this.tabbedPane.setCurrentTabLocked(this.currentPanelLocked),this.tabbedPane.leftToolbar().setEnabled(!this.currentPanelLocked),this.tabbedPane.rightToolbar().setEnabled(!this.currentPanelLocked)}canSelectPanel(e){return!this.currentPanelLocked||this.tabbedPane.selectedTabId===e}async showPanel(e){await Ci.instance().showView(e)}setPanelWarnings(e,t){const i=this.getTabbedPaneForTabId(e);if(i){let n=null;if(0!==t.length){const e=1===t.length?t[0]:"· "+t.join("\n· ");n=a.Icon.create("warning-filled"),Jt.install(n,e)}i.setTabIcon(e,n)}}emitDrawerChangeEvent(e){const t=new CustomEvent("drawerchange",{bubbles:!0,cancelable:!0,detail:{isDrawerOpen:e}});document.body.dispatchEvent(t)}getTabbedPaneForTabId(e){return this.tabbedPane.hasTab(e)?this.tabbedPane:this.drawerTabbedPane.hasTab(e)?this.drawerTabbedPane:null}currentPanelDeprecated(){return Ci.instance().materializedWidget(this.tabbedPane.selectedTabId||"")}showDrawer({focus:e,hasTargetDrawer:t}){this.drawerTabbedPane.isShowing()||(this.drawerTabbedPane.setAutoSelectFirstItemOnShow(!t),this.drawerSplitWidget.showBoth(),this.focusRestorer=e?new jt(this.drawerTabbedPane):null,this.emitDrawerChangeEvent(!0),Se(zi(Oi.drawerShown)))}drawerVisible(){return this.drawerTabbedPane.isShowing()}closeDrawer(){this.drawerTabbedPane.isShowing()&&(this.focusRestorer&&this.focusRestorer.restore(),this.drawerSplitWidget.hideSidebar(!0),this.emitDrawerChangeEvent(!1),Se(zi(Oi.drawerHidden)))}setDrawerMinimized(e){this.drawerSplitWidget.setSidebarMinimized(e),this.drawerSplitWidget.setResizable(!e)}isDrawerMinimized(){return this.drawerSplitWidget.isSidebarMinimized()}closeDrawerTab(e,t){this.drawerTabbedPane.closeTab(e,t),s.userMetrics.panelClosed(e)}keyDown(t){const i=t;if(!Ke.eventHasCtrlEquivalentKey(i)||i.altKey||i.shiftKey)return;if(e.Settings.moduleSetting("shortcut-panel-switch").get()){let e=-1;if(i.keyCode>48&&i.keyCode<58?e=i.keyCode-49:i.keyCode>96&&i.keyCode<106&&i.location===KeyboardEvent.DOM_KEY_LOCATION_NUMPAD&&(e=i.keyCode-97),-1!==e){const i=this.tabbedPane.tabIds()[e];i&&(Ds.hasInstance()||this.currentPanelLocked||this.showPanel(i),t.consume(!0))}}}onResize(){Ts.containerMoved(this.element)}topResizerElement(){return this.tabbedPane.headerElement()}toolbarItemResized(){this.tabbedPane.headerResized()}tabSelected(e,t){s.userMetrics.panelShown(e),s.userMetrics.panelShownInLocation(e,t)}setOwnerSplit(e){this.ownerSplitWidget=e}ownerSplit(){return this.ownerSplitWidget||null}minimize(){this.ownerSplitWidget&&this.ownerSplitWidget.setSidebarMinimized(!0)}restore(){this.ownerSplitWidget&&this.ownerSplitWidget.setSidebarMinimized(!1)}displayReloadRequiredWarning(e){if(!this.reloadRequiredInfobar){const t=new It("info",e,[{text:zi(Oi.reloadDevtools),highlight:!0,delegate:()=>_i(),dismiss:!1,jslogContext:"main.debug-reload"}],void 0,void 0,"reload-required");t.setParentView(this),this.attachInfobar(t),this.reloadRequiredInfobar=t,t.setCloseCallback((()=>{delete this.reloadRequiredInfobar}))}}displaySelectOverrideFolderInfobar(e){if(!this.#t){const t=new It("info",zi(Oi.selectOverrideFolder),[{text:zi(Oi.selectFolder),highlight:!0,delegate:()=>e(),dismiss:!0,jslogContext:"select-folder"}],void 0,void 0,"select-override-folder");t.setParentView(this),this.attachInfobar(t),this.#t=t,t.setCloseCallback((()=>{this.#t=void 0}))}}createInfoBarDiv(){this.infoBarDiv||(this.infoBarDiv=document.createElement("div"),this.infoBarDiv.classList.add("flex-none"),this.contentElement.insertBefore(this.infoBarDiv,this.contentElement.firstChild))}attachInfobar(e){this.createInfoBarDiv(),this.infoBarDiv?.appendChild(e.element)}}function Ni(){return e.Settings.Settings.instance().createSetting("disable-locale-info-bar",!1)}function _i(){mt.instance().canDock()&&"undocked"===mt.instance().dockSide()&&s.InspectorFrontendHost.InspectorFrontendHostInstance.setIsDocked(!0,(function(){})),s.InspectorFrontendHost.InspectorFrontendHostInstance.reattach((()=>window.location.reload()))}class ji{closeTabs(e,t){e.closeTabs(t,!0),t.forEach((e=>{s.userMetrics.panelClosed(e)}))}moveToDrawer(e){s.userMetrics.actionTaken(s.UserMetrics.Action.TabMovedToDrawer),Ci.instance().moveView(e,"drawer-view")}moveToMainPanel(e){s.userMetrics.actionTaken(s.UserMetrics.Action.TabMovedToMainPanel),Ci.instance().moveView(e,"panel")}onContextMenu(e,t){if("console"===e||"console-view"===e)return;"drawer-view"===Ci.instance().locationNameForViewId(e)?t.defaultSection().appendItem(zi(Oi.moveToTop),this.moveToMainPanel.bind(this,e),{jslogContext:"move-to-top"}):t.defaultSection().appendItem(zi(Oi.moveToBottom),this.moveToDrawer.bind(this,e),{jslogContext:"move-to-bottom"})}}var Vi=Object.freeze({__proto__:null,InspectorView:Hi,ActionDelegate:class{handleAction(e,t){switch(t){case"main.toggle-drawer":return Hi.instance().drawerVisible()?Hi.instance().closeDrawer():Hi.instance().showDrawer({focus:!0,hasTargetDrawer:!1}),!0;case"main.next-tab":return Hi.instance().tabbedPane.selectNextTab(),Hi.instance().tabbedPane.focus(),!0;case"main.previous-tab":return Hi.instance().tabbedPane.selectPrevTab(),Hi.instance().tabbedPane.focus(),!0}return!1}},InspectorViewTabDelegate:ji});const Ui={srequiresReload:"*Requires reload",oneOrMoreSettingsHaveChanged:"One or more settings have changed which requires a reload to take effect."},Ki=t.i18n.registerUIStrings("ui/legacy/SettingsUI.ts",Ui),qi=t.i18n.getLocalizedString.bind(void 0,Ki),$i=function(e,t,i){const n=e;function o(){n.checked!==t.get()&&(n.checked=t.get())}t.addChangeListener(o),o(),n.addEventListener("change",(function(){t.get()!==n.checked&&t.set(n.checked),t.get()&&i?.enable&&s.userMetrics.actionTaken(i.enable),!t.get()&&i?.disable&&s.userMetrics.actionTaken(i.disable),i?.toggle&&s.userMetrics.actionTaken(i.toggle)}),!1)};var Gi,Xi=Object.freeze({__proto__:null,createSettingCheckbox:function(e,t,i,n){const s=ls.create(e,void 0,void 0,t.name);n&&Jt.install(s,n);const o=s.checkboxElement;if(o.name=e,$i(o,t),i)return s;const r=document.createElement("p");return r.appendChild(s),r},bindCheckbox:$i,createCustomSetting:function(e,t){const i=document.createElement("p");i.classList.add("settings-select");const n=i.createChild("label");return n.textContent=e,B(n,t),i.appendChild(t),i},createControlForSetting:function(e,t){const n=e.title();switch(e.type()){case"boolean":{const t=new h.SettingCheckbox.SettingCheckbox;return t.data={setting:e},t.onchange=()=>{Hi.instance().displayReloadRequiredWarning(qi(Ui.oneOrMoreSettingsHaveChanged))},t}case"enum":return Array.isArray(e.options())?function(e,t,n,s,r){const a=document.createElement("div"),l=a.createChild("p");l.classList.add("settings-select");const d=l.createChild("label"),c=l.createChild("select","chrome-select");d.textContent=e,r&&(a.classList.add("chrome-select-label"),d.createChild("p").textContent=r),c.setAttribute("jslog",`${o.dropDown().track({change:!0}).context(s.name)}`),B(d,c);for(const e of t)e.text&&"string"==typeof e.value&&c.add(as(e.text,e.value,i.StringUtilities.toKebabCase(e.value)));let u=null;n&&(u=a.createChild("span","reload-warning hidden"),u.textContent=qi(Ui.srequiresReload),O(u));const{deprecation:m}=s;if(m){const e=new h.SettingDeprecationWarning.SettingDeprecationWarning;e.data=m,d.appendChild(e)}return s.addChangeListener(p),p(),c.addEventListener("change",(function(){s.set(t[c.selectedIndex].value),u&&(u.classList.remove("hidden"),Hi.instance().displayReloadRequiredWarning(qi(Ui.oneOrMoreSettingsHaveChanged)))}),!1),a;function p(){const e=s.get();for(let i=0;i<t.length;i++)t[i].value===e&&(c.selectedIndex=i);c.disabled=s.disabled()}}(n,e.options(),e.reloadRequired(),e,t):(console.error("Enum setting defined without options"),null);default:return console.error("Invalid setting type: "+e.type()),null}}});!function(e){e.NonViewport="UI.ListMode.NonViewport",e.EqualHeightItems="UI.ListMode.EqualHeightItems",e.VariousHeightItems="UI.ListMode.VariousHeightItems"}(Gi||(Gi={}));class Yi{element;topElement;bottomElement;firstIndex;lastIndex;renderedHeight;topHeight;bottomHeight;model;itemToElement;selectedIndexInternal;selectedItemInternal;delegate;mode;fixedHeight;variableOffsets;constructor(e,t,i){this.element=document.createElement("div"),this.element.style.overflowY="auto",this.topElement=this.element.createChild("div"),this.bottomElement=this.element.createChild("div"),this.firstIndex=0,this.lastIndex=0,this.renderedHeight=0,this.topHeight=0,this.bottomHeight=0,this.model=e,this.model.addEventListener("ItemsReplaced",this.replacedItemsInRange,this),this.itemToElement=new Map,this.selectedIndexInternal=-1,this.selectedItemInternal=null,this.element.tabIndex=-1,this.element.addEventListener("click",this.onClick.bind(this),!1),this.element.addEventListener("keydown",this.onKeyDown.bind(this),!1),Z(this.element),this.delegate=t,this.mode=i||Gi.EqualHeightItems,this.fixedHeight=0,this.variableOffsets=new Int32Array(0),this.clearContents(),this.mode!==Gi.NonViewport&&this.element.addEventListener("scroll",(()=>{this.updateViewport(this.element.scrollTop,this.element.offsetHeight)}),!1)}setModel(e){this.itemToElement.clear();const t=this.model.length;this.model.removeEventListener("ItemsReplaced",this.replacedItemsInRange,this),this.model=e,this.model.addEventListener("ItemsReplaced",this.replacedItemsInRange,this),this.invalidateRange(0,t)}replacedItemsInRange(e){const t=e.data,i=t.index,n=i+t.removed.length,s=t.keepSelectedIndex,o=this.selectedItemInternal,r=null!==o&&this.itemToElement.get(o)||null;for(let e=0;e<t.removed.length;e++)this.itemToElement.delete(t.removed[e]);if(this.invalidate(i,n,t.inserted),this.selectedIndexInternal>=n)this.selectedIndexInternal+=t.inserted-(n-i),this.selectedItemInternal=this.model.at(this.selectedIndexInternal);else if(this.selectedIndexInternal>=i){const e=s?i:i+t.inserted;let n=this.findFirstSelectable(e,1,!1);if(-1===n){const e=s?i:i-1;n=this.findFirstSelectable(e,-1,!1)}this.select(n,o,r)}}refreshItem(e){const t=this.model.indexOf(e);-1!==t?this.refreshItemByIndex(t):console.error("Item to refresh is not present")}refreshItemByIndex(e){const t=this.model.at(e);this.itemToElement.delete(t),this.invalidateRange(e,e+1),-1!==this.selectedIndexInternal&&this.select(this.selectedIndexInternal,null,null)}refreshAllItems(){this.itemToElement.clear(),this.invalidateRange(0,this.model.length),-1!==this.selectedIndexInternal&&this.select(this.selectedIndexInternal,null,null)}invalidateRange(e,t){this.invalidate(e,t,t-e)}viewportResized(){if(this.mode===Gi.NonViewport)return;const e=this.element.scrollTop,t=this.element.offsetHeight;this.clearViewport(),this.updateViewport(i.NumberUtilities.clamp(e,0,this.totalHeight()-t),t)}invalidateItemHeight(){this.mode===Gi.EqualHeightItems?(this.fixedHeight=0,this.model.length&&(this.itemToElement.clear(),this.invalidate(0,this.model.length,this.model.length))):console.error("Only supported in equal height items mode")}itemForNode(e){for(;e&&e.parentNodeOrShadowHost()!==this.element;)e=e.parentNodeOrShadowHost();if(!e)return null;const t=e,i=this.model.findIndex((e=>this.itemToElement.get(e)===t));return-1!==i?this.model.at(i):null}scrollItemIntoView(e,t){const i=this.model.indexOf(e);-1!==i?this.scrollIntoView(i,t):console.error("Attempt to scroll onto missing item")}selectedItem(){return this.selectedItemInternal}selectedIndex(){return this.selectedIndexInternal}selectItem(e,t,i){let n=-1;if(null!==e){if(n=this.model.indexOf(e),-1===n)return void console.error("Attempt to select missing item");if(!this.delegate.isItemSelectable(e))return void console.error("Attempt to select non-selectable item")}-1===n||i||this.scrollIntoView(n,t),this.selectedIndexInternal!==n&&this.select(n)}selectPreviousItem(e,t){if(-1===this.selectedIndexInternal&&!e)return!1;let i=-1===this.selectedIndexInternal?this.model.length-1:this.selectedIndexInternal-1;return i=this.findFirstSelectable(i,-1,Boolean(e)),-1!==i&&(this.scrollIntoView(i,t),this.select(i),!0)}selectNextItem(e,t){if(-1===this.selectedIndexInternal&&!e)return!1;let i=-1===this.selectedIndexInternal?0:this.selectedIndexInternal+1;return i=this.findFirstSelectable(i,1,Boolean(e)),-1!==i&&(this.scrollIntoView(i,t),this.select(i),!0)}selectItemPreviousPage(e){if(this.mode===Gi.NonViewport)return!1;let t=-1===this.selectedIndexInternal?this.model.length-1:this.selectedIndexInternal;return t=this.findPageSelectable(t,-1),-1!==t&&(this.scrollIntoView(t,e),this.select(t),!0)}selectItemNextPage(e){if(this.mode===Gi.NonViewport)return!1;let t=-1===this.selectedIndexInternal?0:this.selectedIndexInternal;return t=this.findPageSelectable(t,1),-1!==t&&(this.scrollIntoView(t,e),this.select(t),!0)}scrollIntoView(e,t){if(this.mode===Gi.NonViewport)return void this.elementAtIndex(e).scrollIntoViewIfNeeded(Boolean(t));const n=this.offsetAtIndex(e),s=this.offsetAtIndex(e+1),o=this.element.offsetHeight;if(t){const e=(n+s)/2-o/2;return void this.updateViewport(i.NumberUtilities.clamp(e,0,this.totalHeight()-o),o)}const r=this.element.scrollTop;n<r?this.updateViewport(n,o):s>r+o&&this.updateViewport(s-o,o)}onClick(e){const t=this.itemForNode(e.target);null!==t&&this.delegate.isItemSelectable(t)&&this.selectItem(t)}onKeyDown(e){const t=e;let i=!1;switch(t.key){case"ArrowUp":i=this.selectPreviousItem(!0,!1);break;case"ArrowDown":i=this.selectNextItem(!0,!1);break;case"PageUp":i=this.selectItemPreviousPage(!1);break;case"PageDown":i=this.selectItemNextPage(!1)}i&&t.consume(!0)}totalHeight(){return this.offsetAtIndex(this.model.length)}indexAtOffset(e){if(this.mode===Gi.NonViewport)throw"There should be no offset conversions in non-viewport mode";return!this.model.length||e<0?0:this.mode===Gi.VariousHeightItems?Math.min(this.model.length-1,i.ArrayUtilities.lowerBound(this.variableOffsets,e,i.ArrayUtilities.DEFAULT_COMPARATOR,0,this.model.length)):(this.fixedHeight||this.measureHeight(),Math.min(this.model.length-1,Math.floor(e/this.fixedHeight)))}elementAtIndex(e){const t=this.model.at(e);let i=this.itemToElement.get(t);return i||(i=this.delegate.createElementForItem(t),i.hasAttribute("jslog")||i.setAttribute("jslog",`${o.item().track({click:!0})}`),this.itemToElement.set(t,i),this.updateElementARIA(i,e)),i}refreshARIA(){for(let e=this.firstIndex;e<=this.lastIndex;e++){const t=this.model.at(e),i=this.itemToElement.get(t);i&&this.updateElementARIA(i,e)}}updateElementARIA(e,t){ne(e)||ee(e),we(e,this.model.length),xe(e,t+1)}offsetAtIndex(e){if(this.mode===Gi.NonViewport)throw new Error("There should be no offset conversions in non-viewport mode");return this.model.length?this.mode===Gi.VariousHeightItems?this.variableOffsets[e]:(this.fixedHeight||this.measureHeight(),e*this.fixedHeight):0}measureHeight(){this.fixedHeight=this.delegate.heightForItem(this.model.at(0)),this.fixedHeight||(this.fixedHeight=Qn(this.elementAtIndex(0),this.element).height)}select(e,t,i){void 0===t&&(t=this.selectedItemInternal),void 0===i&&(i=this.itemToElement.get(t)||null),this.selectedIndexInternal=e,this.selectedItemInternal=-1===e?null:this.model.at(e);const n=this.selectedItemInternal,s=-1!==this.selectedIndexInternal?this.elementAtIndex(e):null;this.delegate.selectedItemChanged(t,n,i,s),this.delegate.updateSelectedItemARIA(i,s)||(i&&ue(i,!1),s&&ue(s,!0),ve(this.element,s))}findFirstSelectable(e,t,i){const n=this.model.length;if(!n)return-1;for(let s=0;s<=n;s++){if(e<0||e>=n){if(!i)return-1;e=(e+n)%n}if(this.delegate.isItemSelectable(this.model.at(e)))return e;e+=t}return-1}findPageSelectable(e,t){let i=-1;const n=this.offsetAtIndex(e),s=this.element.offsetHeight-1;for(;e>=0&&e<this.model.length;){if(this.delegate.isItemSelectable(this.model.at(e))){if(Math.abs(this.offsetAtIndex(e)-n)>=s)return e;i=e}e+=t}return i}reallocateVariableOffsets(e,t){if(this.variableOffsets.length<e){const i=new Int32Array(Math.max(e,2*this.variableOffsets.length));i.set(this.variableOffsets.slice(0,t),0),this.variableOffsets=i}else if(this.variableOffsets.length>=2*e){const i=new Int32Array(e);i.set(this.variableOffsets.slice(0,t),0),this.variableOffsets=i}}invalidate(e,t,n){if(this.mode===Gi.NonViewport)return void this.invalidateNonViewportMode(e,t-e,n);if(this.mode===Gi.VariousHeightItems){this.reallocateVariableOffsets(this.model.length+1,e+1);for(let t=e+1;t<=this.model.length;t++)this.variableOffsets[t]=this.variableOffsets[t-1]+this.delegate.heightForItem(this.model.at(t-1))}const s=this.element.offsetHeight,o=this.totalHeight(),r=this.element.scrollTop;if(this.renderedHeight<s||o<s)return this.clearViewport(),void this.updateViewport(i.NumberUtilities.clamp(r,0,o-s),s);const a=o-this.renderedHeight;if(t<=this.firstIndex){const i=this.topHeight+a;this.topElement.style.height=i+"px",this.element.scrollTop=r+a,this.topHeight=i,this.renderedHeight=o;const s=n-(t-e);return this.firstIndex+=s,void(this.lastIndex+=s)}if(e>=this.lastIndex){const e=this.bottomHeight+a;return this.bottomElement.style.height=e+"px",this.bottomHeight=e,void(this.renderedHeight=o)}this.clearViewport(),this.updateViewport(i.NumberUtilities.clamp(r,0,o-s),s),this.refreshARIA()}invalidateNonViewportMode(e,t,i){let n=this.topElement;for(let t=0;t<e;t++)n=n.nextElementSibling;for(;t--;)n.nextElementSibling.remove();for(;i--;)this.element.insertBefore(this.elementAtIndex(e+i),n.nextElementSibling)}clearViewport(){this.mode!==Gi.NonViewport?(this.firstIndex=0,this.lastIndex=0,this.renderedHeight=0,this.topHeight=0,this.bottomHeight=0,this.clearContents()):console.error("There should be no viewport updates in non-viewport mode")}clearContents(){this.topElement.style.height="0",this.bottomElement.style.height="0",this.element.removeChildren(),this.element.appendChild(this.topElement),this.element.appendChild(this.bottomElement)}updateViewport(e,t){if(this.mode===Gi.NonViewport)return void console.error("There should be no viewport updates in non-viewport mode");const i=this.totalHeight();if(!i)return this.firstIndex=0,this.lastIndex=0,this.topHeight=0,this.bottomHeight=0,this.renderedHeight=0,this.topElement.style.height="0",void(this.bottomElement.style.height="0");const n=this.indexAtOffset(e-t),s=this.indexAtOffset(e+2*t)+1;for(;this.firstIndex<Math.min(n,this.lastIndex);)this.elementAtIndex(this.firstIndex).remove(),this.firstIndex++;for(;this.lastIndex>Math.max(s,this.firstIndex);)this.elementAtIndex(this.lastIndex-1).remove(),this.lastIndex--;this.firstIndex=Math.min(this.firstIndex,s),this.lastIndex=Math.max(this.lastIndex,n);for(let e=this.firstIndex-1;e>=n;e--){const t=this.elementAtIndex(e);this.element.insertBefore(t,this.topElement.nextSibling)}for(let e=this.lastIndex;e<s;e++){const t=this.elementAtIndex(e);this.element.insertBefore(t,this.bottomElement)}this.firstIndex=n,this.lastIndex=s,this.topHeight=this.offsetAtIndex(n),this.topElement.style.height=this.topHeight+"px",this.bottomHeight=i-this.offsetAtIndex(s),this.bottomElement.style.height=this.bottomHeight+"px",this.renderedHeight=i,this.element.scrollTop=e}}var Qi=Object.freeze({__proto__:null,get ListMode(){return Gi},ListControl:Yi});class Zi extends e.ObjectWrapper.ObjectWrapper{items;constructor(e){super(),this.items=e||[]}[Symbol.iterator](){return this.items[Symbol.iterator]()}get length(){return this.items.length}at(e){return this.items[e]}every(e){return this.items.every(e)}filter(e){return this.items.filter(e)}find(e){return this.items.find(e)}findIndex(e){return this.items.findIndex(e)}indexOf(e,t){return this.items.indexOf(e,t)}insert(e,t){this.items.splice(e,0,t),this.replaced(e,[],1)}insertWithComparator(e,t){this.insert(i.ArrayUtilities.lowerBound(this.items,e,t),e)}join(e){return this.items.join(e)}remove(e){const t=this.items[e];return this.items.splice(e,1),this.replaced(e,[t],0),t}replace(e,t,i){const n=this.items[e];return this.items[e]=t,this.replaced(e,[n],1,i),n}replaceRange(e,t,i){let n;if(i.length<1e4)n=this.items.splice(e,t-e,...i);else{n=this.items.slice(e,t);const s=this.items.slice(0,e),o=this.items.slice(t);this.items=[...s,...i,...o]}return this.replaced(e,n,i.length),n}replaceAll(e){const t=this.items.slice();return this.items=e,this.replaced(0,t,e.length),t}slice(e,t){return this.items.slice(e,t)}some(e){return this.items.some(e)}replaced(e,t,i,n){this.dispatchEventToListeners("ItemsReplaced",{index:e,removed:t,inserted:i,keepSelectedIndex:n})}}var Ji=Object.freeze({__proto__:null,ListModel:Zi}),en={cssContent:":host{display:flex;flex:auto}.suggest-box{flex:auto;background-color:var(--sys-color-cdt-base-container);pointer-events:auto;margin-left:-3px;box-shadow:var(--drop-shadow);overflow-x:hidden}.suggest-box-content-item{padding:1px 0 1px 1px;margin:0;border:1px solid transparent;white-space:nowrap;display:flex;align-items:center;justify-content:space-between}.suggest-box-content-item.secondary{background-color:var(--sys-color-neutral-container);justify-content:normal}.suggestion-title{overflow:hidden;text-overflow:ellipsis}.suggestion-title span{white-space:pre}.suggestion-subtitle{flex:auto;text-align:right;color:var(--sys-color-token-subtle);margin-right:3px;overflow:hidden;text-overflow:ellipsis}.suggest-box-content-item devtools-icon{color:var(--sys-color-on-surface-subtle);margin-right:1px}.suggest-box-content-item .query{font-weight:bold}.suggest-box-content-item .spacer{display:inline-block;width:20px}.suggest-box-content-item.selected{background-color:var(--sys-color-tonal-container)}.suggest-box-content-item.selected .suggestion-subtitle,\n.suggest-box-content-item.selected > span{color:var(--sys-color-on-tonal-container)}.suggest-box-content-item:hover:not(.selected){background-color:var(--sys-color-state-hover-on-subtle)}@media (forced-colors: active){.suggest-box-content-item.selected{forced-color-adjust:none;background-color:Highlight}.suggest-box-content-item.selected > span{color:HighlightText}}"};const tn={sSuggestionSOfS:"{PH1}, suggestion {PH2} of {PH3}",sSuggestionSSelected:"{PH1}, suggestion selected"},nn=t.i18n.registerUIStrings("ui/legacy/SuggestBox.ts",tn),sn=t.i18n.getLocalizedString.bind(void 0,nn);class on{suggestBoxDelegate;maxItemsHeight;rowHeight;userEnteredText;defaultSelectionIsDimmed;onlyCompletion;items;list;element;glassPane;constructor(e,t){this.suggestBoxDelegate=e,this.maxItemsHeight=t,this.rowHeight=17,this.userEnteredText="",this.defaultSelectionIsDimmed=!1,this.onlyCompletion=null,this.items=new Zi,this.list=new Yi(this.items,this,Gi.EqualHeightItems),this.element=this.list.element,this.element.classList.add("suggest-box"),this.element.addEventListener("mousedown",(e=>e.preventDefault()),!0),this.element.addEventListener("click",this.onClick.bind(this),!1),this.glassPane=new Ts,this.glassPane.setAnchorBehavior("PreferBottom"),this.glassPane.setOutsideClickCallback(this.hide.bind(this));d.createShadowRootWithCoreStyles(this.glassPane.contentElement,{cssFile:en,delegatesFocus:void 0}).appendChild(this.element)}visible(){return this.glassPane.isShowing()}setPosition(e){this.glassPane.setContentAnchorBox(e)}setAnchorBehavior(e){this.glassPane.setAnchorBehavior(e)}updateMaxSize(e){const t=this.maxWidth(e),i=(this.maxItemsHeight?Math.min(this.maxItemsHeight,e.length):e.length)*this.rowHeight;this.glassPane.setMaxContentSize(new _e(t,i))}maxWidth(e){if(!e.length)return 300;let t,i=-1/0;for(let n=0;n<e.length;n++){const s=(e[n].title||e[n].text).length+(e[n].subtitle||"").length;s>i&&(i=s,t=e[n])}const n=Qn(this.createElementForItem(t),this.element).width+d.measuredScrollbarWidth(this.element.ownerDocument);return Math.min(300,n)}show(){if(this.visible())return;this.glassPane.show(document);this.rowHeight=Qn(this.createElementForItem({text:"1",subtitle:"12"}),this.element).height,re(this.suggestBoxDelegate.ariaControlledBy(),this.element),ae(this.suggestBoxDelegate.ariaControlledBy(),!0)}hide(){this.visible()&&(this.glassPane.hide(),re(this.suggestBoxDelegate.ariaControlledBy(),null),ae(this.suggestBoxDelegate.ariaControlledBy(),!1))}applySuggestion(e){if(this.onlyCompletion)return Se(e?sn(tn.sSuggestionSOfS,{PH1:this.onlyCompletion.text,PH2:this.list.selectedIndex()+1,PH3:this.items.length}):sn(tn.sSuggestionSSelected,{PH1:this.onlyCompletion.text})),this.suggestBoxDelegate.applySuggestion(this.onlyCompletion,e),!0;const t=this.list.selectedItem();return t&&t.text&&Se(e?sn(tn.sSuggestionSOfS,{PH1:t.title||t.text,PH2:this.list.selectedIndex()+1,PH3:this.items.length}):sn(tn.sSuggestionSSelected,{PH1:t.title||t.text})),this.suggestBoxDelegate.applySuggestion(t,e),this.visible()&&Boolean(t)}acceptSuggestion(){const e=this.applySuggestion();return this.hide(),!!e&&(this.suggestBoxDelegate.acceptSuggestion(),!0)}createElementForItem(e){const t=this.userEnteredText,n=document.createElement("div");n.classList.add("suggest-box-content-item"),n.classList.add("source-code"),e.isSecondary&&n.classList.add("secondary"),n.tabIndex=-1;const s=50+t.length,o=i.StringUtilities.trimEndWithMaxLength((e.title||e.text).trim(),s).replace(/\n/g,"↵"),r=n.createChild("span","suggestion-title"),a=o.toLowerCase().indexOf(t.toLowerCase());if(a>0&&(r.createChild("span").textContent=o.substring(0,a)),a>-1&&(r.createChild("span","query").textContent=o.substring(a,a+t.length)),r.createChild("span").textContent=o.substring(a>-1?a+t.length:0),r.createChild("span","spacer"),e.subtitleRenderer){const t=e.subtitleRenderer.call(null);t.classList.add("suggestion-subtitle"),n.appendChild(t)}else if(e.subtitle){n.createChild("span","suggestion-subtitle").textContent=i.StringUtilities.trimEndWithMaxLength(e.subtitle,s-o.length)}return e.iconElement&&n.appendChild(e.iconElement),n}heightForItem(e){return this.rowHeight}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,n){i&&i.classList.remove("selected","force-white-icons"),n&&(n.classList.add("selected"),n.classList.add("force-white-icons")),this.applySuggestion(!0)}updateSelectedItemARIA(e,t){return!1}onClick(e){const t=this.list.itemForNode(e.target);t&&(this.list.selectItem(t),this.acceptSuggestion(),e.consume(!0))}canShowBox(e,t,i,n){return!(!e||!e.length)&&(e.length>1||(!(t&&!t.isSecondary&&t.text.startsWith(n))||i&&t.text!==n))}updateSuggestions(e,t,i,n,s){this.onlyCompletion=null;const o=i?t.reduce(((e,t)=>(e.priority||0)>=(t.priority||0)?e:t)):null;this.canShowBox(t,o,n,s)?(this.userEnteredText=s,this.show(),this.updateMaxSize(t),this.glassPane.setContentAnchorBox(e),this.list.invalidateItemHeight(),this.items.replaceAll(t),o&&!o.isSecondary?this.list.selectItem(o,!0):this.list.selectItem(null)):(1===t.length&&(this.onlyCompletion=t[0],this.applySuggestion(!0)),this.hide())}keyPressed(e){switch(e.key){case"Enter":return this.enterKeyPressed();case"ArrowUp":return this.list.selectPreviousItem(!0,!1);case"ArrowDown":return this.list.selectNextItem(!0,!1);case"PageUp":return this.list.selectItemPreviousPage(!1);case"PageDown":return this.list.selectItemNextPage(!1)}return!1}enterKeyPressed(){const e=Boolean(this.list.selectedItem())||Boolean(this.onlyCompletion);return this.acceptSuggestion(),e}}var rn=Object.freeze({__proto__:null,SuggestBox:on}),an={cssContent:'.text-prompt-root{display:flex;align-items:center}.text-prompt-editing{box-shadow:var(--drop-shadow);background-color:var(--sys-color-cdt-base-container);text-overflow:clip!important;margin:0 -2px -1px;padding:0 2px 1px;opacity:100%!important}.text-prompt{cursor:text;overflow-x:visible}.text-prompt::-webkit-scrollbar{display:none}.text-prompt-editing > .text-prompt{color:var(--sys-color-on-surface)!important;text-decoration:none!important;white-space:pre}.text-prompt > .auto-complete-text{color:var(--sys-color-token-subtle)!important}.text-prompt[data-placeholder]:empty::before{content:attr(data-placeholder);color:var(--sys-color-token-subtle)}.text-prompt:not([data-placeholder]):empty::after{content:"\\00A0";width:0;display:block}.text-prompt.disabled{opacity:50%;cursor:default}.text-prompt-editing br{display:none}.text-prompt-root:not(:focus-within) ::selection{background:transparent}@media (forced-colors: active){.text-prompt[data-placeholder]:empty::before{color:GrayText!important}.text-prompt.disabled{opacity:100%}}'};class ln extends e.ObjectWrapper.ObjectWrapper{proxyElement;proxyElementDisplay;autocompletionTimeout;titleInternal;queryRange;previousText;currentSuggestion;completionRequestId;ghostTextElement;leftParenthesesIndices;loadCompletions;completionStopCharacters;usesSuggestionBuilder;elementInternal;boundOnKeyDown;boundOnInput;boundOnMouseWheel;boundClearAutocomplete;contentElement;suggestBox;isEditing;focusRestorer;blurListener;oldTabIndex;completeTimeout;disableDefaultSuggestionForEmptyInputInternal;jslogContext=void 0;constructor(){super(),this.proxyElementDisplay="inline-block",this.autocompletionTimeout=hn,this.titleInternal="",this.queryRange=null,this.previousText="",this.currentSuggestion=null,this.completionRequestId=0,this.ghostTextElement=document.createElement("span"),this.ghostTextElement.classList.add("auto-complete-text"),this.ghostTextElement.setAttribute("contenteditable","false"),this.leftParenthesesIndices=[],te(this.ghostTextElement)}initialize(e,t,i){this.loadCompletions=e,this.completionStopCharacters=t||" =:[({;,!+-*/&|^<>.",this.usesSuggestionBuilder=i||!1}setAutocompletionTimeout(e){this.autocompletionTimeout=e}renderAsBlock(){this.proxyElementDisplay="block"}attach(e){return this.attachInternal(e)}attachAndStartEditing(e,t){const i=this.attachInternal(e);return this.startEditing(t),i}attachInternal(e){if(this.proxyElement)throw"Cannot attach an attached TextPrompt";this.elementInternal=e,this.boundOnKeyDown=this.onKeyDown.bind(this),this.boundOnInput=this.onInput.bind(this),this.boundOnMouseWheel=this.onMouseWheel.bind(this),this.boundClearAutocomplete=this.clearAutocomplete.bind(this),this.proxyElement=e.ownerDocument.createElement("span"),m.ThemeSupport.instance().appendStyle(this.proxyElement,an),this.contentElement=this.proxyElement.createChild("div","text-prompt-root"),this.proxyElement.style.display=this.proxyElementDisplay,e.parentElement&&e.parentElement.insertBefore(this.proxyElement,e),this.contentElement.appendChild(e);let t=o.textField().track({keydown:!0});return this.jslogContext&&(t=t.context(this.jslogContext)),this.elementInternal.setAttribute("jslog",`${t}`),this.elementInternal.classList.add("text-prompt"),K(this.elementInternal),he(this.elementInternal,"both"),ce(this.elementInternal,"listbox"),this.elementInternal.setAttribute("contenteditable","plaintext-only"),this.element().addEventListener("keydown",this.boundOnKeyDown,!1),this.elementInternal.addEventListener("input",this.boundOnInput,!1),this.elementInternal.addEventListener("wheel",this.boundOnMouseWheel,!1),this.elementInternal.addEventListener("selectstart",this.boundClearAutocomplete,!1),this.elementInternal.addEventListener("blur",this.boundClearAutocomplete,!1),this.suggestBox=new on(this,20),this.titleInternal&&Jt.install(this.proxyElement,this.titleInternal),this.proxyElement}element(){if(!this.elementInternal)throw new Error("Expected an already attached element!");return this.elementInternal}detach(){this.removeFromElement(),this.focusRestorer&&this.focusRestorer.restore(),this.proxyElement&&this.proxyElement.parentElement&&(this.proxyElement.parentElement.insertBefore(this.element(),this.proxyElement),this.proxyElement.remove()),delete this.proxyElement,this.element().classList.remove("text-prompt"),this.element().removeAttribute("contenteditable"),this.element().removeAttribute("role"),de(this.element()),ce(this.element(),"false")}textWithCurrentSuggestion(){const e=this.text();if(!this.queryRange||!this.currentSuggestion)return e;const t=this.currentSuggestion.text;return e.substring(0,this.queryRange.startColumn)+t+e.substring(this.queryRange.endColumn)}text(){let e=this.element().textContent||"";if(this.ghostTextElement.parentNode){const t=this.ghostTextElement.textContent||"";e=e.substring(0,e.length-t.length)}return e}setText(e){this.clearAutocomplete(),this.element().textContent=e,this.previousText=this.text(),this.element().hasFocus()&&(this.moveCaretToEndOfPrompt(),this.element().scrollIntoView())}setSelectedRange(e,t){if(e<0)throw new RangeError("Selected range start must be a nonnegative integer");const i=this.element().textContent,n=i?i.length:0;t>n&&(t=n),t<e&&(t=e);const s=this.element().childNodes[0],o=new Range;o.setStart(s,e),o.setEnd(s,t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(o))}focus(){this.element().focus()}title(){return this.titleInternal}setTitle(e){this.titleInternal=e,this.proxyElement&&Jt.install(this.proxyElement,e)}setPlaceholder(e,t){e?(this.element().setAttribute("data-placeholder",e),se(this.element(),t||e)):(this.element().removeAttribute("data-placeholder"),se(this.element(),null))}setEnabled(e){e?this.element().setAttribute("contenteditable","plaintext-only"):this.element().removeAttribute("contenteditable"),this.element().classList.toggle("disabled",!e)}removeFromElement(){this.clearAutocomplete(),this.element().removeEventListener("keydown",this.boundOnKeyDown,!1),this.element().removeEventListener("input",this.boundOnInput,!1),this.element().removeEventListener("selectstart",this.boundClearAutocomplete,!1),this.element().removeEventListener("blur",this.boundClearAutocomplete,!1),this.isEditing&&this.stopEditing(),this.suggestBox&&this.suggestBox.hide()}startEditing(e){this.isEditing=!0,this.contentElement&&this.contentElement.classList.add("text-prompt-editing"),this.focusRestorer=new Gn(this.element()),e&&(this.blurListener=e,this.element().addEventListener("blur",this.blurListener,!1)),this.oldTabIndex=this.element().tabIndex,this.element().tabIndex<0&&(this.element().tabIndex=0),this.text()||this.autoCompleteSoon()}stopEditing(){this.element().tabIndex=this.oldTabIndex,this.blurListener&&this.element().removeEventListener("blur",this.blurListener,!1),this.contentElement&&this.contentElement.classList.remove("text-prompt-editing"),delete this.isEditing}onMouseWheel(e){}onKeyDown(e){let t=!1;const i=e;if(this.isSuggestBoxVisible()&&this.suggestBox&&this.suggestBox.keyPressed(i))i.consume(!0);else{switch(i.key){case"Tab":t=this.tabKeyPressed(i);break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Home":this.clearAutocomplete();break;case"PageDown":case"ArrowRight":case"ArrowDown":case"End":this.isCaretAtEndOfPrompt()?t=this.acceptAutoComplete():this.clearAutocomplete();break;case"Escape":this.isSuggestBoxVisible()&&(this.clearAutocomplete(),t=!0);break;case" ":!i.ctrlKey||i.metaKey||i.altKey||i.shiftKey||(this.autoCompleteSoon(!0),t=!0)}"Enter"===i.key&&i.preventDefault(),t&&i.consume(!0)}}acceptSuggestionOnStopCharacters(e){if(!(this.currentSuggestion&&this.queryRange&&1===e.length&&this.completionStopCharacters&&this.completionStopCharacters.includes(e)))return!1;const t=this.text().substring(this.queryRange.startColumn,this.queryRange.endColumn);return!(!t||!this.currentSuggestion.text.startsWith(t+e))&&(this.queryRange.endColumn+=1,this.acceptAutoComplete())}onInput(e){const t=e;let n=this.text();const s=t.data;"insertFromPaste"===t.inputType&&n.includes("\n")&&(n=i.StringUtilities.stripLineBreaks(n),this.setText(n));const o=this.getCaretPosition();if(")"===s&&o>=0&&this.leftParenthesesIndices.length>0){if(")"===n[o]&&this.tryMatchingLeftParenthesis(o))return n=n.substring(0,o)+n.substring(o+1),void this.setText(n)}if(s&&!this.acceptSuggestionOnStopCharacters(s)){const e=n.startsWith(this.previousText)||this.previousText.startsWith(n);this.queryRange&&e&&(this.queryRange.endColumn+=n.length-this.previousText.length)}this.refreshGhostText(),this.previousText=n,this.dispatchEventToListeners("TextChanged"),this.autoCompleteSoon()}acceptAutoComplete(){let e=!1;return this.isSuggestBoxVisible()&&this.suggestBox&&(e=this.suggestBox.acceptSuggestion()),e||(e=this.acceptSuggestionInternal()),this.usesSuggestionBuilder&&e&&this.autoCompleteSoon(),e}clearAutocomplete(){const e=this.textWithCurrentSuggestion();this.isSuggestBoxVisible()&&this.suggestBox&&this.suggestBox.hide(),this.clearAutocompleteTimeout(),this.queryRange=null,this.refreshGhostText(),e!==this.textWithCurrentSuggestion()&&this.dispatchEventToListeners("TextChanged")}refreshGhostText(){this.currentSuggestion&&this.currentSuggestion.hideGhostText?this.ghostTextElement.remove():this.queryRange&&this.currentSuggestion&&this.isCaretAtEndOfPrompt()&&this.currentSuggestion.text.startsWith(this.text().substring(this.queryRange.startColumn))?(this.ghostTextElement.textContent=this.currentSuggestion.text.substring(this.queryRange.endColumn-this.queryRange.startColumn),this.element().appendChild(this.ghostTextElement)):this.ghostTextElement.remove()}clearAutocompleteTimeout(){this.completeTimeout&&(clearTimeout(this.completeTimeout),delete this.completeTimeout),this.completionRequestId++}autoCompleteSoon(e){const t=this.isSuggestBoxVisible()||e;this.completeTimeout||(this.completeTimeout=window.setTimeout(this.complete.bind(this,e),t?0:this.autocompletionTimeout))}async complete(e){this.clearAutocompleteTimeout();const t=this.element().getComponentSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0);let s;if((e||this.isCaretAtEndOfPrompt()||this.isSuggestBoxVisible())&&t.isCollapsed||(s=!0),s)return void this.clearAutocomplete();const o=i.DOMUtilities.rangeOfWord(n.startContainer,n.startOffset,this.completionStopCharacters,this.element(),"backward"),r=o.cloneRange();r.collapse(!0),r.setStartBefore(this.element());const a=++this.completionRequestId,l=await this.loadCompletions.call(null,r.toString(),o.toString(),Boolean(e));this.completionsReady(a,t,o,Boolean(e),l)}disableDefaultSuggestionForEmptyInput(){this.disableDefaultSuggestionForEmptyInputInternal=!0}boxForAnchorAtStart(e,t){const i=e.getRangeAt(0).cloneRange(),n=document.createElement("span");n.textContent="",t.insertNode(n);const s=n.boxInWindow(window);return n.remove(),e.removeAllRanges(),e.addRange(i),s}additionalCompletions(e){return[]}completionsReady(e,t,i,n,s){if(this.completionRequestId!==e)return;const o=i.toString(),a=new Set;if(s=s.filter((e=>!a.has(e.text)&&Boolean(a.add(e.text)))),(o||n)&&(s=o?s.concat(this.additionalCompletions(o)):this.additionalCompletions(o).concat(s)),!s.length)return void this.clearAutocomplete();const l=t.getRangeAt(0),h=document.createRange();if(h.setStart(i.startContainer,i.startOffset),h.setEnd(l.endContainer,l.endOffset),o+l.toString()!==h.toString())return;const d=document.createRange();d.setStart(this.element(),0),d.setEnd(h.startContainer,h.startOffset),this.queryRange=new r.TextRange.TextRange(0,d.toString().length,0,d.toString().length+h.toString().length);const c=!this.disableDefaultSuggestionForEmptyInputInternal||Boolean(this.text());this.suggestBox&&this.suggestBox.updateSuggestions(this.boxForAnchorAtStart(t,h),s,c,!this.isCaretAtEndOfPrompt(),this.text())}applySuggestion(e,t){this.currentSuggestion=e,this.refreshGhostText(),t&&this.dispatchEventToListeners("TextChanged")}acceptSuggestion(){this.acceptSuggestionInternal()}acceptSuggestionInternal(){if(!this.queryRange)return!1;const e=this.currentSuggestion?this.currentSuggestion.text.length:0,t=this.currentSuggestion?this.currentSuggestion.selectionRange:null,i=t?t.endColumn:e,n=t?t.startColumn:e;return this.element().textContent=this.textWithCurrentSuggestion(),this.setDOMSelection(this.queryRange.startColumn+n,this.queryRange.startColumn+i),this.updateLeftParenthesesIndices(),this.clearAutocomplete(),this.dispatchEventToListeners("TextChanged"),!0}ariaControlledBy(){return this.element()}setDOMSelection(e,t){this.element().normalize();const i=this.element().childNodes[0];if(!i||i===this.ghostTextElement)return;const n=document.createRange();n.setStart(i,e),n.setEnd(i,t);const s=this.element().getComponentSelection();s&&(s.removeAllRanges(),s.addRange(n))}isSuggestBoxVisible(){return void 0!==this.suggestBox&&this.suggestBox.visible()}isCaretInsidePrompt(){const e=this.element().getComponentSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;return e.getRangeAt(0).startContainer.isSelfOrDescendant(this.element())}isCaretAtEndOfPrompt(){const e=this.element().getComponentSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;const t=e.getRangeAt(0);let i=t.startContainer;if(!i.isSelfOrDescendant(this.element()))return!1;if(this.ghostTextElement.isAncestor(i))return!0;if(i.nodeType===Node.TEXT_NODE&&t.startOffset<(i.nodeValue||"").length)return!1;let n=!1;for(;i;){if(i.nodeType===Node.TEXT_NODE&&i.nodeValue&&i.nodeValue.length){if(n&&!this.ghostTextElement.isAncestor(i))return!1;n=!0}i=i.traverseNextNode(this.elementInternal)}return!0}moveCaretToEndOfPrompt(){const e=this.element().getComponentSelection(),t=document.createRange();let i=this.element();for(;i.lastChild;)i=i.lastChild;let n=0;if(i.nodeType===Node.TEXT_NODE){n=(i.textContent||"").length}t.setStart(i,n),t.setEnd(i,n),e&&(e.removeAllRanges(),e.addRange(t))}getCaretPosition(){if(!this.element().hasFocus())return-1;const e=this.element().getComponentSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return-1;const t=e.getRangeAt(0);return t.startOffset!==t.endOffset?-1:t.startOffset}tabKeyPressed(e){return this.acceptAutoComplete()}proxyElementForTests(){return this.proxyElement||null}tryMatchingLeftParenthesis(e){const t=this.leftParenthesesIndices;if(0===t.length||e<0)return!1;for(let i=t.length-1;i>=0;--i)if(t[i]<e)return t.splice(i,1),!0;return!1}updateLeftParenthesesIndices(){const e=this.text(),t=this.leftParenthesesIndices=[];for(let i=0;i<e.length;++i)"("===e[i]&&t.push(i)}suggestBoxForTest(){return this.suggestBox}}const hn=250;var dn=Object.freeze({__proto__:null,TextPrompt:ln}),cn={cssContent:':host{flex:none;padding:0 2px;--toolbar-height:26px}.toolbar-shadow{position:relative;white-space:nowrap;height:var(--toolbar-height);overflow:hidden;display:flex;flex:none;align-items:center;z-index:0}.toolbar-shadow.wrappable{flex-wrap:wrap;overflow:visible}.toolbar-shadow.toolbar-grow-vertical{height:initial}.toolbar-shadow.vertical{flex-direction:column;height:auto;align-items:flex-start}.toolbar-item{position:relative;display:flex;background-color:transparent;flex:none;align-items:center;justify-content:center;padding:0;height:var(--toolbar-height);border:none;white-space:pre;overflow:hidden;max-width:100%}devtools-adorner.fix-perf-icon{--override-adorner-text-color:transparent;--override-adorner-border-color:transparent;--override-adorner-background-color:transparent}.toolbar-item,\n.toolbar-item .devtools-link{color:var(--icon-default)}.toolbar-shadow.vertical .toolbar-item{height:auto;min-height:var(--toolbar-height);white-space:normal}devtools-issue-counter.toolbar-item{margin-top:-4px;padding-left:1px}devtools-issue-counter.main-toolbar{margin-top:1px;margin-left:1px;margin-right:1px}.toolbar-dropdown-arrow{pointer-events:none;flex:none;margin-left:-4px}.toolbar-button.dark-text .toolbar-dropdown-arrow{color:var(--sys-color-on-surface)}select.toolbar-item:disabled + .toolbar-dropdown-arrow{opacity:50%}.toolbar-button{white-space:nowrap;overflow:hidden;min-width:28px;background:transparent;border-radius:0}.toolbar-item-search{min-width:5.2em;max-width:300px;flex:1 1 auto;justify-content:start;overflow:revert}.toolbar-text{margin:0 5px;flex:none;color:var(--ui-text)}.toolbar-text:empty{margin:0}.toolbar-has-dropdown{justify-content:space-between;padding:0 3px 0 5px;border:1px solid transparent}.toolbar-has-dropdown-shrinkable{flex-shrink:1}.toolbar-has-dropdown .toolbar-text{margin:0 4px 0 0;text-overflow:ellipsis;flex:auto;overflow:hidden;text-align:right}.toolbar-render-as-links *{font-weight:initial;color:var(--sys-color-primary);text-decoration:underline;cursor:pointer}.toolbar-render-as-links button{height:15px;margin:2px}.toolbar-render-as-links button:focus-visible{outline:auto 5px -webkit-focus-ring-color}:not(.toolbar-render-as-links) .toolbar-button:focus-visible::before{position:absolute;top:2px;bottom:2px;left:2px;right:2px;background-color:var(--sys-color-state-focus-highlight);border-radius:2px;content:"";z-index:-1}.toolbar-glyph{flex:none}.toolbar-button:disabled{opacity:50%}.toolbar-button.close-devtools{position:absolute;right:0}:host-context(.right) .toolbar-button.main-menu,\n:host-context(.left) .toolbar-button.main-menu,\n:host-context(.bottom) .toolbar-button.main-menu{margin-inline-end:28px}.toolbar-button.copied-to-clipboard::after{content:attr(data-content);position:fixed;margin-top:calc(2 * var(--toolbar-height));padding:3px 5px;color:var(--sys-color-token-subtle);background:var(--sys-color-cdt-base-container);animation:2s fade-out;font-weight:normal;border:1px solid var(--sys-color-divider);border-radius:3px}@keyframes fade-out{from{opacity:100%}to{opacity:0%}}.toolbar-button.toolbar-state-on .toolbar-glyph{color:var(--icon-toggled)}.toolbar-state-on.toolbar-toggle-with-dot .toolbar-text::after{content:"";position:absolute;bottom:2px;background-color:var(--sys-color-primary-bright);width:4.5px;height:4.5px;border:2px solid var(--override-toolbar-background-color,--sys-color-cdt-base-container);border-radius:50%;right:0}.toolbar-button.toolbar-state-on.toolbar-toggle-with-red-color .toolbar-glyph,\n.toolbar-button.toolbar-state-off.toolbar-default-with-red-color .toolbar-glyph{color:var(--icon-error)!important}.toolbar-button:not(.toolbar-has-glyph):not(.toolbar-has-dropdown):not(.largeicon-menu):not(.toolbar-button-secondary){font-weight:bold}.toolbar-button.dark-text .toolbar-text{color:var(--sys-color-on-surface)!important}.toolbar-button.toolbar-state-on .toolbar-text{color:var(--sys-color-primary)}.toolbar-button.toolbar-state-on:enabled:active .toolbar-text{color:var(--sys-color-primary-bright)}.toolbar-blue-on-hover .toolbar-button:not(.toolbar-state-on):enabled:hover:not(:active){background-color:var(--sys-color-state-hover-on-subtle)}.toolbar-blue-on-hover .toolbar-button:not(.toolbar-state-on):enabled:active:hover{background-color:var(--sys-color-state-hover-on-subtle)}.toolbar-toggled-gray:not(.toolbar-render-as-links) .toolbar-button:not(.toolbar-has-glyph):not(.toolbar-has-dropdown):not(.largeicon-menu):hover{background-color:var(--sys-color-state-hover-on-subtle)}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-glyph{color:var(--sys-color-on-surface)}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-text{color:var(--sys-color-on-surface)}.toolbar-blue-on-hover .toolbar-button:not(.toolbar-state-on):enabled:hover .toolbar-text{color:var(--sys-color-on-surface)}.toolbar-button.toolbar-state-on:enabled:hover:not(:active) .toolbar-glyph{color:var(--sys-color-primary)}.toolbar-button.toolbar-state-on:enabled:hover:not(:active) .toolbar-text{color:var(--sys-color-primary)}.toolbar-toggled-gray .toolbar-button.toolbar-state-on{background-color:var(--sys-color-neutral-container)!important}.toolbar-item.checkbox{padding:0 5px 0 2px}.toolbar-select-container{display:inline-flex;flex-shrink:0;margin-right:6px}select.toolbar-item{min-width:38px;appearance:none;border:1px solid transparent;padding:0 13px 0 5px;margin-right:-17px;position:relative;height:22px;margin-top:2px;margin-bottom:2px}select.toolbar-item:disabled{opacity:50%}button.toolbar-item:focus-visible,\nselect.toolbar-item:focus-visible{background:var(--sys-color-state-hover-on-subtle);border-radius:2px}select.toolbar-item:focus-visible > *{background:var(--sys-color-cdt-base-container);border-radius:7px}.toolbar-input{width:120px;height:19px;padding:4px 3px 3px;margin:1px 3px;background:var(--sys-color-cdt-base-container);border:1px solid var(--sys-color-neutral-outline);border-radius:4px;min-width:35px;&.focused,\n &:not(.toolbar-input-empty){border-color:var(--sys-color-state-focus-ring)}&:hover:not(.focused){background:var(--sys-color-state-hover-on-subtle)}& > input{border:none;flex-grow:1}}.toolbar-input-clear-button{opacity:70%;flex-basis:13px;flex-shrink:0;height:16px}.toolbar-input-clear-button > .search-cancel-button{display:block}.toolbar-input-clear-button:hover{opacity:99%}.toolbar-input-empty .toolbar-input-clear-button{display:none}.toolbar-prompt-proxy{flex:1}.toolbar-input-prompt{flex:1;overflow:hidden;white-space:nowrap;cursor:auto;color:var(--sys-color-on-surface)}.toolbar-divider{background-color:var(--sys-color-on-base-divider);width:1px;margin:5px 4px;height:16px}.toolbar-spacer{flex:auto}.long-click-glyph{position:absolute;top:2px;left:3px}.toolbar-button.emulate-active{background-color:var(--sys-color-surface-variant)}.toolbar-shadow.floating{flex-direction:column;height:auto;background-color:var(--sys-color-cdt-base-container);border:1px solid var(--sys-color-divider);margin-top:-1px;width:28px;left:-2px}.toolbar-shadow:not(.floating) .toolbar-item:last-child:not(:first-child, .toolbar-select-container){flex-shrink:1;justify-content:left}.toolbar-shadow:not(.floating) .toolbar-button.toolbar-item:last-child:not(:first-child, .toolbar-select-container){justify-content:center;margin-right:2px}input[is="history-input"]{margin:0 1px;border:1px solid var(--sys-color-neutral-outline);border-radius:4px;line-height:16px;padding:1px 1px 1px 3px;color:var(--sys-color-on-surface)}input[is="history-input"]:focus,\ninput[is="history-input"]:not(:placeholder-shown){border-color:var(--sys-color-state-focus-ring)}input[is="history-input"]:hover:not(:focus){background-color:var(--sys-color-state-hover-on-subtle)}.toolbar-item.highlight::before{content:"";position:absolute;top:2px;left:2px;right:2px;bottom:2px;border-radius:2px;background:var(--sys-color-neutral-container);z-index:-1}.toolbar-item.highlight:focus-visible{background:var(--sys-color-tonal-container);& > .title{color:var(--sys-color-on-tonal-container)}}devtools-icon.leading-issue-icon{margin:0 7px}@media (forced-colors: active){.toolbar-button:disabled{opacity:100%;color:Graytext}.toolbar-item,\n .toolbar-text{color:ButtonText}.toolbar-button:disabled .toolbar-text{color:Graytext}select.toolbar-item:disabled,\n select.toolbar-item:disabled + .toolbar-dropdown-arrow{opacity:100%;color:Graytext}.toolbar-button.toolbar-state-on .toolbar-glyph{forced-color-adjust:none;color:Highlight}.toolbar-button.toolbar-state-on .toolbar-text{forced-color-adjust:none;color:Highlight}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-text,\n :not(.toolbar-render-as-links) .toolbar-button:enabled:focus:not(:active) .toolbar-text{color:HighlightText}.toolbar-button:disabled devtools-icon{color:GrayText}:not(.toolbar-render-as-links) .toolbar-button:disabled .toolbar-glyph{color:GrayText}.toolbar-button:enabled.hover:not(:active) .toolbar-glyph{forced-color-adjust:none;color:Highlight}.toolbar-button:focus,\n .toolbar-button:hover:enabled,\n .toolbar-toggled-gray:not(.toolbar-render-as-links) .toolbar-button:not(.toolbar-has-glyph):not(.toolbar-has-dropdown):not(.largeicon-menu):hover{forced-color-adjust:none;background-color:Highlight}:not(.toolbar-render-as-links) .toolbar-button:enabled:hover .toolbar-glyph,\n :not(.toolbar-render-as-links) .toolbar-button:enabled:focus .toolbar-glyph,\n :not(.toolbar-render-as-links) .toolbar-button:enabled:hover:not(:active) .toolbar-glyph,\n .toolbar-button:enabled:hover devtools-icon,\n .toolbar-button:enabled:focus devtools-icon{color:HighlightText}.toolbar-input{forced-color-adjust:none;background:canvas;box-shadow:var(--legacy-focus-ring-inactive-shadow)}.toolbar-input.focused,\n .toolbar-input:not(.toolbar-input-empty){forced-color-adjust:none;background:canvas;box-shadow:var(--legacy-focus-ring-active-shadow)}.toolbar-input:hover{box-shadow:var(--legacy-focus-ring-active-shadow)}.toolbar-item .devtools-link{color:linktext}.toolbar-has-dropdown{forced-color-adjust:none;background:ButtonFace;color:ButtonText}}[aria-label="[FB-only] Send feedback"]{height:20px;padding:0 4px;border-radius:4px;background:color-mix(in srgb,var(--color-green) 80%,transparent)}[aria-label="[FB-only] Send feedback"]:hover{background:color-mix(in srgb,var(--color-green) 90%,transparent)}[aria-label="[FB-only] Send feedback"] .toolbar-text,\n[aria-label="[FB-only] Send feedback"] .toolbar-glyph{color:white!important}.fusebox-connection-status{margin:4px;height:20px;padding:0 4px;border-radius:4px;background:color-mix(in srgb,var(--color-red) 80%,transparent)}.fusebox-connection-status:hover{background:color-mix(in srgb,var(--color-red) 90%,transparent)}.fusebox-connection-status .toolbar-text,\n.fusebox-connection-status .toolbar-glyph{color:white!important}.toolbar-item.open-in-external-editor-button{background-color:transparent;border:none}.toolbar-item.open-in-external-editor-button:hover{background-color:var(--sys-color-state-hover-on-subtle)}.open-in-external-editor-adorner{background-repeat:no-repeat;background-origin:content-box;background-size:contain;padding:4px;width:28px;height:28px;margin-right:-4px}'};const un={pressed:"pressed",notPressed:"not pressed",clearInput:"Clear input"},mn=t.i18n.registerUIStrings("ui/legacy/Toolbar.ts",un),pn=t.i18n.getLocalizedString.bind(void 0,mn);class gn{items;element;enabled;shadowRoot;contentElement;compactLayout=!1;constructor(e,t){this.items=[],this.element=t?t.createChild("div"):document.createElement("div"),this.element.className=e,this.element.classList.add("toolbar"),this.enabled=!0,this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:cn,delegatesFocus:void 0}),this.contentElement=this.shadowRoot.createChild("div","toolbar-shadow")}hasCompactLayout(){return this.compactLayout}registerCSSFiles(e){this.shadowRoot.adoptedStyleSheets=this.shadowRoot.adoptedStyleSheets.concat(e)}setCompactLayout(e){if(this.compactLayout!==e){this.compactLayout=e;for(const t of this.items)t.setCompactLayout(e)}}static createLongPressActionButton(e,t,i){const n=gn.createActionButton(e),s=gn.createActionButton(e);let o=null,r=null,l=null;return e.addEventListener("Toggled",h),h(),n;function h(){const s=e.toggled()?t||null:i||null;s&&s.length?o||(o=new is(n.element,d),l=a.Icon.create("triangle-bottom-right","long-click-glyph"),n.element.appendChild(l),r=s):o&&(o.dispose(),o=null,l&&l.remove(),l=null,r=null)}function d(){let e=r?r.slice():[];e.push(s);const t=n.element.ownerDocument;t.documentElement.addEventListener("mouseup",(function n(s){if(1!==s.which)return;i.hide(),t.documentElement.removeEventListener("mouseup",n,!1);for(let t=0;t<e.length;++t)if(e[t].element.classList.contains("emulate-active")){e[t].element.classList.remove("emulate-active"),e[t].clicked(s);break}}),!1);const i=new Ts;i.setPointerEventsBehavior("BlockedByGlassPane"),i.show(t);const o=new gn("fill",i.contentElement);o.contentElement.classList.add("floating");const a=n.element.boxInWindow().relativeToElement(Ts.container(t)),l=a.y+26*e.length<t.documentElement.offsetHeight;l&&(e=e.reverse()),o.element.style.height=26*e.length+"px",o.element.style.top=l?a.y-5+"px":a.y-26*(e.length-1)-6+"px",o.element.style.left=a.x-5+"px";for(let t=0;t<e.length;++t)e[t].element.addEventListener("mousemove",d,!1),e[t].element.addEventListener("mouseout",c,!1),o.appendToolbarItem(e[t]);const h=l?0:e.length-1;function d(e){if(1===e.which&&e.target instanceof HTMLElement){e.target.enclosingNodeOrSelfWithClass("toolbar-item").classList.add("emulate-active")}}function c(e){if(1===e.which&&e.target instanceof HTMLElement){e.target.enclosingNodeOrSelfWithClass("toolbar-item").classList.remove("emulate-active")}}e[h].element.classList.add("emulate-active")}}static createActionButton(e,t=bn){const i=e.toggleable()?function(){const t=new xn(e.title(),e.icon(),e.toggledIcon(),e.id());return t.setToggleWithRedColor(e.toggleWithRedColor()),e.addEventListener("Toggled",i),i(),t;function i(){t.setToggled(e.toggled()),e.title()&&(t.setTitle(e.title()),Jt.installWithActionBinding(t.element,e.title(),e.id()))}}():function(){const t=new wn(e.title(),e.icon(),void 0,e.id());e.title()&&Jt.installWithActionBinding(t.element,e.title(),e.id());return t}();t.showLabel&&i.setText(t.label?.()||e.title());let n=t=>{e.execute()};if(t.userActionCode){const i=t.userActionCode;n=()=>{s.userMetrics.actionTaken(i),e.execute()}}return i.addEventListener("Click",n,e),e.addEventListener("Enabled",(function(e){i.setEnabled(e.data)})),i.setEnabled(e.enabled()),i}static createActionButtonForId(e,t){const i=M.instance().getAction(e);return gn.createActionButton(i,t)}gripElementForResize(){return this.contentElement}makeWrappable(e){this.contentElement.classList.add("wrappable"),e&&this.contentElement.classList.add("toolbar-grow-vertical")}makeVertical(){this.contentElement.classList.add("vertical")}makeBlueOnHover(){this.contentElement.classList.add("toolbar-blue-on-hover")}makeToggledGray(){this.contentElement.classList.add("toolbar-toggled-gray")}renderAsLinks(){this.contentElement.classList.add("toolbar-render-as-links")}empty(){return!this.items.length}setEnabled(e){this.enabled=e;for(const e of this.items)e.applyEnabledState(this.enabled&&e.enabled)}appendToolbarItem(e){this.items.push(e),e.toolbar=this,e.setCompactLayout(this.hasCompactLayout()),this.enabled||e.applyEnabledState(!1),this.contentElement.appendChild(e.element),this.hideSeparatorDupes()}appendSeparator(){this.appendToolbarItem(new yn)}appendSpacer(){this.appendToolbarItem(new yn(!0))}appendText(e){this.appendToolbarItem(new vn(e))}removeToolbarItem(e){const t=[];for(const i of this.items)i===e?i.element.remove():t.push(i);this.items=t}removeToolbarItems(){for(const e of this.items)e.toolbar=null;this.items=[],this.contentElement.removeChildren()}setColor(e){const t=document.createElement("style");t.textContent=".toolbar-glyph { background-color: "+e+" !important }",this.shadowRoot.appendChild(t)}setToggledColor(e){const t=document.createElement("style");t.textContent=".toolbar-button.toolbar-state-on .toolbar-glyph { background-color: "+e+" !important }",this.shadowRoot.appendChild(t)}hideSeparatorDupes(){if(!this.items.length)return;let e,t=!1,i=!1;for(let n=0;n<this.items.length;++n)this.items[n]instanceof yn?(this.items[n].setVisible(!t),t=!0,e=this.items[n]):this.items[n].visible()&&(t=!1,e=null,i=!0);e&&e!==this.items[this.items.length-1]&&e.setVisible(!1),this.element.classList.toggle("hidden",null!=e&&e.visible()&&!i)}async appendItemsAtLocation(e){const t=Tn.filter((e=>n.Runtime.Runtime.isDescriptorEnabled({experiment:e.experiment,condition:e.condition})));t.sort(((e,t)=>(e.order||0)-(t.order||0)));const i=t.filter((t=>t.location===e)),s=await Promise.all(i.map((e=>{const{separator:t,actionId:i,showLabel:n,label:s,loadItem:o}=e;if(t)return new yn;if(i)return gn.createActionButtonForId(i,{label:s,showLabel:Boolean(n),userActionCode:void 0});if(!o)throw new Error("Could not load a toolbar item registration with no loadItem function");return o().then((e=>e.item()))})));for(const e of s)e&&this.appendToolbarItem(e)}}const bn={showLabel:!1,userActionCode:void 0};class fn extends e.ObjectWrapper.ObjectWrapper{element;visibleInternal;enabled;toolbar;title;constructor(e){super(),this.element=e,this.element.classList.add("toolbar-item"),this.visibleInternal=!0,this.enabled=!0,this.toolbar=null}setTitle(e,t=void 0){this.title!==e&&(this.title=e,be(this.element,e),void 0===t?Jt.install(this.element,e):Jt.installWithActionBinding(this.element,e,t))}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.applyEnabledState(this.enabled&&(!this.toolbar||this.toolbar.enabled)))}applyEnabledState(e){this.element.disabled=!e}visible(){return this.visibleInternal}setVisible(e){this.visibleInternal!==e&&(this.element.classList.toggle("hidden",!e),this.visibleInternal=e,!this.toolbar||this instanceof yn||this.toolbar.hideSeparatorDupes())}setRightAligned(e){this.element.classList.toggle("toolbar-item-right-aligned",e)}setCompactLayout(e){}}class vn extends fn{constructor(e){const t=document.createElement("div");t.classList.add("toolbar-text"),super(t),this.element.classList.add("toolbar-text"),this.setText(e||"")}text(){return this.element.textContent||""}setText(e){this.element.textContent=e}}class wn extends fn{glyphElement;textElement;text;glyph;adorner;constructor(e,t,i,n){const s=document.createElement("button");s.classList.add("toolbar-button"),super(s),this.element.addEventListener("click",this.clicked.bind(this),!1),this.element.addEventListener("mousedown",this.mouseDown.bind(this),!1),this.glyphElement=new a.Icon.Icon,this.glyphElement.className="toolbar-glyph hidden",this.element.appendChild(this.glyphElement),this.textElement=this.element.createChild("div","toolbar-text hidden"),this.setTitle(e),t&&this.setGlyphOrAdorner(t),this.setText(i||""),n&&this.element.setAttribute("jslog",`${o.action().track({click:!0}).context(n)}`),this.title=""}focus(){this.element.focus()}setText(e){this.text!==e&&(this.textElement.textContent=e,this.textElement.classList.toggle("hidden",!e),this.text=e)}setGlyphOrAdorner(e){e instanceof l.Adorner.Adorner?(this.adorner?this.adorner.replaceWith(e):this.element.prepend(e),this.adorner=e):this.setGlyph(e)}setGlyph(e){this.glyph!==e&&(this.glyphElement.name=e||null,this.glyphElement.classList.toggle("hidden",!e),this.element.classList.toggle("toolbar-has-glyph",Boolean(e)),this.glyph=e)}setBackgroundImage(e){this.element.style.backgroundImage="url("+e+")"}setSecondary(){this.element.classList.add("toolbar-button-secondary")}setDarkText(){this.element.classList.add("dark-text")}turnIntoSelect(e=!1){this.element.classList.add("toolbar-has-dropdown"),e&&this.element.classList.add("toolbar-has-dropdown-shrinkable");const t=a.Icon.create("triangle-down","toolbar-dropdown-arrow");this.element.appendChild(t)}clicked(e){this.enabled&&(this.dispatchEventToListeners("Click",e),e.consume())}mouseDown(e){this.enabled&&this.dispatchEventToListeners("MouseDown",e)}}class xn extends wn{toggledInternal;untoggledGlyph;toggledGlyph;constructor(e,t,i,n){super(e,t,""),this.toggledInternal=!1,this.untoggledGlyph=t,this.toggledGlyph=i,this.element.classList.add("toolbar-state-off"),ge(this.element,!1),n&&this.element.setAttribute("jslog",`${o.toggle().track({click:!0}).context(n)}`)}toggled(){return this.toggledInternal}setToggled(e){this.toggledInternal!==e&&(this.toggledInternal=e,this.element.classList.toggle("toolbar-state-on",e),this.element.classList.toggle("toolbar-state-off",!e),ge(this.element,e),this.toggledGlyph&&this.untoggledGlyph&&this.setGlyph(e?this.toggledGlyph:this.untoggledGlyph))}setDefaultWithRedColor(e){this.element.classList.toggle("toolbar-default-with-red-color",e)}setToggleWithRedColor(e){this.element.classList.toggle("toolbar-toggle-with-red-color",e)}setToggleWithDot(e){this.element.classList.toggle("toolbar-toggle-with-dot",e)}}class En extends wn{contextMenuHandler;useSoftMenu;triggerTimeout;constructor(e,t,i){super("","dots-vertical",void 0,i),i&&this.element.setAttribute("jslog",`${o.dropDown().track({click:!0}).context(i)}`),this.contextMenuHandler=e,this.useSoftMenu=Boolean(t),N(this.element)}mouseDown(e){1===e.buttons?this.triggerTimeout||(this.triggerTimeout=window.setTimeout(this.trigger.bind(this,e),200)):super.mouseDown(e)}trigger(e){delete this.triggerTimeout;const t=new Ys(e,{useSoftMenu:this.useSoftMenu,x:this.element.getBoundingClientRect().left,y:this.element.getBoundingClientRect().top+this.element.offsetHeight});this.contextMenuHandler(t),t.show()}clicked(e){this.triggerTimeout&&clearTimeout(this.triggerTimeout),this.trigger(e)}}class In extends xn{defaultTitle;setting;willAnnounceState;constructor(e,t,i,n,s){super(i,t,n,s),this.defaultTitle=i,this.setting=e,this.settingChanged(),this.setting.addChangeListener(this.settingChanged,this),this.willAnnounceState=!1}settingChanged(){const e=this.setting.get();this.setToggled(e);const t=pn(e?un.pressed:un.notPressed);this.willAnnounceState&&Se(t),this.willAnnounceState=!1,this.setTitle(this.defaultTitle)}clicked(e){this.willAnnounceState=!0,this.setting.set(!this.toggled()),super.clicked(e)}}class yn extends fn{constructor(e){const t=document.createElement("div");t.classList.add(e?"toolbar-spacer":"toolbar-divider"),super(t)}}class Sn extends fn{selectElementInternal;constructor(e,t,i,n){const s=document.createElement("span");s.classList.add("toolbar-select-container"),super(s),this.selectElementInternal=this.element.createChild("select","toolbar-item");const r=a.Icon.create("triangle-down","toolbar-dropdown-arrow");this.element.appendChild(r),e&&this.selectElementInternal.addEventListener("change",e,!1),be(this.selectElementInternal,t),super.setTitle(t),i&&this.selectElementInternal.classList.add(i),n&&this.selectElementInternal.setAttribute("jslog",`${o.dropDown().track({change:!0}).context(n)}`)}selectElement(){return this.selectElementInternal}size(){return this.selectElementInternal.childElementCount}options(){return Array.prototype.slice.call(this.selectElementInternal.children,0)}addOption(e){this.selectElementInternal.appendChild(e)}createOption(e,t){const n=this.selectElementInternal.createChild("option");n.text=e,void 0!==t&&(n.value=t);const s=t?i.StringUtilities.toKebabCase(t):void 0;return n.setAttribute("jslog",`${o.item(s).track({click:!0})}`),n}applyEnabledState(e){super.applyEnabledState(e),this.selectElementInternal.disabled=!e}removeOption(e){this.selectElementInternal.removeChild(e)}removeOptions(){this.selectElementInternal.removeChildren()}selectedOption(){return this.selectElementInternal.selectedIndex>=0?this.selectElementInternal[this.selectElementInternal.selectedIndex]:null}select(e){this.selectElementInternal.selectedIndex=Array.prototype.indexOf.call(this.selectElementInternal,e)}setSelectedIndex(e){this.selectElementInternal.selectedIndex=e}selectedIndex(){return this.selectElementInternal.selectedIndex}setMaxWidth(e){this.selectElementInternal.style.maxWidth=e+"px"}setMinWidth(e){this.selectElementInternal.style.minWidth=e+"px"}}class Cn extends fn{inputElement;constructor(e,t,i,n){super(ls.create(e)),this.element.classList.add("checkbox"),this.inputElement=this.element.checkboxElement,t&&(Jt.install(this.inputElement,t),Jt.install(this.element.textElement,t)),i&&this.inputElement.addEventListener("click",i,!1),n&&this.inputElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(n)}`)}checked(){return this.inputElement.checked}setChecked(e){this.inputElement.checked=e}applyEnabledState(e){super.applyEnabledState(e),this.inputElement.disabled=!e}setIndeterminate(e){this.inputElement.indeterminate=e}}const Tn=[];var kn=Object.freeze({__proto__:null,Toolbar:gn,ToolbarItem:fn,ToolbarItemWithCompactLayout:class extends fn{constructor(e){super(e)}setCompactLayout(e){this.dispatchEventToListeners("CompactLayoutUpdated",e)}},ToolbarText:vn,ToolbarButton:wn,ToolbarInput:class extends fn{prompt;proxyElement;constructor(e,t,i,n,s,o,r,l){const h=document.createElement("div");h.classList.add("toolbar-input"),super(h);const d=this.element.createChild("div","toolbar-input-prompt");be(d,t||e),d.addEventListener("focus",(()=>this.element.classList.add("focused"))),d.addEventListener("blur",(()=>this.element.classList.remove("focused"))),this.prompt=new ln,this.prompt.jslogContext=l,this.proxyElement=this.prompt.attach(d),this.proxyElement.classList.add("toolbar-prompt-proxy"),this.proxyElement.addEventListener("keydown",(e=>this.onKeydownCallback(e))),this.prompt.initialize(o||(()=>Promise.resolve([]))," ",r),s&&this.prompt.setTitle(s),this.prompt.setPlaceholder(e,t),this.prompt.addEventListener("TextChanged",this.onChangeCallback.bind(this)),i&&(this.element.style.flexGrow=String(i)),n&&(this.element.style.flexShrink=String(n));const c=this.element.createChild("div","toolbar-input-clear-button");c.title=un.clearInput;const u=new a.Icon.Icon;u.data={color:"var(--icon-default)",width:"16px",height:"16px",iconName:"cross-circle-filled"},u.classList.add("search-cancel-button"),c.appendChild(u),c.addEventListener("click",(()=>{this.setValue("",!0),this.prompt.focus()})),this.updateEmptyStyles()}applyEnabledState(e){this.prompt.setEnabled(e)}setValue(e,t){this.prompt.setText(e),t&&this.onChangeCallback(),this.updateEmptyStyles()}value(){return this.prompt.textWithCurrentSuggestion()}valueWithoutSuggestion(){return this.prompt.text()}onKeydownCallback(e){"Enter"===e.key&&this.prompt.text()&&this.dispatchEventToListeners("EnterPressed",this.prompt.text()),i.KeyboardUtilities.isEscKey(e)&&this.prompt.text()&&(this.setValue("",!0),e.consume(!0))}onChangeCallback(){this.updateEmptyStyles(),this.dispatchEventToListeners("TextChanged",this.prompt.text())}updateEmptyStyles(){this.element.classList.toggle("toolbar-input-empty",!this.prompt.text())}},ToolbarToggle:xn,ToolbarMenuButton:En,ToolbarSettingToggle:In,ToolbarSeparator:yn,ToolbarComboBox:Sn,ToolbarSettingComboBox:class extends Sn{optionsInternal;setting;muteSettingListener;constructor(e,t,i){super(null,i),this.optionsInternal=e,this.setting=t,this.selectElementInternal.addEventListener("change",this.valueChanged.bind(this),!1),this.setOptions(e),t.addChangeListener(this.settingChanged,this)}setOptions(e){this.optionsInternal=e,this.selectElementInternal.removeChildren();for(let t=0;t<e.length;++t){const i=e[t],n=this.createOption(i.label,i.value);this.selectElementInternal.appendChild(n),this.setting.get()===i.value&&this.setSelectedIndex(t)}}value(){return this.optionsInternal[this.selectedIndex()].value}settingChanged(){if(this.muteSettingListener)return;const e=this.setting.get();for(let t=0;t<this.optionsInternal.length;++t)if(e===this.optionsInternal[t].value){this.setSelectedIndex(t);break}}valueChanged(e){const t=this.optionsInternal[this.selectedIndex()];this.muteSettingListener=!0,this.setting.set(t.value),this.muteSettingListener=!1}},ToolbarCheckbox:Cn,ToolbarSettingCheckbox:class extends Cn{constructor(e,t,i){super(i||e.title()||"",t,void 0,e.name),$i(this.inputElement,e)}},registerToolbarItem:function(e){Tn.push(e)}});const Mn={openInNewTab:"Open in new tab",copyLinkAddress:"Copy link address",copyFileName:"Copy file name",anotherProfilerIsAlreadyActive:"Another profiler is already active",promiseResolvedAsync:"Promise resolved (async)",promiseRejectedAsync:"Promise rejected (async)",sAsync:"{PH1} (async)",asyncCall:"Async Call",anonymous:"(anonymous)",close:"Close",ok:"OK",cancel:"Cancel"},Ln=t.i18n.registerUIStrings("ui/legacy/UIUtils.ts",Mn),Pn=t.i18n.getLocalizedString.bind(void 0,Ln),Dn="highlighted-search-result";function An(e,t,i,n,s,o,r){let a;e.addEventListener("pointerdown",(function(o){const l=new Bn,h=()=>l.elementDragStart(e,t,i,n,s,o);r?a=window.setTimeout(h,r):h()}),!1),r&&e.addEventListener("pointerup",(function(){a&&window.clearTimeout(a),a=null}),!1),null!==o&&(e.style.cursor=o||s||"")}function Rn(e,t,i,n,s,o){(new Bn).elementDragStart(e,t,i,n,s,o)}class Bn{glassPaneInUse;elementDraggingEventListener;elementEndDraggingEventListener;dragEventsTargetDocument;dragEventsTargetDocumentTop;restoreCursorAfterDrag;constructor(){this.elementDragMove=this.elementDragMove.bind(this),this.elementDragEnd=this.elementDragEnd.bind(this),this.mouseOutWhileDragging=this.mouseOutWhileDragging.bind(this)}createGlassPane(){this.glassPaneInUse=!0,Bn.glassPaneUsageCount++||(Bn.glassPane=new Ts,Bn.glassPane.setPointerEventsBehavior("BlockedByGlassPane"),Bn.documentForMouseOut&&Bn.glassPane.show(Bn.documentForMouseOut))}disposeGlassPane(){this.glassPaneInUse&&(this.glassPaneInUse=!1,--Bn.glassPaneUsageCount||(Bn.glassPane&&(Bn.glassPane.hide(),Bn.glassPane=null),Bn.documentForMouseOut=null,Bn.rootForMouseOut=null))}elementDragStart(e,t,i,n,o,r){const a=r;if(a.button||s.Platform.isMac()&&a.ctrlKey)return;if(this.elementDraggingEventListener)return;if(t&&!t(a))return;const l=a.target instanceof Node&&a.target.ownerDocument;this.elementDraggingEventListener=i,this.elementEndDraggingEventListener=n,console.assert((Bn.documentForMouseOut||l)===l,"Dragging on multiple documents."),Bn.documentForMouseOut=l,Bn.rootForMouseOut=a.target instanceof Node&&a.target.getRootNode()||null,this.dragEventsTargetDocument=l;try{l.defaultView&&l.defaultView.top&&(this.dragEventsTargetDocumentTop=l.defaultView.top.document)}catch(e){this.dragEventsTargetDocumentTop=this.dragEventsTargetDocument}l.addEventListener("pointermove",this.elementDragMove,!0),l.addEventListener("pointerup",this.elementDragEnd,!0),Bn.rootForMouseOut&&Bn.rootForMouseOut.addEventListener("pointerout",this.mouseOutWhileDragging,{capture:!0}),this.dragEventsTargetDocumentTop&&l!==this.dragEventsTargetDocumentTop&&this.dragEventsTargetDocumentTop.addEventListener("pointerup",this.elementDragEnd,!0);const h=e;"string"==typeof o&&(this.restoreCursorAfterDrag=function(e){l.body.style.removeProperty("cursor"),h.style.cursor=e,this.restoreCursorAfterDrag=void 0}.bind(this,h.style.cursor),h.style.cursor=o,l.body.style.cursor=o),a.preventDefault()}mouseOutWhileDragging(){this.unregisterMouseOutWhileDragging(),this.createGlassPane()}unregisterMouseOutWhileDragging(){Bn.rootForMouseOut&&Bn.rootForMouseOut.removeEventListener("pointerout",this.mouseOutWhileDragging,{capture:!0})}unregisterDragEvents(){this.dragEventsTargetDocument&&(this.dragEventsTargetDocument.removeEventListener("pointermove",this.elementDragMove,!0),this.dragEventsTargetDocument.removeEventListener("pointerup",this.elementDragEnd,!0),this.dragEventsTargetDocumentTop&&this.dragEventsTargetDocument!==this.dragEventsTargetDocumentTop&&this.dragEventsTargetDocumentTop.removeEventListener("pointerup",this.elementDragEnd,!0),delete this.dragEventsTargetDocument,delete this.dragEventsTargetDocumentTop)}elementDragMove(e){1===e.buttons?this.elementDraggingEventListener&&this.elementDraggingEventListener(e)&&this.cancelDragEvents(e):this.elementDragEnd(e)}cancelDragEvents(e){this.unregisterDragEvents(),this.unregisterMouseOutWhileDragging(),this.restoreCursorAfterDrag&&this.restoreCursorAfterDrag(),this.disposeGlassPane(),delete this.elementDraggingEventListener,delete this.elementEndDraggingEventListener}elementDragEnd(e){const t=this.elementEndDraggingEventListener;this.cancelDragEvents(e),e.preventDefault(),t&&t(e)}static glassPaneUsageCount=0;static glassPane=null;static documentForMouseOut=null;static rootForMouseOut=null}function On(){if(zn.size)return!0;const e=i.DOMUtilities.deepActiveElement(document);return!!e&&(e.classList.contains("text-prompt")||"INPUT"===e.nodeName||"TEXTAREA"===e.nodeName||"true"===e.contentEditable||"plaintext-only"===e.contentEditable)}function Fn(e,t){if(t){if(zn.has(e))return!1;e.classList.add("being-edited"),zn.add(e)}else{if(!zn.has(e))return!1;e.classList.remove("being-edited"),zn.delete(e)}return!0}const zn=new Set,Wn=/^(-?(?:\d+(?:\.\d+)?|\.\d+))$/,Hn=" \t\n\"':;,/()";function Nn(e){let t=null;if("wheel"===e.type){const i=e;i.deltaY<0||i.deltaX<0?t="Up":(i.deltaY>0||i.deltaX>0)&&(t="Down")}else{const i=e;"ArrowUp"===i.key||"PageUp"===i.key?t="Up":"ArrowDown"!==i.key&&"PageDown"!==i.key||(t="Down")}return t}function _n(e,t,i){const n=Nn(t);if(!n)return null;const s=t;let o=1;Ke.eventHasCtrlEquivalentKey(s)?o=100:s.shiftKey?o=10:s.altKey&&(o=.1),"Down"===n&&(o*=-1),i&&(o*=i);const r=Number((e+o).toFixed(6));return String(r).match(Wn)?r:null}function jn(e,t,n){let s,o,r,a=null,l=/(.*#)([\da-fA-F]+)(.*)/.exec(e);return l&&l.length?(s=l[1],o=l[3],r=function(e,t){const n=Nn(t);if(!n)return null;const s=t,o=parseInt(e,16);if(isNaN(o)||!isFinite(o))return null;const r=e.length,a=r/3;if(1!==a&&2!==a)return null;let l=0;Ke.eventHasCtrlEquivalentKey(s)&&(l+=Math.pow(16,2*a)),s.shiftKey&&(l+=Math.pow(16,a)),s.altKey&&(l+=1),0===l&&(l=1),"Down"===n&&(l*=-1);const h=Math.pow(16,r)-1;let d=i.NumberUtilities.clamp(o+l,0,h).toString(16).toUpperCase();for(let e=0,t=r-d.length;e<t;++e)d="0"+d;return d}(l[2],t),null!==r&&(a=s+r+o)):(l=/(.*?)(-?(?:\d+(?:\.\d+)?|\.\d+))(.*)/.exec(e),l&&l.length&&(s=l[1],o=l[3],r=_n(parseFloat(l[2]),t),null!==r&&(a=n?n(s,r,o):s+r+o))),a}function Vn(e){const t="ArrowUp"===e.key||"ArrowDown"===e.key||"wheel"===e.type,i="PageUp"===e.key||"PageDown"===e.key;return t||i}function Un(){return Pn(Mn.openInNewTab)}function Kn(){return Pn(Mn.copyLinkAddress)}function qn(e,t){t.target instanceof Window&&t.target.document.nodeType===Node.DOCUMENT_NODE&&e.body.classList.remove("inactive")}function $n(e,t){t.target instanceof Window&&t.target.document.nodeType===Node.DOCUMENT_NODE&&e.body.classList.add("inactive")}class Gn{element;previous;constructor(e){this.element=e,this.previous=i.DOMUtilities.deepActiveElement(e.ownerDocument),e.focus()}restore(){this.element&&(this.element.hasFocus()&&this.previous&&this.previous.focus(),this.previous=null,this.element=null)}}function Xn(e,t,i){return Yn(e,t,Dn,i)}function Yn(e,t,i,n){n=n||[];const s=[],o=e.childTextNodes(),a=o.map((function(e){return e.textContent})).join(""),l=e.ownerDocument;if(0===o.length)return s;const h=[];let d=0;for(const e of o){const t=new r.TextRange.SourceRange(d,e.textContent?e.textContent.length:0);d=t.offset+t.length,h.push(t)}let c=0;for(let e=0;e<t.length;++e){const r=t[e].offset,d=r+t[e].length;for(;c<o.length&&h[c].offset+h[c].length<=r;)c++;let u=c;for(;u<o.length&&h[u].offset+h[u].length<d;)u++;if(u===o.length)break;const m=l.createElement("span");m.className=i,m.textContent=a.substring(r,d);const p=o[u],g=p.textContent||"";if(p.textContent=g.substring(d-h[u].offset),n.push({node:p,type:"changed",oldText:g,newText:p.textContent,nextSibling:void 0,parent:void 0}),c===u&&p.parentElement){p.parentElement.insertBefore(m,p),n.push({node:m,type:"added",nextSibling:p,parent:p.parentElement,oldText:void 0,newText:void 0}),s.push(m);const e=l.createTextNode(g.substring(0,r-h[c].offset));p.parentElement.insertBefore(e,m),n.push({node:e,type:"added",nextSibling:m,parent:p.parentElement,oldText:void 0,newText:void 0})}else{const e=o[c],t=e.textContent||"",i=e.nextSibling;e.parentElement&&(e.parentElement.insertBefore(m,i),n.push({node:m,type:"added",nextSibling:i||void 0,parent:e.parentElement,oldText:void 0,newText:void 0}),s.push(m)),e.textContent=t.substring(0,r-h[c].offset),n.push({node:e,type:"changed",oldText:t,newText:e.textContent,nextSibling:void 0,parent:void 0});for(let e=c+1;e<u;e++){const t=o[e],i=t.textContent;t.textContent="",n.push({node:t,type:"changed",oldText:i||void 0,newText:t.textContent,nextSibling:void 0,parent:void 0})}}c=u,h[c].offset=d,h[c].length=p.textContent.length}return s}function Qn(e,t){const i=e.parentElement,n=e.nextSibling;(t=t||e.ownerDocument.body).appendChild(e),e.positionAt(0,0);const s=e.getBoundingClientRect();return e.positionAt(void 0,void 0),i?i.insertBefore(e,n):e.remove(),new _e(s.width,s.height)}class Zn{handlers;autoInvoke;constructor(e){this.handlers=null,this.autoInvoke=e}add(e,t){this.handlers||(this.handlers=new Map,this.autoInvoke&&this.scheduleInvoke());let i=this.handlers.get(e);i||(i=new Set,this.handlers.set(e,i)),i.add(t)}scheduleInvoke(){this.handlers&&requestAnimationFrame(this.invoke.bind(this))}invoke(){const e=this.handlers;if(this.handlers=null,e)for(const[t,i]of e)for(const e of i)e.call(t)}}let Jn=0,es=null;function ts(e,t){es||(es=new Zn(!0)),es.add(e,t)}class is{element;callback;editKey;longClickData;longClickInterval;constructor(e,t,n=(e=>i.KeyboardUtilities.isEnterOrSpaceKey(e))){this.element=e,this.callback=t,this.editKey=n,this.enable()}reset(){this.longClickInterval&&(clearInterval(this.longClickInterval),delete this.longClickInterval)}enable(){if(this.longClickData)return;const e=function(e){if(this.editKey(e)){const t=this.callback;this.longClickInterval=window.setTimeout(t.bind(null,e),is.TIME_MS)}}.bind(this),t=function(e){this.editKey(e)&&this.reset()}.bind(this),i=function(e){if(1!==e.which)return;const t=this.callback;this.longClickInterval=window.setTimeout(t.bind(null,e),is.TIME_MS)}.bind(this),n=function(e){if(1!==e.which)return;this.reset()}.bind(this),s=this.reset.bind(this);this.element.addEventListener("keydown",e,!1),this.element.addEventListener("keyup",t,!1),this.element.addEventListener("pointerdown",i,!1),this.element.addEventListener("pointerout",s,!1),this.element.addEventListener("pointerup",n,!1),this.element.addEventListener("click",s,!0),this.longClickData={mouseUp:n,mouseDown:i,reset:s}}dispose(){this.longClickData&&(this.element.removeEventListener("pointerdown",this.longClickData.mouseDown,!1),this.element.removeEventListener("pointerout",this.longClickData.reset,!1),this.element.removeEventListener("pointerup",this.longClickData.mouseUp,!1),this.element.addEventListener("click",this.longClickData.reset,!0),delete this.longClickData)}static TIME_MS=200}function ns(e){return e||Pn(Mn.anonymous)}const ss=(e,t)=>{const i=e.ownerDocument.createTextNode(t);return e.appendChild(i),i};function os(e,t,i){const n=document.createElement("button");return i?.className&&(n.className=i.className),n.textContent=e,n.classList.add("text-button"),i?.primary&&n.classList.add("primary-button"),t&&n.addEventListener("click",t),i?.jslogContext&&n.setAttribute("jslog",`${o.action().track({click:!0}).context(i.jslogContext)}`),n.type="button",n}function rs(e,t,i){const n=document.createElement("input");return e&&(n.className=e),n.spellcheck=!1,n.classList.add("harmony-input"),t&&(n.type=t),i&&n.setAttribute("jslog",`${o.textField().track({keydown:!0}).context(i)}`),n}function as(e,t,i){const n=new Option(e,t||e);return i&&n.setAttribute("jslog",`${o.item(i).track({click:!0})}`),n}class ls extends HTMLSpanElement{shadowRootInternal;checkboxElement;textElement;constructor(){super(),ls.lastId=ls.lastId+1;const e="ui-checkbox-label"+ls.lastId;this.shadowRootInternal=d.createShadowRootWithCoreStyles(this,{cssFile:Le,delegatesFocus:void 0}),this.checkboxElement=this.shadowRootInternal.createChild("input"),this.checkboxElement.type="checkbox",this.checkboxElement.setAttribute("id",e),this.textElement=this.shadowRootInternal.createChild("label","dt-checkbox-text"),this.textElement.setAttribute("for",e),this.shadowRootInternal.createChild("slot")}static create(e,t,i,n){ls.constructorInternal||(ls.constructorInternal=d.registerCustomElement("span","dt-checkbox",ls));const s=ls.constructorInternal();return s.checkboxElement.checked=Boolean(t),n&&s.checkboxElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(n)}`),void 0!==e&&(s.textElement.textContent=e,s.checkboxElement.title=e,void 0!==i&&(s.textElement.createChild("div","dt-checkbox-subtitle").textContent=i)),s}static lastId=0;static constructorInternal=null}class hs extends HTMLSpanElement{#i;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:void 0,delegatesFocus:void 0});this.#i=new a.Icon.Icon,this.#i.style.setProperty("margin-right","4px"),this.#i.style.setProperty("vertical-align","baseline"),e.appendChild(this.#i),e.createChild("slot")}set data(e){this.#i.data=e,"14px"===e.height?this.#i.style.setProperty("margin-bottom","-2px"):"20px"===e.height&&this.#i.style.setProperty("margin-bottom","2px")}}let ds=0;class cs extends HTMLSpanElement{radioElement;labelElement;constructor(){super(),this.radioElement=this.createChild("input","dt-radio-button"),this.labelElement=this.createChild("label");const e="dt-radio-button-id"+ ++ds;this.radioElement.id=e,this.radioElement.type="radio",this.labelElement.htmlFor=e;d.createShadowRootWithCoreStyles(this,{cssFile:rt,delegatesFocus:void 0}).createChild("slot"),this.addEventListener("click",this.radioClickHandler.bind(this),!1)}radioClickHandler(){this.radioElement.checked||this.radioElement.disabled||(this.radioElement.checked=!0,this.radioElement.dispatchEvent(new Event("change")))}}d.registerCustomElement("span","dt-radio",cs),d.registerCustomElement("span","dt-icon-label",hs);class us extends HTMLSpanElement{sliderElement;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:at,delegatesFocus:void 0});this.sliderElement=document.createElement("input"),this.sliderElement.classList.add("dt-range-input"),this.sliderElement.type="range",e.appendChild(this.sliderElement)}set value(e){this.sliderElement.value=String(e)}get value(){return Number(this.sliderElement.value)}}d.registerCustomElement("span","dt-slider",us);class ms extends HTMLSpanElement{textElement;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:lt,delegatesFocus:void 0});this.textElement=e.createChild("div"),this.textElement.className="info",this.textElement.createChild("slot")}set type(e){this.textElement.className=e}}d.registerCustomElement("span","dt-small-bubble",ms);class ps extends HTMLDivElement{buttonElement;constructor(){super();const e=d.createShadowRootWithCoreStyles(this,{cssFile:Pe,delegatesFocus:void 0});this.buttonElement=e.createChild("div","close-button"),this.buttonElement.setAttribute("jslog",`${o.close().track({click:!0})}`),Jt.install(this.buttonElement,Pn(Mn.close)),be(this.buttonElement,Pn(Mn.close)),F(this.buttonElement);const t=a.Icon.create("cross");this.buttonElement.appendChild(t)}setAccessibleName(e){be(this.buttonElement,e)}setTabbable(e){this.buttonElement.tabIndex=e?0:-1}}function gs(e,t,i,n){if(i<=10)return"";t.length>200&&(t=n(t,200));const s=bs(e,t);if(s<=i)return t;let o=0,r=t.length,a=0,l=s;for(;o<r&&a!==l&&a!==i;){const s=Math.ceil(o+(r-o)*(i-a)/(l-a)),h=bs(e,n(t,s));h<=i?(o=s,a=h):(r=s-1,l=h)}return"…"!==(t=n(t,o))?t:""}function bs(e,t){if(t.length>200)return e.measureText(t).width;fs||(fs=new Map);const i=e.font;let n=fs.get(i);n||(n=new Map,fs.set(i,n));let s=n.get(t);return s||(s=e.measureText(t).width,n.set(t,s)),s}d.registerCustomElement("div","dt-close-button",ps);let fs=null;function vs(e){return/(\?|&)utm_source=devtools/.test(e)?e:-1===e.indexOf("?")?e.replace(/^([^#]*)(#.*)?$/g,"$1?utm_source=devtools$2"):e.replace(/^([^#]*)(#.*)?$/g,"$1&utm_source=devtools$2")}function ws(e){return/(\/\/developers.google.com\/|\/\/web.dev\/|\/\/developer.chrome.com\/)/.test(e)?vs(e):e}const xs=(e,t)=>{let i=e;for(;i&&i!==e.ownerDocument;i=i.parentNodeOrShadowHost())for(let e=0;e<t.length;++e)if(i.nodeName.toLowerCase()===t[e].toLowerCase())return i;return null},Es=(e,t,i)=>{let n=e,s=null;for(;n;){const e=n.elementFromPoint(t,i);if(!e||s===e)break;s=e,n=s.shadowRoot}return s},Is=e=>{const t=e;if(!(t.which||t.pageX||t.pageY||t.clientX||t.clientY||t.movementX||t.movementY))return null;const i=t.target&&t.target.getComponentRoot();return i?Es(i,t.pageX,t.pageY):null},ys=[];function Ss(e){return ys.filter((function(t){if(!t.contextTypes)return!0;for(const i of t.contextTypes())if(e instanceof i)return!0;return!1}))}var Cs=Object.freeze({__proto__:null,highlightedSearchResultClassName:Dn,highlightedCurrentSearchResultClassName:"current-search-result",installDragHandle:An,elementDragStart:Rn,isBeingEdited:function(e){if(!e||e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;if(t.classList.contains("text-prompt")||"INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)return!0;if(!zn.size)return!1;let i=t;for(;i;){if(zn.has(t))return!0;i=i.parentElementOrShadowHost()}return!1},isEditing:On,markBeingEdited:Fn,StyleValueDelimiters:Hn,getValueModificationDirection:Nn,modifiedFloatNumber:_n,createReplacementString:jn,isElementValueModification:Vn,handleElementValueModifications:function(e,t,n,s,r){if(!Vn(e))return!1;o.logKeyDown(e,"element-value-modification");const a=t.getComponentSelection();if(!a||!a.rangeCount)return!1;const l=a.getRangeAt(0);if(!l.commonAncestorContainer.isSelfOrDescendant(t))return!1;const h=t.textContent,d=i.DOMUtilities.rangeOfWord(l.startContainer,l.startOffset,Hn,t),c=d.toString();if(s&&s(c))return!1;const u=jn(c,e,r);if(u){const t=document.createTextNode(u);d.deleteContents(),d.insertNode(t);const i=document.createRange();return i.setStart(t,0),i.setEnd(t,u.length),a.removeAllRanges(),a.addRange(i),e.handled=!0,e.preventDefault(),n&&n(h||"",u),!0}return!1},openLinkExternallyLabel:Un,copyLinkAddressLabel:Kn,copyFileNameLabel:function(){return Pn(Mn.copyFileName)},anotherProfilerActiveLabel:function(){return Pn(Mn.anotherProfilerIsAlreadyActive)},asyncStackTraceLabel:function(e,t){if(e){if("Promise.resolve"===e)return Pn(Mn.promiseResolvedAsync);if("Promise.reject"===e)return Pn(Mn.promiseRejectedAsync);if(("await"===e||"async function"===e)&&0!==t.length){e=`await in ${ns(t[t.length-1].functionName)}`}return Pn(Mn.sAsync,{PH1:e})}return Pn(Mn.asyncCall)},installComponentRootStyles:function(e){d.injectCoreStyles(e),e.classList.add("platform-"+s.Platform.platform()),s.Platform.isMac()||0!==d.measuredScrollbarWidth(e.ownerDocument)||e.classList.add("overlay-scrollbar-enabled")},ElementFocusRestorer:Gn,highlightSearchResult:function(e,t,i,n){const s=Xn(e,[new r.TextRange.SourceRange(t,i)],n);return s.length?s[0]:null},highlightSearchResults:Xn,runCSSAnimationOnce:function(e,t){e.classList.contains(t)&&e.classList.remove(t),e.addEventListener("webkitAnimationEnd",(function i(){e.classList.remove(t),e.removeEventListener("webkitAnimationEnd",i,!1)}),!1),e.classList.add(t)},highlightRangesWithStyleClass:Yn,applyDomChanges:function(e){for(let t=0,i=e.length;t<i;++t){const i=e[t];switch(i.type){case"added":i.parent?.insertBefore(i.node,i.nextSibling??null);break;case"changed":i.node.textContent=i.newText??null}}},revertDomChanges:function(e){for(let t=e.length-1;t>=0;--t){const i=e[t];switch(i.type){case"added":i.node.remove();break;case"changed":i.node.textContent=i.oldText??null}}},measurePreferredSize:Qn,startBatchUpdate:function(){Jn++||(es=new Zn(!1))},endBatchUpdate:function(){--Jn||es&&(es.scheduleInvoke(),es=null)},invokeOnceAfterBatchUpdate:ts,animateFunction:function(e,t,n,s,o){const r=e.performance.now();let a=e.requestAnimationFrame((function l(h){const d=i.NumberUtilities.clamp((h-r)/s,0,1);t(...n.map((e=>e.from+(e.to-e.from)*d))),d<1?a=e.requestAnimationFrame(l):o&&o()}));return()=>e.cancelAnimationFrame(a)},LongClickController:is,initializeUIUtils:function(e){e.body.classList.toggle("inactive",!e.hasFocus()),e.defaultView&&(e.defaultView.addEventListener("focus",qn.bind(void 0,e),!1),e.defaultView.addEventListener("blur",$n.bind(void 0,e),!1)),e.addEventListener("focus",d.focusChanged.bind(void 0),!0);const t=e.body;Ts.setContainer(t)},beautifyFunctionName:ns,createTextChild:ss,createTextChildren:(e,...t)=>{for(const i of t)ss(e,i)},createTextButton:os,createInput:rs,createSelect:function(e,t){const n=document.createElement("select");n.classList.add("chrome-select"),be(n,e);for(const e of t)if(e instanceof Map)for(const[t,s]of e){const e=n.createChild("optgroup");e.label=t;for(const t of s)"string"==typeof t&&e.appendChild(as(t,t,i.StringUtilities.toKebabCase(t)))}else"string"==typeof e&&n.add(as(e,e,i.StringUtilities.toKebabCase(e)));return n},createOption:as,createLabel:function(e,t,i){const n=document.createElement("label");return t&&(n.className=t),n.textContent=e,i&&B(n,i),n},createRadioLabel:function(e,t,i,n){const s=document.createElement("span",{is:"dt-radio"});return s.radioElement.name=e,s.radioElement.checked=Boolean(i),ss(s.labelElement,t),n&&s.radioElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(n)}`),s},createIconLabel:function(e){const t=document.createElement("span",{is:"dt-icon-label"});return e.title&&(t.createChild("span").textContent=e.title),t.data={iconName:e.iconName,color:e.color??"var(--icon-default)",width:e.width??"14px",height:e.height??"14px"},t},createSlider:function(e,t,i){const n=document.createElement("span",{is:"dt-slider"});return n.sliderElement.min=String(e),n.sliderElement.max=String(t),n.sliderElement.step=String(1),n.sliderElement.tabIndex=i,n},setTitle:function(e,t){be(e,t),Jt.install(e,t)},CheckboxLabel:ls,DevToolsIconLabel:hs,DevToolsRadioButton:cs,DevToolsSlider:us,DevToolsSmallBubble:ms,DevToolsCloseButton:ps,bindInput:function(e,t,i,n,s){function o(t){if(t===e.value)return;const{valid:n}=i(t);e.classList.toggle("error-input",!n),e.value=t}return e.addEventListener("change",(function(){const{valid:n}=i(e.value);e.classList.toggle("error-input",!n),n&&t(e.value)}),!1),e.addEventListener("input",(function(){e.classList.toggle("error-input",!i(e.value))}),!1),e.addEventListener("keydown",(function(r){if("Enter"===r.key){const{valid:n}=i(e.value);return n&&t(e.value),void r.preventDefault()}if(!n)return;const a=_n(parseFloat(e.value),r,s);if(null===a)return;const l=String(a),{valid:h}=i(l);h&&o(l);r.preventDefault()}),!1),e.addEventListener("focus",e.select.bind(e),!1),o},trimText:gs,trimTextMiddle:function(e,t,n){return gs(e,t,n,((e,t)=>i.StringUtilities.trimMiddle(e,t)))},trimTextEnd:function(e,t,n){return gs(e,t,n,((e,t)=>i.StringUtilities.trimEndWithMaxLength(e,t)))},measureTextWidth:bs,addReferrerToURL:vs,addReferrerToURLIfNecessary:ws,loadImage:function(e){return new Promise((t=>{const i=new Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(()=>t(null))),i.src=e}))},createFileSelectorElement:function(e){const t=document.createElement("input");return t.type="file",t.style.display="none",t.tabIndex=-1,t.onchange=()=>{t.files&&e(t.files[0])},t},MaxLengthForDisplayedURLs:150,MessageDialog:class{static async show(e,t,i){const n=new Ds(i);n.setSizeBehavior("MeasureContent"),n.setDimmed(!0);const s=d.createShadowRootWithCoreStyles(n.contentElement,{cssFile:De,delegatesFocus:void 0}).createChild("div","widget");await new Promise((i=>{const o=os(Pn(Mn.ok),i,{jslogContext:"confirm",primary:!0});s.createChild("div","message").createChild("span").textContent=e,s.createChild("div","button").appendChild(o),n.setOutsideClickCallback((e=>{e.consume(),i(void 0)})),n.show(t),o.focus()})),n.hide()}},ConfirmDialog:class{static async show(e,t,i){const n=new Ds(i?.jslogContext);n.setSizeBehavior("MeasureContent"),n.setDimmed(!0),be(n.contentElement,e);const s=d.createShadowRootWithCoreStyles(n.contentElement,{cssFile:De,delegatesFocus:void 0}).createChild("div","widget");s.createChild("div","message").createChild("span").textContent=e;const o=s.createChild("div","button"),r=await new Promise((e=>{const s=os(i?.okButtonLabel||Pn(Mn.ok),(()=>e(!0)),{jslogContext:"confirm",primary:!0});o.appendChild(s),o.appendChild(os(i?.cancelButtonLabel||Pn(Mn.cancel),(()=>e(!1)),{jslogContext:"cancel"})),n.setOutsideClickCallback((t=>{t.consume(),e(!1)})),n.show(t),s.focus()}));return n.hide(),r}},createInlineButton:function(e){const t=document.createElement("span"),i=d.createShadowRootWithCoreStyles(t,{cssFile:Ue,delegatesFocus:void 0});t.classList.add("inline-button");const n=new gn("");return n.appendToolbarItem(e),i.appendChild(n.element),t},Renderer:class{static async render(e,t){if(!e)throw new Error("Can't render "+e);const i=Ss(e)[0];if(!i)return null;return(await i.loadRenderer()).render(e,t)}},formatTimestamp:function(e,t){const i=new Date(e),n=i.getFullYear()+"-"+o(i.getMonth()+1,2)+"-"+o(i.getDate(),2),s=o(i.getHours(),2)+":"+o(i.getMinutes(),2)+":"+o(i.getSeconds(),2)+"."+o(i.getMilliseconds(),3);return t?n+" "+s:s;function o(e,t){return String(e).padStart(t,"0")}},isScrolledToBottom:e=>Math.abs(e.scrollTop+e.clientHeight-e.scrollHeight)<=2,createSVGChild:function(e,t,i){const n=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg",t);return i&&n.setAttribute("class",i),e.appendChild(n),n},enclosingNodeOrSelfWithNodeNameInArray:xs,enclosingNodeOrSelfWithNodeName:function(e,t){return xs(e,[t])},deepElementFromPoint:Es,deepElementFromEvent:Is,registerRenderer:function(e){ys.push(e)},getApplicableRegisteredRenderers:Ss});class Ts{widgetInternal;element;contentElement;arrowElement;onMouseDownBound;onClickOutsideCallback;maxSize;positionX;positionY;anchorBox;anchorBehavior;sizeBehavior;marginBehavior;#n=!1;constructor(e){this.widgetInternal=new Wt(!0),this.widgetInternal.markAsRoot(),this.element=this.widgetInternal.element,this.contentElement=this.widgetInternal.contentElement,e&&this.contentElement.setAttribute("jslog",e),this.arrowElement=document.createElement("span"),this.arrowElement.classList.add("arrow","hidden"),this.element.shadowRoot&&this.element.shadowRoot.appendChild(this.arrowElement),this.registerRequiredCSS(Me),this.setPointerEventsBehavior("PierceGlassPane"),this.onMouseDownBound=this.onMouseDown.bind(this),this.onClickOutsideCallback=null,this.maxSize=null,this.positionX=null,this.positionY=null,this.anchorBox=null,this.anchorBehavior="PreferTop",this.sizeBehavior="SetExactSize",this.marginBehavior="DefaultMargin"}setJsLog(e){this.contentElement.setAttribute("jslog",e)}isShowing(){return this.widgetInternal.isShowing()}registerRequiredCSS(e){this.widgetInternal.registerRequiredCSS(e)}registerCSSFiles(e){this.widgetInternal.registerCSSFiles(e)}setDefaultFocusedElement(e){this.widgetInternal.setDefaultFocusedElement(e)}setDimmed(e){this.element.classList.toggle("dimmed-pane",e)}setPointerEventsBehavior(e){this.element.classList.toggle("no-pointer-events","BlockedByGlassPane"!==e),this.contentElement.classList.toggle("no-pointer-events","PierceContents"===e)}setOutsideClickCallback(e){this.onClickOutsideCallback=e}setMaxContentSize(e){this.maxSize=e,this.positionContent()}setSizeBehavior(e){this.sizeBehavior=e,this.positionContent()}setContentPosition(e,t){this.positionX=e,this.positionY=t,this.positionContent()}setContentAnchorBox(e){this.anchorBox=e,this.positionContent()}setAnchorBehavior(e){this.anchorBehavior=e}setMarginBehavior(e){this.marginBehavior=e,this.arrowElement.classList.toggle("hidden","Arrow"!==e)}setIgnoreLeftMargin(e){this.#n=e}show(e){this.isShowing()||(this.element.style.zIndex=""+(3e3+1e3*Ms.size),this.element.setAttribute("data-devtools-glass-pane",""),e.body.addEventListener("mousedown",this.onMouseDownBound,!0),e.body.addEventListener("pointerdown",this.onMouseDownBound,!0),this.widgetInternal.show(e.body),Ms.add(this),this.positionContent())}hide(){this.isShowing()&&(Ms.delete(this),this.element.ownerDocument.body.removeEventListener("mousedown",this.onMouseDownBound,!0),this.element.ownerDocument.body.removeEventListener("pointerdown",this.onMouseDownBound,!0),this.widgetInternal.detach())}onMouseDown(e){if(!this.onClickOutsideCallback)return;const t=Is(e);t&&!this.contentElement.isSelfOrAncestor(t)&&this.onClickOutsideCallback.call(null,e)}positionContent(){if(!this.isShowing())return;const e="Arrow"===this.marginBehavior,t=e?8:"NoMargin"===this.marginBehavior?0:3,n=d.measuredScrollbarWidth(this.element.ownerDocument),s=10,o=ks.get(this.element.ownerDocument);"MeasureContent"===this.sizeBehavior&&(this.contentElement.positionAt(0,0),this.contentElement.style.width="",this.contentElement.style.maxWidth="",this.contentElement.style.height="",this.contentElement.style.maxHeight="");const r=o.offsetWidth,a=o.offsetHeight;let l=r-2*t,h=a-2*t,c=t,u=t;if(this.maxSize&&(l=Math.min(l,this.maxSize.width),h=Math.min(h,this.maxSize.height)),"MeasureContent"===this.sizeBehavior){const e=this.contentElement.getBoundingClientRect(),t=h<e.height?n:0,i=l<e.width?n:0;l=Math.min(l,e.width+t),h=Math.min(h,e.height+i)}if(this.anchorBox){const n=this.anchorBox.relativeToElement(o);let d=this.anchorBehavior;if(this.arrowElement.classList.remove("arrow-none","arrow-top","arrow-bottom","arrow-left","arrow-right"),"PreferTop"===d||"PreferBottom"===d){const m=n.y-2*t,p=a-n.y-n.height-2*t;let g;"PreferTop"===d&&m<h&&p>m&&(d="PreferBottom"),"PreferBottom"===d&&p<h&&m>p&&(d="PreferTop");let b=!0;if("PreferTop"===d){u=Math.max(t,n.y-h-t);const e=n.y-u-t;"MeasureContent"===this.sizeBehavior?h>e&&(this.arrowElement.classList.add("arrow-none"),b=!1):h=Math.min(h,e),this.arrowElement.classList.add("arrow-bottom"),g=n.y-t}else{u=n.y+n.height+t;const e=a-u-t;"MeasureContent"===this.sizeBehavior?h>e&&(this.arrowElement.classList.add("arrow-none"),u=a-t-h,b=!1):h=Math.min(h,e),this.arrowElement.classList.add("arrow-top"),g=n.y+n.height+t}const f=Math.min(n.x,r-l-t);if(c=Math.max(t,f),this.#n&&t>f&&(c=0),b?e&&c-s>=t&&(c-=s):c=Math.min(c+s,r-l-t),l=Math.min(l,r-c-t),20>=l)this.arrowElement.classList.add("arrow-none");else{let e=n.x+Math.min(50,Math.floor(n.width/2));e=i.NumberUtilities.clamp(e,c+s,c+l-s),this.arrowElement.positionAt(e,g,o)}}else{const m=n.x-2*t,p=r-n.x-n.width-2*t;let g;"PreferLeft"===d&&m<l&&p>m&&(d="PreferRight"),"PreferRight"===d&&p<l&&m>p&&(d="PreferLeft");let b=!0;if("PreferLeft"===d){c=Math.max(t,n.x-l-t);const e=n.x-c-t;"MeasureContent"===this.sizeBehavior?l>e&&(this.arrowElement.classList.add("arrow-none"),b=!1):l=Math.min(l,e),this.arrowElement.classList.add("arrow-right"),g=n.x-t}else{c=n.x+n.width+t;const e=r-c-t;"MeasureContent"===this.sizeBehavior?l>e&&(this.arrowElement.classList.add("arrow-none"),c=r-t-l,b=!1):l=Math.min(l,e),this.arrowElement.classList.add("arrow-left"),g=n.x+n.width+t}if(u=Math.max(t,Math.min(n.y,a-h-t)),b?e&&u-s>=t&&(u-=s):u=Math.min(u+s,a-h-t),h=Math.min(h,a-u-t),20>=h)this.arrowElement.classList.add("arrow-none");else{let e=n.y+Math.min(50,Math.floor(n.height/2));e=i.NumberUtilities.clamp(e,u+s,u+h-s),this.arrowElement.positionAt(g,e,o)}}}else c=null!==this.positionX?this.positionX:(r-l)/2,u=null!==this.positionY?this.positionY:(a-h)/2,l=Math.min(l,r-c-t),h=Math.min(h,a-u-t),this.arrowElement.classList.add("arrow-none");this.contentElement.style.width=l+"px","SetExactWidthMaxHeight"===this.sizeBehavior?this.contentElement.style.maxHeight=h+"px":this.contentElement.style.height=h+"px",this.contentElement.positionAt(c,u,o),this.widgetInternal.doResize()}widget(){return this.widgetInternal}static setContainer(e){ks.set(e.ownerDocument,e),Ts.containerMoved(e)}static container(e){return ks.get(e)}static containerMoved(e){for(const t of Ms)t.isShowing()&&t.element.ownerDocument===e.ownerDocument&&t.positionContent()}}const ks=new Map,Ms=new Set,Ls=Ms;var Ps=Object.freeze({__proto__:null,GlassPane:Ts,GlassPanePanes:Ls});class Ds extends(e.ObjectWrapper.eventMixin(Ts)){tabIndexBehavior;tabIndexMap;focusRestorer;closeOnEscape;targetDocument;targetDocumentKeyDownHandler;escapeKeyCallback;constructor(e){super(),this.registerRequiredCSS(ke),this.contentElement.tabIndex=0,this.contentElement.addEventListener("focus",(()=>this.widget().focus()),!1),e&&this.contentElement.setAttribute("jslog",`${o.dialog(e).track({resize:!0})}`),this.widget().setDefaultFocusedElement(this.contentElement),this.setPointerEventsBehavior("BlockedByGlassPane"),this.setOutsideClickCallback((e=>{this.hide(),e.consume(!0)})),z(this.contentElement),this.tabIndexBehavior="DisableAllTabIndex",this.tabIndexMap=new Map,this.focusRestorer=null,this.closeOnEscape=!0,this.targetDocumentKeyDownHandler=this.onKeyDown.bind(this),this.escapeKeyCallback=null}static hasInstance(){return Boolean(Ds.instance)}show(e){const t=e instanceof Document?e:(e||Hi.instance().element).ownerDocument;this.targetDocument=t,this.targetDocument.addEventListener("keydown",this.targetDocumentKeyDownHandler,!0),Ds.instance&&Ds.instance.hide(),Ds.instance=this,this.disableTabIndexOnElements(t),super.show(t),this.focusRestorer=new jt(this.widget())}hide(){this.focusRestorer&&this.focusRestorer.restore(),super.hide(),this.targetDocument&&this.targetDocument.removeEventListener("keydown",this.targetDocumentKeyDownHandler,!0),this.restoreTabIndexOnElements(),this.dispatchEventToListeners("hidden"),Ds.instance=null}setCloseOnEscape(e){this.closeOnEscape=e}setEscapeKeyCallback(e){this.escapeKeyCallback=e}addCloseButton(){this.contentElement.createChild("div","dialog-close-button","dt-close-button").addEventListener("click",(()=>this.hide()),!1)}setOutsideTabIndexBehavior(e){this.tabIndexBehavior=e}disableTabIndexOnElements(e){if("PreserveTabIndex"===this.tabIndexBehavior)return;let t=null;"PreserveMainViewTabIndex"===this.tabIndexBehavior&&(t=this.getMainWidgetTabIndexElements(Hi.instance().ownerSplit())),this.tabIndexMap.clear();let i=e;for(;i;i=i.traverseNextNode(e))if(i instanceof HTMLElement){const e=i,n=e.tabIndex;t?.has(e)||(n>=0?(this.tabIndexMap.set(e,n),e.tabIndex=-1):e.hasAttribute("contenteditable")&&(this.tabIndexMap.set(e,e.hasAttribute("tabindex")?n:0),e.tabIndex=-1))}}getMainWidgetTabIndexElements(e){const t=new Set;if(!e)return t;const i=e.mainWidget();if(!i||!i.element)return t;let n=i.element;for(;n;n=n.traverseNextNode(i.element)){if(!(n instanceof HTMLElement))continue;const e=n;e.tabIndex<0||t.add(e)}return t}restoreTabIndexOnElements(){for(const e of this.tabIndexMap.keys())e.tabIndex=this.tabIndexMap.get(e);this.tabIndexMap.clear()}onKeyDown(e){if(e.keyCode===nt.Esc.code&&Ke.hasNoModifiers(e)){if(this.escapeKeyCallback&&this.escapeKeyCallback(e),e.handled)return;this.closeOnEscape&&(e.consume(!0),this.hide())}}static instance=null}var As=Object.freeze({__proto__:null,Dialog:Ds});let Rs;class Bs{actionRegistry;actionToShortcut;keyMap;activePrefixKey;activePrefixTimeout;consumePrefix;devToolsDefaultShortcutActions;disabledDefaultShortcutsForAction;keybindSetSetting;userShortcutsSetting;constructor(t){this.actionRegistry=t,this.actionToShortcut=new i.MapUtilities.Multimap,this.keyMap=new Os(0,0),this.activePrefixKey=null,this.activePrefixTimeout=null,this.consumePrefix=null,this.devToolsDefaultShortcutActions=new Set,this.disabledDefaultShortcutsForAction=new i.MapUtilities.Multimap,this.keybindSetSetting=e.Settings.Settings.instance().moduleSetting("active-keybind-set"),this.keybindSetSetting.addChangeListener((e=>{s.userMetrics.keybindSetSettingChanged(e.data),this.registerBindings()})),this.userShortcutsSetting=e.Settings.Settings.instance().moduleSetting("user-shortcuts"),this.userShortcutsSetting.addChangeListener(this.registerBindings,this),this.registerBindings()}static instance(e={forceNew:null,actionRegistry:null}){const{forceNew:t,actionRegistry:i}=e;if(!Rs||t){if(!i)throw new Error("Missing actionRegistry for shortcutRegistry");Rs=new Bs(i)}return Rs}static removeInstance(){Rs=void 0}applicableActions(e,t={}){let i=[];const n=(this.activePrefixKey||this.keyMap).getNode(e);n&&(i=n.actions());const s=this.actionRegistry.applicableActions(i,b.instance());if(n)for(const e of Object.keys(t))if(n.actions().indexOf(e)>=0&&this.actionRegistry.hasAction(e)){const t=this.actionRegistry.getAction(e);s.push(t)}return s}shortcutsForAction(e){return[...this.actionToShortcut.get(e)]}actionsForDescriptors(e){let t=this.keyMap;for(const{key:i}of e){if(!t)return[];t=t.getNode(i)}return t?t.actions():[]}globalShortcutKeys(){const e=[];for(const t of this.keyMap.chords().values()){const i=t.actions();(this.actionRegistry.applicableActions(i,b.instance()).length||t.hasChords())&&e.push(t.key())}return e}keysForActions(e){const t=e.flatMap((e=>[...this.actionToShortcut.get(e)].flatMap((e=>e.descriptors.map((e=>e.key))))));return[...new Set(t)]}shortcutTitleForAction(e){for(const t of this.actionToShortcut.get(e))return t.title()}handleShortcut(e,t){this.handleKey(Ke.makeKeyFromEvent(e),e.key,e,t)}actionHasDefaultShortcut(e){return this.devToolsDefaultShortcutActions.has(e)}getShortcutListener(e){const t=Object.keys(e).flatMap((e=>[...this.actionToShortcut.get(e)])),i=new Os(0,0);return t.forEach((e=>{i.addKeyMapping(e.descriptors.map((e=>e.key)),e.action)})),t=>{const n=Ke.makeKeyFromEvent(t),s=this.activePrefixKey?i.getNode(this.activePrefixKey.key()):i;s&&s.getNode(n)&&this.handleShortcut(t,e)}}addShortcutListener(e,t){const i=this.getShortcutListener(t);return e.addEventListener("keydown",i),i}async handleKey(e,t,i,n){const o=e>>8,r=Boolean(n)||Boolean(this.activePrefixKey),a=this.keyMap.getNode(e),l=this.applicableActions(e,n).length>0||a&&a.hasChords();if((r||!function(){if(!i||!On()||/^F\d+|Control|Shift|Alt|Meta|Escape|Win|U\+001B$/.test(t))return!1;if(!o)return!0;const n=qe;if(s.Platform.isMac()){if(Ke.makeKey("z",n.Meta)===e)return!0;if(Ke.makeKey("z",n.Meta|n.Shift)===e)return!0}else{if(Ke.makeKey("z",n.Ctrl)===e)return!0;if(Ke.makeKey("y",n.Ctrl)===e)return!0;if(!s.Platform.isWin()&&Ke.makeKey("z",n.Ctrl|n.Shift)===e)return!0}if((o&(n.Ctrl|n.Alt))==(n.Ctrl|n.Alt))return s.Platform.isWin();return!h(n.Ctrl)&&!h(n.Alt)&&!h(n.Meta)}())&&l&&!Ke.isModifier(Ke.keyCodeAndModifiersFromKey(e).keyCode)&&(i&&i.consume(!0),r||!Ds.hasInstance())){if(this.activePrefixTimeout){clearTimeout(this.activePrefixTimeout);const e=await d.call(this);if(this.activePrefixKey=null,this.activePrefixTimeout=null,e)return;this.consumePrefix&&await this.consumePrefix()}a&&a.hasChords()?(this.activePrefixKey=a,this.consumePrefix=async()=>{this.activePrefixKey=null,this.activePrefixTimeout=null,await d.call(this)},this.activePrefixTimeout=window.setTimeout(this.consumePrefix,Ws)):await d.call(this)}function h(e){return Boolean(o&e)}async function d(){const t=this.applicableActions(e,n);if(!t.length)return!1;for(const e of t){let t;if(n&&n[e.id()]&&(t=await n[e.id()]()),n||(t=await e.execute()),t)return s.userMetrics.keyboardShortcutFired(e.id()),!0}return!1}}registerUserShortcut(e){for(const t of this.disabledDefaultShortcutsForAction.get(e.action))if(t.descriptorsMatch(e.descriptors)&&t.hasKeybindSet(this.keybindSetSetting.get()))return void this.removeShortcut(t);for(const t of this.actionToShortcut.get(e.action))if(t.descriptorsMatch(e.descriptors))return;this.addShortcutToSetting(e)}removeShortcut(e){"DefaultShortcut"===e.type||"KeybindSetShortcut"===e.type?this.addShortcutToSetting(e.changeType("DisabledDefault")):this.removeShortcutFromSetting(e)}disabledDefaultsForAction(e){return this.disabledDefaultShortcutsForAction.get(e)}addShortcutToSetting(e){const t=this.userShortcutsSetting.get();t.push(e),this.userShortcutsSetting.set(t)}removeShortcutFromSetting(e){const t=this.userShortcutsSetting.get(),i=t.findIndex(e.equals,e);-1!==i&&(t.splice(i,1),this.userShortcutsSetting.set(t))}registerShortcut(e){this.actionToShortcut.set(e.action,e),this.keyMap.addKeyMapping(e.descriptors.map((e=>e.key)),e.action)}registerBindings(){this.actionToShortcut.clear(),this.keyMap.clear();const e=this.keybindSetSetting.get();this.disabledDefaultShortcutsForAction.clear(),this.devToolsDefaultShortcutActions.clear();const t=[],i=this.userShortcutsSetting.get();for(const e of i){const i=Ke.createShortcutFromSettingObject(e);"DisabledDefault"===i.type?this.disabledDefaultShortcutsForAction.set(i.action,i):(zs.has(i.action)&&t.push(...i.descriptors.map((e=>Ke.keyCodeAndModifiersFromKey(e.key)))),this.registerShortcut(i))}for(const e of C()){const i=e.id(),s=e.bindings();for(let e=0;s&&e<s.length;++e){const r=s[e].keybindSets;if(!n(s[e].platform)||!o(r))continue;const a=s[e].shortcut.split(/\s+/).map(Ke.makeDescriptorFromBindingShortcut);if(a.length>0){if(this.isDisabledDefault(a,i)){this.devToolsDefaultShortcutActions.add(i);continue}zs.has(i)&&t.push(...a.map((e=>Ke.keyCodeAndModifiersFromKey(e.key)))),r?(r.includes("devToolsDefault")&&this.devToolsDefaultShortcutActions.add(i),this.registerShortcut(new Ke(a,i,"KeybindSetShortcut",new Set(r)))):(this.devToolsDefaultShortcutActions.add(i),this.registerShortcut(new Ke(a,i,"DefaultShortcut")))}}}function n(e){if(!e)return!0;const t=e.split(",");let i=!1;const n=s.Platform.platform();for(let e=0;!i&&e<t.length;++e)i=t[e]===n;return i}function o(t){return!t||t.includes(e)}s.InspectorFrontendHost.InspectorFrontendHostInstance.setWhitelistedShortcuts(JSON.stringify(t))}isDisabledDefault(e,t){const i=this.disabledDefaultShortcutsForAction.get(t);for(const t of i)if(t.descriptorsMatch(e))return!0;return!1}}class Os{keyInternal;actionsInternal;chordsInternal;depth;constructor(e,t=0){this.keyInternal=e,this.actionsInternal=[],this.chordsInternal=new Map,this.depth=t}addAction(e){this.actionsInternal.push(e)}key(){return this.keyInternal}chords(){return this.chordsInternal}hasChords(){return this.chordsInternal.size>0}addKeyMapping(e,t){if(!(e.length<this.depth))if(e.length===this.depth)this.addAction(t);else{const i=e[this.depth];this.chordsInternal.has(i)||this.chordsInternal.set(i,new Os(i,this.depth+1)),this.chordsInternal.get(i).addKeyMapping(e,t)}}getNode(e){return this.chordsInternal.get(e)||null}actions(){return this.actionsInternal}clear(){this.actionsInternal=[],this.chordsInternal=new Map}}class Fs{static instance=new Fs}const zs=new Set(["main.toggle-dock","debugger.toggle-breakpoints-active","debugger.toggle-pause","quick-open.show-command-menu","console.toggle"]),Ws=1e3,Hs="devToolsDefault";var Ns=Object.freeze({__proto__:null,ShortcutRegistry:Bs,ShortcutTreeNode:Os,ForwardedShortcut:Fs,ForwardedActions:zs,KeyTimeout:Ws,DefaultShortcutSetting:Hs}),_s={cssContent:".soft-context-menu{overflow-y:auto;min-width:160px!important;padding:4px 0;border:1px solid var(--sys-color-neutral-outline);border-radius:7px;background-color:var(--sys-color-cdt-base-container);box-shadow:var(--drop-shadow)}:host-context(.-theme-with-dark-background) .soft-context-menu{border:none}.dockside-title{padding-right:13px}.soft-context-menu-item{display:flex;width:100%;font-size:12px;padding:3px 7px 3px 8px;white-space:nowrap;align-items:center;&.soft-context-menu-item-mouse-over{background-color:var(--sys-color-state-hover-on-subtle)}& devtools-icon{width:16px;height:16px;pointer-events:none;&.checkmark{margin:-1px 5px -1px 0;opacity:0%;.soft-context-menu-item[checked] &{opacity:100%}}}}.soft-context-menu-disabled{color:var(--sys-color-state-disabled);pointer-events:none}.soft-context-menu-separator{height:10px;margin:0 1px;& > .separator-line{margin:0;height:5px;border-bottom:1px solid var(--sys-color-divider);pointer-events:none}}.soft-context-menu-item-submenu-arrow{pointer-events:none;font-size:11px;text-align:right;align-self:center;margin-left:auto}.soft-context-menu-custom-item{display:inline-flex;justify-content:center;align-items:center;flex:auto}.soft-context-menu-shortcut{color:var(--sys-color-token-subtle);pointer-events:none;flex:1 1 auto;text-align:right;padding-left:10px;.soft-context-menu-item-mouse-over &{color:inherit}}@media (forced-colors: active){.soft-context-menu-item{color:canvastext}.soft-context-menu-item.soft-context-menu-item-mouse-over,\n .-theme-with-dark-background .soft-context-menu-item.soft-context-menu-item-mouse-over,\n :host-context(.-theme-with-dark-background) .soft-context-menu-item.soft-context-menu-item-mouse-over{background-color:Highlight;color:HighlightText;forced-color-adjust:none}.soft-context-menu .soft-context-menu-item devtools-icon,\n .soft-context-menu .soft-context-menu-item .soft-context-menu-shortcut{color:ButtonText}.soft-context-menu .soft-context-menu-item.soft-context-menu-item-mouse-over devtools-icon,\n .soft-context-menu .soft-context-menu-item.soft-context-menu-item-mouse-over .soft-context-menu-shortcut{color:HighlightText}.soft-context-menu:focus-visible{forced-color-adjust:none;background:canvas;border-color:Highlight}.soft-context-menu-separator > .separator-line{border-bottom-color:ButtonText}}"};const js={checked:"checked",unchecked:"unchecked",sSS:"{PH1}, {PH2}, {PH3}",sS:"{PH1}, {PH2}"},Vs=t.i18n.registerUIStrings("ui/legacy/SoftContextMenu.ts",js),Us=t.i18n.getLocalizedString.bind(void 0,Vs);class Ks{items;itemSelectedCallback;parentMenu;highlightedMenuItemElement;detailsForElementMap;document;glassPane;contextMenuElement;focusRestorer;hideOnUserMouseDownUnlessInMenu;activeSubMenuElement;subMenu;onMenuClosed;focusOnTheFirstItem=!0;keepOpen;loggableParent;constructor(e,t,i,n,s,o){this.items=e,this.itemSelectedCallback=t,this.parentMenu=n,this.highlightedMenuItemElement=null,this.detailsForElementMap=new WeakMap,this.onMenuClosed=s,this.keepOpen=i,this.loggableParent=o||null}getItems(){return this.items}show(e,t){if(!this.items.length)return;this.document=e,this.glassPane=new Ts,this.glassPane.setPointerEventsBehavior(this.parentMenu?"PierceGlassPane":"BlockedByGlassPane"),this.glassPane.registerRequiredCSS(_s),this.glassPane.setContentAnchorBox(t),this.glassPane.setSizeBehavior("MeasureContent"),this.glassPane.setMarginBehavior("NoMargin"),this.glassPane.setAnchorBehavior(this.parentMenu?"PreferRight":"PreferBottom"),this.contextMenuElement=this.glassPane.contentElement.createChild("div","soft-context-menu"),this.contextMenuElement.setAttribute("jslog",`${o.menu().track({resize:!0}).parent("mapped")}`),this.loggableParent&&o.setMappedParent(this.contextMenuElement,this.loggableParent),this.contextMenuElement.tabIndex=-1,q(this.contextMenuElement),this.contextMenuElement.addEventListener("mouseup",(e=>e.consume()),!1),this.contextMenuElement.addEventListener("keydown",this.menuKeyDown.bind(this),!1);const i=!!this.items.find((e=>"checkbox"===e.type));for(let e=0;e<this.items.length;++e)this.contextMenuElement.appendChild(this.createMenuItem(this.items[e],i));if(this.glassPane.show(e),this.focusRestorer=new Gn(this.contextMenuElement),!this.parentMenu){this.hideOnUserMouseDownUnlessInMenu=e=>{let t=this.subMenu;for(;t;){if(t.contextMenuElement===e.composedPath()[0])return;t=t.subMenu}this.discard(),e.consume(!0)},this.document.body.addEventListener("mousedown",this.hideOnUserMouseDownUnlessInMenu,!1);const e=Hi.maybeGetInspectorViewInstance()?.element;if(e){let t=!1;const i=new ResizeObserver((()=>{if(t)return i.disconnect(),void this.discard();t=!0}));i.observe(e)}if(this.contextMenuElement.children&&this.focusOnTheFirstItem){const e=this.contextMenuElement.children[0];this.highlightMenuItem(e,!1)}}}setContextMenuElementLabel(e){this.contextMenuElement&&be(this.contextMenuElement,e)}discard(){this.subMenu&&this.subMenu.discard(),this.focusRestorer&&this.focusRestorer.restore(),this.glassPane&&(this.glassPane.hide(),delete this.glassPane,this.hideOnUserMouseDownUnlessInMenu&&(this.document&&this.document.body.removeEventListener("mousedown",this.hideOnUserMouseDownUnlessInMenu,!1),delete this.hideOnUserMouseDownUnlessInMenu)),this.parentMenu&&(delete this.parentMenu.subMenu,this.parentMenu.activeSubMenuElement&&(ae(this.parentMenu.activeSubMenuElement,!1),delete this.parentMenu.activeSubMenuElement)),this.onMenuClosed?.()}createMenuItem(e,t){if("separator"===e.type)return this.createSeparator();if("subMenu"===e.type)return this.createSubMenu(e,t);const i=document.createElement("div");if(i.classList.add("soft-context-menu-item"),i.tabIndex=-1,$(i),e.checked&&i.setAttribute("checked",""),void 0!==e.id&&i.setAttribute("data-action-id",e.id.toString()),t){const e=a.Icon.create("checkmark","checkmark");i.appendChild(e)}e.tooltip&&Jt.install(i,e.tooltip);const n={actionId:void 0,isSeparator:void 0,customElement:void 0,subItems:void 0,subMenuTimer:void 0};if(e.jslogContext&&!e.element?.hasAttribute("jslog")&&("checkbox"===e.type?i.setAttribute("jslog",`${o.toggle().track({click:!0}).context(e.jslogContext)}`):i.setAttribute("jslog",`${o.action().track({click:!0}).context(e.jslogContext)}`)),e.element&&!e.label){if(i.createChild("div","soft-context-menu-custom-item").appendChild(e.element),e.element?.classList.contains("location-menu")){const t=e.element.ariaLabel||"";e.element.ariaLabel="",be(i,t)}return n.customElement=e.element,this.detailsForElementMap.set(i,n),i}e.enabled||i.classList.add("soft-context-menu-disabled"),ss(i,e.label||""),e.element&&i.appendChild(e.element),i.createChild("span","soft-context-menu-shortcut").textContent=e.shortcut||"",i.addEventListener("mousedown",this.menuItemMouseDown.bind(this),!1),i.addEventListener("mouseup",this.menuItemMouseUp.bind(this),!1),i.addEventListener("mouseover",this.menuItemMouseOver.bind(this),!1),i.addEventListener("mouseleave",this.menuItemMouseLeave.bind(this),!1),n.actionId=e.id;let s=e.label||"";if("checkbox"===e.type){const t=e.checked?Us(js.checked):Us(js.unchecked);s=e.shortcut?Us(js.sSS,{PH1:String(e.label),PH2:e.shortcut,PH3:t}):Us(js.sS,{PH1:String(e.label),PH2:t})}else e.shortcut&&(s=Us(js.sS,{PH1:String(e.label),PH2:e.shortcut}));return be(i,s),this.detailsForElementMap.set(i,n),i}createSubMenu(e,t){const i=document.createElement("div");if(i.classList.add("soft-context-menu-item"),i.tabIndex=-1,X(i),this.detailsForElementMap.set(i,{subItems:e.subItems,actionId:void 0,isSeparator:void 0,customElement:void 0,subMenuTimer:void 0}),t){const e=a.Icon.create("checkmark","checkmark soft-context-menu-item-checkmark");i.appendChild(e)}if(ss(i,e.label||""),ae(i,!1),s.Platform.isMac()&&!m.ThemeSupport.instance().hasTheme()){const e=i.createChild("span","soft-context-menu-item-submenu-arrow");te(e),e.textContent="▶"}else{const e=a.Icon.create("triangle-right","soft-context-menu-item-submenu-arrow");i.appendChild(e)}return i.addEventListener("mousedown",this.menuItemMouseDown.bind(this),!1),i.addEventListener("mouseup",this.menuItemMouseUp.bind(this),!1),i.addEventListener("mouseover",this.menuItemMouseOver.bind(this),!1),i.addEventListener("mouseleave",this.menuItemMouseLeave.bind(this),!1),e.jslogContext&&i.setAttribute("jslog",`${o.item().context(e.jslogContext)}`),i}createSeparator(){const e=document.createElement("div");return e.classList.add("soft-context-menu-separator"),this.detailsForElementMap.set(e,{subItems:void 0,actionId:void 0,isSeparator:!0,customElement:void 0,subMenuTimer:void 0}),e.createChild("div","separator-line"),e}menuItemMouseDown(e){e.consume(!0)}menuItemMouseUp(e){this.triggerAction(e.target,e),e.consume()}root(){let e=this;for(;e.parentMenu;)e=e.parentMenu;return e}setChecked(e,t){e.checked=t;const i=this.contextMenuElement?.querySelector(`[data-action-id="${e.id}"]`);if(!i)return;t?i.setAttribute("checked",""):i.removeAttribute("checked");const n=e.checked?Us(js.checked):Us(js.unchecked);be(i,e.shortcut?Us(js.sSS,{PH1:String(e.label),PH2:e.shortcut,PH3:n}):Us(js.sS,{PH1:String(e.label),PH2:n}))}triggerAction(e,t){const i=this.detailsForElementMap.get(e);if(!i||i.subItems)return this.showSubMenu(e),void t.consume();if(this.keepOpen){t.consume(!0);const e=this.items.find((e=>e.id===i.actionId));void 0!==e?.id&&(this.setChecked(e,!e.checked),this.itemSelectedCallback(e.id))}else this.root().discard(),t.consume(!0),void 0!==i.actionId&&(this.itemSelectedCallback(i.actionId),delete i.actionId)}showSubMenu(e){const t=this.detailsForElementMap.get(e);if(!t)return;if(t.subMenuTimer&&(window.clearTimeout(t.subMenuTimer),delete t.subMenuTimer),this.subMenu||!this.document)return;if(this.activeSubMenuElement=e,ae(e,!0),!t.subItems)return;this.subMenu=new Ks(t.subItems,this.itemSelectedCallback,!1,this);const i=e.boxInWindow();i.y-=5,i.x+=3,i.width-=6,i.height+=10,this.subMenu.show(this.document,i)}menuItemMouseOver(e){this.highlightMenuItem(e.target,!0)}menuItemMouseLeave(e){if(!this.subMenu||!e.relatedTarget)return void this.highlightMenuItem(null,!0);e.relatedTarget===this.contextMenuElement&&this.highlightMenuItem(null,!0)}highlightMenuItem(e,t){if(this.highlightedMenuItemElement!==e){if(this.subMenu&&this.subMenu.discard(),this.highlightedMenuItemElement){const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);this.highlightedMenuItemElement.classList.remove("force-white-icons"),this.highlightedMenuItemElement.classList.remove("soft-context-menu-item-mouse-over"),e&&e.subItems&&e.subMenuTimer&&(window.clearTimeout(e.subMenuTimer),delete e.subMenuTimer)}if(this.highlightedMenuItemElement=e,this.highlightedMenuItemElement){this.highlightedMenuItemElement.classList.add("force-white-icons"),this.highlightedMenuItemElement.classList.add("soft-context-menu-item-mouse-over");const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);e&&e.customElement&&!e.customElement.classList.contains("location-menu")?e.customElement.focus():this.highlightedMenuItemElement.focus(),t&&e&&e.subItems&&!e.subMenuTimer&&(e.subMenuTimer=window.setTimeout(this.showSubMenu.bind(this,this.highlightedMenuItemElement),150))}this.contextMenuElement&&ve(this.contextMenuElement,e)}}highlightPrevious(){let e=this.highlightedMenuItemElement?this.highlightedMenuItemElement.previousSibling:this.contextMenuElement?this.contextMenuElement.lastChild:null,t=e?this.detailsForElementMap.get(e):void 0;for(;e&&t&&(t.isSeparator||e.classList.contains("soft-context-menu-disabled"));)e=e.previousSibling,t=e?this.detailsForElementMap.get(e):void 0;e&&this.highlightMenuItem(e,!1)}highlightNext(){let e=this.highlightedMenuItemElement?this.highlightedMenuItemElement.nextSibling:this.contextMenuElement?this.contextMenuElement.firstChild:null,t=e?this.detailsForElementMap.get(e):void 0;for(;e&&(t&&t.isSeparator||e.classList.contains("soft-context-menu-disabled"));)e=e.nextSibling,t=e?this.detailsForElementMap.get(e):void 0;e&&this.highlightMenuItem(e,!1)}menuKeyDown(e){const t=e;function i(){if(!this.highlightedMenuItemElement)return;const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);e&&!e.customElement&&(this.triggerAction(this.highlightedMenuItemElement,t),e.subItems&&this.subMenu&&this.subMenu.highlightNext(),t.consume(!0))}switch(t.key){case"ArrowUp":this.highlightPrevious(),t.consume(!0);break;case"ArrowDown":this.highlightNext(),t.consume(!0);break;case"ArrowLeft":this.parentMenu&&(this.highlightMenuItem(null,!1),this.discard()),t.consume(!0);break;case"ArrowRight":{if(!this.highlightedMenuItemElement)break;const e=this.detailsForElementMap.get(this.highlightedMenuItemElement);e&&e.subItems&&(this.showSubMenu(this.highlightedMenuItemElement),this.subMenu&&this.subMenu.highlightNext()),e?.customElement?.classList.contains("location-menu")&&(e.customElement.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowRight"})),this.highlightMenuItem(null,!0)),t.consume(!0);break}case"Escape":this.discard(),t.consume(!0);break;case"Enter":if("Enter"!==t.key)return;i.call(this);break;case" ":i.call(this);break;default:t.consume(!0)}}markAsMenuItemCheckBox(){if(this.contextMenuElement)for(const e of this.contextMenuElement.children)"soft-context-menu-separator"!==e.className&&G(e)}setFocusOnTheFirstItem(e){this.focusOnTheFirstItem=e}}var qs=Object.freeze({__proto__:null,SoftContextMenu:Ks});class $s{typeInternal;label;disabled;checked;contextMenu;idInternal;customElement;shortcut;#s;jslogContext;constructor(e,t,i,n,s,o,r){this.typeInternal=t,this.label=i,this.disabled=n,this.checked=s,this.contextMenu=e,this.idInternal=void 0,this.#s=o,"item"!==t&&"checkbox"!==t||(this.idInternal=e?e.nextId():0),this.jslogContext=r}id(){if(void 0===this.idInternal)throw new Error("Tried to access a ContextMenu Item ID but none was set.");return this.idInternal}type(){return this.typeInternal}isEnabled(){return!this.disabled}setEnabled(e){this.disabled=!e}buildDescriptor(){switch(this.typeInternal){case"item":{const e={type:"item",id:this.idInternal,label:this.label,enabled:!this.disabled,checked:void 0,subItems:void 0,tooltip:this.#s,jslogContext:this.jslogContext};return this.customElement&&(e.element=this.customElement),this.shortcut&&(e.shortcut=this.shortcut),e}case"separator":return{type:"separator",id:void 0,label:void 0,enabled:void 0,checked:void 0,subItems:void 0};case"checkbox":{const e={type:"checkbox",id:this.idInternal,label:this.label,checked:Boolean(this.checked),enabled:!this.disabled,subItems:void 0,tooltip:this.#s,jslogContext:this.jslogContext};return this.customElement&&(e.element=this.customElement),e}}throw new Error("Invalid item type:"+this.typeInternal)}setShortcut(e){this.shortcut=e}}class Gs{contextMenu;items;constructor(e){this.contextMenu=e,this.items=[]}appendItem(e,t,i){const n=new $s(this.contextMenu,"item",e,i?.disabled,void 0,i?.tooltip,i?.jslogContext);return i?.additionalElement&&(n.customElement=i?.additionalElement),this.items.push(n),this.contextMenu&&this.contextMenu.setHandler(n.id(),t),n}appendCustomItem(e,t){const i=new $s(this.contextMenu,"item",void 0,void 0,void 0,void 0,t);return i.customElement=e,this.items.push(i),i}appendSeparator(){const e=new $s(this.contextMenu,"separator");return this.items.push(e),e}appendAction(e,t,i){if(i&&!M.instance().hasAction(e))return;const n=M.instance().getAction(e);t||(t=n.title());const s=this.appendItem(t,n.execute.bind(n),{disabled:!n.enabled(),jslogContext:e}),o=Bs.instance().shortcutTitleForAction(e);o&&s.setShortcut(o)}appendSubMenuItem(e,t,i){const n=new Xs(this.contextMenu,e,t,i);return n.init(),this.items.push(n),n}appendCheckboxItem(e,t,i){const n=new $s(this.contextMenu,"checkbox",e,i?.disabled,i?.checked,i?.tooltip,i?.jslogContext);return this.items.push(n),this.contextMenu&&this.contextMenu.setHandler(n.id(),t),i?.additionalElement&&(n.customElement=i?.additionalElement),n}}class Xs extends $s{sections;sectionList;constructor(e,t,i,n){super(e,"subMenu",t,i,void 0,void 0,n),this.sections=new Map,this.sectionList=[]}init(){Ys.groupWeights.forEach((e=>this.section(e)))}section(e){let t=e?this.sections.get(e):null;return t||(t=new Gs(this.contextMenu),e?(this.sections.set(e,t),this.sectionList.push(t)):this.sectionList.splice(Ys.groupWeights.indexOf("default"),0,t)),t}headerSection(){return this.section("header")}newSection(){return this.section("new")}revealSection(){return this.section("reveal")}clipboardSection(){return this.section("clipboard")}editSection(){return this.section("edit")}debugSection(){return this.section("debug")}viewSection(){return this.section("view")}defaultSection(){return this.section("default")}overrideSection(){return this.section("override")}saveSection(){return this.section("save")}footerSection(){return this.section("footer")}buildDescriptor(){const e={type:"subMenu",label:this.label,enabled:!this.disabled,subItems:[],id:void 0,checked:void 0,jslogContext:this.jslogContext},t=this.sectionList.filter((e=>Boolean(e.items.length)));for(const i of t){for(const t of i.items)e.subItems||(e.subItems=[]),e.subItems.push(t.buildDescriptor());i!==t[t.length-1]&&(e.subItems||(e.subItems=[]),e.subItems.push({type:"separator",id:void 0,subItems:void 0,checked:void 0,enabled:void 0,label:void 0}))}return e}appendItemsAtLocation(e){const t=Zs;t.sort(((e,t)=>(e.order||0)-(t.order||0)));for(const i of t){if(i.experiment&&!n.Runtime.experiments.isEnabled(i.experiment))continue;const t=i.location,s=i.actionId;if(!t||!t.startsWith(e+"/"))continue;const o=t.substr(e.length+1);o&&!o.includes("/")&&(s&&this.section(o).appendAction(s))}}static uniqueSectionName=0}class Ys extends Xs{contextMenu;pendingTargets;event;useSoftMenu;keepOpen;x;y;onSoftMenuClosed;jsLogContext;handlers;idInternal;softMenu;contextMenuLabel;openHostedMenu;eventTarget;loggableParent=null;constructor(e,t={}){super(null);const i=e;this.contextMenu=this,super.init(),this.pendingTargets=[],this.event=i,this.eventTarget=this.event.target,this.useSoftMenu=Boolean(t.useSoftMenu),this.keepOpen=Boolean(t.keepOpen),this.x=void 0===t.x?i.x:t.x,this.y=void 0===t.y?i.y:t.y,this.onSoftMenuClosed=t.onSoftMenuClosed,this.handlers=new Map,this.idInternal=0,this.openHostedMenu=null;let n=Is(e)||e.target;if(n){for(this.appendApplicableItems(n);n instanceof Element&&!n.hasAttribute("jslog");)n=n.parentElementOrShadowHost()??null;this.loggableParent=n}}static initialize(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.SetUseSoftMenu,(function(e){Ys.useSoftMenu=e.data}))}static installHandler(e){e.body.addEventListener("contextmenu",(function(e){new Ys(e).show()}),!1)}nextId(){return this.idInternal++}isHostedMenuOpen(){return Boolean(this.openHostedMenu)}getItems(){return this.softMenu?.getItems()||[]}setChecked(e,t){this.softMenu?.setChecked(e,t)}async show(){Ys.pendingMenu=this,this.event.consume(!0);const e=await Promise.all(this.pendingTargets.map((async e=>{const t=await async function(e){const t=[];for(const i of Qs)if(n.Runtime.Runtime.isDescriptorEnabled({experiment:i.experiment,condition:void 0})&&i.contextTypes)for(const n of i.contextTypes())e instanceof n&&t.push(await i.loadProvider());return t}(e);return{target:e,providers:t}})));if(Ys.pendingMenu===this){Ys.pendingMenu=null;for(const{target:t,providers:i}of e)for(const e of i)e.appendApplicableItems(this.event,this,t);this.pendingTargets=[],this.innerShow()}}discard(){this.softMenu&&this.softMenu.discard()}registerLoggablesWithin(e,t){for(const i of e)i.jslogContext&&("checkbox"===i.type?o.registerLoggable(i,`${o.toggle().track({click:!0}).context(i.jslogContext)}`,t||e):"item"===i.type?o.registerLoggable(i,`${o.action().track({click:!0}).context(i.jslogContext)}`,t||e):"subMenu"===i.type&&o.registerLoggable(i,`${o.item().context(i.jslogContext)}`,t||e),i.subItems&&this.registerLoggablesWithin(i.subItems,i))}innerShow(){const e=this.buildMenuDescriptors();if(!this.eventTarget)return;const t=this.eventTarget.ownerDocument;if(this.useSoftMenu||Ys.useSoftMenu||s.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode()){this.softMenu=new Ks(e,this.itemSelected.bind(this),this.keepOpen,void 0,this.onSoftMenuClosed,this.loggableParent);const i="mouse"===this.event.pointerType&&this.event.button>=0;this.softMenu.setFocusOnTheFirstItem(!i),this.softMenu.show(t,new AnchorBox(this.x,this.y,0,0)),this.contextMenuLabel&&this.softMenu.setContextMenuElementLabel(this.contextMenuLabel)}else{function n(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuCleared,this.menuCleared,this),s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuItemSelected,this.onItemSelected,this)}s.InspectorFrontendHost.InspectorFrontendHostInstance.showContextMenuAtPoint(this.x,this.y,e,t),o.registerLoggable(e,`${o.menu()}`,this.loggableParent),this.registerLoggablesWithin(e),this.openHostedMenu=e,queueMicrotask(n.bind(this))}}setContextMenuLabel(e){this.contextMenuLabel=e}setX(e){this.x=e}setY(e){this.y=e}setHandler(e,t){t&&this.handlers.set(e,t)}buildMenuDescriptors(){return super.buildDescriptor().subItems}onItemSelected(e){this.itemSelected(e.data)}itemSelected(e){const t=this.handlers.get(e);if(t&&t.call(this),this.openHostedMenu){const t=(e,i)=>{for(const n of e){if(n.id===i)return n;const e=n.subItems&&t(n.subItems,i);if(e)return e}return null},i=t(this.openHostedMenu,e);i&&i.jslogContext&&o.logClick(i,new MouseEvent("click"))}this.menuCleared()}menuCleared(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.removeEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuCleared,this.menuCleared,this),s.InspectorFrontendHost.InspectorFrontendHostInstance.events.removeEventListener(s.InspectorFrontendHostAPI.Events.ContextMenuItemSelected,this.onItemSelected,this),this.openHostedMenu&&o.logResize(this.openHostedMenu,new DOMRect(0,0,0,0)),this.openHostedMenu=null,this.keepOpen||this.onSoftMenuClosed?.()}appendApplicableItems(e){this.pendingTargets.includes(e)||this.pendingTargets.push(e)}markAsMenuItemCheckBox(){this.softMenu&&this.softMenu.markAsMenuItemCheckBox()}static pendingMenu=null;static useSoftMenu=!1;static groupWeights=["header","new","reveal","edit","clipboard","debug","view","default","override","save","footer"]}const Qs=[];const Zs=[];var Js=Object.freeze({__proto__:null,Item:$s,Section:Gs,SubMenu:Xs,ContextMenu:Ys,registerProvider:function(e){Qs.push(e)},registerItem:function(e){Zs.push(e)},maybeRemoveItem:function(e){const t=Zs.findIndex((t=>t.actionId===e.actionId&&t.location===e.location));return!(t<0)&&(Zs.splice(t,1),!0)}}),eo={cssContent:":host{position:absolute;top:0;bottom:0;left:0;right:0;display:flex;background-color:var(--color-background-opacity-80);z-index:1000}.drop-target-message{flex:auto;font-size:30px;color:var(--sys-color-token-subtle);display:flex;justify-content:center;align-items:center;margin:20px;border:4px dashed var(--sys-color-neutral-outline);pointer-events:none}"};var to=Object.freeze({__proto__:null,DropTarget:class{element;transferTypes;messageText;handleDrop;enabled;dragMaskElement;constructor(e,t,i,n){e.addEventListener("dragenter",this.onDragEnter.bind(this),!0),e.addEventListener("dragover",this.onDragOver.bind(this),!0),this.element=e,this.transferTypes=t,this.messageText=i,this.handleDrop=n,this.enabled=!0,this.dragMaskElement=null}setEnabled(e){this.enabled=e}onDragEnter(e){this.enabled&&this.hasMatchingType(e)&&e.consume(!0)}hasMatchingType(e){const t=e;if(!t.dataTransfer)return!1;for(const e of this.transferTypes){if(Array.from(t.dataTransfer.items).find((t=>e.kind===t.kind&&Boolean(e.type.exec(t.type)))))return!0}return!1}onDragOver(e){const t=e;if(!this.enabled||!this.hasMatchingType(t))return;if(t.dataTransfer&&(t.dataTransfer.dropEffect="copy"),t.consume(!0),this.dragMaskElement)return;this.dragMaskElement=this.element.createChild("div","");d.createShadowRootWithCoreStyles(this.dragMaskElement,{cssFile:eo,delegatesFocus:void 0}).createChild("div","drop-target-message").textContent=this.messageText,this.dragMaskElement.addEventListener("drop",this.onDrop.bind(this),!0),this.dragMaskElement.addEventListener("dragleave",this.onDragLeave.bind(this),!0)}onDrop(e){const t=e;t.consume(!0),this.removeMask(),this.enabled&&t.dataTransfer&&this.handleDrop(t.dataTransfer)}onDragLeave(e){e.consume(!0),this.removeMask()}removeMask(){this.dragMaskElement&&(this.dragMaskElement.remove(),this.dragMaskElement=null)}},Type:{URI:{kind:"string",type:/text\/uri-list/},Folder:{kind:"file",type:/$^/},File:{kind:"file",type:/.*/},WebFile:{kind:"file",type:/[\w]+/},ImageFile:{kind:"file",type:/image\/.*/}}}),io={cssContent:".empty-bold-text{display:block;font-size:1.5em;margin:0.83em 0;font-weight:bold}.empty-view{color:var(--sys-color-token-subtle);padding:30px;text-align:center;min-width:70px}.empty-view-scroller{justify-content:center;overflow:auto}.empty-view p{white-space:initial;line-height:18px;max-width:300px;flex-shrink:0}"};function no(e){return e.data}function so(e,t){e.data=t}class oo{elementInternal;elementsById;constructor(e){this.elementInternal=e,this.elementsById=new Map}element(){return this.elementInternal}$(e){return this.elementsById.get(e)}static build(e,...t){return oo.render(oo.template(e),t)}static cached(e,...t){let i=uo.get(e);return i||(i=oo.template(e),uo.set(e,i)),oo.render(i,t)}static template(e){let t="",i=!0;for(let n=0;n<e.length-1;n++){t+=e[n];const s=e[n].lastIndexOf(">"),o=e[n].indexOf("<",s+1);-1!==s&&-1===o?i=!0:-1!==o&&(i=!1),t+=i?ro:lo(n)}t+=e[e.length-1];const n=document.createElement("template");n.innerHTML=t;const s=n.ownerDocument.createTreeWalker(n.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);let o=0;const r=[],a=[],l=[];for(;s.nextNode();){const e=s.currentNode;if(e.nodeType===Node.ELEMENT_NODE&&e.hasAttributes()){e.hasAttribute("$")&&(l.push(e),a.push({replaceNodeIndex:void 0,attr:void 0,elementId:e.getAttribute("$")||""}),e.removeAttribute("$"));const t=[];for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i].name;if(!ho.test(n)&&!ho.test(e.attributes[i].value))continue;t.push(n),l.push(e);const s={index:o,names:n.split(ho),values:e.attributes[i].value.split(ho)};o+=s.names.length-1,o+=s.values.length-1;const r={elementId:void 0,replaceNodeIndex:void 0,attr:s};a.push(r)}for(let i=0;i<t.length;i++)e.removeAttribute(t[i])}if(e.nodeType===Node.TEXT_NODE&&-1!==no(e).indexOf(ro)){const t=no(e).split(ao);so(e,t[t.length-1]);const i=e.parentNode;for(let n=0;n<t.length-1;n++){t[n]&&i.insertBefore(document.createTextNode(t[n]),e);const s=document.createElement("span");l.push(s),a.push({attr:void 0,elementId:void 0,replaceNodeIndex:o++}),i.insertBefore(s,e)}}e.nodeType!==Node.TEXT_NODE||e.previousSibling&&e.previousSibling.nodeType!==Node.ELEMENT_NODE||e.nextSibling&&e.nextSibling.nodeType!==Node.ELEMENT_NODE||!/^\s*$/.test(no(e))||r.push(e)}for(let e=0;e<l.length;e++)l[e].classList.add(co(e));for(const e of r)e.remove();return{template:n,binds:a}}static render(e,t){const i=e.template.ownerDocument.importNode(e.template.content,!0),n=i.firstChild===i.lastChild?i.firstChild:i,s=new oo(n),o=[];for(let t=0;t<e.binds.length;t++){const e=co(t),n=i.querySelector("."+e);n.classList.remove(e),o.push(n)}for(let i=0;i<e.binds.length;i++){const n=e.binds[i],r=o[i];if(void 0!==n.elementId)s.elementsById.set(n.elementId,r);else if(void 0!==n.replaceNodeIndex){const e=t[n.replaceNodeIndex];r.parentNode.replaceChild(this.nodeForValue(e),r)}else{if(void 0===n.attr)throw new Error("Unexpected bind");if(2===n.attr.names.length&&1===n.attr.values.length&&"function"==typeof t[n.attr.index])t[n.attr.index].call(null,r);else{let e=n.attr.names[0];for(let i=1;i<n.attr.names.length;i++)e+=t[n.attr.index+i-1],e+=n.attr.names[i];if(e){let i=n.attr.values[0];for(let e=1;e<n.attr.values.length;e++)i+=t[n.attr.index+n.attr.names.length-1+e-1],i+=n.attr.values[e];r.setAttribute(e,i)}}}}return s}static nodeForValue(e){if(e instanceof Node)return e;if(e instanceof oo)return e.elementInternal;if(Array.isArray(e)){const t=document.createDocumentFragment();for(const i of e)t.appendChild(this.nodeForValue(i));return t}return document.createTextNode(String(e))}}const ro="{{template-text}}",ao=/{{template-text}}/,lo=e=>"template-attribute"+e,ho=/template-attribute\d+/,co=e=>"template-class-"+e,uo=new Map,mo=(e,...t)=>oo.cached(e,...t).element();var po=Object.freeze({__proto__:null,Fragment:oo,textMarker:ro,attributeMarker:lo,html:mo});class go extends Lt{hrefInternal;clickable;onClick;onKeyDown;static create(e,t,n,s,r){t||(t=e);return mo` <x-link href='${e}' tabindex="0" class='${n=n||""} devtools-link' ${s?"no-click":""} jslog=${o.link().track({click:!0}).context(r)}>${i.StringUtilities.trimMiddle(t,150)}</x-link>`}constructor(){super(),this.style.setProperty("display","inline"),H(this),this.setAttribute("tabindex","0"),this.setAttribute("target","_blank"),this.setAttribute("rel","noopener"),this.hrefInternal=null,this.clickable=!0,this.onClick=e=>{e.consume(!0),this.hrefInternal&&s.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(this.hrefInternal),this.dispatchEvent(new Event("x-link-invoke"))},this.onKeyDown=e=>{i.KeyboardUtilities.isEnterOrSpaceKey(e)&&(e.consume(!0),this.hrefInternal&&s.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(this.hrefInternal)),this.dispatchEvent(new Event("x-link-invoke"))}}static get observedAttributes(){return Lt.observedAttributes.concat(["href","no-click","title"])}get href(){return this.hrefInternal}attributeChangedCallback(e,t,i){if("no-click"===e)return this.clickable=!i,void this.updateClick();if("href"===e){i||(i="");let e=null,t=null;try{t=new URL(ws(i)),e=t.toString()}catch{}return t&&"javascript:"===t.protocol&&(e=null),this.hrefInternal=e,this.hasAttribute("title")||Jt.install(this,i),void this.updateClick()}super.attributeChangedCallback(e,t,i)}updateClick(){null!==this.hrefInternal&&this.clickable?(this.addEventListener("click",this.onClick,!1),this.addEventListener("keydown",this.onKeyDown,!1),this.style.setProperty("cursor","pointer")):(this.removeEventListener("click",this.onClick,!1),this.removeEventListener("keydown",this.onKeyDown,!1),this.style.removeProperty("cursor"))}}customElements.define("x-link",go);const bo=p.html`<p>Hello, <x-link>world!</x-link></p>`;var fo=Object.freeze({__proto__:null,XLink:go,ContextMenuProvider:class{appendApplicableItems(e,t,i){let n=i;for(;n&&!(n instanceof go);)n=n.parentNodeOrShadowHost();if(!n||!n.href)return;const o=n;t.revealSection().appendItem(Un(),(()=>{o.href&&s.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(o.href)}),{jslogContext:"open-in-new-tab"}),t.revealSection().appendItem(Kn(),(()=>{o.href&&s.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(o.href)}),{jslogContext:"copy-link-address"})}},sample:bo});const vo={learnMore:"Learn more"},wo=t.i18n.registerUIStrings("ui/legacy/EmptyWidget.ts",vo),xo=t.i18n.getLocalizedString.bind(void 0,wo);var Eo=Object.freeze({__proto__:null,EmptyWidget:class extends Nt{textElement;constructor(e){super(),this.registerRequiredCSS(io),this.element.classList.add("empty-view-scroller"),this.contentElement=this.element.createChild("div","empty-view"),this.contentElement.setAttribute("jslog",`${o.section("empty-view")}`),this.textElement=this.contentElement.createChild("div","empty-bold-text"),this.textElement.textContent=e}appendParagraph(){return this.contentElement.createChild("p")}appendLink(e){const t=go.create(e,xo(vo.learnMore),void 0,void 0,"learn-more");return this.contentElement.appendChild(t)}set text(e){this.textElement.textContent=e}}}),Io={cssContent:'.filter-bar{background-color:var(--sys-color-cdt-base-container);flex:none;flex-wrap:wrap;align-items:center;border-bottom:1px solid var(--sys-color-divider);color:var(--sys-color-on-surface-subtle)}.filter-text-filter{display:inline-flex;margin-left:1px;margin-right:2px;min-width:40px;max-width:200px;height:24px;align-items:center}.filter-bitset-filter{padding:2px;display:inline-flex;overflow:hidden;height:24px;position:relative;margin:0}.filter-bitset-filter span{color:var(--sys-color-on-surface);outline:1px solid var(--sys-color-neutral-outline);outline-offset:-1px;box-sizing:border-box;display:inline-block;flex:none;margin:auto 2px;padding:3px 6px;background:transparent;border-radius:6px;overflow:hidden;cursor:pointer;font-weight:500;font-size:11px}.filter-bitset-filter span:focus-visible{outline:-webkit-focus-ring-color auto 5px}.filter-bitset-filter span:hover{outline:none;background:var(--sys-color-state-hover-on-subtle)}.filter-bitset-filter span.selected,\n.filter-bitset-filter span:active{color:var(--sys-color-on-tonal-container);outline:none;background-color:var(--sys-color-tonal-container)}.filter-bitset-filter-divider{background-color:var(--sys-color-divider);height:16px;width:1px;margin:auto 2px;display:inline-block}.filter-checkbox-filter{padding-left:4px;padding-right:7px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:inline-flex;vertical-align:middle;height:24px;position:relative}.filter-checkbox-filter > [is="dt-checkbox"]{display:flex;margin:auto 0}.toolbar-has-dropdown-shrinkable{flex-shrink:1}.filter-divider{background-color:var(--sys-color-on-base-divider);width:1px;margin:5px 4px;height:16px}.toolbar-button{white-space:nowrap;overflow:hidden;min-width:28px;background:transparent;border-radius:0}.toolbar-button .active-filters-count{margin-right:5px;--override-adorner-background-color:var(--sys-color-tonal-container);--override-adorner-border-color:var(--sys-color-tonal-container);--override-adorner-text-color:var(--sys-color-primary);--override-adorner-font-size:10px;font-weight:700}.toolbar-text{margin:0 4px 0 0;text-overflow:ellipsis;flex:auto;overflow:hidden;text-align:right}.dropdown-filterbar{justify-content:space-between;padding:0 3px 0 5px;border:1px solid transparent;border-radius:7px;display:flex;background-color:transparent;color:var(--sys-color-on-surface-subtle)}.filter-input-field{padding-left:3px;width:163px;height:18px;line-height:20px;display:inline-block;overflow:hidden;white-space:nowrap;cursor:auto}.filter-input-container{margin:0 3px;display:flex;background:var(--sys-color-cdt-base-container);border:1px solid var(--sys-color-neutral-outline);border-radius:4px;width:163px;&:focus-within{border-color:var(--sys-color-state-focus-ring)}&:hover:not(:focus-within){background:var(--sys-color-state-hover-on-subtle)}}.filter-text-filter:not(.filter-text-empty) .filter-input-container{border-color:var(--sys-color-state-focus-ring)}.filter-input-clear-button{opacity:70%;height:16px;margin:0;cursor:pointer;border:none;background:none;padding:1px 2px;devtools-icon{display:block}&:hover{opacity:99%}}.filter-text-empty .filter-input-clear-button{display:none}button.toolbar-item:focus-visible{background:var(--sys-color-state-hover-on-subtle);border-radius:2px}@media (forced-colors: active){.filter-bitset-filter span:hover,\n .filter-bitset-filter span.selected,\n .filter-bitset-filter span:active{forced-color-adjust:none;background:Highlight;color:HighlightText}.filter-input-container{forced-color-adjust:none;background:ButtonFace;box-shadow:var(--legacy-focus-ring-inactive-shadow);color:fieldtext}.filter-input-container:hover,\n .filter-input-container:focus-within,\n .filter-text-filter:not(.filter-text-empty) .filter-input-container{box-shadow:var(--legacy-focus-ring-active-shadow)}}'};const yo={filter:"Filter",egSmalldUrlacomb:"e.g. `/small[d]+/ url:a.com/b`",sclickToSelectMultipleTypes:"{PH1}Click to select multiple types",allStrings:"All",clearFilter:"Clear input"},So=t.i18n.registerUIStrings("ui/legacy/FilterBar.ts",yo),Co=t.i18n.getLocalizedString.bind(void 0,So);class To extends(e.ObjectWrapper.eventMixin(_t)){enabled;stateSetting;filterButtonInternal;filters;alwaysShowFilters;showingWidget;constructor(t,i){super(),this.registerRequiredCSS(Io),this.enabled=!0,this.element.classList.add("filter-bar"),this.element.setAttribute("jslog",`${o.toolbar("filter-bar")}`),this.stateSetting=e.Settings.Settings.instance().createSetting("filter-bar-"+t+"-toggled",Boolean(i)),this.filterButtonInternal=new In(this.stateSetting,"filter",Co(yo.filter),"filter-filled","filter"),this.filters=[],this.updateFilterBar(),this.stateSetting.addChangeListener(this.updateFilterBar.bind(this))}filterButton(){return this.filterButtonInternal}addDivider(){const e=document.createElement("div");e.classList.add("filter-divider"),this.element.appendChild(e)}addFilter(e){this.filters.push(e),this.element.appendChild(e.element()),e.addEventListener("FilterChanged",this.filterChanged,this),this.updateFilterButton()}setEnabled(e){this.enabled=e,this.filterButtonInternal.setEnabled(e),this.updateFilterBar()}forceShowFilterBar(){this.alwaysShowFilters=!0,this.updateFilterBar()}showOnce(){this.stateSetting.set(!0)}filterChanged(){this.updateFilterButton(),this.dispatchEventToListeners("Changed")}wasShown(){super.wasShown(),this.updateFilterBar()}updateFilterBar(){this.parentWidget()&&!this.showingWidget&&(this.visible()?(this.showingWidget=!0,this.showWidget(),this.showingWidget=!1):this.hideWidget())}focus(){for(let e=0;e<this.filters.length;++e)if(this.filters[e]instanceof ko){this.filters[e].focus();break}}updateFilterButton(){let e=!1;for(const t of this.filters)e=e||t.isActive();this.filterButtonInternal.setDefaultWithRedColor(e),this.filterButtonInternal.setToggleWithRedColor(e)}clear(){this.element.removeChildren(),this.filters=[],this.updateFilterButton()}setting(){return this.stateSetting}visible(){return this.alwaysShowFilters||this.stateSetting.get()&&this.enabled}}class ko extends e.ObjectWrapper.ObjectWrapper{filterElement;filterInputElement;prompt;proxyElement;suggestionProvider;constructor(){super(),this.filterElement=document.createElement("div"),this.filterElement.className="filter-text-filter";const e=this.filterElement.createChild("div","filter-input-container");this.filterInputElement=e.createChild("span","filter-input-field"),this.prompt=new ln,this.prompt.initialize(this.completions.bind(this)," ",!0),this.proxyElement=this.prompt.attach(this.filterInputElement),Jt.install(this.proxyElement,Co(yo.egSmalldUrlacomb)),this.prompt.setPlaceholder(Co(yo.filter)),this.prompt.addEventListener("TextChanged",this.valueChanged.bind(this)),this.suggestionProvider=null;const t=e.createChild("button","filter-input-clear-button");Jt.install(t,Co(yo.clearFilter));const i=new a.Icon.Icon;i.data={color:"var(--icon-default)",width:"16px",height:"16px",iconName:"cross-circle-filled"},t.appendChild(i),t.addEventListener("click",(()=>{this.clear(),this.focus()})),t.setAttribute("jslog",`${o.action("clear-filter").track({click:!0})}`),this.updateEmptyStyles()}completions(e,t,i){return this.suggestionProvider?this.suggestionProvider(e,t,i):Promise.resolve([])}isActive(){return Boolean(this.prompt.text())}element(){return this.filterElement}value(){return this.prompt.text()}setValue(e){this.prompt.setText(e),this.valueChanged()}focus(){this.filterInputElement.focus()}setSuggestionProvider(e){this.prompt.clearAutocomplete(),this.suggestionProvider=e}valueChanged(){this.dispatchEventToListeners("FilterChanged"),this.updateEmptyStyles()}updateEmptyStyles(){this.filterElement.classList.toggle("filter-text-empty",!this.prompt.text())}clear(){this.setValue("")}}class Mo extends e.ObjectWrapper.ObjectWrapper{filtersElement;typeFilterElementTypeNames;allowedTypes;typeFilterElements;setting;constructor(e,t){super(),this.filtersElement=document.createElement("div"),this.filtersElement.classList.add("filter-bitset-filter"),this.filtersElement.setAttribute("jslog",`${o.section("filter-bitset")}`),Z(this.filtersElement),J(this.filtersElement),Jt.install(this.filtersElement,Co(yo.sclickToSelectMultipleTypes,{PH1:Ke.shortcutToString("",qe.CtrlOrMeta)})),this.typeFilterElementTypeNames=new WeakMap,this.allowedTypes=new Set,this.typeFilterElements=[],this.addBit(Mo.ALL_TYPES,Co(yo.allStrings)),this.typeFilterElements[0].tabIndex=0,this.filtersElement.createChild("div","filter-bitset-filter-divider");for(let t=0;t<e.length;++t)this.addBit(e[t].name,e[t].label(),e[t].title);t?(this.setting=t,t.addChangeListener(this.settingChanged.bind(this)),this.settingChanged()):this.toggleTypeFilter(Mo.ALL_TYPES,!1)}reset(){this.toggleTypeFilter(Mo.ALL_TYPES,!1)}isActive(){return!this.allowedTypes.has(Mo.ALL_TYPES)}element(){return this.filtersElement}accept(e){return this.allowedTypes.has(Mo.ALL_TYPES)||this.allowedTypes.has(e)}settingChanged(){const e=this.setting.get();this.allowedTypes=new Set;for(const t of this.typeFilterElements){const i=this.typeFilterElementTypeNames.get(t);i&&e[i]&&this.allowedTypes.add(i)}this.update()}update(){(0===this.allowedTypes.size||this.allowedTypes.has(Mo.ALL_TYPES))&&(this.allowedTypes=new Set,this.allowedTypes.add(Mo.ALL_TYPES));for(const e of this.typeFilterElements){const t=this.typeFilterElementTypeNames.get(e),i=this.allowedTypes.has(t||"");e.classList.toggle("selected",i),ue(e,i)}this.dispatchEventToListeners("FilterChanged")}addBit(e,t,i){const n=this.filtersElement.createChild("span",e);n.tabIndex=-1,this.typeFilterElementTypeNames.set(n,e),ss(n,t),ee(n),i&&(n.title=i),n.addEventListener("click",this.onTypeFilterClicked.bind(this),!1),n.addEventListener("keydown",this.onTypeFilterKeydown.bind(this),!1),n.setAttribute("jslog",`${o.item(e).track({click:!0})}`),this.typeFilterElements.push(n)}onTypeFilterClicked(e){const t=e;let i;if(i=s.Platform.isMac()?t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey:t.ctrlKey&&!t.metaKey&&!t.altKey&&!t.shiftKey,t.target){const e=t.target,n=this.typeFilterElementTypeNames.get(e);this.toggleTypeFilter(n,i)}}onTypeFilterKeydown(e){const t=e,n=t.target;n&&("ArrowLeft"===t.key||"ArrowUp"===t.key?this.keyFocusNextBit(n,!0)&&t.consume(!0):"ArrowRight"===t.key||"ArrowDown"===t.key?this.keyFocusNextBit(n,!1)&&t.consume(!0):i.KeyboardUtilities.isEnterOrSpaceKey(t)&&this.onTypeFilterClicked(t))}keyFocusNextBit(e,t){const i=this.typeFilterElements.indexOf(e);if(-1===i)return!1;const n=t?i-1:i+1;if(n<0||n>=this.typeFilterElements.length)return!1;const s=this.typeFilterElements[n];return s.tabIndex=0,e.tabIndex=-1,s.focus(),!0}toggleTypeFilter(e,t){if(t&&e!==Mo.ALL_TYPES?this.allowedTypes.delete(Mo.ALL_TYPES):this.allowedTypes=new Set,this.allowedTypes.has(e)?this.allowedTypes.delete(e):(this.allowedTypes.add(e),s.userMetrics.legacyResourceTypeFilterItemSelected(e)),0===this.allowedTypes.size&&this.allowedTypes.add(Mo.ALL_TYPES),s.userMetrics.legacyResourceTypeFilterNumberOfSelectedChanged(this.allowedTypes.size),this.setting){const e={};for(const t of this.allowedTypes)e[t]=!0;this.setting.set(e)}else this.update()}static ALL_TYPES="all"}class Lo extends e.ObjectWrapper.ObjectWrapper{filterElement;activeWhenChecked;label;checkboxElement;constructor(e,t,i,n,s){super(),this.filterElement=document.createElement("div"),this.filterElement.classList.add("filter-checkbox-filter"),this.activeWhenChecked=Boolean(i),this.label=ls.create(t),this.filterElement.appendChild(this.label),this.checkboxElement=this.label.checkboxElement,n?$i(this.checkboxElement,n):this.checkboxElement.checked=!0,this.checkboxElement.addEventListener("change",this.fireUpdated.bind(this),!1),s&&this.checkboxElement.setAttribute("jslog",`${o.toggle().track({change:!0}).context(s)}`)}isActive(){return this.activeWhenChecked===this.checkboxElement.checked}checked(){return this.checkboxElement.checked}setChecked(e){this.checkboxElement.checked=e}element(){return this.filterElement}labelElement(){return this.label}fireUpdated(){this.dispatchEventToListeners("FilterChanged")}}var Po=Object.freeze({__proto__:null,FilterBar:To,TextFilterUI:ko,NamedBitSetFilterUI:Mo,CheckboxFilterUI:Lo});var Do=Object.freeze({__proto__:null,FilterSuggestionBuilder:class{keys;valueSorter;valuesMap;constructor(e,t){this.keys=e,this.valueSorter=t||((e,t)=>t.sort()),this.valuesMap=new Map}completions(e,t,n){if(!t&&!n)return Promise.resolve([]);const s=t.startsWith("-");s&&(t=t.substring(1));const o=s?"-":"",r=t.indexOf(":"),a=[];if(-1===r){const e=new RegExp("^"+i.StringUtilities.escapeForRegExp(t),"i");for(const t of this.keys)e.test(t)&&a.push({text:o+t+":"})}else{const e=t.substring(0,r).toLowerCase(),n=t.substring(r+1),s=new RegExp("^"+i.StringUtilities.escapeForRegExp(n),"i"),l=Array.from(this.valuesMap.get(e)||new Set);this.valueSorter(e,l);for(const t of l)s.test(t)&&t!==n&&a.push({text:o+e+":"+t})}return Promise.resolve(a)}addItem(e,t){if(!t)return;let i=this.valuesMap.get(e);i||(i=new Set,this.valuesMap.set(e,i)),i.add(t)}clear(){this.valuesMap.clear()}}});class Ao{constructor(){s.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(s.InspectorFrontendHostAPI.Events.KeyEventUnhandled,this.onKeyEventUnhandled,this)}async onKeyEventUnhandled(e){const{type:t,key:i,keyCode:n,modifiers:s}=e.data;if("keydown"!==t)return;const o=b.instance(),r=Bs.instance();o.setFlavor(Fs,Fs.instance),await r.handleKey(Ke.makeKey(n,s),i),o.setFlavor(Fs,null)}}new Ao;var Ro=Object.freeze({__proto__:null,ForwardedInputEventHandler:Ao});let Bo=null;class Oo extends HTMLInputElement{history;historyPosition;constructor(){super(),this.history=[""],this.historyPosition=0,this.addEventListener("keydown",this.onKeyDown.bind(this),!1),this.addEventListener("input",this.onInput.bind(this),!1)}static create(){return Bo||(Bo=d.registerCustomElement("input","history-input",Oo)),Bo()}onInput(e){this.history.length===this.historyPosition+1&&(this.history[this.history.length-1]=this.value)}onKeyDown(e){const t=e;t.keyCode===nt.Up.code?(this.historyPosition=Math.max(this.historyPosition-1,0),this.value=this.history[this.historyPosition],this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t.consume(!0)):t.keyCode===nt.Down.code?(this.historyPosition=Math.min(this.historyPosition+1,this.history.length-1),this.value=this.history[this.historyPosition],this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t.consume(!0)):t.keyCode===nt.Enter.code&&this.saveToHistory()}saveToHistory(){this.history.length>1&&this.history[this.history.length-2]===this.value||(this.history[this.history.length-1]=this.value,this.historyPosition=this.history.length-1,this.history.push(""))}}var Fo=Object.freeze({__proto__:null,HistoryInput:Oo});let zo=null;class Wo{focusRestorer;static startEditing(e,t){return zo||(zo=new Wo),zo.startEditing(e,t)}editorContent(e){const t=e.element;return"INPUT"===t.tagName&&"text"===t.type?t.value:t.textContent||""}setUpEditor(e){const t=e.element;t.classList.add("editing"),t.setAttribute("contenteditable","plaintext-only");const i=t.getAttribute("role");K(t),e.oldRole=i;const n=t.getAttribute("tabIndex");("number"!=typeof n||n<0)&&(t.tabIndex=0),this.focusRestorer=new Gn(t),e.oldTabIndex=n}closeEditor(e){const t=e.element;t.classList.remove("editing"),t.removeAttribute("contenteditable"),"string"!=typeof e.oldRole?t.removeAttribute("role"):t.setAttribute("role",e.oldRole),"number"!=typeof e.oldTabIndex?t.removeAttribute("tabIndex"):t.setAttribute("tabIndex",e.oldTabIndex),t.scrollTop=0,t.scrollLeft=0}cancelEditing(e){const t=e.element;"INPUT"===t.tagName&&"text"===t.type?t.value=e.oldText||"":t.textContent=e.oldText}startEditing(e,t){if(!Fn(e,!0))return null;const n=t||new Ho((function(){}),(function(){})),s={element:e,config:n,oldRole:null,oldTabIndex:null,oldText:null},o=n.commitHandler,r=n.cancelHandler,a=n.pasteHandler,l=n.context;let h="";const d=this;function c(t){n.blurHandler&&!n.blurHandler(e,t)||p.call(e)}function u(){Fn(e,!1),e.removeEventListener("blur",c,!1),e.removeEventListener("keydown",f,!0),a&&e.removeEventListener("paste",b,!0),d.focusRestorer&&d.focusRestorer.restore(),d.closeEditor(s)}function m(){d.cancelEditing(s),u(),r(this,l)}function p(){u(),o(this,d.editorContent(s),s.oldText||"",l,h)}function g(t,i){"commit"===t?(p.call(e),i.consume(!0)):"cancel"===t?(m.call(e),i.consume(!0)):t&&t.startsWith("move-")&&(h=t.substring(5),"Tab"===i.key&&i.consume(!0),c())}function b(e){if(!a)return;g(a(e),e)}function f(e){let t=function(e){return"Enter"===e.key?"commit":e.keyCode===nt.Esc.code||e.key===i.KeyboardUtilities.ESCAPE_KEY?"cancel":"Tab"===e.key?"move-"+(e.shiftKey?"backward":"forward"):""}(e);if(!t&&n.postKeydownFinishHandler){const i=n.postKeydownFinishHandler(e);i&&(t=i)}g(t,e)}this.setUpEditor(s),s.oldText=this.editorContent(s),e.addEventListener("blur",c,!1),e.addEventListener("keydown",f,!0),void 0!==a&&e.addEventListener("paste",b,!0);return{cancel:m.bind(e),commit:p.bind(e)}}}class Ho{commitHandler;cancelHandler;context;blurHandler;pasteHandler;postKeydownFinishHandler;constructor(e,t,i,n){this.commitHandler=e,this.cancelHandler=t,this.context=i,this.blurHandler=n}setPasteHandler(e){this.pasteHandler=e}setPostKeydownFinishHandler(e){this.postKeydownFinishHandler=e}}var No=Object.freeze({__proto__:null,InplaceEditor:Wo,Config:Ho}),_o={cssContent:".list{flex:auto 0 1;overflow-y:auto;border:1px solid var(--sys-color-divider);flex-direction:column;--override-background-list-item-color:hsl(0deg 0% 96%)}.-theme-with-dark-background .list,\n:host-context(.-theme-with-dark-background) .list{--override-background-list-item-color:hsl(0deg 0% 16%)}.list-separator{background:var(--sys-color-divider);height:1px}.list-item{flex:none;min-height:30px;display:flex;align-items:center;position:relative;overflow:hidden}.list-item:focus-within,\n.list-item:hover{background:var(--sys-color-state-hover-on-subtle)}.list-widget-input-validation-error{color:var(--sys-color-error);margin:0 5px}.controls-container{display:flex;flex-direction:row;justify-content:flex-end;align-items:stretch;pointer-events:none}.controls-gradient{flex:0 1 50px}.list-item:focus-within .controls-gradient,\n.list-item:hover .controls-gradient{background-image:linear-gradient(90deg,transparent,var(--override-background-list-item-color))}.controls-buttons{flex:none;display:flex;flex-direction:row;align-items:center;pointer-events:auto;visibility:hidden}.list-item:focus-within .controls-buttons,\n.list-item:hover .controls-buttons{background-color:var(--override-background-list-item-color);visibility:visible}.editor-container{display:flex;flex-direction:column;align-items:stretch;flex:none;background:var(--sys-color-surface3);overflow:hidden}.editor-content{flex:auto;display:flex;flex-direction:column;align-items:stretch}.editor-buttons{flex:none;display:flex;flex-direction:row;align-items:center;justify-content:flex-start;padding:5px}.editor-buttons > button{flex:none;margin-right:10px}.editor-content input{margin-right:10px}.editor-content input.error-input{background-color:var(--sys-color-cdt-base-container)}.text-prompt-container{padding:3px 6px;height:24px;border:none;box-shadow:var(--legacy-focus-ring-inactive-shadow);border-radius:2px;width:100%;background-color:var(--sys-color-cdt-base-container);&:focus{border:1px solid var(--sys-color-state-focus-ring)}& .text-prompt{width:100%}}@media (forced-colors: active){.list-item:focus-within .controls-buttons,\n .list-item:hover .controls-buttons{background-color:canvas}.list-item:focus-within,\n .list-item:hover{forced-color-adjust:none;background:Highlight}.list-item:focus-within *,\n .list-item:hover *{color:HighlightText}.list-item:focus-within .controls-gradient,\n .list-item:hover .controls-gradient{background-image:unset}}"};const jo={editString:"Edit",removeString:"Remove",saveString:"Save",addString:"Add",cancelString:"Cancel",changesSaved:"Changes to item have been saved",removedItem:"Item has been removed"},Vo=t.i18n.registerUIStrings("ui/legacy/ListWidget.ts",jo),Uo=t.i18n.getLocalizedString.bind(void 0,Vo);var Ko=Object.freeze({__proto__:null,ListWidget:class extends Nt{delegate;list;lastSeparator;focusRestorer;items;editable;elements;editor;editItem;editElement;emptyPlaceholder;isTable;constructor(e,t=!0,i=!1){super(!0,t),this.registerRequiredCSS(_o),this.delegate=e,this.list=this.contentElement.createChild("div","list"),this.lastSeparator=!1,this.focusRestorer=null,this.items=[],this.editable=[],this.elements=[],this.editor=null,this.editItem=null,this.editElement=null,this.emptyPlaceholder=null,this.isTable=i,i&&(this.list.role="table"),this.updatePlaceholder()}clear(){this.items=[],this.editable=[],this.elements=[],this.lastSeparator=!1,this.list.removeChildren(),this.updatePlaceholder(),this.stopEditing()}appendItem(e,t){if(this.lastSeparator&&this.items.length){const e=document.createElement("div");e.classList.add("list-separator"),this.isTable&&(e.role="rowgroup"),this.list.appendChild(e)}this.lastSeparator=!1,this.items.push(e),this.editable.push(t);const i=this.list.createChild("div","list-item");this.isTable&&(i.role="rowgroup");const n=this.delegate.renderItem(e,t);n.hasAttribute("jslog")||n.setAttribute("jslog",`${o.item()}`),i.appendChild(n),t&&(i.classList.add("editable"),i.tabIndex=0,i.appendChild(this.createControls(e,i))),this.elements.push(i),this.updatePlaceholder()}appendSeparator(){this.lastSeparator=!0}removeItem(e){this.editItem===this.items[e]&&this.stopEditing();const t=this.elements[e],i=t.previousElementSibling,n=i&&i.classList.contains("list-separator"),s=t.nextElementSibling,o=s&&s.classList.contains("list-separator");!n||!o&&s||i.remove(),o&&!i&&s.remove(),t.remove(),this.elements.splice(e,1),this.items.splice(e,1),this.editable.splice(e,1),this.updatePlaceholder()}addNewItem(e,t){this.startEditing(t,null,this.elements[e]||null)}setEmptyPlaceholder(e){this.emptyPlaceholder=e,this.updatePlaceholder()}createControls(e,t){const i=document.createElement("div");i.classList.add("controls-container"),i.classList.add("fill"),i.createChild("div","controls-gradient");const n=i.createChild("div","controls-buttons"),s=new gn("",n),o=new wn(Uo(jo.editString),"edit",void 0,"edit-item");o.addEventListener("Click",function(){const i=this.elements.indexOf(t),n=this.elements[i+1]||null;this.startEditing(e,t,n)}.bind(this)),s.appendToolbarItem(o);const r=new wn(Uo(jo.removeString),"bin",void 0,"remove-item");return r.addEventListener("Click",function(){const e=this.elements.indexOf(t);this.element.focus(),this.delegate.removeItemRequested(this.items[e],e),Se(Uo(jo.removedItem)),this.elements[Math.min(e,this.elements.length-1)].focus()}.bind(this)),s.appendToolbarItem(r),i}wasShown(){super.wasShown(),this.stopEditing()}updatePlaceholder(){this.emptyPlaceholder&&(this.elements.length||this.editor?this.emptyPlaceholder.remove():this.list.appendChild(this.emptyPlaceholder))}startEditing(e,t,i){if(t&&this.editElement===t)return;this.stopEditing(),this.focusRestorer=new Gn(this.element),this.list.classList.add("list-editing"),this.element.classList.add("list-editing"),this.editItem=e,this.editElement=t,t&&t.classList.add("hidden");const n=t?this.elements.indexOf(t):-1;this.editor=this.delegate.beginEdit(e),this.updatePlaceholder(),this.list.insertBefore(this.editor.element,i),this.editor.beginEdit(e,n,Uo(t?jo.saveString:jo.addString),this.commitEditing.bind(this),this.stopEditing.bind(this))}commitEditing(){const e=this.editItem,t=!this.editElement,i=this.editor,n=this.editElement?this.elements.indexOf(this.editElement):this.elements.length-1;this.stopEditing(),null!==e&&(this.delegate.commitEdit(e,i,t),Se(Uo(jo.changesSaved)),this.elements[n]&&this.elements[n].focus())}stopEditing(){this.list.classList.remove("list-editing"),this.element.classList.remove("list-editing"),this.focusRestorer&&this.focusRestorer.restore(),this.editElement&&this.editElement.classList.remove("hidden"),this.editor&&this.editor.element.parentElement&&this.editor.element.remove(),this.editor=null,this.editItem=null,this.editElement=null,this.updatePlaceholder()}},Editor:class{element;contentElementInternal;commitButton;cancelButton;errorMessageContainer;controls;controlByName;validators;commit;cancel;item;index;constructor(){this.element=document.createElement("div"),this.element.classList.add("editor-container"),this.element.addEventListener("keydown",t.bind(null,i.KeyboardUtilities.isEscKey,this.cancelClicked.bind(this)),!1),this.contentElementInternal=this.element.createChild("div","editor-content"),this.contentElementInternal.addEventListener("keydown",t.bind(null,(e=>"Enter"===e.key&&!(e.target instanceof HTMLSelectElement)),this.commitClicked.bind(this)),!1);const e=this.element.createChild("div","editor-buttons");function t(e,t,i){e(i)&&(i.consume(!0),t())}this.commitButton=os("",this.commitClicked.bind(this),{jslogContext:"commit",primary:!0}),e.appendChild(this.commitButton),this.cancelButton=os(Uo(jo.cancelString),this.cancelClicked.bind(this),{jslogContext:"cancel",primary:!0}),this.cancelButton.setAttribute("jslog",`${o.action("cancel").track({click:!0})}`),e.appendChild(this.cancelButton),this.errorMessageContainer=this.element.createChild("div","list-widget-input-validation-error"),O(this.errorMessageContainer),this.controls=[],this.controlByName=new Map,this.validators=[],this.commit=null,this.cancel=null,this.item=null,this.index=-1}contentElement(){return this.contentElementInternal}createInput(e,t,i,n){const s=rs("",t);return s.placeholder=i,s.addEventListener("input",this.validateControls.bind(this,!1),!1),s.setAttribute("jslog",`${o.textField().track({keydown:!0}).context(e)}`),be(s,i),this.controlByName.set(e,s),this.controls.push(s),this.validators.push(n),s}createSelect(e,t,n,s){const r=document.createElement("select");r.setAttribute("jslog",`${o.dropDown().track({change:!0}).context(e)}`),r.classList.add("chrome-select");for(let e=0;e<t.length;++e){const n=r.createChild("option");n.value=t[e],n.textContent=t[e],n.setAttribute("jslog",`${o.item(i.StringUtilities.toKebabCase(t[e])).track({click:!0})}`)}return s&&(Jt.install(r,s),be(r,s)),r.addEventListener("input",this.validateControls.bind(this,!1),!1),r.addEventListener("blur",this.validateControls.bind(this,!1),!1),this.controlByName.set(e,r),this.controls.push(r),this.validators.push(n),r}createCustomControl(e,t,i){const n=new t;return this.controlByName.set(e,n),this.controls.push(n),this.validators.push(i),n}control(e){const t=this.controlByName.get(e);if(!t)throw new Error(`Control with name ${e} does not exist, please verify.`);return t}validateControls(e){let t=!0;this.errorMessageContainer.textContent="";for(let i=0;i<this.controls.length;++i){const n=this.controls[i],{valid:s,errorMessage:o}=this.validators[i].call(null,this.item,this.index,n);if(n.classList.toggle("error-input",!s&&!e),pe(n,!s&&!e),!e&&o){if(this.errorMessageContainer.textContent){const e=document.createElement("br");this.errorMessageContainer.append(e)}this.errorMessageContainer.append(o)}t=t&&s}this.commitButton.disabled=!t}requestValidation(){this.validateControls(!1)}beginEdit(e,t,i,n,s){this.commit=n,this.cancel=s,this.item=e,this.index=t,this.commitButton.textContent=i,this.element.scrollIntoViewIfNeeded(!1),this.controls.length&&this.controls[0].focus(),this.validateControls(!0)}commitClicked(){if(this.commitButton.disabled)return;const e=this.commit;this.commit=null,this.cancel=null,this.item=null,this.index=-1,e&&e()}cancelClicked(){const e=this.cancel;this.commit=null,this.cancel=null,this.item=null,this.index=-1,e&&e()}}});class qo extends Nt{panelName;constructor(e){super(),this.element.setAttribute("jslog",`${o.panel().context(e).track({resize:!0})}`),this.element.classList.add("panel"),this.element.setAttribute("aria-label",e),this.element.classList.add(e),this.panelName=e,self.UI=self.UI||{},self.UI.panels=self.UI.panels||{},UI.panels[e]=this}get name(){return this.panelName}searchableView(){return null}elementsToRestoreScrollPositionsFor(){return[]}}var $o=Object.freeze({__proto__:null,Panel:qo,PanelWithSidebar:class extends qo{panelSplitWidget;mainWidget;sidebarWidget;constructor(e,t){super(e),this.panelSplitWidget=new Gt(!0,!1,this.panelName+"-panel-split-view-state",t||200),this.panelSplitWidget.show(this.element),this.mainWidget=new Nt,this.panelSplitWidget.setMainWidget(this.mainWidget),this.sidebarWidget=new Nt,this.sidebarWidget.setMinimumSize(100,25),this.panelSplitWidget.setSidebarWidget(this.sidebarWidget),this.sidebarWidget.element.classList.add("panel-sidebar"),this.sidebarWidget.element.setAttribute("jslog",`${o.pane("sidebar").track({resize:!0})}`)}panelSidebarElement(){return this.sidebarWidget.element}mainElement(){return this.mainWidget.element}splitWidget(){return this.panelSplitWidget}}}),Go={cssContent:".widget{display:flex;background:var(--sys-color-cdt-base-container);border:1px solid transparent;box-shadow:var(--drop-shadow);border-radius:2px;overflow:auto;user-select:text;line-height:11px;&.borderless-popover{border:0}}.widget.has-padding{padding:6px}"};class Xo{static createPopover=e=>{const t=new Ts(`${o.popover(e).parent("mapped")}`);return t.registerRequiredCSS(Go),t.setSizeBehavior("MeasureContent"),t.setMarginBehavior("Arrow"),t};disableOnClick;hasPadding;getRequest;scheduledRequest;hidePopoverCallback;container;showTimeout;hideTimeout;hidePopoverTimer;showPopoverTimer;boundMouseDown;boundMouseMove;boundMouseOut;#o;constructor(e,t,i){this.disableOnClick=!1,this.hasPadding=!1,this.getRequest=t,this.#o=i,this.scheduledRequest=null,this.hidePopoverCallback=null,this.container=e,this.showTimeout=0,this.hideTimeout=0,this.hidePopoverTimer=null,this.showPopoverTimer=null,this.boundMouseDown=this.mouseDown.bind(this),this.boundMouseMove=this.mouseMove.bind(this),this.boundMouseOut=this.mouseOut.bind(this),this.container.addEventListener("mousedown",this.boundMouseDown,!1),this.container.addEventListener("mousemove",this.boundMouseMove,!1),this.container.addEventListener("mouseout",this.boundMouseOut,!1),this.setTimeout(1e3)}setTimeout(e,t){this.showTimeout=e,this.hideTimeout="number"==typeof t?t:e/2}setHasPadding(e){this.hasPadding=e}setDisableOnClick(e){this.disableOnClick=e}eventInScheduledContent(e){const t=e;return!!this.scheduledRequest&&this.scheduledRequest.box.contains(t.clientX,t.clientY)}mouseDown(e){this.disableOnClick?this.hidePopover():this.eventInScheduledContent(e)||(this.startHidePopoverTimer(0),this.stopShowPopoverTimer(),this.startShowPopoverTimer(e,0))}mouseMove(e){const t=e;if(this.eventInScheduledContent(t))return this.stopShowPopoverTimer(),void this.startShowPopoverTimer(t,this.isPopoverVisible()?.6*this.showTimeout:this.showTimeout);this.startHidePopoverTimer(this.hideTimeout),this.stopShowPopoverTimer(),t.buttons&&this.disableOnClick||this.startShowPopoverTimer(t,this.isPopoverVisible()?.6*this.showTimeout:this.showTimeout)}popoverMouseMove(e){this.stopHidePopoverTimer()}popoverMouseOut(e,t){const i=t;if(!e.isShowing())return;const n=i.relatedTarget;n&&!n.isSelfOrDescendant(e.contentElement)&&this.startHidePopoverTimer(this.hideTimeout)}mouseOut(e){this.isPopoverVisible()&&(this.eventInScheduledContent(e)||this.startHidePopoverTimer(this.hideTimeout))}startHidePopoverTimer(e){this.hidePopoverCallback&&!this.hidePopoverTimer&&(this.hidePopoverTimer=window.setTimeout((()=>{this.hidePopoverInternal(),this.hidePopoverTimer=null}),e))}startShowPopoverTimer(e,t){this.scheduledRequest=this.getRequest.call(null,e),this.scheduledRequest&&(this.showPopoverTimer=window.setTimeout((()=>{this.showPopoverTimer=null,this.stopHidePopoverTimer(),this.hidePopoverInternal();const t=e.target.ownerDocument;this.showPopover(t)}),t))}stopShowPopoverTimer(){this.showPopoverTimer&&(clearTimeout(this.showPopoverTimer),this.showPopoverTimer=null)}isPopoverVisible(){return Boolean(this.hidePopoverCallback)}hidePopover(){this.stopShowPopoverTimer(),this.hidePopoverInternal()}hidePopoverInternal(){this.hidePopoverCallback&&(this.hidePopoverCallback.call(null),this.hidePopoverCallback=null)}showPopover(e){const t=Xo.createPopover(this.#o),i=this.scheduledRequest;i&&i.show.call(null,t).then((n=>{n&&(this.scheduledRequest===i?(Yo&&Yo.hidePopover(),Yo=this,o.setMappedParent(t.contentElement,this.container),t.contentElement.classList.toggle("has-padding",this.hasPadding),t.contentElement.addEventListener("mousemove",this.popoverMouseMove.bind(this),!0),t.contentElement.addEventListener("mouseout",this.popoverMouseOut.bind(this,t),!0),t.setContentAnchorBox(i.box),t.show(e),this.hidePopoverCallback=()=>{i.hide&&i.hide.call(null),t.hide(),Yo=null}):i.hide&&i.hide.call(null))}))}stopHidePopoverTimer(){this.hidePopoverTimer&&(clearTimeout(this.hidePopoverTimer),this.hidePopoverTimer=null,this.stopShowPopoverTimer())}dispose(){this.container.removeEventListener("mousedown",this.boundMouseDown,!1),this.container.removeEventListener("mousemove",this.boundMouseMove,!1),this.container.removeEventListener("mouseout",this.boundMouseOut,!1)}}let Yo=null;var Qo=Object.freeze({__proto__:null,PopoverHelper:Xo}),Zo={cssContent:".progress-indicator-shadow-stop-button{background-color:var(--sys-color-error-bright);border:0;width:10px;height:12px;border-radius:2px}.progress-indicator-shadow-container{display:flex;flex:1 0 auto;align-items:center}.progress-indicator-shadow-container .title{text-overflow:ellipsis;overflow:hidden;max-width:150px;margin-right:2px;color:var(--sys-color-token-subtle)}.progress-indicator-shadow-container progress{flex:auto;margin:0 2px;width:100px}"};var Jo=Object.freeze({__proto__:null,ProgressIndicator:class{element;shadowRoot;contentElement;labelElement;progressElement;stopButton;isCanceledInternal;worked;isDone;constructor(){this.element=document.createElement("div"),this.element.classList.add("progress-indicator"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:Zo,delegatesFocus:void 0}),this.contentElement=this.shadowRoot.createChild("div","progress-indicator-shadow-container"),this.labelElement=this.contentElement.createChild("div","title"),this.progressElement=this.contentElement.createChild("progress"),this.progressElement.value=0,this.stopButton=this.contentElement.createChild("button","progress-indicator-shadow-stop-button"),this.stopButton.addEventListener("click",this.cancel.bind(this)),this.isCanceledInternal=!1,this.worked=0}show(e){e.appendChild(this.element)}done(){this.isDone||(this.isDone=!0,this.element.remove())}cancel(){this.isCanceledInternal=!0}isCanceled(){return this.isCanceledInternal}setTitle(e){this.labelElement.textContent=e}setTotalWork(e){this.progressElement.max=e}setWorked(e,t){this.worked=e,this.progressElement.value=e,t&&this.setTitle(t)}incrementWorked(e){this.setWorked(this.worked+(e||1))}}});const er=new CSSStyleSheet;er.replaceSync(".widget{padding:20px}.remote-debugging-terminated-title{font-size:17px;font-weight:normal;margin:6px 0}.remote-debugging-terminated-message{font-size:14px;margin:5px 0;margin-bottom:24px}.remote-debugging-terminated-options{display:grid;grid-template-columns:1fr auto;grid-gap:8px;align-items:center;padding-top:12px;border-top:1px solid var(--color-details-hairline-light)}.remote-debugging-terminated-label{grid-column:1;margin:8px 0;max-width:300px;font-size:larger;line-height:1.4}.remote-debugging-terminated-options .text-button{grid-column:2}.remote-debugging-terminated-feedback-container{display:flex;flex-direction:column;align-items:center;margin-top:16px;padding:12px 16px;background-color:var(--color-background-elevation-1);border-radius:6px}.remote-debugging-terminated-feedback-label{font-size:14px;margin-bottom:8px}.remote-debugging-terminated-reason{--override-reason-color:#8b0000;color:var(--override-reason-color)}.-theme-with-dark-background .remote-debugging-terminated-reason,\n:host-context(.-theme-with-dark-background) .reason{--override-reason-color:rgb(255 116 116)}\n/*# sourceURL=remoteDebuggingTerminatedScreen.css */\n");const tr={title:"DevTools is disconnected",debuggingConnectionWasClosed:"Debugging connection was closed. Reason: ",reconnectWhenReadyByReopening:"Reconnect when ready (will reload DevTools)",reconnectDevtools:"Reconnect `DevTools`",closeDialog:"Dismiss",closeDialogDetail:"Dismiss this dialog and continue using `DevTools` while disconnected",sendFeedbackMessage:"[FB-only] Please send feedback if this disconnection is unexpected.",sendFeedback:"Send feedback"},ir=t.i18n.registerUIStrings("ui/legacy/RemoteDebuggingTerminatedScreen.ts",tr),nr=t.i18n.getLocalizedString.bind(void 0,ir),{render:sr,html:or}=p;class rr extends Nt{constructor(e,t){super(!0),this.registerCSSFiles([er]);const i=globalThis.FB_ONLY__reactNativeFeedbackLink;sr(or` <h1 class="remote-debugging-terminated-title">${nr(tr.title)}</h1>