@react-native/debugger-frontend
Version:
Debugger frontend for React Native based on Chrome DevTools
1 lines • 190 kB
JavaScript
import*as e from"../../core/platform/platform.js";import*as t from"../../core/i18n/i18n.js";import*as i from"../../ui/components/icon_button/icon_button.js";import*as s from"../../ui/legacy/components/data_grid/data_grid.js";import*as r from"../../ui/legacy/legacy.js";import*as o from"../../core/host/host.js";import*as n from"../../core/common/common.js";import*as a from"../../core/sdk/sdk.js";import*as l from"../../ui/visual_logging/visual_logging.js";import*as d from"../../ui/components/buttons/buttons.js";import*as h from"../../core/root/root.js";import*as c from"../../models/cpu_profile/cpu_profile.js";import*as p from"../../ui/legacy/components/perf_ui/perf_ui.js";import*as u from"../../ui/legacy/components/utils/utils.js";import*as m from"../../models/bindings/bindings.js";import*as f from"../../models/heap_snapshot_model/heap_snapshot_model.js";import*as g from"../../ui/legacy/components/object_ui/object_ui.js";import*as v from"../../models/workspace/workspace.js";const S={notOptimizedS:"Not optimized: {PH1}",genericTextTwoPlaceholders:"{PH1}, {PH2}"},w=t.i18n.registerUIStrings("panels/profiler/ProfileDataGrid.ts",S),b=t.i18n.getLocalizedString.bind(void 0,w);class C extends s.DataGrid.DataGridNode{searchMatchedSelfColumn;searchMatchedTotalColumn;searchMatchedFunctionColumn;profileNode;tree;childrenByCallUID;lastComparator;callUID;self;total;functionName;deoptReason;url;linkElement;populated;savedSelf;savedTotal;savedChildren;constructor(e,t,i){super(null,i),this.searchMatchedSelfColumn=!1,this.searchMatchedTotalColumn=!1,this.searchMatchedFunctionColumn=!1,this.profileNode=e,this.tree=t,this.childrenByCallUID=new Map,this.lastComparator=null,this.callUID=e.callUID,this.self=e.self,this.total=e.total,this.functionName=r.UIUtils.beautifyFunctionName(e.functionName),this.deoptReason=e.deoptReason||"",this.url=e.url,this.linkElement=null,this.populated=!1}static sort(e,t,i){for(let s=0;s<e.length;++s){const r=e[s],o=r.length;for(let s=0;s<o;++s){const o=r[s];if(!(i||o.expanded&&o.lastComparator!==t)){o.children.length&&(o.shouldRefreshChildren=!0);continue}o.lastComparator=t;const n=o.children,a=n.length;if(a){n.sort(t);for(let e=0;e<a;++e)n[e].recalculateSiblings(e);e.push(n)}}}}static merge(e,t,i){e.self+=t.self,i||(e.total+=t.total);let s=e.children.slice();e.removeChildren();let r=s.length;for(let o=0;o<r;++o)i&&s[o]===t||e.appendChild(s[o]);s=t.children.slice(),r=s.length;for(let t=0;t<r;++t){const i=s[t],r=e.childrenByCallUID.get(i.callUID);r?r.merge(i,!1):e.appendChild(i)}}static populate(e){if(e.populated)return;e.populated=!0,e.populateChildren();const t=e.tree.lastComparator;t&&e.sort(t,!0)}createCell(e){switch(e){case"self":{const t=this.createValueCell(this.self,this.selfPercent,e);return t.classList.toggle("highlight",this.searchMatchedSelfColumn),t}case"total":{const t=this.createValueCell(this.total,this.totalPercent,e);return t.classList.toggle("highlight",this.searchMatchedTotalColumn),t}case"function":{const t=this.createTD(e);if(t.classList.toggle("highlight",this.searchMatchedFunctionColumn),this.deoptReason){t.classList.add("not-optimized");const e=new i.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("profile-warn-marker"),r.Tooltip.Tooltip.install(e,b(S.notOptimizedS,{PH1:this.deoptReason})),t.appendChild(e)}if(r.UIUtils.createTextChild(t,this.functionName),"0"===this.profileNode.scriptId)return t;const s=this.tree.formatter.linkifyNode(this);return s?(s.style.maxWidth="75%",t.appendChild(s),this.linkElement=s,t):t}}return super.createCell(e)}createValueCell(e,t,i){const s=document.createElement("td");s.classList.add("numeric-column");const r=s.createChild("div","profile-multiple-values"),o=r.createChild("span"),n=this.tree.formatter.formatValue(e,this);o.textContent=n;const a=r.createChild("span","percent-column"),l=this.tree.formatter.formatPercent(t,this);a.textContent=l;const d=this.tree.formatter.formatValueAccessibleText(e,this);return this.setCellAccessibleName(b(S.genericTextTwoPlaceholders,{PH1:d,PH2:l}),s,i),s}sort(e,t){const i=e;return C.sort([[this]],i,t)}insertChild(e,t){const i=e;super.insertChild(i,t),this.childrenByCallUID.set(i.callUID,i)}removeChild(e){super.removeChild(e),this.childrenByCallUID.delete(e.callUID)}removeChildren(){super.removeChildren(),this.childrenByCallUID.clear()}findChild(e){return e&&this.childrenByCallUID.get(e.callUID)||null}get selfPercent(){return this.self/this.tree.total*100}get totalPercent(){return this.total/this.tree.total*100}populate(){C.populate(this)}populateChildren(){}save(){this.savedChildren||(this.savedSelf=this.self,this.savedTotal=this.total,this.savedChildren=this.children.slice())}restore(){if(!this.savedChildren)return;this.savedSelf&&this.savedTotal&&(this.self=this.savedSelf,this.total=this.savedTotal),this.removeChildren();const e=this.savedChildren,t=e.length;for(let i=0;i<t;++i)e[i].restore(),this.appendChild(e[i])}merge(e,t){C.merge(this,e,t)}}class y{tree;self;children;formatter;searchableView;total;lastComparator;childrenByCallUID;deepSearch;populated;searchResults;savedTotal;savedChildren;searchResultIndex=-1;constructor(e,t,i){this.tree=this,this.self=0,this.children=[],this.formatter=e,this.searchableView=t,this.total=i,this.lastComparator=null,this.childrenByCallUID=new Map,this.deepSearch=!0,this.populated=!1}static propertyComparator(e,t){let i=P[t?1:0][e];return i||(i=t?function(t,i){return t[e]<i[e]?-1:t[e]>i[e]?1:0}:function(t,i){return t[e]>i[e]?-1:t[e]<i[e]?1:0},P[t?1:0][e]=i),i}get expanded(){return!0}appendChild(e){this.insertChild(e,this.children.length)}focus(e){}exclude(e){}insertChild(e,t){const i=e;this.children.splice(t,0,i),this.childrenByCallUID.set(i.callUID,e)}removeChildren(){this.children=[],this.childrenByCallUID.clear()}populateChildren(){}findChild(e){return e&&this.childrenByCallUID.get(e.callUID)||null}sort(e,t){return C.sort([[this]],e,t)}save(){this.savedChildren||(this.savedTotal=this.total,this.savedChildren=this.children.slice())}restore(){if(!this.savedChildren)return;this.children=this.savedChildren,this.savedTotal&&(this.total=this.savedTotal);const e=this.children,t=e.length;for(let i=0;i<t;++i)e[i].restore();this.savedChildren=null}matchFunction(t){const i=t.query.trim();if(!i.length)return null;const s=i.startsWith(">"),r=i.startsWith("<");let o=i.startsWith("=")||(s||r)&&1===i.indexOf("=");const n=i.endsWith("%"),a=i.length>2&&i.endsWith("ms"),l=!a&&i.endsWith("s");let d=parseFloat(i);(s||r||o)&&(d=o&&(s||r)?parseFloat(i.substring(2)):parseFloat(i.substring(1)));const h=l?1e3*d:d;isNaN(d)||s||r||(o=!0);const c=e.StringUtilities.createPlainTextSearchRegex(i,"i");return function(e){return e.searchMatchedSelfColumn=!1,e.searchMatchedTotalColumn=!1,e.searchMatchedFunctionColumn=!1,n?(r?(e.selfPercent<d&&(e.searchMatchedSelfColumn=!0),e.totalPercent<d&&(e.searchMatchedTotalColumn=!0)):s&&(e.selfPercent>d&&(e.searchMatchedSelfColumn=!0),e.totalPercent>d&&(e.searchMatchedTotalColumn=!0)),o&&(e.selfPercent===d&&(e.searchMatchedSelfColumn=!0),e.totalPercent===d&&(e.searchMatchedTotalColumn=!0))):(a||l)&&(r?(e.self<h&&(e.searchMatchedSelfColumn=!0),e.total<h&&(e.searchMatchedTotalColumn=!0)):s&&(e.self>h&&(e.searchMatchedSelfColumn=!0),e.total>h&&(e.searchMatchedTotalColumn=!0)),o&&(e.self===h&&(e.searchMatchedSelfColumn=!0),e.total===h&&(e.searchMatchedTotalColumn=!0))),(e.functionName.match(c)||e.url&&e.url.match(c))&&(e.searchMatchedFunctionColumn=!0),!!(e.searchMatchedSelfColumn||e.searchMatchedTotalColumn||e.searchMatchedFunctionColumn)&&(e.refresh(),!0)}}performSearch(e,t,i){this.onSearchCanceled();const s=this.matchFunction(e);if(!s)return;this.searchResults=[];const r=this.deepSearch;let o;for(o=this.children[0];o;o=o.traverseNextNode(!r,null,!r)){const e=o;if(!e)break;s(e)&&this.searchResults.push({profileNode:e})}this.searchResultIndex=i?0:this.searchResults.length-1,this.searchableView.updateSearchMatchesCount(this.searchResults.length),this.searchableView.updateCurrentMatchIndex(this.searchResultIndex)}onSearchCanceled(){if(this.searchResults)for(let e=0;e<this.searchResults.length;++e){const t=this.searchResults[e].profileNode;t.searchMatchedSelfColumn=!1,t.searchMatchedTotalColumn=!1,t.searchMatchedFunctionColumn=!1,t.refresh()}this.searchResults=[],this.searchResultIndex=-1}jumpToNextSearchResult(){this.searchResults&&this.searchResults.length&&(this.searchResultIndex=(this.searchResultIndex+1)%this.searchResults.length,this.jumpToSearchResult(this.searchResultIndex))}jumpToPreviousSearchResult(){this.searchResults&&this.searchResults.length&&(this.searchResultIndex=(this.searchResultIndex-1+this.searchResults.length)%this.searchResults.length,this.jumpToSearchResult(this.searchResultIndex))}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!1}jumpToSearchResult(e){const t=this.searchResults[e];if(!t)return;t.profileNode.revealAndSelect(),this.searchableView.updateCurrentMatchIndex(e)}}const P=[{},{}];var T=Object.freeze({__proto__:null,ProfileDataGridNode:C,ProfileDataGridTree:y});class I extends C{remainingNodeInfos;constructor(e,t){super(e,t,null!==e.parent&&Boolean(e.parent.parent)),this.remainingNodeInfos=[]}static sharedPopulate(e){if(void 0===e.remainingNodeInfos)return;const t=e.remainingNodeInfos,i=t.length;for(let s=0;s<i;++s){const i=t[s],r=i.ancestor,o=i.focusNode;let n=e.findChild(r);if(n){const e=i.totalAccountedFor;n.self+=o.self,e||(n.total+=o.total)}else n=new I(r,e.tree),r!==o&&(n.self=o.self,n.total=o.total),e.appendChild(n);const a=r.parent;a&&a.parent&&(i.ancestor=a,n.remainingNodeInfos||(n.remainingNodeInfos=[]),n.remainingNodeInfos.push(i))}delete e.remainingNodeInfos}takePropertiesFromProfileDataGridNode(e){this.save(),this.self=e.self,this.total=e.total}keepOnlyChild(e){this.save(),this.removeChildren(),this.appendChild(e)}exclude(e){this.remainingNodeInfos&&this.populate(),this.save();const t=this.children;let i=this.children.length;for(;i--;)t[i].exclude(e);const s=this.childrenByCallUID.get(e);s&&this.merge(s,!0)}restore(){super.restore(),this.children.length||this.setHasChildren(this.willHaveChildren(this.profileNode))}merge(e,t){this.self-=e.self,super.merge(e,t)}populateChildren(){I.sharedPopulate(this)}willHaveChildren(e){return Boolean(e.parent&&e.parent.parent)}}class x extends y{deepSearch;remainingNodeInfos;constructor(e,t,i,s){super(e,t,s),this.deepSearch=!1;let r=0;const o=[[],[i]],n=new Map;this.remainingNodeInfos=[];for(let e=0;e<o.length;++e){const t=o[e],i=o[++e],s=i.length,a=new WeakMap;for(let e=0;e<s;++e){const s=i[e];if(a.get(s)||a.set(s,++r),s.parent){let e=n.get(s.callUID),i=!1;if(e){const s=t.length;for(let r=0;r<s;++r){const s=a.get(t[r]);if(s&&e.has(s)){i=!0;break}}}else e=new Set,n.set(s.callUID,e);const r=a.get(s);r&&e.add(r),this.remainingNodeInfos.push({ancestor:s,focusNode:s,totalAccountedFor:i})}const l=s.children;l.length&&(o.push(t.concat([s])),o.push(l))}}return C.populate(this),this}focus(e){if(!e)return;this.save();let t=e,i=e;for(;t.parent&&t instanceof I;)t.takePropertiesFromProfileDataGridNode(e),i=t,t=t.parent,t instanceof I&&t.keepOnlyChild(i);this.children=[i],this.total=e.total}exclude(t){if(!t)return;this.save();const i=t.callUID,s=this.childrenByCallUID.get(i);s&&e.ArrayUtilities.removeElement(this.children,s);const r=this.children,o=r.length;for(let e=0;e<o;++e)r[e].exclude(i);this.lastComparator&&this.sort(this.lastComparator,!0)}populateChildren(){I.sharedPopulate(this)}}var R=Object.freeze({__proto__:null,BottomUpProfileDataGridNode:I,BottomUpProfileDataGridTree:x}),N=Object.freeze({__proto__:null});const k=new CSSStyleSheet;k.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 D=new CSSStyleSheet;D.replaceSync('.heap-snapshot-view{overflow:hidden}.heap-snapshot-view .data-grid{border:none;flex:auto}.heap-snapshot-view .data-grid tr:empty{height:16px;visibility:hidden}.heap-snapshot-view .data-grid span.percent-column{width:35px!important}.heap-snapshot-view .object-value-object,\n.object-value-node{display:inline;position:static}.heap-snapshot-view .object-value-string{white-space:nowrap}.heap-snapshot-view td.object-column .objects-count{margin-left:10px;font-size:11px;color:var(--sys-color-token-subtle)}.heap-snapshot-view tr:not(.selected) .object-value-id{color:var(--sys-color-token-subtle)}.profile-view .heap-tracking-overview{flex:0 0 80px;height:80px}.heap-snapshot-view .retaining-paths-view{overflow:hidden}.heap-snapshot-view .heap-snapshot-view-resizer{background-color:var(--sys-color-surface1);display:flex;flex:0 0 21px}.heap-snapshot-view td.object-column > div > span{margin-right:6px}.heap-snapshot-view .heap-snapshot-view-resizer .title{flex:0 1 auto;overflow:hidden;white-space:nowrap}.heap-snapshot-view .heap-snapshot-view-resizer .verticalResizerIcon{background-image:var(--image-file-toolbarResizerVertical);background-repeat:no-repeat;background-position:center;flex:0 0 28px;margin-left:auto}.heap-snapshot-view .heap-snapshot-view-resizer .title > span{display:inline-block;padding-top:3px;vertical-align:middle;margin-left:4px;margin-right:8px}.heap-snapshot-view .heap-snapshot-view-resizer *{pointer-events:none}.heap-snapshot-view tr:not(.selected) td.object-column span.highlight{background-color:inherit}.heap-snapshot-view td.object-column span.heap-object-source-link{float:right}.heap-snapshot-view td.object-column span.heap-object-source-link:empty{animation:fadeInOut 2s infinite}.heap-snapshot-view td.object-column span.heap-object-source-link:empty::before{content:"\\b7\\b7";font-weight:bold}@keyframes fadeInOut{0%{transform:rotate(0)}50%{transform:rotate(0.5turn)}100%{transform:rotate(1turn)}}.heap-object-tag{height:14px;width:14px}.heap-snapshot-view tr:not(.selected) td.object-column span.heap-object-tag,\n.heap-snapshot-view tr:not(.selected) td.object-column span.grayed{color:var(--sys-color-token-subtle)}.heap-snapshot-view tr:not(.selected) .cycled-ancestor-node,\n.heap-snapshot-view tr:not(.selected) .unreachable-ancestor-node{opacity:60%}#heap-recording-view .profile-view{top:80px}.heap-overview-container{overflow:hidden;position:absolute;top:0;width:100%;height:80px}#heap-recording-overview-grid .resources-dividers-label-bar{pointer-events:auto}.heap-recording-overview-canvas{position:absolute;top:20px;left:0;right:0;bottom:0}.heap-snapshot-statistics-view{overflow:auto}.heap-snapshot-stats-pie-chart{margin:12px 30px;flex-shrink:0}.heap-allocation-stack .stack-frame{display:flex;justify-content:space-between;border-bottom:1px solid var(--sys-color-divider);padding:2px}.heap-allocation-stack .stack-frame:focus{background-color:var(--sys-color-tonal-container);color:var(--sys-color-on-tonal-container)}.heap-allocation-stack .stack-frame:hover:not(:focus){background-color:var(--sys-color-state-hover-on-subtle)}.heap-allocation-stack .stack-frame .devtools-link{color:var(--sys-color-primary)}.no-heap-allocation-stack{padding:5px}@media (forced-colors: active){.cycled-ancestor-node{opacity:100%}.heap-snapshot-view td.object-column .objects-count,\n .heap-snapshot-view tr:not(.selected) td.object-column span.heap-object-tag,\n .heap-snapshot-view tr:not(.selected) .object-value-id{color:ButtonText}}\n/*# sourceURL=heapProfiler.css */\n');class E extends n.ObjectWrapper.ObjectWrapper{profileTypeInternal;title;uid;fromFileInternal;tempFile;constructor(e,t){super(),this.profileTypeInternal=e,this.title=t,this.uid=e.incrementProfileUid(),this.fromFileInternal=!1,this.tempFile=null}setTitle(e){this.title=e,this.dispatchEventToListeners("ProfileTitleChanged",this)}profileType(){return this.profileTypeInternal}updateStatus(e,t){this.dispatchEventToListeners("UpdateStatus",new M(e,t))}createSidebarTreeElement(e){throw new Error("Not implemented.")}createView(e){throw new Error("Not implemented.")}removeTempFile(){this.tempFile&&this.tempFile.remove()}dispose(){}canSaveToFile(){return!1}saveToFile(){throw new Error("Not implemented.")}loadFromFile(e){throw new Error("Not implemented.")}fromFile(){return this.fromFileInternal}setFromFile(){this.fromFileInternal=!0}setProfile(e){}}class M{subtitle;wait;constructor(e,t){this.subtitle=e,this.wait=t}}class F extends n.ObjectWrapper.ObjectWrapper{idInternal;nameInternal;profiles;profileBeingRecordedInternal;nextProfileUidInternal;constructor(e,t){super(),this.idInternal=e,this.nameInternal=t,this.profiles=[],this.profileBeingRecordedInternal=null,this.nextProfileUidInternal=1,window.opener||window.addEventListener("pagehide",this.clearTempStorage.bind(this),!1)}typeName(){return""}nextProfileUid(){return this.nextProfileUidInternal}incrementProfileUid(){return this.nextProfileUidInternal++}hasTemporaryView(){return!1}fileExtension(){return null}get buttonTooltip(){return""}get id(){return this.idInternal}get treeItemTitle(){return this.nameInternal}get name(){return this.nameInternal}buttonClicked(){return!1}get description(){return""}isInstantProfile(){return!1}isEnabled(){return!0}getProfiles(){return this.profiles.filter(function(e){return this.profileBeingRecordedInternal!==e}.bind(this))}customContent(){return null}setCustomContentEnabled(e){}getProfile(e){for(let t=0;t<this.profiles.length;++t)if(this.profiles[t].uid===e)return this.profiles[t];return null}loadFromFile(e){let t=e.name;const i=this.fileExtension();i&&t.endsWith(i)&&(t=t.substr(0,t.length-i.length));const s=this.createProfileLoadedFromFile(t);return s.setFromFile(),this.setProfileBeingRecorded(s),this.addProfile(s),s.loadFromFile(e)}createProfileLoadedFromFile(e){throw new Error("Not implemented")}addProfile(e){this.profiles.push(e),this.dispatchEventToListeners("add-profile-header",e)}removeProfile(e){const t=this.profiles.indexOf(e);-1!==t&&(this.profiles.splice(t,1),this.disposeProfile(e))}clearTempStorage(){for(let e=0;e<this.profiles.length;++e)this.profiles[e].removeTempFile()}profileBeingRecorded(){return this.profileBeingRecordedInternal}setProfileBeingRecorded(e){this.profileBeingRecordedInternal=e}profileBeingRecordedRemoved(){}reset(){for(const e of this.profiles.slice())this.disposeProfile(e);this.profiles=[],this.nextProfileUidInternal=1}disposeProfile(e){this.dispatchEventToListeners("remove-profile-header",e),e.dispose(),this.profileBeingRecordedInternal===e&&(this.profileBeingRecordedRemoved(),this.setProfileBeingRecorded(null))}}var j=Object.freeze({__proto__:null,ProfileHeader:E,StatusUpdate:M,ProfileType:F});const H={javascriptVmInstances:"JavaScript VM instances",totalJsHeapSize:"Total JS heap size",totalPageJsHeapSizeChangeTrend:"Total page JS heap size change trend over the last {PH1} minutes.",totalPageJsHeapSizeAcrossAllVm:"Total page JS heap size across all VM instances.",changeRate:"{PH1}/s",increasingBySPerSecond:"increasing by {PH1} per second",decreasingBySPerSecond:"decreasing by {PH1} per second",heapSizeInUseByLiveJsObjects:"Heap size in use by live JS objects.",heapSizeChangeTrendOverTheLastS:"Heap size change trend over the last {PH1} minutes.",empty:"(empty)"},L=t.i18n.registerUIStrings("panels/profiler/IsolateSelector.ts",H),O=t.i18n.getLocalizedString.bind(void 0,L);class z extends r.Widget.VBox{items;list;itemByIsolate;totalElement;totalValueDiv;totalTrendDiv;constructor(){super(!1),this.items=new r.ListModel.ListModel,this.list=new r.ListControl.ListControl(this.items,this,r.ListControl.ListMode.NonViewport),this.list.element.classList.add("javascript-vm-instances-list"),r.ARIAUtils.setLabel(this.list.element,O(H.javascriptVmInstances)),this.contentElement.appendChild(this.list.element),this.itemByIsolate=new Map,this.totalElement=document.createElement("div"),this.totalElement.classList.add("profile-memory-usage-item"),this.totalElement.classList.add("hbox"),this.totalValueDiv=this.totalElement.createChild("div","profile-memory-usage-item-size"),this.totalTrendDiv=this.totalElement.createChild("div","profile-memory-usage-item-trend"),this.totalElement.createChild("div").textContent=O(H.totalJsHeapSize);const e=Math.round(a.IsolateManager.MemoryTrendWindowMs/6e4);r.Tooltip.Tooltip.install(this.totalTrendDiv,O(H.totalPageJsHeapSizeChangeTrend,{PH1:e})),r.Tooltip.Tooltip.install(this.totalValueDiv,O(H.totalPageJsHeapSizeAcrossAllVm)),a.IsolateManager.IsolateManager.instance().observeIsolates(this),a.TargetManager.TargetManager.instance().addEventListener("NameChanged",this.targetChanged,this),a.TargetManager.TargetManager.instance().addEventListener("InspectedURLChanged",this.targetChanged,this)}wasShown(){super.wasShown(),a.IsolateManager.IsolateManager.instance().addEventListener("MemoryChanged",this.heapStatsChanged,this)}willHide(){a.IsolateManager.IsolateManager.instance().removeEventListener("MemoryChanged",this.heapStatsChanged,this)}isolateAdded(e){this.list.element.tabIndex=0;const t=new B(e),i=t.model().target()===a.TargetManager.TargetManager.instance().rootTarget()?0:this.items.length;this.items.insert(i,t),this.itemByIsolate.set(e,t),(1===this.items.length||e.isMainThread())&&this.list.selectItem(t),this.update()}isolateChanged(e){const t=this.itemByIsolate.get(e);t&&t.updateTitle(),this.update()}isolateRemoved(e){const t=this.itemByIsolate.get(e);t&&this.items.remove(this.items.indexOf(t)),this.itemByIsolate.delete(e),0===this.items.length&&(this.list.element.tabIndex=-1),this.update()}targetChanged(e){const t=e.data.model(a.RuntimeModel.RuntimeModel);if(!t)return;const i=a.IsolateManager.IsolateManager.instance().isolateByModel(t),s=i&&this.itemByIsolate.get(i);s&&s.updateTitle()}heapStatsChanged(e){const t=e.data,i=this.itemByIsolate.get(t);i&&i.updateStats(),this.updateTotal()}updateTotal(){let t=0,i=0;for(const e of a.IsolateManager.IsolateManager.instance().isolates())t+=e.usedHeapSize(),i+=e.usedHeapSizeGrowRate();this.totalValueDiv.textContent=e.NumberUtilities.bytesToString(t),z.formatTrendElement(i,this.totalTrendDiv)}static formatTrendElement(t,i){const s=1e3*t;if(Math.abs(s)<1e3)return;const o=e.NumberUtilities.bytesToString(Math.abs(s));let n,a;s>0?(n="⬆"+O(H.changeRate,{PH1:o}),i.classList.toggle("increasing",!0),a=O(H.increasingBySPerSecond,{PH1:o})):(n="⬇"+O(H.changeRate,{PH1:o}),i.classList.toggle("increasing",!1),a=O(H.decreasingBySPerSecond,{PH1:o})),i.textContent=n,r.ARIAUtils.setLabel(i,a)}totalMemoryElement(){return this.totalElement}createElementForItem(e){return e.element}heightForItem(e){return console.assert(!1,"should not be called"),0}updateSelectedItemARIA(e,t){return!1}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,s){i&&i.classList.remove("selected"),s&&s.classList.add("selected");const o=t&&t.model();r.Context.Context.instance().setFlavor(a.HeapProfilerModel.HeapProfilerModel,o&&o.heapProfilerModel()),r.Context.Context.instance().setFlavor(a.CPUProfilerModel.CPUProfilerModel,o&&o.target().model(a.CPUProfilerModel.CPUProfilerModel))}update(){this.updateTotal(),this.list.invalidateRange(0,this.items.length)}}class B{isolate;element;heapDiv;trendDiv;nameDiv;constructor(e){this.isolate=e;const t=Math.round(a.IsolateManager.MemoryTrendWindowMs/6e4);this.element=document.createElement("div"),this.element.classList.add("profile-memory-usage-item"),this.element.classList.add("hbox"),r.ARIAUtils.markAsOption(this.element),this.heapDiv=this.element.createChild("div","profile-memory-usage-item-size"),r.Tooltip.Tooltip.install(this.heapDiv,O(H.heapSizeInUseByLiveJsObjects)),this.trendDiv=this.element.createChild("div","profile-memory-usage-item-trend"),r.Tooltip.Tooltip.install(this.trendDiv,O(H.heapSizeChangeTrendOverTheLastS,{PH1:t})),this.nameDiv=this.element.createChild("div","profile-memory-usage-item-name"),this.updateTitle()}model(){return this.isolate.runtimeModel()}updateStats(){this.heapDiv.textContent=e.NumberUtilities.bytesToString(this.isolate.usedHeapSize()),z.formatTrendElement(this.isolate.usedHeapSizeGrowRate(),this.trendDiv)}updateTitle(){const e=new Map;for(const t of this.isolate.models()){const i=t.target(),s=a.TargetManager.TargetManager.instance().rootTarget()!==i?i.name():"",r=new n.ParsedURL.ParsedURL(i.inspectedURL()),o=r.isValid?r.domain():"",l=i.decorateLabel(o&&s?`${o}: ${s}`:s||o||O(H.empty));e.set(l,(e.get(l)||0)+1)}this.nameDiv.removeChildren();const t=[];for(const[i,s]of e){const e=s>1?`${i} (${s})`:i;t.push(e);const o=this.nameDiv.createChild("div");o.textContent=e,r.Tooltip.Tooltip.install(o,String(e))}}}var A=Object.freeze({__proto__:null,IsolateSelector:z,ListItem:B});const G=new CSSStyleSheet;G.replaceSync('.profile-launcher-view{overflow:auto}.profile-launcher-view-content{margin:10px 16px;flex:auto 1 0}.profile-launcher-view-content h1{font-size:15px;font-weight:normal;margin:6px 0 10px}.profile-launcher-view-content [is="dt-radio"]{font-size:13px}.profile-launcher-view-content p{color:var(--sys-color-token-subtle);margin-top:1px;margin-left:22px}.profile-launcher-view-content p [is="dt-checkbox"]{display:flex}.profile-launcher-view-content button.text-button.running,\n.profile-launcher-view-content button.text-button.running:focus{color:var(--sys-color-error)}.profile-launcher-view-content > div{flex:auto 0 0}.profile-launcher-view-content > .profile-isolate-selector-block{flex:auto 1 0;overflow:hidden}.profile-isolate-selector-block button{min-width:110px}.profile-launcher-target-list{margin-bottom:6px;border:1px solid var(--sys-color-divider);flex:150px 1 0}.profile-launcher-target-list-container{overflow:auto}.profile-memory-usage-item{min-width:100%;width:max-content;padding:4px;line-height:16px}.profile-isolate-selector-block > .profile-memory-usage-item{margin-left:1px;margin-bottom:4px;font-weight:bolder}.profile-memory-usage-item.selected{background-color:var(--sys-color-neutral-container)}.profile-memory-usage-item:focus{background-color:var(--sys-color-tonal-container)}.profile-launcher-target-list .profile-memory-usage-item:hover:not(.selected){background-color:var(--sys-color-state-hover-on-subtle)}.javascript-vm-instances-list{width:max-content;min-width:100%}.javascript-vm-instances-list:focus .profile-memory-usage-item.selected{background-color:var(--sys-color-tonal-container)}.profile-memory-usage-item > div{flex-shrink:0;margin-right:12px}.profile-memory-usage-item-size{width:60px;text-align:right}.profile-memory-usage-item-trend{min-width:5em;color:var(--sys-color-tertiary)}.profile-memory-usage-item-trend.increasing{color:var(--sys-color-error)}.profile-launcher-buttons{flex-wrap:wrap;column-gap:8px}@media (forced-colors: active){.profile-memory-usage-item{forced-color-adjust:none;border-left-color:transparent}.profile-memory-usage-item-trend,\n .profile-memory-usage-item-trend.increasing,\n .profile-launcher-view-content button.running,\n body.inactive .profile-launcher-view-content button.running:not(.toolbar-item){color:ButtonText}.javascript-vm-instances-list .profile-memory-usage-item:hover:not(.selected){background-color:Highlight;color:HighlightText}.javascript-vm-instances-list .profile-memory-usage-item.selected .profile-memory-usage-item-trend,\n .javascript-vm-instances-list .profile-memory-usage-item.selected .profile-memory-usage-item-trend.increasing{color:ButtonFace}.javascript-vm-instances-list .profile-memory-usage-item:hover:not(.selected) .profile-memory-usage-item-trend,\n .javascript-vm-instances-list .profile-memory-usage-item:hover:not(.selected) .profile-memory-usage-item-trend.increasing{background-color:Highlight;color:HighlightText}.javascript-vm-instances-list .profile-memory-usage-item.selected{background-color:ButtonText;border-color:Highlight;color:ButtonFace}.javascript-vm-instances-list:focus .profile-memory-usage-item.selected,\n .javascript-vm-instances-list:focus-visible .profile-memory-usage-item.selected{background-color:Highlight;border-color:ButtonText;color:HighlightText}}\n/*# sourceURL=profileLauncherView.css */\n');const V={selectJavascriptVmInstance:"Select JavaScript VM instance",load:"Load profile",takeSnapshot:"Take snapshot",stop:"Stop",start:"Start",selectProfilingType:"Select profiling type"},W=t.i18n.registerUIStrings("panels/profiler/ProfileLauncherView.ts",V),U=t.i18n.getLocalizedString.bind(void 0,W);class _ extends(n.ObjectWrapper.eventMixin(r.Widget.VBox)){panel;contentElementInternal;selectedProfileTypeSetting;profileTypeHeaderElement;profileTypeSelectorForm;controlButton;loadButton;recordButtonEnabled;typeIdToOptionElementAndProfileType;isProfiling;isInstantProfile;isEnabled;constructor(e){super(),this.panel=e,this.element.classList.add("profile-launcher-view"),this.contentElementInternal=this.element.createChild("div","profile-launcher-view-content vbox");const t=this.contentElementInternal.createChild("div","vbox");this.selectedProfileTypeSetting=n.Settings.Settings.instance().createSetting("selected-profile-type","CPU"),this.profileTypeHeaderElement=t.createChild("h1"),this.profileTypeSelectorForm=t.createChild("form"),r.ARIAUtils.markAsRadioGroup(this.profileTypeSelectorForm);const i=this.contentElementInternal.createChild("div","vbox profile-isolate-selector-block");i.createChild("h1").textContent=U(V.selectJavascriptVmInstance);const s=new z,o=i.createChild("div","vbox profile-launcher-target-list");o.classList.add("profile-launcher-target-list-container"),s.show(o),i.appendChild(s.totalMemoryElement());const a=this.contentElementInternal.createChild("div","hbox profile-launcher-buttons");this.controlButton=r.UIUtils.createTextButton("",this.controlButtonClicked.bind(this),{jslogContext:"profiler.heap-toggle-recording",variant:"primary"}),this.loadButton=new d.Button.Button,this.loadButton.data={iconName:"import",variant:"outlined",jslogContext:"profiler.load-from-file"},this.loadButton.textContent=U(V.load),this.loadButton.addEventListener("click",this.loadButtonClicked.bind(this)),a.appendChild(this.loadButton),a.appendChild(this.controlButton),this.recordButtonEnabled=!0,this.typeIdToOptionElementAndProfileType=new Map}loadButtonClicked(){r.ActionRegistry.ActionRegistry.instance().getAction("profiler.load-from-file").execute()}updateControls(){this.isEnabled&&this.recordButtonEnabled?this.controlButton.removeAttribute("disabled"):this.controlButton.setAttribute("disabled",""),r.Tooltip.Tooltip.install(this.controlButton,this.recordButtonEnabled?"":r.UIUtils.anotherProfilerActiveLabel()),this.isInstantProfile?(this.controlButton.classList.remove("running"),this.controlButton.textContent=U(V.takeSnapshot)):this.isProfiling?(this.controlButton.classList.add("running"),this.controlButton.textContent=U(V.stop)):(this.controlButton.classList.remove("running"),this.controlButton.textContent=U(V.start));for(const{optionElement:e}of this.typeIdToOptionElementAndProfileType.values())e.disabled=Boolean(this.isProfiling)}profileStarted(){this.isProfiling=!0,this.updateControls()}profileFinished(){this.isProfiling=!1,this.updateControls()}updateProfileType(e,t){this.isInstantProfile=e.isInstantProfile(),this.recordButtonEnabled=t,this.isEnabled=e.isEnabled(),this.updateControls()}addProfileType(e){const t=r.UIUtils.createRadioLabel("profile-type",e.name,void 0,"profiler.profile-type");this.profileTypeSelectorForm.appendChild(t);const i=t.radioElement;this.typeIdToOptionElementAndProfileType.set(e.id,{optionElement:i,profileType:e}),i.addEventListener("change",this.profileTypeChanged.bind(this,e),!1);this.profileTypeSelectorForm.createChild("p").textContent=e.description,r.ARIAUtils.setDescription(i,e.description);const s=e.customContent();s&&(s.setAttribute("role","group"),s.setAttribute("aria-labelledby",`${i.id}`),this.profileTypeSelectorForm.createChild("p").appendChild(s),e.setCustomContentEnabled(!1));const o=this.typeIdToOptionElementAndProfileType.size>1?U(V.selectProfilingType):e.name;this.profileTypeHeaderElement.textContent=o,r.ARIAUtils.setLabel(this.profileTypeSelectorForm,o)}restoreSelectedProfileType(){let e=this.selectedProfileTypeSetting.get();this.typeIdToOptionElementAndProfileType.has(e)||(e=this.typeIdToOptionElementAndProfileType.keys().next().value,this.selectedProfileTypeSetting.set(e));const t=this.typeIdToOptionElementAndProfileType.get(e);t.optionElement.checked=!0;const i=t.profileType;for(const[t,{profileType:i}]of this.typeIdToOptionElementAndProfileType){const s=t===e;i.setCustomContentEnabled(s)}this.dispatchEventToListeners("ProfileTypeSelected",i)}controlButtonClicked(){this.panel.toggleRecord()}profileTypeChanged(e){const t=this.selectedProfileTypeSetting.get();this.typeIdToOptionElementAndProfileType.get(t).profileType.setCustomContentEnabled(!1),e.setCustomContentEnabled(!0),this.dispatchEventToListeners("ProfileTypeSelected",e),this.isInstantProfile=e.isInstantProfile(),this.isEnabled=e.isEnabled(),this.updateControls(),this.selectedProfileTypeSetting.set(e.id)}wasShown(){super.wasShown(),this.registerCSSFiles([G])}}var $=Object.freeze({__proto__:null,ProfileLauncherView:_});const J={profileOptions:"Profile options"},q=t.i18n.registerUIStrings("panels/profiler/ProfileSidebarTreeElement.ts",J),Q=t.i18n.getLocalizedString.bind(void 0,q);class K extends r.TreeOutline.TreeElement{iconElement;titlesElement;menuElement;titleContainer;titleElement;subtitleElement;className;small;dataDisplayDelegate;profile;saveLinkElement;editing;constructor(e,t,i){super("",!1),this.iconElement=document.createElement("div"),this.iconElement.classList.add("icon"),this.titlesElement=document.createElement("div"),this.titlesElement.classList.add("titles"),this.titlesElement.classList.add("no-subtitle"),this.titlesElement.setAttribute("jslog",`${l.value("title").track({dblclick:!0,change:!0})}`),this.titleContainer=this.titlesElement.createChild("span","title-container"),this.titleElement=this.titleContainer.createChild("span","title"),this.subtitleElement=this.titlesElement.createChild("span","subtitle"),this.menuElement=new d.Button.Button,this.menuElement.data={variant:"icon",iconName:"dots-vertical",title:Q(J.profileOptions)},this.menuElement.tabIndex=-1,this.menuElement.addEventListener("click",this.handleContextMenuEvent.bind(this)),this.menuElement.setAttribute("jslog",`${l.dropDown("profile-options").track({click:!0})}`),this.titleElement.textContent=t.title,this.className=i,this.small=!1,this.dataDisplayDelegate=e,this.profile=t,t.addEventListener("UpdateStatus",this.updateStatus,this)}updateStatus(e){const t=e.data;null!==t.subtitle&&(this.subtitleElement.textContent=t.subtitle.length>0?`(${t.subtitle})`:"",this.titlesElement.classList.toggle("no-subtitle",!t.subtitle),r.ARIAUtils.setLabel(this.listItemElement,`${this.profile.title}, ${t.subtitle}`)),"boolean"==typeof t.wait&&this.listItemElement&&(this.iconElement.classList.toggle("spinner",t.wait),this.listItemElement.classList.toggle("wait",t.wait))}ondblclick(e){return this.editing||this.startEditing(e.target),!1}startEditing(e){const t=e.enclosingNodeOrSelfWithClass("title");if(!t)return;const i=new r.InplaceEditor.Config(this.editingCommitted.bind(this),this.editingCancelled.bind(this));this.editing=r.InplaceEditor.InplaceEditor.startEditing(t,i)}editingCommitted(e,t){delete this.editing,this.profile.setTitle(t)}editingCancelled(){delete this.editing}dispose(){this.profile.removeEventListener("UpdateStatus",this.updateStatus,this)}onselect(){return this.dataDisplayDelegate.showProfile(this.profile),!0}ondelete(){return this.profile.profileType().removeProfile(this.profile),!0}onattach(){this.className&&this.listItemElement.classList.add(this.className),this.small&&this.listItemElement.classList.add("small"),this.listItemElement.append(this.iconElement,this.titlesElement,this.menuElement),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!0),r.ARIAUtils.setDescription(this.listItemElement,this.profile.profileType().name)}handleContextMenuEvent(e){const t=new r.ContextMenu.ContextMenu(e);t.appendItemsAtLocation("profilerMenu"),t.show()}setSmall(e){this.small=e,this.listItemElement&&this.listItemElement.classList.toggle("small",this.small)}setMainTitle(e){this.titleElement.textContent=e}}var Y=Object.freeze({__proto__:null,ProfileSidebarTreeElement:K});const Z=new CSSStyleSheet;Z.replaceSync("#profile-views{flex:auto;position:relative}.profile-view .data-grid table.data{background:var(--sys-color-cdt-base-container)}.profile-view .data-grid tr:not(.selected) .highlight{background-color:var(--sys-color-tonal-container)}.profile-view .data-grid tr:hover td:not(.bottom-filler-td){background-color:var(--sys-color-state-hover-on-subtle)}.profile-view .data-grid td.numeric-column{text-align:right}.profile-view .data-grid div.profile-multiple-values{float:right}.profile-view .data-grid span.percent-column{color:var(--sys-color-token-subtle);width:9ex;display:inline-block}.profile-view .data-grid tr.selected span{color:inherit}.profiles-toolbar{background-color:var(--sys-color-cdt-base-container);border-bottom:1px solid var(--sys-color-divider);flex-shrink:0}.profiles-tree-sidebar{flex:auto;overflow:hidden}.profiles-sidebar-tree-box{overflow-y:auto}.profile-view{display:flex;overflow:hidden}.profile-view .data-grid{border:none;flex:auto}.profile-view .data-grid th.self-column,\n.profile-view .data-grid th.total-column{text-align:center}.profile-node-file{float:right;color:var(--sys-color-token-subtle)}.profile-warn-marker{vertical-align:-1px;margin-right:2px}.cpu-profile-flame-chart-overview-container{overflow:hidden;position:absolute;top:0;width:100%;height:80px}#cpu-profile-flame-chart-overview-container{border-bottom:1px solid var(--sys-color-divider);overflow:hidden}.cpu-profile-flame-chart-overview-canvas{position:absolute;top:20px;left:0;right:0;bottom:0}#cpu-profile-flame-chart-overview-grid .resources-dividers-label-bar{pointer-events:auto}.cpu-profile-flame-chart-overview-pane{flex:0 0 80px!important}.profile-text-view{padding:10px;overflow:auto;margin:0;user-select:text;cursor:text}.empty-landing-page{position:absolute;background-color:var(--sys-color-cdt-base-container);justify-content:center;align-items:center;overflow:auto;font-size:16px;color:var(--sys-color-token-subtle);padding:50px}button{cursor:pointer}@media (forced-colors: active){.profile-view .data-grid tr:hover td:not(.bottom-filler-td){background:Highlight}.profile-view .data-grid table.data{background:transparent}}\n/*# sourceURL=profilesPanel.css */\n");const X=new CSSStyleSheet;X.replaceSync(':host{padding:var(--sys-size-3) 0}.tree-outline-disclosure{width:100%}li .icon{width:20px;height:20px;margin-right:var(--sys-size-6);flex:none}.heap-snapshot-sidebar-tree-item .icon,\n.profile-sidebar-tree-item .icon{mask-image:var(--image-file-heap-snapshot);background:var(--icon-default)}.profile-group-sidebar-tree-item .icon{mask-image:var(--image-file-heap-snapshots);background:var(--icon-default)}li.small .icon{width:16px;height:16px}li.wait .icon{content:none}.heap-snapshot-sidebar-tree-item.wait .icon{mask-image:unset;background-color:inherit}.heap-snapshot-sidebar-tree-item.small .icon{mask-image:var(--image-file-heap-snapshots);background:var(--icon-default)}.profile-sidebar-tree-item.small .icon{mask-image:var(--image-file-heap-snapshots);background:var(--icon-default)}.tree-outline li:not(.parent)::before{content:none}ol.tree-outline{flex:auto;padding:0}.tree-outline li{height:var(--sys-size-12);padding-left:var(--sys-size-7);margin-right:var(--sys-size-5);color:var(--sys-color-on-surface);& .leading-icons{margin-right:var(--sys-size-6);flex:none}& .selection{border-radius:0 100px 100px 0}}.tree-outline .profile-launcher-view-tree-item,\n.tree-outline li.profiles-tree-section + .children > li{border-radius:0 100px 100px 0;position:relative;&.selected{background-color:var(--app-color-navigation-drawer-background-selected);color:var(--app-color-navigation-drawer-label-selected);& devtools-icon{color:var(--app-color-navigation-drawer-label-selected)}& > .icon:not(.spinner){background-color:var(--app-color-navigation-drawer-label-selected)}}&:active::before{background-color:var(--sys-color-state-ripple-neutral-on-subtle);mask-image:none;content:"";height:100%;width:100%;border-radius:inherit;position:absolute;top:0;left:0}&:focus-visible{box-shadow:inset 0 0 0 2px var(--sys-color-state-focus-ring)}}.tree-outline li.profiles-tree-section{margin-top:var(--sys-size-6);line-height:var(--sys-size-8);&:hover:not(:has(span[is="dt-checkbox"])) .selection{background-color:transparent}}.tree-outline li.profiles-tree-section::before{display:none}.tree-outline ol{overflow:hidden;padding:0}li.wait .spinner::before{--dimension:20px;margin:0}li.wait.small .spinner::before{--dimension:14px;--clip-size:9px;--override-spinner-size:2px;margin:1px}li.wait.selected .spinner::before{--override-spinner-color:var(--ref-palette-neutral100)}@keyframes spinner-animation{from{transform:rotate(0)}to{transform:rotate(360deg)}}li.small{height:20px}li .titles{display:inline-flex;padding-right:var(--sys-size-5)}li .titles > .title-container{z-index:1;text-overflow:ellipsis;overflow:hidden}li.small .titles{top:2px;line-height:normal}li:not(.small) .title::after{content:"\\A";white-space:pre}li .subtitle{text-overflow:ellipsis;overflow:hidden;margin-left:var(--sys-size-3)}li.small .subtitle{display:none}li devtools-button{min-width:var(--sys-size-12);visibility:hidden}li.selected:hover devtools-button{visibility:visible;margin-left:auto}@media (forced-colors: active){.tree-outline li,\n .tree-outline li.profiles-tree-section,\n .tree-outline li:hover .tree-element-title{forced-color-adjust:none;color:ButtonText;text-shadow:unset}.tree-outline .profile-launcher-view-tree-item,\n .tree-outline li.profiles-tree-section + .children > li{&.selected{background-color:Highlight;color:HighlightText;& devtools-icon{color:HighlightText}& > .icon:not(.spinner){background-color:HighlightText}}}}\n/*# sourceURL=profilesSidebarTree.css */\n');const ee={cantLoadFileSupportedFile:"Can’t load file. Supported file extensions: ''{PH1}''.",cantLoadProfileWhileAnother:"Can’t load profile while another profile is being recorded.",profileLoadingFailedS:"Profile loading failed: {PH1}.",runD:"Run {PH1}",profiles:"Profiles"},te=t.i18n.registerUIStrings("panels/profiler/ProfilesPanel.ts",ee),ie=t.i18n.getLocalizedString.bind(void 0,te);class se extends r.Panel.PanelWithSidebar{profileTypes;profilesItemTreeElement;sidebarTree;profileViews;toolbarElement;toggleRecordAction;toggleRecordButton;#e;profileViewToolbar;profileGroups;launcherView;visibleView;profileToView;typeIdToSidebarSection;fileSelectorElement;selectedProfileType;constructor(e,t,i){super(e),this.profileTypes=t;const s=new r.Widget.VBox;this.splitWidget().setMainWidget(s),this.profilesItemTreeElement=new ae(this),this.sidebarTree=new r.TreeOutline.TreeOutlineInShadow,this.sidebarTree.element.classList.add("profiles-sidebar-tree-box"),this.panelSidebarElement().appendChild(this.sidebarTree.element),this.sidebarTree.appendChild(this.profilesItemTreeElement),this.sidebarTree.element.addEventListener("keydown",this.onKeyDown.bind(this),!1),this.profileViews=document.createElement("div"),this.profileViews.id="profile-views",this.profileViews.classList.add("vbox"),s.element.appendChild(this.profileViews),this.toolbarElement=document.createElement("div"),this.toolbarElement.classList.add("profiles-toolbar"),s.element.insertBefore(this.toolbarElement,s.element.firstChild),this.panelSidebarElement().classList.add("profiles-tree-sidebar");const o=document.createElement("div");o.classList.add("profiles-toolbar"),o.setAttribute("jslog",`${l.toolbar("profiles-sidebar")}`),this.panelSidebarElement().insertBefore(o,this.panelSidebarElement().firstChild);const n=new r.Toolbar.Toolbar("",o);n.makeWrappable(!0),this.toggleRecordAction=r.ActionRegistry.ActionRegistry.instance().getAction(i),this.toggleRecordButton=r.Toolbar.Toolbar.createActionButton(this.toggleRecordAction),n.appendToolbarItem(this.toggleRecordButton),n.appendToolbarItem(r.Toolbar.Toolbar.createActionButtonForId("profiler.clear-all")),n.appendSeparator(),n.appendToolbarItem(r.Toolbar.Toolbar.createActionButtonForId("profiler.load-from-file")),this.#e=r.ActionRegistry.ActionRegistry.instance().getAction("profiler.save-to-file"),this.#e.setEnabled(!1),n.appendToolbarItem(r.Toolbar.Toolbar.createActionButton(this.#e)),n.appendSeparator(),n.appendToolbarItem(r.Toolbar.Toolbar.createActionButtonForId("components.collect-garbage")),this.profileViewToolbar=new r.Toolbar.Toolbar("",this.toolbarElement),this.profileViewToolbar.makeWrappable(!0),this.profileViewToolbar.element.setAttribute("jslog",`${l.toolbar("profile-view")}`),this.profileGroups={},this.launcherView=new _(this),this.launcherView.addEventListener("ProfileTypeSelected",this.onProfileTypeSelected,this),this.profileToView=[],this.typeIdToSidebarSection={};const d=this.profileTypes;for(let e=0;e<d.length;e++)this.registerProfileType(d[e]);this.launcherView.restoreSelectedProfileType(),this.profilesItemTreeElement.select(),this.showLauncherView(),this.createFileSelectorElement(),a.TargetManager.TargetManager.instance().addEventListener("SuspendStateChanged",this.onSuspendStateChanged,this),r.Context.Context.instance().addFlavorChangeListener(a.CPUProfilerModel.CPUProfilerModel,this.updateProfileTypeSpecificUI,this),r.Context.Context.instance().addFlavorChangeListener(a.HeapProfilerModel.HeapProfilerModel,this.updateProfileTypeSpecificUI,this)}onKeyDown(e){const t=e;let i=!1;"ArrowDown"!==t.key||t.altKey?"ArrowUp"!==t.key||t.altKey||(i=this.sidebarTree.selectPrevious()):i=this.sidebarTree.selectNext(),i&&t.consume(!0)}searchableView(){const e=this.visibleView;return e&&e.searchableView?e.searchableView():null}createFileSelectorElement(){this.fileSelectorElement&&this.element.removeChild(this.fileSelectorElement),this.fileSelectorElement=r.UIUtils.createFileSelectorElement(this.loadFromFile.bind(this)),this.element.appendChild(this.fileSelectorElement)}findProfileTypeByExtension(e){return this.profileTypes.find((t=>Boolean(t.fileExtension())&&e.endsWith(t.fileExtension()||"")))||null}async loadFromFile(e){this.createFileSelectorElement();const t=this.findProfileTypeByExtension(e.name);if(!t){const e=new Set(this.profileTypes.map((e=>e.fileExtension())).filter((e=>e)));return void n.Console.Console.instance().error(ie(ee.cantLoadFileSupportedFile,{PH1:Array.from(e).join("', '")}))}if(Boolean(t.profileBeingRecorded()))return void n.Console.Console.instance().error(ie(ee.cantLoadProfileWhileAnother));const i=await t.loadFromFile(e);i&&"message"in i&&r.UIUtils.MessageDialog.show(ie(ee.profileLoadingFailedS,{PH1:i.message}),void 0,"profile-loading-failed")}toggleRecord(){if(!this.toggleRecordAction.enabled())return!0;const t=e.DOMUtilities.deepActiveElement(this.element.ownerDocument),i=this.selectedProfileType;if(!i)return!0;const s=i.buttonClicked();return this.updateToggleRecordAction(s),s?(this.launcherView.profileStarted(),i.hasTemporaryView()&&this.showProfile(i.profileBeingRecorded())):this.launcherView.profileFinished(),t&&t.focus(),!0}onSuspendStateChanged(){this.updateToggleRecordAction(this.toggleRecordAction.toggled())}updateToggleRecordAction(e){const t=Boolean(r.Context.Context.instance().flavor(a.CPUProfilerModel.CPUProfilerModel)||r.Context.Context.instance().flavor(a.HeapProfilerModel.HeapProfilerModel)),i=e||!a.TargetManager.TargetManager.instance().allTargetsSuspended()&&t;this.toggleRecordAction.setEnabled(i),this.toggleRecordAction.setToggled(e),i?this.toggleRecordButton.setTitle(this.selectedProfileType?this.selectedProfileType.buttonTooltip:""):this.toggleRecordButton.setTitle(r.UIUtils.anotherProfilerActiveLabel()),this.selectedProfileType&&this.launcherView.updateProfileType(this.selectedProfileType,i)}profileBeingRecordedRemoved(){this.updateToggleRecordAction(!1),this.launcherView.profileFinished()}onProfileTypeSelected(e){this.selectedProfileType=e.data,this.updateProfileTypeSpecificUI()}updateProfileTypeSpecificUI(){this.updateToggleRecordAction(this.toggleRecordAction.toggled())}reset(){this.profileTypes.forEach((e=>e.reset())),delete this.visibleView,this.profileGroups={},this.updateToggleRecordAction(!1),this.laun