import{j as e,d as L,r as C,eh as T,b as W,a as H,k0 as M,k1 as w,B as r,T as n,W as R,K as v,N as q,gW as B,k2 as E}from"./index-60a3c753.js";import{L as Y}from"./List-f567f8e4.js";import{C as D}from"./Chip-cc311899.js";import{A as N}from"./Avatar-a21f41a5.js";import{u as U}from"./index-900fa817.js";import{T as F}from"./TextField-32b29087.js";import"./createSvgIcon-de433e5f.js";import"./useMediaQuery-dba48e3b.js";import"./useControlled-194ef007.js";import"./FormControl-d13d2693.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./InputLabel-71dfc9d4.js";import"./Select-99fc0d84.js";import"./Menu-d1b7e1c3.js";import"./Grow-68442588.js";const K=U.createSvgIcon([e.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),e.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime"),P=L(Y)(({theme:i})=>({maxHeight:"300px",marginTop:"15px",overflowY:"auto",padding:"0 8px","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-thumb":{backgroundColor:i.palette.primary.main,borderRadius:"8px"}})),le=()=>{const[i,d]=C.useState(""),{id:l}=T(),p=W(),{bq_comments:{bq_commentList:x,pageParams:a,bq_commentCount:S,loading:_}}=H(s=>M(s)),z=()=>{d("")},k=()=>{p(E({data:{lead_id:l||"",comment:i},params:a,hide:z}))};return C.useMemo(()=>{p(w({...a,lead:l,search:"",page:1,page_size:10}))},[]),e.jsxs(r,{sx:{bgcolor:"background.paper",borderRadius:3,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",overflow:"hidden"},children:[e.jsx(r,{sx:{p:3,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"white"},children:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsx(n,{variant:"h5",sx:{fontWeight:700},children:"💬 Comments"}),e.jsx(D,{label:S,size:"small",sx:{bgcolor:"rgba(255,255,255,0.2)",color:"white",fontWeight:600}})]})}),e.jsxs(r,{sx:{p:3},children:[e.jsxs(P,{onScroll:s=>{const{target:t}=s;Math.ceil((t==null?void 0:t.scrollTop)+(t==null?void 0:t.offsetHeight))==(t==null?void 0:t.scrollHeight)&&a.page<a.no_of_pages&&p(w({...a,page:(a==null?void 0:a.page)+1,page_size:10}))},children:[x&&x.map((s,t)=>{var c,h,m;return e.jsx(R,{elevation:0,sx:{p:2.5,mb:2,borderRadius:2,bgcolor:"grey.50",border:"1px solid",borderColor:"grey.200",transition:"all 0.3s ease","&:hover":{transform:"translateY(-2px)",boxShadow:"0 4px 20px rgba(0,0,0,0.1)",borderColor:"primary.main"}},children:e.jsxs(r,{sx:{display:"flex",gap:2},children:[e.jsx(N,{sx:{height:40,width:40,bgcolor:"primary.main",fontWeight:600},children:(()=>{var g,b,u,f,j,y;const o=((b=(g=s==null?void 0:s.created_by)==null?void 0:g.fullname)==null?void 0:b.split(" "))||[],A=((f=(u=o[0])==null?void 0:u.charAt(0))==null?void 0:f.toUpperCase())||"",I=((y=(j=o[o.length-1])==null?void 0:j.charAt(0))==null?void 0:y.toUpperCase())||"";return A+(o.length>1?I:"")})()}),e.jsxs(r,{sx:{flex:1},children:[e.jsxs(r,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[e.jsx(r,{children:e.jsxs(n,{component:"h5",sx:{mb:"8px",color:"grey.700",fontWeight:500,fontSize:"13px"},children:[(c=s==null?void 0:s.created_by)==null?void 0:c.fullname," ","(",(h=s==null?void 0:s.created_by)==null?void 0:h.username,")"]})}),e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(K,{sx:{fontSize:12,color:"text.secondary"}}),e.jsx(n,{variant:"caption",sx:{color:"text.secondary"},children:(m=s==null?void 0:s.created_on)==null?void 0:m.toLocaleString()})]})]}),e.jsx(n,{variant:"body2",sx:{color:"text.primary",lineHeight:1.6,whiteSpace:"pre-wrap"},children:s.comment})]})]})},t)}),_&&e.jsx(r,{textAlign:"center",mt:"12px",children:e.jsx(v,{size:"small",sx:{"& > svg":{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}},startIcon:e.jsx(q,{size:16,style:{marginRight:"6px",animation:"spin 1.5s linear infinite"}}),children:"Load More"})})]}),e.jsxs(r,{sx:{border:"1px solid divider",borderRadius:"5px",mt:"28px"},children:[e.jsx(F,{id:"outlined-multiline-static",placeholder:"Your Comment...",rows:3,multiline:!0,fullWidth:!0,value:i,onChange:s=>d(s.target.value)}),e.jsxs(r,{sx:{p:"8px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r,{}),e.jsx(v,{variant:"contained",startIcon:e.jsx(B,{size:16}),onClick:k,disabled:!i,size:"medium",color:"secondary",children:"Submit"})]})]})]})]})};export{le as default};
