@kylincloud/flamegraph 0.35.19 → 0.35.20

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.
@@ -14,5 +14,5 @@ function y(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 Yi,Zi=(Ji||(Ji=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}()}(Xi)),Xi.exports),qi=h(Zi),Ki={};function Gi(){return Yi||(Yi=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}(Ki)),Ki}var es,ts=Gi(),ns={};function as(){return es||(es=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}(ns)),ns}var rs=as(),os={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"},is="Button-module_button__Ed1ge",ss="Button-module_noIcon__Uzjvv",ls="Button-module_noBox__mLreC",cs="Button-module_customIcon__-slpC",fs="Button-module_iconWithText__DQRkr",us="Button-module_default__HhXlQ",ds="Button-module_outline__Flf4r",hs="Button-module_float__4marx",ms="Button-module_primary__xByv0",ps="Button-module_secondary__D0K-F",gs="Button-module_danger__5-vIq",vs="Button-module_grouped__j8KwB";const bs=t.forwardRef(function({disabled:t=!1,kind:n="default",type:a="button",icon:r,iconNode:o,children:i,grouped:s,onClick:l,id:c,className:f,form:u,noBox:d,autoFocus:h,...m},p){return e.jsxs("button",{...m,id:c,ref:p,type:a,"data-testid":m["data-testid"],disabled:t,onClick:l,form:u,autoFocus:h,"aria-label":m["aria-label"],className:qi(is,s?vs:"",ys(n),f,d&&ls,o&&cs,!r&&!o&&ss),children:[r?e.jsx(Ja,{icon:r,className:i?fs:""}):null,o,i]})});function ys(e){switch(e){case"default":return us;case"primary":return ms;case"secondary":return ps;case"danger":return gs;case"outline":return ds;case"float":return hs;default:throw Error(`Unsupported kind ${e}`)}}function xs({sortByDirection:n,sortBy:a,updateSortParams:r,table:o,tableBodyRef:i,className:s,isLoading:l,itemsPerPage:c}){const f=n&&a&&r,[u,d]=t.useState(0);return l?e.jsx("div",{className:os.loadingSpinner}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:Or(os.table,{[s||""]:s}),"data-testid":"table-ui",children:[e.jsx("thead",{children:e.jsx("tr",{children:o.headRow.map(({sortable:i,label:s,name:l,...c},u)=>i&&"not-filled"!==o.type&&f?t.createElement("th",{...c,key:u,className:os.sortable,onClick:()=>r(l)},s,e.jsx("span",{className:Or(os.sortArrow,{[os[n]]:a===l})})):e.jsx("th",{...c,children:s},u))})}),e.jsx("tbody",{ref:i,children:"not-filled"===o.type?e.jsx("tr",{className:null==o?void 0:o.bodyClassName,children:e.jsx("td",{colSpan:o.headRow.length,children:o.value})}):ws(o.bodyRows,u,c).map(({cells:t,isRowSelected:n,isRowDisabled:a,className:r,...o})=>{const i=Math.random();return e.jsx("tr",{...o,className:Or(r,{[os.isRowSelected]:n,[os.isRowDisabled]:a}),children:t&&t.map(({style:t,value:n,...a},r)=>e.jsx("td",{style:t,...a,children:n},i+r))},i)})})]}),e.jsx(js,{bodyRows:"filled"===o.type?o.bodyRows:void 0,itemsPerPage:c,currPage:u,setCurrPage:d})]})}function ws(e,t,n){return n?e.slice(t*n,n*(t+1)):e}function js({itemsPerPage:t,currPage:n,setCurrPage:a,bodyRows:r}){if(!t)return null;const o=!!r&&ws(r,n+1,t).length>0,i=!!r&&ws(r,n-1,t).length>0;return e.jsxs("nav",{className:os.pagination,children:[e.jsx(bs,{"aria-label":"Previous Page",disabled:!i,kind:"float",icon:ts.faChevronLeft,onClick:()=>a(n-1)}),e.jsx(bs,{disabled:!o,"aria-label":"Next Page",kind:"float",icon:rs.faChevronRight,onClick:()=>a(n+1)})]})}function ks({numTicks:n,sampleRate:a,units:r,tableBodyRef:o,palette:i}){const s=pr(n,a,r),l=s.format(n,a),c=yi(),f=t.useCallback((e,t,n)=>{var o;const f=null===(o=n.target.closest("tr"))||void 0===o?void 0:o.dataset.row;if(!f)return void t();const[u,d,...h]=f.split(";");switch(u){case"single":{const[t,n]=h,o=s.format(parseInt(t,10),a),i=s.format(parseInt(n,10),a),c=l.split(" "),f="<"===c[0]?c[1]:c[0],u=o.split(" "),m="<"===u[0]?u[1]:u[0],p=i.split(" "),g="<"===p[0]?p[1]:p[0];e({title:{text:d,diff:{text:"",color:""}},tooltipData:[{units:r,self:`${o}(${(parseFloat(m)/parseFloat(f)*100).toFixed(2)}%)`,total:`${i}(${(parseFloat(g)/parseFloat(f)*100).toFixed(2)}%)`,tooltipType:"table"}]});break}case"double":{const[t,n,o,l]=h,f=_i({formatter:s,sampleRate:a,totalLeft:parseInt(t,10),leftTicks:parseInt(n,10),totalRight:parseInt(o,10),rightTicks:parseInt(l,10),title:d,units:r},i,c);e({title:f.title,tooltipData:f.tooltipData});break}}},[s,a,r,l,i,c]);return e.jsx(Ni,{dataSourceRef:o,shouldShowTitle:!1,clickInfoSide:"left",setTooltipContent:f,palette:i})}const Ns=e=>e||0;function Ss(e,t,n,a){const r=t;return r.type="single",r.self=Ns(r.self)+e.getBarSelf(n,a),r.total=Ns(r.total)+e.getBarTotal(n,a),r}function Cs(e,t,n,a,r,o){const i=t;return i.type="double",i.self=Ns(i.self)+e.getBarSelf(n,a),i.total=Ns(i.total)+e.getBarTotal(n,a),i.selfLeft=Ns(i.selfLeft)+e.getBarSelfLeft(n,a),i.selfRght=Ns(i.selfRght)+e.getBarSelfRght(n,a),i.selfDiff=Ns(i.selfDiff)+e.getBarSelfDiff(n,a),i.totalLeft=Ns(i.totalLeft)+e.getBarTotalLeft(n,a),i.totalRght=Ns(i.totalRght)+e.getBarTotalRght(n,a),i.totalDiff=Ns(i.totalDiff)+e.getBarTotalDiff(n,a),i.leftTicks=r,i.rightTicks=o,i}function Ts(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 _s=({flamebearer:t,sortBy:n,sortByDirection:a,fitMode:r,handleTableItemClick:o,highlightQuery:i,palette:s,selectedItem:l,messages:c})=>{const{numTicks:f,maxSelf:u,sampleRate:d,spyName:h,units:m}=t,p=function(e){if(!e)return[];const{names:t,levels:n,format:a}=e,r="double"!==a?tr:nr,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?Ss(tr,l,s,n):Cs(nr,l,s,n,e.leftTicks,e.rightTicks)}}return Array.from(o.values())}(t).sort((e,t)=>t.total-e.total),g="asc"===a?1:-1;let v;if("name"===n)v=p.sort((e,t)=>g*e[n].localeCompare(t[n]));else switch(n){case"total":case"self":v=p.sort((e,t)=>g*(e[n]-t[n]));break;case"baseline":v=p.sort((e,t)=>g*(e.totalLeft/e.leftTicks-t.totalLeft/t.leftTicks));break;case"comparison":v=p.sort((e,t)=>g*(e.totalRght/e.rightTicks-t.totalRght/t.rightTicks));break;case"diff":v=p.sort((e,t)=>{const n=mr(hr(e.totalLeft/e.leftTicks),hr(e.totalRght/e.rightTicks)),a=mr(hr(t.totalLeft/t.leftTicks),hr(t.totalRght/t.rightTicks));return g*(n-a)});break;default:v=p}const b=pr(f,d,m),y=e=>!!l.isJust&&e===l.value,x=t=>{return e.jsx("button",{className:"table-item-button",children:e.jsx("div",{className:"symbol-name",style:(n=r,n===xr?{direction:"rtl",overflow:"hidden",textOverflow:"ellipsis"}:{overflow:"hidden",textOverflow:"ellipsis"}),children:t.name})});var n},w=v.filter(e=>!i||Tr(i,e.name)).map(e=>{if("double"===e.type)return(e=>{const t=hr(e.totalLeft/e.leftTicks),n=hr(e.totalRght/e.rightTicks),a=mr(t,n);let r="";a>0?r=s.badColor.rgb().string():a<0&&(r=s.goodColor.rgb().string());let i="";return e.totalLeft&&a!==1/0?e.totalRght?a>0?i=`+${a.toFixed(2)}%`:a<0&&(i=`${a.toFixed(2)}%`):i=c.diffRemoved:i=c.diffNew,{"data-row":`${e.type};${e.name};${e.totalLeft};${e.leftTicks};${e.totalRght};${e.rightTicks}`,isRowSelected:y(e.name),onClick:()=>o(e),cells:[{value:x(e)},{value:`${t} %`},{value:`${n} %`},{value:i,style:{color:r}}]}})(e);const t=Nr(h,e.name);return((e,t)=>({"data-row":`${e.type};${e.name};${e.self};${e.total}`,isRowSelected:y(e.name),onClick:()=>o(e),cells:[{value:x(e)},{value:b.format(e.self,d),style:Ts(e.self,u,t)},{value:b.format(e.total,d),style:Ts(e.total,f,t)}]}))(e,Sr(s,t))});return w.length>0?{bodyRows:w,type:"filled"}:{value:e.jsx("div",{className:"unsupported-format",children:c.noItemsFound}),type:"not-filled"}};function Ms({tableBodyRef:n,flamebearer:a,isDoubles:r,fitMode:o,handleTableItemClick:i,highlightQuery:s,selectedItem:l,palette:c}){const f=yi(),u=t.useMemo(()=>r?[{sortable:1,name:"name",label:f.location},{sortable:1,name:"baseline",label:f.baseline,default:!0},{sortable:1,name:"comparison",label:f.comparison},{sortable:1,name:"diff",label:f.diff}]:[{sortable:1,name:"name",label:f.location},{sortable:1,name:"self",label:f.self,default:!0},{sortable:1,name:"total",label:f.total}],[f,r]),d=(e=>{const n=e.filter(e=>null==e?void 0:e.default)[0]||e[0],[a,r]=t.useState(n.name),[o,i]=t.useState("desc");return{sortBy:a,sortByDirection:o,updateSortParams:e=>{let t=o;t=a===e?"asc"===t?"desc":"asc":"desc",r(e),i(t)}}})(u),h={headRow:u,..._s({flamebearer:a,sortBy:d.sortBy,sortByDirection:d.sortByDirection,fitMode:o,handleTableItemClick:i,highlightQuery:s,palette:c,selectedItem:l,messages:f})};return e.jsx(xs,{...d,tableBodyRef:n,table:h,className:qi("flamegraph-table",{"flamegraph-table-doubles":r})})}const Rs=t.memo(function({flamebearer:n,fitMode:a,handleTableItemClick:r,highlightQuery:o,palette:i,selectedItem:s}){const l=t.useRef(null),c="double"===n.format;return e.jsxs("div",{"data-testid":"table-view",className:c?"flamegraph-table-wrapper flamegraph-table-wrapper--double":"flamegraph-table-wrapper",children:[e.jsx("div",{className:"flamegraph-table-scroll",children:e.jsx(Ms,{tableBodyRef:l,flamebearer:n,isDoubles:c,fitMode:a,highlightQuery:o,handleTableItemClick:r,palette:i,selectedItem:s})}),e.jsx(ks,{tableBodyRef:l,numTicks:n.numTicks,sampleRate:n.sampleRate,units:n.units,palette:i})]})});var Ps,Es,Fs={},Is={};function As(){return Ps||(Ps=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}(Is)),Is}function Ds(){return Es||(Es=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=As();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}(Fs)),Fs}var Os,zs,Ls=Ds(),Bs={},$s={};function Vs(){return Os||(Os=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}($s)),$s}function Hs(){return zs||(zs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Vs();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}(Bs)),Bs}var Ws,Us,Qs=Hs(),Js={},Xs={};function Ys(){return Ws||(Ws=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}(Xs)),Xs}function Zs(){return Us||(Us=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ys();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}(Js)),Js}var qs=Zs();function Ks(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=>Ks(e)).filter(e=>!!e);return t.length?t.join(" "):void 0}return t.isValidElement(e)?Ks(e.props.children):void 0}}const Gs=({placement:t,title:n,content:a,children:r})=>{const o=Ks(null!=n?n:a);return o?e.jsx("span",{title:o,children:r}):e.jsx(e.Fragment,{children:r})};var el,tl={};function nl(){return el||(el=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}(tl)),tl}var al=nl(),rl="Input-module_input__ulQdV";const ol=t.forwardRef(({testId:t,className:n,type:a,name:r,placeholder:o,minLength:i=0,debounceTimeout:s=100,onChange:l,value:f,htmlId:u},d)=>e.jsx(c.DebounceInput,{inputRef:d,"data-testid":t,className:`${rl} ${n||""}`,type:a,name:r,placeholder:o,minLength:i,debounceTimeout:s,onChange:l,value:f,id:u}));var il="SharedQueryInput-module_wrapper__XRxrd",sl="SharedQueryInput-module_search__XlzRv",ll="SharedQueryInput-module_search-synced__J4T4b",cl="SharedQueryInput-module_searchWithSync__ryuQa",fl="SharedQueryInput-module_icon__Aq0Hv",ul="SharedQueryInput-module_checked__oRvod",dl="SharedQueryInput-module_sync__0IO2N",hl="SharedQueryInput-module_syncSelected__hstBI";const ml=({onHighlightChange:n,highlightQuery:a,sharedQuery:r,width:o})=>{const i=yi(),s=(e=>{const n=t.useRef();return t.useEffect(()=>{n.current=e},[e]),n.current})(null==r?void 0:r.syncEnabled);t.useEffect(()=>{"string"==typeof(null==r?void 0:r.searchQuery)&&(r.syncEnabled&&n(r.searchQuery),!r.syncEnabled&&s&&s!==(null==r?void 0:r.id)&&n(""))},[null==r?void 0:r.searchQuery,null==r?void 0:r.syncEnabled]);const l=t.useMemo(()=>r&&r.syncEnabled?r.searchQuery||"":a,[r,a]),c=t.useMemo(()=>`${r?cl:sl} ${(null==r?void 0:r.syncEnabled)?ll:""}`,[r]),f=(null==r?void 0:r.syncEnabled)?i.unsyncSearchBars:i.syncSearchBars;return e.jsxs("div",{className:il,style:{width:o},children:[e.jsx(ol,{testId:"flamegraph-search",className:c,type:"search",name:"flamegraph-search",placeholder:i.searchPlaceholder,minLength:1,debounceTimeout:100,onChange:e=>{n(e.target.value),r&&r.syncEnabled&&r.onQueryChange(e.target.value)},value:l}),r?e.jsx(Gs,{placement:"top",title:f,children:e.jsx("button",{className:r.syncEnabled?hl:dl,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.jsx(Ja,{className:`${r.syncEnabled?ul:fl}`,icon:al.faLink})})}):null]})};var pl="DiffLegend-module_flamegraph-legend__Cywr1",gl="DiffLegend-module_flamegraph-legend-list__swdXj",vl="DiffLegend-module_flamegraph-legend-item__0P-6g";function bl(t){const{palette:n,showMode:a}=t,r=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}`)}}(a),o=Cr(n);return e.jsx("div",{"data-testid":"flamegraph-legend",className:`${pl} ${gl}`,children:r.map(t=>e.jsxs("div",{className:vl,style:{backgroundColor:o(t).rgb().toString()},children:[t>0?"+":"",t,"%"]},t))})}function yl(){return e.jsx("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.jsx("g",{children:e.jsx("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 xl="Dropdown-module_dropdownMenu__tbN8r",wl="Dropdown-module_dropdownMenuButton__Xy8M4";function jl({id:t,children:n,className:a,disabled:r,value:o,label:i,onItemClick:s,overflow:l,position:c,direction:f,align:u,viewScroll:d,arrow:h,menuButtonClassName:m="",ariaLabel:p,portal:g,...v}){const b=v.menuButton||e.jsx(Nl,{"aria-label":p,className:`${wl} ${m}`,disabled:r,type:"button",children:o||i});return e.jsxs(ei,{id:t,"aria-label":p,className:qi(a,xl),"data-testid":v["data-testid"],onItemClick:s,overflow:l,position:c,direction:f,align:u,viewScroll:d,arrow:h,menuButton:b,portal:g,children:[e.jsx(ai,{children:i}),n]})}const kl=ni,Nl=Ao;var Sl="DiffLegendPaletteDropdown-module_container__h8Tts",Cl="DiffLegendPaletteDropdown-module_triggerButton__oezA6",Tl="DiffLegendPaletteDropdown-module_dropdownArrow__-Lu0w",_l="DiffLegendPaletteDropdown-module_menuItem__5iWry",Ml="DiffLegendPaletteDropdown-module_menuItemText__a-tt0";const Rl=[fi,ui],Pl=t=>{const{palette:n=fi,onChange:a}=t,r=yi(),o=e=>"Default"===e.name?r.paletteDefaultName:"Color Blind"===e.name?r.paletteColorBlindName:e.name,i=e=>"Default"===e.name?r.paletteDefaultDesc:"Color Blind"===e.name?r.paletteColorBlindDesc:"";return e.jsx("div",{className:Sl,children:e.jsx(jl,{label:r.diffLegendSelectPalette,align:"end",menuButton:e.jsxs(Nl,{className:qi(wl,Cl),children:[e.jsx(bl,{palette:n,showMode:"small"}),e.jsx("span",{className:Tl,children:"▼"})]}),onItemClick:e=>{e.value&&a(e.value)},children:Rl.map(t=>e.jsx(kl,{value:t,children:e.jsxs("div",{className:_l,children:[e.jsxs("span",{className:Ml,children:[o(t)," ",i(t)]}),t.name===n.name&&e.jsx(yl,{})]})},t.name))})})};var El={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 Fl=b.bind(El),Il=(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},Al=()=>e.jsx("div",{className:El.divider}),Dl=t.memo(({view:n,handleSearchChange:a,highlightQuery:r,isFlamegraphDirty:o,reset:s,updateFitMode:l,fitMode:c,updateView:f,selectedNode:u,onFocusOnSubtree:d,flamegraphType:h,enableChangingDisplay:m=!0,sharedQuery:p,ExportData:g,palette:v,setPalette:b})=>{const y=t.useRef(null),x=yi(),w="double"===h&&v&&b,j=[{el:e.jsxs(e.Fragment,{children:[e.jsx(Ll,{fitMode:c,updateFitMode:l}),e.jsx(Al,{})]}),width:93},{el:e.jsx(zl,{isFlamegraphDirty:o,reset:s}),width:44},{el:e.jsxs(e.Fragment,{children:[e.jsx(Ol,{selectedNode:u,onFocusOnSubtree:d}),e.jsx(Al,{})]}),width:49},m?{el:e.jsx($l,{flamegraphType:h,view:n,updateView:f}),width:44*("single"===h?5:3)}:null,t.isValidElement(g)?{el:e.jsxs(e.Fragment,{children:[e.jsx(Al,{}),g]}),width:49}:null].filter(e=>null!==e),k=j.reduce((e,t)=>[...e,t.width],[]),{isCollapsed:N,collapsedItemsNumber:S,handleMoreClick:C}=((e,n)=>{const[a,r]=t.useState(!0),[o,s]=t.useState(0);return t.useLayoutEffect(()=>{if(e.current){const{width:t}=e.current.getBoundingClientRect(),a=Il(t,o,n);s(a)}},[e.current,n]),i(e,e=>{const{width:t}=e.target.getBoundingClientRect(),a=Il(t,o,n);s(a),r(!0)}),{isCollapsed:a,handleMoreClick:()=>{r(e=>!e)},collapsedItemsNumber:o}})(y,k),T=j.reduce((e,t,n)=>(n<S?e.hidden.push(t):e.visible.push(t),e),{visible:[],hidden:[]});return e.jsx("div",{role:"toolbar",ref:y,children:e.jsxs("div",{className:El.navbar,children:[e.jsx("div",{className:El.searchWrapper,children:e.jsx(ml,{width:360,onHighlightChange:a,highlightQuery:r,sharedQuery:p})}),e.jsxs("div",{className:El.rightSection,children:[w&&e.jsxs(e.Fragment,{children:[e.jsx(Pl,{palette:v,onChange:b}),e.jsx(Al,{})]}),e.jsxs("div",{className:El.itemsContainer,children:[T.visible.map((t,n)=>e.jsx("div",{className:El.item,style:{width:t.width},children:t.el},n)),0!==S&&e.jsx(Gs,{placement:"top",title:x.more,children:e.jsx("button",{onClick:C,className:Fl({[El.moreButton]:!0,[El.active]:!N}),children:e.jsx(Ja,{icon:qs.faEllipsisV})})})]})]}),!N&&e.jsx("div",{className:El.navbarCollapsedItems,children:T.hidden.map((t,n)=>e.jsx("div",{className:El.item,style:{width:t.width},children:t.el},n))})]})})});function Ol({onFocusOnSubtree:t,selectedNode:n}){const a=yi(),r=n.mapOr(()=>{},e=>()=>t(e.i,e.j));return e.jsx(Gs,{placement:"top",title:a.collapseNodesAbove,children:e.jsx("div",{children:e.jsx(bs,{disabled:!n.isJust,onClick:r,className:El.collapseNodeButton,"aria-label":a.collapseNodesAbove,children:e.jsx(Ja,{icon:so.faCompressAlt})})})})}function zl({isFlamegraphDirty:t,reset:n}){const a=yi();return e.jsx(Gs,{placement:"top",title:a.resetView,children:e.jsx("span",{children:e.jsx(bs,{id:"reset",disabled:!t,onClick:n,className:El.resetViewButton,"aria-label":a.resetView,children:e.jsx(Ja,{icon:Ls.faUndo})})})})}function Ll({fitMode:t,updateFitMode:n}){const a=yi(),r=e=>t===e;return e.jsxs(e.Fragment,{children:[e.jsx(Gs,{placement:"top",title:a.headFirst,children:e.jsx(bs,{onClick:()=>n("HEAD"),className:Fl({[El.fitModeButton]:!0,[El.selected]:r("HEAD")}),children:e.jsx(Oi,{})})}),e.jsx(Gs,{placement:"top",title:a.tailFirst,children:e.jsx(bs,{onClick:()=>n("TAIL"),className:Fl({[El.fitModeButton]:!0,[El.selected]:r("TAIL")}),children:e.jsx(zi,{})})})]})}const Bl=(t,n)=>"single"===t?[{label:n.viewTable,value:"table",Icon:Fi},{label:n.viewTableAndFlamegraph,value:"both",Icon:Ii},{label:n.viewFlamegraph,value:"flamegraph",Icon:Ai},{label:n.viewSandwich,value:"sandwich",Icon:Di},{label:n.viewGraphviz,value:"graphviz",Icon:()=>e.jsx(Ja,{icon:Qs.faProjectDiagram})}]:[{label:n.viewTable,value:"table",Icon:Fi},{label:n.viewTableAndFlamegraph,value:"both",Icon:Ii},{label:n.viewFlamegraph,value:"flamegraph",Icon:Ai}];function $l({view:t,updateView:n,flamegraphType:a}){const r=yi(),o=Bl(a,r);return e.jsx("div",{className:El.viewType,children:o.map(({label:a,value:r,Icon:o})=>e.jsx(Gs,{placement:"top",title:a,children:e.jsx(bs,{"data-testid":r,onClick:()=>n(r),className:Fl({[El.toggleViewButton]:!0,selected:t===r}),children:e.jsx(o,{})})},r))})}function Vl(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 Hl=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 Wl(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)Wl(e.children[t])}function Ul(e,t){const n=function(e,t){const n=Vl(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),Wl(r),{...a,...Hl(r)}}(JSON.parse(JSON.stringify(e)),t);return n}function Ql(e,t){const n=function(e,t){const n=Vl(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]))}),Wl(i);const l=Hl(i);return l.levels=l.levels.reverse().slice(0,-1),{...a,...l}}(JSON.parse(JSON.stringify(e)),t);return n}var Jl={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 Xl(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 Yl(e,t){return`${(100*e/t).toFixed(2)}%`}function Zl(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 ql(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=Zl(o/a,!1),f=Zl(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} (${Yl(n,r)})`:o+="0";let s=i;a!==n&&(o+=0!==n?"\n":" ",s=e(a),o=`${o}of ${s} (${Yl(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} ${Xl(d)}`}function Kl(e){if("double"===e.metadata.format)return"diff flamegraphs are not supported";const t=Vl(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=pr(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}),x={};function w(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=>{x[e.name]=e}),y.slice(80).forEach(e=>{delete x[e.name]}),function e(t,n){const a=!x[t.name];t.children.forEach(r=>{const o=!x[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=x,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;w(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(ql(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:Zl(o/n,!1),style:t.residual?"dotted":""};return`N${t.from.index} -> N${t.to.index} ${Xl(l)}`}(f,d[e],o))}),`digraph "unnamed" {\n fontname= ""\n ${n.join("\n")}\n ${a.join("\n")}\n }`}var Gl="GraphVizPanel-module_graphVizPane__B18cQ";const ec=()=>null;function tc({flamebearer:n}){var a,r;const o=n,i=(null===(a=o.metadata)||void 0===a?void 0:a.format)&&(null===(r=o.flamebearer)||void 0===r?void 0:r.levels),s=`graphviz-pane-${(null==o?void 0:o.appName)||String((new Date).valueOf())}`,l=t.useMemo(()=>Kl(o),[JSON.stringify(o)]);return e.jsx("div",{className:Gl,children:i?e.jsx(ec,{options:{zoom:!0,width:"150%",height:"100%",scale:1,useWorker:!1},dot:l}):e.jsx("div",{children:"NO DATA"})},s)}function nc(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 ac(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 rc(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=ac(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 oc extends t.Component{constructor(t){super(t),this.resetFlamegraphState={focusedNode:n.Maybe.nothing(),zoom:n.Maybe.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[ar(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.Maybe.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 a={...this.state.flamegraphConfigs};const{zoom:r}=this.state.flamegraphConfigs;r.isJust&&r.value.i<=e&&(a={...a,zoom:this.initialFlamegraphState.zoom}),this.setState({...this.state,flamegraphConfigs:{...a,focusedNode:n.Maybe.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.Maybe.nothing()}):this.setState({selectedItem:n.Maybe.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 t=e.jsx("div",{className:Or(Jl.tablePane,"vertical"===this.state.panesOrientation?Jl.vertical:Jl.horizontal),children:e.jsx(Rs,{"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"),n=this.shouldShowToolbar(),a=e.jsx(Qi,{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:n,setPalette:this.handleSetPalette,enableSandwichView:this.props.enableSandwichView},"flamegraph-pane"),r=(()=>{if(this.state.selectedItem.isNothing)return e.jsx("div",{className:Jl.sandwichPane,children:e.jsxs("div",{className:Or(Jl.sandwichPaneInfo,"vertical"===this.state.panesOrientation?Jl.vertical:Jl.horizontal),children:[e.jsx("div",{className:Jl.arrow}),"Select a function to view callers/callees sandwich view"]})},"sandwich-pane");const t=Ql(this.state.flamebearer,this.state.selectedItem.value),a=Ul(this.state.flamebearer,this.state.selectedItem.value),r=t=>e.jsx(Qi,{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:n,setPalette:this.handleSetPalette,...t});return e.jsxs("div",{className:Jl.sandwichPane,children:[e.jsxs("div",{className:Jl.sandwichTop,children:[e.jsx("span",{className:Jl.name,children:"Callers"}),r({flamebearer:t})]}),e.jsxs("div",{className:Jl.sandwichBottom,children:[e.jsx("span",{className:Jl.name,children:"Callees"}),r({flamebearer:a,headerVisible:!1,showSingleLevel:!0})]})]},"sandwich-pane")})(),o=!this.state.flamebearer||this.state.flamebearer.names.length<=1,i=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,a,t,r,e.jsx(tc,{flamebearer:this.state.flamebearer}));return e.jsxs("div",{children:[e.jsxs("div",{children:[n&&e.jsx(Dl,{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.jsx("div",{className:`${Jl.flamegraphContainer} ${Or("vertical"===this.state.panesOrientation?Jl.vertical:Jl.horizontal,Jl[this.state.panesOrientation],Jl.panesWrapper)}`,children:o?e.jsx(Lr,{}):i.map(e=>e)})]}),this.props.showPyroscopeLogo&&e.jsxs("div",{className:Jl.createdBy,children:["Created by",e.jsxs("a",{href:"https://twitter.com/PyroscopeIO",rel:"noreferrer",target:"_blank",children:[e.jsx(f,{width:"30",height:"30"}),"@PyroscopeIO"]})]})]})},this.state={isFlamegraphDirty:!1,view:this.props.onlyDisplay?this.props.onlyDisplay:"both",fitMode:"HEAD",flamebearer:rc(t),panesOrientation:t.panesOrientation?t.panesOrientation:"horizontal",searchQuery:"",selectedItem:n.Maybe.nothing(),flamegraphConfigs:this.initialFlamegraphState,palette:fi}}componentDidUpdate(e,t){const a=rc(e),r=rc(this.props);if(!this.isSameFlamebearer(a,r)){const e=this.calcNewConfigs(a,r);return void this.setState({flamebearer:r,flamegraphConfigs:{...this.state.flamegraphConfigs,...e},selectedItem:n.Maybe.nothing()})}t.flamegraphConfigs!==this.state.flamegraphConfigs&&this.updateFlamegraphDirtiness()}shouldShowToolbar(){return void 0===this.props.showToolbar||this.props.showToolbar}}oc.defaultProps={showCredit:!1};const ic={showPyroscopeLogo:!1},sc=(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)?gi:pi};exports.Box=function(t){const{children:n,noPadding:a,className:r="",theme:o="dark"}=t,i=a?"":Xa.padding;return e.jsx("div",{className:`${Xa.box} ${i} ${r}`,"data-theme":o,children:n})},exports.DefaultPalette=fi,exports.Flamegraph=Ar,exports.FlamegraphI18nProvider=bi,exports.FlamegraphRenderer=n=>{const{i18n:a,locale:r,colorMode:o="light",sandwich:i=!0,...s}=n,l=t.useMemo(()=>sc(r,a),[r,a]),c=t.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.jsx("pyro-flamegraph",{className:c,children:e.jsx(bi,{messages:l,children:e.jsx(oc,{...ic,enableSandwichView:i,...s})})})},exports.convertJaegerTraceToProfile=function(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=u(t.children||[],e=>e.operationName);t.children=d(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=nc("single",t.levels),{version:1,flamebearer:t,metadata:{format:"single",units:"trace_samples",spyName:"tracing",sampleRate:1e6}}},exports.diffTwoProfiles=function(e,t){e.flamebearer.levels=ac("single",e.flamebearer.levels),t.flamebearer.levels=ac("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=Vl(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=nc("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}},exports.flamegraphDefaultMessages=pi,exports.flamegraphZhCNMessages=gi;
17
+ */var Yi,Zi=(Ji||(Ji=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}()}(Xi)),Xi.exports),qi=h(Zi),Ki={};function Gi(){return Yi||(Yi=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}(Ki)),Ki}var es,ts=Gi(),ns={};function as(){return es||(es=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}(ns)),ns}var rs=as(),os={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"},is="Button-module_button__Ed1ge",ss="Button-module_noIcon__Uzjvv",ls="Button-module_noBox__mLreC",cs="Button-module_customIcon__-slpC",fs="Button-module_iconWithText__DQRkr",us="Button-module_default__HhXlQ",ds="Button-module_outline__Flf4r",hs="Button-module_float__4marx",ms="Button-module_primary__xByv0",ps="Button-module_secondary__D0K-F",gs="Button-module_danger__5-vIq",vs="Button-module_grouped__j8KwB";const bs=t.forwardRef(function({disabled:t=!1,kind:n="default",type:a="button",icon:r,iconNode:o,children:i,grouped:s,onClick:l,id:c,className:f,form:u,noBox:d,autoFocus:h,...m},p){return e.jsxs("button",{...m,id:c,ref:p,type:a,"data-testid":m["data-testid"],disabled:t,onClick:l,form:u,autoFocus:h,"aria-label":m["aria-label"],className:qi(is,s?vs:"",ys(n),f,d&&ls,o&&cs,!r&&!o&&ss),children:[r?e.jsx(Ja,{icon:r,className:i?fs:""}):null,o,i]})});function ys(e){switch(e){case"default":return us;case"primary":return ms;case"secondary":return ps;case"danger":return gs;case"outline":return ds;case"float":return hs;default:throw Error(`Unsupported kind ${e}`)}}function xs({sortByDirection:n,sortBy:a,updateSortParams:r,table:o,tableBodyRef:i,className:s,isLoading:l,itemsPerPage:c}){const f=n&&a&&r,[u,d]=t.useState(0);return l?e.jsx("div",{className:os.loadingSpinner}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:Or(os.table,{[s||""]:s}),"data-testid":"table-ui",children:[e.jsx("thead",{children:e.jsx("tr",{children:o.headRow.map(({sortable:i,label:s,name:l,...c},u)=>i&&"not-filled"!==o.type&&f?t.createElement("th",{...c,key:u,className:os.sortable,onClick:()=>r(l)},s,e.jsx("span",{className:Or(os.sortArrow,{[os[n]]:a===l})})):e.jsx("th",{...c,children:s},u))})}),e.jsx("tbody",{ref:i,children:"not-filled"===o.type?e.jsx("tr",{className:null==o?void 0:o.bodyClassName,children:e.jsx("td",{colSpan:o.headRow.length,children:o.value})}):ws(o.bodyRows,u,c).map(({cells:t,isRowSelected:n,isRowDisabled:a,className:r,...o})=>{const i=Math.random();return e.jsx("tr",{...o,className:Or(r,{[os.isRowSelected]:n,[os.isRowDisabled]:a}),children:t&&t.map(({style:t,value:n,...a},r)=>e.jsx("td",{style:t,...a,children:n},i+r))},i)})})]}),e.jsx(js,{bodyRows:"filled"===o.type?o.bodyRows:void 0,itemsPerPage:c,currPage:u,setCurrPage:d})]})}function ws(e,t,n){return n?e.slice(t*n,n*(t+1)):e}function js({itemsPerPage:t,currPage:n,setCurrPage:a,bodyRows:r}){if(!t)return null;const o=!!r&&ws(r,n+1,t).length>0,i=!!r&&ws(r,n-1,t).length>0;return e.jsxs("nav",{className:os.pagination,children:[e.jsx(bs,{"aria-label":"Previous Page",disabled:!i,kind:"float",icon:ts.faChevronLeft,onClick:()=>a(n-1)}),e.jsx(bs,{disabled:!o,"aria-label":"Next Page",kind:"float",icon:rs.faChevronRight,onClick:()=>a(n+1)})]})}function ks({numTicks:n,sampleRate:a,units:r,tableBodyRef:o,palette:i}){const s=pr(n,a,r),l=s.format(n,a),c=yi(),f=t.useCallback((e,t,n)=>{var o;const f=null===(o=n.target.closest("tr"))||void 0===o?void 0:o.dataset.row;if(!f)return void t();const[u,d,...h]=f.split(";");switch(u){case"single":{const[t,n]=h,o=s.format(parseInt(t,10),a),i=s.format(parseInt(n,10),a),c=l.split(" "),f="<"===c[0]?c[1]:c[0],u=o.split(" "),m="<"===u[0]?u[1]:u[0],p=i.split(" "),g="<"===p[0]?p[1]:p[0];e({title:{text:d,diff:{text:"",color:""}},tooltipData:[{units:r,self:`${o}(${(parseFloat(m)/parseFloat(f)*100).toFixed(2)}%)`,total:`${i}(${(parseFloat(g)/parseFloat(f)*100).toFixed(2)}%)`,tooltipType:"table"}]});break}case"double":{const[t,n,o,l]=h,f=_i({formatter:s,sampleRate:a,totalLeft:parseInt(t,10),leftTicks:parseInt(n,10),totalRight:parseInt(o,10),rightTicks:parseInt(l,10),title:d,units:r},i,c);e({title:f.title,tooltipData:f.tooltipData});break}}},[s,a,r,l,i,c]);return e.jsx(Ni,{dataSourceRef:o,shouldShowTitle:!1,clickInfoSide:"left",setTooltipContent:f,palette:i})}const Ns=e=>e||0;function Ss(e,t,n,a){const r=t;return r.type="single",r.self=Ns(r.self)+e.getBarSelf(n,a),r.total=Ns(r.total)+e.getBarTotal(n,a),r}function Cs(e,t,n,a,r,o){const i=t;return i.type="double",i.self=Ns(i.self)+e.getBarSelf(n,a),i.total=Ns(i.total)+e.getBarTotal(n,a),i.selfLeft=Ns(i.selfLeft)+e.getBarSelfLeft(n,a),i.selfRght=Ns(i.selfRght)+e.getBarSelfRght(n,a),i.selfDiff=Ns(i.selfDiff)+e.getBarSelfDiff(n,a),i.totalLeft=Ns(i.totalLeft)+e.getBarTotalLeft(n,a),i.totalRght=Ns(i.totalRght)+e.getBarTotalRght(n,a),i.totalDiff=Ns(i.totalDiff)+e.getBarTotalDiff(n,a),i.leftTicks=r,i.rightTicks=o,i}function Ts(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 _s=({flamebearer:t,sortBy:n,sortByDirection:a,fitMode:r,handleTableItemClick:o,highlightQuery:i,palette:s,selectedItem:l,messages:c})=>{const{numTicks:f,maxSelf:u,sampleRate:d,spyName:h,units:m}=t,p=function(e){if(!e)return[];const{names:t,levels:n,format:a}=e,r="double"!==a?tr:nr,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?Ss(tr,l,s,n):Cs(nr,l,s,n,e.leftTicks,e.rightTicks)}}return Array.from(o.values())}(t).sort((e,t)=>t.total-e.total),g="asc"===a?1:-1;let v;if("name"===n)v=p.sort((e,t)=>g*e[n].localeCompare(t[n]));else switch(n){case"total":case"self":v=p.sort((e,t)=>g*(e[n]-t[n]));break;case"baseline":v=p.sort((e,t)=>g*(e.totalLeft/e.leftTicks-t.totalLeft/t.leftTicks));break;case"comparison":v=p.sort((e,t)=>g*(e.totalRght/e.rightTicks-t.totalRght/t.rightTicks));break;case"diff":v=p.sort((e,t)=>{const n=mr(hr(e.totalLeft/e.leftTicks),hr(e.totalRght/e.rightTicks)),a=mr(hr(t.totalLeft/t.leftTicks),hr(t.totalRght/t.rightTicks));return g*(n-a)});break;default:v=p}const b=pr(f,d,m),y=e=>!!l.isJust&&e===l.value,x=t=>{return e.jsx("button",{className:"table-item-button",children:e.jsx("div",{className:"symbol-name",style:(n=r,n===xr?{direction:"rtl",overflow:"hidden",textOverflow:"ellipsis"}:{overflow:"hidden",textOverflow:"ellipsis"}),children:t.name})});var n},w=v.filter(e=>!i||Tr(i,e.name)).map(e=>{if("double"===e.type)return(e=>{const t=hr(e.totalLeft/e.leftTicks),n=hr(e.totalRght/e.rightTicks),a=mr(t,n);let r="";a>0?r=s.badColor.rgb().string():a<0&&(r=s.goodColor.rgb().string());let i="";return e.totalLeft&&a!==1/0?e.totalRght?a>0?i=`+${a.toFixed(2)}%`:a<0&&(i=`${a.toFixed(2)}%`):i=c.diffRemoved:i=c.diffNew,{"data-row":`${e.type};${e.name};${e.totalLeft};${e.leftTicks};${e.totalRght};${e.rightTicks}`,isRowSelected:y(e.name),onClick:()=>o(e),cells:[{value:x(e)},{value:`${t} %`},{value:`${n} %`},{value:i,style:{color:r}}]}})(e);const t=Nr(h,e.name);return((e,t)=>({"data-row":`${e.type};${e.name};${e.self};${e.total}`,isRowSelected:y(e.name),onClick:()=>o(e),cells:[{value:x(e)},{value:b.format(e.self,d),style:Ts(e.self,u,t)},{value:b.format(e.total,d),style:Ts(e.total,f,t)}]}))(e,Sr(s,t))});return w.length>0?{bodyRows:w,type:"filled"}:{value:e.jsx("div",{className:"unsupported-format",children:c.noItemsFound}),type:"not-filled"}};function Ms({tableBodyRef:n,flamebearer:a,isDoubles:r,fitMode:o,handleTableItemClick:i,highlightQuery:s,selectedItem:l,palette:c}){const f=yi(),u=t.useMemo(()=>r?[{sortable:1,name:"name",label:f.location},{sortable:1,name:"baseline",label:f.baseline,default:!0},{sortable:1,name:"comparison",label:f.comparison},{sortable:1,name:"diff",label:f.diff}]:[{sortable:1,name:"name",label:f.location},{sortable:1,name:"self",label:f.self,default:!0},{sortable:1,name:"total",label:f.total}],[f,r]),d=(e=>{const n=e.filter(e=>null==e?void 0:e.default)[0]||e[0],[a,r]=t.useState(n.name),[o,i]=t.useState("desc");return{sortBy:a,sortByDirection:o,updateSortParams:e=>{let t=o;t=a===e?"asc"===t?"desc":"asc":"desc",r(e),i(t)}}})(u),h={headRow:u,..._s({flamebearer:a,sortBy:d.sortBy,sortByDirection:d.sortByDirection,fitMode:o,handleTableItemClick:i,highlightQuery:s,palette:c,selectedItem:l,messages:f})};return e.jsx(xs,{...d,tableBodyRef:n,table:h,className:qi("flamegraph-table",{"flamegraph-table-doubles":r})})}const Rs=t.memo(function({flamebearer:n,fitMode:a,handleTableItemClick:r,highlightQuery:o,palette:i,selectedItem:s}){const l=t.useRef(null),c="double"===n.format;return e.jsxs("div",{"data-testid":"table-view",className:c?"flamegraph-table-wrapper flamegraph-table-wrapper--double":"flamegraph-table-wrapper",children:[e.jsx("div",{className:"flamegraph-table-scroll",children:e.jsx(Ms,{tableBodyRef:l,flamebearer:n,isDoubles:c,fitMode:a,highlightQuery:o,handleTableItemClick:r,palette:i,selectedItem:s})}),e.jsx(ks,{tableBodyRef:l,numTicks:n.numTicks,sampleRate:n.sampleRate,units:n.units,palette:i})]})});var Ps,Es,Fs={},Is={};function As(){return Ps||(Ps=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}(Is)),Is}function Ds(){return Es||(Es=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=As();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}(Fs)),Fs}var Os,zs,Ls=Ds(),Bs={},$s={};function Vs(){return Os||(Os=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}($s)),$s}function Hs(){return zs||(zs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Vs();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}(Bs)),Bs}var Ws,Us,Qs=Hs(),Js={},Xs={};function Ys(){return Ws||(Ws=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}(Xs)),Xs}function Zs(){return Us||(Us=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ys();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}(Js)),Js}var qs=Zs();function Ks(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=>Ks(e)).filter(e=>!!e);return t.length?t.join(" "):void 0}return t.isValidElement(e)?Ks(e.props.children):void 0}}const Gs=({placement:t,title:n,content:a,children:r})=>{const o=Ks(null!=n?n:a);return o?e.jsx("span",{title:o,children:r}):e.jsx(e.Fragment,{children:r})};var el,tl={};function nl(){return el||(el=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}(tl)),tl}var al=nl(),rl="Input-module_input__ulQdV";const ol=t.forwardRef(({testId:t,className:n,type:a,name:r,placeholder:o,minLength:i=0,debounceTimeout:s=100,onChange:l,value:f,htmlId:u},d)=>e.jsx(c.DebounceInput,{inputRef:d,"data-testid":t,className:`${rl} ${n||""}`,type:a,name:r,placeholder:o,minLength:i,debounceTimeout:s,onChange:l,value:f,id:u}));var il="SharedQueryInput-module_wrapper__XRxrd",sl="SharedQueryInput-module_search__XlzRv",ll="SharedQueryInput-module_search-synced__J4T4b",cl="SharedQueryInput-module_searchWithSync__ryuQa",fl="SharedQueryInput-module_icon__Aq0Hv",ul="SharedQueryInput-module_checked__oRvod",dl="SharedQueryInput-module_sync__0IO2N",hl="SharedQueryInput-module_syncSelected__hstBI";const ml=({onHighlightChange:n,highlightQuery:a,sharedQuery:r,width:o})=>{const i=yi(),s=(e=>{const n=t.useRef();return t.useEffect(()=>{n.current=e},[e]),n.current})(null==r?void 0:r.syncEnabled);t.useEffect(()=>{"string"==typeof(null==r?void 0:r.searchQuery)&&(r.syncEnabled&&n(r.searchQuery),!r.syncEnabled&&s&&s!==(null==r?void 0:r.id)&&n(""))},[null==r?void 0:r.searchQuery,null==r?void 0:r.syncEnabled]);const l=t.useMemo(()=>r&&r.syncEnabled?r.searchQuery||"":a,[r,a]),c=t.useMemo(()=>`${r?cl:sl} ${(null==r?void 0:r.syncEnabled)?ll:""}`,[r]),f=(null==r?void 0:r.syncEnabled)?i.unsyncSearchBars:i.syncSearchBars;return e.jsxs("div",{className:il,style:{width:o},children:[e.jsx(ol,{testId:"flamegraph-search",className:c,type:"search",name:"flamegraph-search",placeholder:i.searchPlaceholder,minLength:1,debounceTimeout:100,onChange:e=>{n(e.target.value),r&&r.syncEnabled&&r.onQueryChange(e.target.value)},value:l}),r?e.jsx(Gs,{placement:"top",title:f,children:e.jsx("button",{className:r.syncEnabled?hl:dl,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.jsx(Ja,{className:`${r.syncEnabled?ul:fl}`,icon:al.faLink})})}):null]})};var pl="DiffLegend-module_flamegraph-legend__Cywr1",gl="DiffLegend-module_flamegraph-legend-list__swdXj",vl="DiffLegend-module_flamegraph-legend-item__0P-6g";function bl(t){const{palette:n,showMode:a}=t,r=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}`)}}(a),o=Cr(n);return e.jsx("div",{"data-testid":"flamegraph-legend",className:`${pl} ${gl}`,children:r.map(t=>e.jsxs("div",{className:vl,style:{backgroundColor:o(t).rgb().toString()},children:[t>0?"+":"",t,"%"]},t))})}function yl(){return e.jsx("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.jsx("g",{children:e.jsx("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 xl="Dropdown-module_dropdownMenu__tbN8r",wl="Dropdown-module_dropdownMenuButton__Xy8M4";function jl({id:t,children:n,className:a,disabled:r,value:o,label:i,onItemClick:s,overflow:l,position:c,direction:f,align:u,viewScroll:d,arrow:h,menuButtonClassName:m="",ariaLabel:p,portal:g,...v}){const b=v.menuButton||e.jsx(Nl,{"aria-label":p,className:`${wl} ${m}`,disabled:r,type:"button",children:o||i});return e.jsxs(ei,{id:t,"aria-label":p,className:qi(a,xl),"data-testid":v["data-testid"],onItemClick:s,overflow:l,position:c,direction:f,align:u,viewScroll:d,arrow:h,menuButton:b,portal:g,children:[e.jsx(ai,{children:i}),n]})}const kl=ni,Nl=Ao;var Sl="DiffLegendPaletteDropdown-module_container__h8Tts",Cl="DiffLegendPaletteDropdown-module_triggerButton__oezA6",Tl="DiffLegendPaletteDropdown-module_dropdownArrow__-Lu0w",_l="DiffLegendPaletteDropdown-module_menuItem__5iWry",Ml="DiffLegendPaletteDropdown-module_menuItemText__a-tt0";const Rl=[fi,ui],Pl=t=>{const{palette:n=fi,onChange:a}=t,r=yi(),o=e=>"Default"===e.name?r.paletteDefaultName:"Color Blind"===e.name?r.paletteColorBlindName:e.name,i=e=>"Default"===e.name?r.paletteDefaultDesc:"Color Blind"===e.name?r.paletteColorBlindDesc:"";return e.jsx("div",{className:Sl,children:e.jsx(jl,{label:r.diffLegendSelectPalette,align:"end",menuButton:e.jsxs(Nl,{className:qi(wl,Cl),children:[e.jsx(bl,{palette:n,showMode:"small"}),e.jsx("span",{className:Tl})]}),onItemClick:e=>{e.value&&a(e.value)},children:Rl.map(t=>e.jsx(kl,{value:t,children:e.jsxs("div",{className:_l,children:[e.jsxs("span",{className:Ml,children:[o(t)," ",i(t)]}),t.name===n.name&&e.jsx(yl,{})]})},t.name))})})};var El={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 Fl=b.bind(El),Il=(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},Al=()=>e.jsx("div",{className:El.divider}),Dl=t.memo(({view:n,handleSearchChange:a,highlightQuery:r,isFlamegraphDirty:o,reset:s,updateFitMode:l,fitMode:c,updateView:f,selectedNode:u,onFocusOnSubtree:d,flamegraphType:h,enableChangingDisplay:m=!0,sharedQuery:p,ExportData:g,palette:v,setPalette:b})=>{const y=t.useRef(null),x=yi(),w="double"===h&&v&&b,j=[{el:e.jsxs(e.Fragment,{children:[e.jsx(Ll,{fitMode:c,updateFitMode:l}),e.jsx(Al,{})]}),width:93},{el:e.jsx(zl,{isFlamegraphDirty:o,reset:s}),width:44},{el:e.jsxs(e.Fragment,{children:[e.jsx(Ol,{selectedNode:u,onFocusOnSubtree:d}),e.jsx(Al,{})]}),width:49},m?{el:e.jsx($l,{flamegraphType:h,view:n,updateView:f}),width:44*("single"===h?5:3)}:null,t.isValidElement(g)?{el:e.jsxs(e.Fragment,{children:[e.jsx(Al,{}),g]}),width:49}:null].filter(e=>null!==e),k=j.reduce((e,t)=>[...e,t.width],[]),{isCollapsed:N,collapsedItemsNumber:S,handleMoreClick:C}=((e,n)=>{const[a,r]=t.useState(!0),[o,s]=t.useState(0);return t.useLayoutEffect(()=>{if(e.current){const{width:t}=e.current.getBoundingClientRect(),a=Il(t,o,n);s(a)}},[e.current,n]),i(e,e=>{const{width:t}=e.target.getBoundingClientRect(),a=Il(t,o,n);s(a),r(!0)}),{isCollapsed:a,handleMoreClick:()=>{r(e=>!e)},collapsedItemsNumber:o}})(y,k),T=j.reduce((e,t,n)=>(n<S?e.hidden.push(t):e.visible.push(t),e),{visible:[],hidden:[]});return e.jsx("div",{role:"toolbar",ref:y,children:e.jsxs("div",{className:El.navbar,children:[e.jsx("div",{className:El.searchWrapper,children:e.jsx(ml,{width:360,onHighlightChange:a,highlightQuery:r,sharedQuery:p})}),e.jsxs("div",{className:El.rightSection,children:[w&&e.jsxs(e.Fragment,{children:[e.jsx(Pl,{palette:v,onChange:b}),e.jsx(Al,{})]}),e.jsxs("div",{className:El.itemsContainer,children:[T.visible.map((t,n)=>e.jsx("div",{className:El.item,style:{width:t.width},children:t.el},n)),0!==S&&e.jsx(Gs,{placement:"top",title:x.more,children:e.jsx("button",{onClick:C,className:Fl({[El.moreButton]:!0,[El.active]:!N}),children:e.jsx(Ja,{icon:qs.faEllipsisV})})})]})]}),!N&&e.jsx("div",{className:El.navbarCollapsedItems,children:T.hidden.map((t,n)=>e.jsx("div",{className:El.item,style:{width:t.width},children:t.el},n))})]})})});function Ol({onFocusOnSubtree:t,selectedNode:n}){const a=yi(),r=n.mapOr(()=>{},e=>()=>t(e.i,e.j));return e.jsx(Gs,{placement:"top",title:a.collapseNodesAbove,children:e.jsx("div",{children:e.jsx(bs,{disabled:!n.isJust,onClick:r,className:El.collapseNodeButton,"aria-label":a.collapseNodesAbove,children:e.jsx(Ja,{icon:so.faCompressAlt})})})})}function zl({isFlamegraphDirty:t,reset:n}){const a=yi();return e.jsx(Gs,{placement:"top",title:a.resetView,children:e.jsx("span",{children:e.jsx(bs,{id:"reset",disabled:!t,onClick:n,className:El.resetViewButton,"aria-label":a.resetView,children:e.jsx(Ja,{icon:Ls.faUndo})})})})}function Ll({fitMode:t,updateFitMode:n}){const a=yi(),r=e=>t===e;return e.jsxs(e.Fragment,{children:[e.jsx(Gs,{placement:"top",title:a.headFirst,children:e.jsx(bs,{onClick:()=>n("HEAD"),className:Fl({[El.fitModeButton]:!0,[El.selected]:r("HEAD")}),children:e.jsx(Oi,{})})}),e.jsx(Gs,{placement:"top",title:a.tailFirst,children:e.jsx(bs,{onClick:()=>n("TAIL"),className:Fl({[El.fitModeButton]:!0,[El.selected]:r("TAIL")}),children:e.jsx(zi,{})})})]})}const Bl=(t,n)=>"single"===t?[{label:n.viewTable,value:"table",Icon:Fi},{label:n.viewTableAndFlamegraph,value:"both",Icon:Ii},{label:n.viewFlamegraph,value:"flamegraph",Icon:Ai},{label:n.viewSandwich,value:"sandwich",Icon:Di},{label:n.viewGraphviz,value:"graphviz",Icon:()=>e.jsx(Ja,{icon:Qs.faProjectDiagram})}]:[{label:n.viewTable,value:"table",Icon:Fi},{label:n.viewTableAndFlamegraph,value:"both",Icon:Ii},{label:n.viewFlamegraph,value:"flamegraph",Icon:Ai}];function $l({view:t,updateView:n,flamegraphType:a}){const r=yi(),o=Bl(a,r);return e.jsx("div",{className:El.viewType,children:o.map(({label:a,value:r,Icon:o})=>e.jsx(Gs,{placement:"top",title:a,children:e.jsx(bs,{"data-testid":r,onClick:()=>n(r),className:Fl({[El.toggleViewButton]:!0,selected:t===r}),children:e.jsx(o,{})})},r))})}function Vl(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 Hl=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 Wl(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)Wl(e.children[t])}function Ul(e,t){const n=function(e,t){const n=Vl(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),Wl(r),{...a,...Hl(r)}}(JSON.parse(JSON.stringify(e)),t);return n}function Ql(e,t){const n=function(e,t){const n=Vl(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]))}),Wl(i);const l=Hl(i);return l.levels=l.levels.reverse().slice(0,-1),{...a,...l}}(JSON.parse(JSON.stringify(e)),t);return n}var Jl={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 Xl(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 Yl(e,t){return`${(100*e/t).toFixed(2)}%`}function Zl(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 ql(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=Zl(o/a,!1),f=Zl(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} (${Yl(n,r)})`:o+="0";let s=i;a!==n&&(o+=0!==n?"\n":" ",s=e(a),o=`${o}of ${s} (${Yl(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} ${Xl(d)}`}function Kl(e){if("double"===e.metadata.format)return"diff flamegraphs are not supported";const t=Vl(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=pr(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}),x={};function w(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=>{x[e.name]=e}),y.slice(80).forEach(e=>{delete x[e.name]}),function e(t,n){const a=!x[t.name];t.children.forEach(r=>{const o=!x[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=x,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;w(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(ql(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:Zl(o/n,!1),style:t.residual?"dotted":""};return`N${t.from.index} -> N${t.to.index} ${Xl(l)}`}(f,d[e],o))}),`digraph "unnamed" {\n fontname= ""\n ${n.join("\n")}\n ${a.join("\n")}\n }`}var Gl="GraphVizPanel-module_graphVizPane__B18cQ";const ec=()=>null;function tc({flamebearer:n}){var a,r;const o=n,i=(null===(a=o.metadata)||void 0===a?void 0:a.format)&&(null===(r=o.flamebearer)||void 0===r?void 0:r.levels),s=`graphviz-pane-${(null==o?void 0:o.appName)||String((new Date).valueOf())}`,l=t.useMemo(()=>Kl(o),[JSON.stringify(o)]);return e.jsx("div",{className:Gl,children:i?e.jsx(ec,{options:{zoom:!0,width:"150%",height:"100%",scale:1,useWorker:!1},dot:l}):e.jsx("div",{children:"NO DATA"})},s)}function nc(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 ac(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 rc(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=ac(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 oc extends t.Component{constructor(t){super(t),this.resetFlamegraphState={focusedNode:n.Maybe.nothing(),zoom:n.Maybe.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[ar(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.Maybe.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 a={...this.state.flamegraphConfigs};const{zoom:r}=this.state.flamegraphConfigs;r.isJust&&r.value.i<=e&&(a={...a,zoom:this.initialFlamegraphState.zoom}),this.setState({...this.state,flamegraphConfigs:{...a,focusedNode:n.Maybe.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.Maybe.nothing()}):this.setState({selectedItem:n.Maybe.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 t=e.jsx("div",{className:Or(Jl.tablePane,"vertical"===this.state.panesOrientation?Jl.vertical:Jl.horizontal),children:e.jsx(Rs,{"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"),n=this.shouldShowToolbar(),a=e.jsx(Qi,{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:n,setPalette:this.handleSetPalette,enableSandwichView:this.props.enableSandwichView},"flamegraph-pane"),r=(()=>{if(this.state.selectedItem.isNothing)return e.jsx("div",{className:Jl.sandwichPane,children:e.jsxs("div",{className:Or(Jl.sandwichPaneInfo,"vertical"===this.state.panesOrientation?Jl.vertical:Jl.horizontal),children:[e.jsx("div",{className:Jl.arrow}),"Select a function to view callers/callees sandwich view"]})},"sandwich-pane");const t=Ql(this.state.flamebearer,this.state.selectedItem.value),a=Ul(this.state.flamebearer,this.state.selectedItem.value),r=t=>e.jsx(Qi,{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:n,setPalette:this.handleSetPalette,...t});return e.jsxs("div",{className:Jl.sandwichPane,children:[e.jsxs("div",{className:Jl.sandwichTop,children:[e.jsx("span",{className:Jl.name,children:"Callers"}),r({flamebearer:t})]}),e.jsxs("div",{className:Jl.sandwichBottom,children:[e.jsx("span",{className:Jl.name,children:"Callees"}),r({flamebearer:a,headerVisible:!1,showSingleLevel:!0})]})]},"sandwich-pane")})(),o=!this.state.flamebearer||this.state.flamebearer.names.length<=1,i=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,a,t,r,e.jsx(tc,{flamebearer:this.state.flamebearer}));return e.jsxs("div",{children:[e.jsxs("div",{children:[n&&e.jsx(Dl,{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.jsx("div",{className:`${Jl.flamegraphContainer} ${Or("vertical"===this.state.panesOrientation?Jl.vertical:Jl.horizontal,Jl[this.state.panesOrientation],Jl.panesWrapper)}`,children:o?e.jsx(Lr,{}):i.map(e=>e)})]}),this.props.showPyroscopeLogo&&e.jsxs("div",{className:Jl.createdBy,children:["Created by",e.jsxs("a",{href:"https://twitter.com/PyroscopeIO",rel:"noreferrer",target:"_blank",children:[e.jsx(f,{width:"30",height:"30"}),"@PyroscopeIO"]})]})]})},this.state={isFlamegraphDirty:!1,view:this.props.onlyDisplay?this.props.onlyDisplay:"both",fitMode:"HEAD",flamebearer:rc(t),panesOrientation:t.panesOrientation?t.panesOrientation:"horizontal",searchQuery:"",selectedItem:n.Maybe.nothing(),flamegraphConfigs:this.initialFlamegraphState,palette:fi}}componentDidUpdate(e,t){const a=rc(e),r=rc(this.props);if(!this.isSameFlamebearer(a,r)){const e=this.calcNewConfigs(a,r);return void this.setState({flamebearer:r,flamegraphConfigs:{...this.state.flamegraphConfigs,...e},selectedItem:n.Maybe.nothing()})}t.flamegraphConfigs!==this.state.flamegraphConfigs&&this.updateFlamegraphDirtiness()}shouldShowToolbar(){return void 0===this.props.showToolbar||this.props.showToolbar}}oc.defaultProps={showCredit:!1};const ic={showPyroscopeLogo:!1},sc=(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)?gi:pi};exports.Box=function(t){const{children:n,noPadding:a,className:r="",theme:o="dark"}=t,i=a?"":Xa.padding;return e.jsx("div",{className:`${Xa.box} ${i} ${r}`,"data-theme":o,children:n})},exports.DefaultPalette=fi,exports.Flamegraph=Ar,exports.FlamegraphI18nProvider=bi,exports.FlamegraphRenderer=n=>{const{i18n:a,locale:r,colorMode:o="light",sandwich:i=!0,...s}=n,l=t.useMemo(()=>sc(r,a),[r,a]),c=t.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.jsx("pyro-flamegraph",{className:c,children:e.jsx(bi,{messages:l,children:e.jsx(oc,{...ic,enableSandwichView:i,...s})})})},exports.convertJaegerTraceToProfile=function(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=u(t.children||[],e=>e.operationName);t.children=d(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=nc("single",t.levels),{version:1,flamebearer:t,metadata:{format:"single",units:"trace_samples",spyName:"tracing",sampleRate:1e6}}},exports.diffTwoProfiles=function(e,t){e.flamebearer.levels=ac("single",e.flamebearer.levels),t.flamebearer.levels=ac("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=Vl(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=nc("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}},exports.flamegraphDefaultMessages=pi,exports.flamegraphZhCNMessages=gi;
18
18
  //# sourceMappingURL=index.node.cjs.js.map