1import{f as D,r as x,R as w,j as e}from"./vendor-wagmi-CRHMQcRy.js";import{U as b,f1 as q,f2 as B,eq as K,f3 as k,$ as Q,d0 as L,ch as _,L as U,f as j,aC as z,ao as S,b3 as R,aE as T,aZ as H,K as $,f4 as O,f5 as X,f6 as V,S as W,M as Y,bm as Z}from"./index-CjDX1y09.js";import{u as J}from"./DirectCastUtils-Csf6YDsT.js";import{u as ee}from"./useRemoveDirectCastConversationFromInbox-m7Ycxkfy.js";const A=()=>{const s=D();return x.useCallback(({fid:r,category:a,filter:o,conversationId:i})=>({conversation:s.getQueryData(b({fid:r,category:a,filter:o}))?.pages.reduce((f,d)=>f||d.result.conversations.find(c=>c.conversationId===i),void 0)}),[s])},te=()=>{const s=D(),r=q();return x.useCallback(({updates:a})=>{const o=B({conversationId:a.conversationId}),i=r({conversationId:a.conversationId});typeof i<"u"&&K({cache:i,updates:a})&&s.setQueryData(o,u=>k({},u,a))},[r,s])},de=()=>{const{apiClient:s}=Q(),r=L(),a=te(),o=D(),i=A(),u=ee(),v=J(),f=_();return x.useCallback(async({fid:d,conversationId:c,fromCategory:p,toCategory:l,enabled:g=!0})=>{l!=="deleted"&&(a({updates:{conversationId:c,viewerContext:{category:l,archived:l==="archived"}}}),f({updates:{conversationId:c,viewerContext:{category:l,archived:l==="archived"}}}));const{conversation:C}=i({fid:d,category:p,conversationId:c});if(u({fid:d,category:p,conversationId:c}),l!=="deleted"&&C&&v({fid:d,category:l,conversation:C}),p==="request"&&o.setQueryData(b({fid:d,category:"default"}),t=>{if(!t||t.pages.length===0)return t;const m=t.pages[t.pages.length-1];return{...t,pages:[...t.pages.slice(0,-1),{...m,result:{...m.result,requestsCount:Math.max(m.result.requestsCount-1,0)}}]}}),p==="void"&&o.setQueryData(b({fid:d,category:"default"}),t=>{if(!t||t.pages.length===0)return t;const m=t.pages[t.pages.length-1];return{...t,pages:[...t.pages.slice(0,-1),{...m,result:{...m.result,voidCount:Math.max(m.result.voidCount-1,0)}}]}}),l==="archived"&&o.setQueryData(b({fid:d,category:"default"}),t=>{if(!t||t.pages.length===0)return t;const m=t.pages[t.pages.length-1];return{...t,pages:[...t.pages.slice(0,-1),{...m,result:{...m.result,hasArchived:!0}}]}}),g){const{data:t}=await s.postDirectCastConversationCategorizationV3({conversationId:c,category:l});return t}l!=="deleted"&&(typeof p>"u"||typeof C>"u")&&r({fid:d,category:l})},[s,r,a,o,i,u,v,f])},ue=()=>{const s=D(),r=A();return x.useCallback(({fid:a,category:o,filter:i,updates:u})=>{r({fid:a,conversationId:u.conversationId,category:o,filter:i})&&s.setQueryData(b({fid:a,category:o,filter:i}),f=>{if(f)return{...f,pages:f.pages.map(d=>({...d,result:{...d.result,conversations:d.result.conversations.map(c=>c.conversationId===u.conversationId?k({},c,u):c)}}))}})},[s,r])},se=w.memo(({group:s,onGroupClickCallback:r,disabled:a=!1})=>{const[o,i]=x.useState(!1),u=x.useCallback(v=>{v.stopPropagation(),i(!0);try{r()}catch{}finally{i(!1)}},[r]);return e.jsx("div",{className:j("relative flex cursor-pointer flex-row py-2 pl-[12px] hover:bg-overlay-faint",(o||a)&&"pointer-events-none opacity-50"),onClick:v=>{!o&&!a&&u(v)},children:e.jsx("div",{className:j("flex grow flex-col pr-2",(o||a)&&"opacity-10"),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx(U,{imageURL:s.photoUrl,size:"md",className:"mr-2"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"flex min-w-0 flex-row items-center",children:s.name&&e.jsx("span",{className:"block min-w-0 truncate break-words text-base font-semibold text-default hover:underline",children:s.name})}),e.jsx("div",{className:"flex flex-row items-baseline",children:e.jsxs("div",{className:"mr-1 text-sm text-muted",children:[s.activeParticipantsCount," members"]})})]})]})})})}),G=w.memo(({user:s,onUserClickCallback:r,actions:a,note:o,disabled:i=!1})=>{const[u,v]=x.useState(!1),f=x.useRef(null),[d,c]=x.useState(!1),p=typeof s.viewerContext?.canSendDirectCasts>"u"||s.viewerContext?.canSendDirectCasts===!0,l=x.useCallback(t=>{i||(t.stopPropagation(),c(!0))},[i]),g=x.useCallback(t=>async m=>{if(m.stopPropagation(),!!p){v(!0);try{r(t)}catch{}finally{v(!1)}}},[r,p]),C=z(s)==="pro";return e.jsxs("div",{className:j("relative flex flex-row py-2 pl-[12px]",!u&&p&&"cursor-pointer hover:bg-overlay-faint",(!p||i)&&"pointer-events-none opacity-50"),onClick:t=>{!a&&!u&&!i&&g("default")(t)},children:[e.jsx("div",{className:j("flex grow flex-col pr-2",(u||!p||i)&&"opacity-50"),children:e.jsxs("div",{className:"flex flex-row items-center",children:[e.jsx(S,{user:s,className:"mr-2",withDetailsPopover:!0}),e.jsxs("div",{className:"min-w-0 truncate break-words text-base font-semibold text-default",children:[e.jsxs("span",{className:"flex flex-row items-center gap-[2px]",children:[R({username:s.username,fid:s.fid}),C&&e.jsx(T,{size:20,className:"mb-px"})]}),!p&&" cannot be messaged."]})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:e.jsx(H,{})}),o&&e.jsx("span",{className:"flex flex-col justify-center text-faint",children:o}),a!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-2 flex flex-col justify-center",children:e.jsx("div",{ref:f,className:"h-6 cursor-pointer rounded-full px-1 text-muted hover:bg-overlay-faint hover:text-action-purple",onClick:l,children:e.jsx($,{})})}),d&&e.jsx(O,{children:e.jsx(X,{onClose:()=>
1c(!1),style:{top:f.current?.getBoundingClientRect().bottom,left:f.current?.getBoundingClientRect().right},children:e.jsx("div",{className:j("-ml-48 flex w-48 flex-col rounded-md border p-1 shadow-lg bg-app border-default"),children:a?.map(t=>e.jsx("div",{className:"ml-2 flex flex-col items-center justify-center",children:e.jsx(V,{icon:t.icon??e.jsx(e.Fragment,{}),onClick:m=>g(t.action)(m),name:t.title})},"new-dc-user-action-"+s.fid+"-"+t))})})})]})]})});G.displayName="NewDirectCastConversationUser";const ne=5,ae=62,xe=({onSelectionChanged:s,searchInputRef:r,noSelectionView:a,results:o=[],onEndReached:i,isFetchingNextPage:u,onQueryStringChange:v,showEmptyResultsView:f=!0,maxNumSelectedTargets:d})=>{const[c,p]=x.useState(""),[l,g]=x.useState([]),C=w.useRef(void 0),t=w.useRef(void 0),m=x.useMemo(()=>ne*ae,[]);x.useEffect(()=>{document.body.style.setProperty("--search-for-direct-cast-targets-list-height",`${m}px`)},[m]),x.useEffect(()=>{r?.current&&r.current.focus()},[r]);const I=x.useMemo(()=>o.filter(n=>!l.some(h=>n.type==="user"&&h.type==="user"&&n.content.fid===h.content.fid||n.type==="group"&&h.type==="group"&&n.content.conversationId===h.content.conversationId)),[o,l]),N=x.useMemo(()=>!!(d&&l.length>=d),[d,l]),P=n=>{g(h=>{const y=[...h,n];return s(y),y}),p(""),v(""),r?.current&&r.current.focus()},E=n=>{g(h=>{const y=h.filter(M=>M!==n);return s(y),y})},F=({item:n})=>n.type==="user"?e.jsx(G,{user:n.content,onUserClickCallback:()=>P(n),disabled:N}):e.jsx(se,{group:n.content,onGroupClickCallback:()=>P(n),disabled:N});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-[16px] mb-[12px]",children:e.jsx(W,{ref:r,placeholder:"Search",className:"!rounded-md border border-default",variant:"muted",value:c,disabled:N,maxLength:64,onKeyDown:n=>{C.current=n.code,t.current=c},onKeyUp:n=>{C.current==="Escape"&&t.current&&!c&&n.stopPropagation()},onChange:n=>{const h=n.target.value;p(h),v(h)},onClear:()=>{p(""),v("")}})}),c===""&&l.length===0&&a,l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-start border-b px-[16px] pb-3 border-default",children:e.jsx("span",{className:"text-xs font-medium leading-none text-faint",children:"Selected"})}),N&&e.jsx("div",{className:"mx-[16px] mt-3 inline-flex items-center justify-center rounded-lg border border-yellow-500 bg-yellow-500/10 px-4 py-3",children:e.jsx("span",{className:"text-base font-normal leading-tight text-default",children:"You selected the maximum number of users."})}),e.jsx("div",{className:"mx-[16px] my-[12px] flex h-fit flex-row",children:e.jsx("div",{className:"max-h-[120px] grow overflow-y-auto",children:e.jsx("div",{className:"flex flex-row flex-wrap border-default",children:l.map(n=>e.jsx(re,{target:n,handleRemove:E},`dc-group-${n.type==="user"?"user":"group"}-${n.type==="user"?n.content.fid:n.content.conversationId}`))})})})]}),e.jsxs(e.Fragment,{children:[I.length>0&&e.jsx("div",{className:"flex items-center justify-start border-b px-[16px] pb-3 border-default",children:e.jsx("span",{className:"text-xs font-normal leading-none text-faint",children:"Results"})}),e.jsx(Y,{containerClassName:"overflow-y-auto overflow-x-hidden my-[12px] h-[var(--search-for-direct-cast-targets-list-height)]",data:I,renderItem:F,keyExtractor:n=>`target-${n.type==="user"?n.content.fid:n.content.conversationId}`,onEndReached:i,isFetchingNextPage:u,emptyView:e.jsxs("div",{className:"m-[12px] flex h-[var(--search-for-direct-cast-targets-list-height)] items-center justify-center",children:[f&&!!c&&e.jsx("span",{className:"text-sm text-faint",children:"No results found"}),f&&!c&&e.jsx("span",{className:"text-sm text-faint",children:"Start typing to search people"})]})})]})]})},re=({target:s,handleRemove:r})=>{const a=s.type==="user"?s.content:void 0,o=s.type==="group"?s.content:void 0,i=z(a)==="pro";return e.jsxs("div",{onClick:()=>r(s),className:"mb-2 mr-2 flex cursor-pointer flex-row rounded-md border p-1 align-baseline text-sm bg-overlay-medium border-default",children:[typeof a<"u"?e.jsx(S,{className:"z-0 mr-2",size:"xs",user:a}):e.jsx(U,{imageURL:o?.photoUrl,size:"xs",className:"mr-2"}),e.jsxs("span",{className:"flex flex-row items-center gap-[2px]",children:[typeof a<"u"?e.jsx("span",{children:R({username:a?.username,fid:a?.fid})}):e.jsx("span",{children:o?.name}),i&&e.jsx(T,{size:14,className:"mb-px"})]}
1),e.jsx("div",{className:"ml-2 mt-[2px] inline-block size-[16px] cursor-pointer rounded-full text-center leading-[10px]",children:e.jsx(Z,{size:16})})]})};export{xe as S,ue as a,A as b,de as c,te as u};
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.