=k&&(k=w+1);!(y=v[k])&&++k=0;)(i=r[a])&&(o&&4^i.compareDocumentPosition(o)&&o.parentNode.insertBefore(i,o),o=i);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=od);for(var n=this._groups,i=n.length,r=Array(i),a=0;a1?this.each((null==t?function(e){return function(){this.style.removeProperty(e)}}:"function"==typeof t?function(e,t,n){return function(){var i=t.apply(this,arguments);null==i?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}:function(e,t,n){return function(){this.style.setProperty(e,t,n)}})(e,t,null==n?"":n)):(i=this.node()).style.getPropertyValue(e)||ov(i).getComputedStyle(i,null).getPropertyValue(e)},property:function(e,t){return arguments.length>1?this.each((null==t?function(e){return function(){delete this[e]}}:"function"==typeof t?function(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}:function(e,t){return function(){this[e]=t}})(e,t)):this.node()[e]},classed:function(e,t){var n=ox(e+"");if(arguments.length<2){for(var i=ob(this.node()),r=-1,a=n.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}),o=a.length;if(arguments.length<2){var s=this.node().__on;if(s){for(var l,c=0,u=s.length;cn(e)}}function oH({data:e,width:t,height:n,labelFn:a,subLabelFn:o,valueFn:s}){let l=(0,b.useRef)(null),[c,u]=(0,b.useState)(e),[d,f]=(0,b.useState)([oY(e,a,u)]);(0,b.useEffect)(()=>{u(e),f([oY(e,a,u)])},[e,a,u]);let p=(0,b.useRef)(d);p.current=d;let g=(0,b.useCallback)(e=>{u(e.data);let t=e.ancestors().reverse(),n=[...p.current.slice(0,p.current.length-1)];for(let e=0;e{u(i.data),f([...r,o])}};n.push(o)}f(n)},[u]),[v,x]=(0,b.useMemo)(()=>[(function(){var e=aA,t=!1,n=1,i=1,r=[0],a=aE,o=aE,s=aE,l=aE,c=aE;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=i,e.eachBefore(h),r=[0],t&&e.eachBefore(aC),e}function h(t){var n=r[t.depth],i=t.x0+n,u=t.y0+n,h=t.x1-n,d=t.y1-n;ht.value-e.value)),function e(){var t,n,a=(n=(t=(function(){var e,t,n,i,r,a=0,o=1,s=aW,l=!1;function c(t){return null==t||isNaN(t=+t)?r:s(0===n?.5:(t=(i(t)-e)*n,l?Math.max(0,Math.min(1,t)):t))}function u(e){return function(t){var n,i;return arguments.length?([n,i]=t,s=e(n,i),c):[s(0),s(1)]}}return c.domain=function(r){return arguments.length?([a,o]=r,e=i(a=+a),t=i(o=+o),n=e===t?0:1/(t-e),c):[a,o]},c.clamp=function(e){return arguments.length?(l=!!e,c):l},c.interpolator=function(e){return arguments.length?(s=e,c):s},c.range=u(function e(t,n){var i,r,a=typeof n;return null==n||"boolean"===a?aT(n):("number"===a?az:"string"===a?(r=(0,aL.default)(n))?(n=r,a_):function(e,t){var n,i,r,a,o,s=aO.lastIndex=aN.lastIndex=0,l=-1,c=[],u=[];for(e+="",t+="";(r=aO.exec(e))&&(a=aN.exec(t));)(o=a.index)>s&&(o=t.slice(s,o),c[l]?c[l]+=o:c[++l]=o),(r=r[0])===(a=a[0])?c[l]?c[l]+=a:c[++l]=a:(c[++l]=null,u.push({i:l,x:az(r,a)})),s=aN.lastIndex;return s0))return[];if(e===t)return[e];let i=t=r))return[];let s=a-r+1,l=Array(s);if(i){if(o<0)for(let e=0;e0;){if((r=aq(l,c,e))===i)return a[o]=l,a[s]=c,n(a);if(r>0)l=Math.floor(l/r)*r,c=Math.ceil(c/r)*r;else if(r<0)l=Math.ceil(l*r)/r,c=Math.floor(c*r)/r;else break;i=r}return t},t);return a.copy=function(){return e().domain(a.domain()).interpolator(a.interpolator()).clamp(a.clamp()).unknown(a.unknown())},aj.apply(a,arguments)}([8,0],a7)],[t,n,c,s]);return(0,b.useLayoutEffect)(()=>{var e;if(!l.current)return;let t="string"==typeof(e=l.current)?new oO([[document.querySelector(e)]],[document.documentElement]):new oO([[e]],oz);console.log("Rendering svg",t);let n=oF("shadow");t.append("filter").attr("id",n.id).append("feDropShadow").attr("flood-opacity",.3).attr("dx",0).attr("stdDeviation",3);let i=t.selectAll("g").data(v).attr("filter",n).join("g").attr("transform",e=>`translate(${e.x0},${e.y0})`).style("cursor",e=>e.children?"pointer":"default").style("font-weight",e=>e.children?"bold":"auto").on("click",(e,t)=>t.children?g(t):null);return i.append("title").text(e=>a(e.data)+" / "+o(e.data,e.value)),i.append("rect").attr("id",e=>(e.nodeUid=e.nodeUid||oF("node")).id).attr("fill",e=>x(e.height)).attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0),i.append("clipPath").attr("id",e=>(e.clipUid=e.clipUid||oF("clip")).id).append("use").attr("xlink:href",e=>e.nodeUid.href),i.append("text").attr("clip-path",e=>e.clipUid).selectAll("tspan").data(e=>[a(e.data)+(e.children?" (+"+(e.descendants().length-1)+")":""),o(e.data,e.value)]).join("tspan").attr("fill-opacity",(e,t,n)=>t===n.length-1?.7:null).text(e=>e),i.filter(e=>e.children&&e.children.length>0).selectAll("tspan").attr("dx",3).attr("y",13),i.filter(e=>!e.children||0===e.children.length).selectAll("tspan").attr("x",3).attr("y",(e,t,n)=>`${(t===n.length-1)*.3+1.1+.9*t}em`),()=>{t.selectAll("*").remove()}},[t,n,v]),(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{className:"breadcrumbs mv1 pv1",children:d.map((e,t)=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:"b pointer",onClick:e.activate,children:e.name},e.name),t(function e(t){for(let n=0;ne.part===o);s||(s={name:r,part:o,value:0,children:[]},i.children.push(s)),i=s,n===a.length-1&&(i.value+="time"===e?t.time:t.alloc)}}(e,i,n);return(0,ik.forEach)(n.children,e=>{n.value+=e.value}),console.log("Built nestedData",n),n}(e,n)),[e,n]),r=(0,b.useRef)(null),[a,o]=(0,b.useState)(null),s=(0,b.useMemo)(()=>new ResizeObserver(()=>{(0,ik.debounce)(()=>{r.current&&o({height:r.current.clientHeight,width:r.current.clientWidth})},10)()}),[r.current]);return(0,b.useEffect)(()=>{if(!r)return;let e=r.current;return s.observe(e),()=>{s.unobserve(e)}},[r.current,s]),(0,h.jsx)("div",{ref:r,style:oB,children:a&&(0,h.jsx)(oH,{width:a.width,height:a.height,data:i,labelFn:e=>e.name,subLabelFn:(t,n)=>"time"===e?iC(n):iS(n),valueFn:e=>e.value})})}const oj=window.module_data;(0,d.render)((0,h.jsx)(function(){let[e,t]=b.useState("bars"),[n,i]=b.useState("time"),[r,a]=b.useState(50),o=b.useMemo(()=>(0,ik.reduce)(oj.phasesByTime,(e,t)=>e+t.time,0),[oj]),s=b.useMemo(()=>(0,ik.reduce)(oj.phasesByAlloc,(e,t)=>e+t.alloc,0),[oj]);console.log("App got data",oj);let l=b.useCallback(e=>t(e.target.value),[t]),c=b.useCallback(e=>i(e.target.value),[i]),u=b.useCallback(e=>a(e.target.value),[a]);return(0,h.jsxs)("div",{className:"center w-80",children:[(0,h.jsxs)("div",{className:"ba b--silver pa1 mv1 flex flex-row justify-between",children:[(0,h.jsxs)("div",{children:[(0,h.jsxs)(iw,{value:e,onChange:l,children:[(0,h.jsx)(t9,{value:"bars",children:"Bar chart"}),(0,h.jsx)(t9,{value:"treemap",children:"Treemap"})]}),(0,h.jsxs)(iw,{className:"ml2",value:n,onChange:c,children:[(0,h.jsx)(t9,{value:"time",children:"Time (ms)"}),(0,h.jsx)(t9,{value:"alloc",children:"Allocations (bytes)"})]}),"bars"===e&&(0,h.jsxs)(iw,{className:"ml2",value:r,onChange:u,children:[(0,h.jsx)(t9,{value:10,children:"Top 10 modules"}),(0,h.jsx)(t9,{value:20,children:"Top 20 modules"}),(0,h.jsx)(t9,{value:50,children:"Top 50 modules"}),(0,h.jsx)(t9,{value:100,children:"Top 100 modules"}),(0,h.jsx)(t9,{value:1/0,children:"All modules"})]})]}),(0,h.jsxs)("div",{className:"dib",children:[(0,h.jsxs)("div",{className:"dib mr2",children:[(0,h.jsx)("div",{className:"gray",children:"Total time"}),(0,h.jsx)("div",{className:"gray",children:"Total allocations"})]}),(0,h.jsxs)("div",{className:"dib near-black",children:[(0,h.jsx)("div",{className:"code",children:iC(o)}),(0,h.jsx)("div",{className:"code",children:iS(s)})]})]})]}),"bars"===e&&(0,h.jsx)(av,{aggregate:n,data:oj,numModulesToShow:r}),"treemap"===e&&(0,h.jsx)(oW,{aggregate:n,data:oj})]})},{}),document.getElementById("root"));