1import{r as g,j as r}from"./react-vendor-DUi0d5iR.js";import{o as O}from"./nivo-B9Ms-2Uy.js";import{a as N}from"./tanstack-C_fWFKTi.js";import{C as z}from"./ChartCard-Br7Vdt1v.js";import{h as L,a as S,D as w}from"./chartTheme-Cpcjkp5k.js";import{ae as q,e as D,a_ as E,dl as B}from"./index-g56J2YBJ.js";import"./d3-t9uHqJzG.js";import"./reactflow-CllIyddt.js";import"./force-graph-Bw2zfEgy.js";function P(f,o,c,y){const a=new Map(f.map(e=>[e.id,e.name])),C=new Map(o.map(e=>[e.id,e.name])),_=new Map(c.map(e=>[e.id,e.name])),p=new Map,j=new Map;for(const e of y)if(e.relationship_type==="part_of"&&a.has(e.target_entity_id)&&p.set(e.source_entity_id,e.target_entity_id),e.relationship_type==="works_on"&&C.has(e.source_entity_id)){const s=j.get(e.source_entity_id)||new Set;s.add(e.target_entity_id),j.set(e.source_entity_id,s)}const d=new Map;for(const[e,s]of p){const i=C.get(e);if(!i)continue;const l=j.get(e),m=[];if(l)for(const F of l){const b=_.get(F);b&&m.push({name:b,depth:"person",value:1})}const x={name:i,depth:"project",...m.length>0?{children:m}:{value:1}},T=d.get(s)||[];T.push(x),d.set(s,T)}const h=[];for(const[e,s]of d){const i=a.get(e);!i||s.length===0||h.push({name:i,depth:"org",children:s})}const u=e=>e.value??(e.children||[]).reduce((s,i)=>s+u(i),0);h.sort((e,s)=>u(s)-u(e));const v=h.map(e=>e.name);return{tree:{name:"Portfolio",depth:"root",children:h},orgNames:v}}const J=({onOpenChat:f})=>{const o=typeof document<"u"&&document.documentElement.classList.contains("dark"),[c,y]=g.useState(null),[a,C]=g.useState("__all__"),_=o?w.dark:w.light,{data:p,isLoading:j}=N({queryKey:["orgs-for-chart"],queryFn:()=>E({entity_type:"organization",limit:100}),staleTime:600*1e3}),{data:d,isLoading:h}=N({queryKey:["projects-for-chart"],queryFn:()=>E({entity_type:"project",limit:100}),staleTime:600*1e3}),{data:u,isLoading:v}=N({queryKey:["people-for-packing"],queryFn:()=>E({entity_type:"person",limit:100}),staleTime:600*1e3}),{data:e,isLoading:s}=N({queryKey:["relationships-for-chart"],queryFn:()=>B({limit:500}),staleTime:600*1e3}),i=j||h||v||s,{fullTree:l,orgNames:m}=g.useMemo(()=>{if(!p?.length||!d?.length||!e?.length)return{fullTree:null,orgNames:[]};const t=P(p,d,u||[],e);return{fullTree:t.tree,orgNames:t.orgNames}},[p,d,u,e]),x=g.useMemo(()=>{if(!l)return null;if(a==="__all__")return l;const t=l.children?.find(n=>n.name===a);return t?{name:t.name,depth:"root",children:t.children}:l},[l,a]),T=g.useCallback(t=>{if(t.data.depth==="person"&&f){f(`Tell me about ${t.data.name}'s current projects and workload`);return}y(n=>n===t.id?null:t.id)},[f]),F=g.useCallback(t=>{C(t.target.value),y(null)},[]),b=m.length>0?r.jsxs(q,{value:a,onChange:F,className:"text-xs",style:{fontFamily:"Inter Tight, sans-serif"},children:[r.jsx("option",{value:"__all__",children:"All organizations"}),m.map(t=>r.jsx("option",{value:t,children:t},t))]}):void 0;return i?r.jsx(z,{title:"Organization Hierarchy",height:420,testId:"chart-organization-hierarchy-2",children:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(D,{size:"sm"})})}):!x||!x.children?.length?r.jsx(z,{title:"Organization Hierarchy",headerExtra:b,height:420,testId:"chart-organization-hierarchy",children:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx("p",{className:"text-sm text-ink-500",children:"No org hierarchy data yet"})})}):r.jsx(z,{testId:"chart-organization-hierarchy",title:"Organization Hierarchy",headerExtra:b,actionLabel:c?"Reset zoom":void 0,onAction:c?()=>y(null):void 0,height:420,children:r.jsx(O,{data:x,theme:o?L:S,id:"name",value:"value",colors:t=>{const n=t.data.depth;return n==="org"?_.org:n==="project"?_.project:n==="person"?_.person:o?"#0f172a":"#F3EEE5"},inheritColorFromParent:!1,padding:6,leavesOnly:!1,enableLabels:!0,labelsFilter:t=>a!=="__all__"?t.node.depth>=1:c?t.node.depth>=1&&t.node.depth<=2:t.node.depth===1,labelsSkipRadius:18,labelTextColor:t=>t.data.depth==="org"?o?"#e2e8f0":"#FBF9F4":o?"#cbd5e1":"#3F3A33",borderWidth:2,borderColor:t=>{const n=t.data.depth;return n==="org"?o?"#243d57":"#84461A80":n==="project"?o?"#1e4d4d":"#BC6B2E60":o?"#1e293b":"#E0D8C8"},motionConfig:"gentle",zoomedId:c,onClick:T,tooltip:({id:t,value:n,data:I})=>{const k=I.depth,M=k==="org"?"Organization":k==="project"?"Project":"Team member";return r.jsxs("div",{className:"rounded-none px-3 py-2 text-xs shadow-sm border",style:{background:o?"#152338":"#FBF9F4",borderColor:o?"#243d57":"#E0D8C8",color:o?"#dbe7f1":"#1D1A16",fontFamily:"Inter Tight, sans-serif"},children:[r.jsx("strong",{children:t}),r.jsx("br",{}),r.jsx("span",{style:{color:o?"#6a93b8":"#8C8373"},children:M}),k!=="person"&&n>0&&r.jsxs("span",{style:{color:o?"#6a93b8":"#8C8373"},children:[" ","· ",n," ",n===1?"member":"members"]}),!c&&k==="org"&&r.jsx("span",{style:{display:"block",marginTop:2,color:o?"#3bb3b3":"#BC6B2E",fontSize:10},children:"Click to zoom in"})]})}})})};export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.