PageSourceSearch

https://reengage.ai/assets/MetaMessages-DNxKv3aO.js

js reengage.ai collected 2026-10-05 12:30:50 UTC 27,954 bytes, 1 lines download raw bytes

1import{K as dt,j as e,bc as he,b5 as ie,r as i,b as ge,t as J,b9 as $e,B as ee,ag as ve,ba as pt,e as M,aR as Q,T as $,ad as mt,w as N,b8 as Ee,x as Ie,a as Me,aU as Je,S as H,bY as ut,aD as _e,b7 as gt,aN as ht,D as ft,aO as _t,aP as xt,k as St,aS as ze,R as bt,ci as jt,I as yt,d as Ct}from"./index-BBY15sAj.js";import{H as Et}from"./Header-ClnXQq65.js";import{S as Tt}from"./SearchInput-CJVm_E8a.js";import{M as vt}from"./Modal-DOsaxXWm.js";import{u as It,T as Mt,R as At,s as Rt}from"./useSyncSearchParamsPayload-D1Lz934y.js";import{C as Nt}from"./ConnectionAction-BnbUuzw_.js";import{S as Ae}from"./Pagination-kJmwjW-c.js";import{u as Qe}from"./index.esm-DG1Ty31A.js";import{g as Ge}from"./date-D8u5m6gG.js";import{g as Ft,a as Ot}from"./sortingQueryBuilder-C0y4NVxx.js";import{t as Pt}from"./toDisableInputFilter-clfdYQMq.js";import{u as Y}from"./urlQueryBuilder-B7FR08j4.js";import{a as Lt,F as wt}from"./areAllKeysEmpty-D252dFno.js";import{S as oe,C as Ze,a as te}from"./CustomLinkify-CMHpuoqw.js";import{C as Xe,M as v}from"./combinedPlatforms-CReTWGaj.js";import{I as Re}from"./Instagram-Mxp_xiR1.js";import{g as Bt}from"./index-CwcExWDa.js";import{b as Ne,T as De,I as Ke}from"./TextField-8dAl8v62.js";import{A as Wt}from"./Autocomplete-Dybmme_b.js";import{F as Fe}from"./Facebook-C4vrOKus.js";import{M as Oe}from"./MenuItem-BqljAD2L.js";import{a as kt}from"./intercomOffset-BqOunVEA.js";import{M as $t}from"./Menu-BmjpnJkl.js";import{g as zt,K as Gt}from"./getTableMenuPosition-WuTxV5bS.js";import{K as Kt,a as Vt,I as Ht}from"./KeyboardArrowRight-ZQQOdDjC.js";import{a as xe}from"./appendTeamSlug-DMTfDJv9.js";import{f as Ut}from"./formateDate-DT4h-d65.js";import{T as qt}from"./Toolbar-B0_ovqE9.js";import{S as Ve}from"./Select-BcWdgGSa.js";import{i as Yt}from"./index-CPZ6avG0.js";import"./Checkbox-C7OkiWj7.js";import"./SwitchBase-BpCCQgwG.js";import"./useFormControl-D94OB1U5.js";import"./TableRow-Cs4Ck_0d.js";import"./CloseIcon-B5E00aE-.js";import"./index-OztSKMtU.js";import"./isMuiElement-iu7bEC02.js";import"./Close-Ch4GpVRF.js";import"./isHostComponent-DVu5iVWx.js";import"./index-COmIkRYU.js";const Jt=dt(e.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune"),Qt=({color:s=he,...o})=>e.jsx("svg",{width:"20",height:"22",viewBox:"0 0 20 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:e.jsx("path",{d:"M18.7377 9.68843L2.98773 0.698747C2.72206 0.549191 2.41713 0.484137 2.11356 0.512253C1.80999 0.540368 1.52219 0.660317 1.28851 0.85612C1.05483 1.05192 0.886364 1.31428 0.80555 1.60825C0.724737 1.90221 0.735416 2.21382 0.836164 2.50156L3.70773 11.0009L0.836164 19.5012C0.75625 19.7274 0.731752 19.9695 0.764727 20.2071C0.797701 20.4447 0.887186 20.671 1.02567 20.8669C1.16416 21.0627 1.34761 21.2226 1.56063 21.3329C1.77365 21.4432 2.01002 21.5008 2.24991 21.5009C2.51054 21.5004 2.76661 21.4326 2.99335 21.3041L18.7359 12.2994C18.9681 12.1693 19.1615 11.9798 19.2962 11.7503C19.431 11.5208 19.5023 11.2595 19.5028 10.9934C19.5032 10.7272 19.4329 10.4658 19.299 10.2358C19.165 10.0058 18.9723 9.81559 18.7405 9.68468L18.7377 9.68843ZM2.24991 20.0009C2.25032 19.9972 2.25032 19.9934 2.24991 19.9897L5.03804 11.7509H10.4999C10.6988 11.7509 10.8896 11.6719 11.0302 11.5313C11.1709 11.3906 11.2499 11.1998 11.2499 11.0009C11.2499 10.802 11.1709 10.6113 11.0302 10.4706C10.8896 10.33 10.6988 10.2509 10.4999 10.2509H5.03804L2.25554 2.01593C2.25462 2.01063 2.25271 2.00554 2.24991 2.00093L17.9999 10.985L2.24991 20.0009Z",fill:he})}),Zt="_page_n9f42_1",Xt="_pageHeader_n9f42_121",Dt="_pageTitle_n9f42_133",es="_pageSubtitle_n9f42_148",ts="_mainWrapper_n9f42_156",ss="_actionWrapper_n9f42_173",ns="_inputContainer_n9f42_188",rs="_tableWrapper_n9f42_226",as="_modalBodyWrapper_n9f42_258",is="_messageWrapper_n9f42_287",os="_replyWrapper_n9f42_293",ls="_sendDetails_n9f42_301",cs="_dateHeading_n9f42_307",ds="_line_n9f42_314",He={page:Zt,pageHeader:Xt,pageTitle:Dt,pageSubtitle:es,mainWrapper:ts,actionWrapper:ss,inputContainer:ns,tableWrapper:rs,modalBodyWrapper:as,messageWrapper:is,replyWrapper:os,sendDetails:ls,dateHeading:cs,line:ds},ps="_filterSection_1n4jt_1",ms="_filterFooter_1n4jt_8",us={filterSection:ps,filterFooter:ms},Te={phishingStatus:void 0,platform:void 0,sentimentLabel:void 0,selectedPages:[]},gs=[{id:"true",label:"True"},{id:"false",label:"False"}],et=Object.values(Xe).map(s=>{const o=oe[s];return{id:s,label:o.label}}),hs=Object.values(v).map(s=>({id:s,label:`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}));var Pe=(s=>(s[s.UPDATE_PAGE_CONFIG_AND_FILTERS=0]="UPDATE_PAGE_CONFIG_AND_FILTERS",s))(Pe||{}),fe=(s=>(s.REPLY="Reply",s.ADJUST_SENTIMENT="Adjust Sentiment",s))(fe||{});const le={page:1,page_size:ie[0]},fs=(s,o)=>{const{type:t,payload:p}=o;switch(t){case Pe.UPDATE_PAGE_CONFIG_AND_FILTERS:return{...s,...le,...p};default:return s}},_s=s=>{const o=s.get("first_message_sentiment")||s.get("message_sentiment")||void 0;return{search:s.get("search")||void 0,ordering:s.get("ordering")||void 0,contains_phishing:s.get("contains_phishing")||void 0,first_message_sentiment:o,platform:s.get("platform")||void 0,page_id:s.get("page_id")||void 0,instagram_account_id:s.get("instagram_account_id")||void 0}},Ue=s=>{const o=t=>String(t??"").trim().toLowerCase();return{phishingStatus:s.contains_phishing?{id:s.contains_phishing,label:qe(s.contains_phishing)}:void 0,sentimentLabel:s.first_message_sentiment&&(()=>{const t=o(s.first_message_sentiment),p=et.find(S=>o(S.id)===t||o(S.label)===t);return p||void 0})(),platform:s.platform?{id:s.platform,label:qe(s.platform)}:void 0}},xs=s=>new Date(s).getDate()===new Date().getDate(),qe=s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`,me=(s,o)=>o.filter(t=>t.platform===s).map(t=>t.platform_id).join(","),Ss=[{id:fe.REPLY,content:"Reply"},{id:fe.ADJUST_SENTIMENT,content:"Adjust sentiment"}],tt=s=>{var t,p;return{id:s.id,platform:s.platform,author:s.sender_name||"",text:s.message_text||"",sentiment_label:s.sentiment_label,alreadyCorrectedSentiment:((t=s.ai_learning)==null?void 0:t.correct_sentiment)||null,reasonWhyCorrected:((p=s.ai_learning)==null?void 0:p.reason)||""}},bs="_dropdownLikeTextField_j7a8g_1",js={dropdownLikeTextField:bs},ys=({chosenPlatform:s,chosenPages:o,handleChangePages:t,initialPagesIds:p,resetKey:S})=>{const[f,_]=i.useState([]),[d,b]=i.useState(""),j=i.useRef(!1),W=i.useRef(null),F=i.useRef(1),O=i.useRef(0),c=s===v.INSTAGRAM,z=s===v.FACEBOOK,k=i.useMemo(()=>f.filter(l=>c?l.platform===v.INSTAGRAM:z?l.platform===v.FACEBOOK:!0),[f,s]),{execute:m,data:x,loading:y}=ge(Bt,{onSuccess(l){_(n=>{const h=l.results.filter(T=>!n.some(L=>L.id===T.id&&L.platform===T.platform));return[...n,...h]}),l.count>O.current&&(O.current=l.count)},onError(){J("Something went wrong while fetching pages data")}}),E=i.useMemo(()=>f.length<O.current,[x,f]),A=i.useMemo(()=>$e.debounce(()=>{F.current+=1,m(`?page=${F.current}&page_size=100`)},150),[]),P=i.useCallback(()=>{A()},[E,A,c]);i.useEffect(()=>{j.current=!1},[S]),i.useEffect(()=>{E&&s&&m(`?page=1&page_size=100&platform=${s}`)},[E,s]),i.useEffect(()=>{m("?page=1&page_size=100")},[]),i.useEffect(()=>{p&&m(`?page_ids=${encodeURIComponent(p)}`)},[p]),i.useEffect(()=>{if(!p||!f.length||o.length||j.current)return;
1const l=p.split(",").filter(Boolean).map(n=>f.find(h=>(h==null?void 0:h.platform_id)===n)).filter(n=>n!==void 0);l.length&&(t(l),j.current=!0)},[p,f,o,t]);const u=i.useMemo(()=>$e.debounce(l=>{m(`?search=${encodeURIComponent(l)}`)},300),[x]),I=(l,n)=>{l&&(b(n),n.length>=Cs&&f.length<O.current&&u(n))};return e.jsx(Ne,{fullWidth:!0,children:e.jsx(Wt,{multiple:!0,options:k,getOptionLabel:l=>(l==null?void 0:l.name)??"",isOptionEqualToValue:(l,n)=>l.id===n.id&&l.platform===n.platform,value:o,onChange:(l,n)=>t(n),inputValue:d,onInputChange:(l,n)=>I(l,n),loading:y,slotProps:{listbox:{onScroll:l=>{const n=l.currentTarget;n.scrollHeight-n.scrollTop-n.clientHeight<5&&E&&!y&&P()}}},renderInput:l=>e.jsx(De,{...l,className:js.dropdownLikeTextField,variant:"outlined",label:"Pages",inputRef:W,slotProps:{input:{...l.InputProps,notched:!1,endAdornment:e.jsxs(e.Fragment,{children:[y?e.jsx(mt,{color:"primary",size:20}):null,l.InputProps.endAdornment]})}},sx:{"& .MuiInputLabel-root":{transform:"translate(14px, 14px) scale(1)",opacity:"0.5"},"& .MuiInputLabel-root.MuiInputLabel-shrink":{opacity:"0"}}}),filterSelectedOptions:!0,renderOption:(l,n)=>{const{key:h,...T}=l,L=`${h}-${n==null?void 0:n.id}`;return e.jsxs(Oe,{value:n==null?void 0:n.id,sx:{alignItems:"center",display:"flex",maxWidth:"100%",overflow:"hidden"},...T,children:[(n==null?void 0:n.platform)===v.FACEBOOK?e.jsx(Fe,{sx:{color:M.color.blue}}):e.jsx(Re,{sx:{color:M.color.blue}}),e.jsx($,{sx:{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.jsx(Q,{title:n==null?void 0:n.name,placement:"top",children:e.jsx("span",{children:n==null?void 0:n.name})})})]},L)},renderTags:(l,n)=>e.jsx(ee,{sx:{display:"flex",flexWrap:"wrap",gap:.5,maxWidth:"100%",overflow:"hidden"},children:l.map((h,T)=>{const{key:L,...w}=n({index:T}),Z=`${L}-${h==null?void 0:h.id}`;return e.jsx(ve,{variant:"outlined",label:e.jsx(Q,{title:h==null?void 0:h.name,placement:"top",children:e.jsx("span",{children:h==null?void 0:h.name})}),avatar:(h==null?void 0:h.platform)===v.FACEBOOK?e.jsx(Fe,{sx:{color:`${M.color.blue} !important`}}):e.jsx(Re,{sx:{color:`${M.color.blue} !important`}}),deleteIcon:e.jsx(pt,{style:{color:M.color.blue},onMouseDown:g=>g.stopPropagation()}),sx:{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},...w},Z)})})})})},Cs=3,Es=({searchFilters:s,onReset:o,onSubmit:t})=>{const{filterSection:p,filterFooter:S}=us,f=i.useMemo(()=>({style:{padding:"4px 0"}}),[]),[_,d]=i.useState(!1),[b,j]=i.useState(0);i.useEffect(()=>_?kt():void 0,[_]);const W=()=>{j(g=>g+1),d(!1)},F=i.useMemo(()=>s.toString(),[s]),O=i.useMemo(()=>`${b}-${F}`,[b,F]),c=i.useMemo(()=>_s(new URLSearchParams(F)),[F]),z=c.page_id?c.page_id.split(",").filter(g=>g!=="undefined"):[],k=c.instagram_account_id?c.instagram_account_id.split(",").filter(g=>g!=="undefined"):[],m=[...z,...k].join(","),{watch:x,setValue:y,reset:E,handleSubmit:A}=Qe({mode:"onChange",defaultValues:{...Te,...Ue(c)}}),P=i.useMemo(()=>({...Te,...Ue(c),selectedPages:[]}),[c]);i.useEffect(()=>{_||E(P,{keepDirty:!1})},[_,E,P]);const[u,I,l,n]=x(["phishingStatus","platform","sentimentLabel","selectedPages"]),h=i.useMemo(()=>{const g=X=>String(X??"").trim().toLowerCase(),R=X=>X?X.split(",").map(de=>de.trim()).filter(Boolean).sort().join(","):"",G=(u==null?void 0:u.id)==="true"?"true":(u==null?void 0:u.id)==="false"?"false":void 0,U=I==null?void 0:I.id,C=l==null?void 0:l.id,se=n!=null&&n.length?me(v.FACEBOOK,n):"",ne=n!=null&&n.length?me(v.INSTAGRAM,n):"",je=g(G)===g(c.contains_phishing),ye=g(U)===g(c.platform),q=g(C)===g(c.first_message_sentiment),ce=R(se)===R(c.page_id),Ce=R(ne)===R(c.instagram_account_id);return!(je&&ye&&q&&ce&&Ce)},[u==null?void 0:u.id,I==null?void 0:I.id,l==null?void 0:l.id,n,c.contains_phishing,c.platform,c.first_message_sentiment,c.page_id,c.instagram_account_id]),T=i.useMemo(()=>!Lt({contains_phishing:c.contains_phishing,first_message_sentiment:c.first_message_sentiment,platform:c.platform,page_id:c.page_id,instagram_account_id:c.instagram_account_id}),[c.contains_phishing,c.first_message_sentiment,c.platform,c.page_id,c.instagram_account_id]),L=i.useMemo(()=>!T&&!h,[T,h]),w=g=>{const{phishingStatus:R,sentimentLabel:G,platform:U,selectedPages:C}=g,se=C?me(v.INSTAGRAM,C):"",ne=C?me(v.FACEBOOK,C):"";t({contains_phishing:(R==null?void 0:R.id)==="true"?"true":(R==null?void 0:R.id)==="false"?"false":void 0,first_message_sentiment:G==null?void 0:G.id,platform:U==null?void 0:U.id,page_id:ne,instagram_account_id:se}),E(g,{keepDirty:!1}),W()},Z=()=>{E(Te,{keepDirty:!1}),W(),o()};return e.jsx(wt,{headerText:"Filters",isOpen:_,isFilterApplied:T,handleOpen:g=>{if(!g){h&&E(P,{keepDirty:!1}),W();return}d(!0)},children:e.jsxs("form",{onSubmit:A(w),children:[e.jsxs("section",{className:p,children:[e.jsxs("div",{children:[e.jsx(N,{variant:"b3-medium",children:" Phishing status "}),e.jsx(Ee,{options:gs,value:u,placeholder:"Select phishing status",openPosition:"Bottom",isClearable:!0,inputContainerProps:f,onChange:g=>y("phishingStatus",g,ae)},`phishing-${b}`)]}),e.jsxs("div",{children:[e.jsx(N,{variant:"b3-medium",children:"Sentiment label"}),e.jsx(Ee,{options:et,value:l,placeholder:"Select sentiment label",isClearable:!0,inputContainerProps:f,onChange:g=>y("sentimentLabel",g,ae),openPosition:"Bottom"},`sentiment-${b}`)]}),e.jsxs("div",{children:[e.jsx(N,{variant:"b3-medium",children:" Platform "}
1),e.jsx(Ee,{options:hs,value:I,placeholder:"Select platform",isClearable:!0,inputContainerProps:f,onChange:g=>{y("platform",g,ae),y("selectedPages",[],ae)},openPosition:"Bottom"},`platform-${b}`)]}),e.jsxs("div",{children:[e.jsx(N,{variant:"b3-medium",children:" Pages "}),e.jsx(ys,{chosenPlatform:I==null?void 0:I.id,initialPagesIds:m,resetKey:O,chosenPages:n??[],handleChangePages:g=>y("selectedPages",g,ae)})]})]}),e.jsxs("div",{className:S,children:[e.jsx(Ie,{variant:"Outlined",type:"reset",disabled:L,onClick:()=>Z(),children:"Reset"}),e.jsx(Ie,{variant:"Primary",disabled:!h,type:"submit",children:"Apply"})]})]})})},ae={shouldDirty:!0,shouldValidate:!0},Ts=({message:s})=>{const[o,t]=i.useState(!1),[p,S]=i.useState(!1),f=i.useRef(null),_=i.useId();return i.useEffect(()=>{if(o)return;const d=f.current;if(!d)return;const b=()=>S(d.scrollHeight>d.clientHeight+1);b();const j=new ResizeObserver(b);return j.observe(d),()=>j.disconnect()},[s,o]),e.jsxs(ee,{children:[e.jsx(ee,{ref:f,id:_,sx:{display:o?"block":"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:o?"unset":3,overflow:"hidden",overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:e.jsx(N,{variant:"b4-regular",children:e.jsx(Ze,{styles:{display:"inline",color:M.color.blue,overflowWrap:"anywhere"},children:s})})}),(p||o)&&e.jsx(Me,{variant:"text",size:"small","aria-expanded":o,"aria-controls":_,onClick:()=>t(d=>!d),sx:{p:0,minWidth:0,mt:.5},children:o?"Show less":"Show more"})]})},vs=(s,o)=>[{id:"message-thread",header:"Thread",meta:{width:88,headerStyle:{whiteSpace:"nowrap"}},cell:({row:t})=>{const p=t.original,S=!p.has_multiple_messages,f=t.getIsExpanded(),_=S?"Thread is empty":t.getIsExpanded()?"Close message thread":"View message thread",d=()=>{f||o(p),t.toggleExpanded()};return e.jsx(Q,{title:_,children:e.jsx("span",{children:e.jsx(Je,{"aria-label":_,onClick:d,disabled:S,children:f?e.jsx(Kt,{}):e.jsx(Vt,{})})})})}},{accessorKey:"account_source_name",header:"Source name",meta:{width:144,sortColumn:!0},cell:({row:{original:t}})=>e.jsx(N,{variant:"b4-regular",title:t.account_source_name??void 0,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.account_source_name})},{accessorKey:"platform",header:"Platform",meta:{width:104,sortColumn:!0},cell:({row:{original:t}})=>t.platform===v.INSTAGRAM?e.jsx(Q,{title:"Instagram",children:e.jsx(Re,{color:"primary"})}):e.jsx(Q,{title:"Facebook",children:e.jsx(Fe,{color:"primary"})})},{accessorKey:"participant_name",header:"Sender name",meta:{width:120},cell:({row:{original:t}})=>e.jsx(N,{variant:"b4-regular",title:t.participant_name??void 0,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.participant_name})},{accessorKey:"last_message_translated",header:"Translated message",cell:({row:{original:t}})=>e.jsx(Ts,{message:t.last_message_translated||""},t.id)},{accessorKey:"has_phishing_messages",header:"Phishing status",meta:{width:136},cell:({row:{original:t}})=>e.jsx(N,{variant:"b4-regular",children:t.has_phishing_messages?"Phishing":"Not phishing"})},{accessorKey:"last_message_sentiment",header:"Sentiment",meta:{width:128},cell:({row:{original:t}})=>t.last_message_ai_learning?e.jsxs(H,{gap:"10px",children:[e.jsx(te,{sentimentLabel:t.last_message_sentiment,isOld:!0}),e.jsx(te,{sentimentLabel:t.last_message_ai_learning.correct_sentiment})]}):e.jsx(te,{sentimentLabel:t.last_message_sentiment})},{header:"Action",meta:{width:80,headerStyle:{textAlign:"right"},rowDataStyle:{textAlign:"right"}},cell:({row:{original:t,index:p},table:S})=>{const f=zt(p,S);return e.jsx($t,{TriggerElement:e.jsx(Gt,{}),menuItems:Ss,menuPosition:f,onMenuItemClick:_=>s(_,t)})}}],Se={META_CONVERSATIONS_MESSAGES:"/socialpilot/conversations/"},be={MESSAGES:"messages/",REPLY:"reply/",LIST_CONVERSATION:"list_conversations/",SENTIMENT_FEEDBACK:"sentiment_feedback/"},ue=async(s,o,t="")=>{const p={platform:o,...t&&{additionalParams:t}},{data:S}=await _e.get(xe(`${Se.META_CONVERSATIONS_MESSAGES}${s}/${be.MESSAGES}`),{params:p});return S},Is=async(s,o)=>{const{data:t}=await _e.post(xe(`${Se.META_CONVERSATIONS_MESSAGES}${s}/${be.REPLY}`),o);return t},Ms=(s="")=>{const o=xe(`${Se.META_CONVERSATIONS_MESSAGES}${be.LIST_CONVERSATION}${s}`);return ut(o,async()=>{const{data:t}=await _e.get(o,{timeout:gt});return t})},As=async s=>(await _e.post(xe(`${Se.META_CONVERSATIONS_MESSAGES}${be.SENTIMENT_FEEDBACK}`),s),!0),Rs=({conversation:s,conversationLoading:o,rowData:t,setSentimentObject:p,setSelectedConversation:S})=>{const f=d=>{t&&S(t);const b=tt(d);p(b)},_=i.useMemo(()=>(t==null?void 0:t.platform)===v.FACEBOOK?t==null?void 0:t.fb_page_id:(t==null?void 0:t.platform)===v.INSTAGRAM?t==null?void 0:t.ig_account_id:null,[t]);return o?e.jsx(Ae,{variant:"Rectangular",width:"100%",height:"50px"}):!s||s.length<2?e.jsx(ee,{bgcolor:M.color.pageBg,p:2,children:e.jsx($,{pl:2,children:"No messages in this thread"})}):e.jsx(H,{borderBottom:`1px solid ${M.color.hairline}`,children:s.map(d=>{const b=!!_&&d.sender_id===_,j=d.translated_message===(t==null?void 0:t.last_message_text);return e.jsxs(ee,{mt:2,p:3,sx:{borderColor:M.color.hairline,borderWidth:"1px",borderStyle:"solid",borderRadius:`${M.radius.base}px`,bgcolor:j?M.color.pageBg:M.color.surface},children:[e.jsxs(H,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[e.jsxs(H,{direction:"row",gap:2,alignItems:"center",justifyContent:"flex-start",children:[e.jsx($,{variant:"h6",fontSize:"16px",children:b?(t==null?void 0:t.account_source_name)??"Messenger owner":d.sender_name}),d.created_at&&e.jsxs(H,{direction:"row",alignItems:"center",spacing:"2px",children:[e.jsx(Ht,{size:"7",fill:"",fillOpacity:"0.1",strokeOpacity:"0.1"})," ",e.jsx($,{variant:"caption",color:"textSecondary",fontSize:"14px",children:Ut(d.created_at)})]})]}),d.ai_learning?e.jsxs(H,{gap:"10px",children:[e.jsx(te,{sentimentLabel:d.sentiment_label,isOld:!0}),e.jsx(te,{sentimentLabel:d.ai_learning.correct_sentiment})]}):e.jsx(te,{sentimentLabel:d.sentiment_label})]}),e.jsx(ee,{py:2,pr:"150px",children:e.jsx($,{color:"textSecondary",fontSize:"14px",children:e.jsx(Ze,{styles:{fontWeight:500,fontSize:"14px",color:M.color.ink,display:"inline",textDecoration:"underline",textUnderlineOffset:"2px"},children:d.message_text})})}),e.jsx(Je,{size:"small",title:"Adjust sentiment",onClick:()=>f(d),sx:{color:M.color.ink},children:e.jsx(Jt,{})})]},d.id)})})};var Le=(s=>(s.COMMENT="Comment",s.MESSAGE="Message",s))(Le||{});const Ye={newSentiment:Xe.NEUTRAL,alreadyCorrectedSentiment:null,reason:""},Ns=({isOpen:s,closeModal:o,sentimentData:t,setSentimentData:p,onSubmit:S,messageType:f=Le.COMMENT})=>{const[_,d]=i.useState(Ye),{newSentiment:b,alreadyCorrectedSentiment:j,reason:W}=_,F=ht(m=>m.breakpoints.down("sm"));i.useEffect(()=>{t&&d({newSentiment:t.sentiment_label,alreadyCorrectedSentiment:t.alreadyCorrectedSentiment,reason:t.reasonWhyCorrected})},[t]);const O=()=>{o(),p(),d(Ye)}
1,c=()=>{t&&S(_)},z=(m,x)=>{d(y=>({...y,[m]:x}))},k=b===(t==null?void 0:t.sentiment_label);return e.jsxs(ft,{fullWidth:!0,open:s,onClose:O,TransitionComponent:_t,children:[e.jsx(xt,{sx:{position:"relative"},children:e.jsx(qt,{children:e.jsx($,{textAlign:"center",fontWeight:"bold",width:"100%",letterSpacing:0,children:"Adjust the sentiment"})})}),e.jsxs(St,{sx:{p:"30px"},children:[e.jsxs(H,{width:"100%",mb:"40px",children:[e.jsx($,{fontWeight:600,mb:"10px",children:`${f} ${t!=null&&t.author?` from ${t==null?void 0:t.author}`:":"}`}),e.jsx($,{mb:"20px",children:t==null?void 0:t.text}),e.jsxs(Ne,{fullWidth:!0,sx:{mb:"20px"},children:[e.jsx(Ve,{label:"Sentiment",name:"sentiment_label",labelId:"select-sentiment-label",value:b,onChange:m=>z("newSentiment",m.target.value),renderValue:m=>{if(!m)return e.jsx("em",{children:"Select a sentiment"});const x=oe[m];return e.jsx(ve,{label:x.label,sx:ze(x.accent,x.bGColor)})},children:Object.entries(oe).map(([m,x])=>e.jsx(Oe,{value:m,children:x.label},m))}),e.jsx(Ke,{id:"select-sentiment-label",children:"Sentiment"})]}),e.jsxs(Ne,{fullWidth:!0,sx:{mb:"20px"},children:[e.jsx(Ve,{label:j?"Corrected Sentiment":"Sentiment wasn't corrected yet",name:"alreadyCorrectedSentiment",labelId:"already_corrected_sentiment-id",value:j||"",disabled:!0,renderValue:m=>{if(!m)return e.jsx("em",{children:"Sentiment wasn't corrected yet"});const x=oe[m];return e.jsx(ve,{label:x.label,sx:ze(x.accent,x.bGColor)})},children:Object.entries(oe).map(([m,x])=>e.jsx(Oe,{value:m,children:x.label},m))}),e.jsx(Ke,{id:"already_corrected_sentiment-id",children:j?"Corrected Sentiment":"Sentiment wasn't corrected yet"})]}),e.jsx(De,{value:W,onChange:m=>z("reason",m.target.value),placeholder:"Reason"})]}),e.jsxs(H,{direction:F?"column":"row",spacing:2,children:[e.jsx(Q,{title:"Close without changes",placement:"top",arrow:!0,children:e.jsx(Me,{fullWidth:!0,variant:"contained",sx:{color:"grey.600",bgcolor:"grey.300","&:hover":{bgcolor:"grey.200"}},onClick:O,children:"Close"})}),e.jsx(Q,{title:k?"Change the sentiment to activate":"",placement:"top",arrow:!0,children:e.jsx($,{component:"span",sx:{display:"block",width:"100%"},children:e.jsx(Me,{fullWidth:!0,variant:"contained",color:"primary",onClick:c,disabled:k,children:"Adjust"})})})]})]})]})},Sn=()=>{const{page:s,pageHeader:o,pageTitle:t,pageSubtitle:p,mainWrapper:S,actionWrapper:f,inputContainer:_,tableWrapper:d,modalBodyWrapper:b,messageWrapper:j,replyWrapper:W,sendDetails:F,dateHeading:O,line:c}=He,[z,k]=i.useState(!1),[m,x]=i.useState({}),[y,E]=i.useState(null),[A,P]=i.useState(null),[u,I]=i.useReducer(fs,le),{page:l,page_size:n,ordering:h}=i.useMemo(()=>u,[u]),T=i.useRef(null),{searchParams:L,setSearchParams:w,isReady:Z}=It({defaults:{page:"1",page_size:ie[0].toString()},actionType:Pe.UPDATE_PAGE_CONFIG_AND_FILTERS,dispatch:I,sanitizeRest:r=>{const a=Rt(r);return!a.first_message_sentiment&&a.message_sentiment&&(a.first_message_sentiment=a.message_sentiment),delete a.message_sentiment,a},parse:r=>({page:Number(r.page)||le.page,page_size:Number(r.page_size)||le.page_size,search:r.search,ordering:r.ordering,contains_phishing:r.contains_phishing,platform:r.platform,first_message_sentiment:r.first_message_sentiment,page_id:r.page_id,instagram_account_id:r.instagram_account_id})}),{register:g,getValues:R,reset:G}=Qe({mode:"onChange",defaultValues:{replyMessage:""}}),{execute:U,data:C,loading:se,error:ne,reload:je}=ge(Ms,{initialLoading:!0,latestOnly:!0,onError(){J("Failed to fetch Messages data")}}),{execute:ye,data:q,loading:ce,reload:Ce}=ge(ue,{onError(){J("Failed to fetch Messages data for this conversation")}}),{execute:X,loading:de,error:st}=ge(Is,{onError(){J("Failed to send new message")}});i.useEffect(()=>{Z&&U(Y({...u}))},[u,Z]),i.useLayoutEffect(()=>{if(q&&q.length>0){const r=document.getElementById("modal-body-wrapper");r&&(r.scrollTop=r.scrollHeight)}},[q]);const nt=r=>{const a=Y({...u,page:1,search:r});w(a)},rt=(r,a)=>{const K=Y({...u,...{page:r,page_size:a}});w(K)},at=r=>{const a=Ot(r),B=Y({...u,ordering:a});w(B)},it=async(r,a)=>{const{REPLY:B,ADJUST_SENTIMENT:K}=fe;switch(r){case B:{await ye(a==null?void 0:a.id,a.platform),T.current=a,k(!0);break}case K:{E(a);let D=m[a.id];if(!D)try{D=await ue(a.id,a.platform),x(V=>({...V,[a.id]:D}))}catch{J("Failed to fetch Messages data for this conversation")}let pe=a==null?void 0:a.fb_page_id;(a==null?void 0:a.platform)===v.INSTAGRAM&&(pe=a==null?void 0:a.ig_account_id);const re=D.find(V=>V.sender_id===pe)||null;if(re){const V=tt(re);P(V)}break}}},ot=async r=>{if(E(r),r&&!m[r.id])try{const a=await ue(r.id,r.platform);x(B=>({...B,[r.id]:a}))}catch{J("Failed to fetch Messages data for this conversation")}},we=async()=>
1{if(T.current){const r=T.current,a={message_text:R("replyMessage"),moderation_reason:"",platform:r.platform};await X(r==null?void 0:r.id,a),Ce(),G()}},lt=async r=>{const a={messages:[{id:(A==null?void 0:A.id.toString())||"",platform:A==null?void 0:A.platform}],correct_sentiment:r.newSentiment,reason:r.reason};try{if(await As(a),y){const B=await ue(y.id,y.platform);x(K=>({...K,[y.id]:B}))}P(null),E(null)}catch{J("Failed to adjust sentiment")}},Be=Pt(u,C==null?void 0:C.results),We=!!(u.search||u.contains_phishing||u.platform||u.first_message_sentiment||u.page_id||u.instagram_account_id);return e.jsxs("div",{className:s,children:[e.jsx(Et,{className:o,titleClassName:t,subtitleClassName:p,subTitle:"Manage all your Meta messages in one place",title:"Messages"}),e.jsxs("main",{className:S,children:[e.jsxs("div",{className:f,children:[e.jsx(Tt,{placeholder:"Search messages",value:u.search??"",onSearch:nt,containerProps:{className:_},disabled:Be}),!Be&&e.jsx(Es,{searchFilters:L,onSubmit:r=>{const a=Y({...u,...r,page:1,page_size:n||ie[0]});w(a)},onReset:()=>{const r=Y({page:1,page_size:ie[0],ordering:u.ordering,search:u.search});w(r)}})]}),se?e.jsx(Mt,{}):e.jsx(At,{emptyText:We?"No messages match your search or filters.":"No messages yet. Connect a page to start receiving messages.",emptyActions:We?e.jsx(Ie,{variant:"Primary",onClick:()=>w(Y({...le})),children:"Clear filters"}):e.jsx(Nt,{to:bt.FB_ACCOUNT,children:"Connect a page"}),data:(C==null?void 0:C.results)||[],columns:vs(it,ot),handleSelectedRow:()=>{},className:d,showErrorContainer:ne,pagination:!0,sortingState:Ft(h),paginationProps:{onPageChange:rt,totalCount:Number(C==null?void 0:C.count)||0,currentPage:Number(l)||0,pageSize:Number(n)||0,pageSizeOptions:ie},enableSorting:!0,onSortingChange:r=>{at(r)},errorContainerProps:{errorText:"Unable to load messages.",onButtonClick:je},showScroll:!1,expandedRowRender:r=>e.jsx(Rs,{conversation:m[r.id],conversationLoading:ce,rowData:r,setSentimentObject:P,setSelectedConversation:E})}),e.jsx(vt,{onClose:()=>{G(),k(!1),T.current=null},keepMounted:!0,open:z,header:e.jsx(N,{variant:"b1-semiBold",children:" Reply "}),footerContent:e.jsx(yt,{placeholder:"Type here ...",error:st,onKeyDown:r=>{r.key==="Enter"&&we()},...g("replyMessage"),disabled:de,endAdornment:de?e.jsx(Ct,{color:"Grey",size:"S"}):e.jsx(Qt,{style:{cursor:"pointer"},onClick:()=>we()})}),children:e.jsx("div",{id:"modal-body-wrapper",className:b,children:ce?e.jsx(e.Fragment,{children:[1,2,3].map(()=>e.jsxs(e.Fragment,{children:[e.jsx(Ae,{variant:"Rectangular",width:"100px",height:"10px"}),e.jsx(Ae,{variant:"Rectangular",width:"450px",height:"50px"})]}))}):e.jsx(e.Fragment,{children:q&&e.jsx(e.Fragment,{children:q.reduce((r,{created_at:a,message_text:B,id:K,sender_id:D,sender_name:pe},re,V)=>{const ke=re>0?V[re-1].created_at:null,ct=!ke||!Yt(new Date(ke),new Date(a));return[...r,ct&&e.jsxs("div",{className:O,children:[e.jsx("span",{className:c}),e.jsx(N,{style:{color:he},variant:"caption2-regular",children:xs(a)?"Today":Ge(a,{day:"2-digit",month:"2-digit",year:"numeric"})}),e.jsx("span",{className:c})]},`date-${K}`),e.jsxs("div",{children:[e.jsxs("div",{className:F,children:[e.jsx(N,{style:{color:jt},variant:"b3-regular",children:pe}),e.jsx(N,{style:{color:he},variant:"caption1-regular",children:Ge(a,{hour:"numeric",minute:"numeric",hour12:!0})})]}),e.jsx("div",{className:V[0].sender_id===D?W:j,children:e.jsx(N,{variant:"b2-regular",className:He.modalDescription,children:B})})]},K)]},[])})})})}),e.jsx(Ns,{isOpen:!!A,closeModal:()=>P(null),sentimentData:A,setSentimentData:()=>P(null),onSubmit:lt,messageType:Le.MESSAGE})]})]})};export{Sn 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.