@react-native/debugger-frontend 0.73.1 → 0.73.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUILD_INFO +2 -2
- package/dist/third-party/front_end/Images/Images.js +1 -0
- package/dist/third-party/front_end/Images/favicon.ico +0 -0
- package/dist/third-party/front_end/core/i18n/locales/en-US.json +1 -1
- package/dist/third-party/front_end/device_mode_emulation_frame.html +2 -1
- package/dist/third-party/front_end/devtools_app.html +2 -1
- package/dist/third-party/front_end/entrypoints/js_app/js_app.js +1 -1
- package/dist/third-party/front_end/entrypoints/main/main.js +1 -1
- package/dist/third-party/front_end/entrypoints/node_app/node_app.js +1 -1
- package/dist/third-party/front_end/entrypoints/rn_inspector/rn_inspector.js +1 -1
- package/dist/third-party/front_end/inspector.html +2 -1
- package/dist/third-party/front_end/js_app.html +2 -1
- package/dist/third-party/front_end/ndb_app.html +2 -1
- package/dist/third-party/front_end/node_app.html +2 -1
- package/dist/third-party/front_end/panels/js_profiler/js_profiler-meta.js +1 -1
- package/dist/third-party/front_end/panels/profiler/profiler.js +1 -1
- package/dist/third-party/front_end/panels/rn_welcome/rn_welcome.js +1 -1
- package/dist/third-party/front_end/rn_inspector.html +2 -1
- package/dist/third-party/front_end/worker_app.html +2 -1
- package/package.json +1 -1
|
@@ -4,4 +4,4 @@ import*as e from"../../core/platform/platform.js";import*as t from"../../core/i1
|
|
|
4
4
|
<span class="value object-value-${e}">${t}</span>
|
|
5
5
|
<span class="object-value-id">@${this.snapshotNodeId}</span>
|
|
6
6
|
</div>
|
|
7
|
-
</td>`,r=i.$("container");this.prefixObjectCell(r),this.reachableFromWindow&&r.appendChild(s.Fragment.html`<span class="heap-object-tag" title="${qe(Je.userObjectReachableFromWindow)}">🗖</span>`),this.detachedDOMTreeNode&&r.appendChild(s.Fragment.html`<span class="heap-object-tag" title="${qe(Je.detachedFromDomTree)}">✀</span>`),this.appendSourceLocation(r);const o=i.element();return this.depth&&o.style.setProperty("padding-left",this.depth*this.dataGrid.indentWidth+"px"),o}prefixObjectCell(e){}async appendSourceLocation(e){const t=s.Fragment.html`<span class="heap-object-source-link">`;e.appendChild(t);const i=await this.dataGridInternal.dataDisplayDelegate().linkifyObject(this.snapshotNodeIndex);i?(t.appendChild(i),this.linkElement=i):t.remove()}async queryObjectContent(e,t){return await this.tryQueryObjectContent(e,t)||e.runtimeModel().createRemoteObjectFromPrimitiveValue(qe(Je.previewIsNotAvailable))}async tryQueryObjectContent(e,t){return"string"===this.type?e.runtimeModel().createRemoteObjectFromPrimitiveValue(this.nameInternal):await e.objectForSnapshotObjectId(String(this.snapshotNodeId),t)}async updateHasChildren(){const e=await this.provider().isEmpty();this.setHasChildren(!e)}shortenWindowURL(t,i){const r=t.indexOf("/"),s=i?t.indexOf("@"):t.length;if(-1===r||-1===s)return t;const o=t.substring(r+1,s).trimLeft();let n=e.StringUtilities.trimURL(o);return n.length>40&&(n=e.StringUtilities.trimMiddle(n,40)),t.substr(0,r+2)+n+t.substr(s)}populateContextMenu(e,t,i){if(e.revealSection().appendItem(qe(Je.revealInSummaryView),(()=>{t.showObject(String(this.snapshotNodeId),qe(Je.summary))})),this.referenceName)for(const i of this.referenceName.matchAll(/\((?<objectName>[^@)]*) @(?<snapshotNodeId>\d+)\)/g)){const{objectName:r,snapshotNodeId:s}=i.groups;e.revealSection().appendItem(qe(Je.revealObjectSWithIdSInSummary,{PH1:r,PH2:s}),(()=>{t.showObject(s,qe(Je.summary))}))}i&&e.revealSection().appendItem(qe(Je.storeAsGlobalVariable),(async()=>{const e=await this.tryQueryObjectContent(i,"");if(e){const t=i.target().model(l.ConsoleModel.ConsoleModel);await(t?.saveToTempVariable(s.Context.Context.instance().flavor(l.RuntimeModel.ExecutionContext),e))}else o.Console.Console.instance().error(qe(Je.previewIsNotAvailable))}))}}class Ze extends Ye{referenceName;referenceType;edgeIndex;snapshot;parentObjectNode;cycledWithAncestorGridNode;constructor(e,t,i,r){super(e,i.node),this.referenceName=i.name,this.referenceType=i.type,this.edgeIndex=i.edgeIndex,this.snapshot=t,this.parentObjectNode=r,this.cycledWithAncestorGridNode=this.findAncestorWithSameSnapshotNodeId(),this.cycledWithAncestorGridNode||this.updateHasChildren();const s=this.data;s.count="",s.addedCount="",s.removedCount="",s.countDelta="",s.addedSize="",s.removedSize="",s.sizeDelta=""}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.snapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create a provider on a root node");return this.snapshot.createEdgesProvider(this.snapshotNodeIndex)}findAncestorWithSameSnapshotNodeId(){let e=this.parentObjectNode;for(;e;){if(e.snapshotNodeId===this.snapshotNodeId)return e;e=e.parentObjectNode}return null}createChildNode(e){return new Ze(this.dataGridInternal,this.snapshot,e,this)}getHash(){return this.edgeIndex}comparator(){const e=this.dataGridInternal.isSortOrderAscending();switch(this.dataGridInternal.sortColumnId()){case"object":return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",e,"retainedSize",!1);case"count":default:return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",!0,"retainedSize",!1);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"!edgeName",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"!edgeName",!0);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",e,"name",!0)}}prefixObjectCell(e){let t=this.referenceName||"(empty)",i="name";switch(this.referenceType){case"context":i="object-value-number";break;case"internal":case"hidden":case"weak":i="object-value-null";break;case"element":t=`[${t}]`}this.cycledWithAncestorGridNode&&e.classList.add("cycled-ancessor-node"),e.prepend(s.Fragment.html`<span class="property-name ${i}">${t}</span> <span class="grayed">${this.edgeNodeSeparator()}</span>`)}edgeNodeSeparator(){return"::"}}class Xe extends Ze{constructor(e,t,i,r){super(e,t,i,r)}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create providers on root nodes");return this.snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex)}createChildNode(e){return new Xe(this.dataGridInternal,this.snapshot,e,this)}edgeNodeSeparator(){return qe(Je.inElement)}expand(){this.expandRetainersChain(20)}expandRetainersChain(e){if(!this.populated)return this.once(Ke.Events.PopulateComplete).then((()=>this.expandRetainersChain(e))),void this.populate();if(super.expand(),--e>0&&this.children.length>0){const t=this.children[0];if((t.distance||0)>1)return void t.expandRetainersChain(e)}this.dataGridInternal.dispatchEventToListeners(pt.ExpandRetainersComplete)}}class et extends Ye{baseSnapshotOrSnapshot;isDeletedNode;constructor(t,i,r,s){super(t,r),this.baseSnapshotOrSnapshot=i,this.isDeletedNode=s,this.updateHasChildren();const o=this.data;o.count="",o.countDelta="",o.sizeDelta="",this.isDeletedNode?(o.addedCount="",o.addedSize="",o.removedCount="•",o.removedSize=e.NumberUtilities.withThousandsSeparator(this.shallowSize||0)):(o.addedCount="•",o.addedSize=e.NumberUtilities.withThousandsSeparator(this.shallowSize||0),o.removedCount="",o.removedSize="")}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.baseSnapshotOrSnapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create providers on root nodes");return this.baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeIndex)}createChildNode(e){return new Ze(this.dataGridInternal,this.baseSnapshotOrSnapshot,e,null)}getHash(){if(void 0===this.snapshotNodeId)throw new Error("Cannot hash root nodes");return this.snapshotNodeId}comparator(){const e=this.dataGridInternal.isSortOrderAscending();switch(this.dataGridInternal.sortColumnId()){case"object":return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",e,"retainedSize",!1);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",e,"retainedSize",!1);case"count":default:return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",!0,"retainedSize",!1);case"addedSize":case"removedSize":case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"!edgeName",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"!edgeName",!0)}}}class tt extends Ke{nameInternal;nodeFilter;distance;count;shallowSize;retainedSize;constructor(t,i,r,s){super(t,r.count>0),this.nameInternal=i,this.nodeFilter=s,this.distance=r.distance,this.count=r.count,this.shallowSize=r.self,this.retainedSize=r.maxRet;const o=t.snapshot,n=this.retainedSize/o.totalSize*100,a=this.shallowSize/o.totalSize*100;this.data={object:i,count:e.NumberUtilities.withThousandsSeparator(this.count),distance:this.toUIDistance(this.distance),shallowSize:e.NumberUtilities.withThousandsSeparator(this.shallowSize),retainedSize:e.NumberUtilities.withThousandsSeparator(this.retainedSize),"shallowSize-percent":this.toPercentString(a),"retainedSize-percent":this.toPercentString(n)}}get name(){return this.nameInternal}createProvider(){return this.dataGridInternal.snapshot.createNodesProviderForClass(this.nameInternal,this.nodeFilter)}async populateNodeBySnapshotObjectId(e){this.dataGridInternal.resetNameFilter(),await this.expandWithoutPopulate();const t=await this.provider().nodePosition(e);if(-1===t)return this.collapse(),[];await this.populateChildren(t,null);const i=this.childForPosition(t);return i?[this,i]:[]}filteredOut(e){return-1===this.nameInternal.toLowerCase().indexOf(e)}createCell(e){const t="object"===e?super.createCell(e):this.createValueCell(e);return"object"===e&&this.count>1&&t.appendChild(s.Fragment.html`<span class="objects-count">×${this.count}</span>`),t}createChildNode(e){return new et(this.dataGridInternal,this.dataGridInternal.snapshot,e,!1)}comparator(){const e=this.dataGridInternal.isSortOrderAscending(),t=this.dataGridInternal.sortColumnId();switch(t){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",e,"id",!0);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",e,"retainedSize",!1);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"id",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"id",!0);default:throw new Error(`Invalid sort column id ${t}`)}}}class it{addedNodesProvider;deletedNodesProvider;addedCount;removedCount;constructor(e,t,i,r){this.addedNodesProvider=e,this.deletedNodesProvider=t,this.addedCount=i,this.removedCount=r}dispose(){this.addedNodesProvider.dispose(),this.deletedNodesProvider.dispose()}nodePosition(e){throw new Error("Unreachable")}isEmpty(){return Promise.resolve(!1)}async serializeItemsRange(e,t){let i,r;if(e<this.addedCount){i=await this.addedNodesProvider.serializeItemsRange(e,t);for(const e of i.items)e.isAddedNotRemoved=!0;if(i.endPosition>=t)return i.totalLength=this.addedCount+this.removedCount,i;r=i,i=await this.deletedNodesProvider.serializeItemsRange(0,t-i.endPosition)}else r=new p.HeapSnapshotModel.ItemsRange(0,0,0,[]),i=await this.deletedNodesProvider.serializeItemsRange(e-this.addedCount,t-this.addedCount);r.items.length||(r.startPosition=this.addedCount+i.startPosition);for(const e of i.items)e.isAddedNotRemoved=!1;return r.items.push(...i.items),r.endPosition=this.addedCount+i.endPosition,r.totalLength=this.addedCount+this.removedCount,r}async sortAndRewind(e){await this.addedNodesProvider.sortAndRewind(e),await this.deletedNodesProvider.sortAndRewind(e)}}class rt extends Ke{nameInternal;addedCount;removedCount;countDelta;addedSize;removedSize;sizeDelta;deletedIndexes;constructor(t,i,r){super(t,!0),this.nameInternal=i,this.addedCount=r.addedCount,this.removedCount=r.removedCount,this.countDelta=r.countDelta,this.addedSize=r.addedSize,this.removedSize=r.removedSize,this.sizeDelta=r.sizeDelta,this.deletedIndexes=r.deletedIndexes,this.data={object:i,addedCount:e.NumberUtilities.withThousandsSeparator(this.addedCount),removedCount:e.NumberUtilities.withThousandsSeparator(this.removedCount),countDelta:this.signForDelta(this.countDelta)+e.NumberUtilities.withThousandsSeparator(Math.abs(this.countDelta)),addedSize:e.NumberUtilities.withThousandsSeparator(this.addedSize),removedSize:e.NumberUtilities.withThousandsSeparator(this.removedSize),sizeDelta:this.signForDelta(this.sizeDelta)+e.NumberUtilities.withThousandsSeparator(Math.abs(this.sizeDelta))}}get name(){return this.nameInternal}createProvider(){const e=this.dataGridInternal;if(null===e.snapshot||void 0===e.baseSnapshot||void 0===e.baseSnapshot.uid)throw new Error("Data sources have not been set correctly");const t=e.snapshot.createAddedNodesProvider(e.baseSnapshot.uid,this.nameInternal),i=e.baseSnapshot.createDeletedNodesProvider(this.deletedIndexes);if(!t||!i)throw new Error("Failed to create node providers");return new it(t,i,this.addedCount,this.removedCount)}createCell(e){const t=super.createCell(e);return"object"!==e&&t.classList.add("numeric-column"),t}createChildNode(e){const t=this.dataGridInternal;if(e.isAddedNotRemoved){if(null===t.snapshot)throw new Error("Data sources have not been set correctly");return new et(this.dataGridInternal,t.snapshot,e,!1)}if(void 0===t.baseSnapshot)throw new Error("Data sources have not been set correctly");return new et(this.dataGridInternal,t.baseSnapshot,e,!0)}comparator(){const e=this.dataGridInternal.isSortOrderAscending(),t=this.dataGridInternal.sortColumnId();switch(t){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",e,"id",!0);case"addedCount":case"removedCount":case"countDelta":return new p.HeapSnapshotModel.ComparatorConfig("name",!0,"id",!0);case"addedSize":case"removedSize":case"sizeDelta":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"id",!0);default:throw new Error(`Invalid sort column ${t}`)}}filteredOut(e){return-1===this.nameInternal.toLowerCase().indexOf(e)}signForDelta(e){return 0===e?"":e>0?"+":"−"}}class st extends Ke{populated;allocationNode;constructor(t,i){super(t,i.hasChildren),this.populated=!1,this.allocationNode=i,this.data={liveCount:e.NumberUtilities.withThousandsSeparator(i.liveCount),count:e.NumberUtilities.withThousandsSeparator(i.count),liveSize:e.NumberUtilities.withThousandsSeparator(i.liveSize),size:e.NumberUtilities.withThousandsSeparator(i.size),name:i.name}}populate(){this.populated||this.doPopulate()}async doPopulate(){this.populated=!0;const e=await this.dataGridInternal.snapshot.allocationNodeCallers(this.allocationNode.id),t=e.nodesWithSingleCaller;let i=this;const r=this.dataGridInternal;for(const e of t){const t=new st(r,e);r.appendNode(i,t),i=t,i.populated=!0,this.expanded&&i.expand()}const s=e.branchingCallers;s.sort(this.dataGridInternal.createComparator());for(const e of s)r.appendNode(i,new st(r,e));r.updateVisibleNodes(!0)}expand(){super.expand(),1===this.children.length&&this.children[0].expand()}createCell(e){if("name"!==e)return this.createValueCell(e);const t=super.createCell(e),i=this.allocationNode,r=this.dataGridInternal.heapProfilerModel();if(i.scriptId){const e=this.dataGridInternal.linkifier.linkifyScriptLocation(r?r.target():null,String(i.scriptId),i.scriptName,i.line-1,{columnNumber:i.column-1,inlineFrameIndex:0,className:"profile-node-file"});e.style.maxWidth="75%",t.insertBefore(e,t.firstChild)}return t}allocationNodeId(){return this.allocationNode.id}}var ot=Object.freeze({__proto__:null,get HeapSnapshotGridNode(){return Ke},HeapSnapshotGenericObjectNode:Ye,HeapSnapshotObjectNode:Ze,HeapSnapshotRetainingObjectNode:Xe,HeapSnapshotInstanceNode:et,HeapSnapshotConstructorNode:tt,HeapSnapshotDiffNodesProvider:it,HeapSnapshotDiffNode:rt,AllocationGridNode:st});const nt={distanceFromWindowObject:"Distance from window object",sizeOfTheObjectItselfInBytes:"Size of the object itself in bytes",sizeOfTheObjectPlusTheGraphIt:"Size of the object plus the graph it retains in bytes",object:"Object",distance:"Distance",shallowSize:"Shallow Size",retainedSize:"Retained Size",heapSnapshotRetainment:"Heap Snapshot Retainment",constructorString:"Constructor",heapSnapshotConstructors:"Heap Snapshot Constructors",New:"# New",Deleted:"# Deleted",Delta:"# Delta",allocSize:"Alloc. Size",freedSize:"Freed Size",sizeDelta:"Size Delta",heapSnapshotDiff:"Heap Snapshot Diff",liveCount:"Live Count",count:"Count",liveSize:"Live Size",size:"Size",function:"Function",allocation:"Allocation"},at=t.i18n.registerUIStrings("panels/profiler/HeapSnapshotDataGrids.ts",nt),lt=t.i18n.getLocalizedString.bind(void 0,at),dt=new WeakMap;class ht extends r.DataGrid.DataGridImpl{}class ct extends(o.ObjectWrapper.eventMixin(ht)){snapshot;selectedNode;heapProfilerModelInternal;dataDisplayDelegateInternal;recursiveSortingDepth;populatedAndSorted;nameFilter;nodeFilterInternal;lastSortColumnId;lastSortAscending;constructor(e,t,i){super(i),this.snapshot=null,this.selectedNode=null,this.heapProfilerModelInternal=e,this.dataDisplayDelegateInternal=t;const s=[["distance",lt(nt.distanceFromWindowObject)],["shallowSize",lt(nt.sizeOfTheObjectItselfInBytes)],["retainedSize",lt(nt.sizeOfTheObjectPlusTheGraphIt)]];for(const e of s){const t=this.headerTableHeader(e[0]);t&&t.setAttribute("title",e[1])}this.recursiveSortingDepth=0,this.populatedAndSorted=!1,this.nameFilter=null,this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter,this.addEventListener(pt.SortingComplete,this.sortingComplete,this),this.addEventListener(r.DataGrid.Events.SortingChanged,this.sortingChanged,this),this.setRowContextMenuCallback(this.populateContextMenu.bind(this))}async setDataSource(e,t){}isFilteredOut(e){const t=this.nameFilter?this.nameFilter.value().toLowerCase():"";return!!(t&&(e instanceof rt||e instanceof tt)&&e.filteredOut(t))}heapProfilerModel(){return this.heapProfilerModelInternal}dataDisplayDelegate(){return this.dataDisplayDelegateInternal}nodeFilter(){return this.nodeFilterInternal}setNameFilter(e){this.nameFilter=e}defaultPopulateCount(){return 100}disposeAllNodes(){const e=this.topLevelNodes();for(let t=0,i=e.length;t<i;++t)e[t].dispose()}wasShown(){this.nameFilter&&(this.nameFilter.addEventListener(s.Toolbar.ToolbarInput.Event.TextChanged,this.onNameFilterChanged,this),this.updateVisibleNodes(!0)),this.populatedAndSorted&&this.dispatchEventToListeners(pt.ContentShown,this)}sortingComplete(){this.removeEventListener(pt.SortingComplete,this.sortingComplete,this),this.populatedAndSorted=!0,this.dispatchEventToListeners(pt.ContentShown,this)}willHide(){this.nameFilter&&this.nameFilter.removeEventListener(s.Toolbar.ToolbarInput.Event.TextChanged,this.onNameFilterChanged,this)}populateContextMenu(e,t){const i=t;i.populateContextMenu(e,this.dataDisplayDelegateInternal,this.heapProfilerModel()),i instanceof Ye&&i.linkElement&&!e.containsTarget(i.linkElement)&&e.appendApplicableItems(i.linkElement)}resetSortingCache(){delete this.lastSortColumnId,delete this.lastSortAscending}topLevelNodes(){return this.rootNode().children}revealObjectByHeapSnapshotId(e){return Promise.resolve(null)}resetNameFilter(){this.nameFilter&&this.nameFilter.setValue("")}onNameFilterChanged(){this.updateVisibleNodes(!0),this.deselectFilteredNodes()}deselectFilteredNodes(){let e=this.selectedNode;for(;e;){if(this.selectedNode&&this.isFilteredOut(e))return this.selectedNode.deselect(),void(this.selectedNode=null);e=e.parent}}sortFields(e,t){throw new Error("Not implemented")}sortingChanged(){const e=this.isSortOrderAscending(),t=this.sortColumnId();if(this.lastSortColumnId===t&&this.lastSortAscending===e)return;this.lastSortColumnId=t,this.lastSortAscending=e;const i=this.sortFields(t||"",e);this.performSorting((function(e,t){let r=e[i.fieldName1],s=t[i.fieldName1],o=r<s?-1:r>s?1:0;return i.ascending1||(o=-o),0!==o||(r=e[i.fieldName2],s=t[i.fieldName2],o=r<s?-1:r>s?1:0,i.ascending2||(o=-o)),o}))}performSorting(e){this.recursiveSortingEnter();const t=this.allChildren(this.rootNode());this.rootNode().removeChildren(),t.sort(e);for(let e=0,i=t.length;e<i;++e){const i=t[e];this.appendChildAfterSorting(i),i.expanded&&i.sort()}this.recursiveSortingLeave()}appendChildAfterSorting(e){const t=e.revealed;this.rootNode().appendChild(e),e.revealed=t}recursiveSortingEnter(){++this.recursiveSortingDepth}recursiveSortingLeave(){this.recursiveSortingDepth&&(--this.recursiveSortingDepth||(this.updateVisibleNodes(!0),this.dispatchEventToListeners(pt.SortingComplete)))}updateVisibleNodes(e){}allChildren(e){return e.children}insertChild(e,t,i){e.insertChild(t,i)}removeChildByIndex(e,t){e.removeChild(e.children[t])}removeAllChildren(e){e.removeChildren()}}var pt,ut;!function(e){e.ContentShown="ContentShown",e.SortingComplete="SortingComplete",e.ExpandRetainersComplete="ExpandRetainersComplete"}(pt||(pt={}));class mt extends ct{topPaddingHeight;bottomPaddingHeight;selectedNode;scrollToResolveCallback;constructor(e,t,i){super(e,t,i),this.scrollContainer.addEventListener("scroll",this.onScroll.bind(this),!0),this.topPaddingHeight=0,this.bottomPaddingHeight=0,this.selectedNode=null}topLevelNodes(){return this.allChildren(this.rootNode())}appendChildAfterSorting(e){}updateVisibleNodes(e){const t=this.scrollContainer.scrollHeight;let i=this.scrollContainer.scrollTop,r=t-i-this.scrollContainer.offsetHeight;i=Math.max(0,i-40),r=Math.max(0,r-40);let s=t-i-r;if(!e&&i>=this.topPaddingHeight&&r>=this.bottomPaddingHeight)return;i-=500,s+=1e3;const o=this.selectedNode;this.rootNode().removeChildren(),this.topPaddingHeight=0,this.bottomPaddingHeight=0,this.addVisibleNodes(this.rootNode(),i,i+s),this.setVerticalPadding(this.topPaddingHeight,this.bottomPaddingHeight),o&&(o.parent?o.select(!0):this.selectedNode=o)}addVisibleNodes(e,t,i){if(!e.expanded)return 0;const r=this.allChildren(e);let s=0,o=0;for(;o<r.length;++o){const e=r[o];if(this.isFilteredOut(e))continue;const i=s+this.nodeHeight(e);if(i>t)break;s=i}let n=s;for(;o<r.length&&n<i;++o){const s=r[o];if(this.isFilteredOut(s))continue;const a=s.hasChildren();s.removeChildren(),s.setHasChildren(a),e.appendChild(s),n+=s.nodeSelfHeight(),n+=this.addVisibleNodes(s,t-n,i-n)}let a=0;for(;o<r.length;++o){const e=r[o];this.isFilteredOut(e)||(a+=this.nodeHeight(e))}return this.topPaddingHeight+=s,this.bottomPaddingHeight+=a,n+a}nodeHeight(e){let t=e.nodeSelfHeight();if(!e.expanded)return t;const i=this.allChildren(e);for(let e=0;e<i.length;e++)t+=this.nodeHeight(i[e]);return t}revealTreeNode(e){const t=this.calculateOffset(e),i=e[e.length-1],r=this.scrollContainer.scrollTop,s=r+this.scrollContainer.offsetHeight;if(t>=r&&t<s)return Promise.resolve(i);return this.scrollContainer.scrollTop=Math.max(0,t-40),new Promise((e=>{console.assert(!this.scrollToResolveCallback),this.scrollToResolveCallback=e.bind(null,i),this.scrollContainer.window().requestAnimationFrame((()=>{this.scrollToResolveCallback&&(this.scrollToResolveCallback(),this.scrollToResolveCallback=null)}))}))}calculateOffset(e){let t=this.rootNode(),i=0;if(0===e.length)return 0;for(let r=0;r<e.length;++r){const s=e[r],o=this.allChildren(t);for(let e=0;e<o.length;++e){const t=o[e];if(s===t){i+=s.nodeSelfHeight();break}i+=this.nodeHeight(t)}t=s}return i-e[e.length-1].nodeSelfHeight()}allChildren(e){const t=dt.get(e)||[];return dt.has(e)||dt.set(e,t),t}appendNode(e,t){this.allChildren(e).push(t)}insertChild(e,t,i){this.allChildren(e).splice(i,0,t)}removeChildByIndex(e,t){this.allChildren(e).splice(t,1)}removeAllChildren(e){dt.delete(e)}removeTopLevelNodes(){this.disposeAllNodes(),this.rootNode().removeChildren(),this.removeAllChildren(this.rootNode())}isScrolledIntoView(e){const t=this.scrollContainer.scrollTop,i=t+this.scrollContainer.clientHeight,r=e.offsetTop;return r+e.offsetHeight<=i&&r>=t}onResize(){super.onResize(),this.updateVisibleNodes(!1)}onScroll(e){this.updateVisibleNodes(!1),this.scrollToResolveCallback&&(this.scrollToResolveCallback(),this.scrollToResolveCallback=null)}}class ft extends ct{constructor(e,t,i,s){super(e,t,{displayName:i,columns:s=s||[{id:"object",title:lt(nt.object),disclosure:!0,sortable:!0},{id:"distance",title:lt(nt.distance),width:"70px",sortable:!0,fixedWidth:!0},{id:"shallowSize",title:lt(nt.shallowSize),width:"110px",sortable:!0,fixedWidth:!0},{id:"retainedSize",title:lt(nt.retainedSize),width:"110px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Descending}]})}async setDataSource(e,t){this.snapshot=e;const i=new p.HeapSnapshotModel.Node(-1,"root",0,t||e.rootNodeIndex,0,0,"");this.setRootNode(this.createRootNode(e,i)),this.rootNode().sort()}createRootNode(e,t){const i=new p.HeapSnapshotModel.Edge("",t,"",-1);return new Ze(this,e,i,null)}sortingChanged(){const e=this.rootNode();e.hasChildren()&&e.sort()}}class gt extends ft{constructor(e,t){const i=[{id:"object",title:lt(nt.object),disclosure:!0,sortable:!0},{id:"distance",title:lt(nt.distance),width:"70px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Ascending},{id:"shallowSize",title:lt(nt.shallowSize),width:"110px",sortable:!0,fixedWidth:!0},{id:"retainedSize",title:lt(nt.retainedSize),width:"110px",sortable:!0,fixedWidth:!0}];super(e,t,lt(nt.heapSnapshotRetainment),i)}createRootNode(e,t){const i=new p.HeapSnapshotModel.Edge("",t,"",-1);return new Xe(this,e,i,null)}sortFields(e,t){switch(e){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",t,"count",!1);case"count":return new p.HeapSnapshotModel.ComparatorConfig("count",t,"name",!0);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("shallowSize",t,"name",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",t,"name",!0);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",t,"name",!0);default:throw new Error(`Unknown column ${e}`)}}reset(){this.rootNode().removeChildren(),this.resetSortingCache()}async setDataSource(e,t){await super.setDataSource(e,t),this.rootNode().expand()}}!function(e){e.ExpandRetainersComplete="ExpandRetainersComplete"}(ut||(ut={}));class vt extends mt{profileIndex;objectIdToSelect;nextRequestedFilter;lastFilter;filterInProgress;constructor(e,t){const i=[{id:"object",title:lt(nt.constructorString),disclosure:!0,sortable:!0},{id:"distance",title:lt(nt.distance),width:"70px",sortable:!0,fixedWidth:!0},{id:"shallowSize",title:lt(nt.shallowSize),width:"110px",sortable:!0,fixedWidth:!0},{id:"retainedSize",title:lt(nt.retainedSize),width:"110px",sort:r.DataGrid.Order.Descending,sortable:!0,fixedWidth:!0}];super(e,t,{displayName:lt(nt.heapSnapshotConstructors).toString(),columns:i}),this.profileIndex=-1,this.objectIdToSelect=null,this.nextRequestedFilter=null}sortFields(e,t){switch(e){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",t,"retainedSize",!1);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",t,"retainedSize",!1);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("shallowSize",t,"name",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",t,"name",!0);default:throw new Error(`Unknown column ${e}`)}}async revealObjectByHeapSnapshotId(e){if(!this.snapshot)return this.objectIdToSelect=e,null;const t=await this.snapshot.nodeClassName(parseInt(e,10));if(!t)return null;const i=this.topLevelNodes().find((e=>e.name===t));if(!i)return null;const r=await i.populateNodeBySnapshotObjectId(parseInt(e,10));return r.length?this.revealTreeNode(r):null}clear(){this.nextRequestedFilter=null,this.lastFilter=null,this.removeTopLevelNodes()}async setDataSource(e,t){this.snapshot=e,-1===this.profileIndex&&this.populateChildren(),this.objectIdToSelect&&(this.revealObjectByHeapSnapshotId(this.objectIdToSelect),this.objectIdToSelect=null)}setSelectionRange(e,t){this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter(e,t),this.populateChildren(this.nodeFilterInternal)}setAllocationNodeId(e){this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter,this.nodeFilterInternal.allocationNodeId=e,this.populateChildren(this.nodeFilterInternal)}aggregatesReceived(e,t){this.filterInProgress=null,this.nextRequestedFilter&&this.snapshot&&(this.snapshot.aggregatesWithFilter(this.nextRequestedFilter).then(this.aggregatesReceived.bind(this,this.nextRequestedFilter)),this.filterInProgress=this.nextRequestedFilter,this.nextRequestedFilter=null),this.removeTopLevelNodes(),this.resetSortingCache();for(const i in t)this.appendNode(this.rootNode(),new tt(this,i,t[i],e));this.sortingChanged(),this.lastFilter=e}async populateChildren(e){const t=e||new p.HeapSnapshotModel.NodeFilter;if(this.filterInProgress)this.nextRequestedFilter=this.filterInProgress.equals(t)?null:t;else if((!this.lastFilter||!this.lastFilter.equals(t))&&(this.filterInProgress=t,this.snapshot)){const e=await this.snapshot.aggregatesWithFilter(t);this.aggregatesReceived(t,e)}}filterSelectIndexChanged(e,t){if(this.profileIndex=t,this.nodeFilterInternal=void 0,-1!==t){const i=t>0?e[t-1].maxJSObjectId:0,r=e[t].maxJSObjectId;this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter(i,r)}this.populateChildren(this.nodeFilterInternal)}}class wt extends mt{baseSnapshot;constructor(e,t){const i=[{id:"object",title:lt(nt.constructorString),disclosure:!0,sortable:!0},{id:"addedCount",title:lt(nt.New),width:"75px",sortable:!0,fixedWidth:!0},{id:"removedCount",title:lt(nt.Deleted),width:"75px",sortable:!0,fixedWidth:!0},{id:"countDelta",title:lt(nt.Delta),width:"65px",sortable:!0,fixedWidth:!0},{id:"addedSize",title:lt(nt.allocSize),width:"75px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Descending},{id:"removedSize",title:lt(nt.freedSize),width:"75px",sortable:!0,fixedWidth:!0},{id:"sizeDelta",title:lt(nt.sizeDelta),width:"75px",sortable:!0,fixedWidth:!0}];super(e,t,{displayName:lt(nt.heapSnapshotDiff).toString(),columns:i})}defaultPopulateCount(){return 50}sortFields(e,t){switch(e){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",t,"count",!1);case"addedCount":return new p.HeapSnapshotModel.ComparatorConfig("addedCount",t,"name",!0);case"removedCount":return new p.HeapSnapshotModel.ComparatorConfig("removedCount",t,"name",!0);case"countDelta":return new p.HeapSnapshotModel.ComparatorConfig("countDelta",t,"name",!0);case"addedSize":return new p.HeapSnapshotModel.ComparatorConfig("addedSize",t,"name",!0);case"removedSize":return new p.HeapSnapshotModel.ComparatorConfig("removedSize",t,"name",!0);case"sizeDelta":return new p.HeapSnapshotModel.ComparatorConfig("sizeDelta",t,"name",!0);default:throw new Error(`Unknown column ${e}`)}}async setDataSource(e,t){this.snapshot=e}setBaseDataSource(e){this.baseSnapshot=e,this.removeTopLevelNodes(),this.resetSortingCache(),this.baseSnapshot!==this.snapshot?this.populateChildren():this.dispatchEventToListeners(pt.SortingComplete)}async populateChildren(){if(null===this.snapshot||void 0===this.baseSnapshot||void 0===this.baseSnapshot.uid)throw new Error("Data sources have not been set correctly");const e=await this.baseSnapshot.aggregatesForDiff(),t=await this.snapshot.calculateSnapshotDiff(this.baseSnapshot.uid,e);for(const e in t){const i=t[e];this.appendNode(this.rootNode(),new rt(this,e,i))}this.sortingChanged()}}class St extends mt{linkifierInternal;topNodes;constructor(e,t){const i=[{id:"liveCount",title:lt(nt.liveCount),width:"75px",sortable:!0,fixedWidth:!0},{id:"count",title:lt(nt.count),width:"65px",sortable:!0,fixedWidth:!0},{id:"liveSize",title:lt(nt.liveSize),width:"75px",sortable:!0,fixedWidth:!0},{id:"size",title:lt(nt.size),width:"75px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Descending},{id:"name",title:lt(nt.function),disclosure:!0,sortable:!0}];super(e,t,{displayName:lt(nt.allocation).toString(),columns:i}),this.linkifierInternal=new d.Linkifier.Linkifier}get linkifier(){return this.linkifierInternal}dispose(){this.linkifierInternal.reset()}async setDataSource(e,t){this.snapshot=e,this.topNodes=await this.snapshot.allocationTracesTops(),this.populateChildren()}populateChildren(){this.removeTopLevelNodes();const e=this.rootNode(),t=this.topNodes||[];for(const i of t)this.appendNode(e,new st(this,i));this.updateVisibleNodes(!0)}sortingChanged(){void 0!==this.topNodes&&(this.topNodes.sort(this.createComparator()),this.rootNode().removeChildren(),this.populateChildren())}createComparator(){const e=this.sortColumnId(),t=this.sortOrder()===r.DataGrid.Order.Ascending?1:-1;return function(i,r){return i[e]>r[e]?t:i[e]<r[e]?-t:0}}}var bt=Object.freeze({__proto__:null,HeapSnapshotSortableDataGrid:ct,get HeapSnapshotSortableDataGridEvents(){return pt},HeapSnapshotViewportDataGrid:mt,HeapSnapshotContainmentDataGrid:ft,HeapSnapshotRetainmentDataGrid:gt,get HeapSnapshotRetainmentDataGridEvents(){return ut},HeapSnapshotConstructorsDataGrid:vt,HeapSnapshotDiffDataGrid:wt,AllocationDataGrid:St});const Ct={anErrorOccurredWhenACallToMethod:"An error occurred when a call to method ''{PH1}'' was requested"},Pt=t.i18n.registerUIStrings("panels/profiler/HeapSnapshotProxy.ts",Ct),Tt=t.i18n.getLocalizedString.bind(void 0,Pt);class xt extends o.ObjectWrapper.ObjectWrapper{eventHandler;nextObjectId;nextCallId;callbacks;previousCallbacks;worker;interval;constructor(e){super(),this.eventHandler=e,this.nextObjectId=1,this.nextCallId=1,this.callbacks=new Map,this.previousCallbacks=new Set,this.worker=o.Worker.WorkerWrapper.fromURL(new URL("../../entrypoints/heap_snapshot_worker/heap_snapshot_worker-legacy.js",import.meta.url)),this.worker.onmessage=this.messageReceived.bind(this)}createLoader(e,t){const i=this.nextObjectId++,r=new It(this,i,e,t);return this.postMessage({callId:this.nextCallId++,disposition:"create",objectId:i,methodName:"HeapSnapshotWorker.HeapSnapshotLoader"}),r}dispose(){this.worker.terminate(),this.interval&&clearInterval(this.interval)}disposeObject(e){this.postMessage({callId:this.nextCallId++,disposition:"dispose",objectId:e})}evaluateForTest(e,t){const i=this.nextCallId++;this.callbacks.set(i,t),this.postMessage({callId:i,disposition:"evaluateForTest",source:e})}callFactoryMethod(e,t,i,r){const s=this.nextCallId++,o=Array.prototype.slice.call(arguments,4),n=this.nextObjectId++;return e?(this.callbacks.set(s,(t=>{e(t?new r(this,n):null)})),this.postMessage({callId:s,disposition:"factory",objectId:t,methodName:i,methodArguments:o,newObjectId:n}),null):(this.postMessage({callId:s,disposition:"factory",objectId:t,methodName:i,methodArguments:o,newObjectId:n}),new r(this,n))}callMethod(e,t,i){const r=this.nextCallId++,s=Array.prototype.slice.call(arguments,3);e&&this.callbacks.set(r,e),this.postMessage({callId:r,disposition:"method",objectId:t,methodName:i,methodArguments:s})}startCheckingForLongRunningCalls(){this.interval||(this.checkLongRunningCalls(),this.interval=window.setInterval(this.checkLongRunningCalls.bind(this),300))}checkLongRunningCalls(){for(const e of this.previousCallbacks)this.callbacks.has(e)||this.previousCallbacks.delete(e);const e=Boolean(this.previousCallbacks.size);this.dispatchEventToListeners("Wait",e);for(const e of this.callbacks.keys())this.previousCallbacks.add(e)}messageReceived(e){const t=e.data;if(t.eventName)return void(this.eventHandler&&this.eventHandler(t.eventName,t.data));if(t.error)return t.errorMethodName&&o.Console.Console.instance().error(Tt(Ct.anErrorOccurredWhenACallToMethod,{PH1:t.errorMethodName})),o.Console.Console.instance().error(t.errorCallStack),void this.callbacks.delete(t.callId);const i=this.callbacks.get(t.callId);i&&(this.callbacks.delete(t.callId),i(t.result))}postMessage(e){this.worker.postMessage(e)}}class yt{worker;objectId;constructor(e,t){this.worker=e,this.objectId=t}callWorker(e,t){t.splice(1,0,this.objectId);const i=this.worker[e];if(!i)throw new Error(`Could not find worker with name ${e}.`);return i.apply(this.worker,t)}dispose(){this.worker.disposeObject(this.objectId)}disposeWorker(){this.worker.dispose()}callFactoryMethod(e,t,i,...r){return this.callWorker("callFactoryMethod",Array.prototype.slice.call(arguments,0))}callMethodPromise(e,...t){const i=Array.prototype.slice.call(arguments);return new Promise((e=>this.callWorker("callMethod",[e,...i])))}}class It extends yt{profileUid;snapshotReceivedCallback;constructor(e,t,i,r){super(e,t),this.profileUid=i,this.snapshotReceivedCallback=r}async write(e){await this.callMethodPromise("write",e)}async close(){await this.callMethodPromise("close");const e=await new Promise((e=>this.callFactoryMethod(e,"buildSnapshot",Rt)));this.dispose(),e.setProfileUid(this.profileUid),await e.updateStaticData(),this.snapshotReceivedCallback(e)}}class Rt extends yt{staticData;profileUid;constructor(e,t){super(e,t),this.staticData=null}search(e,t){return this.callMethodPromise("search",e,t)}aggregatesWithFilter(e){return this.callMethodPromise("aggregatesWithFilter",e)}aggregatesForDiff(){return this.callMethodPromise("aggregatesForDiff")}calculateSnapshotDiff(e,t){return this.callMethodPromise("calculateSnapshotDiff",e,t)}nodeClassName(e){return this.callMethodPromise("nodeClassName",e)}createEdgesProvider(e){return this.callFactoryMethod(null,"createEdgesProvider",Et,e)}createRetainingEdgesProvider(e){return this.callFactoryMethod(null,"createRetainingEdgesProvider",Et,e)}createAddedNodesProvider(e,t){return this.callFactoryMethod(null,"createAddedNodesProvider",Et,e,t)}createDeletedNodesProvider(e){return this.callFactoryMethod(null,"createDeletedNodesProvider",Et,e)}createNodesProvider(e){return this.callFactoryMethod(null,"createNodesProvider",Et,e)}createNodesProviderForClass(e,t){return this.callFactoryMethod(null,"createNodesProviderForClass",Et,e,t)}allocationTracesTops(){return this.callMethodPromise("allocationTracesTops")}allocationNodeCallers(e){return this.callMethodPromise("allocationNodeCallers",e)}allocationStack(e){return this.callMethodPromise("allocationStack",e)}dispose(){throw new Error("Should never be called")}get nodeCount(){return this.staticData?this.staticData.nodeCount:0}get rootNodeIndex(){return this.staticData?this.staticData.rootNodeIndex:0}async updateStaticData(){this.staticData=await this.callMethodPromise("updateStaticData")}getStatistics(){return this.callMethodPromise("getStatistics")}getLocation(e){return this.callMethodPromise("getLocation",e)}getSamples(){return this.callMethodPromise("getSamples")}get totalSize(){return this.staticData?this.staticData.totalSize:0}get uid(){return this.profileUid}setProfileUid(e){this.profileUid=e}maxJSObjectId(){return this.staticData?this.staticData.maxJSObjectId:0}}class Et extends yt{constructor(e,t){super(e,t)}nodePosition(e){return this.callMethodPromise("nodePosition",e)}isEmpty(){return this.callMethodPromise("isEmpty")}serializeItemsRange(e,t){return this.callMethodPromise("serializeItemsRange",e,t)}async sortAndRewind(e){await this.callMethodPromise("sortAndRewind",e)}}var Nt=Object.freeze({__proto__:null,HeapSnapshotWorkerProxy:xt,HeapSnapshotProxyObject:yt,HeapSnapshotLoaderProxy:It,HeapSnapshotProxy:Rt,HeapSnapshotProviderProxy:Et});const kt={find:"Find",containment:"Containment",retainers:"Retainers",allocationStack:"Allocation stack",perspective:"Perspective",baseSnapshot:"Base snapshot",filter:"Filter",classFilter:"Class filter",code:"Code",strings:"Strings",jsArrays:"JS arrays",typedArrays:"Typed arrays",systemObjects:"System objects",selectedSizeS:"Selected size: {PH1}",allObjects:"All objects",objectsAllocatedBeforeS:"Objects allocated before {PH1}",objectsAllocatedBetweenSAndS:"Objects allocated between {PH1} and {PH2}",summary:"Summary",comparison:"Comparison",allocation:"Allocation",liveObjects:"Live objects",statistics:"Statistics",heapSnapshot:"Heap snapshot",takeHeapSnapshot:"Take heap snapshot",heapSnapshots:"HEAP SNAPSHOTS",heapSnapshotProfilesShowMemory:"Heap snapshot profiles show memory distribution among your page's JavaScript objects and related DOM nodes.",exposeInternals:"Expose internals (includes additional implementation-specific details)",captureNumericValue:"Include numerical values in capture",snapshotting:"Snapshotting…",snapshotD:"Snapshot {PH1}",percentagePlaceholder:"{PH1}%",allocationInstrumentationOn:"Allocation instrumentation on timeline",stopRecordingHeapProfile:"Stop recording heap profile",startRecordingHeapProfile:"Start recording heap profile",recordAllocationStacksExtra:"Record stack traces of allocations (extra performance overhead)",recording:"Recording…",allocationTimelines:"ALLOCATION TIMELINES",AllocationTimelinesShowInstrumented:"Allocation timelines show instrumented JavaScript memory allocations over time. Once profile is recorded you can select a time interval to see objects that were allocated within it and still alive by the end of recording. Use this profile type to isolate memory leaks.",loading:"Loading…",savingD:"Saving… {PH1}%",sKb:"{PH1} kB",heapMemoryUsage:"Heap memory usage",stackWasNotRecordedForThisObject:"Stack was not recorded for this object because it had been allocated before this profile recording started."},Dt=t.i18n.registerUIStrings("panels/profiler/HeapSnapshotView.ts",kt),Mt=t.i18n.getLocalizedString.bind(void 0,Dt),Ft=t.i18n.registerUIStrings("panels/profiler/ModuleUIStrings.ts",{buildingEdgeIndexes:"Building edge indexes…",buildingRetainers:"Building retainers…",propagatingDomState:"Propagating DOM state…",calculatingNodeFlags:"Calculating node flags…",calculatingDistances:"Calculating distances…",buildingPostorderIndex:"Building postorder index…",buildingDominatorTree:"Building dominator tree…",calculatingRetainedSizes:"Calculating retained sizes…",buildingDominatedNodes:"Building dominated nodes…",calculatingStatistics:"Calculating statistics…",calculatingSamples:"Calculating samples…",buildingLocations:"Building locations…",finishedProcessing:"Finished processing.",buildingAllocationStatistics:"Building allocation statistics…",done:"Done",processingSnapshot:"Processing snapshot…",parsingStrings:"Parsing strings…",loadingSnapshotInfo:"Loading snapshot info…",loadingNodesD:"Loading nodes… {PH1}%",loadingEdgesD:"Loading edges… {PH1}%",loadingAllocationTracesD:"Loading allocation traces… {PH1}%",loadingSamples:"Loading samples…",loadingLocations:"Loading locations…",loadingStrings:"Loading strings…"}),Ht=t.i18n.getLocalizedString.bind(void 0,Ft);class Lt extends s.View.SimpleView{searchResults;profile;linkifier;parentDataDisplayDelegate;searchableViewInternal;splitWidget;containmentDataGrid;containmentWidget;statisticsView;constructorsDataGrid;constructorsWidget;diffDataGrid;diffWidget;allocationDataGrid;allocationWidget;allocationStackView;tabbedPane;retainmentDataGrid;retainmentWidget;objectDetailsView;perspectives;comparisonPerspective;perspectiveSelect;baseSelect;filterSelect;classNameFilter;selectedSizeText;popoverHelper;currentPerspectiveIndex;currentPerspective;dataGrid;searchThrottler;baseProfile;trackingOverviewGrid;currentSearchResultIndex=-1;currentQuery;constructor(e,t){super(Mt(kt.heapSnapshot)),this.searchResults=[],this.element.classList.add("heap-snapshot-view"),this.profile=t,this.linkifier=new d.Linkifier.Linkifier;const i=t.profileType();i.addEventListener("SnapshotReceived",this.onReceiveSnapshot,this),i.addEventListener(D.RemoveProfileHeader,this.onProfileHeaderRemoved,this);const n=i.id===At.TypeId;n&&this.createOverview();const a=Kt.trackingHeapSnapshotProfileType.recordAllocationStacksSetting().get();this.parentDataDisplayDelegate=e,this.searchableViewInternal=new s.SearchableView.SearchableView(this,null),this.searchableViewInternal.setPlaceholder(Mt(kt.find),Mt(kt.find)),this.searchableViewInternal.show(this.element),this.splitWidget=new s.SplitWidget.SplitWidget(!1,!0,"heapSnapshotSplitViewState",200,200),this.splitWidget.show(this.searchableViewInternal.element);const l=t.heapProfilerModel();let h;if(this.containmentDataGrid=new ft(l,this,Mt(kt.containment)),this.containmentDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.selectionChanged,this),this.containmentWidget=this.containmentDataGrid.asWidget(),this.containmentWidget.setMinimumSize(50,25),this.statisticsView=new _t,this.constructorsDataGrid=new vt(l,this),this.constructorsDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.selectionChanged,this),this.constructorsWidget=this.constructorsDataGrid.asWidget(),this.constructorsWidget.setMinimumSize(50,25),this.diffDataGrid=new wt(l,this),this.diffDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.selectionChanged,this),this.diffWidget=this.diffDataGrid.asWidget(),this.diffWidget.setMinimumSize(50,25),this.allocationDataGrid=null,n&&a&&(this.allocationDataGrid=new St(l,this),this.allocationDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.onSelectAllocationNode,this),this.allocationWidget=this.allocationDataGrid.asWidget(),this.allocationWidget.setMinimumSize(50,25),this.allocationStackView=new Jt(l),this.allocationStackView.setMinimumSize(50,25),this.tabbedPane=new s.TabbedPane.TabbedPane),this.retainmentDataGrid=new gt(l,this),this.retainmentWidget=this.retainmentDataGrid.asWidget(),this.retainmentWidget.setMinimumSize(50,21),this.retainmentWidget.element.classList.add("retaining-paths-view"),this.allocationStackView)this.tabbedPane=new s.TabbedPane.TabbedPane,this.tabbedPane.appendTab("retainers",Mt(kt.retainers),this.retainmentWidget),this.tabbedPane.appendTab("allocation-stack",Mt(kt.allocationStack),this.allocationStackView),h=this.tabbedPane.headerElement(),this.objectDetailsView=this.tabbedPane;else{const e=document.createElement("div");e.classList.add("heap-snapshot-view-resizer");const t=e.createChild("div","title");e.createChild("div","verticalResizerIcon");t.createChild("span").textContent=Mt(kt.retainers),h=e,this.objectDetailsView=new s.Widget.VBox,this.objectDetailsView.element.appendChild(e),this.retainmentWidget.show(this.objectDetailsView.element)}this.splitWidget.hideDefaultResizer(),this.splitWidget.installResizer(h),this.retainmentDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.inspectedObjectChanged,this),this.retainmentDataGrid.reset(),this.perspectives=[],this.comparisonPerspective=new zt,this.perspectives.push(new Ot),t.profileType()!==Kt.trackingHeapSnapshotProfileType&&this.perspectives.push(this.comparisonPerspective),this.perspectives.push(new Bt),this.allocationWidget&&this.perspectives.push(new Gt),this.perspectives.push(new Vt),this.perspectiveSelect=new s.Toolbar.ToolbarComboBox(this.onSelectedPerspectiveChanged.bind(this),Mt(kt.perspective)),this.updatePerspectiveOptions(),this.baseSelect=new s.Toolbar.ToolbarComboBox(this.changeBase.bind(this),Mt(kt.baseSnapshot)),this.baseSelect.setVisible(!1),this.updateBaseOptions(),this.filterSelect=new s.Toolbar.ToolbarComboBox(this.changeFilter.bind(this),Mt(kt.filter)),this.filterSelect.setVisible(!1),this.updateFilterOptions(),this.classNameFilter=new s.Toolbar.ToolbarInput(Mt(kt.classFilter)),this.classNameFilter.setVisible(!1),this.constructorsDataGrid.setNameFilter(this.classNameFilter),this.diffDataGrid.setNameFilter(this.classNameFilter),this.selectedSizeText=new s.Toolbar.ToolbarText,this.popoverHelper=new s.PopoverHelper.PopoverHelper(this.element,this.getPopoverRequest.bind(this)),this.popoverHelper.setDisableOnClick(!0),this.popoverHelper.setHasPadding(!0),this.element.addEventListener("scroll",this.popoverHelper.hidePopover.bind(this.popoverHelper),!0),this.currentPerspectiveIndex=0,this.currentPerspective=this.perspectives[0],this.currentPerspective.activate(this),this.dataGrid=this.currentPerspective.masterGrid(this),this.populate(),this.searchThrottler=new o.Throttler.Throttler(0);for(const e of this.profiles())e.addEventListener(k.ProfileTitleChanged,this.updateControls,this)}createOverview(){const e=this.profile.profileType();this.trackingOverviewGrid=new Re,this.trackingOverviewGrid.addEventListener("IdsRangeChanged",this.onIdsRangeChanged.bind(this)),this.profile.fromFile()||e.profileBeingRecorded()!==this.profile||(e.addEventListener("HeapStatsUpdate",this.onHeapStatsUpdate,this),e.addEventListener("TrackingStopped",this.onStopTracking,this),this.trackingOverviewGrid.start())}onStopTracking(){const e=this.profile.profileType();e.removeEventListener("HeapStatsUpdate",this.onHeapStatsUpdate,this),e.removeEventListener("TrackingStopped",this.onStopTracking,this),this.trackingOverviewGrid&&this.trackingOverviewGrid.stop()}onHeapStatsUpdate({data:e}){this.trackingOverviewGrid&&this.trackingOverviewGrid.setSamples(e)}searchableView(){return this.searchableViewInternal}showProfile(e){return this.parentDataDisplayDelegate.showProfile(e)}showObject(e,t){Number(e)<=this.profile.maxJSObjectId?this.selectLiveObject(t,e):this.parentDataDisplayDelegate.showObject(e,t)}async linkifyObject(e){const t=this.profile.heapProfilerModel();if(!t)return null;const i=await this.profile.getLocation(e);if(!i)return null;const r=t.runtimeModel().debuggerModel().createRawLocationByScriptId(String(i.scriptId),i.lineNumber,i.columnNumber);if(!r)return null;const s=r.script(),o=s&&s.sourceURL;return o&&this.linkifier?this.linkifier.linkifyRawLocation(r,o):null}async populate(){const e=await this.profile.loadPromise;if(this.retrieveStatistics(e),this.dataGrid&&this.dataGrid.setDataSource(e,0),this.profile.profileType().id===At.TypeId&&this.profile.fromFile()){const t=await e.getSamples();if(t){console.assert(Boolean(t.timestamps.length));const e=new Ne;e.sizes=t.sizes,e.ids=t.lastAssignedIds,e.timestamps=t.timestamps,e.max=t.sizes,e.totalTime=Math.max(t.timestamps[t.timestamps.length-1]||0,1e4),this.trackingOverviewGrid&&this.trackingOverviewGrid.setSamples(e)}}const t=this.profiles().indexOf(this.profile);this.baseSelect.setSelectedIndex(Math.max(0,t-1)),this.trackingOverviewGrid&&this.trackingOverviewGrid.updateGrid()}async retrieveStatistics(e){const t=await e.getStatistics(),i=[{value:t.code,color:"#f77",title:Mt(kt.code)},{value:t.strings,color:"#5e5",title:Mt(kt.strings)},{value:t.jsArrays,color:"#7af",title:Mt(kt.jsArrays)},{value:t.native,color:"#fc5",title:Mt(kt.typedArrays)},{value:t.system,color:"#98f",title:Mt(kt.systemObjects)}];return this.statisticsView.setTotalAndRecords(t.total,i),t}onIdsRangeChanged(t){const{minId:i,maxId:r}=t.data;this.selectedSizeText.setText(Mt(kt.selectedSizeS,{PH1:e.NumberUtilities.bytesToString(t.data.size)})),this.constructorsDataGrid.snapshot&&this.constructorsDataGrid.setSelectionRange(i,r)}async toolbarItems(){const e=[this.perspectiveSelect,this.classNameFilter];return this.profile.profileType()!==Kt.trackingHeapSnapshotProfileType&&e.push(this.baseSelect,this.filterSelect),e.push(this.selectedSizeText),e}willHide(){this.currentSearchResultIndex=-1,this.popoverHelper.hidePopover()}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!1}onSearchCanceled(){this.currentSearchResultIndex=-1,this.searchResults=[]}selectRevealedNode(e){e&&e.select()}performSearch(e,t,i){const r=new p.HeapSnapshotModel.SearchConfig(e.query.trim(),e.caseSensitive,e.isRegex,t,i||!1);this.searchThrottler.schedule(this.performSearchInternal.bind(this,r))}async performSearchInternal(e){if(this.onSearchCanceled(),!this.currentPerspective.supportsSearch())return;this.currentQuery=e;const t=e.query.trim();if(!t)return;if("@"===t.charAt(0)){const e=parseInt(t.substring(1),10);if(isNaN(e))return;if(!this.dataGrid)return;const i=await this.dataGrid.revealObjectByHeapSnapshotId(String(e));return void this.selectRevealedNode(i)}if(!this.profile.snapshotProxy||!this.dataGrid)return;const i=this.dataGrid.nodeFilter();this.searchResults=i?await this.profile.snapshotProxy.search(this.currentQuery,i):[],this.searchableViewInternal.updateSearchMatchesCount(this.searchResults.length),this.searchResults.length&&(this.currentSearchResultIndex=e.jumpBackward?this.searchResults.length-1:0),await this.jumpToSearchResult(this.currentSearchResultIndex)}jumpToNextSearchResult(){this.searchResults.length&&(this.currentSearchResultIndex=(this.currentSearchResultIndex+1)%this.searchResults.length,this.searchThrottler.schedule(this.jumpToSearchResult.bind(this,this.currentSearchResultIndex)))}jumpToPreviousSearchResult(){this.searchResults.length&&(this.currentSearchResultIndex=(this.currentSearchResultIndex+this.searchResults.length-1)%this.searchResults.length,this.searchThrottler.schedule(this.jumpToSearchResult.bind(this,this.currentSearchResultIndex)))}async jumpToSearchResult(e){if(this.searchableViewInternal.updateCurrentMatchIndex(e),-1===e)return;if(!this.dataGrid)return;const t=await this.dataGrid.revealObjectByHeapSnapshotId(String(this.searchResults[e]));this.selectRevealedNode(t)}refreshVisibleData(){if(!this.dataGrid)return;let e=this.dataGrid.rootNode().children[0];for(;e;)e.refresh(),e=e.traverseNextNode(!1,null,!0)}changeBase(){if(this.baseProfile===this.profiles()[this.baseSelect.selectedIndex()])return;this.baseProfile=this.profiles()[this.baseSelect.selectedIndex()];const e=this.dataGrid;e.snapshot&&this.baseProfile.loadPromise.then(e.setBaseDataSource.bind(e)),this.currentQuery&&this.searchResults&&this.performSearch(this.currentQuery,!1)}changeFilter(){const e=this.filterSelect.selectedIndex()-1;this.dataGrid&&(this.dataGrid.filterSelectIndexChanged(this.profiles(),e),this.currentQuery&&this.searchResults&&this.performSearch(this.currentQuery,!1))}profiles(){return this.profile.profileType().getProfiles()}selectionChanged(e){const t=e.data;this.setSelectedNodeForDetailsView(t),this.inspectedObjectChanged(e)}onSelectAllocationNode(e){const t=e.data;this.constructorsDataGrid.setAllocationNodeId(t.allocationNodeId()),this.setSelectedNodeForDetailsView(null)}inspectedObjectChanged(e){const t=e.data,i=this.profile.heapProfilerModel();i&&t instanceof Ye&&i.addInspectedHeapObject(String(t.snapshotNodeId))}setSelectedNodeForDetailsView(e){const t=e&&e.retainersDataSource();t?(this.retainmentDataGrid.setDataSource(t.snapshot,t.snapshotNodeIndex),this.allocationStackView&&this.allocationStackView.setAllocatedObject(t.snapshot,t.snapshotNodeIndex)):(this.allocationStackView&&this.allocationStackView.clear(),this.retainmentDataGrid.reset())}async changePerspectiveAndWait(e){const t=this.perspectives.findIndex((t=>t.title()===e));if(-1===t||this.currentPerspectiveIndex===t)return;const i=this.perspectives[t].masterGrid(this);if(!i)return;const r=i.once(pt.ContentShown),s=this.perspectiveSelect.options().find((e=>e.value===String(t)));this.perspectiveSelect.select(s),this.changePerspective(t),await r}async updateDataSourceAndView(){const e=this.dataGrid;if(!e||e.snapshot)return;const t=await this.profile.loadPromise;if(this.dataGrid!==e)return;if(e.snapshot!==t&&e.setDataSource(t,0),e!==this.diffDataGrid)return;this.baseProfile||(this.baseProfile=this.profiles()[this.baseSelect.selectedIndex()]);const i=await this.baseProfile.loadPromise;this.diffDataGrid.baseSnapshot!==i&&this.diffDataGrid.setBaseDataSource(i)}onSelectedPerspectiveChanged(e){this.changePerspective(Number(e.target.selectedOptions[0].value))}changePerspective(e){if(e===this.currentPerspectiveIndex)return;this.currentPerspectiveIndex=e,this.currentPerspective.deactivate(this);const t=this.perspectives[e];this.currentPerspective=t,this.dataGrid=t.masterGrid(this),t.activate(this),this.refreshVisibleData(),this.dataGrid&&this.dataGrid.updateWidths(),this.updateDataSourceAndView(),this.currentQuery&&this.searchResults&&this.performSearch(this.currentQuery,!1)}async selectLiveObject(e,t){if(await this.changePerspectiveAndWait(e),!this.dataGrid)return;const i=await this.dataGrid.revealObjectByHeapSnapshotId(t);i?i.select():o.Console.Console.instance().error("Cannot find corresponding heap snapshot node")}getPopoverRequest(e){const t=s.UIUtils.enclosingNodeOrSelfWithNodeName(e.target,"span"),i=s.UIUtils.enclosingNodeOrSelfWithNodeName(e.target,"tr");if(!i)return null;if(!this.dataGrid)return null;const r=this.dataGrid.dataGridNodeFromNode(i)||this.containmentDataGrid.dataGridNodeFromNode(i)||this.constructorsDataGrid.dataGridNodeFromNode(i)||this.diffDataGrid.dataGridNodeFromNode(i)||this.allocationDataGrid&&this.allocationDataGrid.dataGridNodeFromNode(i)||this.retainmentDataGrid.dataGridNodeFromNode(i),o=this.profile.heapProfilerModel();if(!r||!t||!o)return null;let n;return{box:t.boxInWindow(),show:async e=>{if(!o)return!1;const t=await r.queryObjectContent(o,"popover");return!!t&&(n=await u.ObjectPopoverHelper.ObjectPopoverHelper.buildObjectPopover(t,e),!!n||(o.runtimeModel().releaseObjectGroup("popover"),!1))},hide:()=>{o.runtimeModel().releaseObjectGroup("popover"),n&&n.dispose()}}}updatePerspectiveOptions(){const e=this.profiles().length>1;this.perspectiveSelect.removeOptions(),this.perspectives.forEach(((t,i)=>{(e||t!==this.comparisonPerspective)&&this.perspectiveSelect.createOption(t.title(),String(i))}))}updateBaseOptions(){const e=this.profiles(),t=this.baseSelect.selectedIndex();this.baseSelect.removeOptions();for(const t of e)this.baseSelect.createOption(t.title);t>-1&&this.baseSelect.setSelectedIndex(t)}updateFilterOptions(){const e=this.profiles(),t=this.filterSelect.selectedIndex();this.filterSelect.removeOptions(),this.filterSelect.createOption(Mt(kt.allObjects));for(let t=0;t<e.length;++t){let i;i=t?Mt(kt.objectsAllocatedBetweenSAndS,{PH1:e[t-1].title,PH2:e[t].title}):Mt(kt.objectsAllocatedBeforeS,{PH1:e[t].title}),this.filterSelect.createOption(i)}t>-1&&this.filterSelect.setSelectedIndex(t)}updateControls(){this.updatePerspectiveOptions(),this.updateBaseOptions(),this.updateFilterOptions()}onReceiveSnapshot(e){this.updateControls();e.data.addEventListener(k.ProfileTitleChanged,this.updateControls,this)}onProfileHeaderRemoved(e){const t=e.data;t.removeEventListener(k.ProfileTitleChanged,this.updateControls,this),this.profile===t?(this.detach(),this.profile.profileType().removeEventListener("SnapshotReceived",this.onReceiveSnapshot,this),this.profile.profileType().removeEventListener(D.RemoveProfileHeader,this.onProfileHeaderRemoved,this),this.dispose()):this.updateControls()}dispose(){this.linkifier.dispose(),this.popoverHelper.dispose(),this.allocationStackView&&(this.allocationStackView.clear(),this.allocationDataGrid&&this.allocationDataGrid.dispose()),this.onStopTracking(),this.trackingOverviewGrid&&this.trackingOverviewGrid.removeEventListener("IdsRangeChanged",this.onIdsRangeChanged.bind(this))}}class jt{titleInternal;constructor(e){this.titleInternal=e}activate(e){}deactivate(e){e.baseSelect.setVisible(!1),e.filterSelect.setVisible(!1),e.classNameFilter.setVisible(!1),e.trackingOverviewGrid&&e.trackingOverviewGrid.detach(),e.allocationWidget&&e.allocationWidget.detach(),e.statisticsView&&e.statisticsView.detach(),e.splitWidget.detach(),e.splitWidget.detachChildWidgets()}masterGrid(e){return null}title(){return this.titleInternal}supportsSearch(){return!1}}class Ot extends jt{constructor(){super(Mt(kt.summary))}activate(e){e.splitWidget.setMainWidget(e.constructorsWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView),e.splitWidget.show(e.searchableViewInternal.element),e.filterSelect.setVisible(!0),e.classNameFilter.setVisible(!0),e.trackingOverviewGrid&&(e.trackingOverviewGrid.show(e.searchableViewInternal.element,e.splitWidget.element),e.trackingOverviewGrid.update(),e.trackingOverviewGrid.updateGrid())}masterGrid(e){return e.constructorsDataGrid}supportsSearch(){return!0}}class zt extends jt{constructor(){super(Mt(kt.comparison))}activate(e){e.splitWidget.setMainWidget(e.diffWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView),e.splitWidget.show(e.searchableViewInternal.element),e.baseSelect.setVisible(!0),e.classNameFilter.setVisible(!0)}masterGrid(e){return e.diffDataGrid}supportsSearch(){return!0}}class Bt extends jt{constructor(){super(Mt(kt.containment))}activate(e){e.splitWidget.setMainWidget(e.containmentWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView),e.splitWidget.show(e.searchableViewInternal.element)}masterGrid(e){return e.containmentDataGrid}}class Gt extends jt{allocationSplitWidget;constructor(){super(Mt(kt.allocation)),this.allocationSplitWidget=new s.SplitWidget.SplitWidget(!1,!0,"heapSnapshotAllocationSplitViewState",200,200),this.allocationSplitWidget.setSidebarWidget(new s.Widget.VBox)}activate(e){e.allocationWidget&&this.allocationSplitWidget.setMainWidget(e.allocationWidget),e.splitWidget.setMainWidget(e.constructorsWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView);const t=new s.Widget.VBox,i=document.createElement("div");i.classList.add("heap-snapshot-view-resizer");const r=i.createChild("div","title").createChild("span");if(i.createChild("div","verticalResizerIcon"),r.textContent=Mt(kt.liveObjects),this.allocationSplitWidget.hideDefaultResizer(),this.allocationSplitWidget.installResizer(i),t.element.appendChild(i),e.splitWidget.show(t.element),this.allocationSplitWidget.setSidebarWidget(t),this.allocationSplitWidget.show(e.searchableViewInternal.element),e.constructorsDataGrid.clear(),e.allocationDataGrid){const t=e.allocationDataGrid.selectedNode;t&&e.constructorsDataGrid.setAllocationNodeId(t.allocationNodeId())}}deactivate(e){this.allocationSplitWidget.detach(),super.deactivate(e)}masterGrid(e){return e.allocationDataGrid}}class Vt extends jt{constructor(){super(Mt(kt.statistics))}activate(e){e.statisticsView.show(e.searchableViewInternal.element)}masterGrid(e){return null}}class Ut extends(o.ObjectWrapper.eventMixin(L)){exposeInternals;captureNumericValue;customContentInternal;constructor(e,t){super(e||Ut.TypeId,t||Mt(kt.heapSnapshot)),l.TargetManager.TargetManager.instance().observeModels(l.HeapProfilerModel.HeapProfilerModel,this),l.TargetManager.TargetManager.instance().addModelListener(l.HeapProfilerModel.HeapProfilerModel,l.HeapProfilerModel.Events.ResetProfiles,this.resetProfiles,this),l.TargetManager.TargetManager.instance().addModelListener(l.HeapProfilerModel.HeapProfilerModel,l.HeapProfilerModel.Events.AddHeapSnapshotChunk,this.addHeapSnapshotChunk,this),l.TargetManager.TargetManager.instance().addModelListener(l.HeapProfilerModel.HeapProfilerModel,l.HeapProfilerModel.Events.ReportHeapSnapshotProgress,this.reportHeapSnapshotProgress,this),this.exposeInternals=o.Settings.Settings.instance().createSetting("exposeInternals",!1),this.captureNumericValue=o.Settings.Settings.instance().createSetting("captureNumericValue",!1),this.customContentInternal=null}modelAdded(e){e.enable()}modelRemoved(e){}getProfiles(){return super.getProfiles()}fileExtension(){return".heapsnapshot"}get buttonTooltip(){return Mt(kt.takeHeapSnapshot)}isInstantProfile(){return!0}buttonClicked(){return this.takeHeapSnapshot(),a.userMetrics.actionTaken(a.UserMetrics.Action.ProfilesHeapProfileTaken),!1}get treeItemTitle(){return Mt(kt.heapSnapshots)}get description(){return Mt(kt.heapSnapshotProfilesShowMemory)}customContent(){const e=document.createElement("div"),t=c.Runtime.experiments.isEnabled("showOptionToExposeInternalsInHeapSnapshot"),i=!t;if(t){const t=s.SettingsUI.createSettingCheckbox(Mt(kt.exposeInternals),this.exposeInternals,i);e.appendChild(t)}const r=s.SettingsUI.createSettingCheckbox(Mt(kt.captureNumericValue),this.captureNumericValue,i);return e.appendChild(r),this.customContentInternal=e,e}setCustomContentEnabled(e){this.customContentInternal&&this.customContentInternal.querySelectorAll("[is=dt-checkbox]").forEach((t=>{t.checkboxElement.disabled=!e}))}createProfileLoadedFromFile(e){return new Wt(null,this,e)}async takeHeapSnapshot(){if(this.profileBeingRecorded())return;const e=s.Context.Context.instance().flavor(l.HeapProfilerModel.HeapProfilerModel);if(!e)return;let t=new Wt(e,this);this.setProfileBeingRecorded(t),this.addProfile(t),t.updateStatus(Mt(kt.snapshotting)),await e.takeHeapSnapshot({reportProgress:!0,captureNumericValue:this.captureNumericValue.get(),exposeInternals:this.exposeInternals.get()}),t=this.profileBeingRecorded(),t&&(t.title=Mt(kt.snapshotD,{PH1:t.uid}),t.finishLoad(),this.setProfileBeingRecorded(null),this.dispatchEventToListeners(D.ProfileComplete,t))}addHeapSnapshotChunk(e){const t=this.profileBeingRecorded();t&&t.transferChunk(e.data)}reportHeapSnapshotProgress(e){const t=this.profileBeingRecorded();if(!t)return;const{done:i,total:r,finished:s}=e.data;t.updateStatus(Mt(kt.percentagePlaceholder,{PH1:(i/r*100).toFixed(0)}),!0),s&&t.prepareToLoad()}resetProfiles(e){const t=e.data;for(const e of this.getProfiles())e.heapProfilerModel()===t&&this.removeProfile(e)}snapshotReceived(e){this.profileBeingRecorded()===e&&this.setProfileBeingRecorded(null),this.dispatchEventToListeners("SnapshotReceived",e)}static TypeId="HEAP";static SnapshotReceived="SnapshotReceived"}class At extends(o.ObjectWrapper.eventMixin(Ut)){recordAllocationStacksSettingInternal;customContentInternal;recording;profileSamples;constructor(){super(At.TypeId,Mt(kt.allocationInstrumentationOn)),this.recordAllocationStacksSettingInternal=o.Settings.Settings.instance().createSetting("recordAllocationStacks",!1),this.customContentInternal=null,this.recording=!1}modelAdded(e){super.modelAdded(e),e.addEventListener(l.HeapProfilerModel.Events.HeapStatsUpdate,this.heapStatsUpdate,this),e.addEventListener(l.HeapProfilerModel.Events.LastSeenObjectId,this.lastSeenObjectId,this)}modelRemoved(e){super.modelRemoved(e),e.removeEventListener(l.HeapProfilerModel.Events.HeapStatsUpdate,this.heapStatsUpdate,this),e.removeEventListener(l.HeapProfilerModel.Events.LastSeenObjectId,this.lastSeenObjectId,this)}heapStatsUpdate(e){if(!this.profileSamples)return;const t=e.data;let i;for(let e=0;e<t.length;e+=3){i=t[e];const r=t[e+2];this.profileSamples.sizes[i]=r,this.profileSamples.max[i]||(this.profileSamples.max[i]=r)}}lastSeenObjectId(e){const t=this.profileSamples;if(!t)return;const{lastSeenObjectId:i,timestamp:r}=e.data,s=Math.max(t.ids.length,t.max.length-1);t.ids[s]=i,t.max[s]||(t.max[s]=0,t.sizes[s]=0),t.timestamps[s]=r,t.totalTime<r-t.timestamps[0]&&(t.totalTime*=2),this.profileSamples&&this.dispatchEventToListeners("HeapStatsUpdate",this.profileSamples);const o=this.profileBeingRecorded();o&&o.updateStatus(null,!0)}hasTemporaryView(){return!0}get buttonTooltip(){return this.recording?Mt(kt.stopRecordingHeapProfile):Mt(kt.startRecordingHeapProfile)}isInstantProfile(){return!1}buttonClicked(){return this.toggleRecording()}startRecordingProfile(){if(this.profileBeingRecorded())return;const e=this.addNewProfile();e&&e.startTrackingHeapObjects(this.recordAllocationStacksSettingInternal.get())}customContent(){const e=s.SettingsUI.createSettingCheckbox(Mt(kt.recordAllocationStacksExtra),this.recordAllocationStacksSettingInternal,!0);return this.customContentInternal=e,e}setCustomContentEnabled(e){this.customContentInternal&&(this.customContentInternal.checkboxElement.disabled=!e)}recordAllocationStacksSetting(){return this.recordAllocationStacksSettingInternal}addNewProfile(){const e=s.Context.Context.instance().flavor(l.HeapProfilerModel.HeapProfilerModel);return e?(this.setProfileBeingRecorded(new Wt(e,this,void 0)),this.profileSamples=new Ne,this.profileBeingRecorded()._profileSamples=this.profileSamples,this.recording=!0,this.addProfile(this.profileBeingRecorded()),this.profileBeingRecorded().updateStatus(Mt(kt.recording)),this.dispatchEventToListeners("TrackingStarted"),e):null}async stopRecordingProfile(){let e=this.profileBeingRecorded();e.updateStatus(Mt(kt.snapshotting));const t=e.heapProfilerModel().stopTrackingHeapObjects(!0);this.recording=!1,this.dispatchEventToListeners("TrackingStopped"),await t,e=this.profileBeingRecorded(),e&&(e.finishLoad(),this.profileSamples=null,this.setProfileBeingRecorded(null),this.dispatchEventToListeners(D.ProfileComplete,e))}toggleRecording(){return this.recording?this.stopRecordingProfile():this.startRecordingProfile(),this.recording}fileExtension(){return".heaptimeline"}get treeItemTitle(){return Mt(kt.allocationTimelines)}get description(){return Mt(kt.AllocationTimelinesShowInstrumented)}resetProfiles(e){const t=this.recording;this.setProfileBeingRecorded(null),super.resetProfiles(e),this.profileSamples=null,t&&this.addNewProfile()}profileBeingRecordedRemoved(){this.stopRecordingProfile(),this.profileSamples=null}static TypeId="HEAP-RECORD";static HeapStatsUpdate="HeapStatsUpdate";static TrackingStarted="TrackingStarted";static TrackingStopped="TrackingStopped"}class Wt extends F{heapProfilerModelInternal;maxJSObjectId;workerProxy;receiver;snapshotProxy;loadPromise;fulfillLoad;totalNumberOfChunks;bufferedWriter;onTempFileReady;failedToCreateTempFile;wasDisposed;fileName;constructor(e,t,i){super(t,i||Mt(kt.snapshotD,{PH1:t.nextProfileUid()})),this.heapProfilerModelInternal=e,this.maxJSObjectId=-1,this.workerProxy=null,this.receiver=null,this.snapshotProxy=null,this.loadPromise=new Promise((e=>{this.fulfillLoad=e})),this.totalNumberOfChunks=0,this.bufferedWriter=null,this.onTempFileReady=null}heapProfilerModel(){return this.heapProfilerModelInternal}async getLocation(e){return this.snapshotProxy?this.snapshotProxy.getLocation(e):null}createSidebarTreeElement(e){return new A(e,this,"heap-snapshot-sidebar-tree-item")}createView(e){return new Lt(e,this)}prepareToLoad(){console.assert(!this.receiver,"Already loading"),this.setupWorker(),this.updateStatus(Mt(kt.loading),!0)}finishLoad(){!this.wasDisposed&&this.receiver&&this.receiver.close(),this.bufferedWriter&&this.didWriteToTempFile(this.bufferedWriter)}didWriteToTempFile(e){this.wasDisposed?e&&e.remove():(this.tempFile=e,e||(this.failedToCreateTempFile=!0),this.onTempFileReady&&(this.onTempFileReady(),this.onTempFileReady=null))}setupWorker(){console.assert(!this.workerProxy,"HeapSnapshotWorkerProxy already exists"),this.workerProxy=new xt(this.handleWorkerEvent.bind(this)),this.workerProxy.addEventListener("Wait",(e=>{this.updateStatus(null,e.data)}),this),this.receiver=this.workerProxy.createLoader(this.uid,this.snapshotReceived.bind(this))}handleWorkerEvent(e,i){if(p.HeapSnapshotModel.HeapSnapshotProgressEvent.BrokenSnapshot===e){const e=i;return void o.Console.Console.instance().error(e)}if(p.HeapSnapshotModel.HeapSnapshotProgressEvent.Update!==e)return;const r=i,s=t.i18n.deserializeUIString(r);this.updateStatus(Ht(s.string,s.values))}dispose(){this.workerProxy&&this.workerProxy.dispose(),this.removeTempFile(),this.wasDisposed=!0}didCompleteSnapshotTransfer(){this.snapshotProxy&&this.updateStatus(e.NumberUtilities.bytesToString(this.snapshotProxy.totalSize),!1)}transferChunk(e){this.bufferedWriter||(this.bufferedWriter=new h.TempFile.TempFile),this.bufferedWriter.write([e]),++this.totalNumberOfChunks,this.receiver&&this.receiver.write(e)}snapshotReceived(e){this.wasDisposed||(this.receiver=null,this.snapshotProxy=e,this.maxJSObjectId=e.maxJSObjectId(),this.didCompleteSnapshotTransfer(),this.workerProxy&&this.workerProxy.startCheckingForLongRunningCalls(),this.notifySnapshotReceived())}notifySnapshotReceived(){this.snapshotProxy&&this.fulfillLoad&&this.fulfillLoad(this.snapshotProxy),this.profileType().snapshotReceived(this),this.canSaveToFile()&&this.dispatchEventToListeners(k.ProfileReceived)}canSaveToFile(){return!this.fromFile()&&Boolean(this.snapshotProxy)}saveToFile(){const t=new h.FileUtils.FileOutputStream;this.fileName=this.fileName||"Heap-"+e.DateUtilities.toISO8601Compact(new Date)+this.profileType().fileExtension();const i=async e=>{if(e){if(this.failedToCreateTempFile)return o.Console.Console.instance().error("Failed to open temp file with heap snapshot"),void t.close();if(this.tempFile){const e=await this.tempFile.copyToOutputStream(t,this.onChunkTransferred.bind(this));return e&&o.Console.Console.instance().error("Failed to read heap snapshot from temp file: "+e.message),void this.didCompleteSnapshotTransfer()}this.onTempFileReady=()=>{i(e)},this.updateSaveProgress(0,1)}};t.open(this.fileName).then(i.bind(this))}onChunkTransferred(e){this.updateSaveProgress(e.loadedSize(),e.fileSize())}updateSaveProgress(e,t){const i=(100*(t&&e/t)).toFixed(0);this.updateStatus(Mt(kt.savingD,{PH1:i}))}async loadFromFile(e){this.updateStatus(Mt(kt.loading),!0),this.setupWorker();const t=new h.FileUtils.ChunkedFileReader(e,1e7),i=await t.read(this.receiver);if(!i){const e=t.error();e&&this.updateStatus(e.message)}return i?null:t.error()}profileType(){return super.profileType()}}class _t extends s.Widget.VBox{pieChart;constructor(){super(),this.element.classList.add("heap-snapshot-statistics-view"),this.pieChart=new n.PieChart.PieChart,this.setTotalAndRecords(0,[]),this.pieChart.classList.add("heap-snapshot-stats-pie-chart"),this.element.appendChild(this.pieChart)}static valueFormatter(t){return Mt(kt.sKb,{PH1:e.NumberUtilities.withThousandsSeparator(Math.round(t/1e3))})}setTotalAndRecords(e,t){this.pieChart.data={chartName:Mt(kt.heapMemoryUsage),size:150,formatter:_t.valueFormatter,showLegend:!0,total:e,slices:t}}}class Jt extends s.Widget.Widget{heapProfilerModel;linkifier;frameElements;constructor(e){super(),this.heapProfilerModel=e,this.linkifier=new d.Linkifier.Linkifier,this.frameElements=[]}onContextMenu(e,t){const i=new s.ContextMenu.ContextMenu(t);i.containsTarget(e)||i.appendApplicableItems(e),i.show(),t.consume(!0)}onStackViewKeydown(e){const t=e.target;if(!t)return;if("Enter"===e.key){const i=$t.get(t);if(!i)return;const r=d.Linkifier.Linkifier.linkInfo(i);if(!r)return;return void(d.Linkifier.Linkifier.invokeFirstAction(r)&&e.consume(!0))}let i;const r=e;if("ArrowUp"===r.key)i=!1;else{if("ArrowDown"!==r.key)return;i=!0}const s=this.frameElements.indexOf(t);if(-1===s)return;const o=i?s+1:s-1;if(o<0||o>=this.frameElements.length)return;const n=this.frameElements[o];n.tabIndex=0,t.tabIndex=-1,n.focus(),e.consume(!0)}async setAllocatedObject(e,t){this.clear();const i=await e.allocationStack(t);if(!i){const e=this.element.createChild("div","no-heap-allocation-stack");return void s.UIUtils.createTextChild(e,Mt(kt.stackWasNotRecordedForThisObject))}const r=this.element.createChild("div","heap-allocation-stack");r.addEventListener("keydown",this.onStackViewKeydown.bind(this),!1);for(const e of i){const t=r.createChild("div","stack-frame");this.frameElements.push(t),t.tabIndex=-1;if(t.createChild("div").textContent=s.UIUtils.beautifyFunctionName(e.functionName),!e.scriptId)continue;const i=this.heapProfilerModel?this.heapProfilerModel.target():null,o={columnNumber:e.column-1,inlineFrameIndex:0},n=this.linkifier.linkifyScriptLocation(i,String(e.scriptId),e.scriptName,e.line-1,o);t.appendChild(n),$t.set(t,n),t.addEventListener("contextmenu",this.onContextMenu.bind(this,n))}this.frameElements[0].tabIndex=0}clear(){this.element.removeChildren(),this.frameElements=[],this.linkifier.reset()}}const $t=new WeakMap;var qt=Object.freeze({__proto__:null,HeapSnapshotView:Lt,Perspective:jt,SummaryPerspective:Ot,ComparisonPerspective:zt,ContainmentPerspective:Bt,AllocationPerspective:Gt,StatisticsPerspective:Vt,HeapSnapshotProfileType:Ut,TrackingHeapSnapshotProfileType:At,HeapProfileHeader:Wt,HeapSnapshotStatisticsView:_t,HeapAllocationStackView:Jt});class Qt{cpuProfileType;heapSnapshotProfileType;samplingHeapProfileType;trackingHeapSnapshotProfileType;constructor(){this.cpuProfileType=new oe,this.heapSnapshotProfileType=new Ut,this.samplingHeapProfileType=new Be,this.trackingHeapSnapshotProfileType=new At}}const Kt=new Qt;var Yt=Object.freeze({__proto__:null,ProfileTypeRegistry:Qt,instance:Kt});const Zt={clearAllProfiles:"Clear all profiles",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}.",load:"Load…",runD:"Run {PH1}",profiles:"Profiles",deprecationWarnMsg:"This panel will be deprecated in the upcoming version. Use the Performance panel to record JavaScript CPU profiles.",learnMore:"Learn more",feedback:"Feedback",goToPerformancePanel:"Go to Performance Panel",enableThisPanelTemporarily:"Enable this panel temporarily"},Xt=t.i18n.registerUIStrings("panels/profiler/ProfilesPanel.ts",Zt),ei=t.i18n.getLocalizedString.bind(void 0,Xt);class ti extends s.Panel.PanelWithSidebar{profileTypes;profilesItemTreeElement;sidebarTree;profileViews;toolbarElement;toggleRecordAction;toggleRecordButton;clearResultsButton;profileViewToolbar;profileGroups;launcherView;visibleView;profileToView;typeIdToSidebarSection;fileSelectorElement;selectedProfileType;constructor(e,t,i){super(e),this.profileTypes=t;const r=new s.Widget.VBox;this.splitWidget().setMainWidget(r),this.profilesItemTreeElement=new oi(this),this.sidebarTree=new s.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"),r.element.appendChild(this.profileViews),this.toolbarElement=document.createElement("div"),this.toolbarElement.classList.add("profiles-toolbar"),r.element.insertBefore(this.toolbarElement,r.element.firstChild),this.panelSidebarElement().classList.add("profiles-tree-sidebar");const o=document.createElement("div");o.classList.add("profiles-toolbar"),this.panelSidebarElement().insertBefore(o,this.panelSidebarElement().firstChild);const n=new s.Toolbar.Toolbar("",o);this.toggleRecordAction=s.ActionRegistry.ActionRegistry.instance().action(i),this.toggleRecordButton=s.Toolbar.Toolbar.createActionButton(this.toggleRecordAction),n.appendToolbarItem(this.toggleRecordButton),this.clearResultsButton=new s.Toolbar.ToolbarButton(ei(Zt.clearAllProfiles),"clear"),this.clearResultsButton.addEventListener(s.Toolbar.ToolbarButton.Events.Click,this.reset,this),n.appendToolbarItem(this.clearResultsButton),n.appendSeparator(),n.appendToolbarItem(s.Toolbar.Toolbar.createActionButtonForId("components.collect-garbage")),this.profileViewToolbar=new s.Toolbar.Toolbar("",this.toolbarElement),this.profileViewToolbar.makeWrappable(!0),this.profileGroups={},this.launcherView=new xe(this),this.launcherView.addEventListener(ye.ProfileTypeSelected,this.onProfileTypeSelected,this),this.profileToView=[],this.typeIdToSidebarSection={};const a=this.profileTypes;for(let e=0;e<a.length;e++)this.registerProfileType(a[e]);this.launcherView.restoreSelectedProfileType(),this.profilesItemTreeElement.select(),this.showLauncherView(),this.createFileSelectorElement(),this.element.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),l.TargetManager.TargetManager.instance().addEventListener(l.TargetManager.Events.SuspendStateChanged,this.onSuspendStateChanged,this),s.Context.Context.instance().addFlavorChangeListener(l.CPUProfilerModel.CPUProfilerModel,this.updateProfileTypeSpecificUI,this),s.Context.Context.instance().addFlavorChangeListener(l.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=s.UIUtils.createFileSelectorElement(this.loadFromFile.bind(this)),U(this.fileSelectorElement),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 o.Console.Console.instance().error(ei(Zt.cantLoadFileSupportedFile,{PH1:Array.from(e).join("', '")}))}if(Boolean(t.profileBeingRecorded()))return void o.Console.Console.instance().error(ei(Zt.cantLoadProfileWhileAnother));const i=await t.loadFromFile(e);i&&"message"in i&&s.UIUtils.MessageDialog.show(ei(Zt.profileLoadingFailedS,{PH1:i.message}))}toggleRecord(){if(!this.toggleRecordAction.enabled())return!0;const t=e.DOMUtilities.deepActiveElement(this.element.ownerDocument),i=this.selectedProfileType;if(!i)return!0;const r=i.buttonClicked();return this.updateToggleRecordAction(r),r?(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(s.Context.Context.instance().flavor(l.CPUProfilerModel.CPUProfilerModel)||s.Context.Context.instance().flavor(l.HeapProfilerModel.HeapProfilerModel)),i=e||!l.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(s.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.launcherView.profileFinished(),this.sidebarTree.element.classList.remove("some-expandable"),this.launcherView.detach(),this.profileViews.removeChildren(),this.profileViewToolbar.removeToolbarItems(),this.clearResultsButton.element.classList.remove("hidden"),this.profilesItemTreeElement.select(),this.showLauncherView()}showLauncherView(){this.closeVisibleView(),this.profileViewToolbar.removeToolbarItems(),this.launcherView.show(this.profileViews),this.visibleView=this.launcherView,this.toolbarElement.classList.add("hidden")}registerProfileType(e){this.launcherView.addProfileType(e);const t=new ii(this,e);this.typeIdToSidebarSection[e.id]=t,this.sidebarTree.appendChild(t),t.childrenListElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),e.addEventListener(D.ViewUpdated,this.updateProfileTypeSpecificUI,this),e.addEventListener(D.AddProfileHeader,(function(e){this.addProfileHeader(e.data)}),this),e.addEventListener(D.RemoveProfileHeader,(function(e){this.removeProfileHeader(e.data)}),this),e.addEventListener(D.ProfileComplete,(function(e){this.showProfile(e.data)}),this);const i=e.getProfiles();for(let e=0;e<i.length;e++)this.addProfileHeader(i[e])}handleContextMenuEvent(e){const t=new s.ContextMenu.ContextMenu(e);this.panelSidebarElement().isSelfOrAncestor(e.target)&&t.defaultSection().appendItem(ei(Zt.load),this.fileSelectorElement.click.bind(this.fileSelectorElement)),t.show()}showLoadFromFileDialog(){this.fileSelectorElement.click()}addProfileHeader(e){const t=e.profileType().id;this.typeIdToSidebarSection[t].addProfileHeader(e),this.visibleView&&this.visibleView!==this.launcherView||this.showProfile(e)}removeProfileHeader(e){e.profileType().profileBeingRecorded()===e&&this.profileBeingRecordedRemoved();const t=this.indexOfViewForProfile(e);-1!==t&&this.profileToView.splice(t,1);const i=e.profileType().id;this.typeIdToSidebarSection[i].removeProfileHeader(e)&&(this.profilesItemTreeElement.select(),this.showLauncherView())}showProfile(e){if(!e||e.profileType().profileBeingRecorded()===e&&!e.profileType().hasTemporaryView())return null;const t=this.viewForProfile(e);if(t===this.visibleView)return t;this.closeVisibleView(),t.show(this.profileViews),this.toolbarElement.classList.remove("hidden"),this.visibleView=t;const i=this.typeIdToSidebarSection[e.profileType().id].sidebarElementForProfile(e);return i&&i.revealAndSelect(),this.profileViewToolbar.removeToolbarItems(),t.toolbarItems().then((e=>{e.map((e=>this.profileViewToolbar.appendToolbarItem(e)))})),t}showObject(e,t){}async linkifyObject(e){return null}viewForProfile(e){const t=this.indexOfViewForProfile(e);if(-1!==t)return this.profileToView[t].view;const i=e.createView(this);return i.element.classList.add("profile-view"),this.profileToView.push({profile:e,view:i}),i}indexOfViewForProfile(e){return this.profileToView.findIndex((t=>t.profile===e))}closeVisibleView(){this.visibleView&&this.visibleView.detach(),delete this.visibleView}focus(){this.sidebarTree.focus()}wasShown(){super.wasShown(),this.registerCSSFiles([he,pe,ce]),this.sidebarTree.registerCSSFiles([ue])}}class ii extends s.TreeOutline.TreeElement{dataDisplayDelegate;profileTreeElements;profileGroups;constructor(e,t){super(t.treeItemTitle,!0),this.selectable=!1,this.dataDisplayDelegate=e,this.profileTreeElements=[],this.profileGroups={},this.expand(),this.hidden=!0,this.setCollapsible(!1)}addProfileHeader(e){this.hidden=!1;const t=e.profileType();let i=this;const r=e.createSidebarTreeElement(this.dataDisplayDelegate);if(this.profileTreeElements.push(r),!e.fromFile()&&t.profileBeingRecorded()!==e){const t=e.title;let s=this.profileGroups[t];s||(s=new ri,this.profileGroups[t]=s),s.profileSidebarTreeElements.push(r);const o=s.profileSidebarTreeElements.length;if(2===o){s.sidebarTreeElement=new si(this.dataDisplayDelegate,e.title);const t=s.profileSidebarTreeElements[0],i=this.children().indexOf(t);this.insertChild(s.sidebarTreeElement,i);const r=t.selected;this.removeChild(t),s.sidebarTreeElement.appendChild(t),r&&t.revealAndSelect(),t.setSmall(!0),t.setMainTitle(ei(Zt.runD,{PH1:1})),this.treeOutline&&this.treeOutline.element.classList.add("some-expandable")}o>=2&&(i=s.sidebarTreeElement,r.setSmall(!0),r.setMainTitle(ei(Zt.runD,{PH1:o})))}i&&i.appendChild(r)}removeProfileHeader(e){const t=this.sidebarElementIndex(e);if(-1===t)return!1;const i=this.profileTreeElements[t];this.profileTreeElements.splice(t,1);let r=this;const s=this.profileGroups[e.title];if(s){const t=s.profileSidebarTreeElements;if(t.splice(t.indexOf(i),1),1===t.length){const i=r.children().indexOf(s.sidebarTreeElement);s.sidebarTreeElement&&s.sidebarTreeElement.removeChild(t[0]),this.insertChild(t[0],i),t[0].setSmall(!1),t[0].setMainTitle(e.title),s.sidebarTreeElement&&this.removeChild(s.sidebarTreeElement)}0!==t.length&&(r=s.sidebarTreeElement)}return r&&r.removeChild(i),i.dispose(),!this.childCount()&&(this.hidden=!0,!0)}sidebarElementForProfile(e){const t=this.sidebarElementIndex(e);return-1===t?null:this.profileTreeElements[t]}sidebarElementIndex(e){const t=this.profileTreeElements;for(let i=0;i<t.length;i++)if(t[i].profile===e)return i;return-1}onattach(){this.listItemElement.classList.add("profiles-tree-section")}}class ri{profileSidebarTreeElements;sidebarTreeElement;constructor(){this.profileSidebarTreeElements=[],this.sidebarTreeElement=null}}class si extends s.TreeOutline.TreeElement{dataDisplayDelegate;profileTitle;toggleOnClick;constructor(e,t){super("",!0),this.selectable=!1,this.dataDisplayDelegate=e,this.profileTitle=t,this.expand(),this.toggleOnClick=!0}onselect(){const e=this.childCount()>0;if(e){const e=this.lastChild();e instanceof A&&this.dataDisplayDelegate.showProfile(e.profile)}return e}onattach(){this.listItemElement.classList.add("profile-group-sidebar-tree-item"),this.listItemElement.createChild("div","icon"),this.listItemElement.createChild("div","titles no-subtitle").createChild("span","title-container").createChild("span","title").textContent=this.profileTitle}}class oi extends s.TreeOutline.TreeElement{panel;constructor(e){super("",!1),this.selectable=!0,this.panel=e}onselect(){return this.panel.showLauncherView(),!0}onattach(){this.listItemElement.classList.add("profile-launcher-view-tree-item"),this.listItemElement.createChild("div","icon"),this.listItemElement.createChild("div","titles no-subtitle").createChild("span","title-container").createChild("span","title").textContent=ei(Zt.profiles)}}let ni;class ai extends ti{constructor(){super("js_profiler",[Kt.cpuProfileType],"profiler.js-toggle-recording"),this.splitWidget().mainWidget()?.setMinimumSize(350,0),c.Runtime.experiments.isEnabled("jsProfilerTemporarilyEnable")?this.#t():this.#i()}static instance(e={forceNew:null}){const{forceNew:t}=e;return ni&&!t||(ni=new ai),ni}#t(){function e(){a.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://github.com/ChromeDevTools/rfcs/discussions/2")}const t=new s.Infobar.Infobar(s.Infobar.Type.Warning,ei(Zt.deprecationWarnMsg),[{text:ei(Zt.learnMore),highlight:!1,delegate:e,dismiss:!1},{text:ei(Zt.feedback),highlight:!1,delegate:e,dismiss:!1},{text:ei(Zt.goToPerformancePanel),highlight:!0,delegate:async function(){await s.InspectorView.InspectorView.instance().showPanel("timeline")},dismiss:!1}],void 0);t.setParentView(this),this.splitWidget().mainWidget()?.element.prepend(t.element)}#i(){const e=this.splitWidget().mainWidget();if(e?.detachChildWidgets(),e){const t=new s.Widget.VBox;t.contentElement.classList.add("empty-landing-page","fill");const i=t.contentElement.createChild("div");i.createChild("p").textContent="This panel is deprecated and will be removed in the next version. Use the Performance panel to record JavaScript CPU profiles.",i.createChild("p").textContent="You can temporarily enable this panel with Settings > Experiments > Enable JavaScript Profiler.",i.appendChild(s.UIUtils.createTextButton(ei(Zt.goToPerformancePanel),(async function(){await s.InspectorView.InspectorView.instance().showPanel("timeline")}),"infobar-button primary-button")),i.appendChild(s.UIUtils.createTextButton(ei(Zt.learnMore),(function(){a.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://developer.chrome.com/blog/js-profiler-deprecation/")}))),i.appendChild(s.UIUtils.createTextButton(ei(Zt.feedback),(function(){a.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://bugs.chromium.org/p/chromium/issues/detail?id=1354548")}))),i.appendChild(s.UIUtils.createTextButton(ei(Zt.enableThisPanelTemporarily),(async function(){await s.ViewManager.ViewManager.instance().showView("experiments");(await s.ViewManager.ViewManager.instance().view("experiments").widget()).setFilter("Enable JavaScript Profiler temporarily")}))),t.show(e.element)}}wasShown(){super.wasShown(),s.Context.Context.instance().setFlavor(ai,this)}willHide(){s.Context.Context.instance().setFlavor(ai,null)}handleAction(e,t){const i=s.Context.Context.instance().flavor(ai);if(!(i instanceof ai))throw new Error("non-null JSProfilerPanel expected!");return i.toggleRecord(),!0}}var li=Object.freeze({__proto__:null,ProfilesPanel:ti,ProfileTypeSidebarSection:ii,ProfileGroup:ri,ProfileGroupSidebarTreeElement:si,ProfilesSidebarTreeElement:oi,JSProfilerPanel:ai});const di={revealInSummaryView:"Reveal in Summary view"},hi=t.i18n.registerUIStrings("panels/profiler/HeapProfilerPanel.ts",di),ci=t.i18n.getLocalizedString.bind(void 0,hi);let pi;class ui extends ti{constructor(){const e=Kt;super("heap_profiler",[e.heapSnapshotProfileType,e.trackingHeapSnapshotProfileType,e.samplingHeapProfileType],"profiler.heap-toggle-recording")}static instance(){return pi||(pi=new ui),pi}appendApplicableItems(e,t,i){if(!(i instanceof l.RemoteObject.RemoteObject))return;if(!this.isShowing())return;const r=i;if(!r.objectId)return;const s=r.objectId;if(!Kt.heapSnapshotProfileType.getProfiles().length)return;const o=r.runtimeModel().heapProfilerModel();o&&t.revealSection().appendItem(ci(di.revealInSummaryView),function(e){o.snapshotObjectIdForObjectId(s).then((t=>{this.isShowing()&&t&&this.showObject(t,e)}))}.bind(this,"Summary"))}handleAction(e,t){const i=s.Context.Context.instance().flavor(ui);return console.assert(Boolean(i)&&i instanceof ui),i&&i.toggleRecord(),!0}wasShown(){super.wasShown(),s.Context.Context.instance().setFlavor(ui,this),a.userMetrics.panelLoaded("heap_profiler","DevTools.Launch.HeapProfiler")}willHide(){s.Context.Context.instance().setFlavor(ui,null)}showObject(e,t){const i=Kt.heapSnapshotProfileType.getProfiles();for(let r=0;r<i.length;r++){const s=i[r];if(s.maxJSObjectId>=parseInt(e,10)){this.showProfile(s);this.viewForProfile(s).selectLiveObject(t,e);break}}}}var mi=Object.freeze({__proto__:null,HeapProfilerPanel:ui});const fi=new CSSStyleSheet;fi.replaceSync(".data-grid{border:none}.data-grid td .size-units{margin-left:4px;font-size:75%}.data-grid tr:not(.selected) td .size-units{color:var(--color-text-secondary)}.toolbar{border-bottom:1px solid var(--color-details-hairline)}\n/*# sourceURL=liveHeapProfile.css */\n");const gi={jsHeap:"JS Heap",allocatedJsHeapSizeCurrentlyIn:"Allocated JS heap size currently in use",vms:"VMs",numberOfVmsSharingTheSameScript:"Number of VMs sharing the same script source",scriptUrl:"Script URL",urlOfTheScriptSource:"URL of the script source",heapProfile:"Heap Profile",anonymousScriptS:"(Anonymous Script {PH1})",kb:"kB"},vi=t.i18n.registerUIStrings("panels/profiler/LiveHeapProfileView.ts",gi),wi=t.i18n.getLocalizedString.bind(void 0,vi);let Si,bi;class Ci extends s.Widget.VBox{gridNodeByUrl;setting;toggleRecordAction;toggleRecordButton;startWithReloadButton;dataGrid;currentPollId;constructor(){super(!0),this.gridNodeByUrl=new Map,this.setting=o.Settings.Settings.instance().moduleSetting("memoryLiveHeapProfile");const e=new s.Toolbar.Toolbar("live-heap-profile-toolbar",this.contentElement);this.toggleRecordAction=s.ActionRegistry.ActionRegistry.instance().action("live-heap-profile.toggle-recording"),this.toggleRecordButton=s.Toolbar.Toolbar.createActionButton(this.toggleRecordAction),this.toggleRecordButton.setToggled(this.setting.get()),e.appendToolbarItem(this.toggleRecordButton);const t=l.TargetManager.TargetManager.instance().primaryPageTarget();if(t&&t.model(l.ResourceTreeModel.ResourceTreeModel)){const t=s.ActionRegistry.ActionRegistry.instance().action("live-heap-profile.start-with-reload");this.startWithReloadButton=s.Toolbar.Toolbar.createActionButton(t),e.appendToolbarItem(this.startWithReloadButton)}this.dataGrid=this.createDataGrid(),this.dataGrid.asWidget().show(this.contentElement),this.currentPollId=0}static instance(){return Si||(Si=new Ci),Si}createDataGrid(){const e={id:"",title:o.UIString.LocalizedEmptyString,width:void 0,fixedWidth:!0,sortable:!0,align:r.DataGrid.Align.Right,sort:r.DataGrid.Order.Descending,titleDOMFragment:void 0,editable:void 0,nonSelectable:void 0,longText:void 0,disclosure:void 0,weight:void 0,allowInSortByEvenWhenHidden:void 0,dataType:void 0,defaultWeight:void 0},t=[{...e,id:"size",title:wi(gi.jsHeap),width:"72px",fixedWidth:!0,sortable:!0,align:r.DataGrid.Align.Right,sort:r.DataGrid.Order.Descending,tooltip:wi(gi.allocatedJsHeapSizeCurrentlyIn)},{...e,id:"isolates",title:wi(gi.vms),width:"40px",fixedWidth:!0,align:r.DataGrid.Align.Right,tooltip:wi(gi.numberOfVmsSharingTheSameScript)},{...e,id:"url",title:wi(gi.scriptUrl),fixedWidth:!1,sortable:!0,tooltip:wi(gi.urlOfTheScriptSource)}],i=new r.SortableDataGrid.SortableDataGrid({displayName:wi(gi.heapProfile),columns:t,editCallback:void 0,deleteCallback:void 0,refreshCallback:void 0});i.setResizeMethod(r.DataGrid.ResizeMethod.Last),i.element.classList.add("flex-auto"),i.element.addEventListener("keydown",this.onKeyDown.bind(this),!1),i.addEventListener(r.DataGrid.Events.OpenedNode,this.revealSourceForSelectedNode,this),i.addEventListener(r.DataGrid.Events.SortingChanged,this.sortingChanged,this);for(const e of t){const t=i.headerTableHeader(e.id);t&&t.setAttribute("title",e.tooltip)}return i}wasShown(){super.wasShown(),this.poll(),this.registerCSSFiles([fi]),this.setting.addChangeListener(this.settingChanged,this)}willHide(){++this.currentPollId,this.setting.removeChangeListener(this.settingChanged,this)}settingChanged(e){this.toggleRecordButton.setToggled(e.data)}async poll(){const e=this.currentPollId;do{const t=Array.from(l.IsolateManager.IsolateManager.instance().isolates()),i=await Promise.all(t.map((e=>{const t=e.heapProfilerModel();return t?t.getSamplingProfile():null})));if(this.currentPollId!==e)return;this.update(t,i),await new Promise((e=>window.setTimeout(e,3e3)))}while(this.currentPollId===e)}update(e,t){const i=new Map;t.forEach(((t,i)=>{t&&o(e[i],"",t.head)}));const r=this.dataGrid.rootNode(),s=new Set;for(const e of i){const t=e[0],i=e[1].size,o=e[1].isolates.size;if(!t){console.info(`Node with empty URL: ${i} bytes`);continue}let n=this.gridNodeByUrl.get(t);n?n.updateNode(i,o):(n=new Pi(t,i,o),this.gridNodeByUrl.set(t,n),r.appendChild(n)),s.add(n)}for(const e of r.children.slice()){s.has(e)||e.remove();const t=e;this.gridNodeByUrl.delete(t.url)}function o(e,t,r){const s=r.callFrame.url||t||function(e){const t=e.callFrame.functionName;return t.startsWith("(")&&"(root)"!==t?t:""}(r)||function(e){return Number(e.callFrame.scriptId)?wi(gi.anonymousScriptS,{PH1:e.callFrame.scriptId}):""}(r);if(r.children.forEach(o.bind(null,e,s)),!r.selfSize)return;let n=i.get(s);n||(n={size:0,isolates:new Set},i.set(s,n)),n.size+=r.selfSize,n.isolates.add(e)}this.sortingChanged()}onKeyDown(e){"Enter"===e.key&&(e.consume(!0),this.revealSourceForSelectedNode())}revealSourceForSelectedNode(){const e=this.dataGrid.selectedNode;if(!e||!e.url)return;const t=m.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(e.url);t&&o.Revealer.reveal(t)}sortingChanged(){const e=this.dataGrid.sortColumnId();if(!e)return;const t="url"===e?function(e,t){return t.url.localeCompare(e.url)}:function(e,t){return t.size-e.size};this.dataGrid.sortNodes(t,this.dataGrid.isSortOrderAscending())}toggleRecording(){!this.setting.get()?this.startRecording(!1):this.stopRecording()}startRecording(e){if(this.setting.set(!0),!e)return;const t=l.TargetManager.TargetManager.instance().primaryPageTarget();if(!t)return;const i=t.model(l.ResourceTreeModel.ResourceTreeModel);i&&i.reloadPage()}async stopRecording(){this.setting.set(!1)}}class Pi extends r.SortableDataGrid.SortableDataGridNode{url;size;isolateCount;constructor(e,t,i){super(),this.url=e,this.size=t,this.isolateCount=i}updateNode(e,t){this.size===e&&this.isolateCount===t||(this.size=e,this.isolateCount=t,this.refresh())}createCell(t){const i=this.createTD(t);switch(t){case"url":i.textContent=this.url;break;case"size":i.textContent=e.NumberUtilities.withThousandsSeparator(Math.round(this.size/1e3)),i.createChild("span","size-units").textContent=wi(gi.kb);break;case"isolates":i.textContent=`${this.isolateCount}`}return i}}class Ti{static instance(e={forceNew:null}){const{forceNew:t}=e;return bi&&!t||(bi=new Ti),bi}handleAction(e,t){return(async()=>{const e="live_heap_profile";await s.ViewManager.ViewManager.instance().showView(e);const i=s.ViewManager.ViewManager.instance().view(e);if(i){const e=await i.widget();this.innerHandleAction(e,t)}})(),!0}innerHandleAction(e,t){switch(t){case"live-heap-profile.toggle-recording":e.toggleRecording();break;case"live-heap-profile.start-with-reload":e.startRecording(!0);break;default:console.assert(!1,`Unknown action: ${t}`)}}}var xi=Object.freeze({__proto__:null,LiveHeapProfileView:Ci,GridNode:Pi,ActionDelegate:Ti});export{T as BottomUpProfileDataGrid,M as CPUProfileFlameChart,de as CPUProfileView,x as ChildrenProvider,_e as HeapProfileView,mi as HeapProfilerPanel,bt as HeapSnapshotDataGrids,ot as HeapSnapshotGridNodes,Nt as HeapSnapshotProxy,qt as HeapSnapshotView,De as HeapTimelineOverview,Se as IsolateSelector,xi as LiveHeapProfileView,b as ProfileDataGrid,j as ProfileHeader,Ie as ProfileLauncherView,W as ProfileSidebarTreeElement,Yt as ProfileTypeRegistry,ee as ProfileView,li as ProfilesPanel,$ as TopDownProfileDataGrid};
|
|
7
|
+
</td>`,r=i.$("container");this.prefixObjectCell(r),this.reachableFromWindow&&r.appendChild(s.Fragment.html`<span class="heap-object-tag" title="${qe(Je.userObjectReachableFromWindow)}">🗖</span>`),this.detachedDOMTreeNode&&r.appendChild(s.Fragment.html`<span class="heap-object-tag" title="${qe(Je.detachedFromDomTree)}">✀</span>`),this.appendSourceLocation(r);const o=i.element();return this.depth&&o.style.setProperty("padding-left",this.depth*this.dataGrid.indentWidth+"px"),o}prefixObjectCell(e){}async appendSourceLocation(e){const t=s.Fragment.html`<span class="heap-object-source-link">`;e.appendChild(t);const i=await this.dataGridInternal.dataDisplayDelegate().linkifyObject(this.snapshotNodeIndex);i?(t.appendChild(i),this.linkElement=i):t.remove()}async queryObjectContent(e,t){return await this.tryQueryObjectContent(e,t)||e.runtimeModel().createRemoteObjectFromPrimitiveValue(qe(Je.previewIsNotAvailable))}async tryQueryObjectContent(e,t){return"string"===this.type?e.runtimeModel().createRemoteObjectFromPrimitiveValue(this.nameInternal):await e.objectForSnapshotObjectId(String(this.snapshotNodeId),t)}async updateHasChildren(){const e=await this.provider().isEmpty();this.setHasChildren(!e)}shortenWindowURL(t,i){const r=t.indexOf("/"),s=i?t.indexOf("@"):t.length;if(-1===r||-1===s)return t;const o=t.substring(r+1,s).trimLeft();let n=e.StringUtilities.trimURL(o);return n.length>40&&(n=e.StringUtilities.trimMiddle(n,40)),t.substr(0,r+2)+n+t.substr(s)}populateContextMenu(e,t,i){if(e.revealSection().appendItem(qe(Je.revealInSummaryView),(()=>{t.showObject(String(this.snapshotNodeId),qe(Je.summary))})),this.referenceName)for(const i of this.referenceName.matchAll(/\((?<objectName>[^@)]*) @(?<snapshotNodeId>\d+)\)/g)){const{objectName:r,snapshotNodeId:s}=i.groups;e.revealSection().appendItem(qe(Je.revealObjectSWithIdSInSummary,{PH1:r,PH2:s}),(()=>{t.showObject(s,qe(Je.summary))}))}i&&e.revealSection().appendItem(qe(Je.storeAsGlobalVariable),(async()=>{const e=await this.tryQueryObjectContent(i,"");if(e){const t=i.target().model(l.ConsoleModel.ConsoleModel);await(t?.saveToTempVariable(s.Context.Context.instance().flavor(l.RuntimeModel.ExecutionContext),e))}else o.Console.Console.instance().error(qe(Je.previewIsNotAvailable))}))}}class Ze extends Ye{referenceName;referenceType;edgeIndex;snapshot;parentObjectNode;cycledWithAncestorGridNode;constructor(e,t,i,r){super(e,i.node),this.referenceName=i.name,this.referenceType=i.type,this.edgeIndex=i.edgeIndex,this.snapshot=t,this.parentObjectNode=r,this.cycledWithAncestorGridNode=this.findAncestorWithSameSnapshotNodeId(),this.cycledWithAncestorGridNode||this.updateHasChildren();const s=this.data;s.count="",s.addedCount="",s.removedCount="",s.countDelta="",s.addedSize="",s.removedSize="",s.sizeDelta=""}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.snapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create a provider on a root node");return this.snapshot.createEdgesProvider(this.snapshotNodeIndex)}findAncestorWithSameSnapshotNodeId(){let e=this.parentObjectNode;for(;e;){if(e.snapshotNodeId===this.snapshotNodeId)return e;e=e.parentObjectNode}return null}createChildNode(e){return new Ze(this.dataGridInternal,this.snapshot,e,this)}getHash(){return this.edgeIndex}comparator(){const e=this.dataGridInternal.isSortOrderAscending();switch(this.dataGridInternal.sortColumnId()){case"object":return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",e,"retainedSize",!1);case"count":default:return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",!0,"retainedSize",!1);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"!edgeName",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"!edgeName",!0);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",e,"name",!0)}}prefixObjectCell(e){let t=this.referenceName||"(empty)",i="name";switch(this.referenceType){case"context":i="object-value-number";break;case"internal":case"hidden":case"weak":i="object-value-null";break;case"element":t=`[${t}]`}this.cycledWithAncestorGridNode&&e.classList.add("cycled-ancessor-node"),e.prepend(s.Fragment.html`<span class="property-name ${i}">${t}</span> <span class="grayed">${this.edgeNodeSeparator()}</span>`)}edgeNodeSeparator(){return"::"}}class Xe extends Ze{constructor(e,t,i,r){super(e,t,i,r)}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create providers on root nodes");return this.snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex)}createChildNode(e){return new Xe(this.dataGridInternal,this.snapshot,e,this)}edgeNodeSeparator(){return qe(Je.inElement)}expand(){this.expandRetainersChain(20)}expandRetainersChain(e){if(!this.populated)return this.once(Ke.Events.PopulateComplete).then((()=>this.expandRetainersChain(e))),void this.populate();if(super.expand(),--e>0&&this.children.length>0){const t=this.children[0];if((t.distance||0)>1)return void t.expandRetainersChain(e)}this.dataGridInternal.dispatchEventToListeners(pt.ExpandRetainersComplete)}}class et extends Ye{baseSnapshotOrSnapshot;isDeletedNode;constructor(t,i,r,s){super(t,r),this.baseSnapshotOrSnapshot=i,this.isDeletedNode=s,this.updateHasChildren();const o=this.data;o.count="",o.countDelta="",o.sizeDelta="",this.isDeletedNode?(o.addedCount="",o.addedSize="",o.removedCount="•",o.removedSize=e.NumberUtilities.withThousandsSeparator(this.shallowSize||0)):(o.addedCount="•",o.addedSize=e.NumberUtilities.withThousandsSeparator(this.shallowSize||0),o.removedCount="",o.removedSize="")}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.baseSnapshotOrSnapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create providers on root nodes");return this.baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeIndex)}createChildNode(e){return new Ze(this.dataGridInternal,this.baseSnapshotOrSnapshot,e,null)}getHash(){if(void 0===this.snapshotNodeId)throw new Error("Cannot hash root nodes");return this.snapshotNodeId}comparator(){const e=this.dataGridInternal.isSortOrderAscending();switch(this.dataGridInternal.sortColumnId()){case"object":return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",e,"retainedSize",!1);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",e,"retainedSize",!1);case"count":default:return new p.HeapSnapshotModel.ComparatorConfig("!edgeName",!0,"retainedSize",!1);case"addedSize":case"removedSize":case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"!edgeName",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"!edgeName",!0)}}}class tt extends Ke{nameInternal;nodeFilter;distance;count;shallowSize;retainedSize;constructor(t,i,r,s){super(t,r.count>0),this.nameInternal=i,this.nodeFilter=s,this.distance=r.distance,this.count=r.count,this.shallowSize=r.self,this.retainedSize=r.maxRet;const o=t.snapshot,n=this.retainedSize/o.totalSize*100,a=this.shallowSize/o.totalSize*100;this.data={object:i,count:e.NumberUtilities.withThousandsSeparator(this.count),distance:this.toUIDistance(this.distance),shallowSize:e.NumberUtilities.withThousandsSeparator(this.shallowSize),retainedSize:e.NumberUtilities.withThousandsSeparator(this.retainedSize),"shallowSize-percent":this.toPercentString(a),"retainedSize-percent":this.toPercentString(n)}}get name(){return this.nameInternal}createProvider(){return this.dataGridInternal.snapshot.createNodesProviderForClass(this.nameInternal,this.nodeFilter)}async populateNodeBySnapshotObjectId(e){this.dataGridInternal.resetNameFilter(),await this.expandWithoutPopulate();const t=await this.provider().nodePosition(e);if(-1===t)return this.collapse(),[];await this.populateChildren(t,null);const i=this.childForPosition(t);return i?[this,i]:[]}filteredOut(e){return-1===this.nameInternal.toLowerCase().indexOf(e)}createCell(e){const t="object"===e?super.createCell(e):this.createValueCell(e);return"object"===e&&this.count>1&&t.appendChild(s.Fragment.html`<span class="objects-count">×${this.count}</span>`),t}createChildNode(e){return new et(this.dataGridInternal,this.dataGridInternal.snapshot,e,!1)}comparator(){const e=this.dataGridInternal.isSortOrderAscending(),t=this.dataGridInternal.sortColumnId();switch(t){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",e,"id",!0);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",e,"retainedSize",!1);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"id",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"id",!0);default:throw new Error(`Invalid sort column id ${t}`)}}}class it{addedNodesProvider;deletedNodesProvider;addedCount;removedCount;constructor(e,t,i,r){this.addedNodesProvider=e,this.deletedNodesProvider=t,this.addedCount=i,this.removedCount=r}dispose(){this.addedNodesProvider.dispose(),this.deletedNodesProvider.dispose()}nodePosition(e){throw new Error("Unreachable")}isEmpty(){return Promise.resolve(!1)}async serializeItemsRange(e,t){let i,r;if(e<this.addedCount){i=await this.addedNodesProvider.serializeItemsRange(e,t);for(const e of i.items)e.isAddedNotRemoved=!0;if(i.endPosition>=t)return i.totalLength=this.addedCount+this.removedCount,i;r=i,i=await this.deletedNodesProvider.serializeItemsRange(0,t-i.endPosition)}else r=new p.HeapSnapshotModel.ItemsRange(0,0,0,[]),i=await this.deletedNodesProvider.serializeItemsRange(e-this.addedCount,t-this.addedCount);r.items.length||(r.startPosition=this.addedCount+i.startPosition);for(const e of i.items)e.isAddedNotRemoved=!1;return r.items.push(...i.items),r.endPosition=this.addedCount+i.endPosition,r.totalLength=this.addedCount+this.removedCount,r}async sortAndRewind(e){await this.addedNodesProvider.sortAndRewind(e),await this.deletedNodesProvider.sortAndRewind(e)}}class rt extends Ke{nameInternal;addedCount;removedCount;countDelta;addedSize;removedSize;sizeDelta;deletedIndexes;constructor(t,i,r){super(t,!0),this.nameInternal=i,this.addedCount=r.addedCount,this.removedCount=r.removedCount,this.countDelta=r.countDelta,this.addedSize=r.addedSize,this.removedSize=r.removedSize,this.sizeDelta=r.sizeDelta,this.deletedIndexes=r.deletedIndexes,this.data={object:i,addedCount:e.NumberUtilities.withThousandsSeparator(this.addedCount),removedCount:e.NumberUtilities.withThousandsSeparator(this.removedCount),countDelta:this.signForDelta(this.countDelta)+e.NumberUtilities.withThousandsSeparator(Math.abs(this.countDelta)),addedSize:e.NumberUtilities.withThousandsSeparator(this.addedSize),removedSize:e.NumberUtilities.withThousandsSeparator(this.removedSize),sizeDelta:this.signForDelta(this.sizeDelta)+e.NumberUtilities.withThousandsSeparator(Math.abs(this.sizeDelta))}}get name(){return this.nameInternal}createProvider(){const e=this.dataGridInternal;if(null===e.snapshot||void 0===e.baseSnapshot||void 0===e.baseSnapshot.uid)throw new Error("Data sources have not been set correctly");const t=e.snapshot.createAddedNodesProvider(e.baseSnapshot.uid,this.nameInternal),i=e.baseSnapshot.createDeletedNodesProvider(this.deletedIndexes);if(!t||!i)throw new Error("Failed to create node providers");return new it(t,i,this.addedCount,this.removedCount)}createCell(e){const t=super.createCell(e);return"object"!==e&&t.classList.add("numeric-column"),t}createChildNode(e){const t=this.dataGridInternal;if(e.isAddedNotRemoved){if(null===t.snapshot)throw new Error("Data sources have not been set correctly");return new et(this.dataGridInternal,t.snapshot,e,!1)}if(void 0===t.baseSnapshot)throw new Error("Data sources have not been set correctly");return new et(this.dataGridInternal,t.baseSnapshot,e,!0)}comparator(){const e=this.dataGridInternal.isSortOrderAscending(),t=this.dataGridInternal.sortColumnId();switch(t){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",e,"id",!0);case"addedCount":case"removedCount":case"countDelta":return new p.HeapSnapshotModel.ComparatorConfig("name",!0,"id",!0);case"addedSize":case"removedSize":case"sizeDelta":return new p.HeapSnapshotModel.ComparatorConfig("selfSize",e,"id",!0);default:throw new Error(`Invalid sort column ${t}`)}}filteredOut(e){return-1===this.nameInternal.toLowerCase().indexOf(e)}signForDelta(e){return 0===e?"":e>0?"+":"−"}}class st extends Ke{populated;allocationNode;constructor(t,i){super(t,i.hasChildren),this.populated=!1,this.allocationNode=i,this.data={liveCount:e.NumberUtilities.withThousandsSeparator(i.liveCount),count:e.NumberUtilities.withThousandsSeparator(i.count),liveSize:e.NumberUtilities.withThousandsSeparator(i.liveSize),size:e.NumberUtilities.withThousandsSeparator(i.size),name:i.name}}populate(){this.populated||this.doPopulate()}async doPopulate(){this.populated=!0;const e=await this.dataGridInternal.snapshot.allocationNodeCallers(this.allocationNode.id),t=e.nodesWithSingleCaller;let i=this;const r=this.dataGridInternal;for(const e of t){const t=new st(r,e);r.appendNode(i,t),i=t,i.populated=!0,this.expanded&&i.expand()}const s=e.branchingCallers;s.sort(this.dataGridInternal.createComparator());for(const e of s)r.appendNode(i,new st(r,e));r.updateVisibleNodes(!0)}expand(){super.expand(),1===this.children.length&&this.children[0].expand()}createCell(e){if("name"!==e)return this.createValueCell(e);const t=super.createCell(e),i=this.allocationNode,r=this.dataGridInternal.heapProfilerModel();if(i.scriptId){const e=this.dataGridInternal.linkifier.linkifyScriptLocation(r?r.target():null,String(i.scriptId),i.scriptName,i.line-1,{columnNumber:i.column-1,inlineFrameIndex:0,className:"profile-node-file"});e.style.maxWidth="75%",t.insertBefore(e,t.firstChild)}return t}allocationNodeId(){return this.allocationNode.id}}var ot=Object.freeze({__proto__:null,get HeapSnapshotGridNode(){return Ke},HeapSnapshotGenericObjectNode:Ye,HeapSnapshotObjectNode:Ze,HeapSnapshotRetainingObjectNode:Xe,HeapSnapshotInstanceNode:et,HeapSnapshotConstructorNode:tt,HeapSnapshotDiffNodesProvider:it,HeapSnapshotDiffNode:rt,AllocationGridNode:st});const nt={distanceFromWindowObject:"Distance from window object",sizeOfTheObjectItselfInBytes:"Size of the object itself in bytes",sizeOfTheObjectPlusTheGraphIt:"Size of the object plus the graph it retains in bytes",object:"Object",distance:"Distance",shallowSize:"Shallow Size",retainedSize:"Retained Size",heapSnapshotRetainment:"Heap Snapshot Retainment",constructorString:"Constructor",heapSnapshotConstructors:"Heap Snapshot Constructors",New:"# New",Deleted:"# Deleted",Delta:"# Delta",allocSize:"Alloc. Size",freedSize:"Freed Size",sizeDelta:"Size Delta",heapSnapshotDiff:"Heap Snapshot Diff",liveCount:"Live Count",count:"Count",liveSize:"Live Size",size:"Size",function:"Function",allocation:"Allocation"},at=t.i18n.registerUIStrings("panels/profiler/HeapSnapshotDataGrids.ts",nt),lt=t.i18n.getLocalizedString.bind(void 0,at),dt=new WeakMap;class ht extends r.DataGrid.DataGridImpl{}class ct extends(o.ObjectWrapper.eventMixin(ht)){snapshot;selectedNode;heapProfilerModelInternal;dataDisplayDelegateInternal;recursiveSortingDepth;populatedAndSorted;nameFilter;nodeFilterInternal;lastSortColumnId;lastSortAscending;constructor(e,t,i){super(i),this.snapshot=null,this.selectedNode=null,this.heapProfilerModelInternal=e,this.dataDisplayDelegateInternal=t;const s=[["distance",lt(nt.distanceFromWindowObject)],["shallowSize",lt(nt.sizeOfTheObjectItselfInBytes)],["retainedSize",lt(nt.sizeOfTheObjectPlusTheGraphIt)]];for(const e of s){const t=this.headerTableHeader(e[0]);t&&t.setAttribute("title",e[1])}this.recursiveSortingDepth=0,this.populatedAndSorted=!1,this.nameFilter=null,this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter,this.addEventListener(pt.SortingComplete,this.sortingComplete,this),this.addEventListener(r.DataGrid.Events.SortingChanged,this.sortingChanged,this),this.setRowContextMenuCallback(this.populateContextMenu.bind(this))}async setDataSource(e,t){}isFilteredOut(e){const t=this.nameFilter?this.nameFilter.value().toLowerCase():"";return!!(t&&(e instanceof rt||e instanceof tt)&&e.filteredOut(t))}heapProfilerModel(){return this.heapProfilerModelInternal}dataDisplayDelegate(){return this.dataDisplayDelegateInternal}nodeFilter(){return this.nodeFilterInternal}setNameFilter(e){this.nameFilter=e}defaultPopulateCount(){return 100}disposeAllNodes(){const e=this.topLevelNodes();for(let t=0,i=e.length;t<i;++t)e[t].dispose()}wasShown(){this.nameFilter&&(this.nameFilter.addEventListener(s.Toolbar.ToolbarInput.Event.TextChanged,this.onNameFilterChanged,this),this.updateVisibleNodes(!0)),this.populatedAndSorted&&this.dispatchEventToListeners(pt.ContentShown,this)}sortingComplete(){this.removeEventListener(pt.SortingComplete,this.sortingComplete,this),this.populatedAndSorted=!0,this.dispatchEventToListeners(pt.ContentShown,this)}willHide(){this.nameFilter&&this.nameFilter.removeEventListener(s.Toolbar.ToolbarInput.Event.TextChanged,this.onNameFilterChanged,this)}populateContextMenu(e,t){const i=t;i.populateContextMenu(e,this.dataDisplayDelegateInternal,this.heapProfilerModel()),i instanceof Ye&&i.linkElement&&!e.containsTarget(i.linkElement)&&e.appendApplicableItems(i.linkElement)}resetSortingCache(){delete this.lastSortColumnId,delete this.lastSortAscending}topLevelNodes(){return this.rootNode().children}revealObjectByHeapSnapshotId(e){return Promise.resolve(null)}resetNameFilter(){this.nameFilter&&this.nameFilter.setValue("")}onNameFilterChanged(){this.updateVisibleNodes(!0),this.deselectFilteredNodes()}deselectFilteredNodes(){let e=this.selectedNode;for(;e;){if(this.selectedNode&&this.isFilteredOut(e))return this.selectedNode.deselect(),void(this.selectedNode=null);e=e.parent}}sortFields(e,t){throw new Error("Not implemented")}sortingChanged(){const e=this.isSortOrderAscending(),t=this.sortColumnId();if(this.lastSortColumnId===t&&this.lastSortAscending===e)return;this.lastSortColumnId=t,this.lastSortAscending=e;const i=this.sortFields(t||"",e);this.performSorting((function(e,t){let r=e[i.fieldName1],s=t[i.fieldName1],o=r<s?-1:r>s?1:0;return i.ascending1||(o=-o),0!==o||(r=e[i.fieldName2],s=t[i.fieldName2],o=r<s?-1:r>s?1:0,i.ascending2||(o=-o)),o}))}performSorting(e){this.recursiveSortingEnter();const t=this.allChildren(this.rootNode());this.rootNode().removeChildren(),t.sort(e);for(let e=0,i=t.length;e<i;++e){const i=t[e];this.appendChildAfterSorting(i),i.expanded&&i.sort()}this.recursiveSortingLeave()}appendChildAfterSorting(e){const t=e.revealed;this.rootNode().appendChild(e),e.revealed=t}recursiveSortingEnter(){++this.recursiveSortingDepth}recursiveSortingLeave(){this.recursiveSortingDepth&&(--this.recursiveSortingDepth||(this.updateVisibleNodes(!0),this.dispatchEventToListeners(pt.SortingComplete)))}updateVisibleNodes(e){}allChildren(e){return e.children}insertChild(e,t,i){e.insertChild(t,i)}removeChildByIndex(e,t){e.removeChild(e.children[t])}removeAllChildren(e){e.removeChildren()}}var pt,ut;!function(e){e.ContentShown="ContentShown",e.SortingComplete="SortingComplete",e.ExpandRetainersComplete="ExpandRetainersComplete"}(pt||(pt={}));class mt extends ct{topPaddingHeight;bottomPaddingHeight;selectedNode;scrollToResolveCallback;constructor(e,t,i){super(e,t,i),this.scrollContainer.addEventListener("scroll",this.onScroll.bind(this),!0),this.topPaddingHeight=0,this.bottomPaddingHeight=0,this.selectedNode=null}topLevelNodes(){return this.allChildren(this.rootNode())}appendChildAfterSorting(e){}updateVisibleNodes(e){const t=this.scrollContainer.scrollHeight;let i=this.scrollContainer.scrollTop,r=t-i-this.scrollContainer.offsetHeight;i=Math.max(0,i-40),r=Math.max(0,r-40);let s=t-i-r;if(!e&&i>=this.topPaddingHeight&&r>=this.bottomPaddingHeight)return;i-=500,s+=1e3;const o=this.selectedNode;this.rootNode().removeChildren(),this.topPaddingHeight=0,this.bottomPaddingHeight=0,this.addVisibleNodes(this.rootNode(),i,i+s),this.setVerticalPadding(this.topPaddingHeight,this.bottomPaddingHeight),o&&(o.parent?o.select(!0):this.selectedNode=o)}addVisibleNodes(e,t,i){if(!e.expanded)return 0;const r=this.allChildren(e);let s=0,o=0;for(;o<r.length;++o){const e=r[o];if(this.isFilteredOut(e))continue;const i=s+this.nodeHeight(e);if(i>t)break;s=i}let n=s;for(;o<r.length&&n<i;++o){const s=r[o];if(this.isFilteredOut(s))continue;const a=s.hasChildren();s.removeChildren(),s.setHasChildren(a),e.appendChild(s),n+=s.nodeSelfHeight(),n+=this.addVisibleNodes(s,t-n,i-n)}let a=0;for(;o<r.length;++o){const e=r[o];this.isFilteredOut(e)||(a+=this.nodeHeight(e))}return this.topPaddingHeight+=s,this.bottomPaddingHeight+=a,n+a}nodeHeight(e){let t=e.nodeSelfHeight();if(!e.expanded)return t;const i=this.allChildren(e);for(let e=0;e<i.length;e++)t+=this.nodeHeight(i[e]);return t}revealTreeNode(e){const t=this.calculateOffset(e),i=e[e.length-1],r=this.scrollContainer.scrollTop,s=r+this.scrollContainer.offsetHeight;if(t>=r&&t<s)return Promise.resolve(i);return this.scrollContainer.scrollTop=Math.max(0,t-40),new Promise((e=>{console.assert(!this.scrollToResolveCallback),this.scrollToResolveCallback=e.bind(null,i),this.scrollContainer.window().requestAnimationFrame((()=>{this.scrollToResolveCallback&&(this.scrollToResolveCallback(),this.scrollToResolveCallback=null)}))}))}calculateOffset(e){let t=this.rootNode(),i=0;if(0===e.length)return 0;for(let r=0;r<e.length;++r){const s=e[r],o=this.allChildren(t);for(let e=0;e<o.length;++e){const t=o[e];if(s===t){i+=s.nodeSelfHeight();break}i+=this.nodeHeight(t)}t=s}return i-e[e.length-1].nodeSelfHeight()}allChildren(e){const t=dt.get(e)||[];return dt.has(e)||dt.set(e,t),t}appendNode(e,t){this.allChildren(e).push(t)}insertChild(e,t,i){this.allChildren(e).splice(i,0,t)}removeChildByIndex(e,t){this.allChildren(e).splice(t,1)}removeAllChildren(e){dt.delete(e)}removeTopLevelNodes(){this.disposeAllNodes(),this.rootNode().removeChildren(),this.removeAllChildren(this.rootNode())}isScrolledIntoView(e){const t=this.scrollContainer.scrollTop,i=t+this.scrollContainer.clientHeight,r=e.offsetTop;return r+e.offsetHeight<=i&&r>=t}onResize(){super.onResize(),this.updateVisibleNodes(!1)}onScroll(e){this.updateVisibleNodes(!1),this.scrollToResolveCallback&&(this.scrollToResolveCallback(),this.scrollToResolveCallback=null)}}class ft extends ct{constructor(e,t,i,s){super(e,t,{displayName:i,columns:s=s||[{id:"object",title:lt(nt.object),disclosure:!0,sortable:!0},{id:"distance",title:lt(nt.distance),width:"70px",sortable:!0,fixedWidth:!0},{id:"shallowSize",title:lt(nt.shallowSize),width:"110px",sortable:!0,fixedWidth:!0},{id:"retainedSize",title:lt(nt.retainedSize),width:"110px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Descending}]})}async setDataSource(e,t){this.snapshot=e;const i=new p.HeapSnapshotModel.Node(-1,"root",0,t||e.rootNodeIndex,0,0,"");this.setRootNode(this.createRootNode(e,i)),this.rootNode().sort()}createRootNode(e,t){const i=new p.HeapSnapshotModel.Edge("",t,"",-1);return new Ze(this,e,i,null)}sortingChanged(){const e=this.rootNode();e.hasChildren()&&e.sort()}}class gt extends ft{constructor(e,t){const i=[{id:"object",title:lt(nt.object),disclosure:!0,sortable:!0},{id:"distance",title:lt(nt.distance),width:"70px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Ascending},{id:"shallowSize",title:lt(nt.shallowSize),width:"110px",sortable:!0,fixedWidth:!0},{id:"retainedSize",title:lt(nt.retainedSize),width:"110px",sortable:!0,fixedWidth:!0}];super(e,t,lt(nt.heapSnapshotRetainment),i)}createRootNode(e,t){const i=new p.HeapSnapshotModel.Edge("",t,"",-1);return new Xe(this,e,i,null)}sortFields(e,t){switch(e){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",t,"count",!1);case"count":return new p.HeapSnapshotModel.ComparatorConfig("count",t,"name",!0);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("shallowSize",t,"name",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",t,"name",!0);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",t,"name",!0);default:throw new Error(`Unknown column ${e}`)}}reset(){this.rootNode().removeChildren(),this.resetSortingCache()}async setDataSource(e,t){await super.setDataSource(e,t),this.rootNode().expand()}}!function(e){e.ExpandRetainersComplete="ExpandRetainersComplete"}(ut||(ut={}));class vt extends mt{profileIndex;objectIdToSelect;nextRequestedFilter;lastFilter;filterInProgress;constructor(e,t){const i=[{id:"object",title:lt(nt.constructorString),disclosure:!0,sortable:!0},{id:"distance",title:lt(nt.distance),width:"70px",sortable:!0,fixedWidth:!0},{id:"shallowSize",title:lt(nt.shallowSize),width:"110px",sortable:!0,fixedWidth:!0},{id:"retainedSize",title:lt(nt.retainedSize),width:"110px",sort:r.DataGrid.Order.Descending,sortable:!0,fixedWidth:!0}];super(e,t,{displayName:lt(nt.heapSnapshotConstructors).toString(),columns:i}),this.profileIndex=-1,this.objectIdToSelect=null,this.nextRequestedFilter=null}sortFields(e,t){switch(e){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",t,"retainedSize",!1);case"distance":return new p.HeapSnapshotModel.ComparatorConfig("distance",t,"retainedSize",!1);case"shallowSize":return new p.HeapSnapshotModel.ComparatorConfig("shallowSize",t,"name",!0);case"retainedSize":return new p.HeapSnapshotModel.ComparatorConfig("retainedSize",t,"name",!0);default:throw new Error(`Unknown column ${e}`)}}async revealObjectByHeapSnapshotId(e){if(!this.snapshot)return this.objectIdToSelect=e,null;const t=await this.snapshot.nodeClassName(parseInt(e,10));if(!t)return null;const i=this.topLevelNodes().find((e=>e.name===t));if(!i)return null;const r=await i.populateNodeBySnapshotObjectId(parseInt(e,10));return r.length?this.revealTreeNode(r):null}clear(){this.nextRequestedFilter=null,this.lastFilter=null,this.removeTopLevelNodes()}async setDataSource(e,t){this.snapshot=e,-1===this.profileIndex&&this.populateChildren(),this.objectIdToSelect&&(this.revealObjectByHeapSnapshotId(this.objectIdToSelect),this.objectIdToSelect=null)}setSelectionRange(e,t){this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter(e,t),this.populateChildren(this.nodeFilterInternal)}setAllocationNodeId(e){this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter,this.nodeFilterInternal.allocationNodeId=e,this.populateChildren(this.nodeFilterInternal)}aggregatesReceived(e,t){this.filterInProgress=null,this.nextRequestedFilter&&this.snapshot&&(this.snapshot.aggregatesWithFilter(this.nextRequestedFilter).then(this.aggregatesReceived.bind(this,this.nextRequestedFilter)),this.filterInProgress=this.nextRequestedFilter,this.nextRequestedFilter=null),this.removeTopLevelNodes(),this.resetSortingCache();for(const i in t)this.appendNode(this.rootNode(),new tt(this,i,t[i],e));this.sortingChanged(),this.lastFilter=e}async populateChildren(e){const t=e||new p.HeapSnapshotModel.NodeFilter;if(this.filterInProgress)this.nextRequestedFilter=this.filterInProgress.equals(t)?null:t;else if((!this.lastFilter||!this.lastFilter.equals(t))&&(this.filterInProgress=t,this.snapshot)){const e=await this.snapshot.aggregatesWithFilter(t);this.aggregatesReceived(t,e)}}filterSelectIndexChanged(e,t){if(this.profileIndex=t,this.nodeFilterInternal=void 0,-1!==t){const i=t>0?e[t-1].maxJSObjectId:0,r=e[t].maxJSObjectId;this.nodeFilterInternal=new p.HeapSnapshotModel.NodeFilter(i,r)}this.populateChildren(this.nodeFilterInternal)}}class wt extends mt{baseSnapshot;constructor(e,t){const i=[{id:"object",title:lt(nt.constructorString),disclosure:!0,sortable:!0},{id:"addedCount",title:lt(nt.New),width:"75px",sortable:!0,fixedWidth:!0},{id:"removedCount",title:lt(nt.Deleted),width:"75px",sortable:!0,fixedWidth:!0},{id:"countDelta",title:lt(nt.Delta),width:"65px",sortable:!0,fixedWidth:!0},{id:"addedSize",title:lt(nt.allocSize),width:"75px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Descending},{id:"removedSize",title:lt(nt.freedSize),width:"75px",sortable:!0,fixedWidth:!0},{id:"sizeDelta",title:lt(nt.sizeDelta),width:"75px",sortable:!0,fixedWidth:!0}];super(e,t,{displayName:lt(nt.heapSnapshotDiff).toString(),columns:i})}defaultPopulateCount(){return 50}sortFields(e,t){switch(e){case"object":return new p.HeapSnapshotModel.ComparatorConfig("name",t,"count",!1);case"addedCount":return new p.HeapSnapshotModel.ComparatorConfig("addedCount",t,"name",!0);case"removedCount":return new p.HeapSnapshotModel.ComparatorConfig("removedCount",t,"name",!0);case"countDelta":return new p.HeapSnapshotModel.ComparatorConfig("countDelta",t,"name",!0);case"addedSize":return new p.HeapSnapshotModel.ComparatorConfig("addedSize",t,"name",!0);case"removedSize":return new p.HeapSnapshotModel.ComparatorConfig("removedSize",t,"name",!0);case"sizeDelta":return new p.HeapSnapshotModel.ComparatorConfig("sizeDelta",t,"name",!0);default:throw new Error(`Unknown column ${e}`)}}async setDataSource(e,t){this.snapshot=e}setBaseDataSource(e){this.baseSnapshot=e,this.removeTopLevelNodes(),this.resetSortingCache(),this.baseSnapshot!==this.snapshot?this.populateChildren():this.dispatchEventToListeners(pt.SortingComplete)}async populateChildren(){if(null===this.snapshot||void 0===this.baseSnapshot||void 0===this.baseSnapshot.uid)throw new Error("Data sources have not been set correctly");const e=await this.baseSnapshot.aggregatesForDiff(),t=await this.snapshot.calculateSnapshotDiff(this.baseSnapshot.uid,e);for(const e in t){const i=t[e];this.appendNode(this.rootNode(),new rt(this,e,i))}this.sortingChanged()}}class St extends mt{linkifierInternal;topNodes;constructor(e,t){const i=[{id:"liveCount",title:lt(nt.liveCount),width:"75px",sortable:!0,fixedWidth:!0},{id:"count",title:lt(nt.count),width:"65px",sortable:!0,fixedWidth:!0},{id:"liveSize",title:lt(nt.liveSize),width:"75px",sortable:!0,fixedWidth:!0},{id:"size",title:lt(nt.size),width:"75px",sortable:!0,fixedWidth:!0,sort:r.DataGrid.Order.Descending},{id:"name",title:lt(nt.function),disclosure:!0,sortable:!0}];super(e,t,{displayName:lt(nt.allocation).toString(),columns:i}),this.linkifierInternal=new d.Linkifier.Linkifier}get linkifier(){return this.linkifierInternal}dispose(){this.linkifierInternal.reset()}async setDataSource(e,t){this.snapshot=e,this.topNodes=await this.snapshot.allocationTracesTops(),this.populateChildren()}populateChildren(){this.removeTopLevelNodes();const e=this.rootNode(),t=this.topNodes||[];for(const i of t)this.appendNode(e,new st(this,i));this.updateVisibleNodes(!0)}sortingChanged(){void 0!==this.topNodes&&(this.topNodes.sort(this.createComparator()),this.rootNode().removeChildren(),this.populateChildren())}createComparator(){const e=this.sortColumnId(),t=this.sortOrder()===r.DataGrid.Order.Ascending?1:-1;return function(i,r){return i[e]>r[e]?t:i[e]<r[e]?-t:0}}}var bt=Object.freeze({__proto__:null,HeapSnapshotSortableDataGrid:ct,get HeapSnapshotSortableDataGridEvents(){return pt},HeapSnapshotViewportDataGrid:mt,HeapSnapshotContainmentDataGrid:ft,HeapSnapshotRetainmentDataGrid:gt,get HeapSnapshotRetainmentDataGridEvents(){return ut},HeapSnapshotConstructorsDataGrid:vt,HeapSnapshotDiffDataGrid:wt,AllocationDataGrid:St});const Ct={anErrorOccurredWhenACallToMethod:"An error occurred when a call to method ''{PH1}'' was requested"},Pt=t.i18n.registerUIStrings("panels/profiler/HeapSnapshotProxy.ts",Ct),Tt=t.i18n.getLocalizedString.bind(void 0,Pt);class xt extends o.ObjectWrapper.ObjectWrapper{eventHandler;nextObjectId;nextCallId;callbacks;previousCallbacks;worker;interval;constructor(e){super(),this.eventHandler=e,this.nextObjectId=1,this.nextCallId=1,this.callbacks=new Map,this.previousCallbacks=new Set,this.worker=o.Worker.WorkerWrapper.fromURL(new URL("../../entrypoints/heap_snapshot_worker/heap_snapshot_worker-legacy.js",import.meta.url)),this.worker.onmessage=this.messageReceived.bind(this)}createLoader(e,t){const i=this.nextObjectId++,r=new It(this,i,e,t);return this.postMessage({callId:this.nextCallId++,disposition:"create",objectId:i,methodName:"HeapSnapshotWorker.HeapSnapshotLoader"}),r}dispose(){this.worker.terminate(),this.interval&&clearInterval(this.interval)}disposeObject(e){this.postMessage({callId:this.nextCallId++,disposition:"dispose",objectId:e})}evaluateForTest(e,t){const i=this.nextCallId++;this.callbacks.set(i,t),this.postMessage({callId:i,disposition:"evaluateForTest",source:e})}callFactoryMethod(e,t,i,r){const s=this.nextCallId++,o=Array.prototype.slice.call(arguments,4),n=this.nextObjectId++;return e?(this.callbacks.set(s,(t=>{e(t?new r(this,n):null)})),this.postMessage({callId:s,disposition:"factory",objectId:t,methodName:i,methodArguments:o,newObjectId:n}),null):(this.postMessage({callId:s,disposition:"factory",objectId:t,methodName:i,methodArguments:o,newObjectId:n}),new r(this,n))}callMethod(e,t,i){const r=this.nextCallId++,s=Array.prototype.slice.call(arguments,3);e&&this.callbacks.set(r,e),this.postMessage({callId:r,disposition:"method",objectId:t,methodName:i,methodArguments:s})}startCheckingForLongRunningCalls(){this.interval||(this.checkLongRunningCalls(),this.interval=window.setInterval(this.checkLongRunningCalls.bind(this),300))}checkLongRunningCalls(){for(const e of this.previousCallbacks)this.callbacks.has(e)||this.previousCallbacks.delete(e);const e=Boolean(this.previousCallbacks.size);this.dispatchEventToListeners("Wait",e);for(const e of this.callbacks.keys())this.previousCallbacks.add(e)}messageReceived(e){const t=e.data;if(t.eventName)return void(this.eventHandler&&this.eventHandler(t.eventName,t.data));if(t.error)return t.errorMethodName&&o.Console.Console.instance().error(Tt(Ct.anErrorOccurredWhenACallToMethod,{PH1:t.errorMethodName})),o.Console.Console.instance().error(t.errorCallStack),void this.callbacks.delete(t.callId);const i=this.callbacks.get(t.callId);i&&(this.callbacks.delete(t.callId),i(t.result))}postMessage(e){this.worker.postMessage(e)}}class yt{worker;objectId;constructor(e,t){this.worker=e,this.objectId=t}callWorker(e,t){t.splice(1,0,this.objectId);const i=this.worker[e];if(!i)throw new Error(`Could not find worker with name ${e}.`);return i.apply(this.worker,t)}dispose(){this.worker.disposeObject(this.objectId)}disposeWorker(){this.worker.dispose()}callFactoryMethod(e,t,i,...r){return this.callWorker("callFactoryMethod",Array.prototype.slice.call(arguments,0))}callMethodPromise(e,...t){const i=Array.prototype.slice.call(arguments);return new Promise((e=>this.callWorker("callMethod",[e,...i])))}}class It extends yt{profileUid;snapshotReceivedCallback;constructor(e,t,i,r){super(e,t),this.profileUid=i,this.snapshotReceivedCallback=r}async write(e){await this.callMethodPromise("write",e)}async close(){await this.callMethodPromise("close");const e=await new Promise((e=>this.callFactoryMethod(e,"buildSnapshot",Rt)));this.dispose(),e.setProfileUid(this.profileUid),await e.updateStaticData(),this.snapshotReceivedCallback(e)}}class Rt extends yt{staticData;profileUid;constructor(e,t){super(e,t),this.staticData=null}search(e,t){return this.callMethodPromise("search",e,t)}aggregatesWithFilter(e){return this.callMethodPromise("aggregatesWithFilter",e)}aggregatesForDiff(){return this.callMethodPromise("aggregatesForDiff")}calculateSnapshotDiff(e,t){return this.callMethodPromise("calculateSnapshotDiff",e,t)}nodeClassName(e){return this.callMethodPromise("nodeClassName",e)}createEdgesProvider(e){return this.callFactoryMethod(null,"createEdgesProvider",Et,e)}createRetainingEdgesProvider(e){return this.callFactoryMethod(null,"createRetainingEdgesProvider",Et,e)}createAddedNodesProvider(e,t){return this.callFactoryMethod(null,"createAddedNodesProvider",Et,e,t)}createDeletedNodesProvider(e){return this.callFactoryMethod(null,"createDeletedNodesProvider",Et,e)}createNodesProvider(e){return this.callFactoryMethod(null,"createNodesProvider",Et,e)}createNodesProviderForClass(e,t){return this.callFactoryMethod(null,"createNodesProviderForClass",Et,e,t)}allocationTracesTops(){return this.callMethodPromise("allocationTracesTops")}allocationNodeCallers(e){return this.callMethodPromise("allocationNodeCallers",e)}allocationStack(e){return this.callMethodPromise("allocationStack",e)}dispose(){throw new Error("Should never be called")}get nodeCount(){return this.staticData?this.staticData.nodeCount:0}get rootNodeIndex(){return this.staticData?this.staticData.rootNodeIndex:0}async updateStaticData(){this.staticData=await this.callMethodPromise("updateStaticData")}getStatistics(){return this.callMethodPromise("getStatistics")}getLocation(e){return this.callMethodPromise("getLocation",e)}getSamples(){return this.callMethodPromise("getSamples")}get totalSize(){return this.staticData?this.staticData.totalSize:0}get uid(){return this.profileUid}setProfileUid(e){this.profileUid=e}maxJSObjectId(){return this.staticData?this.staticData.maxJSObjectId:0}}class Et extends yt{constructor(e,t){super(e,t)}nodePosition(e){return this.callMethodPromise("nodePosition",e)}isEmpty(){return this.callMethodPromise("isEmpty")}serializeItemsRange(e,t){return this.callMethodPromise("serializeItemsRange",e,t)}async sortAndRewind(e){await this.callMethodPromise("sortAndRewind",e)}}var Nt=Object.freeze({__proto__:null,HeapSnapshotWorkerProxy:xt,HeapSnapshotProxyObject:yt,HeapSnapshotLoaderProxy:It,HeapSnapshotProxy:Rt,HeapSnapshotProviderProxy:Et});const kt={find:"Find",containment:"Containment",retainers:"Retainers",allocationStack:"Allocation stack",perspective:"Perspective",baseSnapshot:"Base snapshot",filter:"Filter",classFilter:"Class filter",code:"Code",strings:"Strings",jsArrays:"JS arrays",typedArrays:"Typed arrays",systemObjects:"System objects",selectedSizeS:"Selected size: {PH1}",allObjects:"All objects",objectsAllocatedBeforeS:"Objects allocated before {PH1}",objectsAllocatedBetweenSAndS:"Objects allocated between {PH1} and {PH2}",summary:"Summary",comparison:"Comparison",allocation:"Allocation",liveObjects:"Live objects",statistics:"Statistics",heapSnapshot:"Heap snapshot",takeHeapSnapshot:"Take heap snapshot",heapSnapshots:"HEAP SNAPSHOTS",heapSnapshotProfilesShowMemory:"Heap snapshot profiles show memory distribution among your page's JavaScript objects and related DOM nodes.",exposeInternals:"Expose internals (includes additional implementation-specific details)",captureNumericValue:"Include numerical values in capture",snapshotting:"Snapshotting…",snapshotD:"Snapshot {PH1}",percentagePlaceholder:"{PH1}%",allocationInstrumentationOn:"Allocation instrumentation on timeline",stopRecordingHeapProfile:"Stop recording heap profile",startRecordingHeapProfile:"Start recording heap profile",recordAllocationStacksExtra:"Record stack traces of allocations (extra performance overhead)",recording:"Recording…",allocationTimelines:"ALLOCATION TIMELINES",AllocationTimelinesShowInstrumented:"Allocation timelines show instrumented JavaScript memory allocations over time. Once profile is recorded you can select a time interval to see objects that were allocated within it and still alive by the end of recording. Use this profile type to isolate memory leaks.",loading:"Loading…",savingD:"Saving… {PH1}%",sKb:"{PH1} kB",heapMemoryUsage:"Heap memory usage",stackWasNotRecordedForThisObject:"Stack was not recorded for this object because it had been allocated before this profile recording started."},Dt=t.i18n.registerUIStrings("panels/profiler/HeapSnapshotView.ts",kt),Mt=t.i18n.getLocalizedString.bind(void 0,Dt),Ft=t.i18n.registerUIStrings("panels/profiler/ModuleUIStrings.ts",{buildingEdgeIndexes:"Building edge indexes…",buildingRetainers:"Building retainers…",propagatingDomState:"Propagating DOM state…",calculatingNodeFlags:"Calculating node flags…",calculatingDistances:"Calculating distances…",buildingPostorderIndex:"Building postorder index…",buildingDominatorTree:"Building dominator tree…",calculatingRetainedSizes:"Calculating retained sizes…",buildingDominatedNodes:"Building dominated nodes…",calculatingStatistics:"Calculating statistics…",calculatingSamples:"Calculating samples…",buildingLocations:"Building locations…",finishedProcessing:"Finished processing.",buildingAllocationStatistics:"Building allocation statistics…",done:"Done",processingSnapshot:"Processing snapshot…",parsingStrings:"Parsing strings…",loadingSnapshotInfo:"Loading snapshot info…",loadingNodesD:"Loading nodes… {PH1}%",loadingEdgesD:"Loading edges… {PH1}%",loadingAllocationTracesD:"Loading allocation traces… {PH1}%",loadingSamples:"Loading samples…",loadingLocations:"Loading locations…",loadingStrings:"Loading strings…"}),Ht=t.i18n.getLocalizedString.bind(void 0,Ft);class Lt extends s.View.SimpleView{searchResults;profile;linkifier;parentDataDisplayDelegate;searchableViewInternal;splitWidget;containmentDataGrid;containmentWidget;statisticsView;constructorsDataGrid;constructorsWidget;diffDataGrid;diffWidget;allocationDataGrid;allocationWidget;allocationStackView;tabbedPane;retainmentDataGrid;retainmentWidget;objectDetailsView;perspectives;comparisonPerspective;perspectiveSelect;baseSelect;filterSelect;classNameFilter;selectedSizeText;popoverHelper;currentPerspectiveIndex;currentPerspective;dataGrid;searchThrottler;baseProfile;trackingOverviewGrid;currentSearchResultIndex=-1;currentQuery;constructor(e,t){super(Mt(kt.heapSnapshot)),this.searchResults=[],this.element.classList.add("heap-snapshot-view"),this.profile=t,this.linkifier=new d.Linkifier.Linkifier;const i=t.profileType();i.addEventListener("SnapshotReceived",this.onReceiveSnapshot,this),i.addEventListener(D.RemoveProfileHeader,this.onProfileHeaderRemoved,this);const n=i.id===At.TypeId;n&&this.createOverview();const a=Kt.trackingHeapSnapshotProfileType.recordAllocationStacksSetting().get();this.parentDataDisplayDelegate=e,this.searchableViewInternal=new s.SearchableView.SearchableView(this,null),this.searchableViewInternal.setPlaceholder(Mt(kt.find),Mt(kt.find)),this.searchableViewInternal.show(this.element),this.splitWidget=new s.SplitWidget.SplitWidget(!1,!0,"heapSnapshotSplitViewState",200,200),this.splitWidget.show(this.searchableViewInternal.element);const l=t.heapProfilerModel();let h;if(this.containmentDataGrid=new ft(l,this,Mt(kt.containment)),this.containmentDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.selectionChanged,this),this.containmentWidget=this.containmentDataGrid.asWidget(),this.containmentWidget.setMinimumSize(50,25),this.statisticsView=new _t,this.constructorsDataGrid=new vt(l,this),this.constructorsDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.selectionChanged,this),this.constructorsWidget=this.constructorsDataGrid.asWidget(),this.constructorsWidget.setMinimumSize(50,25),this.diffDataGrid=new wt(l,this),this.diffDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.selectionChanged,this),this.diffWidget=this.diffDataGrid.asWidget(),this.diffWidget.setMinimumSize(50,25),this.allocationDataGrid=null,n&&a&&(this.allocationDataGrid=new St(l,this),this.allocationDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.onSelectAllocationNode,this),this.allocationWidget=this.allocationDataGrid.asWidget(),this.allocationWidget.setMinimumSize(50,25),this.allocationStackView=new Jt(l),this.allocationStackView.setMinimumSize(50,25),this.tabbedPane=new s.TabbedPane.TabbedPane),this.retainmentDataGrid=new gt(l,this),this.retainmentWidget=this.retainmentDataGrid.asWidget(),this.retainmentWidget.setMinimumSize(50,21),this.retainmentWidget.element.classList.add("retaining-paths-view"),this.allocationStackView)this.tabbedPane=new s.TabbedPane.TabbedPane,this.tabbedPane.appendTab("retainers",Mt(kt.retainers),this.retainmentWidget),this.tabbedPane.appendTab("allocation-stack",Mt(kt.allocationStack),this.allocationStackView),h=this.tabbedPane.headerElement(),this.objectDetailsView=this.tabbedPane;else{const e=document.createElement("div");e.classList.add("heap-snapshot-view-resizer");const t=e.createChild("div","title");e.createChild("div","verticalResizerIcon");t.createChild("span").textContent=Mt(kt.retainers),h=e,this.objectDetailsView=new s.Widget.VBox,this.objectDetailsView.element.appendChild(e),this.retainmentWidget.show(this.objectDetailsView.element)}this.splitWidget.hideDefaultResizer(),this.splitWidget.installResizer(h),this.retainmentDataGrid.addEventListener(r.DataGrid.Events.SelectedNode,this.inspectedObjectChanged,this),this.retainmentDataGrid.reset(),this.perspectives=[],this.comparisonPerspective=new zt,this.perspectives.push(new Ot),t.profileType()!==Kt.trackingHeapSnapshotProfileType&&this.perspectives.push(this.comparisonPerspective),this.perspectives.push(new Bt),this.allocationWidget&&this.perspectives.push(new Gt),this.perspectives.push(new Vt),this.perspectiveSelect=new s.Toolbar.ToolbarComboBox(this.onSelectedPerspectiveChanged.bind(this),Mt(kt.perspective)),this.updatePerspectiveOptions(),this.baseSelect=new s.Toolbar.ToolbarComboBox(this.changeBase.bind(this),Mt(kt.baseSnapshot)),this.baseSelect.setVisible(!1),this.updateBaseOptions(),this.filterSelect=new s.Toolbar.ToolbarComboBox(this.changeFilter.bind(this),Mt(kt.filter)),this.filterSelect.setVisible(!1),this.updateFilterOptions(),this.classNameFilter=new s.Toolbar.ToolbarInput(Mt(kt.classFilter)),this.classNameFilter.setVisible(!1),this.constructorsDataGrid.setNameFilter(this.classNameFilter),this.diffDataGrid.setNameFilter(this.classNameFilter),this.selectedSizeText=new s.Toolbar.ToolbarText,this.popoverHelper=new s.PopoverHelper.PopoverHelper(this.element,this.getPopoverRequest.bind(this)),this.popoverHelper.setDisableOnClick(!0),this.popoverHelper.setHasPadding(!0),this.element.addEventListener("scroll",this.popoverHelper.hidePopover.bind(this.popoverHelper),!0),this.currentPerspectiveIndex=0,this.currentPerspective=this.perspectives[0],this.currentPerspective.activate(this),this.dataGrid=this.currentPerspective.masterGrid(this),this.populate(),this.searchThrottler=new o.Throttler.Throttler(0);for(const e of this.profiles())e.addEventListener(k.ProfileTitleChanged,this.updateControls,this)}createOverview(){const e=this.profile.profileType();this.trackingOverviewGrid=new Re,this.trackingOverviewGrid.addEventListener("IdsRangeChanged",this.onIdsRangeChanged.bind(this)),this.profile.fromFile()||e.profileBeingRecorded()!==this.profile||(e.addEventListener("HeapStatsUpdate",this.onHeapStatsUpdate,this),e.addEventListener("TrackingStopped",this.onStopTracking,this),this.trackingOverviewGrid.start())}onStopTracking(){const e=this.profile.profileType();e.removeEventListener("HeapStatsUpdate",this.onHeapStatsUpdate,this),e.removeEventListener("TrackingStopped",this.onStopTracking,this),this.trackingOverviewGrid&&this.trackingOverviewGrid.stop()}onHeapStatsUpdate({data:e}){this.trackingOverviewGrid&&this.trackingOverviewGrid.setSamples(e)}searchableView(){return this.searchableViewInternal}showProfile(e){return this.parentDataDisplayDelegate.showProfile(e)}showObject(e,t){Number(e)<=this.profile.maxJSObjectId?this.selectLiveObject(t,e):this.parentDataDisplayDelegate.showObject(e,t)}async linkifyObject(e){const t=this.profile.heapProfilerModel();if(!t)return null;const i=await this.profile.getLocation(e);if(!i)return null;const r=t.runtimeModel().debuggerModel().createRawLocationByScriptId(String(i.scriptId),i.lineNumber,i.columnNumber);if(!r)return null;const s=r.script(),o=s&&s.sourceURL;return o&&this.linkifier?this.linkifier.linkifyRawLocation(r,o):null}async populate(){const e=await this.profile.loadPromise;if(this.retrieveStatistics(e),this.dataGrid&&this.dataGrid.setDataSource(e,0),this.profile.profileType().id===At.TypeId&&this.profile.fromFile()){const t=await e.getSamples();if(t){console.assert(Boolean(t.timestamps.length));const e=new Ne;e.sizes=t.sizes,e.ids=t.lastAssignedIds,e.timestamps=t.timestamps,e.max=t.sizes,e.totalTime=Math.max(t.timestamps[t.timestamps.length-1]||0,1e4),this.trackingOverviewGrid&&this.trackingOverviewGrid.setSamples(e)}}const t=this.profiles().indexOf(this.profile);this.baseSelect.setSelectedIndex(Math.max(0,t-1)),this.trackingOverviewGrid&&this.trackingOverviewGrid.updateGrid()}async retrieveStatistics(e){const t=await e.getStatistics(),i=[{value:t.code,color:"#f77",title:Mt(kt.code)},{value:t.strings,color:"#5e5",title:Mt(kt.strings)},{value:t.jsArrays,color:"#7af",title:Mt(kt.jsArrays)},{value:t.native,color:"#fc5",title:Mt(kt.typedArrays)},{value:t.system,color:"#98f",title:Mt(kt.systemObjects)}];return this.statisticsView.setTotalAndRecords(t.total,i),t}onIdsRangeChanged(t){const{minId:i,maxId:r}=t.data;this.selectedSizeText.setText(Mt(kt.selectedSizeS,{PH1:e.NumberUtilities.bytesToString(t.data.size)})),this.constructorsDataGrid.snapshot&&this.constructorsDataGrid.setSelectionRange(i,r)}async toolbarItems(){const e=[this.perspectiveSelect,this.classNameFilter];return this.profile.profileType()!==Kt.trackingHeapSnapshotProfileType&&e.push(this.baseSelect,this.filterSelect),e.push(this.selectedSizeText),e}willHide(){this.currentSearchResultIndex=-1,this.popoverHelper.hidePopover()}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!1}onSearchCanceled(){this.currentSearchResultIndex=-1,this.searchResults=[]}selectRevealedNode(e){e&&e.select()}performSearch(e,t,i){const r=new p.HeapSnapshotModel.SearchConfig(e.query.trim(),e.caseSensitive,e.isRegex,t,i||!1);this.searchThrottler.schedule(this.performSearchInternal.bind(this,r))}async performSearchInternal(e){if(this.onSearchCanceled(),!this.currentPerspective.supportsSearch())return;this.currentQuery=e;const t=e.query.trim();if(!t)return;if("@"===t.charAt(0)){const e=parseInt(t.substring(1),10);if(isNaN(e))return;if(!this.dataGrid)return;const i=await this.dataGrid.revealObjectByHeapSnapshotId(String(e));return void this.selectRevealedNode(i)}if(!this.profile.snapshotProxy||!this.dataGrid)return;const i=this.dataGrid.nodeFilter();this.searchResults=i?await this.profile.snapshotProxy.search(this.currentQuery,i):[],this.searchableViewInternal.updateSearchMatchesCount(this.searchResults.length),this.searchResults.length&&(this.currentSearchResultIndex=e.jumpBackward?this.searchResults.length-1:0),await this.jumpToSearchResult(this.currentSearchResultIndex)}jumpToNextSearchResult(){this.searchResults.length&&(this.currentSearchResultIndex=(this.currentSearchResultIndex+1)%this.searchResults.length,this.searchThrottler.schedule(this.jumpToSearchResult.bind(this,this.currentSearchResultIndex)))}jumpToPreviousSearchResult(){this.searchResults.length&&(this.currentSearchResultIndex=(this.currentSearchResultIndex+this.searchResults.length-1)%this.searchResults.length,this.searchThrottler.schedule(this.jumpToSearchResult.bind(this,this.currentSearchResultIndex)))}async jumpToSearchResult(e){if(this.searchableViewInternal.updateCurrentMatchIndex(e),-1===e)return;if(!this.dataGrid)return;const t=await this.dataGrid.revealObjectByHeapSnapshotId(String(this.searchResults[e]));this.selectRevealedNode(t)}refreshVisibleData(){if(!this.dataGrid)return;let e=this.dataGrid.rootNode().children[0];for(;e;)e.refresh(),e=e.traverseNextNode(!1,null,!0)}changeBase(){if(this.baseProfile===this.profiles()[this.baseSelect.selectedIndex()])return;this.baseProfile=this.profiles()[this.baseSelect.selectedIndex()];const e=this.dataGrid;e.snapshot&&this.baseProfile.loadPromise.then(e.setBaseDataSource.bind(e)),this.currentQuery&&this.searchResults&&this.performSearch(this.currentQuery,!1)}changeFilter(){const e=this.filterSelect.selectedIndex()-1;this.dataGrid&&(this.dataGrid.filterSelectIndexChanged(this.profiles(),e),this.currentQuery&&this.searchResults&&this.performSearch(this.currentQuery,!1))}profiles(){return this.profile.profileType().getProfiles()}selectionChanged(e){const t=e.data;this.setSelectedNodeForDetailsView(t),this.inspectedObjectChanged(e)}onSelectAllocationNode(e){const t=e.data;this.constructorsDataGrid.setAllocationNodeId(t.allocationNodeId()),this.setSelectedNodeForDetailsView(null)}inspectedObjectChanged(e){const t=e.data,i=this.profile.heapProfilerModel();i&&t instanceof Ye&&i.addInspectedHeapObject(String(t.snapshotNodeId))}setSelectedNodeForDetailsView(e){const t=e&&e.retainersDataSource();t?(this.retainmentDataGrid.setDataSource(t.snapshot,t.snapshotNodeIndex),this.allocationStackView&&this.allocationStackView.setAllocatedObject(t.snapshot,t.snapshotNodeIndex)):(this.allocationStackView&&this.allocationStackView.clear(),this.retainmentDataGrid.reset())}async changePerspectiveAndWait(e){const t=this.perspectives.findIndex((t=>t.title()===e));if(-1===t||this.currentPerspectiveIndex===t)return;const i=this.perspectives[t].masterGrid(this);if(!i)return;const r=i.once(pt.ContentShown),s=this.perspectiveSelect.options().find((e=>e.value===String(t)));this.perspectiveSelect.select(s),this.changePerspective(t),await r}async updateDataSourceAndView(){const e=this.dataGrid;if(!e||e.snapshot)return;const t=await this.profile.loadPromise;if(this.dataGrid!==e)return;if(e.snapshot!==t&&e.setDataSource(t,0),e!==this.diffDataGrid)return;this.baseProfile||(this.baseProfile=this.profiles()[this.baseSelect.selectedIndex()]);const i=await this.baseProfile.loadPromise;this.diffDataGrid.baseSnapshot!==i&&this.diffDataGrid.setBaseDataSource(i)}onSelectedPerspectiveChanged(e){this.changePerspective(Number(e.target.selectedOptions[0].value))}changePerspective(e){if(e===this.currentPerspectiveIndex)return;this.currentPerspectiveIndex=e,this.currentPerspective.deactivate(this);const t=this.perspectives[e];this.currentPerspective=t,this.dataGrid=t.masterGrid(this),t.activate(this),this.refreshVisibleData(),this.dataGrid&&this.dataGrid.updateWidths(),this.updateDataSourceAndView(),this.currentQuery&&this.searchResults&&this.performSearch(this.currentQuery,!1)}async selectLiveObject(e,t){if(await this.changePerspectiveAndWait(e),!this.dataGrid)return;const i=await this.dataGrid.revealObjectByHeapSnapshotId(t);i?i.select():o.Console.Console.instance().error("Cannot find corresponding heap snapshot node")}getPopoverRequest(e){const t=s.UIUtils.enclosingNodeOrSelfWithNodeName(e.target,"span"),i=s.UIUtils.enclosingNodeOrSelfWithNodeName(e.target,"tr");if(!i)return null;if(!this.dataGrid)return null;const r=this.dataGrid.dataGridNodeFromNode(i)||this.containmentDataGrid.dataGridNodeFromNode(i)||this.constructorsDataGrid.dataGridNodeFromNode(i)||this.diffDataGrid.dataGridNodeFromNode(i)||this.allocationDataGrid&&this.allocationDataGrid.dataGridNodeFromNode(i)||this.retainmentDataGrid.dataGridNodeFromNode(i),o=this.profile.heapProfilerModel();if(!r||!t||!o)return null;let n;return{box:t.boxInWindow(),show:async e=>{if(!o)return!1;const t=await r.queryObjectContent(o,"popover");return!!t&&(n=await u.ObjectPopoverHelper.ObjectPopoverHelper.buildObjectPopover(t,e),!!n||(o.runtimeModel().releaseObjectGroup("popover"),!1))},hide:()=>{o.runtimeModel().releaseObjectGroup("popover"),n&&n.dispose()}}}updatePerspectiveOptions(){const e=this.profiles().length>1;this.perspectiveSelect.removeOptions(),this.perspectives.forEach(((t,i)=>{(e||t!==this.comparisonPerspective)&&this.perspectiveSelect.createOption(t.title(),String(i))}))}updateBaseOptions(){const e=this.profiles(),t=this.baseSelect.selectedIndex();this.baseSelect.removeOptions();for(const t of e)this.baseSelect.createOption(t.title);t>-1&&this.baseSelect.setSelectedIndex(t)}updateFilterOptions(){const e=this.profiles(),t=this.filterSelect.selectedIndex();this.filterSelect.removeOptions(),this.filterSelect.createOption(Mt(kt.allObjects));for(let t=0;t<e.length;++t){let i;i=t?Mt(kt.objectsAllocatedBetweenSAndS,{PH1:e[t-1].title,PH2:e[t].title}):Mt(kt.objectsAllocatedBeforeS,{PH1:e[t].title}),this.filterSelect.createOption(i)}t>-1&&this.filterSelect.setSelectedIndex(t)}updateControls(){this.updatePerspectiveOptions(),this.updateBaseOptions(),this.updateFilterOptions()}onReceiveSnapshot(e){this.updateControls();e.data.addEventListener(k.ProfileTitleChanged,this.updateControls,this)}onProfileHeaderRemoved(e){const t=e.data;t.removeEventListener(k.ProfileTitleChanged,this.updateControls,this),this.profile===t?(this.detach(),this.profile.profileType().removeEventListener("SnapshotReceived",this.onReceiveSnapshot,this),this.profile.profileType().removeEventListener(D.RemoveProfileHeader,this.onProfileHeaderRemoved,this),this.dispose()):this.updateControls()}dispose(){this.linkifier.dispose(),this.popoverHelper.dispose(),this.allocationStackView&&(this.allocationStackView.clear(),this.allocationDataGrid&&this.allocationDataGrid.dispose()),this.onStopTracking(),this.trackingOverviewGrid&&this.trackingOverviewGrid.removeEventListener("IdsRangeChanged",this.onIdsRangeChanged.bind(this))}}class jt{titleInternal;constructor(e){this.titleInternal=e}activate(e){}deactivate(e){e.baseSelect.setVisible(!1),e.filterSelect.setVisible(!1),e.classNameFilter.setVisible(!1),e.trackingOverviewGrid&&e.trackingOverviewGrid.detach(),e.allocationWidget&&e.allocationWidget.detach(),e.statisticsView&&e.statisticsView.detach(),e.splitWidget.detach(),e.splitWidget.detachChildWidgets()}masterGrid(e){return null}title(){return this.titleInternal}supportsSearch(){return!1}}class Ot extends jt{constructor(){super(Mt(kt.summary))}activate(e){e.splitWidget.setMainWidget(e.constructorsWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView),e.splitWidget.show(e.searchableViewInternal.element),e.filterSelect.setVisible(!0),e.classNameFilter.setVisible(!0),e.trackingOverviewGrid&&(e.trackingOverviewGrid.show(e.searchableViewInternal.element,e.splitWidget.element),e.trackingOverviewGrid.update(),e.trackingOverviewGrid.updateGrid())}masterGrid(e){return e.constructorsDataGrid}supportsSearch(){return!0}}class zt extends jt{constructor(){super(Mt(kt.comparison))}activate(e){e.splitWidget.setMainWidget(e.diffWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView),e.splitWidget.show(e.searchableViewInternal.element),e.baseSelect.setVisible(!0),e.classNameFilter.setVisible(!0)}masterGrid(e){return e.diffDataGrid}supportsSearch(){return!0}}class Bt extends jt{constructor(){super(Mt(kt.containment))}activate(e){e.splitWidget.setMainWidget(e.containmentWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView),e.splitWidget.show(e.searchableViewInternal.element)}masterGrid(e){return e.containmentDataGrid}}class Gt extends jt{allocationSplitWidget;constructor(){super(Mt(kt.allocation)),this.allocationSplitWidget=new s.SplitWidget.SplitWidget(!1,!0,"heapSnapshotAllocationSplitViewState",200,200),this.allocationSplitWidget.setSidebarWidget(new s.Widget.VBox)}activate(e){e.allocationWidget&&this.allocationSplitWidget.setMainWidget(e.allocationWidget),e.splitWidget.setMainWidget(e.constructorsWidget),e.splitWidget.setSidebarWidget(e.objectDetailsView);const t=new s.Widget.VBox,i=document.createElement("div");i.classList.add("heap-snapshot-view-resizer");const r=i.createChild("div","title").createChild("span");if(i.createChild("div","verticalResizerIcon"),r.textContent=Mt(kt.liveObjects),this.allocationSplitWidget.hideDefaultResizer(),this.allocationSplitWidget.installResizer(i),t.element.appendChild(i),e.splitWidget.show(t.element),this.allocationSplitWidget.setSidebarWidget(t),this.allocationSplitWidget.show(e.searchableViewInternal.element),e.constructorsDataGrid.clear(),e.allocationDataGrid){const t=e.allocationDataGrid.selectedNode;t&&e.constructorsDataGrid.setAllocationNodeId(t.allocationNodeId())}}deactivate(e){this.allocationSplitWidget.detach(),super.deactivate(e)}masterGrid(e){return e.allocationDataGrid}}class Vt extends jt{constructor(){super(Mt(kt.statistics))}activate(e){e.statisticsView.show(e.searchableViewInternal.element)}masterGrid(e){return null}}class Ut extends(o.ObjectWrapper.eventMixin(L)){exposeInternals;captureNumericValue;customContentInternal;constructor(e,t){super(e||Ut.TypeId,t||Mt(kt.heapSnapshot)),l.TargetManager.TargetManager.instance().observeModels(l.HeapProfilerModel.HeapProfilerModel,this),l.TargetManager.TargetManager.instance().addModelListener(l.HeapProfilerModel.HeapProfilerModel,l.HeapProfilerModel.Events.ResetProfiles,this.resetProfiles,this),l.TargetManager.TargetManager.instance().addModelListener(l.HeapProfilerModel.HeapProfilerModel,l.HeapProfilerModel.Events.AddHeapSnapshotChunk,this.addHeapSnapshotChunk,this),l.TargetManager.TargetManager.instance().addModelListener(l.HeapProfilerModel.HeapProfilerModel,l.HeapProfilerModel.Events.ReportHeapSnapshotProgress,this.reportHeapSnapshotProgress,this),this.exposeInternals=o.Settings.Settings.instance().createSetting("exposeInternals",!1),this.captureNumericValue=o.Settings.Settings.instance().createSetting("captureNumericValue",!1),this.customContentInternal=null}modelAdded(e){e.enable()}modelRemoved(e){}getProfiles(){return super.getProfiles()}fileExtension(){return".heapsnapshot"}get buttonTooltip(){return Mt(kt.takeHeapSnapshot)}isInstantProfile(){return!0}buttonClicked(){return this.takeHeapSnapshot(),a.userMetrics.actionTaken(a.UserMetrics.Action.ProfilesHeapProfileTaken),!1}get treeItemTitle(){return Mt(kt.heapSnapshots)}get description(){return Mt(kt.heapSnapshotProfilesShowMemory)}customContent(){const e=document.createElement("div"),t=c.Runtime.experiments.isEnabled("showOptionToExposeInternalsInHeapSnapshot"),i=!t;if(t){const t=s.SettingsUI.createSettingCheckbox(Mt(kt.exposeInternals),this.exposeInternals,i);e.appendChild(t)}const r=s.SettingsUI.createSettingCheckbox(Mt(kt.captureNumericValue),this.captureNumericValue,i);return e.appendChild(r),this.customContentInternal=e,e}setCustomContentEnabled(e){this.customContentInternal&&this.customContentInternal.querySelectorAll("[is=dt-checkbox]").forEach((t=>{t.checkboxElement.disabled=!e}))}createProfileLoadedFromFile(e){return new Wt(null,this,e)}async takeHeapSnapshot(){if(this.profileBeingRecorded())return;const e=s.Context.Context.instance().flavor(l.HeapProfilerModel.HeapProfilerModel);if(!e)return;let t=new Wt(e,this);this.setProfileBeingRecorded(t),this.addProfile(t),t.updateStatus(Mt(kt.snapshotting)),await e.takeHeapSnapshot({reportProgress:!0,captureNumericValue:this.captureNumericValue.get(),exposeInternals:this.exposeInternals.get()}),t=this.profileBeingRecorded(),t&&(t.title=Mt(kt.snapshotD,{PH1:t.uid}),t.finishLoad(),this.setProfileBeingRecorded(null),this.dispatchEventToListeners(D.ProfileComplete,t))}addHeapSnapshotChunk(e){const t=this.profileBeingRecorded();t&&t.transferChunk(e.data)}reportHeapSnapshotProgress(e){const t=this.profileBeingRecorded();if(!t)return;const{done:i,total:r,finished:s}=e.data;t.updateStatus(Mt(kt.percentagePlaceholder,{PH1:(i/r*100).toFixed(0)}),!0),s&&t.prepareToLoad()}resetProfiles(e){const t=e.data;for(const e of this.getProfiles())e.heapProfilerModel()===t&&this.removeProfile(e)}snapshotReceived(e){this.profileBeingRecorded()===e&&this.setProfileBeingRecorded(null),this.dispatchEventToListeners("SnapshotReceived",e)}static TypeId="HEAP";static SnapshotReceived="SnapshotReceived"}class At extends(o.ObjectWrapper.eventMixin(Ut)){recordAllocationStacksSettingInternal;customContentInternal;recording;profileSamples;constructor(){super(At.TypeId,Mt(kt.allocationInstrumentationOn)),this.recordAllocationStacksSettingInternal=o.Settings.Settings.instance().createSetting("recordAllocationStacks",!1),this.customContentInternal=null,this.recording=!1}modelAdded(e){super.modelAdded(e),e.addEventListener(l.HeapProfilerModel.Events.HeapStatsUpdate,this.heapStatsUpdate,this),e.addEventListener(l.HeapProfilerModel.Events.LastSeenObjectId,this.lastSeenObjectId,this)}modelRemoved(e){super.modelRemoved(e),e.removeEventListener(l.HeapProfilerModel.Events.HeapStatsUpdate,this.heapStatsUpdate,this),e.removeEventListener(l.HeapProfilerModel.Events.LastSeenObjectId,this.lastSeenObjectId,this)}heapStatsUpdate(e){if(!this.profileSamples)return;const t=e.data;let i;for(let e=0;e<t.length;e+=3){i=t[e];const r=t[e+2];this.profileSamples.sizes[i]=r,this.profileSamples.max[i]||(this.profileSamples.max[i]=r)}}lastSeenObjectId(e){const t=this.profileSamples;if(!t)return;const{lastSeenObjectId:i,timestamp:r}=e.data,s=Math.max(t.ids.length,t.max.length-1);t.ids[s]=i,t.max[s]||(t.max[s]=0,t.sizes[s]=0),t.timestamps[s]=r,t.totalTime<r-t.timestamps[0]&&(t.totalTime*=2),this.profileSamples&&this.dispatchEventToListeners("HeapStatsUpdate",this.profileSamples);const o=this.profileBeingRecorded();o&&o.updateStatus(null,!0)}hasTemporaryView(){return!0}get buttonTooltip(){return this.recording?Mt(kt.stopRecordingHeapProfile):Mt(kt.startRecordingHeapProfile)}isInstantProfile(){return!1}buttonClicked(){return this.toggleRecording()}startRecordingProfile(){if(this.profileBeingRecorded())return;const e=this.addNewProfile();e&&e.startTrackingHeapObjects(this.recordAllocationStacksSettingInternal.get())}customContent(){const e=s.SettingsUI.createSettingCheckbox(Mt(kt.recordAllocationStacksExtra),this.recordAllocationStacksSettingInternal,!0);return this.customContentInternal=e,e}setCustomContentEnabled(e){this.customContentInternal&&(this.customContentInternal.checkboxElement.disabled=!e)}recordAllocationStacksSetting(){return this.recordAllocationStacksSettingInternal}addNewProfile(){const e=s.Context.Context.instance().flavor(l.HeapProfilerModel.HeapProfilerModel);return e?(this.setProfileBeingRecorded(new Wt(e,this,void 0)),this.profileSamples=new Ne,this.profileBeingRecorded()._profileSamples=this.profileSamples,this.recording=!0,this.addProfile(this.profileBeingRecorded()),this.profileBeingRecorded().updateStatus(Mt(kt.recording)),this.dispatchEventToListeners("TrackingStarted"),e):null}async stopRecordingProfile(){let e=this.profileBeingRecorded();e.updateStatus(Mt(kt.snapshotting));const t=e.heapProfilerModel().stopTrackingHeapObjects(!0);this.recording=!1,this.dispatchEventToListeners("TrackingStopped"),await t,e=this.profileBeingRecorded(),e&&(e.finishLoad(),this.profileSamples=null,this.setProfileBeingRecorded(null),this.dispatchEventToListeners(D.ProfileComplete,e))}toggleRecording(){return this.recording?this.stopRecordingProfile():this.startRecordingProfile(),this.recording}fileExtension(){return".heaptimeline"}get treeItemTitle(){return Mt(kt.allocationTimelines)}get description(){return Mt(kt.AllocationTimelinesShowInstrumented)}resetProfiles(e){const t=this.recording;this.setProfileBeingRecorded(null),super.resetProfiles(e),this.profileSamples=null,t&&this.addNewProfile()}profileBeingRecordedRemoved(){this.stopRecordingProfile(),this.profileSamples=null}static TypeId="HEAP-RECORD";static HeapStatsUpdate="HeapStatsUpdate";static TrackingStarted="TrackingStarted";static TrackingStopped="TrackingStopped"}class Wt extends F{heapProfilerModelInternal;maxJSObjectId;workerProxy;receiver;snapshotProxy;loadPromise;fulfillLoad;totalNumberOfChunks;bufferedWriter;onTempFileReady;failedToCreateTempFile;wasDisposed;fileName;constructor(e,t,i){super(t,i||Mt(kt.snapshotD,{PH1:t.nextProfileUid()})),this.heapProfilerModelInternal=e,this.maxJSObjectId=-1,this.workerProxy=null,this.receiver=null,this.snapshotProxy=null,this.loadPromise=new Promise((e=>{this.fulfillLoad=e})),this.totalNumberOfChunks=0,this.bufferedWriter=null,this.onTempFileReady=null}heapProfilerModel(){return this.heapProfilerModelInternal}async getLocation(e){return this.snapshotProxy?this.snapshotProxy.getLocation(e):null}createSidebarTreeElement(e){return new A(e,this,"heap-snapshot-sidebar-tree-item")}createView(e){return new Lt(e,this)}prepareToLoad(){console.assert(!this.receiver,"Already loading"),this.setupWorker(),this.updateStatus(Mt(kt.loading),!0)}finishLoad(){!this.wasDisposed&&this.receiver&&this.receiver.close(),this.bufferedWriter&&this.didWriteToTempFile(this.bufferedWriter)}didWriteToTempFile(e){this.wasDisposed?e&&e.remove():(this.tempFile=e,e||(this.failedToCreateTempFile=!0),this.onTempFileReady&&(this.onTempFileReady(),this.onTempFileReady=null))}setupWorker(){console.assert(!this.workerProxy,"HeapSnapshotWorkerProxy already exists"),this.workerProxy=new xt(this.handleWorkerEvent.bind(this)),this.workerProxy.addEventListener("Wait",(e=>{this.updateStatus(null,e.data)}),this),this.receiver=this.workerProxy.createLoader(this.uid,this.snapshotReceived.bind(this))}handleWorkerEvent(e,i){if(p.HeapSnapshotModel.HeapSnapshotProgressEvent.BrokenSnapshot===e){const e=i;return void o.Console.Console.instance().error(e)}if(p.HeapSnapshotModel.HeapSnapshotProgressEvent.Update!==e)return;const r=i,s=t.i18n.deserializeUIString(r);this.updateStatus(Ht(s.string,s.values))}dispose(){this.workerProxy&&this.workerProxy.dispose(),this.removeTempFile(),this.wasDisposed=!0}didCompleteSnapshotTransfer(){this.snapshotProxy&&this.updateStatus(e.NumberUtilities.bytesToString(this.snapshotProxy.totalSize),!1)}transferChunk(e){this.bufferedWriter||(this.bufferedWriter=new h.TempFile.TempFile),this.bufferedWriter.write([e]),++this.totalNumberOfChunks,this.receiver&&this.receiver.write(e)}snapshotReceived(e){this.wasDisposed||(this.receiver=null,this.snapshotProxy=e,this.maxJSObjectId=e.maxJSObjectId(),this.didCompleteSnapshotTransfer(),this.workerProxy&&this.workerProxy.startCheckingForLongRunningCalls(),this.notifySnapshotReceived())}notifySnapshotReceived(){this.snapshotProxy&&this.fulfillLoad&&this.fulfillLoad(this.snapshotProxy),this.profileType().snapshotReceived(this),this.canSaveToFile()&&this.dispatchEventToListeners(k.ProfileReceived)}canSaveToFile(){return!this.fromFile()&&Boolean(this.snapshotProxy)}saveToFile(){const t=new h.FileUtils.FileOutputStream;this.fileName=this.fileName||"Heap-"+e.DateUtilities.toISO8601Compact(new Date)+this.profileType().fileExtension();const i=async e=>{if(e){if(this.failedToCreateTempFile)return o.Console.Console.instance().error("Failed to open temp file with heap snapshot"),void t.close();if(this.tempFile){const e=await this.tempFile.copyToOutputStream(t,this.onChunkTransferred.bind(this));return e&&o.Console.Console.instance().error("Failed to read heap snapshot from temp file: "+e.message),void this.didCompleteSnapshotTransfer()}this.onTempFileReady=()=>{i(e)},this.updateSaveProgress(0,1)}};t.open(this.fileName).then(i.bind(this))}onChunkTransferred(e){this.updateSaveProgress(e.loadedSize(),e.fileSize())}updateSaveProgress(e,t){const i=(100*(t&&e/t)).toFixed(0);this.updateStatus(Mt(kt.savingD,{PH1:i}))}async loadFromFile(e){this.updateStatus(Mt(kt.loading),!0),this.setupWorker();const t=new h.FileUtils.ChunkedFileReader(e,1e7),i=await t.read(this.receiver);if(!i){const e=t.error();e&&this.updateStatus(e.message)}return i?null:t.error()}profileType(){return super.profileType()}}class _t extends s.Widget.VBox{pieChart;constructor(){super(),this.element.classList.add("heap-snapshot-statistics-view"),this.pieChart=new n.PieChart.PieChart,this.setTotalAndRecords(0,[]),this.pieChart.classList.add("heap-snapshot-stats-pie-chart"),this.element.appendChild(this.pieChart)}static valueFormatter(t){return Mt(kt.sKb,{PH1:e.NumberUtilities.withThousandsSeparator(Math.round(t/1e3))})}setTotalAndRecords(e,t){this.pieChart.data={chartName:Mt(kt.heapMemoryUsage),size:150,formatter:_t.valueFormatter,showLegend:!0,total:e,slices:t}}}class Jt extends s.Widget.Widget{heapProfilerModel;linkifier;frameElements;constructor(e){super(),this.heapProfilerModel=e,this.linkifier=new d.Linkifier.Linkifier,this.frameElements=[]}onContextMenu(e,t){const i=new s.ContextMenu.ContextMenu(t);i.containsTarget(e)||i.appendApplicableItems(e),i.show(),t.consume(!0)}onStackViewKeydown(e){const t=e.target;if(!t)return;if("Enter"===e.key){const i=$t.get(t);if(!i)return;const r=d.Linkifier.Linkifier.linkInfo(i);if(!r)return;return void(d.Linkifier.Linkifier.invokeFirstAction(r)&&e.consume(!0))}let i;const r=e;if("ArrowUp"===r.key)i=!1;else{if("ArrowDown"!==r.key)return;i=!0}const s=this.frameElements.indexOf(t);if(-1===s)return;const o=i?s+1:s-1;if(o<0||o>=this.frameElements.length)return;const n=this.frameElements[o];n.tabIndex=0,t.tabIndex=-1,n.focus(),e.consume(!0)}async setAllocatedObject(e,t){this.clear();const i=await e.allocationStack(t);if(!i){const e=this.element.createChild("div","no-heap-allocation-stack");return void s.UIUtils.createTextChild(e,Mt(kt.stackWasNotRecordedForThisObject))}const r=this.element.createChild("div","heap-allocation-stack");r.addEventListener("keydown",this.onStackViewKeydown.bind(this),!1);for(const e of i){const t=r.createChild("div","stack-frame");this.frameElements.push(t),t.tabIndex=-1;if(t.createChild("div").textContent=s.UIUtils.beautifyFunctionName(e.functionName),!e.scriptId)continue;const i=this.heapProfilerModel?this.heapProfilerModel.target():null,o={columnNumber:e.column-1,inlineFrameIndex:0},n=this.linkifier.linkifyScriptLocation(i,String(e.scriptId),e.scriptName,e.line-1,o);t.appendChild(n),$t.set(t,n),t.addEventListener("contextmenu",this.onContextMenu.bind(this,n))}this.frameElements[0].tabIndex=0}clear(){this.element.removeChildren(),this.frameElements=[],this.linkifier.reset()}}const $t=new WeakMap;var qt=Object.freeze({__proto__:null,HeapSnapshotView:Lt,Perspective:jt,SummaryPerspective:Ot,ComparisonPerspective:zt,ContainmentPerspective:Bt,AllocationPerspective:Gt,StatisticsPerspective:Vt,HeapSnapshotProfileType:Ut,TrackingHeapSnapshotProfileType:At,HeapProfileHeader:Wt,HeapSnapshotStatisticsView:_t,HeapAllocationStackView:Jt});class Qt{cpuProfileType;heapSnapshotProfileType;samplingHeapProfileType;trackingHeapSnapshotProfileType;constructor(){this.cpuProfileType=new oe,this.heapSnapshotProfileType=new Ut,this.samplingHeapProfileType=new Be,this.trackingHeapSnapshotProfileType=new At}}const Kt=new Qt;var Yt=Object.freeze({__proto__:null,ProfileTypeRegistry:Qt,instance:Kt});const Zt={clearAllProfiles:"Clear all profiles",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}.",load:"Load…",runD:"Run {PH1}",profiles:"Profiles",deprecationWarnMsg:"This panel will be deprecated in the upcoming version. Use the Performance panel to record JavaScript CPU profiles.",learnMore:"Learn more",feedback:"Feedback",goToPerformancePanel:"Go to Performance Panel",enableThisPanelTemporarily:"Enable this panel temporarily"},Xt=t.i18n.registerUIStrings("panels/profiler/ProfilesPanel.ts",Zt),ei=t.i18n.getLocalizedString.bind(void 0,Xt);class ti extends s.Panel.PanelWithSidebar{profileTypes;profilesItemTreeElement;sidebarTree;profileViews;toolbarElement;toggleRecordAction;toggleRecordButton;clearResultsButton;profileViewToolbar;profileGroups;launcherView;visibleView;profileToView;typeIdToSidebarSection;fileSelectorElement;selectedProfileType;constructor(e,t,i){super(e),this.profileTypes=t;const r=new s.Widget.VBox;this.splitWidget().setMainWidget(r),this.profilesItemTreeElement=new oi(this),this.sidebarTree=new s.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"),r.element.appendChild(this.profileViews),this.toolbarElement=document.createElement("div"),this.toolbarElement.classList.add("profiles-toolbar"),r.element.insertBefore(this.toolbarElement,r.element.firstChild),this.panelSidebarElement().classList.add("profiles-tree-sidebar");const o=document.createElement("div");o.classList.add("profiles-toolbar"),this.panelSidebarElement().insertBefore(o,this.panelSidebarElement().firstChild);const n=new s.Toolbar.Toolbar("",o);this.toggleRecordAction=s.ActionRegistry.ActionRegistry.instance().action(i),this.toggleRecordButton=s.Toolbar.Toolbar.createActionButton(this.toggleRecordAction),n.appendToolbarItem(this.toggleRecordButton),this.clearResultsButton=new s.Toolbar.ToolbarButton(ei(Zt.clearAllProfiles),"clear"),this.clearResultsButton.addEventListener(s.Toolbar.ToolbarButton.Events.Click,this.reset,this),n.appendToolbarItem(this.clearResultsButton),n.appendSeparator(),n.appendToolbarItem(s.Toolbar.Toolbar.createActionButtonForId("components.collect-garbage")),this.profileViewToolbar=new s.Toolbar.Toolbar("",this.toolbarElement),this.profileViewToolbar.makeWrappable(!0),this.profileGroups={},this.launcherView=new xe(this),this.launcherView.addEventListener(ye.ProfileTypeSelected,this.onProfileTypeSelected,this),this.profileToView=[],this.typeIdToSidebarSection={};const a=this.profileTypes;for(let e=0;e<a.length;e++)this.registerProfileType(a[e]);this.launcherView.restoreSelectedProfileType(),this.profilesItemTreeElement.select(),this.showLauncherView(),this.createFileSelectorElement(),this.element.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),l.TargetManager.TargetManager.instance().addEventListener(l.TargetManager.Events.SuspendStateChanged,this.onSuspendStateChanged,this),s.Context.Context.instance().addFlavorChangeListener(l.CPUProfilerModel.CPUProfilerModel,this.updateProfileTypeSpecificUI,this),s.Context.Context.instance().addFlavorChangeListener(l.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=s.UIUtils.createFileSelectorElement(this.loadFromFile.bind(this)),U(this.fileSelectorElement),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 o.Console.Console.instance().error(ei(Zt.cantLoadFileSupportedFile,{PH1:Array.from(e).join("', '")}))}if(Boolean(t.profileBeingRecorded()))return void o.Console.Console.instance().error(ei(Zt.cantLoadProfileWhileAnother));const i=await t.loadFromFile(e);i&&"message"in i&&s.UIUtils.MessageDialog.show(ei(Zt.profileLoadingFailedS,{PH1:i.message}))}toggleRecord(){if(!this.toggleRecordAction.enabled())return!0;const t=e.DOMUtilities.deepActiveElement(this.element.ownerDocument),i=this.selectedProfileType;if(!i)return!0;const r=i.buttonClicked();return this.updateToggleRecordAction(r),r?(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(s.Context.Context.instance().flavor(l.CPUProfilerModel.CPUProfilerModel)||s.Context.Context.instance().flavor(l.HeapProfilerModel.HeapProfilerModel)),i=e||!l.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(s.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.launcherView.profileFinished(),this.sidebarTree.element.classList.remove("some-expandable"),this.launcherView.detach(),this.profileViews.removeChildren(),this.profileViewToolbar.removeToolbarItems(),this.clearResultsButton.element.classList.remove("hidden"),this.profilesItemTreeElement.select(),this.showLauncherView()}showLauncherView(){this.closeVisibleView(),this.profileViewToolbar.removeToolbarItems(),this.launcherView.show(this.profileViews),this.visibleView=this.launcherView,this.toolbarElement.classList.add("hidden")}registerProfileType(e){this.launcherView.addProfileType(e);const t=new ii(this,e);this.typeIdToSidebarSection[e.id]=t,this.sidebarTree.appendChild(t),t.childrenListElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),e.addEventListener(D.ViewUpdated,this.updateProfileTypeSpecificUI,this),e.addEventListener(D.AddProfileHeader,(function(e){this.addProfileHeader(e.data)}),this),e.addEventListener(D.RemoveProfileHeader,(function(e){this.removeProfileHeader(e.data)}),this),e.addEventListener(D.ProfileComplete,(function(e){this.showProfile(e.data)}),this);const i=e.getProfiles();for(let e=0;e<i.length;e++)this.addProfileHeader(i[e])}handleContextMenuEvent(e){const t=new s.ContextMenu.ContextMenu(e);this.panelSidebarElement().isSelfOrAncestor(e.target)&&t.defaultSection().appendItem(ei(Zt.load),this.fileSelectorElement.click.bind(this.fileSelectorElement)),t.show()}showLoadFromFileDialog(){this.fileSelectorElement.click()}addProfileHeader(e){const t=e.profileType().id;this.typeIdToSidebarSection[t].addProfileHeader(e),this.visibleView&&this.visibleView!==this.launcherView||this.showProfile(e)}removeProfileHeader(e){e.profileType().profileBeingRecorded()===e&&this.profileBeingRecordedRemoved();const t=this.indexOfViewForProfile(e);-1!==t&&this.profileToView.splice(t,1);const i=e.profileType().id;this.typeIdToSidebarSection[i].removeProfileHeader(e)&&(this.profilesItemTreeElement.select(),this.showLauncherView())}showProfile(e){if(!e||e.profileType().profileBeingRecorded()===e&&!e.profileType().hasTemporaryView())return null;const t=this.viewForProfile(e);if(t===this.visibleView)return t;this.closeVisibleView(),t.show(this.profileViews),this.toolbarElement.classList.remove("hidden"),this.visibleView=t;const i=this.typeIdToSidebarSection[e.profileType().id].sidebarElementForProfile(e);return i&&i.revealAndSelect(),this.profileViewToolbar.removeToolbarItems(),t.toolbarItems().then((e=>{e.map((e=>this.profileViewToolbar.appendToolbarItem(e)))})),t}showObject(e,t){}async linkifyObject(e){return null}viewForProfile(e){const t=this.indexOfViewForProfile(e);if(-1!==t)return this.profileToView[t].view;const i=e.createView(this);return i.element.classList.add("profile-view"),this.profileToView.push({profile:e,view:i}),i}indexOfViewForProfile(e){return this.profileToView.findIndex((t=>t.profile===e))}closeVisibleView(){this.visibleView&&this.visibleView.detach(),delete this.visibleView}focus(){this.sidebarTree.focus()}wasShown(){super.wasShown(),this.registerCSSFiles([he,pe,ce]),this.sidebarTree.registerCSSFiles([ue])}}class ii extends s.TreeOutline.TreeElement{dataDisplayDelegate;profileTreeElements;profileGroups;constructor(e,t){super(t.treeItemTitle,!0),this.selectable=!1,this.dataDisplayDelegate=e,this.profileTreeElements=[],this.profileGroups={},this.expand(),this.hidden=!0,this.setCollapsible(!1)}addProfileHeader(e){this.hidden=!1;const t=e.profileType();let i=this;const r=e.createSidebarTreeElement(this.dataDisplayDelegate);if(this.profileTreeElements.push(r),!e.fromFile()&&t.profileBeingRecorded()!==e){const t=e.title;let s=this.profileGroups[t];s||(s=new ri,this.profileGroups[t]=s),s.profileSidebarTreeElements.push(r);const o=s.profileSidebarTreeElements.length;if(2===o){s.sidebarTreeElement=new si(this.dataDisplayDelegate,e.title);const t=s.profileSidebarTreeElements[0],i=this.children().indexOf(t);this.insertChild(s.sidebarTreeElement,i);const r=t.selected;this.removeChild(t),s.sidebarTreeElement.appendChild(t),r&&t.revealAndSelect(),t.setSmall(!0),t.setMainTitle(ei(Zt.runD,{PH1:1})),this.treeOutline&&this.treeOutline.element.classList.add("some-expandable")}o>=2&&(i=s.sidebarTreeElement,r.setSmall(!0),r.setMainTitle(ei(Zt.runD,{PH1:o})))}i&&i.appendChild(r)}removeProfileHeader(e){const t=this.sidebarElementIndex(e);if(-1===t)return!1;const i=this.profileTreeElements[t];this.profileTreeElements.splice(t,1);let r=this;const s=this.profileGroups[e.title];if(s){const t=s.profileSidebarTreeElements;if(t.splice(t.indexOf(i),1),1===t.length){const i=r.children().indexOf(s.sidebarTreeElement);s.sidebarTreeElement&&s.sidebarTreeElement.removeChild(t[0]),this.insertChild(t[0],i),t[0].setSmall(!1),t[0].setMainTitle(e.title),s.sidebarTreeElement&&this.removeChild(s.sidebarTreeElement)}0!==t.length&&(r=s.sidebarTreeElement)}return r&&r.removeChild(i),i.dispose(),!this.childCount()&&(this.hidden=!0,!0)}sidebarElementForProfile(e){const t=this.sidebarElementIndex(e);return-1===t?null:this.profileTreeElements[t]}sidebarElementIndex(e){const t=this.profileTreeElements;for(let i=0;i<t.length;i++)if(t[i].profile===e)return i;return-1}onattach(){this.listItemElement.classList.add("profiles-tree-section")}}class ri{profileSidebarTreeElements;sidebarTreeElement;constructor(){this.profileSidebarTreeElements=[],this.sidebarTreeElement=null}}class si extends s.TreeOutline.TreeElement{dataDisplayDelegate;profileTitle;toggleOnClick;constructor(e,t){super("",!0),this.selectable=!1,this.dataDisplayDelegate=e,this.profileTitle=t,this.expand(),this.toggleOnClick=!0}onselect(){const e=this.childCount()>0;if(e){const e=this.lastChild();e instanceof A&&this.dataDisplayDelegate.showProfile(e.profile)}return e}onattach(){this.listItemElement.classList.add("profile-group-sidebar-tree-item"),this.listItemElement.createChild("div","icon"),this.listItemElement.createChild("div","titles no-subtitle").createChild("span","title-container").createChild("span","title").textContent=this.profileTitle}}class oi extends s.TreeOutline.TreeElement{panel;constructor(e){super("",!1),this.selectable=!0,this.panel=e}onselect(){return this.panel.showLauncherView(),!0}onattach(){this.listItemElement.classList.add("profile-launcher-view-tree-item"),this.listItemElement.createChild("div","icon"),this.listItemElement.createChild("div","titles no-subtitle").createChild("span","title-container").createChild("span","title").textContent=ei(Zt.profiles)}}let ni;class ai extends ti{constructor(){super("js_profiler",[Kt.cpuProfileType],"profiler.js-toggle-recording"),this.splitWidget().mainWidget()?.setMinimumSize(350,0),c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.REACT_NATIVE_SPECIFIC_UI)||(c.Runtime.experiments.isEnabled("jsProfilerTemporarilyEnable")?this.#t():this.#i())}static instance(e={forceNew:null}){const{forceNew:t}=e;return ni&&!t||(ni=new ai),ni}#t(){function e(){a.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://github.com/ChromeDevTools/rfcs/discussions/2")}const t=new s.Infobar.Infobar(s.Infobar.Type.Warning,ei(Zt.deprecationWarnMsg),[{text:ei(Zt.learnMore),highlight:!1,delegate:e,dismiss:!1},{text:ei(Zt.feedback),highlight:!1,delegate:e,dismiss:!1},{text:ei(Zt.goToPerformancePanel),highlight:!0,delegate:async function(){await s.InspectorView.InspectorView.instance().showPanel("timeline")},dismiss:!1}],void 0);t.setParentView(this),this.splitWidget().mainWidget()?.element.prepend(t.element)}#i(){const e=this.splitWidget().mainWidget();if(e?.detachChildWidgets(),e){const t=new s.Widget.VBox;t.contentElement.classList.add("empty-landing-page","fill");const i=t.contentElement.createChild("div");i.createChild("p").textContent="This panel is deprecated and will be removed in the next version. Use the Performance panel to record JavaScript CPU profiles.",i.createChild("p").textContent="You can temporarily enable this panel with Settings > Experiments > Enable JavaScript Profiler.",i.appendChild(s.UIUtils.createTextButton(ei(Zt.goToPerformancePanel),(async function(){await s.InspectorView.InspectorView.instance().showPanel("timeline")}),"infobar-button primary-button")),i.appendChild(s.UIUtils.createTextButton(ei(Zt.learnMore),(function(){a.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://developer.chrome.com/blog/js-profiler-deprecation/")}))),i.appendChild(s.UIUtils.createTextButton(ei(Zt.feedback),(function(){a.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab("https://bugs.chromium.org/p/chromium/issues/detail?id=1354548")}))),i.appendChild(s.UIUtils.createTextButton(ei(Zt.enableThisPanelTemporarily),(async function(){await s.ViewManager.ViewManager.instance().showView("experiments");(await s.ViewManager.ViewManager.instance().view("experiments").widget()).setFilter("Enable JavaScript Profiler temporarily")}))),t.show(e.element)}}wasShown(){super.wasShown(),s.Context.Context.instance().setFlavor(ai,this)}willHide(){s.Context.Context.instance().setFlavor(ai,null)}handleAction(e,t){const i=s.Context.Context.instance().flavor(ai);if(!(i instanceof ai))throw new Error("non-null JSProfilerPanel expected!");return i.toggleRecord(),!0}}var li=Object.freeze({__proto__:null,ProfilesPanel:ti,ProfileTypeSidebarSection:ii,ProfileGroup:ri,ProfileGroupSidebarTreeElement:si,ProfilesSidebarTreeElement:oi,JSProfilerPanel:ai});const di={revealInSummaryView:"Reveal in Summary view"},hi=t.i18n.registerUIStrings("panels/profiler/HeapProfilerPanel.ts",di),ci=t.i18n.getLocalizedString.bind(void 0,hi);let pi;class ui extends ti{constructor(){const e=Kt;super("heap_profiler",[e.heapSnapshotProfileType,e.trackingHeapSnapshotProfileType,e.samplingHeapProfileType],"profiler.heap-toggle-recording")}static instance(){return pi||(pi=new ui),pi}appendApplicableItems(e,t,i){if(!(i instanceof l.RemoteObject.RemoteObject))return;if(!this.isShowing())return;const r=i;if(!r.objectId)return;const s=r.objectId;if(!Kt.heapSnapshotProfileType.getProfiles().length)return;const o=r.runtimeModel().heapProfilerModel();o&&t.revealSection().appendItem(ci(di.revealInSummaryView),function(e){o.snapshotObjectIdForObjectId(s).then((t=>{this.isShowing()&&t&&this.showObject(t,e)}))}.bind(this,"Summary"))}handleAction(e,t){const i=s.Context.Context.instance().flavor(ui);return console.assert(Boolean(i)&&i instanceof ui),i&&i.toggleRecord(),!0}wasShown(){super.wasShown(),s.Context.Context.instance().setFlavor(ui,this),a.userMetrics.panelLoaded("heap_profiler","DevTools.Launch.HeapProfiler")}willHide(){s.Context.Context.instance().setFlavor(ui,null)}showObject(e,t){const i=Kt.heapSnapshotProfileType.getProfiles();for(let r=0;r<i.length;r++){const s=i[r];if(s.maxJSObjectId>=parseInt(e,10)){this.showProfile(s);this.viewForProfile(s).selectLiveObject(t,e);break}}}}var mi=Object.freeze({__proto__:null,HeapProfilerPanel:ui});const fi=new CSSStyleSheet;fi.replaceSync(".data-grid{border:none}.data-grid td .size-units{margin-left:4px;font-size:75%}.data-grid tr:not(.selected) td .size-units{color:var(--color-text-secondary)}.toolbar{border-bottom:1px solid var(--color-details-hairline)}\n/*# sourceURL=liveHeapProfile.css */\n");const gi={jsHeap:"JS Heap",allocatedJsHeapSizeCurrentlyIn:"Allocated JS heap size currently in use",vms:"VMs",numberOfVmsSharingTheSameScript:"Number of VMs sharing the same script source",scriptUrl:"Script URL",urlOfTheScriptSource:"URL of the script source",heapProfile:"Heap Profile",anonymousScriptS:"(Anonymous Script {PH1})",kb:"kB"},vi=t.i18n.registerUIStrings("panels/profiler/LiveHeapProfileView.ts",gi),wi=t.i18n.getLocalizedString.bind(void 0,vi);let Si,bi;class Ci extends s.Widget.VBox{gridNodeByUrl;setting;toggleRecordAction;toggleRecordButton;startWithReloadButton;dataGrid;currentPollId;constructor(){super(!0),this.gridNodeByUrl=new Map,this.setting=o.Settings.Settings.instance().moduleSetting("memoryLiveHeapProfile");const e=new s.Toolbar.Toolbar("live-heap-profile-toolbar",this.contentElement);this.toggleRecordAction=s.ActionRegistry.ActionRegistry.instance().action("live-heap-profile.toggle-recording"),this.toggleRecordButton=s.Toolbar.Toolbar.createActionButton(this.toggleRecordAction),this.toggleRecordButton.setToggled(this.setting.get()),e.appendToolbarItem(this.toggleRecordButton);const t=l.TargetManager.TargetManager.instance().primaryPageTarget();if(t&&t.model(l.ResourceTreeModel.ResourceTreeModel)){const t=s.ActionRegistry.ActionRegistry.instance().action("live-heap-profile.start-with-reload");this.startWithReloadButton=s.Toolbar.Toolbar.createActionButton(t),e.appendToolbarItem(this.startWithReloadButton)}this.dataGrid=this.createDataGrid(),this.dataGrid.asWidget().show(this.contentElement),this.currentPollId=0}static instance(){return Si||(Si=new Ci),Si}createDataGrid(){const e={id:"",title:o.UIString.LocalizedEmptyString,width:void 0,fixedWidth:!0,sortable:!0,align:r.DataGrid.Align.Right,sort:r.DataGrid.Order.Descending,titleDOMFragment:void 0,editable:void 0,nonSelectable:void 0,longText:void 0,disclosure:void 0,weight:void 0,allowInSortByEvenWhenHidden:void 0,dataType:void 0,defaultWeight:void 0},t=[{...e,id:"size",title:wi(gi.jsHeap),width:"72px",fixedWidth:!0,sortable:!0,align:r.DataGrid.Align.Right,sort:r.DataGrid.Order.Descending,tooltip:wi(gi.allocatedJsHeapSizeCurrentlyIn)},{...e,id:"isolates",title:wi(gi.vms),width:"40px",fixedWidth:!0,align:r.DataGrid.Align.Right,tooltip:wi(gi.numberOfVmsSharingTheSameScript)},{...e,id:"url",title:wi(gi.scriptUrl),fixedWidth:!1,sortable:!0,tooltip:wi(gi.urlOfTheScriptSource)}],i=new r.SortableDataGrid.SortableDataGrid({displayName:wi(gi.heapProfile),columns:t,editCallback:void 0,deleteCallback:void 0,refreshCallback:void 0});i.setResizeMethod(r.DataGrid.ResizeMethod.Last),i.element.classList.add("flex-auto"),i.element.addEventListener("keydown",this.onKeyDown.bind(this),!1),i.addEventListener(r.DataGrid.Events.OpenedNode,this.revealSourceForSelectedNode,this),i.addEventListener(r.DataGrid.Events.SortingChanged,this.sortingChanged,this);for(const e of t){const t=i.headerTableHeader(e.id);t&&t.setAttribute("title",e.tooltip)}return i}wasShown(){super.wasShown(),this.poll(),this.registerCSSFiles([fi]),this.setting.addChangeListener(this.settingChanged,this)}willHide(){++this.currentPollId,this.setting.removeChangeListener(this.settingChanged,this)}settingChanged(e){this.toggleRecordButton.setToggled(e.data)}async poll(){const e=this.currentPollId;do{const t=Array.from(l.IsolateManager.IsolateManager.instance().isolates()),i=await Promise.all(t.map((e=>{const t=e.heapProfilerModel();return t?t.getSamplingProfile():null})));if(this.currentPollId!==e)return;this.update(t,i),await new Promise((e=>window.setTimeout(e,3e3)))}while(this.currentPollId===e)}update(e,t){const i=new Map;t.forEach(((t,i)=>{t&&o(e[i],"",t.head)}));const r=this.dataGrid.rootNode(),s=new Set;for(const e of i){const t=e[0],i=e[1].size,o=e[1].isolates.size;if(!t){console.info(`Node with empty URL: ${i} bytes`);continue}let n=this.gridNodeByUrl.get(t);n?n.updateNode(i,o):(n=new Pi(t,i,o),this.gridNodeByUrl.set(t,n),r.appendChild(n)),s.add(n)}for(const e of r.children.slice()){s.has(e)||e.remove();const t=e;this.gridNodeByUrl.delete(t.url)}function o(e,t,r){const s=r.callFrame.url||t||function(e){const t=e.callFrame.functionName;return t.startsWith("(")&&"(root)"!==t?t:""}(r)||function(e){return Number(e.callFrame.scriptId)?wi(gi.anonymousScriptS,{PH1:e.callFrame.scriptId}):""}(r);if(r.children.forEach(o.bind(null,e,s)),!r.selfSize)return;let n=i.get(s);n||(n={size:0,isolates:new Set},i.set(s,n)),n.size+=r.selfSize,n.isolates.add(e)}this.sortingChanged()}onKeyDown(e){"Enter"===e.key&&(e.consume(!0),this.revealSourceForSelectedNode())}revealSourceForSelectedNode(){const e=this.dataGrid.selectedNode;if(!e||!e.url)return;const t=m.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(e.url);t&&o.Revealer.reveal(t)}sortingChanged(){const e=this.dataGrid.sortColumnId();if(!e)return;const t="url"===e?function(e,t){return t.url.localeCompare(e.url)}:function(e,t){return t.size-e.size};this.dataGrid.sortNodes(t,this.dataGrid.isSortOrderAscending())}toggleRecording(){!this.setting.get()?this.startRecording(!1):this.stopRecording()}startRecording(e){if(this.setting.set(!0),!e)return;const t=l.TargetManager.TargetManager.instance().primaryPageTarget();if(!t)return;const i=t.model(l.ResourceTreeModel.ResourceTreeModel);i&&i.reloadPage()}async stopRecording(){this.setting.set(!1)}}class Pi extends r.SortableDataGrid.SortableDataGridNode{url;size;isolateCount;constructor(e,t,i){super(),this.url=e,this.size=t,this.isolateCount=i}updateNode(e,t){this.size===e&&this.isolateCount===t||(this.size=e,this.isolateCount=t,this.refresh())}createCell(t){const i=this.createTD(t);switch(t){case"url":i.textContent=this.url;break;case"size":i.textContent=e.NumberUtilities.withThousandsSeparator(Math.round(this.size/1e3)),i.createChild("span","size-units").textContent=wi(gi.kb);break;case"isolates":i.textContent=`${this.isolateCount}`}return i}}class Ti{static instance(e={forceNew:null}){const{forceNew:t}=e;return bi&&!t||(bi=new Ti),bi}handleAction(e,t){return(async()=>{const e="live_heap_profile";await s.ViewManager.ViewManager.instance().showView(e);const i=s.ViewManager.ViewManager.instance().view(e);if(i){const e=await i.widget();this.innerHandleAction(e,t)}})(),!0}innerHandleAction(e,t){switch(t){case"live-heap-profile.toggle-recording":e.toggleRecording();break;case"live-heap-profile.start-with-reload":e.startRecording(!0);break;default:console.assert(!1,`Unknown action: ${t}`)}}}var xi=Object.freeze({__proto__:null,LiveHeapProfileView:Ci,GridNode:Pi,ActionDelegate:Ti});export{T as BottomUpProfileDataGrid,M as CPUProfileFlameChart,de as CPUProfileView,x as ChildrenProvider,_e as HeapProfileView,mi as HeapProfilerPanel,bt as HeapSnapshotDataGrids,ot as HeapSnapshotGridNodes,Nt as HeapSnapshotProxy,qt as HeapSnapshotView,De as HeapTimelineOverview,Se as IsolateSelector,xi as LiveHeapProfileView,b as ProfileDataGrid,j as ProfileHeader,Ie as ProfileLauncherView,W as ProfileSidebarTreeElement,Yt as ProfileTypeRegistry,ee as ProfileView,li as ProfilesPanel,$ as TopDownProfileDataGrid};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"../../ui/legacy/legacy.js";import*as
|
|
1
|
+
import*as e from"../../ui/legacy/legacy.js";import*as r from"../../core/i18n/i18n.js";import*as t from"../../ui/lit-html/lit-html.js";const o=new CSSStyleSheet;o.replaceSync('.rn-welcome-panel{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:16px;text-align:center;background-color:var(--color-background-elevation-0)}.rn-welcome-header{display:flex;align-items:center;margin-bottom:16px}.rn-welcome-icon{width:30px;height:30px;border-radius:4px;margin-right:12px}.rn-welcome-title{font-size:20px;color:var(--color-text-primary)}.rn-welcome-title-accessory{margin-left:12px;padding:4px 8px;border-radius:4px;background-color:var(--color-purple-bright);font-size:12px;color:var(--color-on-primary)}.rn-welcome-tagline{margin-bottom:24px;font-size:1rem;line-height:1.3;color:var(--color-text-secondary)}.rn-welcome-links{display:flex;align-items:center}.rn-welcome-links > .devtools-link{position:relative;margin:0 16px;font-size:14px}.rn-welcome-links > .devtools-link:not(:last-child)::after{content:"";position:absolute;right:-16px;height:16px;border-right:1px solid var(--color-details-hairline)}\n/*# sourceURL=rnWelcome.css */\n');const n={debuggerBrandName:"React Native JS Inspector",techPreviewLabel:"Technology Preview",welcomeMessage:"Welcome to debugging in React Native",docsLabel:"Debugging docs",whatsNewLabel:"What's new"},{render:i,html:l}=t,s=r.i18n.registerUIStrings("panels/rn_welcome/RNWelcome.ts",n),c=r.i18n.getLocalizedString.bind(void 0,s);let a;class d extends e.Widget.VBox{static instance(e={forceNew:null}){const{forceNew:r}=e;return a&&!r||(a=new d),a}constructor(){super(!0,!0)}wasShown(){super.wasShown(),this.registerCSSFiles([o]),this.render(),e.InspectorView.InspectorView.instance().showDrawer(!0)}render(){const e=new URL("../../Images/react_native/welcomeIcon.png",import.meta.url).toString();i(l` <div class="rn-welcome-panel"> <div class="rn-welcome-header"> <img class="rn-welcome-icon" src="${e}" role="presentation"> <div class="rn-welcome-title"> ${c(n.debuggerBrandName)} </div> <div class="rn-welcome-title-accessory"> ${c(n.techPreviewLabel)} </div> </div> <div class="rn-welcome-tagline"> ${c(n.welcomeMessage)} </div> <div class="rn-welcome-links"> <x-link class="devtools-link" href="https://reactnative.dev/docs/debugging"> ${c(n.docsLabel)} </x-link> <x-link class="devtools-link" href="https://reactnative.dev/blog"> ${c(n.whatsNewLabel)} </x-link> </div> </div> `,this.contentElement,{host:this})}}var m=Object.freeze({__proto__:null,RNWelcomeImpl:d});export{m as RNWelcome};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<!DOCTYPE html>
|
|
7
7
|
<html lang="en">
|
|
8
8
|
<meta charset="utf-8">
|
|
9
|
-
<title>DevTools</title>
|
|
9
|
+
<title>DevTools (React Native)</title>
|
|
10
10
|
<style>
|
|
11
11
|
@media (prefers-color-scheme: dark) {
|
|
12
12
|
body {
|
|
@@ -16,5 +16,6 @@
|
|
|
16
16
|
</style>
|
|
17
17
|
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com">
|
|
18
18
|
<meta name="referrer" content="no-referrer">
|
|
19
|
+
<link rel="icon" href="./Images/favicon.ico">
|
|
19
20
|
<script type="module" src="./entrypoints/rn_inspector/rn_inspector.js"></script>
|
|
20
21
|
<body class="undocked" id="-blink-dev-tools">
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<!DOCTYPE html>
|
|
7
7
|
<html lang="en">
|
|
8
8
|
<meta charset="utf-8">
|
|
9
|
-
<title>DevTools</title>
|
|
9
|
+
<title>DevTools (React Native)</title>
|
|
10
10
|
<style>
|
|
11
11
|
@media (prefers-color-scheme: dark) {
|
|
12
12
|
body {
|
|
@@ -16,5 +16,6 @@
|
|
|
16
16
|
</style>
|
|
17
17
|
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com">
|
|
18
18
|
<meta name="referrer" content="no-referrer">
|
|
19
|
+
<link rel="icon" href="./Images/favicon.ico">
|
|
19
20
|
<script type="module" src="./entrypoints/worker_app/worker_app.js"></script>
|
|
20
21
|
<body class="undocked" id="-blink-dev-tools">
|