1import{ag as le,r as m,an as re,B as C,a as y,dy as ce,l as O,j as e,dQ as H,Q as ie,bp as k,b4 as me,b5 as oe,b7 as de,b as V,c as G,H as xe,dR as ue,bG as he,Y as ge,ap as pe,aq as fe,_ as Q,at as je,as as ve,C as ye,p as _e,s as Ce,t as Ne,q as we,G as be,d8 as Se,v as ke,d9 as Ee,Z as Fe,dS as Me}from"./index-B79jx0QH.js";import{u as Ie,g as Te,a as ze,b as De}from"./index-Cv_Vf7U1.js";import{u as Ae}from"./useDivHeight-DkMCLk9V.js";import{$,H as B,a as R}from"./hover-card-B1BXbhtP.js";import{g as qe,e as p}from"./CreateAccount-KmyYbJRe.js";import{B as Pe}from"./bluebird-Ukx1d9HB.js";import{c as Ke}from"./useCRMFilterInit-gNct4GR-.js";import{C as We,A as Le,a as Oe}from"./AccountsSavedViewModal-3dTvP1k0.js";import{u as He}from"./useSyncWithSlack-Bi8bXA64.js";import{C as Ve}from"./CopyToClipBoard-Bg36D7af.js";import"./ImageUploader-Cu5gFIZa.js";import"./index-D4EJSZZw.js";import"./table-qlTNHZJv.js";import"./useQueryCardInfo-CS_nnJk_.js";import"./api-tpw92XX5.js";import"./channels-Cx61tpCk.js";import"./auth-DBmBJK6E.js";import"./Avatar-DfbutNKw.js";import"./uploadFiletolinear-Dob_SpBG.js";import"./crm-B4UEAkVM.js";import"./index-DNi9bZVg.js";(function(){try{var f=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},N=new Error().stack;N&&(f._sentryDebugIds=f._sentryDebugIds||{},f._sentryDebugIds[N]="a17c89b7-2057-4630-a3a5-457e85371965",f._sentryDebugIdIdentifier="sentry-dbid-a17c89b7-2057-4630-a3a5-457e85371965")}catch{}})();const Ge=le.div` 2 height: 100%; 3 width: 100%; 4`,Qe=["Customers","Account owners","Solution Engineer"],$e=()=>{window.dispatchEvent(new Event("FILTERS_LANE_CLICKED"))},hs=()=>{const{elementRef:f}=Ae(),[N,I]=m.useState([]),[U,E]=m.useState(!1),[w,Y]=m.useState(""),[Z,T]=m.useState(!1),[x,F]=m.useState({Customers:{values:[],indexed_key:"relationship_id"}}),g=m.useRef(null),{slackSyncMutation:z,loading:J}=He("channels"),[X]=re(),b=X.get("view"),M=C(()=>y().views.toArray(),[],[]),j=m.useMemo(()=>{if(!M||!b)return null;const a=qe(M);return a==null?void 0:a.find(t=>t._id===b)},[M,b]),d=C(()=>y().customerContacts.toArray(),[]),[D,ee]=m.useState([]),v=C(()=>y().filters.toArray(),[],[]),A=C(async()=>{const{crm:a}=await y().crmFields.toArray().then(s=>{var t,n;return{fields:((t=s==null?void 0:s[0])==null?void 0:t.fields)||[],crm:((n=s==null?void 0:s[0])==null?void 0:n.crm)||""}});return a},[]),se=v.filter(a=>Qe.includes(a.name)),te=v.filter(a=>a.indexed_key.startsWith("crm_")),q=[{id:"1",filters:se,label:""},{id:"3",filters:te,label:"CRM filters"}].filter(a=>a.filters.length),P=m.useMemo(()=>{var t;const a=(t=d==null?void 0:d.filter(n=>{var r;return((r=n==null?void 0:n.relationship_ids)==null?void 0:r.length)>0}).map(n=>n.relationship_ids))==null?void 0:t.flat();
4return[...new Set(a)]},[d]),o=C(()=>y().relationships.where("_id").anyOf(P).toArray(),[P]);m.useEffect(()=>{var t;g!=null&&g.current&&((t=g==null?void 0:g.current)==null||t.cancel());const a=[];Object.keys(x).forEach(n=>{const r=x[n];if(r.values.length===0)return;let c;r.indexed_key.includes("crm_")?c=Ke.table("crmRelations").where(r.indexed_key).anyOf(r.values).primaryKeys():c=y().relationships.where(ce(n)).anyOf(r.values).primaryKeys(),a.push(c)});let s=[];g.current=Pe.all(a).then(n=>{s=O.intersection(...n),s=O.uniq(s);const r=d==null?void 0:d.filter(c=>{for(let i=0;i<c.relationship_ids.length;i++)if(s.includes(c.relationship_ids[i]))return!0;return!1});ee(r||[])})},[x,d,o]);const K=Object.keys(x).every(a=>x[a].values.length===0),W=m.useMemo(()=>[{accessorKey:"name",meta:{style:{width:"18rem"}},header:()=>e.jsxs("div",{className:"flex items-center gap-2",children:["Name"," ",e.jsx(H,{size:16,onClick:()=>T(a=>!a)})]}),size:240,enableSortingRemoval:!0,sortingFn:(a,s)=>{var t,n;return(n=a==null?void 0:a.original)==null?void 0:n.name.localeCompare((t=s==null?void 0:s.original)==null?void 0:t.name)},cell:({row:a})=>{var t,n;const s=a==null?void 0:a.original;return e.jsxs("div",{className:"flex items-center gap-2 w-[280px] text-left text-ellipsis whitespace-nowrap overflow-hidden text-sm px-1",children:[e.jsx("img",{src:((n=(t=s==null?void 0:s.metadata)==null?void 0:t.slack)==null?void 0:n.profile_image_48)||ie,alt:s==null?void 0:s.name,className:"w-5 h-5 rounded-full object-cover"}),e.jsx(k,{tooltipContent:s==null?void 0:s.name,children:e.jsx("div",{className:"w-56 truncate text-left",children:s==null?void 0:s.name})})]})}},{accessorKey:"email",meta:{style:{width:"22rem"}},header:()=>e.jsxs("div",{className:"flex items-center gap-2",children:["Email"," ",e.jsx(H,{size:16,onClick:()=>T(a=>!a)})]}),cell:({row:a})=>{var s,t,n;return e.jsxs(me,{children:[e.jsx(oe,{children:e.jsx("div",{className:"w-80 break-words text-sm text-left line-clamp-1",children:((s=a.original)==null?void 0:s.email)||"-"})}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(t=a.original)==null?void 0:t.email,e.jsx(Ve,{text:(n=a.original)==null?void 0:n.email})]})})]})}},{accessorKey:"accountOwner",header:()=>e.jsx("div",{children:"Account"}),meta:{style:{width:"14rem"}},cell:({row:a})=>{var n,r,c,i;const s=o==null?void 0:o.find(u=>{var l,_;return u._id===((_=(l=a==null?void 0:a.original)==null?void 0:l.relationship_ids)==null?void 0:_[0])}),t=(n=a==null?void 0:a.original)==null?void 0:n.relationship_ids;return t!=null&&t.length?e.jsxs("div",{className:"flex items-center gap-4 text-sm w-56 px-1",children:[e.jsx("div",{children:e.jsxs("div",{className:"text-left text-ellipsis whitespace-nowrap overflow-hidden flex items-center gap-2",children:[s!=null&&s.team_logo_url||(c=(r=s==null?void 0:s.customer_team)==null?void 0:r.icon)!=null&&c.image_68?e.jsx("img",{src:(s==null?void 0:s.team_logo_url)||s.customer_team.icon.image_68,alt:p(s==null?void 0:s.customer_name,s),className:"w-5 h-5 rounded-full object-cover"}):e.jsx("div",{className:"w-5 h-5 rounded-full border flex items-center justify-center text-[10px]",children:V(p(s==null?void 0:s.customer_name,s))}),e.jsx(k,{tooltipContent:p(s==null?void 0:s.customer_name,s),children:e.jsx("div",{className:G("truncate text-sm",(t==null?void 0:t.length)>1?"max-w-28 ":"max-w-48"),children:p(s==null?void 0:s.customer_name,s)})})]})}),(t==null?void 0:t.length)>1&&e.jsxs($,{children:[e.jsx(B,{children:e.jsxs("div",{className:"text-sm cursor-pointer bg-primary-foreground p-1 px-2 rounded-md font-medium",children:["+",(i=t==null?void 0:t.slice(1))==null?void 0:i.length]})}),e.jsx(R,{align:"end",className:"max-h-56 overflow-auto p-2",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"text-sm text-muted-text py-1",children:["Accounts (",t==null?void 0:t.length,")"]}),e.jsx("div",{className:"flex flex-col gap-3",children:t==null?void 0:t.map(u=>{var _,L;const l=o==null?void 0:o.find(ne=>ne._id===u);return e.jsxs("div",{className:"text-left text-ellipsis whitespace-nowrap overflow-hidden flex items-center gap-2",children:[l!=null&&l.team_logo_url||(L=(_=l==null?void 0:l.customer_team)==null?void 0:_.icon)!=null&&L.image_68?e.jsx("img",{src:(l==null?void 0:l.team_logo_url)||l.customer_team.icon.image_68,alt:p(l==null?void 0:l.customer_name,l),className:"w-5 h-5 rounded-full object-cover"}):e.jsx("div",{className:"w-5 h-5 rounded-full border flex items-center justify-center text-[10px]",children:V(p(l==null?void 0:l.customer_name,l))}),e.jsx("div",{className:"truncate w-40 text-sm",children:p(l==null?void 0:l.customer_name,l)})]},u)})})]})})]})]}):e.jsx("div",{className:"px-1",children:"-"})},size:180},{accessorKey:"channel_name",header:()=>e.jsx("div",{children:"Channels"}),meta:{style:{width:"14rem"}},size:240,cell:({row:a})=>{var n,r;const s=o==null?void 0:o.find(c=>{var i,u;return c._id===((u=(i=a==null?void 0:a.original)==null?void 0:i.relationship_ids)==null?void 0:u[0])}),t=(n=a==null?void 0:a.original)==null?void 0:n.relationship_ids;return t!=null&&t.length?e.jsxs("div",{className:"flex items-center gap-4 px-1 text-sm w-56",children:[e.jsx(k,{tooltipContent:s==null?void 0:s.channel_name,children:e.jsxs("div",{className:G("truncate",(t==null?void 0:t.length)>1?"max-w-40":"max-w-56"),children:["# ",s==null?void 0:s.channel_name]})}),(t==null?void 0:t.length)>1&&e.jsxs($,{children:[e.jsx(B,{children:e.jsxs("div",{className:"text-sm cursor-pointer bg-primary-foreground p-1 px-2 rounded-md font-medium",children:["+",(r=t==null?void 0:t.slice(1))==null?void 0:r.length]})}),e.jsx(R,{align:"end",className:"max-h-56 overflow-auto p-2",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"text-sm text-muted-text py-1",children:["Channels (",t==null?void 0:t.length,")"]}),e.jsx("div",{className:"flex flex-col gap-2",children:t==null?void 0:t.map(c=>{const i=o==null?void 0:o.find(u=>u._id===c);return e.jsx(k,{tooltipContent:i==null?void 0:i.channel_name,children:e.jsxs("div",{className:"text-left text-sm text-ellipsis whitespace-nowrap overflow-hidden pr-6",children:["# ",i==null?void 0:i.channel_name]})})})})]})})]})]}):e.jsx("div",{className:"px-1",children:"-"})}}],[d,o]),h=m.useMemo(()=>K?d:D??xe,[D,K,d]),S=m.useMemo(()=>w?h==null?void 0:h.filter(a=>{var s,t,n,r;return((t=(s=a==null?void 0:a.name)==null?void 0:s.toLowerCase())==null?void 0:t.includes(w.toLowerCase()))||((r=(n=a==null?void 0:a.email)==null?void 0:n.toLowerCase())==null?void 0:r.includes(w.toLowerCase()))}):h,[w,h]),ae=Ie({data:S||[],columns:W,getCoreRowModel:Te(),getSortedRowModel:ze(),getFilteredRowModel:De(),defaultColumn:{size:0},state:{sorting:N},enableSortingRemoval:!0,onSortingChange:I});return m.useEffect(()=>{if(j!=null&&j.additionalPrefs){const{queryMap:a}=j.additionalPrefs;F(a)}}
4,[j]),e.jsxs("div",{className:"flex flex-col h-[90%] gap-4 p-6",children:[e.jsx("div",{className:"text-xl font-medium",children:"Contacts"}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(ue,{size:16})," ",h==null?void 0:h.length," contacts"]}),e.jsxs("div",{className:"flex flex-col h-[90%] lg:h-[88%] gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex items-center gap-1",children:[e.jsx(he,{size:16,className:"pointer-events-none ml-2 absolute"}),e.jsx(ge,{placeholder:"Find in view",className:"pl-8 w-[180px] h-[28px]",onChange:a=>{Y(a.target.value)}})]}),e.jsx(We,{queryMap:x,setQueryMap:F,filters:v,crm:A}),e.jsxs(pe,{open:U,onOpenChange:E,children:[e.jsx(fe,{asChild:!0,onClick:()=>E(!0),onClickCapture:$e,children:e.jsxs(Q,{size:"sm",className:"h-7 gap-1 flex items-center text-muted-foreground",variant:"ghost",children:[e.jsx(je,{size:16})," Add filter"]})}),e.jsx(ve,{className:"w-[200px] p-0",children:e.jsxs(ye,{children:[e.jsx(_e,{placeholder:"Search for a filter"}),e.jsx(Ce,{children:"No filter found."}),e.jsx(Ne,{children:e.jsx(we,{children:q.map((a,s)=>e.jsxs(m.Fragment,{children:[a.label&&e.jsx("span",{className:"text-xs font-medium block p-[6px] text-color-icon-muted",children:a.label}),a.filters.filter(t=>!x[t.name]).map(t=>{const n=be(a.label||t.name,t.indexed_key.startsWith("custom_"));let r;return t.indexed_key.startsWith("crm")&&(r=Se(A)),e.jsx(ke,{value:t.name,onSelect:()=>{const c=v==null?void 0:v.find(i=>i.name===t.name);c!=null&&c.name&&F({...x,[c.name]:{values:[],indexed_key:c.indexed_key}}),E(!1)},children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[n&&e.jsx(n,{size:16}),r&&e.jsx("img",{src:r,alt:"crm icon",className:"h-4 w-4"}),Ee(t.name)]})},t.name)}),s!==q.length-1&&e.jsx(Fe,{className:"my-1"})]},a.id))})})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Q,{variant:"outline",disabled:J,onClick:()=>{z.mutate({model:"channels"}),z.mutate({model:"userGroups"})},className:"flex items-center gap-3 h-7",children:[e.jsx(Me,{size:16})," Sync contacts"]}),e.jsx(Le,{queryMap:x,type:"CONTACTS_SAVED_VIEW",viewId:b,currentSavedViews:j})]})]}),e.jsx(Ge,{className:"grow",ref:f,children:e.jsx(Oe,{table:ae,memoiziedColumn:W,len:S==null?void 0:S.length,renderProp:Z})})]})]})};export{hs 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.