import{j as i}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a53.js";import{G as g}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a577.js";import{U as j}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a578.js";import{f as p}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a58.js";import{a as o}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a52.js";import{L as v}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a57.js";import{z as w}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a55.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};
