1import{bK as oe,b as Ue,q as Ve,d as we,R as e,a4 as H,b1 as ke,b2 as Me,T as Y,b3 as Pe,cA as je,de as We,cu as Ye,cB as he,s as Ge,bS as qe,bR as ze,K as ye,M as pe,N as ge,O as y,A as Te,cH as Ke,af as _e,B as te,az as Ie,U as le,E as ae,b7 as Qe,b8 as Xe,gU as Ze,aq as Je,gV as et,gW as tt,gX as at,gY as st,gZ as nt,g_ as rt,a5 as ie,bX as lt,b$ as ot,cl as it,c0 as ct,ai as G,a2 as Oe,g$ as dt,h0 as ut,bf as K,be as mt,d9 as ve,eu as be,p as Ee,h1 as pt,r as gt,bP as re,eA as ft,gR as ht,C as Et,fA as yt,h2 as vt,P as bt,dm as St,z as Ct,aA as Rt,aC as wt}from"./index-CpcUj6vn.js";import{V as kt,O as Mt}from"./index-h9mpbqWH.js";import{N as Pt,a as Se,b as fe}from"./index-CXES7HEQ.js";import{S as Tt}from"./EqualizerRounded-DO_fwo9H.js";import{C as It}from"./CheckBoxRounded-hySPtnWg.js";import{S as Ot}from"./SendRounded-B-vmNTy2.js";import{C as At}from"./ClearRounded-sBrUHwMT.js";const Ae=s=>{const p=ie.utc(s).local();return p.isValid()?p.format("D.M.YYYY HH:mm:ss"):""},xt=({filters:s,setFilters:p,expandedRows:f,supportsReactions:c,onViewReactions:v,rowSelectionEnabled:C,handleSelectAllRecipients:I,selectAllRecipients:O})=>{const x=Ge(qe),E=ze(),R=e.useCallback((r,m)=>p(h=>({...h,[r]:m})),[p]),w=e.useCallback(r=>typeof s?.[r]>"u"||s?.[r]===null?[]:s[r]===""?[]:[s[r]],[s]);return[{name:"id",label:"Id",options:{display:!1,viewColumns:!1,filter:!1}},{name:"",options:{filter:!1,sort:!1,empty:!1,viewColumns:!1,download:!1,display:!0,setCellHeaderProps:()=>({style:{padding:"3px"}}),setCellProps:()=>({style:{display:"none"}}),customBodyRenderLite:()=>null,customHeadLabelRender:()=>C?e.createElement(ye,{checked:!!O,onChange:r=>I(r.target.checked)}):null}},{name:"timestamp",label:"Timestamp",options:{filter:!1,sort:!0,customBodyRender:r=>Ae(r)}},{name:"messageType",label:"Message Type",options:{filter:!0,sort:!0,filterType:"custom",filterList:w("messageType"),customFilterListOptions:{render:r=>`Type: ${r?.[0]}`,update:()=>R("messageType",null)},filterOptions:{logic:()=>{},display:(r,m,h,k)=>{const o=r[h]?.[0]??"";return e.createElement(e.Fragment,null,e.createElement(pe,{id:"typeLabel"},"Message Type"),e.createElement(ge,{labelId:"typeLabel",value:o,id:"messageType",name:"messageType",onChange:i=>m(i.target.value!==""?[i.target.value]:[],h,k)},e.createElement(y,{value:""},e.createElement("em",null,"All")),e.createElement(y,{value:"SMS"},"SMS"),e.createElement(y,{value:"MMS"},"MMS"),e.createElement(y,{value:"RCS"},"RCS"),!!x&&E&&e.createElement(y,{value:"Email"},"Email"),e.createElement(y,{value:"Instagram"},"Instagram"),e.createElement(y,{value:"Messenger"},"Messenger"),e.createElement(y,{value:"Webhook"},"Webhook"),e.createElement(y,{value:"WeChat"},"WeChat"),e.createElement(y,{value:"Whatsapp"},"Whatsapp")))}}}},{name:"address",label:"Recipient",options:{filter:!0,sort:!1,filterType:"custom",filterList:w("address"),customFilterListOptions:{render:r=>`Recipient: ${r?.[0]}`,update:()=>R("address",null)},filterOptions:{logic:()=>{},display:(r,m,h,k)=>{const o=r[h]?.[0]??null;return e.createElement(Te,{id:"search-recipient",label:"Recipient",name:"recipient",defaultValue:o,onChange:i=>m(i.target.value!==""?[i.target.value]:[],h,k)})}}}},{name:"partCount",label:"Amount of messages",options:{filter:!1,sort:!1}},{name:"status",label:"Delivery status",options:{display:!0,viewColumns:!1,filter:!0,sort:!1,filterType:"custom",filterList:w("status"),customFilterListOptions:{render:r=>r[0].length>3?`Delivery Status: ${r[0].length} selected`:`Delivery Status: ${r[0].join(" Or ")}`,update:()=>R("status",null)},filterOptions:{logic:()=>{},display:(r,m,h,k)=>{const o=r[h]?.[0]??[],i=[{label:"Acknowledged",value:"Acknowledged"},{label:"Created",value:"Created"},{label:"Delivered",value:"Delivered"},{label:"Delivery Failed",value:"DeliveryFailed"},{label:"Null Status",value:"NullStatus"},{label:"Queued",value:"Queued"},{label:"Resend",value:"Resend"},{label:"Scheduled",value:"Scheduled"},{label:"Sent",value:"Sent"},{label:"Send Failed",value:"SendFailed"},{label:"Send Cancelled",value:"SendCancelled"}];return e.createElement(e.Fragment,null,e.createElement(pe,{id:"deliveryStatuslabel"},"Delivery Status"),e.createElement(ge,{labelId:"deliveryStatuslabel",id:"deliveryStatus",name:"deliveryStatus",multiple:!0,value:o,onChange:S=>m(S.target.value.length>
10?[S.target.value]:[],h,k),input:e.createElement(Ke,null),renderValue:S=>S.length>3?`${S.length} selected`:S.join(", ")},i.map(({label:S,value:L})=>e.createElement(y,{key:L,value:L},e.createElement(ye,{checked:o.indexOf(L)>-1}),e.createElement(_e,{primary:S})))))}}}},{name:"reason",label:"Delivery reason",options:{display:!0,viewColumns:!1,sort:!1,filter:!0,filterType:"custom",filterList:w("reason"),customFilterListOptions:{render:r=>`Delivery Reason: ${r}`,update:()=>R("reason",null)},filterOptions:{logic:()=>{},display:(r,m,h,k)=>{const o=r[h]?.[0]??"";return e.createElement(e.Fragment,null,e.createElement(pe,{id:"deliveryReasonlabel"},"Delivery Reason"),e.createElement(ge,{labelId:"deliveryReasonlabel",value:o,id:"deliveryReason",name:"deliveryReason",onChange:i=>m(i.target.value!==""?[i.target.value]:[],h,k)},e.createElement(y,{value:""},e.createElement("em",null,"All")),e.createElement(y,{value:"BillingError"},"Billing Error"),e.createElement(y,{value:"Expired"},"Expired"),e.createElement(y,{value:"LimitExceeded"},"Limit Exceeded"),e.createElement(y,{value:"NetworkError"},"Network Error"),e.createElement(y,{value:"NoError"},"No Error"),e.createElement(y,{value:"PhoneError"},"Phone Error"),e.createElement(y,{value:"SyntaxError"},"Syntax Error"),e.createElement(y,{value:"SystemError"},"System Error"),e.createElement(y,{value:"SubscriberError"},"Subscriber Error"),e.createElement(y,{value:"NullReason"},"Unknown reason"),e.createElement(y,{value:"Unknown"},"Unknown")))}}}},{name:"recipientReactions",label:"Events",options:{filter:!1,sort:!1,display:c,viewColumns:c,customBodyRender:(r,{rowIndex:m})=>!Array.isArray(r)||r.length===0?"No Events":Array.isArray(f)&&f.indexOf(m)>-1?e.createElement(te,{variant:"outlined",size:"small",onClick:()=>v(m)},"Hide Events"):e.createElement(te,{variant:"outlined",size:"small",onClick:()=>v(m)},r.length,r.length>1?" Events":" Event")}}]},Bt={elevation:0,print:!1,filter:!1,search:!0,download:!0,viewColumns:!1,fixedHeader:!0,confirmFilters:!1,rowsPerPage:10,rowsPerPageOptions:[10,50,100],serverSide:!1,selectableRowsHeader:!1,selectableRows:"none",downloadOptions:{filename:"failed-recipients.csv",separator:";",filterOptions:{useDisplayedColumnsOnly:!0,useDisplayedRowsOnly:!1}},responsive:"standard",textLabels:{body:{noMatch:"No failed recipients"}}},$t=oe(s=>({header:{width:"100%",padding:s.spacing(2)},chip:{marginRight:s.spacing(1),border:"1px solid #e2e6e9"},button:{marginRight:s.spacing(2)},tableHeader:{marginTop:s.spacing(2)},contentContainer:{display:"flex"},tableContainer:{flex:1,display:"flex",flexDirection:"column"},tableContainerItem:{flex:1},previewContainer:{display:"flex",minHeight:640,minWidth:400}})),Dt=[{name:"parsedAddress",label:"Address",options:{filter:!1,sort:!1}},{name:"errorMessage",label:"Errormessage",options:{filter:!1,sort:!1}}],Lt={reason:"",status:"",address:""},Ft=s=>({...s,overrides:{...s.overrides,MUIDataTableFilter:{resetLink:{display:"none"}},MUIDataTableFilterList:{chip:{marginBottom:"10px",border:"1px solid #e2e6e9"}},MUIDataTable:{responsiveBase:{maxHeight:"50vh !important",display:"block"}},MUIDataTableSelectCell:{root:{width:0,padding:0},fixedHeader:{display:"none"}}}}),xe=({open:s=!1,onClose:p=()=>{},messageBatch:f})=>{const c=$t(),v=Ue(),C=Ve(),{customerId:I}=we(),[O,x]=e.useState(Lt),[E,R]=e.useState({page:0,rowsPerPage:10,count:0}),[w,r]=e.useState({name:"timestamp",direction:"asc"}),[m,h]=e.useState([]),[k,o]=e.useState(!1),[i,S]=e.useState(null),[L,M]=e.useState(null),[F,U]=e.useState(!0),[P,q]=e.useState(!1),[T,_]=e.useState(!1),[B,V]=e.useState({}),[se,ce]=e.useState([]),[ne,A]=e.useState(!1);e.useEffect(()=>{h([]),M(null),U(!0),S(null),R(t=>({...t,page:0,count:0}))},[f,s]);const Q=e.useMemo(()=>["Whatsapp","RCS"].includes(i?.protocol),[i]),X=e.useMemo(()=>Array.isArray(i?.failures)?i.failures.reduce((t,a)=>{const l=a?.errorMessage??"Unknown error";return Array.isArray(a?.recipientBatch)?[...t,...a.recipientBatch.reduce((d,n)=>[...d,{errorMessage:l,address:n?.address,parsedAddress:n?.parsedAddress}],[])]:t},[]):[],[i]),Z=e.useMemo(()=>Object.keys(O).reduce((t,a)=>{const l=O[a];if(!l)return t;let d="";switch(a){case"reason":{d=`Reason eq '${l}'`;break}case"status":{d=l?.map?.(n=>`Status eq '${n}'`).join(" or ");break}case"address":{d=`Contains(Address, '${l}')`;break}case"messageType":{d=`Message/Type eq '${l}'`;break}default:return t}return t?.concat?.(` and ${d}`)??d}
1,null),[O]),{mutate:J}=H(t=>({method:"GET",endpoint:`/messagepersistence/messages/smartsend/${t}`})),{mutate:u,abort:b}=H(({$filter:t,$top:a,$skip:l,messageIds:d,sortOrder:n})=>({method:"POST",endpoint:"/messagepersistence/messagerecipients",body:[...d],params:{...t?{$filter:t}:{},$top:a,$count:!0,$skip:l,$orderBy:`${n.name} ${n.direction}`,$expand:"Message($select=Type)"}}));e.useEffect(()=>{s||b()},[s,b]);const{mutate:N}=H(t=>({method:"GET",endpoint:"/messagepersistence/messagesodata",params:{$filter:`Id eq ${t}`,$expand:"Recipients, Attachments",$top:1}})),{mutate:W}=H(t=>({method:"POST",endpoint:"/messagepersistence/messages/nfm",body:t}));e.useEffect(()=>{const t=async()=>{const{payload:a,error:l}=await J(f?.smartSendId);if(l||!Array.isArray(a?.messageIds)){o(!1);return}S(a)};f&&(o(!0),t())},[f,J]),e.useEffect(()=>{const t=async()=>{const{payload:a,error:l}=await N(i.messageIds[0]);!l&&a?.value?.[0]&&(M(a.value[0]),U(!1))};i?.messageIds?.[0]&&(U(!0),t())},[i,N]),e.useEffect(()=>{const t=async()=>{const{payload:a,error:l}=await u({$filter:Z,$top:E.rowsPerPage,$skip:E.page*E.rowsPerPage,sortOrder:w,messageIds:i.messageIds});if(l||!Array.isArray(a?.value))h([]),R(d=>({...d,count:0}));else{let d=[];if(["Whatsapp","RCS"].includes(i?.protocol)){const{payload:n}=await W(i.messageIds);d=Array.isArray(n)?n:[]}h(a.value.map(n=>{const g=d.filter(z=>z?.messageRecipientId===n?.id);return{...n,messageType:n?.message?.type,recipientReactions:g,hasReactions:g.length>0}})),R(n=>({...n,count:a?.["@odata.count"]??0}))}o(!1)};i&&(o(!0),h([]),R(a=>({...a,count:0})),t())},[i,Z,E.rowsPerPage,E.page,w,u,W]);const $=e.useMemo(()=>m.reduce((t,a,l)=>({...t,[a?.id]:l}),{}),[m]),j=e.useMemo(()=>{const t=E.count,a=Object.keys($).length,{currentPageOverriddenIds:l,otherPageOverriddenIds:d}=Object.keys(B).reduce((n,g)=>typeof $?.[g]<"u"?{currentPageOverriddenIds:{...n.currentPageOverriddenIds,[g]:B[g]},otherPageOverriddenIds:n.otherPageOverriddenIds}:{currentPageOverriddenIds:n.currentPageOverriddenIds,otherPageOverriddenIds:{...n.otherPageOverriddenIds,[g]:B[g]}},{currentPageOverriddenIds:{},otherPageOverriddenIds:{}});if(T){const n=Object.keys(d).filter(D=>d[D]===!1).length,g=new Array(Math.max(0,t-n-a)).fill(a+1);return[...Object.keys($).filter(D=>typeof l?.[D]>"u"||l[D]!==!1).map(D=>$[D]),...g]}return[...Object.keys($).filter(n=>l?.[n]===!0).map(n=>$[n]),...new Array(Object.keys(d).length).fill(a+1)]},[B,$,E,T]),de=e.useMemo(()=>!(!P||P&&!T&&Object.keys(B).length>0||P&&T&&E.count>Object.keys(B).length),[P,j,T,E]),ee=t=>{ce(a=>a.indexOf(t)>-1?[]:[t])},$e=e.useCallback(()=>{_(t=>!t),V({})},[]),De=()=>{q(!P),_(!1),V({})},Le=async()=>{let t=!0,a=!1,l=0,d=0;const n=[];A(!0);do{const{payload:g,error:z}=await u({$filter:Z,$top:1e4,$skip:l,sortOrder:w,messageIds:i.messageIds});if(!Array.isArray(g?.value)||z){A(!1),a=!0,t=!1;break}d+=g.value.length,P?T?n.push(...g.value.filter(me=>B?.[me?.id]!==!1)):n.push(...g.value.filter(me=>B?.[me?.id]===!0)):n.push(...g.value);const D=g?.["@odata.count"]??0;d<D?(t=!0,l+=1e4):t=!1}while(t);a||(v(lt()),v(ot({senderSource:i?.sender??null,messageType:i?.protocol??"SMS"})),v(it({groupSource:"reSendBatch",reSendBatchRecipients:n,reSendBatch:!0})),v(ct({content:i?.content??""})),C.push(`/${I}/sendmessages/sender`)),A(!1)},ue=xt({filters:O,setFilters:x,expandedRows:se,supportsReactions:Q,onViewReactions:ee,rowSelectionEnabled:P,handleSelectAllRecipients:$e,selectAllRecipients:T}),Fe=t=>a=>{a.currentTarget.blur();const l=t(),d=ue.reduce((n,g,z)=>{const D=l?.[z]?.[0];return!D||D===""?{...n,[g.name]:null}:{...n,[g.name]:D}},{});x(d)},Ne=t=>a=>{a.currentTarget.blur();const l=ue.reduce((d,n)=>({...d,[n.name]:null}),{});x(l),t()};if(!f)return null;const He={elevation:0,print:!1,filter:!0,search:!1,download:!1,viewColumns:!0,fixedHeader:!0,confirmFilters:!0,sortOrder:w,rowsPerPage:E.rowsPerPage,rowsPerPageOptions:[10,50,100],serverSide:!0,count:E.count,page:E.page,selectableRowsHeader:!1,selectToolbarPlacement:"above",responsive:"standard",selectableRows:P?"multiple":"none",rowsSelected:j,expandableRows:!P,expandableRowsHeader:!1,expandableRowsOnClick:!1,customExpandButton:null,customToolbarSelect:()=>{},rowsExpanded:se,renderExpandableRow:(t,{dataIndex:a})=>{const l=t.length+1,d=Array.isArray(m?.[a]?.recipientReactions)?m[a].recipientReactions:[];return e.createElement(Qe,null,e.createElement(Xe,{colSpan:l},e.createElement("div",null,e.createElement(Ze,{align:"alternate"},d.sort(Je("timestamp")).map(n=>e.createElement(et,{key:n?.action},e.createElement(tt,null,e.createElement(Y,{color:"textSecondary"},Ae(n?.timestamp))),e.createElement(at,null,e.createElement(st,null),e.createElement(nt,null)),e.createElement(rt,null,e.createElement(Y,null,n?.action))))))))},downloadOptions:{filename:"recipients.csv",separator:";",filterOptions:{useDisplayedColumnsOnly:!0,useDisplayedRowsOnly:!0}},customFilterDialogFooter:(t,a)=>e.createElement("div",{style:{marginTop:"40px"}},e.createElement(te,{variant:"contained",className:c.button,color:"primary",onClick:Fe(a)},"Apply Filters"),e.createElement(te,{variant:"contained",className:c.button,color:"primary",onClick:Ne(a
1)},"Reset")),customToolbar:()=>e.createElement(e.Fragment,null,e.createElement(le,{title:P?"Disable recipient selection":"Enable recipient selection"},e.createElement(ae,{className:c.iconButton,onClick:De},e.createElement(It,null))),e.createElement(le,{title:"Re-Send"},e.createElement("span",null,e.createElement(ae,{disabled:ne||de,onClick:Le},e.createElement(Ot,null))))),onTableChange:(t,a)=>{switch(t){case"changePage":R({...E,page:a.page});break;case"changeRowsPerPage":R({...E,page:0,rowsPerPage:a.rowsPerPage});break}},onFilterChange:(t,a,l)=>{l==="custom"&&R({...E,page:0})},onColumnSortChange:(t,a)=>{r({name:t,direction:a})},onRowSelectionChange:t=>{const a=t.reduce((l,{dataIndex:d})=>{const n=m[d]?.id,g={...l};return typeof g[n]<"u"?(delete g[n],g):{...g,[n]:!T}},B);V(a)},textLabels:{body:{noMatch:k?e.createElement(Ie,null):"No message batches found"}}};return e.createElement(ke,{maxWidth:"lg",fullWidth:!0,open:s,onClose:p,keepMounted:!1},e.createElement(Me,{disableTypography:!0},e.createElement(Y,{variant:"h4"},"Recipients")),e.createElement(Pe,null,e.createElement(je,{theme:Ft},e.createElement(We,{loading:ne},e.createElement("div",{className:c.contentContainer},e.createElement("div",{className:c.previewContainer},e.createElement(Ye,{loading:F,messageType:L?.type,messageEvents:[L]})),e.createElement("div",{className:c.tableContainer},e.createElement("div",{className:c.tableContainerItem},e.createElement(he,{data:m,columns:ue,options:He,components:{ExpandButton:()=>null}})),!k&&X.length>0&&e.createElement("div",{className:c.tableContainerItem},e.createElement(Y,{className:c.tableHeader,variant:"h3"},"Failures"),e.createElement(he,{data:X,columns:Dt,options:Bt}))))))))};xe.propTypes={open:G.bool,onClose:G.func,messageBatch:G.object};const Nt=oe(s=>({chipContainer:{textAlign:"center",width:"100%",flexWrap:"wrap",display:"flex",flex:0,justifyContent:"center"},chartsContainer:{display:"flex"},chartAndStatsContainer:({supportsReactions:p})=>({width:p?"50%":"100%",textAlign:"center",paddingTop:s.spacing(1)}),chartContainer:{textAlign:"center",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",flex:1,overflow:"hidden",padding:s.spacing(3,2,2,2)},statsContainer:{textAlign:"center",display:"flex",flex:0,justifyContent:"center"},chip:{marginRight:s.spacing(1),marginBottom:s.spacing(1)}})),Ht=s=>{const p=ie.utc(s).local();return p.isValid()?p.format("D.M.YYYY HH:mm"):""},Be=({open:s=!1,onClose:p=()=>{},smartSendId:f,totalAmountOfMessageParts:c})=>{const{error:v}=Oe(),[C,I]=e.useState({}),[O,x]=e.useState({}),[E,R]=e.useState([]),[w,r]=e.useState(!1),m=dt(O),h=ut(E);e.useEffect(()=>{x({})},[f]);const k=e.useMemo(()=>["Whatsapp","RCS"].includes(C?.protocol),[C]),o=Nt({supportsReactions:k}),{mutate:i}=H(M=>({method:"GET",endpoint:`/messagepersistence/messages/smartsend/${M}`})),{mutate:S}=H(({messageIds:M})=>({method:"POST",endpoint:"/messagepersistence/messagebatchstatistics",body:[...M]})),{mutate:L}=H(M=>({method:"POST",endpoint:"/messagepersistence/messages/nfm",body:M}));return e.useEffect(()=>{const M=async()=>{const{payload:F,error:U}=await i(f);if(U||!Array.isArray(F?.messageIds)){r(!1),v("Sorry, could not fetch message batch statistics");return}I(F??{});const{payload:P,error:q}=await S({messageIds:F.messageIds});if(q)x({}),v("Sorry, could not fetch message batch statistics");else if(x(P??{}),["Whatsapp","RCS"].includes(F?.protocol)){const{payload:T}=await L(F.messageIds);R(Array.isArray(T)?T:[])}r(!1)};f&&(r(!0),I({}),x({}),M())},[f,S,i,L]),f===null?null:e.createElement(ke,{maxWidth:"md",fullWidth:!0,open:s,onClose:p,keepMounted:!1},e.createElement(Me,{disableTypography:!0},e.createElement(Y,{variant:"h4"},"Message recipient statistics")),e.createElement(Pe,null,w&&e.createElement("div",{style:{width:"100%",marginBottom:"8px"}},e.createElement(Ie,null)),e.createElement("div",{className:o.chipContainer},C?.name&&e.createElement(K,{className:o.chip,label:`Batch name: ${C.name}`}),e.createElement(K,{className:o.chip,label:`Batch created: ${Ht(C.created)}`}),e.createElement(K,{className:o.chip,label:`Average delivery time: ${O?.averages?.averageSendTime?.toFixed(1)??""}ms`}),e.createElement(K,{className:o.chip,label:`Average length: ${O?.averages?.averageLength?.toFixed(1)??""} message parts`}),e.createElement(K,{className:o.chip,label:`Total amount of recipients: ${O?.deliveryStatusCounts?.all??""}`}),e.createElement(K,{className:o.chip,label:`Total amount of message parts: ${c??""}`})),e.createElement(mt,null),e.createElement("div",{className:o.chartsContainer},e.createElement("div",{className:o.chartAndStatsContainer},e.createElement(Y,{variant:"h3"},"Delivery Statuses"),e.createElement("div",{className:o.chartContainer},e.createElement(ve,{data:m})),e.createElement("div",{className:o.statsContainer},e.createElement(be,{data:m}))),k&&e.createElement("div",{className:o.chartAndStatsContainer},e.createElement(Y,{variant:"h3"},"Reactions"),e.createElement("div",{className:o.chartContainer},e.createElement(ve,{data:h}
1)),e.createElement("div",{className:o.statsContainer},e.createElement(be,{data:h}))))))};Be.propTypes={open:G.bool,onClose:G.func,smartSendId:G.string,totalAmountOfMessageParts:G.number};const Ce=s=>{const p=ie.utc(s).local();return s&&p.isValid()?p.format("D.M.YYYY HH:mm"):""},Ut=oe(s=>({button:{marginRight:s.spacing(2)},searchTextfield:{minWidth:400}})),Vt=(s=()=>{})=>(p,{rowIndex:f,tableData:c})=>{const v=c?.[f];return v?.protocol==="RCS"?e.createElement(yt,{onClick:C=>{C.stopPropagation(),s(v)}},"View Message"):p},jt=({setSelectedSmartSendId:s,rcsAgentNamesByAddress:p,onViewRcsMessageClick:f})=>[{name:"name",label:"Name",options:{filter:!1,sort:!1,customBodyRender:c=>e.createElement("b",null,c)}},{name:"recipientCount",label:"Recipients",options:{filter:!1,sort:!1}},{name:"sender",label:"Sender",options:{filter:!1,sort:!1,customBodyRender:c=>p?.[c]??c}},{name:"protocol",label:"Message Type",options:{filter:!1,sort:!1}},{name:"created",label:"Created",options:{filter:!1,sort:!1,customBodyRender:c=>Ce(c)}},{name:"lastUpdated",label:"Last Updated",options:{filter:!1,sort:!1,customBodyRender:c=>Ce(c)}},{name:"createdBy",label:"Created By",options:{filter:!1,sort:!1}},{name:"content",label:"Content",options:{filter:!1,sort:!1,customBodyRender:Vt(f)}},{name:"messagePartCount",label:"Message parts",options:{filter:!1,sort:!1}},{name:"smartSendId",label:"Statistics",options:{sort:!1,filter:!1,customBodyRender:c=>e.createElement(ae,{"aria-label":"statistics",onClick:v=>{v.stopPropagation(),s(c)}},e.createElement(le,{title:"View statistics"},e.createElement(Tt,null)))}}],Re=100,Wt=()=>{const s=Ut(),[p,f]=e.useState(!1),[c,v]=e.useState(!1),[C,I]=e.useState(null),[O,x]=e.useState({name:"created",direction:"desc"}),[E,R]=e.useState({}),[w,r]=e.useState(null),[m,h]=e.useState(null),[k,o]=e.useState(!1),[i,S]=e.useState(null),[L,M]=e.useState(!1),{mutate:F,loading:U}=H(({to:u,name:b})=>({method:"GET",endpoint:"/messagepersistence/messages/batches",params:{...u?{to:u}:{},...b?{name:encodeURI(b)}:{},take:Re}})),{mutate:P}=H(u=>({method:"GET",endpoint:`/messagepersistence/messages/smartsend/${u}`})),{mutate:q}=H(u=>({method:"GET",endpoint:"/messagepersistence/messagesodata",params:{$filter:`Id eq ${u}`,$expand:"Recipients, Attachments",$top:1}})),{customerUsers:T}=Ee(u=>u.customer),[_,B]=e.useState(null),{error:V}=Oe(),se=e.useCallback(async u=>{M(!0);const b=u?.smartSendId;if(!b){V("Unknown error when fetching the RCS message preview."),M(!0);return}o(!0);const{payload:N}=await P(b),W=N?.messageIds?.[0];if(!W){V("Unknown error when fetching the RCS message preview."),o(!1);return}const{payload:$}=await q(W),j=$?.value?.[0];if(j){S(j),M(!1);return}V("Unknown error when fetching the RCS message preview."),o(!1)},[q,S,V]),ce=pt(),ne=jt({setSelectedSmartSendId:r,rcsAgentNamesByAddress:ce,onViewRcsMessageClick:se}),A=e.useMemo(()=>Object.keys(E).map(u=>E[u]),[E]),Q=e.useCallback(()=>{R({}),I(null),v(!0),f(!0)},[]);e.useEffect(()=>{Q()},[m,Q]),e.useEffect(()=>{p&&((async()=>{const{payload:b,error:N}=await F({to:C,name:m});if(!N&&Array.isArray(b))if(b.length===0)v(!1);else{b.length<Re&&v(!1),R($=>{const j=b.reduce((de,ee)=>({...de,[ee?.rowKey]:{...ee,createdBy:T?.[ee?.userId]?.profile?.displayName??""}}),$);return Object.keys($).length===Object.keys(j).length&&v(!1),j});const W=ie(b[b.length-1]?.created).add(1,"millisecond").format("x");I(W)}})(),f(!1))},[p,C,T,F,m]);const X=u=>{h(u)},Z={elevation:0,print:!1,selectableRowsHeader:!1,selectableRows:"none",responsive:"standard",filter:!1,search:!0,searchAlwaysOpen:!0,searchText:m,download:!1,viewColumns:!0,fixedHeader:!0,count:A.length,rowsPerPage:A.length,confirmFilters:!0,serverSide:!0,sortOrder:O,customSearchRender:(u,b)=>e.createElement("div",null,e.createElement(Te,{className:s.searchTextfield,variant:"outlined",size:"small",value:u,onChange:N=>{b(N.target.value)},onKeyDown:N=>{N.key==="Enter"&&X(u)},placeholder:"Search using Name. Press 'Enter' to submit.",InputProps:{endAdornment:u&&u!==""?e.createElement(Et,{position:"end"},e.createElement(ae,{size:"small",onClick:()=>X("")},e.createElement(At,null))):null}})),onColumnSortChange:(u,b)=>{x({name:u,direction:b})},customFooter:()=>e.createElement("tfoot",null),customToolbar:()=>e.createElement(le,{title:"Refresh"},e.createElement(ae,{style:{order:-1},onClick:Q},e.createElement(ht,null))),onRowClick:(u,{dataIndex:b})=>{B(A?.[b])}};let J="none";return A.length>1&&(J="block"),e.createElement(e.Fragment,null,e.createElement(gt.Suspense,{fallback:e.createElement(re,null)},A.length===0&&U?e.createElement(re,null):e.createElement(ft,{dataLength:A.length,hasMore:c,loader:e.createElement(e.Fragment,null,U&&e.createElement(re,null),e.createElement("div",{style:{width:"100%",textAlign:"center",backgroundColor:"#fff",padding:"20px 0"}},e.createElement(te,{onClick:()=>f(!0),color:"primary",variant:"contained"},"Load more"))),endMessage:e.createElement("h3",{style:{textAlign:"center",backgroundColor:"#fff",padding:"20px 0",display:`${J}`}},"Yay! You have seen all ",A.length," message batches")},e.createElement(he,{data:A,columns:ne,options:Z}))),e.createElement(xe,{open:!!_,onClose:()=>B(null),messageBatch:_}),e.createElement(Be,{open:!!w,onClose:()=>r(null),smartSendId:w,totalAmountOfMessageParts:A?.find(u=>u.smartSendId===w)?.messagePartCount??0}),e.createElement(kt,{open:k,loading:L,setMessageEvent:()=>{o(!1),S(null)},messageEvent:i}))},Yt=oe(()=>({appBar:{backgroundColor:"#fff"}})),Zt=()=>{const{customerId:s}=we(),p=Yt(),f=vt(),{usersLoading:c}=Ee(I=>I.customer),{customerInputSourcesLoading:v}=Ee(I=>I.twowaymessaging),C=c||v;return e.createElement(bt,{title:"Messages"},e.createElement(St,{position:"static",color:"default",elevation:0,
1className:p.appBar,variant:"outlined"},e.createElement(Ct,{path:"/:customerId/messagelog/:tab",exact:!0},e.createElement(Pt,null,e.createElement(Se,{label:"All",value:`/${s}/messagelog/all`}),e.createElement(Se,{label:"Message Batches",value:`/${s}/messagelog/batches`})))),C&&e.createElement(fe,{path:"*"},e.createElement(re,null)),!C&&e.createElement(Rt,null,e.createElement(fe,{path:"/:customerId/messagelog/all"},e.createElement(Mt,{defaultFrom:{amount:-1,unit:"day"},persistedFiltersTableId:"messagelog/all"})),e.createElement(fe,{path:"/:customerId/messagelog/batches"},e.createElement(Wt,null)),e.createElement(wt,{replace:!0,from:`/${s}/messagelog`,to:`/${s}/messagelog/${f}`})))};export{Zt 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.