import{j as i}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89263.js";import{G as g}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892677.js";import{U as j}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892678.js";import{f as p}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89268.js";import{a as o}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89262.js";import{L as v}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89267.js";import{z as w}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89265.js";function q({loading:e,card:r,finalizado:n,isGroup:t}){return e?i.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-[var(--background-default-active)] text-base-content/60",children:i.jsx(v,{className:"h-5 w-5 animate-spin",strokeWidth:2,"aria-hidden":!0})}):r?.picture?i.jsx("div",{className:p("h-11 w-11 shrink-0 overflow-hidden rounded-full ring-1 ring-[var(--conversation-header-border)]",n&&"opacity-90"),children:i.jsx("img",{src:r.picture,alt:"",className:"h-full w-full object-cover"})}):i.jsx("span",{className:p("flex h-11 w-11 shrink-0 items-center justify-center",n&&"opacity-90"),children:t?i.jsx(g,{style:"w-11 h-11"}):i.jsx(j,{style:"w-11 h-11"})})}function f(e){const r=e.includes("@")?e.split("@")[0]:e;return r.length>22?`${r.slice(0,20)}…`:r}const l=new Map,m=new Map;function y(e){if(l.has(e))return Promise.resolve(l.get(e)??null);const r=m.get(e);if(r)return r;const n=w.Utils("get-card",e).then(t=>{const a=t??null;return l.set(e,a),a}).catch(()=>null).finally(()=>{m.delete(e)});return m.set(e,n),n}function G(e){const[r,n]=o.useState(()=>l.get(e)??null),[t,a]=o.useState(()=>!l.has(e));o.useEffect(()=>{let s=!0;return l.has(e)?(n(l.get(e)??null),a(!1),()=>{s=!1}):(a(!0),y(e).then(d=>s&&n(d)).finally(()=>s&&a(!1)),()=>{s=!1})},[e]);const u=r?.name?.trim()||f(e),c=e.includes("@g.us"),x=o.useMemo(()=>{if(t||c)return null;const s=r?.number?.trim();if(s){const d=f(e);return u===d&&s===u?null:s}return r&&u!==f(e)?f(e):null},[t,c,r,u,e]);return{card:r,loading:t,displayName:u,linhaSecundaria:x,isGroup:c}}export{q as A,y as p,G as u};
