@kylincloud/flamegraph 0.35.9 → 0.35.10
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/README.md +159 -51
- package/dist/ProfilerTable.d.ts.map +1 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +2 -2
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/ProfilerTable.tsx +24 -11
- package/src/sass/_css-variables.scss +15 -2
- package/src/sass/flamegraph.scss +59 -0
- package/src/shims/Table.module.scss +7 -1
package/dist/index.node.esm.js
CHANGED
|
@@ -14,5 +14,5 @@ function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n
|
|
|
14
14
|
Copyright (c) 2018 Jed Watson.
|
|
15
15
|
Licensed under the MIT License (MIT), see
|
|
16
16
|
http://jedwatson.github.io/classnames
|
|
17
|
-
*/var vs,bs=(ps||(ps=1,function(e){!function(){var t={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=r(e,a(n)))}return e}function a(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var a="";for(var o in e)t.call(e,o)&&e[o]&&(a=r(a,o));return a}function r(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):window.classNames=n}()}(gs)),gs.exports),ys=D(bs),ws={};function xs(){return vs||(vs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="chevron-left",n=[9001],a="f053",r="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z";e.definition={prefix:"fas",iconName:t,icon:[320,512,n,a,r]},e.faChevronLeft=e.definition,e.prefix="fas",e.iconName=t,e.width=320,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(ws)),ws}var ks,Ns=xs(),Ss={};function Ts(){return ks||(ks=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="chevron-right",n=[9002],a="f054",r="M311.1 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L243.2 256 73.9 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z";e.definition={prefix:"fas",iconName:t,icon:[320,512,n,a,r]},e.faChevronRight=e.definition,e.prefix="fas",e.iconName=t,e.width=320,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(Ss)),Ss}var Cs=Ts(),_s={table:"Table-module_table__6A8SM",sortable:"Table-module_sortable__J6kyp",sortArrow:"Table-module_sortArrow__Nrncn",asc:"Table-module_asc__tJDI9",desc:"Table-module_desc__fjVRY",isRowSelected:"Table-module_isRowSelected__UhIAJ",isRowDisabled:"Table-module_isRowDisabled__sz3NJ",loadingSpinner:"Table-module_loadingSpinner__SSjMK",pagination:"Table-module_pagination__VXgcO"},Rs="Button-module_button__Ed1ge",Ps="Button-module_noIcon__Uzjvv",Ms="Button-module_noBox__mLreC",Is="Button-module_customIcon__-slpC",Es="Button-module_iconWithText__DQRkr",js="Button-module_default__HhXlQ",Fs="Button-module_outline__Flf4r",As="Button-module_float__4marx",Ds="Button-module_primary__xByv0",Os="Button-module_secondary__D0K-F",Bs="Button-module_danger__5-vIq",Ls="Button-module_grouped__j8KwB";const zs=a.forwardRef(function({disabled:n=!1,kind:a="default",type:r="button",icon:o,iconNode:i,children:s,grouped:l,onClick:c,id:f,className:u,form:d,noBox:h,autoFocus:m,...p},g){return t("button",{...p,id:f,ref:g,type:r,"data-testid":p["data-testid"],disabled:n,onClick:c,form:d,autoFocus:m,"aria-label":p["aria-label"],className:ys(Rs,l?Ls:"",$s(a),u,h&&Ms,i&&Is,!o&&!i&&Ps),children:[o?e(gr,{icon:o,className:s?Es:""}):null,i,s]})});function $s(e){switch(e){case"default":return js;case"primary":return Ds;case"secondary":return Os;case"danger":return Bs;case"outline":return Fs;case"float":return As;default:throw Error(`Unsupported kind ${e}`)}}function Vs({sortByDirection:a,sortBy:r,updateSortParams:o,table:i,tableBodyRef:s,className:c,isLoading:f,itemsPerPage:u}){const d=a&&r&&o,[h,m]=l(0);return f?e("div",{className:_s.loadingSpinner}):t(n,{children:[t("table",{className:lo(_s.table,{[c||""]:c}),"data-testid":"table-ui",children:[e("thead",{children:e("tr",{children:i.headRow.map(({sortable:t,label:n,name:s,...l},c)=>t&&"not-filled"!==i.type&&d?w("th",{...l,key:c,className:_s.sortable,onClick:()=>o(s)},n,e("span",{className:lo(_s.sortArrow,{[_s[a]]:r===s})})):e("th",{...l,children:n},c))})}),e("tbody",{ref:s,children:"not-filled"===i.type?e("tr",{className:null==i?void 0:i.bodyClassName,children:e("td",{colSpan:i.headRow.length,children:i.value})}):Hs(i.bodyRows,h,u).map(({cells:t,isRowSelected:n,isRowDisabled:a,className:r,...o})=>{const i=Math.random();return e("tr",{...o,className:lo(r,{[_s.isRowSelected]:n,[_s.isRowDisabled]:a}),children:t&&t.map(({style:t,value:n,...a},r)=>e("td",{style:t,...a,children:n},i+r))},i)})})]}),e(Ws,{bodyRows:"filled"===i.type?i.bodyRows:void 0,itemsPerPage:u,currPage:h,setCurrPage:m})]})}function Hs(e,t,n){return n?e.slice(t*n,n*(t+1)):e}function Ws({itemsPerPage:n,currPage:a,setCurrPage:r,bodyRows:o}){if(!n)return null;const i=!!o&&Hs(o,a+1,n).length>0,s=!!o&&Hs(o,a-1,n).length>0;return t("nav",{className:_s.pagination,children:[e(zs,{"aria-label":"Previous Page",disabled:!s,kind:"float",icon:Ns.faChevronLeft,onClick:()=>r(a-1)}),e(zs,{disabled:!i,"aria-label":"Next Page",kind:"float",icon:Cs.faChevronRight,onClick:()=>r(a+1)})]})}function Us({numTicks:t,sampleRate:n,units:a,tableBodyRef:r,palette:o}){const i=Lr(t,n,a),s=i.format(t,n),l=f((e,t,r)=>{var l;const c=null===(l=r.target.closest("tr"))||void 0===l?void 0:l.dataset.row;if(!c)return void t();const[f,u,...d]=c.split(";");switch(f){case"single":{const[t,r]=d,o=i.format(parseInt(t,10),n),l=i.format(parseInt(r,10),n),c=s.split(" "),f="<"===c[0]?c[1]:c[0],h=o.split(" "),m="<"===h[0]?h[1]:h[0],p=l.split(" "),g="<"===p[0]?p[1]:p[0];e({title:{text:u,diff:{text:"",color:""}},tooltipData:[{units:a,self:`${o}(${(parseFloat(m)/parseFloat(f)*100).toFixed(2)}%)`,total:`${l}(${(parseFloat(g)/parseFloat(f)*100).toFixed(2)}%)`,tooltipType:"table"}]});break}case"double":{const[t,r,s,l]=d,c=Zi({formatter:i,sampleRate:n,totalLeft:parseInt(t,10),leftTicks:parseInt(r,10),totalRight:parseInt(s,10),rightTicks:parseInt(l,10),title:u,units:a},o);e({title:c.title,tooltipData:c.tooltipData});break}}},[r,t,i,n]);return e(Qi,{dataSourceRef:r,shouldShowTitle:!1,clickInfoSide:"left",setTooltipContent:l})}const Qs=e=>e||0;function Js(e,t,n,a){const r=t;return r.type="single",r.self=Qs(r.self)+e.getBarSelf(n,a),r.total=Qs(r.total)+e.getBarTotal(n,a),r}function Xs(e,t,n,a,r,o){const i=t;return i.type="double",i.self=Qs(i.self)+e.getBarSelf(n,a),i.total=Qs(i.total)+e.getBarTotal(n,a),i.selfLeft=Qs(i.selfLeft)+e.getBarSelfLeft(n,a),i.selfRght=Qs(i.selfRght)+e.getBarSelfRght(n,a),i.selfDiff=Qs(i.selfDiff)+e.getBarSelfDiff(n,a),i.totalLeft=Qs(i.totalLeft)+e.getBarTotalLeft(n,a),i.totalRght=Qs(i.totalRght)+e.getBarTotalRght(n,a),i.totalDiff=Qs(i.totalDiff)+e.getBarTotalDiff(n,a),i.leftTicks=r,i.rightTicks=o,i}function Ys(e,t,n){const a=148-e/t*148,r=n.alpha(1);return{backgroundImage:`linear-gradient(${r}, ${r})`,backgroundPosition:`-${a}px 0px`,backgroundRepeat:"no-repeat"}}const Zs=({flamebearer:n,sortBy:a,sortByDirection:r,isDoubles:o,fitMode:i,handleTableItemClick:s,highlightQuery:l,palette:c,selectedItem:f,messages:u})=>{const{numTicks:d,maxSelf:h,sampleRate:m,spyName:p,units:g}=n,v=function(e){if(!e)return[];const{names:t,levels:n,format:a}=e,r="double"!==a?Tr:Cr,o=new Map;for(let i=0;i<n.length;i++){const s=n[i];for(let n=0;n<s.length;n+=r.jStep){const i=t[r.getBarName(s,n)];o.has(i)||o.set(i,{name:i||"<empty>",self:0,total:0});const l=o.get(i);if(!l)break;"single"===a?Js(Tr,l,s,n):Xs(Cr,l,s,n,e.leftTicks,e.rightTicks)}}return Array.from(o.values())}(n).sort((e,t)=>t.total-e.total),b="asc"===r?1:-1;let y;if("name"===a)y=v.sort((e,t)=>b*e[a].localeCompare(t[a]));else switch(a){case"total":case"self":y=v.sort((e,t)=>b*(e[a]-t[a]));break;case"baseline":y=v.sort((e,t)=>b*(e.totalLeft/e.leftTicks-t.totalLeft/t.leftTicks));break;case"comparison":y=v.sort((e,t)=>b*(e.totalRght/e.rightTicks-t.totalRght/t.rightTicks));break;case"diff":y=v.sort((e,t)=>{const n=Br(Or(e.totalLeft/e.leftTicks),Or(e.totalRght/e.rightTicks)),a=Br(Or(t.totalLeft/t.leftTicks),Or(t.totalRght/t.rightTicks));return b*(n-a)});break;default:y=v}const w=Lr(d,m,g),x=e=>!!f.isJust&&e===f.value,k=(n,a)=>{return t("button",{className:"table-item-button",children:[e("span",{className:"color-reference",style:a}),e("div",{className:"symbol-name",style:(r=i,r===Wr?{direction:"rtl",overflow:"hidden",textOverflow:"ellipsis"}:{overflow:"hidden",textOverflow:"ellipsis"}),children:n.name})]});var r},N=y.filter(e=>!l||Gr(l,e.name)).map(e=>{const t=Yr(p,e.name),n=o?Jr:Zr(c,t),a={backgroundColor:n.rgb().toString()};return"double"===e.type?((e,t)=>{const n=Or(e.totalLeft/e.leftTicks),a=Or(e.totalRght/e.rightTicks),r=Br(n,a);let o="";r>0?o=c.badColor.rgb().string():r<0&&(o=c.goodColor.rgb().string());let i="";return e.totalLeft&&r!==1/0?e.totalRght?r>0?i=`(+${r.toFixed(2)}%)`:r<0&&(i=`(${r.toFixed(2)}%)`):i=u.diffRemoved:i=u.diffNew,{"data-row":`${e.type};${e.name};${e.totalLeft};${e.leftTicks};${e.totalRght};${e.rightTicks}`,isRowSelected:x(e.name),onClick:()=>s(e),cells:[{value:k(e,t)},{value:`${n} %`},{value:`${a} %`},{value:i,style:{color:o}}]}})(e,a):((e,t,n)=>({"data-row":`${e.type};${e.name};${e.self};${e.total}`,isRowSelected:x(e.name),onClick:()=>s(e),cells:[{value:k(e,n)},{value:w.format(e.self,m),style:Ys(e.self,h,t)},{value:w.format(e.total,m),style:Ys(e.total,d,t)}]}))(e,n,a)});return N.length>0?{bodyRows:N,type:"filled"}:{value:e("div",{className:"unsupported-format",children:u.noItemsFound}),type:"not-filled"}};function Ks({tableBodyRef:t,flamebearer:n,isDoubles:r,fitMode:o,handleTableItemClick:i,highlightQuery:s,selectedItem:c,palette:f}){const u=Ui(),d=a.useMemo(()=>r?[{sortable:1,name:"name",label:u.location},{sortable:1,name:"baseline",label:u.baseline,default:!0},{sortable:1,name:"comparison",label:u.comparison},{sortable:1,name:"diff",label:u.diff}]:[{sortable:1,name:"name",label:u.location},{sortable:1,name:"self",label:u.self,default:!0},{sortable:1,name:"total",label:u.total}],[u,r]),h=(e=>{const t=e.filter(e=>null==e?void 0:e.default)[0]||e[0],[n,a]=l(t.name),[r,o]=l("desc");return{sortBy:n,sortByDirection:r,updateSortParams:e=>{let t=r;t=n===e?"asc"===t?"desc":"asc":"desc",a(e),o(t)}}})(d),m={headRow:d,...Zs({flamebearer:n,sortBy:h.sortBy,sortByDirection:h.sortByDirection,isDoubles:r,fitMode:o,handleTableItemClick:i,highlightQuery:s,palette:f,selectedItem:c,messages:u})};return e(Vs,{...h,tableBodyRef:t,table:m,className:ys("flamegraph-table",{"flamegraph-table-doubles":r})})}const Gs=a.memo(function({flamebearer:n,fitMode:a,handleTableItemClick:r,highlightQuery:o,palette:i,selectedItem:s}){const l=c(null);return t("div",{"data-testid":"table-view",children:[e(Ks,{tableBodyRef:l,flamebearer:n,isDoubles:"double"===n.format,fitMode:a,highlightQuery:o,handleTableItemClick:r,palette:i,selectedItem:s}),e(Us,{tableBodyRef:l,numTicks:n.numTicks,sampleRate:n.sampleRate,units:n.units,palette:i})]})});var qs,el,tl={},nl={};function al(){return qs||(qs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="arrow-rotate-left",n=[8634,"arrow-left-rotate","arrow-rotate-back","arrow-rotate-backward","undo"],a="f0e2",r="M256 64c-56.8 0-107.9 24.7-143.1 64l47.1 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 192c-17.7 0-32-14.3-32-32L0 32C0 14.3 14.3 0 32 0S64 14.3 64 32l0 54.7C110.9 33.6 179.5 0 256 0 397.4 0 512 114.6 512 256S397.4 512 256 512c-87 0-163.9-43.4-210.1-109.7-10.1-14.5-6.6-34.4 7.9-44.6s34.4-6.6 44.6 7.9c34.8 49.8 92.4 82.3 157.6 82.3 106 0 192-86 192-192S362 64 256 64z";e.definition={prefix:"fas",iconName:t,icon:[512,512,n,a,r]},e.faArrowRotateLeft=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(nl)),nl}function rl(){return el||(el=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=al();e.definition={prefix:t.prefix,iconName:t.iconName,icon:[t.width,t.height,t.aliases,t.unicode,t.svgPathData]},e.faUndo=e.definition,e.prefix=t.prefix,e.iconName=t.iconName,e.width=t.width,e.height=t.height,e.ligatures=t.aliases,e.unicode=t.unicode,e.svgPathData=t.svgPathData,e.aliases=t.aliases}(tl)),tl}var ol,il,sl=rl(),ll={},cl={};function fl(){return ol||(ol=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="diagram-project",n=["project-diagram"],a="f542",r="M0 80C0 53.5 21.5 32 48 32l96 0c26.5 0 48 21.5 48 48l0 16 128 0 0-16c0-26.5 21.5-48 48-48l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-16-128 0 0 16c0 7.3-1.7 14.3-4.6 20.5l68.6 91.5 80 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-96c0-7.3 1.7-14.3 4.6-20.5L128 224 48 224c-26.5 0-48-21.5-48-48L0 80z";e.definition={prefix:"fas",iconName:t,icon:[512,512,n,a,r]},e.faDiagramProject=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(cl)),cl}function ul(){return il||(il=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=fl();e.definition={prefix:t.prefix,iconName:t.iconName,icon:[t.width,t.height,t.aliases,t.unicode,t.svgPathData]},e.faProjectDiagram=e.definition,e.prefix=t.prefix,e.iconName=t.iconName,e.width=t.width,e.height=t.height,e.ligatures=t.aliases,e.unicode=t.unicode,e.svgPathData=t.svgPathData,e.aliases=t.aliases}(ll)),ll}var dl,hl,ml=ul(),pl={},gl={};function vl(){return dl||(dl=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="ellipsis-vertical",n=["ellipsis-v"],a="f142",r="M64 144a56 56 0 1 1 0-112 56 56 0 1 1 0 112zm0 224c30.9 0 56 25.1 56 56s-25.1 56-56 56-56-25.1-56-56 25.1-56 56-56zm56-112c0 30.9-25.1 56-56 56s-56-25.1-56-56 25.1-56 56-56 56 25.1 56 56z";e.definition={prefix:"fas",iconName:t,icon:[128,512,n,a,r]},e.faEllipsisVertical=e.definition,e.prefix="fas",e.iconName=t,e.width=128,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(gl)),gl}function bl(){return hl||(hl=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=vl();e.definition={prefix:t.prefix,iconName:t.iconName,icon:[t.width,t.height,t.aliases,t.unicode,t.svgPathData]},e.faEllipsisV=e.definition,e.prefix=t.prefix,e.iconName=t.iconName,e.width=t.width,e.height=t.height,e.ligatures=t.aliases,e.unicode=t.unicode,e.svgPathData=t.svgPathData,e.aliases=t.aliases}(pl)),pl}var yl=bl();function wl(e){if(null!=e&&!1!==e){if("string"==typeof e||"number"==typeof e)return String(e);if(Array.isArray(e)){const t=e.map(e=>wl(e)).filter(e=>!!e);return t.length?t.join(" "):void 0}return a.isValidElement(e)?wl(e.props.children):void 0}}const xl=({placement:t,title:a,content:r,children:o})=>{const i=wl(null!=a?a:r);return i?e("span",{title:i,children:o}):e(n,{children:o})};var kl,Nl={};function Sl(){return kl||(kl=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="link",n=[128279,"chain"],a="f0c1",r="M419.5 96c-16.6 0-32.7 4.5-46.8 12.7-15.8-16-34.2-29.4-54.5-39.5 28.2-24 64.1-37.2 101.3-37.2 86.4 0 156.5 70 156.5 156.5 0 41.5-16.5 81.3-45.8 110.6l-71.1 71.1c-29.3 29.3-69.1 45.8-110.6 45.8-86.4 0-156.5-70-156.5-156.5 0-1.5 0-3 .1-4.5 .5-17.7 15.2-31.6 32.9-31.1s31.6 15.2 31.1 32.9c0 .9 0 1.8 0 2.6 0 51.1 41.4 92.5 92.5 92.5 24.5 0 48-9.7 65.4-27.1l71.1-71.1c17.3-17.3 27.1-40.9 27.1-65.4 0-51.1-41.4-92.5-92.5-92.5zM275.2 173.3c-1.9-.8-3.8-1.9-5.5-3.1-12.6-6.5-27-10.2-42.1-10.2-24.5 0-48 9.7-65.4 27.1L91.1 258.2c-17.3 17.3-27.1 40.9-27.1 65.4 0 51.1 41.4 92.5 92.5 92.5 16.5 0 32.6-4.4 46.7-12.6 15.8 16 34.2 29.4 54.6 39.5-28.2 23.9-64 37.2-101.3 37.2-86.4 0-156.5-70-156.5-156.5 0-41.5 16.5-81.3 45.8-110.6l71.1-71.1c29.3-29.3 69.1-45.8 110.6-45.8 86.6 0 156.5 70.6 156.5 156.9 0 1.3 0 2.6 0 3.9-.4 17.7-15.1 31.6-32.8 31.2s-31.6-15.1-31.2-32.8c0-.8 0-1.5 0-2.3 0-33.7-18-63.3-44.8-79.6z";e.definition={prefix:"fas",iconName:t,icon:[576,512,n,a,r]},e.faLink=e.definition,e.prefix="fas",e.iconName=t,e.width=576,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(Nl)),Nl}var Tl=Sl(),Cl="Input-module_input__ulQdV";const _l=a.forwardRef(({testId:t,className:n,type:a,name:r,placeholder:o,minLength:i=0,debounceTimeout:s=100,onChange:l,value:c,htmlId:f},u)=>e(E,{inputRef:u,"data-testid":t,className:`${Cl} ${n||""}`,type:a,name:r,placeholder:o,minLength:i,debounceTimeout:s,onChange:l,value:c,id:f}));var Rl="SharedQueryInput-module_wrapper__XRxrd",Pl="SharedQueryInput-module_search__XlzRv",Ml="SharedQueryInput-module_search-synced__J4T4b",Il="SharedQueryInput-module_searchWithSync__ryuQa",El="SharedQueryInput-module_icon__Aq0Hv",jl="SharedQueryInput-module_checked__oRvod",Fl="SharedQueryInput-module_sync__0IO2N",Al="SharedQueryInput-module_syncSelected__hstBI";const Dl=({onHighlightChange:n,highlightQuery:a,sharedQuery:r,width:i})=>{const s=Ui(),l=(e=>{const t=c();return d(()=>{t.current=e},[e]),t.current})(null==r?void 0:r.syncEnabled);d(()=>{"string"==typeof(null==r?void 0:r.searchQuery)&&(r.syncEnabled&&n(r.searchQuery),!r.syncEnabled&&l&&l!==(null==r?void 0:r.id)&&n(""))},[null==r?void 0:r.searchQuery,null==r?void 0:r.syncEnabled]);const f=o(()=>r&&r.syncEnabled?r.searchQuery||"":a,[r,a]),u=o(()=>`${r?Il:Pl} ${(null==r?void 0:r.syncEnabled)?Ml:""}`,[r]),h=(null==r?void 0:r.syncEnabled)?s.unsyncSearchBars:s.syncSearchBars;return t("div",{className:Rl,style:{width:i},children:[e(_l,{testId:"flamegraph-search",className:u,type:"search",name:"flamegraph-search",placeholder:s.searchPlaceholder,minLength:2,debounceTimeout:100,onChange:e=>{n(e.target.value),r&&r.syncEnabled&&r.onQueryChange(e.target.value)},value:f}),r?e(xl,{placement:"top",title:h,children:e("button",{className:r.syncEnabled?Al:Fl,onClick:()=>{const e=!(null==r?void 0:r.syncEnabled)&&(null==r?void 0:r.id);null==r||r.toggleSync(e),e?null==r||r.onQueryChange(a):(n(a),null==r||r.onQueryChange(""))},children:e(gr,{className:`${r.syncEnabled?jl:El}`,icon:Tl.faLink})})}):null]})};var Ol="DiffLegend-module_flamegraph-legend__Cywr1",Bl="DiffLegend-module_flamegraph-legend-list__swdXj",Ll="DiffLegend-module_flamegraph-legend-item__0P-6g";function zl(n){const{palette:a,showMode:r}=n,o=function(e){switch(e){case"large":return[-100,-80,-60,-40,-20,-10,0,10,20,40,60,80,100];case"small":return[-100,-40,-20,0,20,40,100];default:throw new Error(`Unsupported ${e}`)}}(r),i=Kr(a);return e("div",{"data-testid":"flamegraph-legend",className:`${Ol} ${Bl}`,children:o.map(e=>t("div",{className:Ll,style:{backgroundColor:i(e).rgb().toString()},children:[e>0?"+":"",e,"%"]},e))})}function $l(){return e("svg",{version:"1.1",id:"Capa_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"12px",height:"12px",viewBox:"0 0 405.272 405.272",children:e("g",{children:e("path",{d:"M393.401,124.425L179.603,338.208c-15.832,15.835-41.514,15.835-57.361,0L11.878,227.836\n\n\t\tc-15.838-15.835-15.838-41.52,0-57.358c15.841-15.841,41.521-15.841,57.355-0.006l81.698,81.699L336.037,67.064\n\n\t\tc15.841-15.841,41.523-15.829,57.358,0C409.23,82.902,409.23,108.578,393.401,124.425z"})})})}var Vl="Dropdown-module_dropdownMenu__tbN8r",Hl="Dropdown-module_dropdownMenuButton__Xy8M4";function Wl({id:n,children:a,className:r,disabled:o,value:i,label:s,onItemClick:l,overflow:c,position:f,direction:u,align:d,viewScroll:h,arrow:m,menuButtonClassName:p="",ariaLabel:g,portal:v,...b}){const y=b.menuButton||e(Ql,{"aria-label":g,className:`${Hl} ${p}`,disabled:o,type:"button",children:i||s});return t(Ti,{id:n,"aria-label":g,className:ys(r,Vl),"data-testid":b["data-testid"],onItemClick:l,overflow:c,position:f,direction:u,align:d,viewScroll:h,arrow:m,menuButton:y,portal:v,children:[e(Pi,{children:s}),a]})}const Ul=Ri,Ql=ii;var Jl="DiffLegendPaletteDropdown-module_container__h8Tts",Xl="DiffLegendPaletteDropdown-module_triggerButton__oezA6",Yl="DiffLegendPaletteDropdown-module_dropdownArrow__-Lu0w",Zl="DiffLegendPaletteDropdown-module_menuItem__5iWry",Kl="DiffLegendPaletteDropdown-module_menuItemText__a-tt0";const Gl=[Di,Oi],ql=n=>{const{palette:a=Di,onChange:r}=n,o=Ui(),i=e=>"Default"===e.name?o.paletteDefaultName:"Color Blind"===e.name?o.paletteColorBlindName:e.name,s=e=>"Default"===e.name?o.paletteDefaultDesc:"Color Blind"===e.name?o.paletteColorBlindDesc:"";return e("div",{className:Jl,children:e(Wl,{label:o.diffLegendSelectPalette,align:"end",menuButton:t(Ql,{className:ys(Hl,Xl),children:[e(zl,{palette:a,showMode:"small"}),e("span",{className:Yl,children:"▼"})]}),onItemClick:e=>{e.value&&r(e.value)},children:Gl.map(n=>e(Ul,{value:n,children:t("div",{className:Zl,children:[t("span",{className:Kl,children:[i(n)," ",s(n)]}),n.name===a.name&&e($l,{})]})},n.name))})})};var ec={navbar:"Toolbar-module_navbar__XN6xZ",searchWrapper:"Toolbar-module_searchWrapper__k--ua",rightSection:"Toolbar-module_rightSection__if7LO",viewType:"Toolbar-module_viewType__AKARg",toggleViewButton:"Toolbar-module_toggleViewButton__OQ9-U",fitModeButton:"Toolbar-module_fitModeButton__jOxve",selected:"Toolbar-module_selected__vwBQt",collapseNodeButton:"Toolbar-module_collapseNodeButton__bLdiw",resetViewButton:"Toolbar-module_resetViewButton__y2ebV",divider:"Toolbar-module_divider__dG6pE",itemsContainer:"Toolbar-module_itemsContainer__gSTMF",item:"Toolbar-module_item__o-hKc",moreButton:"Toolbar-module_moreButton__rhOdT",active:"Toolbar-module_active__36Kt-",navbarCollapsedItems:"Toolbar-module_navbarCollapsedItems__vojhw"};const tc=$.bind(ec),nc=(e,t,n)=>{const a=0===t?e-360-5:e-360-16-5;let r=0,o=0;return n.reverse().forEach(e=>{o+=e,a<=o&&(r+=1)}),r},ac=()=>e("div",{className:ec.divider}),rc=y(({view:a,handleSearchChange:r,highlightQuery:o,isFlamegraphDirty:i,reset:s,updateFitMode:f,fitMode:d,updateView:h,selectedNode:m,onFocusOnSubtree:p,flamegraphType:g,enableChangingDisplay:v=!0,sharedQuery:b,ExportData:y,palette:w,setPalette:k})=>{const N=c(null),S=Ui(),T="double"===g&&w&&k,C=[{el:t(n,{children:[e(sc,{fitMode:d,updateFitMode:f}),e(ac,{})]}),width:93},{el:e(ic,{isFlamegraphDirty:i,reset:s}),width:44},{el:t(n,{children:[e(oc,{selectedNode:m,onFocusOnSubtree:p}),e(ac,{})]}),width:49},v?{el:e(cc,{flamegraphType:g,view:a,updateView:h}),width:44*("single"===g?5:3)}:null,x(y)?{el:t(n,{children:[e(ac,{}),y]}),width:49}:null].filter(e=>null!==e),R=C.reduce((e,t)=>[...e,t.width],[]),{isCollapsed:P,collapsedItemsNumber:M,handleMoreClick:I}=((e,t)=>{const[n,a]=l(!0),[r,o]=l(0);return u(()=>{if(e.current){const{width:n}=e.current.getBoundingClientRect(),a=nc(n,r,t);o(a)}},[e.current,t]),_(e,e=>{const{width:n}=e.target.getBoundingClientRect(),i=nc(n,r,t);o(i),a(!0)}),{isCollapsed:n,handleMoreClick:()=>{a(e=>!e)},collapsedItemsNumber:r}})(N,R),E=C.reduce((e,t,n)=>(n<M?e.hidden.push(t):e.visible.push(t),e),{visible:[],hidden:[]});return e("div",{role:"toolbar",ref:N,children:t("div",{className:ec.navbar,children:[e("div",{className:ec.searchWrapper,children:e(Dl,{width:360,onHighlightChange:r,highlightQuery:o,sharedQuery:b})}),t("div",{className:ec.rightSection,children:[T&&t(n,{children:[e(ql,{palette:w,onChange:k}),e(ac,{})]}),t("div",{className:ec.itemsContainer,children:[E.visible.map((t,n)=>e("div",{className:ec.item,style:{width:t.width},children:t.el},n)),0!==M&&e(xl,{placement:"top",title:S.more,children:e("button",{onClick:I,className:tc({[ec.moreButton]:!0,[ec.active]:!P}),children:e(gr,{icon:yl.faEllipsisV})})})]})]}),!P&&e("div",{className:ec.navbarCollapsedItems,children:E.hidden.map((t,n)=>e("div",{className:ec.item,style:{width:t.width},children:t.el},n))})]})})});function oc({onFocusOnSubtree:t,selectedNode:n}){const a=Ui(),r=n.mapOr(()=>{},e=>()=>t(e.i,e.j));return e(xl,{placement:"top",title:a.collapseNodesAbove,children:e("div",{children:e(zs,{disabled:!n.isJust,onClick:r,className:ec.collapseNodeButton,"aria-label":a.collapseNodesAbove,children:e(gr,{icon:jo.faCompressAlt})})})})}function ic({isFlamegraphDirty:t,reset:n}){const a=Ui();return e(xl,{placement:"top",title:a.resetView,children:e("span",{children:e(zs,{id:"reset",disabled:!t,onClick:n,className:ec.resetViewButton,"aria-label":a.resetView,children:e(gr,{icon:sl.faUndo})})})})}function sc({fitMode:a,updateFitMode:r}){const o=Ui(),i=e=>a===e;return t(n,{children:[e(xl,{placement:"top",title:o.headFirst,children:e(zs,{onClick:()=>r("HEAD"),className:tc({[ec.fitModeButton]:!0,[ec.selected]:i("HEAD")}),children:e(os,{})})}),e(xl,{placement:"top",title:o.tailFirst,children:e(zs,{onClick:()=>r("TAIL"),className:tc({[ec.fitModeButton]:!0,[ec.selected]:i("TAIL")}),children:e(is,{})})})]})}const lc=(t,n)=>"single"===t?[{label:n.viewTable,value:"table",Icon:ts},{label:n.viewTableAndFlamegraph,value:"both",Icon:ns},{label:n.viewFlamegraph,value:"flamegraph",Icon:as},{label:n.viewSandwich,value:"sandwich",Icon:rs},{label:n.viewGraphviz,value:"graphviz",Icon:()=>e(gr,{icon:ml.faProjectDiagram})}]:[{label:n.viewTable,value:"table",Icon:ts},{label:n.viewTableAndFlamegraph,value:"both",Icon:ns},{label:n.viewFlamegraph,value:"flamegraph",Icon:as}];function cc({view:t,updateView:n,flamegraphType:a}){const r=Ui(),o=lc(a,r);return e("div",{className:ec.viewType,children:o.map(({label:a,value:r,Icon:o})=>e(xl,{placement:"top",title:a,children:e(zs,{"data-testid":r,onClick:()=>n(r),className:tc({[ec.toggleViewButton]:!0,selected:t===r}),children:e(o,{})})},r))})}function fc(e,t){const n={},a={};let r={name:"total",children:[],self:[],total:[],key:"/total"};return(t?[e,t]:[e]).forEach((e,t)=>{var o,i;for(let s=0;s<e.levels.length;s+=1)for(let l=0;l<e.levels[s].length;l+=4){const c=[t,s,l].join("/"),f=e.names[e.levels[s][l+3]],u=e.levels[s][l+0],d=e.levels[s][l+1],h=e.levels[s][l+2];let m="";if(0!==s){const n=s-1,r=e.levels[n];for(let e=0;e<r.length;e+=4){const o=r[e+0],i=r[e+1];if(u>=o&&u<o+i){const r=[t,n,e].join("/");m=a[r].key;break}}}const p=[m||"",f].join("/"),g=!n[p];n[p]||(n[p]={name:f,children:[],self:[],total:[],key:p});const v=n[p];(o=v.total)[t]||(o[t]=0),v.total[t]+=d,(i=v.self)[t]||(i[t]=0),v.self[t]+=h,a[c]=v,m&&g&&n[m].children.push(v),0===s&&(r=v)}}),r}const uc=e=>{const t={maxSelf:100,names:[],levels:[]},n=(e,a,r)=>{var o;const{name:i,children:s,self:l,total:c,offset:f}=e;t.names.push(i),(o=t.levels)[a]||(o[a]=[]),t.maxSelf=Math.max(t.maxSelf,l[0]||0),t.levels[a]=t.levels[a].concat([r,c[0]||0,l[0]||0,t.names.length-1]);for(let e=0;e<s.length;e+=1){r+=n(s[e],a+1,r)}return f||c[0]||0};return n(e,0,0),t};function dc(e){const t=new Map;for(let n=0;n<e.children.length;n+=1)t.has(e.children[n].name)||t.set(e.children[n].name,e.children[n]);for(let n=0;n<e.children.length;n+=1){const a=e.children[n],r=t.get(e.children[n].name);r&&r!==a&&(r.total[0]+=a.total[0],r.self[0]+=a.self[0],r.children=r.children.concat(a.children))}e.children=Array.from(t.values());for(let t=0;t<e.children.length;t+=1)dc(e.children[t])}function hc(e,t){const n=function(e,t){const n=fc(e),a={format:"single",numTicks:0,maxSelf:100,sampleRate:100,names:[],levels:[],units:e.units,spyName:e.spyName},r={name:t,total:[],self:[0],children:[]},o=e=>{e.name===t&&(a.numTicks+=e.total[0],r.total=[a.numTicks],r.children=r.children.concat(e.children));for(let t=0;t<e.children.length;t+=1)o(e.children[t])};return o(n),dc(r),{...a,...uc(r)}}(JSON.parse(JSON.stringify(e)),t);return n}function mc(e,t){const n=function(e,t){const n=fc(e),a={format:"single",maxSelf:100,sampleRate:100,numTicks:0,names:[],levels:[],units:e.units,spyName:e.spyName},r=[],o=[],i={name:t,total:[0],self:[0],children:[]},s=(e,n=[])=>{const i=n.concat([{...e,children:[]}]);e.name===t&&(o.push(i),r.push(e.total[0]),a.numTicks+=e.total[0]);for(let t=0;t<e.children.length;t+=1)s(e.children[t],i)};s(n),o.forEach((e,t)=>{i.children.push(((e,t)=>{const n={};let a=n;return e.forEach(({name:e,...n})=>{const r={name:e,...n,total:[t]};a.children=[r],a=r}),n.children[0]})(e.reverse(),r[t]))}),dc(i);const l=uc(i);return l.levels=l.levels.reverse().slice(0,-1),{...a,...l}}(JSON.parse(JSON.stringify(e)),t);return n}var pc={flamegraphContainer:"FlamegraphRenderer-module_flamegraphContainer__-7FRV",createdBy:"FlamegraphRenderer-module_createdBy__rHAOT",horizontal:"FlamegraphRenderer-module_horizontal__zs7--",vertical:"FlamegraphRenderer-module_vertical__fRcHg",panesWrapper:"FlamegraphRenderer-module_panesWrapper__L-mlA",tablePane:"FlamegraphRenderer-module_tablePane__Gin7Y",sandwichPane:"FlamegraphRenderer-module_sandwichPane__IEOyR",sandwichPaneInfo:"FlamegraphRenderer-module_sandwichPaneInfo__5hT4a",arrow:"FlamegraphRenderer-module_arrow__dPzpE",sandwichTop:"FlamegraphRenderer-module_sandwichTop__7N0ZY",sandwichBottom:"FlamegraphRenderer-module_sandwichBottom__Dc64g",name:"FlamegraphRenderer-module_name__XRbN9"};function gc(e){const t=[];return Object.keys(e).forEach(n=>{var a;t.push(`${n}="${a=String(e[n]||""),a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`)}),`[${t.join(" ")}]`}function vc(e,t){return`${(100*e/t).toFixed(2)}%`}function bc(e,t){let n,a,r,o;t?(n=.1,a=.93):(n=1,a=.7),e=Math.max(-1,Math.min(1,e)),Math.abs(e)<.2&&(n*=Math.abs(e)/.2),e>0&&(e**=1-.7),e<0&&(e=-((-e)**(1-.7))),e<0?(o=a,r=a*(1+n*e)):(r=a,o=a*(1-n*e));const i=a*(1-n);return`#${Math.floor(255*r).toString(16).padStart(2,"0")}${Math.floor(255*o).toString(16).padStart(2,"0")}${Math.floor(255*i).toString(16).padStart(2,"0")}`}function yc(e,t,n,a){const{self:r}=t,{total:o}=t,i=t.name.replace(/"/g,'\\"'),s=e(r),l=8+Math.ceil(16*Math.sqrt(r/n)),c=bc(o/a,!1),f=bc(o/a,!0),u=function(e,t,n,a,r){let o="";o=`${function(e){return e.replace(/.*\//,"")}(t)}\n`;const i=e(n);0!==n?o=`${o+i} (${vc(n,r)})`:o+="0";let s=i;a!==n&&(o+=0!==n?"\n":" ",s=e(a),o=`${o}of ${s} (${vc(a,r)})`);return o}(e,i,r,o,a),d={label:u,id:`node${t.index}`,fontsize:l,shape:"box",tooltip:`${i} (${s})`,color:c,fontcolor:"#000000",style:"filled",fontname:"",fillcolor:f};return`N${t.index} ${gc(d)}`}function wc(e){if("double"===e.metadata.format)return"diff flamegraphs are not supported";const t=fc(e.flamebearer),n=[],a=[];const[r,o,,i]=function e(t,n,a,r,o){return t.children.forEach(t=>{const[i,s]=e(t,n,a,r,o);n=Math.max(n,i),a=Math.max(a,s)}),n=Math.max(n,t.self[0]),a=Math.max(a,t.total[0]),r+=t.self[0],o+=t.total[0],[n,a,r,o]}(t,0,0,0,0),{sampleRate:s,units:l}=e.metadata,c=Lr(o,s,l),f=e=>c.format(e,s,!0);let u={};const d={};let h=0;function m(e,t){return-1===t.indexOf(e.name)&&(u[e.name]?(u[e.name].self+=e.self[0],u[e.name].total+=e.total[0]):(h+=1,u[e.name]={index:h,name:e.name,self:e.self[0],total:e.total[0],parents:[],children:[]})),e.children.forEach(n=>{const a=m(n,t.concat([e.name])),r=`${e.name}/${n.name}`;n.name!==e.name&&(d[r]?d[r].weight+=n.total[0]:d[r]={from:u[e.name],to:a,weight:n.total[0],residual:!1},a.parents.push(d[r]),u[e.name].children.push(d[r]))}),u[e.name]}t.children.forEach(e=>{m(e,[])});const p=.005*i,g=.001*i;function v(e,t){let n=0,a=t;if(e.forEach(e=>{e.weight>0&&(a+=Math.abs(e.weight))}),0!==a&&(e.forEach(e=>{const t=Math.abs(e.weight)/a;n+=-t*Math.log2(t)}),t>0)){const e=Math.abs(t)/a;n+=-e*Math.log2(e)}return n}Object.keys(u).forEach(e=>{u[e].total<p&&delete u[e]});const b={};Object.keys(u).forEach(e=>{b[u[e].name]=function(e){let t=0;return 0===e.parents.length?t+=1:t+=v(e.parents,0),0===e.children.length?t+=1:t+=v(e.children,e.self),t*e.total+e.self}(u[e])});const y=Object.values(u).sort((e,t)=>{const n=b[e.name],a=b[t.name];return n!==a?a-n:e.name!==t.name?e.name<t.name?-1:1:e.self!==t.self?a-n:e.name<t.name?-1:1}),w={};function x(e){const[t,n]=[e.from,e.to],a={},r=[n];for(;r.length>0;){const n=r.shift();for(let o=0;o<n.parents.length;o+=1){const i=n.parents[o];if(e!==i&&!a[i.from.name]){if(i.from===t)return!0;a[i.from.name]=!0,r.push(i.from)}}}return!1}return y.forEach(e=>{w[e.name]=e}),y.slice(80).forEach(e=>{delete w[e.name]}),function e(t,n){const a=!w[t.name];t.children.forEach(r=>{const o=!w[r.name];if(e(r,a?n:t),!o&&n&&a){const e=`${n.name}/${r.name}`;d[e]||(d[e]={from:u[n.name],to:u[r.name],weight:0,residual:!0}),d[e].weight+=r.total[0],d[e].residual=!0}})}(t,null),u=w,y.reverse().forEach(e=>{const t=e.parents.sort((e,t)=>t.weight-e.weight),n=[];for(let e=0;e<t.length;e+=1){const a=t[e];if(!a.residual)break;x(a)&&(n.push(a),delete d[`${a.from.name}/${a.to.name}`])}n.forEach(e=>{e.from.children=e.from.children.filter(t=>t.to!==e.to),e.to.parents=e.to.parents.filter(t=>t.from!==e.from)})}),Object.keys(d).forEach(e=>{const t=d[e];u[t.from.name]||delete d[e],u[t.to.name]||delete d[e],t.weight<g&&delete d[e]}),Object.keys(u).forEach(e=>{n.push(yc(f,u[e],r,o))}),Object.keys(d).forEach(e=>{a.push(function(e,t,n){const a=t.from.name.replace(/"/g,'\\"'),r=t.to.name.replace(/"/g,'\\"'),o=t.weight,i=e(t.weight),s=`${a} -> ${r} (${i})`,l={label:i,weight:1+100*o/n,penwidth:1+5*o/n,tooltip:s,labeltooltip:s,fontname:"",color:bc(o/n,!1),style:t.residual?"dotted":""};return`N${t.from.index} -> N${t.to.index} ${gc(l)}`}(f,d[e],o))}),`digraph "unnamed" {\n fontname= ""\n ${n.join("\n")}\n ${a.join("\n")}\n }`}var xc="GraphVizPanel-module_graphVizPane__B18cQ";const kc=()=>null;function Nc({flamebearer:t}){var n,a;const r=t,i=(null===(n=r.metadata)||void 0===n?void 0:n.format)&&(null===(a=r.flamebearer)||void 0===a?void 0:a.levels),s=`graphviz-pane-${(null==r?void 0:r.appName)||String((new Date).valueOf())}`,l=o(()=>wc(r),[JSON.stringify(r)]);return e("div",{className:xc,children:i?e(kc,{options:{zoom:!0,width:"150%",height:"100%",scale:1,useWorker:!1},dot:l}):e("div",{children:"NO DATA"})},s)}function Sc(e,t){const n=[...t];function a(e,t,n){for(const a of e){let e=0;for(let r=t;r<a.length;r+=n)a[r]-=e,e+=a[r]+a[r+1]}}return"double"===e?(a(n,0,7),a(n,3,7)):a(n,0,4),n}function Tc(e,t){const n=[...t];function a(e,t,n){for(const a of e){let e=0;for(let r=t;r<a.length;r+=n)a[r]+=e,e=a[r]+a[r+1]}}return"double"===e?(a(n,0,7),a(n,3,7)):a(n,0,4),n}function Cc(e){if(e.profile&&e.flamebearer&&console.warn("'profile' and 'flamebearer' properties are mutually exclusive. Please use profile if possible."),e.profile){const n={...e.profile,flamebearer:{...e.profile.flamebearer}};n.flamebearer.levels=JSON.parse(JSON.stringify(n.flamebearer.levels)),(t=n).flamebearer.levels=Tc(t.metadata.format,t.flamebearer.levels);const a={...n,...n.metadata,...n.flamebearer,flamebearer:void 0,metadata:void 0};return delete a.flamebearer,delete a.metadata,a}var t;if(e.flamebearer)return e.flamebearer;return{format:"single",names:[],units:"unknown",levels:[[]],spyName:"unknown",numTicks:0,sampleRate:0,maxSelf:0}}class _c extends k{constructor(n){super(n),this.resetFlamegraphState={focusedNode:N.nothing(),zoom:N.nothing()},this.initialFlamegraphState=this.resetFlamegraphState,this.calcNewConfigs=(e,t)=>{const n=this.state.flamegraphConfigs,a=(e,t,n)=>{const a=(e,t,n)=>e.names[_r(e.format).getBarName(e.levels[t],n)];if(n.isNothing)return!0;try{const r=n,o=a(e,r.value.i,r.value.j);return o===a(t,r.value.i,r.value.j)}catch{return!1}};a(e,t,this.state.flamegraphConfigs.zoom)||(n.zoom=this.resetFlamegraphState.zoom);return a(e,t,this.state.flamegraphConfigs.focusedNode)||(n.focusedNode=this.resetFlamegraphState.focusedNode),n},this.onSearchChange=e=>{this.setState({searchQuery:e})},this.isSameFlamebearer=(e,t)=>function(e,t){var n;return e.format===t.format&&e.numTicks===t.numTicks&&e.sampleRate===t.sampleRate&&e.units===t.units&&(null===(n=e.names)||void 0===n?void 0:n.length)===(null==t?void 0:t.names.length)&&e.levels.length===t.levels.length&&!!e.names.every((e,n)=>e===t.names[n])&&!!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){if(e[n].length!==t[n].length)return!1;for(let a=0;a<e[n].length;a++)if(e[n][a]!==t[n][a])return!1}return!0}(e.levels,t.levels)&&JSON.stringify({...e,levels:void 0,names:void 0})===JSON.stringify({...t,levels:void 0,names:void 0})}(e,t),this.onReset=()=>{this.setState({...this.state,flamegraphConfigs:{...this.state.flamegraphConfigs,...this.initialFlamegraphState},selectedItem:N.nothing()})},this.onFlamegraphZoom=e=>{e.isJust&&0===e.value.i&&0===e.value.j?this.onReset():this.setState({...this.state,flamegraphConfigs:{...this.state.flamegraphConfigs,zoom:e}})},this.onFocusOnNode=(e,t)=>{if(0===e&&0===t)return void this.onReset();let n={...this.state.flamegraphConfigs};const{zoom:a}=this.state.flamegraphConfigs;a.isJust&&a.value.i<=e&&(n={...n,zoom:this.initialFlamegraphState.zoom}),this.setState({...this.state,flamegraphConfigs:{...n,focusedNode:N.just({i:e,j:t})}})},this.setActiveItem=e=>{const{name:t}=e;this.state.selectedItem.isJust&&t===this.state.selectedItem.value?this.setState({selectedItem:N.nothing()}):this.setState({selectedItem:N.just(t)})},this.getHighlightQuery=()=>this.state.selectedItem.isJust?this.state.selectedItem.value:this.state.searchQuery,this.updateView=e=>{"sandwich"===e&&this.setState({searchQuery:"",flamegraphConfigs:this.resetFlamegraphState}),this.setState({view:e})},this.updateFlamegraphDirtiness=()=>{const e=this.isDirty();this.setState({isFlamegraphDirty:e})},this.updateFitMode=e=>{this.setState({fitMode:e})},this.isDirty=()=>this.state.selectedItem.isJust||JSON.stringify(this.initialFlamegraphState)!==JSON.stringify(this.state.flamegraphConfigs),this.handleSetPalette=e=>{this.setState({palette:e})},this.render=()=>{const n=e("div",{className:lo(pc.tablePane,"vertical"===this.state.panesOrientation?pc.vertical:pc.horizontal),children:e(Gs,{"data-testid":"table-view",flamebearer:this.state.flamebearer,fitMode:this.state.fitMode,highlightQuery:this.state.searchQuery,selectedItem:this.state.selectedItem,handleTableItemClick:this.setActiveItem,palette:this.state.palette})},"table-pane"),a=this.shouldShowToolbar(),r=e(ms,{showCredit:this.props.showCredit,flamebearer:this.state.flamebearer,highlightQuery:this.getHighlightQuery(),setActiveItem:this.setActiveItem,selectedItem:this.state.selectedItem,updateView:this.props.onlyDisplay?void 0:this.updateView,fitMode:this.state.fitMode,updateFitMode:this.updateFitMode,zoom:this.state.flamegraphConfigs.zoom,focusedNode:this.state.flamegraphConfigs.focusedNode,onZoom:this.onFlamegraphZoom,onFocusOnNode:this.onFocusOnNode,onReset:this.onReset,isDirty:this.isDirty,palette:this.state.palette,toolbarVisible:a,setPalette:this.handleSetPalette,enableSandwichView:this.props.enableSandwichView},"flamegraph-pane"),o=(()=>{if(this.state.selectedItem.isNothing)return e("div",{className:pc.sandwichPane,children:t("div",{className:lo(pc.sandwichPaneInfo,"vertical"===this.state.panesOrientation?pc.vertical:pc.horizontal),children:[e("div",{className:pc.arrow}),"Select a function to view callers/callees sandwich view"]})},"sandwich-pane");const n=mc(this.state.flamebearer,this.state.selectedItem.value),r=hc(this.state.flamebearer,this.state.selectedItem.value),o=t=>e(ms,{disableClick:!0,showCredit:this.props.showCredit,highlightQuery:"",setActiveItem:this.setActiveItem,selectedItem:this.state.selectedItem,fitMode:this.state.fitMode,updateFitMode:this.updateFitMode,zoom:this.state.flamegraphConfigs.zoom,focusedNode:this.state.flamegraphConfigs.focusedNode,onZoom:this.onFlamegraphZoom,onFocusOnNode:this.onFocusOnNode,onReset:this.onReset,isDirty:this.isDirty,palette:this.state.palette,toolbarVisible:a,setPalette:this.handleSetPalette,...t});return t("div",{className:pc.sandwichPane,children:[t("div",{className:pc.sandwichTop,children:[e("span",{className:pc.name,children:"Callers"}),o({flamebearer:n})]}),t("div",{className:pc.sandwichBottom,children:[e("span",{className:pc.name,children:"Callees"}),o({flamebearer:r,headerVisible:!1,showSingleLevel:!0})]})]},"sandwich-pane")})(),i=!this.state.flamebearer||this.state.flamebearer.names.length<=1,s=function(e,t,n,a,r){switch(e){case"table":return[n];case"flamegraph":return[t];case"sandwich":return[n,a];case"both":return[n,t];case"graphviz":return[r];default:throw new Error(`Invalid view '${e}'`)}}(this.state.view,r,n,o,e(Nc,{flamebearer:this.state.flamebearer}));return t("div",{children:[t("div",{children:[a&&e(rc,{sharedQuery:this.props.sharedQuery,enableChangingDisplay:!this.props.onlyDisplay,flamegraphType:this.state.flamebearer.format,view:this.state.view,handleSearchChange:this.onSearchChange,reset:this.onReset,updateView:this.updateView,updateFitMode:this.updateFitMode,fitMode:this.state.fitMode,isFlamegraphDirty:this.isDirty(),selectedNode:this.state.flamegraphConfigs.zoom,highlightQuery:this.state.searchQuery,onFocusOnSubtree:this.onFocusOnNode,ExportData:this.props.ExportData,palette:this.state.palette,setPalette:this.handleSetPalette}),this.props.children,e("div",{className:`${pc.flamegraphContainer} ${lo("vertical"===this.state.panesOrientation?pc.vertical:pc.horizontal,pc[this.state.panesOrientation],pc.panesWrapper)}`,children:i?e(fo,{}):s.map(e=>e)})]}),this.props.showPyroscopeLogo&&t("div",{className:pc.createdBy,children:["Created by",t("a",{href:"https://twitter.com/PyroscopeIO",rel:"noreferrer",target:"_blank",children:[e(j,{width:"30",height:"30"}),"@PyroscopeIO"]})]})]})},this.state={isFlamegraphDirty:!1,view:this.props.onlyDisplay?this.props.onlyDisplay:"both",fitMode:"HEAD",flamebearer:Cc(n),panesOrientation:n.panesOrientation?n.panesOrientation:"horizontal",searchQuery:"",selectedItem:N.nothing(),flamegraphConfigs:this.initialFlamegraphState,palette:Di}}componentDidUpdate(e,t){const n=Cc(e),a=Cc(this.props);if(!this.isSameFlamebearer(n,a)){const e=this.calcNewConfigs(n,a);return void this.setState({flamebearer:a,flamegraphConfigs:{...this.state.flamegraphConfigs,...e},selectedItem:N.nothing()})}t.flamegraphConfigs!==this.state.flamegraphConfigs&&this.updateFlamegraphDirtiness()}shouldShowToolbar(){return void 0===this.props.showToolbar||this.props.showToolbar}}_c.defaultProps={showCredit:!1};const Rc={showPyroscopeLogo:!1},Pc=(e,t)=>{if(t)return t;const n=null!=e?e:"auto";return"zh-CN"===("auto"===n?"undefined"!=typeof navigator&&navigator.language&&navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en":n)?Vi:$i},Mc=t=>{const{i18n:n,locale:r,colorMode:o="light",sandwich:i=!0,...s}=t,l=a.useMemo(()=>Pc(r,n),[r,n]),c=a.useMemo(()=>(e=>{switch(e){case"dark":return"ps-theme-dark";case"kylin":return"ps-theme-kylin";default:return"ps-theme-light"}})(o),[o]);return e("pyro-flamegraph",{className:c,children:e(Wi,{messages:l,children:e(_c,{...Rc,enableSandwichView:i,...s})})})};function Ic(e){const t={numTicks:0,maxSelf:0,names:[],levels:[]},n={},a={children:[]};return e.spans.forEach(e=>{e.children=[],n[e.spanID]=e}),e.spans.forEach(e=>{let t=a;e.references&&e.references.length>0&&(t=n[e.references[0].spanID]||a),t.children.push(e)}),function e(t,n){(t.children||[]).forEach(t=>e(t));let a=0;const r=F(t.children||[],e=>e.operationName);t.children=A(r,e=>{const t=e[0];for(let n=1;n<e.length;n+=1)t.duration+=e[n].duration;return a+=t.duration,t}),t.total=t.duration||a,t.self=Math.max(0,t.total-a)}(a),function n(a,r,o){var i;return t.numTicks||(t.numTicks=a.total),(i=t.levels)[r]||(i[r]=[]),t.levels[r].push(o),t.levels[r].push(a.total),t.levels[r].push(a.self),t.names.push((a.processID?`${e.processes[a.processID].serviceName}: `:"")+(a.operationName||"total")),t.levels[r].push(t.names.length-1),(a.children||[]).forEach(e=>{o+=n(e,r+1,o)}),a.total}(a,0,0),t.levels=Sc("single",t.levels),{version:1,flamebearer:t,metadata:{format:"single",units:"trace_samples",spyName:"tracing",sampleRate:1e6}}}function Ec(e,t){e.flamebearer.levels=Tc("single",e.flamebearer.levels),t.flamebearer.levels=Tc("single",t.flamebearer.levels);const n=function(e,t){const n={format:"double",numTicks:e.numTicks+t.numTicks,leftTicks:e.numTicks,rightTicks:t.numTicks,maxSelf:100,sampleRate:e.sampleRate,names:[],levels:[],units:e.units,spyName:e.spyName},a=fc(e,t),r=(e,t,a,o)=>{var i;const{name:s,children:l,self:c,total:f}=e;n.names.push(s),(i=n.levels)[t]||(i[t]=[]),n.maxSelf=Math.max(n.maxSelf,c[0]||0,c[1]||0),n.levels[t]=n.levels[t].concat([a,f[0]||0,c[0]||0,o,f[1]||0,c[1]||0,n.names.length-1]);for(let e=0;e<l.length;e+=1){const[n,i]=r(l[e],t+1,a,o);a+=n,o+=i}return[f[0]||0,f[1]||0]};return r(a,0,0,0),n}(e.flamebearer,t.flamebearer);n.levels=Sc("double",n.levels);const a={...e.metadata};return a.format="double",{version:1,flamebearer:n,metadata:a,leftTicks:e.flamebearer.numTicks,rightTicks:t.flamebearer.numTicks}}export{br as Box,Di as DefaultPalette,io as Flamegraph,Wi as FlamegraphI18nProvider,Mc as FlamegraphRenderer,Ic as convertJaegerTraceToProfile,Ec as diffTwoProfiles,$i as flamegraphDefaultMessages,Vi as flamegraphZhCNMessages};
|
|
17
|
+
*/var vs,bs=(ps||(ps=1,function(e){!function(){var t={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=r(e,a(n)))}return e}function a(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var a="";for(var o in e)t.call(e,o)&&e[o]&&(a=r(a,o));return a}function r(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):window.classNames=n}()}(gs)),gs.exports),ys=D(bs),ws={};function xs(){return vs||(vs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="chevron-left",n=[9001],a="f053",r="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z";e.definition={prefix:"fas",iconName:t,icon:[320,512,n,a,r]},e.faChevronLeft=e.definition,e.prefix="fas",e.iconName=t,e.width=320,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(ws)),ws}var ks,Ns=xs(),Ss={};function Ts(){return ks||(ks=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="chevron-right",n=[9002],a="f054",r="M311.1 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L243.2 256 73.9 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z";e.definition={prefix:"fas",iconName:t,icon:[320,512,n,a,r]},e.faChevronRight=e.definition,e.prefix="fas",e.iconName=t,e.width=320,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(Ss)),Ss}var Cs=Ts(),_s={table:"Table-module_table__6A8SM",sortable:"Table-module_sortable__J6kyp",sortArrow:"Table-module_sortArrow__Nrncn",asc:"Table-module_asc__tJDI9",desc:"Table-module_desc__fjVRY",isRowSelected:"Table-module_isRowSelected__UhIAJ",isRowDisabled:"Table-module_isRowDisabled__sz3NJ",loadingSpinner:"Table-module_loadingSpinner__SSjMK",pagination:"Table-module_pagination__VXgcO"},Rs="Button-module_button__Ed1ge",Ps="Button-module_noIcon__Uzjvv",Ms="Button-module_noBox__mLreC",Is="Button-module_customIcon__-slpC",Es="Button-module_iconWithText__DQRkr",js="Button-module_default__HhXlQ",Fs="Button-module_outline__Flf4r",As="Button-module_float__4marx",Ds="Button-module_primary__xByv0",Os="Button-module_secondary__D0K-F",Bs="Button-module_danger__5-vIq",Ls="Button-module_grouped__j8KwB";const zs=a.forwardRef(function({disabled:n=!1,kind:a="default",type:r="button",icon:o,iconNode:i,children:s,grouped:l,onClick:c,id:f,className:u,form:d,noBox:h,autoFocus:m,...p},g){return t("button",{...p,id:f,ref:g,type:r,"data-testid":p["data-testid"],disabled:n,onClick:c,form:d,autoFocus:m,"aria-label":p["aria-label"],className:ys(Rs,l?Ls:"",$s(a),u,h&&Ms,i&&Is,!o&&!i&&Ps),children:[o?e(gr,{icon:o,className:s?Es:""}):null,i,s]})});function $s(e){switch(e){case"default":return js;case"primary":return Ds;case"secondary":return Os;case"danger":return Bs;case"outline":return Fs;case"float":return As;default:throw Error(`Unsupported kind ${e}`)}}function Vs({sortByDirection:a,sortBy:r,updateSortParams:o,table:i,tableBodyRef:s,className:c,isLoading:f,itemsPerPage:u}){const d=a&&r&&o,[h,m]=l(0);return f?e("div",{className:_s.loadingSpinner}):t(n,{children:[t("table",{className:lo(_s.table,{[c||""]:c}),"data-testid":"table-ui",children:[e("thead",{children:e("tr",{children:i.headRow.map(({sortable:t,label:n,name:s,...l},c)=>t&&"not-filled"!==i.type&&d?w("th",{...l,key:c,className:_s.sortable,onClick:()=>o(s)},n,e("span",{className:lo(_s.sortArrow,{[_s[a]]:r===s})})):e("th",{...l,children:n},c))})}),e("tbody",{ref:s,children:"not-filled"===i.type?e("tr",{className:null==i?void 0:i.bodyClassName,children:e("td",{colSpan:i.headRow.length,children:i.value})}):Hs(i.bodyRows,h,u).map(({cells:t,isRowSelected:n,isRowDisabled:a,className:r,...o})=>{const i=Math.random();return e("tr",{...o,className:lo(r,{[_s.isRowSelected]:n,[_s.isRowDisabled]:a}),children:t&&t.map(({style:t,value:n,...a},r)=>e("td",{style:t,...a,children:n},i+r))},i)})})]}),e(Ws,{bodyRows:"filled"===i.type?i.bodyRows:void 0,itemsPerPage:u,currPage:h,setCurrPage:m})]})}function Hs(e,t,n){return n?e.slice(t*n,n*(t+1)):e}function Ws({itemsPerPage:n,currPage:a,setCurrPage:r,bodyRows:o}){if(!n)return null;const i=!!o&&Hs(o,a+1,n).length>0,s=!!o&&Hs(o,a-1,n).length>0;return t("nav",{className:_s.pagination,children:[e(zs,{"aria-label":"Previous Page",disabled:!s,kind:"float",icon:Ns.faChevronLeft,onClick:()=>r(a-1)}),e(zs,{disabled:!i,"aria-label":"Next Page",kind:"float",icon:Cs.faChevronRight,onClick:()=>r(a+1)})]})}function Us({numTicks:t,sampleRate:n,units:a,tableBodyRef:r,palette:o}){const i=Lr(t,n,a),s=i.format(t,n),l=f((e,t,r)=>{var l;const c=null===(l=r.target.closest("tr"))||void 0===l?void 0:l.dataset.row;if(!c)return void t();const[f,u,...d]=c.split(";");switch(f){case"single":{const[t,r]=d,o=i.format(parseInt(t,10),n),l=i.format(parseInt(r,10),n),c=s.split(" "),f="<"===c[0]?c[1]:c[0],h=o.split(" "),m="<"===h[0]?h[1]:h[0],p=l.split(" "),g="<"===p[0]?p[1]:p[0];e({title:{text:u,diff:{text:"",color:""}},tooltipData:[{units:a,self:`${o}(${(parseFloat(m)/parseFloat(f)*100).toFixed(2)}%)`,total:`${l}(${(parseFloat(g)/parseFloat(f)*100).toFixed(2)}%)`,tooltipType:"table"}]});break}case"double":{const[t,r,s,l]=d,c=Zi({formatter:i,sampleRate:n,totalLeft:parseInt(t,10),leftTicks:parseInt(r,10),totalRight:parseInt(s,10),rightTicks:parseInt(l,10),title:u,units:a},o);e({title:c.title,tooltipData:c.tooltipData});break}}},[r,t,i,n]);return e(Qi,{dataSourceRef:r,shouldShowTitle:!1,clickInfoSide:"left",setTooltipContent:l})}const Qs=e=>e||0;function Js(e,t,n,a){const r=t;return r.type="single",r.self=Qs(r.self)+e.getBarSelf(n,a),r.total=Qs(r.total)+e.getBarTotal(n,a),r}function Xs(e,t,n,a,r,o){const i=t;return i.type="double",i.self=Qs(i.self)+e.getBarSelf(n,a),i.total=Qs(i.total)+e.getBarTotal(n,a),i.selfLeft=Qs(i.selfLeft)+e.getBarSelfLeft(n,a),i.selfRght=Qs(i.selfRght)+e.getBarSelfRght(n,a),i.selfDiff=Qs(i.selfDiff)+e.getBarSelfDiff(n,a),i.totalLeft=Qs(i.totalLeft)+e.getBarTotalLeft(n,a),i.totalRght=Qs(i.totalRght)+e.getBarTotalRght(n,a),i.totalDiff=Qs(i.totalDiff)+e.getBarTotalDiff(n,a),i.leftTicks=r,i.rightTicks=o,i}function Ys(e,t,n){const a=148-e/t*148,r=n.alpha(1);return{backgroundImage:`linear-gradient(${r}, ${r})`,backgroundPosition:`-${a}px 0px`,backgroundRepeat:"no-repeat"}}const Zs=({flamebearer:n,sortBy:a,sortByDirection:r,isDoubles:o,fitMode:i,handleTableItemClick:s,highlightQuery:l,palette:c,selectedItem:f,messages:u})=>{const{numTicks:d,maxSelf:h,sampleRate:m,spyName:p,units:g}=n,v=function(e){if(!e)return[];const{names:t,levels:n,format:a}=e,r="double"!==a?Tr:Cr,o=new Map;for(let i=0;i<n.length;i++){const s=n[i];for(let n=0;n<s.length;n+=r.jStep){const i=t[r.getBarName(s,n)];o.has(i)||o.set(i,{name:i||"<empty>",self:0,total:0});const l=o.get(i);if(!l)break;"single"===a?Js(Tr,l,s,n):Xs(Cr,l,s,n,e.leftTicks,e.rightTicks)}}return Array.from(o.values())}(n).sort((e,t)=>t.total-e.total),b="asc"===r?1:-1;let y;if("name"===a)y=v.sort((e,t)=>b*e[a].localeCompare(t[a]));else switch(a){case"total":case"self":y=v.sort((e,t)=>b*(e[a]-t[a]));break;case"baseline":y=v.sort((e,t)=>b*(e.totalLeft/e.leftTicks-t.totalLeft/t.leftTicks));break;case"comparison":y=v.sort((e,t)=>b*(e.totalRght/e.rightTicks-t.totalRght/t.rightTicks));break;case"diff":y=v.sort((e,t)=>{const n=Br(Or(e.totalLeft/e.leftTicks),Or(e.totalRght/e.rightTicks)),a=Br(Or(t.totalLeft/t.leftTicks),Or(t.totalRght/t.rightTicks));return b*(n-a)});break;default:y=v}const w=Lr(d,m,g),x=e=>!!f.isJust&&e===f.value,k=(n,a)=>{return t("button",{className:"table-item-button",children:[e("span",{className:"color-reference",style:a}),e("div",{className:"symbol-name",style:(r=i,r===Wr?{direction:"rtl",overflow:"hidden",textOverflow:"ellipsis"}:{overflow:"hidden",textOverflow:"ellipsis"}),children:n.name})]});var r},N=y.filter(e=>!l||Gr(l,e.name)).map(e=>{const t=Yr(p,e.name),n=o?Jr:Zr(c,t),a={backgroundColor:n.rgb().toString()};return"double"===e.type?((e,t)=>{const n=Or(e.totalLeft/e.leftTicks),a=Or(e.totalRght/e.rightTicks),r=Br(n,a);let o="";r>0?o=c.badColor.rgb().string():r<0&&(o=c.goodColor.rgb().string());let i="";return e.totalLeft&&r!==1/0?e.totalRght?r>0?i=`(+${r.toFixed(2)}%)`:r<0&&(i=`(${r.toFixed(2)}%)`):i=u.diffRemoved:i=u.diffNew,{"data-row":`${e.type};${e.name};${e.totalLeft};${e.leftTicks};${e.totalRght};${e.rightTicks}`,isRowSelected:x(e.name),onClick:()=>s(e),cells:[{value:k(e,t)},{value:`${n} %`},{value:`${a} %`},{value:i,style:{color:o}}]}})(e,a):((e,t,n)=>({"data-row":`${e.type};${e.name};${e.self};${e.total}`,isRowSelected:x(e.name),onClick:()=>s(e),cells:[{value:k(e,n)},{value:w.format(e.self,m),style:Ys(e.self,h,t)},{value:w.format(e.total,m),style:Ys(e.total,d,t)}]}))(e,n,a)});return N.length>0?{bodyRows:N,type:"filled"}:{value:e("div",{className:"unsupported-format",children:u.noItemsFound}),type:"not-filled"}};function Ks({tableBodyRef:t,flamebearer:n,isDoubles:r,fitMode:o,handleTableItemClick:i,highlightQuery:s,selectedItem:c,palette:f}){const u=Ui(),d=a.useMemo(()=>r?[{sortable:1,name:"name",label:u.location},{sortable:1,name:"baseline",label:u.baseline,default:!0},{sortable:1,name:"comparison",label:u.comparison},{sortable:1,name:"diff",label:u.diff}]:[{sortable:1,name:"name",label:u.location},{sortable:1,name:"self",label:u.self,default:!0},{sortable:1,name:"total",label:u.total}],[u,r]),h=(e=>{const t=e.filter(e=>null==e?void 0:e.default)[0]||e[0],[n,a]=l(t.name),[r,o]=l("desc");return{sortBy:n,sortByDirection:r,updateSortParams:e=>{let t=r;t=n===e?"asc"===t?"desc":"asc":"desc",a(e),o(t)}}})(d),m={headRow:d,...Zs({flamebearer:n,sortBy:h.sortBy,sortByDirection:h.sortByDirection,isDoubles:r,fitMode:o,handleTableItemClick:i,highlightQuery:s,palette:f,selectedItem:c,messages:u})};return e(Vs,{...h,tableBodyRef:t,table:m,className:ys("flamegraph-table",{"flamegraph-table-doubles":r})})}const Gs=a.memo(function({flamebearer:n,fitMode:a,handleTableItemClick:r,highlightQuery:o,palette:i,selectedItem:s}){const l=c(null),f="double"===n.format;return t("div",{"data-testid":"table-view",className:f?"flamegraph-table-wrapper flamegraph-table-wrapper--double":"flamegraph-table-wrapper",children:[e("div",{className:"flamegraph-table-scroll",children:e(Ks,{tableBodyRef:l,flamebearer:n,isDoubles:f,fitMode:a,highlightQuery:o,handleTableItemClick:r,palette:i,selectedItem:s})}),e(Us,{tableBodyRef:l,numTicks:n.numTicks,sampleRate:n.sampleRate,units:n.units,palette:i})]})});var qs,el,tl={},nl={};function al(){return qs||(qs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="arrow-rotate-left",n=[8634,"arrow-left-rotate","arrow-rotate-back","arrow-rotate-backward","undo"],a="f0e2",r="M256 64c-56.8 0-107.9 24.7-143.1 64l47.1 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 192c-17.7 0-32-14.3-32-32L0 32C0 14.3 14.3 0 32 0S64 14.3 64 32l0 54.7C110.9 33.6 179.5 0 256 0 397.4 0 512 114.6 512 256S397.4 512 256 512c-87 0-163.9-43.4-210.1-109.7-10.1-14.5-6.6-34.4 7.9-44.6s34.4-6.6 44.6 7.9c34.8 49.8 92.4 82.3 157.6 82.3 106 0 192-86 192-192S362 64 256 64z";e.definition={prefix:"fas",iconName:t,icon:[512,512,n,a,r]},e.faArrowRotateLeft=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(nl)),nl}function rl(){return el||(el=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=al();e.definition={prefix:t.prefix,iconName:t.iconName,icon:[t.width,t.height,t.aliases,t.unicode,t.svgPathData]},e.faUndo=e.definition,e.prefix=t.prefix,e.iconName=t.iconName,e.width=t.width,e.height=t.height,e.ligatures=t.aliases,e.unicode=t.unicode,e.svgPathData=t.svgPathData,e.aliases=t.aliases}(tl)),tl}var ol,il,sl=rl(),ll={},cl={};function fl(){return ol||(ol=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="diagram-project",n=["project-diagram"],a="f542",r="M0 80C0 53.5 21.5 32 48 32l96 0c26.5 0 48 21.5 48 48l0 16 128 0 0-16c0-26.5 21.5-48 48-48l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-16-128 0 0 16c0 7.3-1.7 14.3-4.6 20.5l68.6 91.5 80 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-96c0-7.3 1.7-14.3 4.6-20.5L128 224 48 224c-26.5 0-48-21.5-48-48L0 80z";e.definition={prefix:"fas",iconName:t,icon:[512,512,n,a,r]},e.faDiagramProject=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(cl)),cl}function ul(){return il||(il=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=fl();e.definition={prefix:t.prefix,iconName:t.iconName,icon:[t.width,t.height,t.aliases,t.unicode,t.svgPathData]},e.faProjectDiagram=e.definition,e.prefix=t.prefix,e.iconName=t.iconName,e.width=t.width,e.height=t.height,e.ligatures=t.aliases,e.unicode=t.unicode,e.svgPathData=t.svgPathData,e.aliases=t.aliases}(ll)),ll}var dl,hl,ml=ul(),pl={},gl={};function vl(){return dl||(dl=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="ellipsis-vertical",n=["ellipsis-v"],a="f142",r="M64 144a56 56 0 1 1 0-112 56 56 0 1 1 0 112zm0 224c30.9 0 56 25.1 56 56s-25.1 56-56 56-56-25.1-56-56 25.1-56 56-56zm56-112c0 30.9-25.1 56-56 56s-56-25.1-56-56 25.1-56 56-56 56 25.1 56 56z";e.definition={prefix:"fas",iconName:t,icon:[128,512,n,a,r]},e.faEllipsisVertical=e.definition,e.prefix="fas",e.iconName=t,e.width=128,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(gl)),gl}function bl(){return hl||(hl=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=vl();e.definition={prefix:t.prefix,iconName:t.iconName,icon:[t.width,t.height,t.aliases,t.unicode,t.svgPathData]},e.faEllipsisV=e.definition,e.prefix=t.prefix,e.iconName=t.iconName,e.width=t.width,e.height=t.height,e.ligatures=t.aliases,e.unicode=t.unicode,e.svgPathData=t.svgPathData,e.aliases=t.aliases}(pl)),pl}var yl=bl();function wl(e){if(null!=e&&!1!==e){if("string"==typeof e||"number"==typeof e)return String(e);if(Array.isArray(e)){const t=e.map(e=>wl(e)).filter(e=>!!e);return t.length?t.join(" "):void 0}return a.isValidElement(e)?wl(e.props.children):void 0}}const xl=({placement:t,title:a,content:r,children:o})=>{const i=wl(null!=a?a:r);return i?e("span",{title:i,children:o}):e(n,{children:o})};var kl,Nl={};function Sl(){return kl||(kl=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="link",n=[128279,"chain"],a="f0c1",r="M419.5 96c-16.6 0-32.7 4.5-46.8 12.7-15.8-16-34.2-29.4-54.5-39.5 28.2-24 64.1-37.2 101.3-37.2 86.4 0 156.5 70 156.5 156.5 0 41.5-16.5 81.3-45.8 110.6l-71.1 71.1c-29.3 29.3-69.1 45.8-110.6 45.8-86.4 0-156.5-70-156.5-156.5 0-1.5 0-3 .1-4.5 .5-17.7 15.2-31.6 32.9-31.1s31.6 15.2 31.1 32.9c0 .9 0 1.8 0 2.6 0 51.1 41.4 92.5 92.5 92.5 24.5 0 48-9.7 65.4-27.1l71.1-71.1c17.3-17.3 27.1-40.9 27.1-65.4 0-51.1-41.4-92.5-92.5-92.5zM275.2 173.3c-1.9-.8-3.8-1.9-5.5-3.1-12.6-6.5-27-10.2-42.1-10.2-24.5 0-48 9.7-65.4 27.1L91.1 258.2c-17.3 17.3-27.1 40.9-27.1 65.4 0 51.1 41.4 92.5 92.5 92.5 16.5 0 32.6-4.4 46.7-12.6 15.8 16 34.2 29.4 54.6 39.5-28.2 23.9-64 37.2-101.3 37.2-86.4 0-156.5-70-156.5-156.5 0-41.5 16.5-81.3 45.8-110.6l71.1-71.1c29.3-29.3 69.1-45.8 110.6-45.8 86.6 0 156.5 70.6 156.5 156.9 0 1.3 0 2.6 0 3.9-.4 17.7-15.1 31.6-32.8 31.2s-31.6-15.1-31.2-32.8c0-.8 0-1.5 0-2.3 0-33.7-18-63.3-44.8-79.6z";e.definition={prefix:"fas",iconName:t,icon:[576,512,n,a,r]},e.faLink=e.definition,e.prefix="fas",e.iconName=t,e.width=576,e.height=512,e.ligatures=n,e.unicode=a,e.svgPathData=r,e.aliases=n}(Nl)),Nl}var Tl=Sl(),Cl="Input-module_input__ulQdV";const _l=a.forwardRef(({testId:t,className:n,type:a,name:r,placeholder:o,minLength:i=0,debounceTimeout:s=100,onChange:l,value:c,htmlId:f},u)=>e(E,{inputRef:u,"data-testid":t,className:`${Cl} ${n||""}`,type:a,name:r,placeholder:o,minLength:i,debounceTimeout:s,onChange:l,value:c,id:f}));var Rl="SharedQueryInput-module_wrapper__XRxrd",Pl="SharedQueryInput-module_search__XlzRv",Ml="SharedQueryInput-module_search-synced__J4T4b",Il="SharedQueryInput-module_searchWithSync__ryuQa",El="SharedQueryInput-module_icon__Aq0Hv",jl="SharedQueryInput-module_checked__oRvod",Fl="SharedQueryInput-module_sync__0IO2N",Al="SharedQueryInput-module_syncSelected__hstBI";const Dl=({onHighlightChange:n,highlightQuery:a,sharedQuery:r,width:i})=>{const s=Ui(),l=(e=>{const t=c();return d(()=>{t.current=e},[e]),t.current})(null==r?void 0:r.syncEnabled);d(()=>{"string"==typeof(null==r?void 0:r.searchQuery)&&(r.syncEnabled&&n(r.searchQuery),!r.syncEnabled&&l&&l!==(null==r?void 0:r.id)&&n(""))},[null==r?void 0:r.searchQuery,null==r?void 0:r.syncEnabled]);const f=o(()=>r&&r.syncEnabled?r.searchQuery||"":a,[r,a]),u=o(()=>`${r?Il:Pl} ${(null==r?void 0:r.syncEnabled)?Ml:""}`,[r]),h=(null==r?void 0:r.syncEnabled)?s.unsyncSearchBars:s.syncSearchBars;return t("div",{className:Rl,style:{width:i},children:[e(_l,{testId:"flamegraph-search",className:u,type:"search",name:"flamegraph-search",placeholder:s.searchPlaceholder,minLength:2,debounceTimeout:100,onChange:e=>{n(e.target.value),r&&r.syncEnabled&&r.onQueryChange(e.target.value)},value:f}),r?e(xl,{placement:"top",title:h,children:e("button",{className:r.syncEnabled?Al:Fl,onClick:()=>{const e=!(null==r?void 0:r.syncEnabled)&&(null==r?void 0:r.id);null==r||r.toggleSync(e),e?null==r||r.onQueryChange(a):(n(a),null==r||r.onQueryChange(""))},children:e(gr,{className:`${r.syncEnabled?jl:El}`,icon:Tl.faLink})})}):null]})};var Ol="DiffLegend-module_flamegraph-legend__Cywr1",Bl="DiffLegend-module_flamegraph-legend-list__swdXj",Ll="DiffLegend-module_flamegraph-legend-item__0P-6g";function zl(n){const{palette:a,showMode:r}=n,o=function(e){switch(e){case"large":return[-100,-80,-60,-40,-20,-10,0,10,20,40,60,80,100];case"small":return[-100,-40,-20,0,20,40,100];default:throw new Error(`Unsupported ${e}`)}}(r),i=Kr(a);return e("div",{"data-testid":"flamegraph-legend",className:`${Ol} ${Bl}`,children:o.map(e=>t("div",{className:Ll,style:{backgroundColor:i(e).rgb().toString()},children:[e>0?"+":"",e,"%"]},e))})}function $l(){return e("svg",{version:"1.1",id:"Capa_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"12px",height:"12px",viewBox:"0 0 405.272 405.272",children:e("g",{children:e("path",{d:"M393.401,124.425L179.603,338.208c-15.832,15.835-41.514,15.835-57.361,0L11.878,227.836\n\n\t\tc-15.838-15.835-15.838-41.52,0-57.358c15.841-15.841,41.521-15.841,57.355-0.006l81.698,81.699L336.037,67.064\n\n\t\tc15.841-15.841,41.523-15.829,57.358,0C409.23,82.902,409.23,108.578,393.401,124.425z"})})})}var Vl="Dropdown-module_dropdownMenu__tbN8r",Hl="Dropdown-module_dropdownMenuButton__Xy8M4";function Wl({id:n,children:a,className:r,disabled:o,value:i,label:s,onItemClick:l,overflow:c,position:f,direction:u,align:d,viewScroll:h,arrow:m,menuButtonClassName:p="",ariaLabel:g,portal:v,...b}){const y=b.menuButton||e(Ql,{"aria-label":g,className:`${Hl} ${p}`,disabled:o,type:"button",children:i||s});return t(Ti,{id:n,"aria-label":g,className:ys(r,Vl),"data-testid":b["data-testid"],onItemClick:l,overflow:c,position:f,direction:u,align:d,viewScroll:h,arrow:m,menuButton:y,portal:v,children:[e(Pi,{children:s}),a]})}const Ul=Ri,Ql=ii;var Jl="DiffLegendPaletteDropdown-module_container__h8Tts",Xl="DiffLegendPaletteDropdown-module_triggerButton__oezA6",Yl="DiffLegendPaletteDropdown-module_dropdownArrow__-Lu0w",Zl="DiffLegendPaletteDropdown-module_menuItem__5iWry",Kl="DiffLegendPaletteDropdown-module_menuItemText__a-tt0";const Gl=[Di,Oi],ql=n=>{const{palette:a=Di,onChange:r}=n,o=Ui(),i=e=>"Default"===e.name?o.paletteDefaultName:"Color Blind"===e.name?o.paletteColorBlindName:e.name,s=e=>"Default"===e.name?o.paletteDefaultDesc:"Color Blind"===e.name?o.paletteColorBlindDesc:"";return e("div",{className:Jl,children:e(Wl,{label:o.diffLegendSelectPalette,align:"end",menuButton:t(Ql,{className:ys(Hl,Xl),children:[e(zl,{palette:a,showMode:"small"}),e("span",{className:Yl,children:"▼"})]}),onItemClick:e=>{e.value&&r(e.value)},children:Gl.map(n=>e(Ul,{value:n,children:t("div",{className:Zl,children:[t("span",{className:Kl,children:[i(n)," ",s(n)]}),n.name===a.name&&e($l,{})]})},n.name))})})};var ec={navbar:"Toolbar-module_navbar__XN6xZ",searchWrapper:"Toolbar-module_searchWrapper__k--ua",rightSection:"Toolbar-module_rightSection__if7LO",viewType:"Toolbar-module_viewType__AKARg",toggleViewButton:"Toolbar-module_toggleViewButton__OQ9-U",fitModeButton:"Toolbar-module_fitModeButton__jOxve",selected:"Toolbar-module_selected__vwBQt",collapseNodeButton:"Toolbar-module_collapseNodeButton__bLdiw",resetViewButton:"Toolbar-module_resetViewButton__y2ebV",divider:"Toolbar-module_divider__dG6pE",itemsContainer:"Toolbar-module_itemsContainer__gSTMF",item:"Toolbar-module_item__o-hKc",moreButton:"Toolbar-module_moreButton__rhOdT",active:"Toolbar-module_active__36Kt-",navbarCollapsedItems:"Toolbar-module_navbarCollapsedItems__vojhw"};const tc=$.bind(ec),nc=(e,t,n)=>{const a=0===t?e-360-5:e-360-16-5;let r=0,o=0;return n.reverse().forEach(e=>{o+=e,a<=o&&(r+=1)}),r},ac=()=>e("div",{className:ec.divider}),rc=y(({view:a,handleSearchChange:r,highlightQuery:o,isFlamegraphDirty:i,reset:s,updateFitMode:f,fitMode:d,updateView:h,selectedNode:m,onFocusOnSubtree:p,flamegraphType:g,enableChangingDisplay:v=!0,sharedQuery:b,ExportData:y,palette:w,setPalette:k})=>{const N=c(null),S=Ui(),T="double"===g&&w&&k,C=[{el:t(n,{children:[e(sc,{fitMode:d,updateFitMode:f}),e(ac,{})]}),width:93},{el:e(ic,{isFlamegraphDirty:i,reset:s}),width:44},{el:t(n,{children:[e(oc,{selectedNode:m,onFocusOnSubtree:p}),e(ac,{})]}),width:49},v?{el:e(cc,{flamegraphType:g,view:a,updateView:h}),width:44*("single"===g?5:3)}:null,x(y)?{el:t(n,{children:[e(ac,{}),y]}),width:49}:null].filter(e=>null!==e),R=C.reduce((e,t)=>[...e,t.width],[]),{isCollapsed:P,collapsedItemsNumber:M,handleMoreClick:I}=((e,t)=>{const[n,a]=l(!0),[r,o]=l(0);return u(()=>{if(e.current){const{width:n}=e.current.getBoundingClientRect(),a=nc(n,r,t);o(a)}},[e.current,t]),_(e,e=>{const{width:n}=e.target.getBoundingClientRect(),i=nc(n,r,t);o(i),a(!0)}),{isCollapsed:n,handleMoreClick:()=>{a(e=>!e)},collapsedItemsNumber:r}})(N,R),E=C.reduce((e,t,n)=>(n<M?e.hidden.push(t):e.visible.push(t),e),{visible:[],hidden:[]});return e("div",{role:"toolbar",ref:N,children:t("div",{className:ec.navbar,children:[e("div",{className:ec.searchWrapper,children:e(Dl,{width:360,onHighlightChange:r,highlightQuery:o,sharedQuery:b})}),t("div",{className:ec.rightSection,children:[T&&t(n,{children:[e(ql,{palette:w,onChange:k}),e(ac,{})]}),t("div",{className:ec.itemsContainer,children:[E.visible.map((t,n)=>e("div",{className:ec.item,style:{width:t.width},children:t.el},n)),0!==M&&e(xl,{placement:"top",title:S.more,children:e("button",{onClick:I,className:tc({[ec.moreButton]:!0,[ec.active]:!P}),children:e(gr,{icon:yl.faEllipsisV})})})]})]}),!P&&e("div",{className:ec.navbarCollapsedItems,children:E.hidden.map((t,n)=>e("div",{className:ec.item,style:{width:t.width},children:t.el},n))})]})})});function oc({onFocusOnSubtree:t,selectedNode:n}){const a=Ui(),r=n.mapOr(()=>{},e=>()=>t(e.i,e.j));return e(xl,{placement:"top",title:a.collapseNodesAbove,children:e("div",{children:e(zs,{disabled:!n.isJust,onClick:r,className:ec.collapseNodeButton,"aria-label":a.collapseNodesAbove,children:e(gr,{icon:jo.faCompressAlt})})})})}function ic({isFlamegraphDirty:t,reset:n}){const a=Ui();return e(xl,{placement:"top",title:a.resetView,children:e("span",{children:e(zs,{id:"reset",disabled:!t,onClick:n,className:ec.resetViewButton,"aria-label":a.resetView,children:e(gr,{icon:sl.faUndo})})})})}function sc({fitMode:a,updateFitMode:r}){const o=Ui(),i=e=>a===e;return t(n,{children:[e(xl,{placement:"top",title:o.headFirst,children:e(zs,{onClick:()=>r("HEAD"),className:tc({[ec.fitModeButton]:!0,[ec.selected]:i("HEAD")}),children:e(os,{})})}),e(xl,{placement:"top",title:o.tailFirst,children:e(zs,{onClick:()=>r("TAIL"),className:tc({[ec.fitModeButton]:!0,[ec.selected]:i("TAIL")}),children:e(is,{})})})]})}const lc=(t,n)=>"single"===t?[{label:n.viewTable,value:"table",Icon:ts},{label:n.viewTableAndFlamegraph,value:"both",Icon:ns},{label:n.viewFlamegraph,value:"flamegraph",Icon:as},{label:n.viewSandwich,value:"sandwich",Icon:rs},{label:n.viewGraphviz,value:"graphviz",Icon:()=>e(gr,{icon:ml.faProjectDiagram})}]:[{label:n.viewTable,value:"table",Icon:ts},{label:n.viewTableAndFlamegraph,value:"both",Icon:ns},{label:n.viewFlamegraph,value:"flamegraph",Icon:as}];function cc({view:t,updateView:n,flamegraphType:a}){const r=Ui(),o=lc(a,r);return e("div",{className:ec.viewType,children:o.map(({label:a,value:r,Icon:o})=>e(xl,{placement:"top",title:a,children:e(zs,{"data-testid":r,onClick:()=>n(r),className:tc({[ec.toggleViewButton]:!0,selected:t===r}),children:e(o,{})})},r))})}function fc(e,t){const n={},a={};let r={name:"total",children:[],self:[],total:[],key:"/total"};return(t?[e,t]:[e]).forEach((e,t)=>{var o,i;for(let s=0;s<e.levels.length;s+=1)for(let l=0;l<e.levels[s].length;l+=4){const c=[t,s,l].join("/"),f=e.names[e.levels[s][l+3]],u=e.levels[s][l+0],d=e.levels[s][l+1],h=e.levels[s][l+2];let m="";if(0!==s){const n=s-1,r=e.levels[n];for(let e=0;e<r.length;e+=4){const o=r[e+0],i=r[e+1];if(u>=o&&u<o+i){const r=[t,n,e].join("/");m=a[r].key;break}}}const p=[m||"",f].join("/"),g=!n[p];n[p]||(n[p]={name:f,children:[],self:[],total:[],key:p});const v=n[p];(o=v.total)[t]||(o[t]=0),v.total[t]+=d,(i=v.self)[t]||(i[t]=0),v.self[t]+=h,a[c]=v,m&&g&&n[m].children.push(v),0===s&&(r=v)}}),r}const uc=e=>{const t={maxSelf:100,names:[],levels:[]},n=(e,a,r)=>{var o;const{name:i,children:s,self:l,total:c,offset:f}=e;t.names.push(i),(o=t.levels)[a]||(o[a]=[]),t.maxSelf=Math.max(t.maxSelf,l[0]||0),t.levels[a]=t.levels[a].concat([r,c[0]||0,l[0]||0,t.names.length-1]);for(let e=0;e<s.length;e+=1){r+=n(s[e],a+1,r)}return f||c[0]||0};return n(e,0,0),t};function dc(e){const t=new Map;for(let n=0;n<e.children.length;n+=1)t.has(e.children[n].name)||t.set(e.children[n].name,e.children[n]);for(let n=0;n<e.children.length;n+=1){const a=e.children[n],r=t.get(e.children[n].name);r&&r!==a&&(r.total[0]+=a.total[0],r.self[0]+=a.self[0],r.children=r.children.concat(a.children))}e.children=Array.from(t.values());for(let t=0;t<e.children.length;t+=1)dc(e.children[t])}function hc(e,t){const n=function(e,t){const n=fc(e),a={format:"single",numTicks:0,maxSelf:100,sampleRate:100,names:[],levels:[],units:e.units,spyName:e.spyName},r={name:t,total:[],self:[0],children:[]},o=e=>{e.name===t&&(a.numTicks+=e.total[0],r.total=[a.numTicks],r.children=r.children.concat(e.children));for(let t=0;t<e.children.length;t+=1)o(e.children[t])};return o(n),dc(r),{...a,...uc(r)}}(JSON.parse(JSON.stringify(e)),t);return n}function mc(e,t){const n=function(e,t){const n=fc(e),a={format:"single",maxSelf:100,sampleRate:100,numTicks:0,names:[],levels:[],units:e.units,spyName:e.spyName},r=[],o=[],i={name:t,total:[0],self:[0],children:[]},s=(e,n=[])=>{const i=n.concat([{...e,children:[]}]);e.name===t&&(o.push(i),r.push(e.total[0]),a.numTicks+=e.total[0]);for(let t=0;t<e.children.length;t+=1)s(e.children[t],i)};s(n),o.forEach((e,t)=>{i.children.push(((e,t)=>{const n={};let a=n;return e.forEach(({name:e,...n})=>{const r={name:e,...n,total:[t]};a.children=[r],a=r}),n.children[0]})(e.reverse(),r[t]))}),dc(i);const l=uc(i);return l.levels=l.levels.reverse().slice(0,-1),{...a,...l}}(JSON.parse(JSON.stringify(e)),t);return n}var pc={flamegraphContainer:"FlamegraphRenderer-module_flamegraphContainer__-7FRV",createdBy:"FlamegraphRenderer-module_createdBy__rHAOT",horizontal:"FlamegraphRenderer-module_horizontal__zs7--",vertical:"FlamegraphRenderer-module_vertical__fRcHg",panesWrapper:"FlamegraphRenderer-module_panesWrapper__L-mlA",tablePane:"FlamegraphRenderer-module_tablePane__Gin7Y",sandwichPane:"FlamegraphRenderer-module_sandwichPane__IEOyR",sandwichPaneInfo:"FlamegraphRenderer-module_sandwichPaneInfo__5hT4a",arrow:"FlamegraphRenderer-module_arrow__dPzpE",sandwichTop:"FlamegraphRenderer-module_sandwichTop__7N0ZY",sandwichBottom:"FlamegraphRenderer-module_sandwichBottom__Dc64g",name:"FlamegraphRenderer-module_name__XRbN9"};function gc(e){const t=[];return Object.keys(e).forEach(n=>{var a;t.push(`${n}="${a=String(e[n]||""),a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`)}),`[${t.join(" ")}]`}function vc(e,t){return`${(100*e/t).toFixed(2)}%`}function bc(e,t){let n,a,r,o;t?(n=.1,a=.93):(n=1,a=.7),e=Math.max(-1,Math.min(1,e)),Math.abs(e)<.2&&(n*=Math.abs(e)/.2),e>0&&(e**=1-.7),e<0&&(e=-((-e)**(1-.7))),e<0?(o=a,r=a*(1+n*e)):(r=a,o=a*(1-n*e));const i=a*(1-n);return`#${Math.floor(255*r).toString(16).padStart(2,"0")}${Math.floor(255*o).toString(16).padStart(2,"0")}${Math.floor(255*i).toString(16).padStart(2,"0")}`}function yc(e,t,n,a){const{self:r}=t,{total:o}=t,i=t.name.replace(/"/g,'\\"'),s=e(r),l=8+Math.ceil(16*Math.sqrt(r/n)),c=bc(o/a,!1),f=bc(o/a,!0),u=function(e,t,n,a,r){let o="";o=`${function(e){return e.replace(/.*\//,"")}(t)}\n`;const i=e(n);0!==n?o=`${o+i} (${vc(n,r)})`:o+="0";let s=i;a!==n&&(o+=0!==n?"\n":" ",s=e(a),o=`${o}of ${s} (${vc(a,r)})`);return o}(e,i,r,o,a),d={label:u,id:`node${t.index}`,fontsize:l,shape:"box",tooltip:`${i} (${s})`,color:c,fontcolor:"#000000",style:"filled",fontname:"",fillcolor:f};return`N${t.index} ${gc(d)}`}function wc(e){if("double"===e.metadata.format)return"diff flamegraphs are not supported";const t=fc(e.flamebearer),n=[],a=[];const[r,o,,i]=function e(t,n,a,r,o){return t.children.forEach(t=>{const[i,s]=e(t,n,a,r,o);n=Math.max(n,i),a=Math.max(a,s)}),n=Math.max(n,t.self[0]),a=Math.max(a,t.total[0]),r+=t.self[0],o+=t.total[0],[n,a,r,o]}(t,0,0,0,0),{sampleRate:s,units:l}=e.metadata,c=Lr(o,s,l),f=e=>c.format(e,s,!0);let u={};const d={};let h=0;function m(e,t){return-1===t.indexOf(e.name)&&(u[e.name]?(u[e.name].self+=e.self[0],u[e.name].total+=e.total[0]):(h+=1,u[e.name]={index:h,name:e.name,self:e.self[0],total:e.total[0],parents:[],children:[]})),e.children.forEach(n=>{const a=m(n,t.concat([e.name])),r=`${e.name}/${n.name}`;n.name!==e.name&&(d[r]?d[r].weight+=n.total[0]:d[r]={from:u[e.name],to:a,weight:n.total[0],residual:!1},a.parents.push(d[r]),u[e.name].children.push(d[r]))}),u[e.name]}t.children.forEach(e=>{m(e,[])});const p=.005*i,g=.001*i;function v(e,t){let n=0,a=t;if(e.forEach(e=>{e.weight>0&&(a+=Math.abs(e.weight))}),0!==a&&(e.forEach(e=>{const t=Math.abs(e.weight)/a;n+=-t*Math.log2(t)}),t>0)){const e=Math.abs(t)/a;n+=-e*Math.log2(e)}return n}Object.keys(u).forEach(e=>{u[e].total<p&&delete u[e]});const b={};Object.keys(u).forEach(e=>{b[u[e].name]=function(e){let t=0;return 0===e.parents.length?t+=1:t+=v(e.parents,0),0===e.children.length?t+=1:t+=v(e.children,e.self),t*e.total+e.self}(u[e])});const y=Object.values(u).sort((e,t)=>{const n=b[e.name],a=b[t.name];return n!==a?a-n:e.name!==t.name?e.name<t.name?-1:1:e.self!==t.self?a-n:e.name<t.name?-1:1}),w={};function x(e){const[t,n]=[e.from,e.to],a={},r=[n];for(;r.length>0;){const n=r.shift();for(let o=0;o<n.parents.length;o+=1){const i=n.parents[o];if(e!==i&&!a[i.from.name]){if(i.from===t)return!0;a[i.from.name]=!0,r.push(i.from)}}}return!1}return y.forEach(e=>{w[e.name]=e}),y.slice(80).forEach(e=>{delete w[e.name]}),function e(t,n){const a=!w[t.name];t.children.forEach(r=>{const o=!w[r.name];if(e(r,a?n:t),!o&&n&&a){const e=`${n.name}/${r.name}`;d[e]||(d[e]={from:u[n.name],to:u[r.name],weight:0,residual:!0}),d[e].weight+=r.total[0],d[e].residual=!0}})}(t,null),u=w,y.reverse().forEach(e=>{const t=e.parents.sort((e,t)=>t.weight-e.weight),n=[];for(let e=0;e<t.length;e+=1){const a=t[e];if(!a.residual)break;x(a)&&(n.push(a),delete d[`${a.from.name}/${a.to.name}`])}n.forEach(e=>{e.from.children=e.from.children.filter(t=>t.to!==e.to),e.to.parents=e.to.parents.filter(t=>t.from!==e.from)})}),Object.keys(d).forEach(e=>{const t=d[e];u[t.from.name]||delete d[e],u[t.to.name]||delete d[e],t.weight<g&&delete d[e]}),Object.keys(u).forEach(e=>{n.push(yc(f,u[e],r,o))}),Object.keys(d).forEach(e=>{a.push(function(e,t,n){const a=t.from.name.replace(/"/g,'\\"'),r=t.to.name.replace(/"/g,'\\"'),o=t.weight,i=e(t.weight),s=`${a} -> ${r} (${i})`,l={label:i,weight:1+100*o/n,penwidth:1+5*o/n,tooltip:s,labeltooltip:s,fontname:"",color:bc(o/n,!1),style:t.residual?"dotted":""};return`N${t.from.index} -> N${t.to.index} ${gc(l)}`}(f,d[e],o))}),`digraph "unnamed" {\n fontname= ""\n ${n.join("\n")}\n ${a.join("\n")}\n }`}var xc="GraphVizPanel-module_graphVizPane__B18cQ";const kc=()=>null;function Nc({flamebearer:t}){var n,a;const r=t,i=(null===(n=r.metadata)||void 0===n?void 0:n.format)&&(null===(a=r.flamebearer)||void 0===a?void 0:a.levels),s=`graphviz-pane-${(null==r?void 0:r.appName)||String((new Date).valueOf())}`,l=o(()=>wc(r),[JSON.stringify(r)]);return e("div",{className:xc,children:i?e(kc,{options:{zoom:!0,width:"150%",height:"100%",scale:1,useWorker:!1},dot:l}):e("div",{children:"NO DATA"})},s)}function Sc(e,t){const n=[...t];function a(e,t,n){for(const a of e){let e=0;for(let r=t;r<a.length;r+=n)a[r]-=e,e+=a[r]+a[r+1]}}return"double"===e?(a(n,0,7),a(n,3,7)):a(n,0,4),n}function Tc(e,t){const n=[...t];function a(e,t,n){for(const a of e){let e=0;for(let r=t;r<a.length;r+=n)a[r]+=e,e=a[r]+a[r+1]}}return"double"===e?(a(n,0,7),a(n,3,7)):a(n,0,4),n}function Cc(e){if(e.profile&&e.flamebearer&&console.warn("'profile' and 'flamebearer' properties are mutually exclusive. Please use profile if possible."),e.profile){const n={...e.profile,flamebearer:{...e.profile.flamebearer}};n.flamebearer.levels=JSON.parse(JSON.stringify(n.flamebearer.levels)),(t=n).flamebearer.levels=Tc(t.metadata.format,t.flamebearer.levels);const a={...n,...n.metadata,...n.flamebearer,flamebearer:void 0,metadata:void 0};return delete a.flamebearer,delete a.metadata,a}var t;if(e.flamebearer)return e.flamebearer;return{format:"single",names:[],units:"unknown",levels:[[]],spyName:"unknown",numTicks:0,sampleRate:0,maxSelf:0}}class _c extends k{constructor(n){super(n),this.resetFlamegraphState={focusedNode:N.nothing(),zoom:N.nothing()},this.initialFlamegraphState=this.resetFlamegraphState,this.calcNewConfigs=(e,t)=>{const n=this.state.flamegraphConfigs,a=(e,t,n)=>{const a=(e,t,n)=>e.names[_r(e.format).getBarName(e.levels[t],n)];if(n.isNothing)return!0;try{const r=n,o=a(e,r.value.i,r.value.j);return o===a(t,r.value.i,r.value.j)}catch{return!1}};a(e,t,this.state.flamegraphConfigs.zoom)||(n.zoom=this.resetFlamegraphState.zoom);return a(e,t,this.state.flamegraphConfigs.focusedNode)||(n.focusedNode=this.resetFlamegraphState.focusedNode),n},this.onSearchChange=e=>{this.setState({searchQuery:e})},this.isSameFlamebearer=(e,t)=>function(e,t){var n;return e.format===t.format&&e.numTicks===t.numTicks&&e.sampleRate===t.sampleRate&&e.units===t.units&&(null===(n=e.names)||void 0===n?void 0:n.length)===(null==t?void 0:t.names.length)&&e.levels.length===t.levels.length&&!!e.names.every((e,n)=>e===t.names[n])&&!!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){if(e[n].length!==t[n].length)return!1;for(let a=0;a<e[n].length;a++)if(e[n][a]!==t[n][a])return!1}return!0}(e.levels,t.levels)&&JSON.stringify({...e,levels:void 0,names:void 0})===JSON.stringify({...t,levels:void 0,names:void 0})}(e,t),this.onReset=()=>{this.setState({...this.state,flamegraphConfigs:{...this.state.flamegraphConfigs,...this.initialFlamegraphState},selectedItem:N.nothing()})},this.onFlamegraphZoom=e=>{e.isJust&&0===e.value.i&&0===e.value.j?this.onReset():this.setState({...this.state,flamegraphConfigs:{...this.state.flamegraphConfigs,zoom:e}})},this.onFocusOnNode=(e,t)=>{if(0===e&&0===t)return void this.onReset();let n={...this.state.flamegraphConfigs};const{zoom:a}=this.state.flamegraphConfigs;a.isJust&&a.value.i<=e&&(n={...n,zoom:this.initialFlamegraphState.zoom}),this.setState({...this.state,flamegraphConfigs:{...n,focusedNode:N.just({i:e,j:t})}})},this.setActiveItem=e=>{const{name:t}=e;this.state.selectedItem.isJust&&t===this.state.selectedItem.value?this.setState({selectedItem:N.nothing()}):this.setState({selectedItem:N.just(t)})},this.getHighlightQuery=()=>this.state.selectedItem.isJust?this.state.selectedItem.value:this.state.searchQuery,this.updateView=e=>{"sandwich"===e&&this.setState({searchQuery:"",flamegraphConfigs:this.resetFlamegraphState}),this.setState({view:e})},this.updateFlamegraphDirtiness=()=>{const e=this.isDirty();this.setState({isFlamegraphDirty:e})},this.updateFitMode=e=>{this.setState({fitMode:e})},this.isDirty=()=>this.state.selectedItem.isJust||JSON.stringify(this.initialFlamegraphState)!==JSON.stringify(this.state.flamegraphConfigs),this.handleSetPalette=e=>{this.setState({palette:e})},this.render=()=>{const n=e("div",{className:lo(pc.tablePane,"vertical"===this.state.panesOrientation?pc.vertical:pc.horizontal),children:e(Gs,{"data-testid":"table-view",flamebearer:this.state.flamebearer,fitMode:this.state.fitMode,highlightQuery:this.state.searchQuery,selectedItem:this.state.selectedItem,handleTableItemClick:this.setActiveItem,palette:this.state.palette})},"table-pane"),a=this.shouldShowToolbar(),r=e(ms,{showCredit:this.props.showCredit,flamebearer:this.state.flamebearer,highlightQuery:this.getHighlightQuery(),setActiveItem:this.setActiveItem,selectedItem:this.state.selectedItem,updateView:this.props.onlyDisplay?void 0:this.updateView,fitMode:this.state.fitMode,updateFitMode:this.updateFitMode,zoom:this.state.flamegraphConfigs.zoom,focusedNode:this.state.flamegraphConfigs.focusedNode,onZoom:this.onFlamegraphZoom,onFocusOnNode:this.onFocusOnNode,onReset:this.onReset,isDirty:this.isDirty,palette:this.state.palette,toolbarVisible:a,setPalette:this.handleSetPalette,enableSandwichView:this.props.enableSandwichView},"flamegraph-pane"),o=(()=>{if(this.state.selectedItem.isNothing)return e("div",{className:pc.sandwichPane,children:t("div",{className:lo(pc.sandwichPaneInfo,"vertical"===this.state.panesOrientation?pc.vertical:pc.horizontal),children:[e("div",{className:pc.arrow}),"Select a function to view callers/callees sandwich view"]})},"sandwich-pane");const n=mc(this.state.flamebearer,this.state.selectedItem.value),r=hc(this.state.flamebearer,this.state.selectedItem.value),o=t=>e(ms,{disableClick:!0,showCredit:this.props.showCredit,highlightQuery:"",setActiveItem:this.setActiveItem,selectedItem:this.state.selectedItem,fitMode:this.state.fitMode,updateFitMode:this.updateFitMode,zoom:this.state.flamegraphConfigs.zoom,focusedNode:this.state.flamegraphConfigs.focusedNode,onZoom:this.onFlamegraphZoom,onFocusOnNode:this.onFocusOnNode,onReset:this.onReset,isDirty:this.isDirty,palette:this.state.palette,toolbarVisible:a,setPalette:this.handleSetPalette,...t});return t("div",{className:pc.sandwichPane,children:[t("div",{className:pc.sandwichTop,children:[e("span",{className:pc.name,children:"Callers"}),o({flamebearer:n})]}),t("div",{className:pc.sandwichBottom,children:[e("span",{className:pc.name,children:"Callees"}),o({flamebearer:r,headerVisible:!1,showSingleLevel:!0})]})]},"sandwich-pane")})(),i=!this.state.flamebearer||this.state.flamebearer.names.length<=1,s=function(e,t,n,a,r){switch(e){case"table":return[n];case"flamegraph":return[t];case"sandwich":return[n,a];case"both":return[n,t];case"graphviz":return[r];default:throw new Error(`Invalid view '${e}'`)}}(this.state.view,r,n,o,e(Nc,{flamebearer:this.state.flamebearer}));return t("div",{children:[t("div",{children:[a&&e(rc,{sharedQuery:this.props.sharedQuery,enableChangingDisplay:!this.props.onlyDisplay,flamegraphType:this.state.flamebearer.format,view:this.state.view,handleSearchChange:this.onSearchChange,reset:this.onReset,updateView:this.updateView,updateFitMode:this.updateFitMode,fitMode:this.state.fitMode,isFlamegraphDirty:this.isDirty(),selectedNode:this.state.flamegraphConfigs.zoom,highlightQuery:this.state.searchQuery,onFocusOnSubtree:this.onFocusOnNode,ExportData:this.props.ExportData,palette:this.state.palette,setPalette:this.handleSetPalette}),this.props.children,e("div",{className:`${pc.flamegraphContainer} ${lo("vertical"===this.state.panesOrientation?pc.vertical:pc.horizontal,pc[this.state.panesOrientation],pc.panesWrapper)}`,children:i?e(fo,{}):s.map(e=>e)})]}),this.props.showPyroscopeLogo&&t("div",{className:pc.createdBy,children:["Created by",t("a",{href:"https://twitter.com/PyroscopeIO",rel:"noreferrer",target:"_blank",children:[e(j,{width:"30",height:"30"}),"@PyroscopeIO"]})]})]})},this.state={isFlamegraphDirty:!1,view:this.props.onlyDisplay?this.props.onlyDisplay:"both",fitMode:"HEAD",flamebearer:Cc(n),panesOrientation:n.panesOrientation?n.panesOrientation:"horizontal",searchQuery:"",selectedItem:N.nothing(),flamegraphConfigs:this.initialFlamegraphState,palette:Di}}componentDidUpdate(e,t){const n=Cc(e),a=Cc(this.props);if(!this.isSameFlamebearer(n,a)){const e=this.calcNewConfigs(n,a);return void this.setState({flamebearer:a,flamegraphConfigs:{...this.state.flamegraphConfigs,...e},selectedItem:N.nothing()})}t.flamegraphConfigs!==this.state.flamegraphConfigs&&this.updateFlamegraphDirtiness()}shouldShowToolbar(){return void 0===this.props.showToolbar||this.props.showToolbar}}_c.defaultProps={showCredit:!1};const Rc={showPyroscopeLogo:!1},Pc=(e,t)=>{if(t)return t;const n=null!=e?e:"auto";return"zh-CN"===("auto"===n?"undefined"!=typeof navigator&&navigator.language&&navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en":n)?Vi:$i},Mc=t=>{const{i18n:n,locale:r,colorMode:o="light",sandwich:i=!0,...s}=t,l=a.useMemo(()=>Pc(r,n),[r,n]),c=a.useMemo(()=>(e=>{switch(e){case"dark":return"ps-theme-dark";case"kylin":return"ps-theme-kylin";default:return"ps-theme-light"}})(o),[o]);return e("pyro-flamegraph",{className:c,children:e(Wi,{messages:l,children:e(_c,{...Rc,enableSandwichView:i,...s})})})};function Ic(e){const t={numTicks:0,maxSelf:0,names:[],levels:[]},n={},a={children:[]};return e.spans.forEach(e=>{e.children=[],n[e.spanID]=e}),e.spans.forEach(e=>{let t=a;e.references&&e.references.length>0&&(t=n[e.references[0].spanID]||a),t.children.push(e)}),function e(t,n){(t.children||[]).forEach(t=>e(t));let a=0;const r=F(t.children||[],e=>e.operationName);t.children=A(r,e=>{const t=e[0];for(let n=1;n<e.length;n+=1)t.duration+=e[n].duration;return a+=t.duration,t}),t.total=t.duration||a,t.self=Math.max(0,t.total-a)}(a),function n(a,r,o){var i;return t.numTicks||(t.numTicks=a.total),(i=t.levels)[r]||(i[r]=[]),t.levels[r].push(o),t.levels[r].push(a.total),t.levels[r].push(a.self),t.names.push((a.processID?`${e.processes[a.processID].serviceName}: `:"")+(a.operationName||"total")),t.levels[r].push(t.names.length-1),(a.children||[]).forEach(e=>{o+=n(e,r+1,o)}),a.total}(a,0,0),t.levels=Sc("single",t.levels),{version:1,flamebearer:t,metadata:{format:"single",units:"trace_samples",spyName:"tracing",sampleRate:1e6}}}function Ec(e,t){e.flamebearer.levels=Tc("single",e.flamebearer.levels),t.flamebearer.levels=Tc("single",t.flamebearer.levels);const n=function(e,t){const n={format:"double",numTicks:e.numTicks+t.numTicks,leftTicks:e.numTicks,rightTicks:t.numTicks,maxSelf:100,sampleRate:e.sampleRate,names:[],levels:[],units:e.units,spyName:e.spyName},a=fc(e,t),r=(e,t,a,o)=>{var i;const{name:s,children:l,self:c,total:f}=e;n.names.push(s),(i=n.levels)[t]||(i[t]=[]),n.maxSelf=Math.max(n.maxSelf,c[0]||0,c[1]||0),n.levels[t]=n.levels[t].concat([a,f[0]||0,c[0]||0,o,f[1]||0,c[1]||0,n.names.length-1]);for(let e=0;e<l.length;e+=1){const[n,i]=r(l[e],t+1,a,o);a+=n,o+=i}return[f[0]||0,f[1]||0]};return r(a,0,0,0),n}(e.flamebearer,t.flamebearer);n.levels=Sc("double",n.levels);const a={...e.metadata};return a.format="double",{version:1,flamebearer:n,metadata:a,leftTicks:e.flamebearer.numTicks,rightTicks:t.flamebearer.numTicks}}export{br as Box,Di as DefaultPalette,io as Flamegraph,Wi as FlamegraphI18nProvider,Mc as FlamegraphRenderer,Ic as convertJaegerTraceToProfile,Ec as diffTwoProfiles,$i as flamegraphDefaultMessages,Vi as flamegraphZhCNMessages};
|
|
18
18
|
//# sourceMappingURL=index.node.esm.js.map
|