@mesh.ai/rabbit 0.0.36 → 0.0.37

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.
@@ -14439,10 +14439,10 @@ function wO({ count: e, totalCount: t, title: n, subTitle: r, className: o, unst
14439
14439
  children: [
14440
14440
  /* @__PURE__ */ Me("div", { className: "self-stretch px-3 py-1 flex items-baseline", children: [
14441
14441
  /* @__PURE__ */ te("div", { className: "text-zinc-800 text-2xl font-semibold", children: e }),
14442
- t && /* @__PURE__ */ Me("div", { className: "text-stone-500 text-xs font-normal", children: [
14442
+ t && t > 0 ? /* @__PURE__ */ Me("div", { className: "text-stone-500 text-xs font-normal", children: [
14443
14443
  "/",
14444
14444
  t
14445
- ] })
14445
+ ] }) : null
14446
14446
  ] }),
14447
14447
  /* @__PURE__ */ te("div", { className: "self-stretch px-3 justify-start items-center gap-2 inline-flex", children: /* @__PURE__ */ Me("div", { className: "grow shrink basis-0 flex-col justify-start items-start gap-0.5 inline-flex", children: [
14448
14448
  /* @__PURE__ */ te("div", { className: "self-stretch justify-start items-start gap-2.5 inline-flex", children: /* @__PURE__ */ te("div", { className: "grow shrink basis-0 text-zinc-800 text-xs font-semibold leading-none", children: n }) }),
@@ -43,4 +43,4 @@ z`).split(`
43
43
  `)} {
44
44
  ${Jt}
45
45
  }
46
- `}),I.appendChild(M.createTextNode(qe))}z.timeEnd("clone node"),re==null||re(ve),te!==!1&&ae(ve)&&(z.time("embed web font"),yield Pk(ve,k),z.timeEnd("embed web font")),z.time("embed node"),np(ve,k);const be=G.length;let xe=0;const ke=()=>v(this,null,function*(){for(;;){const qe=G.pop();if(!qe)break;try{yield qe}catch(Lt){Me("Failed to run task",Lt)}ne==null||ne(++xe,be)}});ne==null||ne(xe,be),yield Promise.all([...Array(4)].map(ke)),z.timeEnd("embed node"),ge==null||ge(ve);const Se=zk(ve,k);return q&&Se.insertBefore(q,Se.children[0]),I&&Se.insertBefore(I,Se.children[0]),se&&Kh(k),pe==null||pe(Se),Se})}function zk(h,$){const{width:k,height:M}=$,z=qr(k,M,h.ownerDocument),G=z.ownerDocument.createElementNS(z.namespaceURI,"foreignObject");return G.setAttributeNS(null,"x","0%"),G.setAttributeNS(null,"y","0%"),G.setAttributeNS(null,"width","100%"),G.setAttributeNS(null,"height","100%"),G.append(h),z.appendChild(G),z}function wi(h,$){return v(this,null,function*(){var k;const M=yield et(h,$),z=yield rp(M),G=er(z,M.isEnable("removeControlCharacter"));M.autoDestruct||(M.svgStyleElement=He(M.ownerDocument),M.svgDefsElement=(k=M.ownerDocument)==null?void 0:k.createElementNS(wn,"defs"),M.svgStyles.clear());const I=wt(G,z.ownerDocument);return yield _t(I,M)})}function Fk(h,$){return v(this,null,function*(){const k=yield et(h,$),{log:M,type:z,quality:G,dpi:I}=k,q=yield wi(k);M.time("canvas to blob");const Q=yield ci(q,z,G);if(["image/png","image/jpeg"].includes(z)&&I){const te=yield hi(Q.slice(0,33));let ne=new Uint8Array(te);return z==="image/png"?ne=N(ne,I):z==="image/jpeg"&&(ne=S(ne,I)),new Blob([ne,Q.slice(33)],{type:z})}return M.timeEnd("canvas to blob"),Q})}function rr(h,$){return v(this,null,function*(){const k=yield et(h,$),{log:M,quality:z,type:G,dpi:I}=k,q=yield wi(k);M.time("canvas to data url");let Q=q.toDataURL(G,z);if(["image/png","image/jpeg"].includes(G)&&I&&F&&B){const[te,ne]=Q.split(",");let se=0,re=!1;if(G==="image/png"){const Se=X(ne);Se>=0?(se=Math.ceil((Se+28)/3)*4,re=!0):se=33/3*4}else G==="image/jpeg"&&(se=18/3*4);const ge=ne.substring(0,se),pe=ne.substring(se),ve=window.atob(ge),be=new Uint8Array(ve.length);for(let Se=0;Se<be.length;Se++)be[Se]=ve.charCodeAt(Se);const xe=G==="image/png"?N(be,I,re):S(be,I),ke=window.btoa(String.fromCharCode(...xe));Q=[te,",",ke,pe].join("")}return M.timeEnd("canvas to data url"),Q})}function op(h,$){return v(this,null,function*(){const k=yield et(h,$),{width:M,height:z,ownerDocument:G}=k,I=yield rr(k),q=qr(M,z,G),Q=q.ownerDocument.createElementNS(q.namespaceURI,"image");return Q.setAttributeNS(null,"href",I),Q.setAttributeNS(null,"height","100%"),Q.setAttributeNS(null,"width","100%"),q.appendChild(Q),er(q,k.isEnable("removeControlCharacter"))})}function Wk(h,$){return v(this,null,function*(){const k=yield et(h,$),{ownerDocument:M,width:z,height:G,scale:I,type:q}=k,Q=q==="image/svg+xml"?yield op(k):yield rr(k),te=wt(Q,M);return te.width=Math.floor(z*I),te.height=Math.floor(G*I),te.style.width=`${z}px`,te.style.height=`${G}px`,te})}function Bk(h,$){return v(this,null,function*(){return rr(yield et(h,m(d({},$),{type:"image/jpeg"})))})}function Uk(h,$){return v(this,null,function*(){const k=yield et(h,$),M=yield wi(k);return M.getContext("2d").getImageData(0,0,M.width,M.height).data})}function Hk(h,$){return v(this,null,function*(){return rr(yield et(h,m(d({},$),{type:"image/png"})))})}function qk(h,$){return v(this,null,function*(){return rr(yield et(h,m(d({},$),{type:"image/webp"})))})}n.createContext=mi,n.destroyContext=Kh,n.domToBlob=Fk,n.domToCanvas=wi,n.domToDataUrl=rr,n.domToForeignObjectSvg=rp,n.domToImage=Wk,n.domToJpeg=Bk,n.domToPixel=Uk,n.domToPng=Hk,n.domToSvg=op,n.domToWebp=qk,n.loadMedia=At,n.waitUntilLoad=Gr,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})})})(sl,sl.exports);var XT=sl.exports;const ll=(e,t,n)=>{g.useImperativeHandle(t,()=>({download(){e.current&&XT.domToPng(e.current,{scale:5}).then(r=>{const o=document.createElement("a");o.download=`${n}.png`,o.href=r,o.click()})}}))},KT=({x:e,y:t,datum:n,size:r})=>H.jsx(Fs,{cx:e,cy:t,stroke:n.color.dark,strokeWidth:1,fill:n.color.light,r:r/2}),ZT=({x:e,y:t,datum:n})=>H.jsx(Fs,{cx:e,cy:t,stroke:n.color.dark,strokeWidth:1,fill:n.color.dark,r:5,style:{zIndex:1500}}),ri={xAccessor:e=>e.x,yAccessor:e=>e.y},Ph=(e,t,n)=>n==="pre"?`${t}${e}`:`${e}${t}`,Nh=10,QT=5,ul=g.forwardRef(({nodes:e,height:t,width:n,xAxisValues:r,series:o,xAxisLabel:i,yAxisLabel:a,xAxisDomain:s,yAxisDomain:l,xAxisUnitSymbol:u,yAxisUnitSymbol:c,tooltipTitle:f,mode:d,xAxisCharLimit:m,connectNulls:p=!1,maxNodesInMiniMode:v=QT,tooltipStackCharLimit:S=Nh},b)=>{const[x,C]=g.useState(e.map(E=>E.id)),O=g.useRef(null);ll(O,b,`${i}-${a}-LineChart`);const y=g.useMemo(()=>o.map((E,N)=>({points:E.data.map((j,L)=>({x:r[L],y:j,nodeId:E.id,color:Ue(N)}))})).slice(0,d==="mini"?v:o.length),[r,o,d,v]),T=g.useMemo(()=>d==="full"?y.filter(E=>x.includes(E.points[0].nodeId)):y,[y,x,d]),D=g.useMemo(()=>Math.floor((n-(d==="mini"?0:150))/(r.length*8)),[n,r,d]);return H.jsxs("div",{ref:O,id:"line-chart",className:"bg-white flex flex-col rabbit-ds",style:{width:n,height:t},children:[H.jsxs("div",{className:"w-full min-w-0 min-h-0 h-full flex flex-row",children:[H.jsx("div",{className:"w-full min-w-0 min-h-0 h-full",children:H.jsxs(qn,{margin:{top:10,left:50,right:50,bottom:50},xScale:{type:"band",nice:!0,...s&&{domain:s}},yScale:{type:"linear",nice:!0,...l&&{domain:l}},children:[H.jsx(Bw,{columns:!1,numTicks:6,lineStyle:{stroke:"#EBEFF3",strokeWidth:1}}),H.jsx(Kf,{hideTicks:!0,orientation:"bottom",stroke:"#CFD7DF",strokeWidth:1,numTicks:6,tickFormat:E=>u?Ph(E,u.symbol,u.position):E,rangePadding:{end:10},tickComponent:E=>H.jsx(ol,{textLabel:E.formattedValue||"",x:E.x,y:E.y,textStyles:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666",textAnchor:"middle"},axisCharLimit:m??D}),label:`${i} ➔`,labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dy:10,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),H.jsx(Kf,{hideTicks:!0,numTicks:6,strokeWidth:1,orientation:"left",stroke:"#CFD7DF",label:`${a} ➔`,tickFormat:E=>c?Ph(E,c.symbol,c.position):E,tickLabelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666"},labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dx:-20,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),T.map((E,N)=>H.jsxs(H.Fragment,{children:[H.jsx(VT,{data:E.points,xAccessor:ri.xAccessor,yAccessor:ri.yAccessor,connectNulls:p}),H.jsx(dS,{dataKey:`Performance Management ${N}`,data:E.points,size:8,renderGlyph:KT,xAccessor:ri.xAccessor,yAccessor:ri.yAccessor})]})),H.jsx(ad,{showDatumGlyph:!0,scroll:!0,debounce:500,snapTooltipToDatumX:!0,snapTooltipToDatumY:!0,detectBounds:!0,unstyled:!0,applyPositionStyle:!0,renderGlyph:ZT,renderTooltip:({tooltipData:E})=>{var L,V,X,R,w,A;const N=e.find(F=>{var B;return F.id===((B=E==null?void 0:E.nearestDatum)==null?void 0:B.datum.nodeId)}),j=((L=E==null?void 0:E.nearestDatum)==null?void 0:L.datum)&&((V=E==null?void 0:E.nearestDatum)==null?void 0:V.datum.x.length)<S;return H.jsx(Mh,{xValue:(X=E==null?void 0:E.nearestDatum)==null?void 0:X.datum.x,yValue:(R=E==null?void 0:E.nearestDatum)==null?void 0:R.datum.y,xAxisLabel:i,yAxisLabel:a,showSideBySide:!!j,tooltipTitle:f,legendValue:(N==null?void 0:N.name)||"",legendDarkColor:((w=E==null?void 0:E.nearestDatum)==null?void 0:w.datum.color.dark)||Ue(0).dark,legendLightColor:((A=E==null?void 0:E.nearestDatum)==null?void 0:A.datum.color.light)||Ue(0).light})}})]})}),d==="full"&&H.jsxs("div",{className:"w-64 p-4 bg-zinc-100 rounded-lg flex-col justify-start items-start gap-0.5 inline-flex text-xs grow-0 shrink-0 basis-auto",children:[H.jsxs("div",{className:"text-sm font-semibold pb-2",children:[H.jsx("span",{className:"pr-1",children:i}),"(",y.length,")"]}),y.map(E=>{const N=e.find(j=>j.id===E.points[0].nodeId);return N&&H.jsxs("div",{className:"flex justify-between items-center gap-1 py-1 w-full",children:[H.jsxs("div",{className:"flex justify-between items-center",children:[H.jsx("div",{style:{backgroundColor:E.points[0].color.light,borderColor:E.points[0].color.dark},className:"h-3 w-3 rounded-full border mr-1"}),N.name]}),H.jsx("div",{className:"flex items-center",children:H.jsx(pC,{checked:x.includes(N.id),onCheckedChange:j=>{let L=[...x];j?L=[...x,N.id]:L.splice(x.indexOf(N.id),1),C(L)}})})]},N.id)})]})]}),d==="mini"&&H.jsx("div",{className:"flex flex-row flex-wrap justify-center gap-4 text-[10px] text-[#666666] font-semibold",children:y.map(E=>{const N=e.find(j=>j.id===E.points[0].nodeId);return H.jsxs("div",{className:"flex justify-center items-center gap-1",children:[H.jsx("div",{style:{backgroundColor:E.points[0].color.light,borderColor:E.points[0].color.dark},className:"h-3 w-3 rounded-full border"}),N==null?void 0:N.name]},N==null?void 0:N.id)})})]})}),JT={xAxisUnitSymbol:void 0,yAxisUnitSymbol:void 0,mode:"mini",xAxisCharLimit:void 0,tooltipStackCharLimit:Nh,xAxisDomain:void 0,yAxisDomain:void 0,connectNulls:!1};ul.defaultProps=JT,ul.displayName="LineBase";const Ah=g.forwardRef((e,t)=>H.jsx(Ho,{debounceTime:10,children:({width:n,height:r})=>H.jsx(ul,{ref:t,width:n,height:r,...e})}));Ah.displayName="LineChart";const ek=Ah;function _h(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(n<o||n===void 0&&o>=o)&&(n=o)}return n}function tk(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function cl(e,t){let n=0;if(t===void 0)for(let r of e)(r=+r)&&(n+=r);else{let r=-1;for(let o of e)(o=+t(o,++r,e))&&(n+=o)}return n}function nk(e,t){return e.sourceLinks.length?e.depth:t-1}function oi(e){return function(){return e}}function Dh(e,t){return ii(e.source,t.source)||e.index-t.index}function Lh(e,t){return ii(e.target,t.target)||e.index-t.index}function ii(e,t){return e.y0-t.y0}function fl(e){return e.value}function rk(e){return e.index}function ok(e){return e.nodes}function ik(e){return e.links}function Ih(e,t){const n=e.get(t);if(!n)throw new Error("missing: "+t);return n}function jh({nodes:e}){for(const t of e){let n=t.y0,r=n;for(const o of t.sourceLinks)o.y0=n+o.width/2,n+=o.width;for(const o of t.targetLinks)o.y1=r+o.width/2,r+=o.width}}function ak(){let e=0,t=0,n=1,r=1,o=24,i=8,a,s=rk,l=nk,u,c,f=ok,d=ik,m=6;function p(){const w={nodes:f.apply(null,arguments),links:d.apply(null,arguments)};return v(w),S(w),b(w),x(w),y(w),jh(w),w}p.update=function(w){return jh(w),w},p.nodeId=function(w){return arguments.length?(s=typeof w=="function"?w:oi(w),p):s},p.nodeAlign=function(w){return arguments.length?(l=typeof w=="function"?w:oi(w),p):l},p.nodeSort=function(w){return arguments.length?(u=w,p):u},p.nodeWidth=function(w){return arguments.length?(o=+w,p):o},p.nodePadding=function(w){return arguments.length?(i=a=+w,p):i},p.nodes=function(w){return arguments.length?(f=typeof w=="function"?w:oi(w),p):f},p.links=function(w){return arguments.length?(d=typeof w=="function"?w:oi(w),p):d},p.linkSort=function(w){return arguments.length?(c=w,p):c},p.size=function(w){return arguments.length?(e=t=0,n=+w[0],r=+w[1],p):[n-e,r-t]},p.extent=function(w){return arguments.length?(e=+w[0][0],n=+w[1][0],t=+w[0][1],r=+w[1][1],p):[[e,t],[n,r]]},p.iterations=function(w){return arguments.length?(m=+w,p):m};function v({nodes:w,links:A}){for(const[B,U]of w.entries())U.index=B,U.sourceLinks=[],U.targetLinks=[];const F=new Map(w.map((B,U)=>[s(B,U,w),B]));for(const[B,U]of A.entries()){U.index=B;let{source:_,target:W}=U;typeof _!="object"&&(_=U.source=Ih(F,_)),typeof W!="object"&&(W=U.target=Ih(F,W)),_.sourceLinks.push(U),W.targetLinks.push(U)}if(c!=null)for(const{sourceLinks:B,targetLinks:U}of w)B.sort(c),U.sort(c)}function S({nodes:w}){for(const A of w)A.value=A.fixedValue===void 0?Math.max(cl(A.sourceLinks,fl),cl(A.targetLinks,fl)):A.fixedValue}function b({nodes:w}){const A=w.length;let F=new Set(w),B=new Set,U=0;for(;F.size;){for(const _ of F){_.depth=U;for(const{target:W}of _.sourceLinks)B.add(W)}if(++U>A)throw new Error("circular link");F=B,B=new Set}}function x({nodes:w}){const A=w.length;let F=new Set(w),B=new Set,U=0;for(;F.size;){for(const _ of F){_.height=U;for(const{source:W}of _.targetLinks)B.add(W)}if(++U>A)throw new Error("circular link");F=B,B=new Set}}function C({nodes:w}){const A=_h(w,U=>U.depth)+1,F=(n-e-o)/(A-1),B=new Array(A);for(const U of w){const _=Math.max(0,Math.min(A-1,Math.floor(l.call(null,U,A))));U.layer=_,U.x0=e+_*F,U.x1=U.x0+o,B[_]?B[_].push(U):B[_]=[U]}if(u)for(const U of B)U.sort(u);return B}function O(w){const A=tk(w,F=>(r-t-(F.length-1)*a)/cl(F,fl));for(const F of w){let B=t;for(const U of F){U.y0=B,U.y1=B+U.value*A,B=U.y1+a;for(const _ of U.sourceLinks)_.width=_.value*A}B=(r-B+a)/(F.length+1);for(let U=0;U<F.length;++U){const _=F[U];_.y0+=B*(U+1),_.y1+=B*(U+1)}V(F)}}function y(w){const A=C(w);a=Math.min(i,(r-t)/(_h(A,F=>F.length)-1)),O(A);for(let F=0;F<m;++F){const B=Math.pow(.99,F),U=Math.max(1-B,(F+1)/m);D(A,B,U),T(A,B,U)}}function T(w,A,F){for(let B=1,U=w.length;B<U;++B){const _=w[B];for(const W of _){let oe=0,Z=0;for(const{source:ee,value:ae}of W.targetLinks){let le=ae*(W.layer-ee.layer);oe+=X(ee,W)*le,Z+=le}if(!(Z>0))continue;let ie=(oe/Z-W.y0)*A;W.y0+=ie,W.y1+=ie,L(W)}u===void 0&&_.sort(ii),E(_,F)}}function D(w,A,F){for(let B=w.length,U=B-2;U>=0;--U){const _=w[U];for(const W of _){let oe=0,Z=0;for(const{target:ee,value:ae}of W.sourceLinks){let le=ae*(ee.layer-W.layer);oe+=R(W,ee)*le,Z+=le}if(!(Z>0))continue;let ie=(oe/Z-W.y0)*A;W.y0+=ie,W.y1+=ie,L(W)}u===void 0&&_.sort(ii),E(_,F)}}function E(w,A){const F=w.length>>1,B=w[F];j(w,B.y0-a,F-1,A),N(w,B.y1+a,F+1,A),j(w,r,w.length-1,A),N(w,t,0,A)}function N(w,A,F,B){for(;F<w.length;++F){const U=w[F],_=(A-U.y0)*B;_>1e-6&&(U.y0+=_,U.y1+=_),A=U.y1+a}}function j(w,A,F,B){for(;F>=0;--F){const U=w[F],_=(U.y1-A)*B;_>1e-6&&(U.y0-=_,U.y1-=_),A=U.y0-a}}function L({sourceLinks:w,targetLinks:A}){if(c===void 0){for(const{source:{sourceLinks:F}}of A)F.sort(Lh);for(const{target:{targetLinks:F}}of w)F.sort(Dh)}}function V(w){if(c===void 0)for(const{sourceLinks:A,targetLinks:F}of w)A.sort(Lh),F.sort(Dh)}function X(w,A){let F=w.y0-(w.sourceLinks.length-1)*a/2;for(const{target:B,width:U}of w.sourceLinks){if(B===A)break;F+=U+a}for(const{source:B,width:U}of A.targetLinks){if(B===w)break;F-=U}return F}function R(w,A){let F=A.y0-(A.targetLinks.length-1)*a/2;for(const{source:B,width:U}of A.targetLinks){if(B===w)break;F+=U+a}for(const{target:B,width:U}of w.sourceLinks){if(B===A)break;F-=U}return F}return p}function sk({tooltipData:e,fromLabel:t,toLabel:n,weightLabel:r,tooltipTitle:o}){var s,l,u,c;const i=e.source,a=e.target;return H.jsxs(Ie,{tooltipTitle:o,children:[H.jsx(Ie.Item,{label:t,value:i.name}),H.jsx(Ie.Item,{label:n,value:a.name}),H.jsx(Ie.Item,{label:r,value:e.weight.toString()}),H.jsx(Ie.Legend,{value:i.name,darkColor:(s=Ue(i.index||0))==null?void 0:s.dark,lightColor:(l=Ue(i.index||0))==null?void 0:l.light}),H.jsx(Ie.Legend,{value:a.name,darkColor:(u=Ue(a.index||0))==null?void 0:u.dark,lightColor:(c=Ue(a.index||0))==null?void 0:c.light})]})}const zh=80,Fh=20,lk=30,uk=12,Wh=g.forwardRef(({height:e,width:t,tooltipTitle:n,nodes:r,links:o,groups:i,weightLabel:a},s)=>{const l=g.useMemo(()=>ak().nodeId(w=>w.id).nodeWidth(uk).nodePadding(lk).nodeAlign(w=>w.group),[]),u=g.useRef(null);ll(u,s,`${n}-SankeyChart`);const[c,f]=g.useState(""),[d,m]=g.useState(null),{tooltipData:p,tooltipLeft:v,tooltipTop:S,tooltipOpen:b,showTooltip:x,hideTooltip:C}=ts(),{containerBounds:O,containerRef:y,TooltipInPortal:T}=ls({detectBounds:!0,debounce:500,scroll:!0,zIndex:1500}),D=g.useMemo(()=>l.extent([[zh,Fh],[t-zh,e-Fh-50]])({nodes:r,links:o.map(w=>({...w,value:Number(w.weight)}))}),[e,t,l,r,o]),E=g.useMemo(()=>Math.max(...D.nodes.map(w=>w.depth??0)),[D]),N=g.useMemo(()=>{const w={};let A=-1/0;return D.nodes.forEach(F=>{const{group:B}=F;w[B]?(w[B].x=Math.max(w[B].x??-1/0,F.x0??-1/0),w[B].y=Math.max(w[B].y??-1/0,F.y1??-1/0)):(w[B]={},w[B].x=F.x0,w[B].y=F.y1),A=Math.max(A,w[B].y??-1/0),w[B].y=A}),w},[D]),j=g.useCallback(w=>{const A=l.nodeId()(w);f(c===A?"":A)},[c,l]),L=g.useCallback(()=>{f(""),m(null)},[]),V=g.useMemo(()=>c===""&&d===null?new Set:new Set(D.links.filter(w=>l.nodeId()(w.source)===c||l.nodeId()(w.target)===c||(d==null?void 0:d.source)===w.source&&(d==null?void 0:d.target)===w.target)),[c,D,d,l]),X=g.useCallback((w,A)=>{const F=("clientX"in w?w.clientX:0)-O.left,B=("clientY"in w?w.clientY:0)-O.top;m(A),F&&B&&x({tooltipLeft:F,tooltipTop:B,tooltipData:A})},[x,O]),R=g.useCallback(()=>{L(),C()},[L,C]);return H.jsxs("div",{ref:u,className:"bg-white w-min h-min rabbit-ds",id:"sankey-chart",children:[H.jsxs("svg",{height:e,width:t,ref:y,children:[H.jsx("g",{children:D.links.map(w=>H.jsx(iw,{data:w,source:A=>({x:A.source.x1,y:A.y0}),target:A=>({x:A.target.x0,y:A.y1}),x:A=>A.x??0,y:A=>A.y??0,fill:"none",pointerEvents:"stroke",onMouseLeave:()=>R(),onMouseMove:A=>X(A,w),stroke:Ue(w.source.index||0).light,strokeWidth:w.width,strokeOpacity:V.has(w)?.7:.25},w.index))}),H.jsx("g",{children:D.nodes.map(w=>{var A,F,B;return H.jsx("g",{children:H.jsx(Zx,{x:w.x0??0,height:(w.y1??0)-(w.y0??0)+10,width:(w.x1??0)-(w.x0??0),y:(w.y0??0)-5,onMouseEnter:()=>j(w),onMouseLeave:()=>L(),radius:2,fill:c===w.id?(A=Ue(w.index||0))==null?void 0:A.dark:(F=Ue(w.index||0))==null?void 0:F.light,stroke:(B=Ue(w.index||0))==null?void 0:B.dark,all:!0})},w.index)})}),H.jsx("g",{children:i.map(w=>H.jsx(ol,{axisCharLimit:20,x:N[w.id].x??0,y:(N[w.id].y??0)+40,textLabel:w.name,textStyles:{fontSize:10,fontWeight:600,textAnchor:"middle",fill:"#666666"}},w.id))}),H.jsxs("g",{children:[D.nodes.map(w=>H.jsx(ol,{axisCharLimit:8,x:w.depth===E?(w.x1??0)+10:(w.x0??0)-10,y:(w.y0??0)+((w.y1??0)-(w.y0??0))/2,textLabel:w.name,textStyles:{fontSize:10,fontWeight:600,textAnchor:w.depth===E?"start":"end",fill:"#666666"}},w.index)),D.nodes.map(w=>w.value&&H.jsx(Fi,{x:w.depth===E?(w.x1??0)+10:(w.x0??0)-10,y:(w.y0??0)+((w.y1??0)-(w.y0??0))/2+16,style:{fontSize:10,fontWeight:400,textAnchor:w.depth===E?"start":"end",fill:"#666666"},children:`(${w.value.toString()})`},w.index))]})]}),b&&p&&H.jsx(T,{top:S,left:v,unstyled:!0,applyPositionStyle:!0,children:H.jsx(sk,{tooltipData:p,fromLabel:`From: ${i[p.source.group].name}`,toLabel:`To: ${i[p.target.group].name}`,weightLabel:a,tooltipTitle:n})},Math.random())]})});Wh.displayName="Sankey";const Bh=g.forwardRef((e,t)=>H.jsx(Ho,{debounceTime:10,children:({width:n,height:r})=>n&&r&&H.jsx(Wh,{ref:t,width:n,height:r,...e})}));Bh.displayName="SankeyChart";const ck=Bh;function fk(e){return"bandwidth"in e?e.bandwidth():0}var dk=["top","left","scale","width","stroke","strokeWidth","strokeDasharray","className","children","numTicks","lineStyle","offset","tickValues"];function dl(){return dl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dl.apply(this,arguments)}function hk(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function Uh(e){var t=e.top,n=t===void 0?0:t,r=e.left,o=r===void 0?0:r,i=e.scale,a=e.width,s=e.stroke,l=s===void 0?"#eaf0f6":s,u=e.strokeWidth,c=u===void 0?1:u,f=e.strokeDasharray,d=e.className,m=e.children,p=e.numTicks,v=p===void 0?10:p,S=e.lineStyle,b=e.offset,x=e.tickValues,C=hk(e,dk),O=x??Da(i,v),y=(b??0)+fk(i)/2,T=O.map(function(D,E){var N,j=((N=_a(i(D)))!=null?N:0)+y;return{index:E,from:new jt({x:0,y:j}),to:new jt({x:a,y:j})}});return g.createElement(en,{className:Ge("visx-rows",d),top:n,left:o},m?m({lines:T}):T.map(function(D){var E=D.from,N=D.to,j=D.index;return g.createElement(uw,dl({key:"row-line-"+j,from:E,to:N,stroke:l,strokeWidth:c,strokeDasharray:f,style:S},C))}))}Uh.propTypes={tickValues:K.array,width:K.number.isRequired};function Hh({xValue:e,yValue:t,tooltipTitle:n,xAxisLabel:r,yAxisLabel:o,legendValue:i,legendDarkColor:a,legendLightColor:s}){const l=e==null?void 0:e.toString(),u=t==null?void 0:t.toString();return H.jsxs(Ie,{tooltipTitle:n,showSideBySide:!0,children:[H.jsx(Ie.Item,{label:r,value:l}),H.jsx(Ie.Item,{label:o,value:u}),H.jsx(Ie.Legend,{value:i,darkColor:a,lightColor:s})]})}Hh.defaultProps={xValue:void 0,yValue:void 0};const qh=20,Yh=20,hl=80,ai=50,pk=10,gk=25,pl=g.forwardRef(({tooltipTitle:e,xAxisLabel:t,yAxisLabel:n,domain:r,binCount:o,data:i,width:a,height:s,maxBinCount:l=gk,minBinCount:u=pk,integerBins:c=!1},f)=>{const d=g.useMemo(()=>io(i),[i]),m=g.useMemo(()=>{const R=d[0]??0,w=d[1]??0,A=w-R>u?w:u+R,F=Math.min(Math.max(w-R,u),l),B=Math.floor(d[0]??0),U=Math.ceil(A),_=Math.ceil(F),W=r||(c?[B,U]:[R,A]);return c0().domain(W).thresholds(o||(c?_:F))(i)},[d,o,i,r,c,l,u]),p=g.useMemo(()=>Mr({domain:[m[0].x0??0,m[m.length-1].x1??0],range:[ai,a-Yh],round:!0,nice:!0}),[m,a]),v=g.useMemo(()=>Mr({domain:[0,Yi(m,R=>R.length)??0],range:[s-hl,qh],round:!0,nice:!0}),[m,s]),S=g.useRef(null);ll(S,f,`${t}-${n}-Histogram`);const{tooltipData:b,tooltipLeft:x,tooltipTop:C,tooltipOpen:O,showTooltip:y,hideTooltip:T}=ts(),{containerBounds:D,containerRef:E,TooltipInPortal:N}=ls({detectBounds:!0,debounce:500,scroll:!0,zIndex:1500}),j=a-ai-Yh,L=s-qh-hl-100,V=g.useCallback((R,w)=>{const A=("clientX"in R?R.clientX:0)-D.left,F=("clientY"in R?R.clientY:0)-D.top;A&&F&&y({tooltipLeft:A,tooltipTop:F,tooltipData:w})},[y,D]),X=g.useCallback(()=>{T()},[T]);return H.jsxs("div",{className:"bg-white flex flex-col rabbit-ds",style:{width:a,height:s},ref:S,children:[H.jsxs("svg",{width:a,height:s,ref:E,children:[H.jsx(Qa,{orientation:"bottom",scale:p,top:s-hl,hideTicks:!0,stroke:"#CFD7DF",strokeWidth:1,rangePadding:{end:10},label:`${t} ➔`,tickLabelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666",textAnchor:"middle"},labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dy:10,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),H.jsx(Qa,{orientation:"left",scale:v,left:ai,hideTicks:!0,strokeWidth:1,stroke:"#CFD7DF",label:`${n} ➔`,tickLabelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666",textAnchor:"end"},labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dx:-20,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),H.jsxs(en,{children:[H.jsx(Uh,{scale:v,width:j,height:L,left:ai,top:0,lineStyle:{stroke:"#EBEFF3",strokeWidth:1}}),m.map(R=>{const w=v(0)-v(R.length),A=p(R.x1??0)-p(R.x0??0);return H.jsx("g",{children:H.jsx(Rx,{x:p(R.x0??0),y:v(R.length),width:A,height:w&&w-1,fill:Ue(0).light,stroke:Ue(0).dark,strokeWidth:1,onMouseMove:F=>V(F,R),onMouseLeave:()=>X()})},Math.random())})]})]}),O&&b&&H.jsx(N,{top:C,left:x,unstyled:!0,applyPositionStyle:!0,children:H.jsx(Hh,{xAxisLabel:t,xValue:`${b.x0} to ${b.x1}`,yAxisLabel:n,yValue:b.length,tooltipTitle:e,legendValue:n,legendDarkColor:Ue(0).dark,legendLightColor:Ue(0).light})},Math.random())]})}),Gh=g.forwardRef((e,t)=>H.jsx(Ho,{debounceTime:10,children:({width:n,height:r})=>H.jsx(pl,{ref:t,width:n,height:r,...e})}));pl.defaultProps={domain:void 0,binCount:void 0,integerBins:!1},pl.displayName="HistogramBase",Gh.displayName="HistogramChart";const mk=Gh;function vk({count:e,totalCount:t,title:n,subTitle:r,className:o,unstyledDimension:i=!1,style:a}){const s="max-w-[336px] min-h-[96px] min-w-[200px]";return H.jsxs("div",{className:Rn("rabbit-ds box-border px-2 py-4 bg-white rounded-lg shadow flex-col justify-center items-start gap-1 inline-flex",o,!i&&s),style:a,children:[H.jsxs("div",{className:"self-stretch px-3 py-1 flex items-baseline",children:[H.jsx("div",{className:"text-zinc-800 text-2xl font-semibold",children:e}),t&&H.jsxs("div",{className:"text-stone-500 text-xs font-normal",children:["/",t]})]}),H.jsx("div",{className:"self-stretch px-3 justify-start items-center gap-2 inline-flex",children:H.jsxs("div",{className:"grow shrink basis-0 flex-col justify-start items-start gap-0.5 inline-flex",children:[H.jsx("div",{className:"self-stretch justify-start items-start gap-2.5 inline-flex",children:H.jsx("div",{className:"grow shrink basis-0 text-zinc-800 text-xs font-semibold leading-none",children:n})}),r&&H.jsx("div",{className:"self-stretch justify-start py-2 items-center gap-1 inline-flex",children:H.jsx("div",{className:"grow shrink basis-0 text-stone-500 text-xs font-normal leading-none",children:r})})]})})]})}Ye.CardKPI=vk,Ye.HistogramChart=mk,Ye.LineChart=ek,Ye.SankeyChart=ck,Object.defineProperty(Ye,Symbol.toStringTag,{value:"Module"})});
46
+ `}),I.appendChild(M.createTextNode(qe))}z.timeEnd("clone node"),re==null||re(ve),te!==!1&&ae(ve)&&(z.time("embed web font"),yield Pk(ve,k),z.timeEnd("embed web font")),z.time("embed node"),np(ve,k);const be=G.length;let xe=0;const ke=()=>v(this,null,function*(){for(;;){const qe=G.pop();if(!qe)break;try{yield qe}catch(Lt){Me("Failed to run task",Lt)}ne==null||ne(++xe,be)}});ne==null||ne(xe,be),yield Promise.all([...Array(4)].map(ke)),z.timeEnd("embed node"),ge==null||ge(ve);const Se=zk(ve,k);return q&&Se.insertBefore(q,Se.children[0]),I&&Se.insertBefore(I,Se.children[0]),se&&Kh(k),pe==null||pe(Se),Se})}function zk(h,$){const{width:k,height:M}=$,z=qr(k,M,h.ownerDocument),G=z.ownerDocument.createElementNS(z.namespaceURI,"foreignObject");return G.setAttributeNS(null,"x","0%"),G.setAttributeNS(null,"y","0%"),G.setAttributeNS(null,"width","100%"),G.setAttributeNS(null,"height","100%"),G.append(h),z.appendChild(G),z}function wi(h,$){return v(this,null,function*(){var k;const M=yield et(h,$),z=yield rp(M),G=er(z,M.isEnable("removeControlCharacter"));M.autoDestruct||(M.svgStyleElement=He(M.ownerDocument),M.svgDefsElement=(k=M.ownerDocument)==null?void 0:k.createElementNS(wn,"defs"),M.svgStyles.clear());const I=wt(G,z.ownerDocument);return yield _t(I,M)})}function Fk(h,$){return v(this,null,function*(){const k=yield et(h,$),{log:M,type:z,quality:G,dpi:I}=k,q=yield wi(k);M.time("canvas to blob");const Q=yield ci(q,z,G);if(["image/png","image/jpeg"].includes(z)&&I){const te=yield hi(Q.slice(0,33));let ne=new Uint8Array(te);return z==="image/png"?ne=N(ne,I):z==="image/jpeg"&&(ne=S(ne,I)),new Blob([ne,Q.slice(33)],{type:z})}return M.timeEnd("canvas to blob"),Q})}function rr(h,$){return v(this,null,function*(){const k=yield et(h,$),{log:M,quality:z,type:G,dpi:I}=k,q=yield wi(k);M.time("canvas to data url");let Q=q.toDataURL(G,z);if(["image/png","image/jpeg"].includes(G)&&I&&F&&B){const[te,ne]=Q.split(",");let se=0,re=!1;if(G==="image/png"){const Se=X(ne);Se>=0?(se=Math.ceil((Se+28)/3)*4,re=!0):se=33/3*4}else G==="image/jpeg"&&(se=18/3*4);const ge=ne.substring(0,se),pe=ne.substring(se),ve=window.atob(ge),be=new Uint8Array(ve.length);for(let Se=0;Se<be.length;Se++)be[Se]=ve.charCodeAt(Se);const xe=G==="image/png"?N(be,I,re):S(be,I),ke=window.btoa(String.fromCharCode(...xe));Q=[te,",",ke,pe].join("")}return M.timeEnd("canvas to data url"),Q})}function op(h,$){return v(this,null,function*(){const k=yield et(h,$),{width:M,height:z,ownerDocument:G}=k,I=yield rr(k),q=qr(M,z,G),Q=q.ownerDocument.createElementNS(q.namespaceURI,"image");return Q.setAttributeNS(null,"href",I),Q.setAttributeNS(null,"height","100%"),Q.setAttributeNS(null,"width","100%"),q.appendChild(Q),er(q,k.isEnable("removeControlCharacter"))})}function Wk(h,$){return v(this,null,function*(){const k=yield et(h,$),{ownerDocument:M,width:z,height:G,scale:I,type:q}=k,Q=q==="image/svg+xml"?yield op(k):yield rr(k),te=wt(Q,M);return te.width=Math.floor(z*I),te.height=Math.floor(G*I),te.style.width=`${z}px`,te.style.height=`${G}px`,te})}function Bk(h,$){return v(this,null,function*(){return rr(yield et(h,m(d({},$),{type:"image/jpeg"})))})}function Uk(h,$){return v(this,null,function*(){const k=yield et(h,$),M=yield wi(k);return M.getContext("2d").getImageData(0,0,M.width,M.height).data})}function Hk(h,$){return v(this,null,function*(){return rr(yield et(h,m(d({},$),{type:"image/png"})))})}function qk(h,$){return v(this,null,function*(){return rr(yield et(h,m(d({},$),{type:"image/webp"})))})}n.createContext=mi,n.destroyContext=Kh,n.domToBlob=Fk,n.domToCanvas=wi,n.domToDataUrl=rr,n.domToForeignObjectSvg=rp,n.domToImage=Wk,n.domToJpeg=Bk,n.domToPixel=Uk,n.domToPng=Hk,n.domToSvg=op,n.domToWebp=qk,n.loadMedia=At,n.waitUntilLoad=Gr,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})})})(sl,sl.exports);var XT=sl.exports;const ll=(e,t,n)=>{g.useImperativeHandle(t,()=>({download(){e.current&&XT.domToPng(e.current,{scale:5}).then(r=>{const o=document.createElement("a");o.download=`${n}.png`,o.href=r,o.click()})}}))},KT=({x:e,y:t,datum:n,size:r})=>H.jsx(Fs,{cx:e,cy:t,stroke:n.color.dark,strokeWidth:1,fill:n.color.light,r:r/2}),ZT=({x:e,y:t,datum:n})=>H.jsx(Fs,{cx:e,cy:t,stroke:n.color.dark,strokeWidth:1,fill:n.color.dark,r:5,style:{zIndex:1500}}),ri={xAccessor:e=>e.x,yAccessor:e=>e.y},Ph=(e,t,n)=>n==="pre"?`${t}${e}`:`${e}${t}`,Nh=10,QT=5,ul=g.forwardRef(({nodes:e,height:t,width:n,xAxisValues:r,series:o,xAxisLabel:i,yAxisLabel:a,xAxisDomain:s,yAxisDomain:l,xAxisUnitSymbol:u,yAxisUnitSymbol:c,tooltipTitle:f,mode:d,xAxisCharLimit:m,connectNulls:p=!1,maxNodesInMiniMode:v=QT,tooltipStackCharLimit:S=Nh},b)=>{const[x,C]=g.useState(e.map(E=>E.id)),O=g.useRef(null);ll(O,b,`${i}-${a}-LineChart`);const y=g.useMemo(()=>o.map((E,N)=>({points:E.data.map((j,L)=>({x:r[L],y:j,nodeId:E.id,color:Ue(N)}))})).slice(0,d==="mini"?v:o.length),[r,o,d,v]),T=g.useMemo(()=>d==="full"?y.filter(E=>x.includes(E.points[0].nodeId)):y,[y,x,d]),D=g.useMemo(()=>Math.floor((n-(d==="mini"?0:150))/(r.length*8)),[n,r,d]);return H.jsxs("div",{ref:O,id:"line-chart",className:"bg-white flex flex-col rabbit-ds",style:{width:n,height:t},children:[H.jsxs("div",{className:"w-full min-w-0 min-h-0 h-full flex flex-row",children:[H.jsx("div",{className:"w-full min-w-0 min-h-0 h-full",children:H.jsxs(qn,{margin:{top:10,left:50,right:50,bottom:50},xScale:{type:"band",nice:!0,...s&&{domain:s}},yScale:{type:"linear",nice:!0,...l&&{domain:l}},children:[H.jsx(Bw,{columns:!1,numTicks:6,lineStyle:{stroke:"#EBEFF3",strokeWidth:1}}),H.jsx(Kf,{hideTicks:!0,orientation:"bottom",stroke:"#CFD7DF",strokeWidth:1,numTicks:6,tickFormat:E=>u?Ph(E,u.symbol,u.position):E,rangePadding:{end:10},tickComponent:E=>H.jsx(ol,{textLabel:E.formattedValue||"",x:E.x,y:E.y,textStyles:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666",textAnchor:"middle"},axisCharLimit:m??D}),label:`${i} ➔`,labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dy:10,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),H.jsx(Kf,{hideTicks:!0,numTicks:6,strokeWidth:1,orientation:"left",stroke:"#CFD7DF",label:`${a} ➔`,tickFormat:E=>c?Ph(E,c.symbol,c.position):E,tickLabelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666"},labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dx:-20,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),T.map((E,N)=>H.jsxs(H.Fragment,{children:[H.jsx(VT,{data:E.points,xAccessor:ri.xAccessor,yAccessor:ri.yAccessor,connectNulls:p}),H.jsx(dS,{dataKey:`Performance Management ${N}`,data:E.points,size:8,renderGlyph:KT,xAccessor:ri.xAccessor,yAccessor:ri.yAccessor})]})),H.jsx(ad,{showDatumGlyph:!0,scroll:!0,debounce:500,snapTooltipToDatumX:!0,snapTooltipToDatumY:!0,detectBounds:!0,unstyled:!0,applyPositionStyle:!0,renderGlyph:ZT,renderTooltip:({tooltipData:E})=>{var L,V,X,R,w,A;const N=e.find(F=>{var B;return F.id===((B=E==null?void 0:E.nearestDatum)==null?void 0:B.datum.nodeId)}),j=((L=E==null?void 0:E.nearestDatum)==null?void 0:L.datum)&&((V=E==null?void 0:E.nearestDatum)==null?void 0:V.datum.x.length)<S;return H.jsx(Mh,{xValue:(X=E==null?void 0:E.nearestDatum)==null?void 0:X.datum.x,yValue:(R=E==null?void 0:E.nearestDatum)==null?void 0:R.datum.y,xAxisLabel:i,yAxisLabel:a,showSideBySide:!!j,tooltipTitle:f,legendValue:(N==null?void 0:N.name)||"",legendDarkColor:((w=E==null?void 0:E.nearestDatum)==null?void 0:w.datum.color.dark)||Ue(0).dark,legendLightColor:((A=E==null?void 0:E.nearestDatum)==null?void 0:A.datum.color.light)||Ue(0).light})}})]})}),d==="full"&&H.jsxs("div",{className:"w-64 p-4 bg-zinc-100 rounded-lg flex-col justify-start items-start gap-0.5 inline-flex text-xs grow-0 shrink-0 basis-auto",children:[H.jsxs("div",{className:"text-sm font-semibold pb-2",children:[H.jsx("span",{className:"pr-1",children:i}),"(",y.length,")"]}),y.map(E=>{const N=e.find(j=>j.id===E.points[0].nodeId);return N&&H.jsxs("div",{className:"flex justify-between items-center gap-1 py-1 w-full",children:[H.jsxs("div",{className:"flex justify-between items-center",children:[H.jsx("div",{style:{backgroundColor:E.points[0].color.light,borderColor:E.points[0].color.dark},className:"h-3 w-3 rounded-full border mr-1"}),N.name]}),H.jsx("div",{className:"flex items-center",children:H.jsx(pC,{checked:x.includes(N.id),onCheckedChange:j=>{let L=[...x];j?L=[...x,N.id]:L.splice(x.indexOf(N.id),1),C(L)}})})]},N.id)})]})]}),d==="mini"&&H.jsx("div",{className:"flex flex-row flex-wrap justify-center gap-4 text-[10px] text-[#666666] font-semibold",children:y.map(E=>{const N=e.find(j=>j.id===E.points[0].nodeId);return H.jsxs("div",{className:"flex justify-center items-center gap-1",children:[H.jsx("div",{style:{backgroundColor:E.points[0].color.light,borderColor:E.points[0].color.dark},className:"h-3 w-3 rounded-full border"}),N==null?void 0:N.name]},N==null?void 0:N.id)})})]})}),JT={xAxisUnitSymbol:void 0,yAxisUnitSymbol:void 0,mode:"mini",xAxisCharLimit:void 0,tooltipStackCharLimit:Nh,xAxisDomain:void 0,yAxisDomain:void 0,connectNulls:!1};ul.defaultProps=JT,ul.displayName="LineBase";const Ah=g.forwardRef((e,t)=>H.jsx(Ho,{debounceTime:10,children:({width:n,height:r})=>H.jsx(ul,{ref:t,width:n,height:r,...e})}));Ah.displayName="LineChart";const ek=Ah;function _h(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(n<o||n===void 0&&o>=o)&&(n=o)}return n}function tk(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function cl(e,t){let n=0;if(t===void 0)for(let r of e)(r=+r)&&(n+=r);else{let r=-1;for(let o of e)(o=+t(o,++r,e))&&(n+=o)}return n}function nk(e,t){return e.sourceLinks.length?e.depth:t-1}function oi(e){return function(){return e}}function Dh(e,t){return ii(e.source,t.source)||e.index-t.index}function Lh(e,t){return ii(e.target,t.target)||e.index-t.index}function ii(e,t){return e.y0-t.y0}function fl(e){return e.value}function rk(e){return e.index}function ok(e){return e.nodes}function ik(e){return e.links}function Ih(e,t){const n=e.get(t);if(!n)throw new Error("missing: "+t);return n}function jh({nodes:e}){for(const t of e){let n=t.y0,r=n;for(const o of t.sourceLinks)o.y0=n+o.width/2,n+=o.width;for(const o of t.targetLinks)o.y1=r+o.width/2,r+=o.width}}function ak(){let e=0,t=0,n=1,r=1,o=24,i=8,a,s=rk,l=nk,u,c,f=ok,d=ik,m=6;function p(){const w={nodes:f.apply(null,arguments),links:d.apply(null,arguments)};return v(w),S(w),b(w),x(w),y(w),jh(w),w}p.update=function(w){return jh(w),w},p.nodeId=function(w){return arguments.length?(s=typeof w=="function"?w:oi(w),p):s},p.nodeAlign=function(w){return arguments.length?(l=typeof w=="function"?w:oi(w),p):l},p.nodeSort=function(w){return arguments.length?(u=w,p):u},p.nodeWidth=function(w){return arguments.length?(o=+w,p):o},p.nodePadding=function(w){return arguments.length?(i=a=+w,p):i},p.nodes=function(w){return arguments.length?(f=typeof w=="function"?w:oi(w),p):f},p.links=function(w){return arguments.length?(d=typeof w=="function"?w:oi(w),p):d},p.linkSort=function(w){return arguments.length?(c=w,p):c},p.size=function(w){return arguments.length?(e=t=0,n=+w[0],r=+w[1],p):[n-e,r-t]},p.extent=function(w){return arguments.length?(e=+w[0][0],n=+w[1][0],t=+w[0][1],r=+w[1][1],p):[[e,t],[n,r]]},p.iterations=function(w){return arguments.length?(m=+w,p):m};function v({nodes:w,links:A}){for(const[B,U]of w.entries())U.index=B,U.sourceLinks=[],U.targetLinks=[];const F=new Map(w.map((B,U)=>[s(B,U,w),B]));for(const[B,U]of A.entries()){U.index=B;let{source:_,target:W}=U;typeof _!="object"&&(_=U.source=Ih(F,_)),typeof W!="object"&&(W=U.target=Ih(F,W)),_.sourceLinks.push(U),W.targetLinks.push(U)}if(c!=null)for(const{sourceLinks:B,targetLinks:U}of w)B.sort(c),U.sort(c)}function S({nodes:w}){for(const A of w)A.value=A.fixedValue===void 0?Math.max(cl(A.sourceLinks,fl),cl(A.targetLinks,fl)):A.fixedValue}function b({nodes:w}){const A=w.length;let F=new Set(w),B=new Set,U=0;for(;F.size;){for(const _ of F){_.depth=U;for(const{target:W}of _.sourceLinks)B.add(W)}if(++U>A)throw new Error("circular link");F=B,B=new Set}}function x({nodes:w}){const A=w.length;let F=new Set(w),B=new Set,U=0;for(;F.size;){for(const _ of F){_.height=U;for(const{source:W}of _.targetLinks)B.add(W)}if(++U>A)throw new Error("circular link");F=B,B=new Set}}function C({nodes:w}){const A=_h(w,U=>U.depth)+1,F=(n-e-o)/(A-1),B=new Array(A);for(const U of w){const _=Math.max(0,Math.min(A-1,Math.floor(l.call(null,U,A))));U.layer=_,U.x0=e+_*F,U.x1=U.x0+o,B[_]?B[_].push(U):B[_]=[U]}if(u)for(const U of B)U.sort(u);return B}function O(w){const A=tk(w,F=>(r-t-(F.length-1)*a)/cl(F,fl));for(const F of w){let B=t;for(const U of F){U.y0=B,U.y1=B+U.value*A,B=U.y1+a;for(const _ of U.sourceLinks)_.width=_.value*A}B=(r-B+a)/(F.length+1);for(let U=0;U<F.length;++U){const _=F[U];_.y0+=B*(U+1),_.y1+=B*(U+1)}V(F)}}function y(w){const A=C(w);a=Math.min(i,(r-t)/(_h(A,F=>F.length)-1)),O(A);for(let F=0;F<m;++F){const B=Math.pow(.99,F),U=Math.max(1-B,(F+1)/m);D(A,B,U),T(A,B,U)}}function T(w,A,F){for(let B=1,U=w.length;B<U;++B){const _=w[B];for(const W of _){let oe=0,Z=0;for(const{source:ee,value:ae}of W.targetLinks){let le=ae*(W.layer-ee.layer);oe+=X(ee,W)*le,Z+=le}if(!(Z>0))continue;let ie=(oe/Z-W.y0)*A;W.y0+=ie,W.y1+=ie,L(W)}u===void 0&&_.sort(ii),E(_,F)}}function D(w,A,F){for(let B=w.length,U=B-2;U>=0;--U){const _=w[U];for(const W of _){let oe=0,Z=0;for(const{target:ee,value:ae}of W.sourceLinks){let le=ae*(ee.layer-W.layer);oe+=R(W,ee)*le,Z+=le}if(!(Z>0))continue;let ie=(oe/Z-W.y0)*A;W.y0+=ie,W.y1+=ie,L(W)}u===void 0&&_.sort(ii),E(_,F)}}function E(w,A){const F=w.length>>1,B=w[F];j(w,B.y0-a,F-1,A),N(w,B.y1+a,F+1,A),j(w,r,w.length-1,A),N(w,t,0,A)}function N(w,A,F,B){for(;F<w.length;++F){const U=w[F],_=(A-U.y0)*B;_>1e-6&&(U.y0+=_,U.y1+=_),A=U.y1+a}}function j(w,A,F,B){for(;F>=0;--F){const U=w[F],_=(U.y1-A)*B;_>1e-6&&(U.y0-=_,U.y1-=_),A=U.y0-a}}function L({sourceLinks:w,targetLinks:A}){if(c===void 0){for(const{source:{sourceLinks:F}}of A)F.sort(Lh);for(const{target:{targetLinks:F}}of w)F.sort(Dh)}}function V(w){if(c===void 0)for(const{sourceLinks:A,targetLinks:F}of w)A.sort(Lh),F.sort(Dh)}function X(w,A){let F=w.y0-(w.sourceLinks.length-1)*a/2;for(const{target:B,width:U}of w.sourceLinks){if(B===A)break;F+=U+a}for(const{source:B,width:U}of A.targetLinks){if(B===w)break;F-=U}return F}function R(w,A){let F=A.y0-(A.targetLinks.length-1)*a/2;for(const{source:B,width:U}of A.targetLinks){if(B===w)break;F+=U+a}for(const{target:B,width:U}of w.sourceLinks){if(B===A)break;F-=U}return F}return p}function sk({tooltipData:e,fromLabel:t,toLabel:n,weightLabel:r,tooltipTitle:o}){var s,l,u,c;const i=e.source,a=e.target;return H.jsxs(Ie,{tooltipTitle:o,children:[H.jsx(Ie.Item,{label:t,value:i.name}),H.jsx(Ie.Item,{label:n,value:a.name}),H.jsx(Ie.Item,{label:r,value:e.weight.toString()}),H.jsx(Ie.Legend,{value:i.name,darkColor:(s=Ue(i.index||0))==null?void 0:s.dark,lightColor:(l=Ue(i.index||0))==null?void 0:l.light}),H.jsx(Ie.Legend,{value:a.name,darkColor:(u=Ue(a.index||0))==null?void 0:u.dark,lightColor:(c=Ue(a.index||0))==null?void 0:c.light})]})}const zh=80,Fh=20,lk=30,uk=12,Wh=g.forwardRef(({height:e,width:t,tooltipTitle:n,nodes:r,links:o,groups:i,weightLabel:a},s)=>{const l=g.useMemo(()=>ak().nodeId(w=>w.id).nodeWidth(uk).nodePadding(lk).nodeAlign(w=>w.group),[]),u=g.useRef(null);ll(u,s,`${n}-SankeyChart`);const[c,f]=g.useState(""),[d,m]=g.useState(null),{tooltipData:p,tooltipLeft:v,tooltipTop:S,tooltipOpen:b,showTooltip:x,hideTooltip:C}=ts(),{containerBounds:O,containerRef:y,TooltipInPortal:T}=ls({detectBounds:!0,debounce:500,scroll:!0,zIndex:1500}),D=g.useMemo(()=>l.extent([[zh,Fh],[t-zh,e-Fh-50]])({nodes:r,links:o.map(w=>({...w,value:Number(w.weight)}))}),[e,t,l,r,o]),E=g.useMemo(()=>Math.max(...D.nodes.map(w=>w.depth??0)),[D]),N=g.useMemo(()=>{const w={};let A=-1/0;return D.nodes.forEach(F=>{const{group:B}=F;w[B]?(w[B].x=Math.max(w[B].x??-1/0,F.x0??-1/0),w[B].y=Math.max(w[B].y??-1/0,F.y1??-1/0)):(w[B]={},w[B].x=F.x0,w[B].y=F.y1),A=Math.max(A,w[B].y??-1/0),w[B].y=A}),w},[D]),j=g.useCallback(w=>{const A=l.nodeId()(w);f(c===A?"":A)},[c,l]),L=g.useCallback(()=>{f(""),m(null)},[]),V=g.useMemo(()=>c===""&&d===null?new Set:new Set(D.links.filter(w=>l.nodeId()(w.source)===c||l.nodeId()(w.target)===c||(d==null?void 0:d.source)===w.source&&(d==null?void 0:d.target)===w.target)),[c,D,d,l]),X=g.useCallback((w,A)=>{const F=("clientX"in w?w.clientX:0)-O.left,B=("clientY"in w?w.clientY:0)-O.top;m(A),F&&B&&x({tooltipLeft:F,tooltipTop:B,tooltipData:A})},[x,O]),R=g.useCallback(()=>{L(),C()},[L,C]);return H.jsxs("div",{ref:u,className:"bg-white w-min h-min rabbit-ds",id:"sankey-chart",children:[H.jsxs("svg",{height:e,width:t,ref:y,children:[H.jsx("g",{children:D.links.map(w=>H.jsx(iw,{data:w,source:A=>({x:A.source.x1,y:A.y0}),target:A=>({x:A.target.x0,y:A.y1}),x:A=>A.x??0,y:A=>A.y??0,fill:"none",pointerEvents:"stroke",onMouseLeave:()=>R(),onMouseMove:A=>X(A,w),stroke:Ue(w.source.index||0).light,strokeWidth:w.width,strokeOpacity:V.has(w)?.7:.25},w.index))}),H.jsx("g",{children:D.nodes.map(w=>{var A,F,B;return H.jsx("g",{children:H.jsx(Zx,{x:w.x0??0,height:(w.y1??0)-(w.y0??0)+10,width:(w.x1??0)-(w.x0??0),y:(w.y0??0)-5,onMouseEnter:()=>j(w),onMouseLeave:()=>L(),radius:2,fill:c===w.id?(A=Ue(w.index||0))==null?void 0:A.dark:(F=Ue(w.index||0))==null?void 0:F.light,stroke:(B=Ue(w.index||0))==null?void 0:B.dark,all:!0})},w.index)})}),H.jsx("g",{children:i.map(w=>H.jsx(ol,{axisCharLimit:20,x:N[w.id].x??0,y:(N[w.id].y??0)+40,textLabel:w.name,textStyles:{fontSize:10,fontWeight:600,textAnchor:"middle",fill:"#666666"}},w.id))}),H.jsxs("g",{children:[D.nodes.map(w=>H.jsx(ol,{axisCharLimit:8,x:w.depth===E?(w.x1??0)+10:(w.x0??0)-10,y:(w.y0??0)+((w.y1??0)-(w.y0??0))/2,textLabel:w.name,textStyles:{fontSize:10,fontWeight:600,textAnchor:w.depth===E?"start":"end",fill:"#666666"}},w.index)),D.nodes.map(w=>w.value&&H.jsx(Fi,{x:w.depth===E?(w.x1??0)+10:(w.x0??0)-10,y:(w.y0??0)+((w.y1??0)-(w.y0??0))/2+16,style:{fontSize:10,fontWeight:400,textAnchor:w.depth===E?"start":"end",fill:"#666666"},children:`(${w.value.toString()})`},w.index))]})]}),b&&p&&H.jsx(T,{top:S,left:v,unstyled:!0,applyPositionStyle:!0,children:H.jsx(sk,{tooltipData:p,fromLabel:`From: ${i[p.source.group].name}`,toLabel:`To: ${i[p.target.group].name}`,weightLabel:a,tooltipTitle:n})},Math.random())]})});Wh.displayName="Sankey";const Bh=g.forwardRef((e,t)=>H.jsx(Ho,{debounceTime:10,children:({width:n,height:r})=>n&&r&&H.jsx(Wh,{ref:t,width:n,height:r,...e})}));Bh.displayName="SankeyChart";const ck=Bh;function fk(e){return"bandwidth"in e?e.bandwidth():0}var dk=["top","left","scale","width","stroke","strokeWidth","strokeDasharray","className","children","numTicks","lineStyle","offset","tickValues"];function dl(){return dl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dl.apply(this,arguments)}function hk(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function Uh(e){var t=e.top,n=t===void 0?0:t,r=e.left,o=r===void 0?0:r,i=e.scale,a=e.width,s=e.stroke,l=s===void 0?"#eaf0f6":s,u=e.strokeWidth,c=u===void 0?1:u,f=e.strokeDasharray,d=e.className,m=e.children,p=e.numTicks,v=p===void 0?10:p,S=e.lineStyle,b=e.offset,x=e.tickValues,C=hk(e,dk),O=x??Da(i,v),y=(b??0)+fk(i)/2,T=O.map(function(D,E){var N,j=((N=_a(i(D)))!=null?N:0)+y;return{index:E,from:new jt({x:0,y:j}),to:new jt({x:a,y:j})}});return g.createElement(en,{className:Ge("visx-rows",d),top:n,left:o},m?m({lines:T}):T.map(function(D){var E=D.from,N=D.to,j=D.index;return g.createElement(uw,dl({key:"row-line-"+j,from:E,to:N,stroke:l,strokeWidth:c,strokeDasharray:f,style:S},C))}))}Uh.propTypes={tickValues:K.array,width:K.number.isRequired};function Hh({xValue:e,yValue:t,tooltipTitle:n,xAxisLabel:r,yAxisLabel:o,legendValue:i,legendDarkColor:a,legendLightColor:s}){const l=e==null?void 0:e.toString(),u=t==null?void 0:t.toString();return H.jsxs(Ie,{tooltipTitle:n,showSideBySide:!0,children:[H.jsx(Ie.Item,{label:r,value:l}),H.jsx(Ie.Item,{label:o,value:u}),H.jsx(Ie.Legend,{value:i,darkColor:a,lightColor:s})]})}Hh.defaultProps={xValue:void 0,yValue:void 0};const qh=20,Yh=20,hl=80,ai=50,pk=10,gk=25,pl=g.forwardRef(({tooltipTitle:e,xAxisLabel:t,yAxisLabel:n,domain:r,binCount:o,data:i,width:a,height:s,maxBinCount:l=gk,minBinCount:u=pk,integerBins:c=!1},f)=>{const d=g.useMemo(()=>io(i),[i]),m=g.useMemo(()=>{const R=d[0]??0,w=d[1]??0,A=w-R>u?w:u+R,F=Math.min(Math.max(w-R,u),l),B=Math.floor(d[0]??0),U=Math.ceil(A),_=Math.ceil(F),W=r||(c?[B,U]:[R,A]);return c0().domain(W).thresholds(o||(c?_:F))(i)},[d,o,i,r,c,l,u]),p=g.useMemo(()=>Mr({domain:[m[0].x0??0,m[m.length-1].x1??0],range:[ai,a-Yh],round:!0,nice:!0}),[m,a]),v=g.useMemo(()=>Mr({domain:[0,Yi(m,R=>R.length)??0],range:[s-hl,qh],round:!0,nice:!0}),[m,s]),S=g.useRef(null);ll(S,f,`${t}-${n}-Histogram`);const{tooltipData:b,tooltipLeft:x,tooltipTop:C,tooltipOpen:O,showTooltip:y,hideTooltip:T}=ts(),{containerBounds:D,containerRef:E,TooltipInPortal:N}=ls({detectBounds:!0,debounce:500,scroll:!0,zIndex:1500}),j=a-ai-Yh,L=s-qh-hl-100,V=g.useCallback((R,w)=>{const A=("clientX"in R?R.clientX:0)-D.left,F=("clientY"in R?R.clientY:0)-D.top;A&&F&&y({tooltipLeft:A,tooltipTop:F,tooltipData:w})},[y,D]),X=g.useCallback(()=>{T()},[T]);return H.jsxs("div",{className:"bg-white flex flex-col rabbit-ds",style:{width:a,height:s},ref:S,children:[H.jsxs("svg",{width:a,height:s,ref:E,children:[H.jsx(Qa,{orientation:"bottom",scale:p,top:s-hl,hideTicks:!0,stroke:"#CFD7DF",strokeWidth:1,rangePadding:{end:10},label:`${t} ➔`,tickLabelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666",textAnchor:"middle"},labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dy:10,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),H.jsx(Qa,{orientation:"left",scale:v,left:ai,hideTicks:!0,strokeWidth:1,stroke:"#CFD7DF",label:`${n} ➔`,tickLabelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,fill:"#666666",textAnchor:"end"},labelProps:{fontFamily:"system-ui",fontSize:"10px",fontWeight:600,dx:-20,fill:"#666666",textAnchor:"middle",verticalAnchor:"middle"}}),H.jsxs(en,{children:[H.jsx(Uh,{scale:v,width:j,height:L,left:ai,top:0,lineStyle:{stroke:"#EBEFF3",strokeWidth:1}}),m.map(R=>{const w=v(0)-v(R.length),A=p(R.x1??0)-p(R.x0??0);return H.jsx("g",{children:H.jsx(Rx,{x:p(R.x0??0),y:v(R.length),width:A,height:w&&w-1,fill:Ue(0).light,stroke:Ue(0).dark,strokeWidth:1,onMouseMove:F=>V(F,R),onMouseLeave:()=>X()})},Math.random())})]})]}),O&&b&&H.jsx(N,{top:C,left:x,unstyled:!0,applyPositionStyle:!0,children:H.jsx(Hh,{xAxisLabel:t,xValue:`${b.x0} to ${b.x1}`,yAxisLabel:n,yValue:b.length,tooltipTitle:e,legendValue:n,legendDarkColor:Ue(0).dark,legendLightColor:Ue(0).light})},Math.random())]})}),Gh=g.forwardRef((e,t)=>H.jsx(Ho,{debounceTime:10,children:({width:n,height:r})=>H.jsx(pl,{ref:t,width:n,height:r,...e})}));pl.defaultProps={domain:void 0,binCount:void 0,integerBins:!1},pl.displayName="HistogramBase",Gh.displayName="HistogramChart";const mk=Gh;function vk({count:e,totalCount:t,title:n,subTitle:r,className:o,unstyledDimension:i=!1,style:a}){const s="max-w-[336px] min-h-[96px] min-w-[200px]";return H.jsxs("div",{className:Rn("rabbit-ds box-border px-2 py-4 bg-white rounded-lg shadow flex-col justify-center items-start gap-1 inline-flex",o,!i&&s),style:a,children:[H.jsxs("div",{className:"self-stretch px-3 py-1 flex items-baseline",children:[H.jsx("div",{className:"text-zinc-800 text-2xl font-semibold",children:e}),t&&t>0?H.jsxs("div",{className:"text-stone-500 text-xs font-normal",children:["/",t]}):null]}),H.jsx("div",{className:"self-stretch px-3 justify-start items-center gap-2 inline-flex",children:H.jsxs("div",{className:"grow shrink basis-0 flex-col justify-start items-start gap-0.5 inline-flex",children:[H.jsx("div",{className:"self-stretch justify-start items-start gap-2.5 inline-flex",children:H.jsx("div",{className:"grow shrink basis-0 text-zinc-800 text-xs font-semibold leading-none",children:n})}),r&&H.jsx("div",{className:"self-stretch justify-start py-2 items-center gap-1 inline-flex",children:H.jsx("div",{className:"grow shrink basis-0 text-stone-500 text-xs font-normal leading-none",children:r})})]})})]})}Ye.CardKPI=vk,Ye.HistogramChart=mk,Ye.LineChart=ek,Ye.SankeyChart=ck,Object.defineProperty(Ye,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mesh.ai/rabbit",
3
3
  "private": false,
4
- "version": "0.0.36",
4
+ "version": "0.0.37",
5
5
  "packageManager": "pnpm@8.6.0",
6
6
  "main": "./dist/@mesh.ai/rabbit.umd.js",
7
7
  "module": "./dist/@mesh.ai/rabbit.es.js ",