PageSourceSearch

https://app.markopolo.ai/assets/index-CrbkYGQJ.js

js markopolo.ai collected 2026-09-24 18:40:09 UTC 54,104 bytes, 2 lines download raw bytes

1import{j as e,r as g,l as ca,e as oa,u as da}from"./vendor-react-BN8-jPqf.js";import{G as v,u as Te,i as ma,v as xa,S as o,T as r,B as qe,h as ua,C as E,n as He,o as Z,l as k,p as W,q as Q,m as w,c as L,E as ue,D as F,I as $,t as U,J as Oe,y as pa,k as ga}from"./index-V1zIfw7Q.js";import{C as ha}from"./index-Ccaa6g5H.js";import{d as S,u as fa}from"./vendor-utils-CS7fQHMJ.js";import{K as V,S as ja}from"./Knowledgebase-RXbKWwO-.js";import{g as va,a as wa,i as ba}from"./demo-preset-campaigns-CiBI-TpZ.js";import{d as ya,e as _a,f as Na}from"./campaign.api-fEC-EUhu.js";import{d as Ca,e as Da,g as Sa,h as Aa,i as La}from"./campaignV2.api-CTv4UZ8A.js";import{c as xe}from"./date.utils-Dh6qda7I.js";import{G as K,F as pe}from"./GatewayLogo-CP5lIT2A.js";import{u as M}from"./vendor-i18n-CnMO7MKm.js";import{T as X}from"./TableLoader-CrNv5CjT.js";import{O as Ge}from"./OptionTabs-CtnQiLYt.js";import{S as B}from"./Skeleton-bmPPgpIK.js";import{P as za,L as Ue,X as Ma}from"./vendor-icons-DrvWjlOJ.js";import{B as T}from"./Badge-DNb8vKs8.js";import{C as ka}from"./index-BW7zOLMJ.js";import{E as Ta}from"./EmailHtmlPreview-CnuRIf17.js";import{D as Ea,a as Pa,b as Ra}from"./Drawer-3NZD1eC-.js";import{F as Ia}from"./FiDownload02-DO46m3VD.js";import{P as Fa}from"./index-Bm0f8qC_.js";import{P as Ya}from"./Progress-ChPS5RHE.js";import{U as Ee}from"./UnstyledButton-lE66j0zk.js";import{u as Ba}from"./index-CI2BjeV9.js";import{M as Va}from"./MultiSelect-BpQlC5t9.js";import{D as qa}from"./DatePickerInput-CX7iZlVm.js";import{B as Ha}from"./Breadcrumbs-jkYPpxPy.js";import"./vendor-redux-DiHVN3TZ.js";import"./vendor-motion-2T9_tTTe.js";import"./campaign-date-range.utils-CQfSdAz9.js";import"./index-DsdKdrfu.js";import"./index-DKOIsVX2.js";import"./Checkbox-hm7ZboUt.js";import"./Calendar-pI4LlAdF.js";const Oa=({color:i="#12B76A",size:s=10,strokeWidth:a=1.5,onClick:t,style:n})=>e.jsx("svg",{style:{...n},onClick:d=>t&&t(d),width:s,height:s,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{stroke:i,strokeWidth:a,d:"M19 9H1M14 1V5M6 1V5M5.8 21H14.2C15.8802 21 16.7202 21 17.362 20.673C17.9265 20.3854 18.3854 19.9265 18.673 19.362C19 18.7202 19 17.8802 19 16.2V7.8C19 6.11984 19 5.27976 18.673 4.63803C18.3854 4.07354 17.9265 3.6146 17.362 3.32698C16.7202 3 15.8802 3 14.2 3H5.8C4.11984 3 3.27976 3 2.63803 3.32698C2.07354 3.6146 1.6146 4.07354 1.32698 4.63803C1 5.27976 1 6.11984 1 7.8V16.2C1 17.8802 1 18.7202 1.32698 19.362C1.6146 19.9265 2.07354 20.3854 2.63803 20.673C3.27976 21 4.11984 21 5.8 21Z"})}),Ga=({color:i="currentColor",size:s=10,onClick:a,style:t})=>e.jsxs("svg",{style:{...t},onClick:n=>a&&a(n),width:s,height:s,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M5 0L5.65075 2.603C5.77773 3.11092 5.84122 3.36489 5.97346 3.57154C6.09042 3.75434 6.24566 3.90958 6.42846 4.02654C6.63511 4.15878 6.88908 4.22227 7.39701 4.34925L10 5L7.397 5.65075C6.88908 5.77773 6.63511 5.84122 6.42846 5.97346C6.24566 6.09042 6.09042 6.24566 5.97346 6.42846C5.84122 6.63511 5.77773 6.88908 5.65075 7.39701L5 10L4.34925 7.397C4.22227 6.88908 4.15878 6.63511 4.02654 6.42846C3.90958 6.24566 3.75434 6.09042 3.57154 5.97346C3.36489 5.84122 3.11092 5.77773 2.60299 5.65075L0 5L2.603 4.34925C3.11092 4.22227 3.36489 4.15878 3.57154 4.02654C3.75434 3.90958 3.90958 3.75434 4.02654 3.57154C4.15878 3.36489 4.22227 3.11092 4.34925 2.60299L5 0Z",fill:i}),e.jsx("path",{d:"M5 0L5.65075 2.603C5.77773 3.11092 5.84122 3.36489 5.97346 3.57154C6.09042 3.75434 6.24566 3.90958 6.42846 4.02654C6.63511 4.15878 6.88908 4.22227 7.39701 4.34925L10 5L7.397 5.65075C6.88908 5.77773 6.63511 5.84122 6.42846 5.97346C6.24566 6.09042 6.09042 6.24566 5.97346 6.42846C5.84122 6.63511 5.77773 6.88908 5.65075 7.39701L5 10L4.34925 7.397C4.22227 6.88908 4.15878 6.63511 4.02654 6.42846C3.90958 6.24566 3.75434 6.09042 3.57154 5.97346C3.36489 5.84122 3.11092 5.77773 2.60299 5.65075L0 5L2.603 4.34925C3.11092 4.22227 3.36489 4.15878 3.57154 4.02654C3.75434 3.90958 3.90958 3.75434 4.02654 3.57154C4.15878 3.36489 4.22227 3.11092 4.34925 2.60299L5 0Z",fill:i})]}),Ua=({color:i="currentColor",size:s=16,onClick:a,style:t})=>e.jsx("svg",{style:{...t},width:s,height:s,onClick:n=>a&&a(n),fill:"none",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M1.33341 10.6666H3.92608L7.45541 13.5546C7.50425 13.5947 7.56345 13.62 7.62613 13.6277C7.6888 13.6354 7.75238 13.6251 7.80944 13.5981C7.86651 13.5711 7.91473 13.5284 7.94848 13.475C7.98223 13.4216 8.00012 13.3598 8.00008 13.2966V2.70331C8.00012 2.64016 7.98223 2.5783 7.94848 2.52493C7.91473 2.47156 7.86651 2.42887 7.80944 2.40184C7.75238 2.37481 7.6888 2.36454 7.62613 2.37224C7.56345 2.37993 7.50425 2.40527 7.45541 2.44531L3.92675 5.33331H1.33341C1.1566 5.33331 0.987034 5.40355 0.86201 5.52857C0.736986 5.65359 0.666748 5.82316 0.666748 5.99997V9.99997C0.666748 10.1768 0.736986 10.3464 0.86201 10.4714C0.987034 10.5964 1.1566 10.6666 1.33341 10.6666ZM15.3334 7.99997C15.3334 10.1946 14.3694 12.164 12.8414 13.508L11.8961 12.5626C12.5564 12 13.0866 11.3005 13.4499 10.5127C13.8132 9.72489 14.0009 8.86752 14.0001 7.99997C14.001 7.13247 13.8134 6.27514 13.4502 5.48732C13.087 4.6995 12.557 4.00002 11.8967 3.43731L12.8414 2.49197C13.6254 3.17936 14.2534 4.02645 14.6832 4.97642C15.113 5.9264 15.3347 6.9573 15.3334 7.99997ZM12.0001 7.99997C12.0006 7.39497 11.8636 6.79777 11.5994 6.25346C11.3353 5.70916 10.951 5.23198 10.4754 4.85797L9.52275 5.81064C9.87587 6.05625 10.1643 6.38363 10.3635 6.76486C10.5627 7.14608 10.6668 7.56984 10.6667 7.99997C10.6667 8.90664 10.2141 9.70731 9.52275 10.1893L10.4761 11.1426C10.9516 10.7685 11.3359 10.2912 11.5999 9.74676C11.8639 9.20233 12.0007 8.60503 12.0001 7.99997Z",fill:i})}),$a=({color:i="currentColor",size:s=16,onClick:a,style:t})=>e.jsx("svg",{style:{...t},width:s,height:s,onClick:n=>
1a&&a(n),viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M3.92608 10.6666H1.33341C1.1566 10.6666 0.987034 10.5964 0.86201 10.4714C0.736986 10.3464 0.666748 10.1768 0.666748 9.99997V5.99997C0.666748 5.82316 0.736986 5.65359 0.86201 5.52857C0.987034 5.40355 1.1566 5.33331 1.33341 5.33331H3.92608L7.45541 2.44531C7.50425 2.40527 7.56345 2.37993 7.62613 2.37224C7.6888 2.36454 7.75238 2.37481 7.80944 2.40184C7.86651 2.42887 7.91473 2.47156 7.94848 2.52493C7.98223 2.5783 8.00012 2.64016 8.00008 2.70331V13.2966C8.00012 13.3598 7.98223 13.4216 7.94848 13.475C7.91473 13.5284 7.86651 13.5711 7.80944 13.5981C7.75238 13.6251 7.6888 13.6354 7.62613 13.6277C7.56345 13.62 7.50425 13.5947 7.45541 13.5546L3.92608 10.6666ZM13.6094 7.99997L15.9667 10.3573L15.0234 11.3L12.6667 8.94264L10.3094 11.3L9.36675 10.3573L11.7241 7.99997L9.36675 5.64331L10.3094 4.69997L12.6667 7.05731L15.0234 4.69997L15.9667 5.64331L13.6094 7.99997Z",fill:i})}),Za=({audioUrl:i,...s})=>{const a=g.useRef(null),t=g.useRef(null),[n,d]=g.useState(!1),[h,m]=g.useState(0),[p,l]=g.useState(0),[j,f]=g.useState(!1),y=()=>{const u=a.current;n?u.pause():u.play(),d(!n)},b=u=>{if(isNaN(u))return"0:00";const _=Math.floor(u/60),D=Math.floor(u%60).toString().padStart(2,"0");return`${_}:${D}`},z=()=>{a.current.muted=!j,f(!j)},x=u=>{const _=t.current.getBoundingClientRect(),C=(u.clientX-_.left)/_.width*p;a.current.currentTime=C,m(C/p*100)};return g.useEffect(()=>{const u=a.current,_=()=>{u.duration&&m(u.currentTime/u.duration*100)},D=()=>{d(!1)},C=()=>l(u.duration);return u.addEventListener("timeupdate",_),u.addEventListener("loadedmetadata",C),u.addEventListener("ended",D),()=>{u.removeEventListener("timeupdate",_),u.removeEventListener("loadedmetadata",C),u.removeEventListener("ended",D)}},[]),e.jsxs(v,{align:"center",className:"gap-3 p-3 rounded border border-border shadow-sm bg-card/50 backdrop-blur-sm",...s,children:[e.jsx("audio",{ref:a,src:i,preload:"metadata"}),e.jsx(Ee,{onClick:y,className:"text-foreground hover:text-primary-dark dark:hover:text-primary",children:n?e.jsx(za,{size:16,className:"text-foreground"}):e.jsx(Fa,{size:16,className:"text-foreground"})}),e.jsxs("span",{className:"text-sm font-normal text-muted-foreground w-[72px]",children:[b(h/100*p)," / ",b(p)]}),e.jsx("div",{ref:t,role:"button",tabIndex:0,"aria-label":"Seek audio",style:{flex:1,cursor:"pointer"},className:"flex items-center",onClick:x,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&x(u)},children:e.jsx(Ya,{value:h,className:"w-full rounded-full"})}),e.jsx(Ee,{onClick:z,className:"text-muted-foreground hover:text-foreground",children:j?e.jsx($a,{size:16}):e.jsx(Ua,{size:16})}),e.jsx("a",{href:i,download:!0,className:"text-muted-foreground hover:text-foreground cursor-pointer inline-flex items-center justify-center",children:e.jsx(Ia,{size:16})})]})};S.extend(fa);const $e=g.createContext({}),P=()=>g.useContext($e),oe=10,de=1e4,Wa=({children:i})=>{const s=Te(ma),a=Te(Y=>Y.companyV2?.resourceId),{campaignId:t}=ca(),n=ba(a,t),[d,h]=g.useState(1),[m,p]=g.useState([null,null]),[l,j]=g.useState(xe("last_week")),[f,y]=g.useState("step"),[b,z]=g.useState("sequences"),[x,u]=g.useState(""),[_,D]=g.useState(""),[C,c]=g.useState(""),[A,R]=g.useState(null),[N,J]=g.useState(["self_identified","visitor_identified"]),[ee,Ze]=g.useState(1),[ae,ge]=g.useState(1),H=S.utc(l.startDate).startOf("day").format("YYYY-MM-DD"),O=S.utc(l.endDate).startOf("day").format("YYYY-MM-DD");g.useEffect(()=>{ge(1)},[H,O]);const We=4,[he,Qe]=g.useState({search:"",dateRange:"last_week",channels:["email","sms","call","whatsapp","push"]}),{data:G,isFetching:fe}=Ca(t,{skip:!t}),Ke=G?.channels||[],je=n?["email","sms","whatsapp"]:Ke,Xe=G?.triggerType==="event_based",I=G?.status==="active";g.useEffect(()=>{h(1)},[x]);const{data:q,isLoading:se,isFetching:ve}=Da({campaignId:t,page:d,limit:oe,search:x},{skip:!t||b!=="sequences",pollingInterval:I&&b==="sequences"?de:0}),te=I?se:se||ve,we=I&&b==="sequences"&&ve&&!se,be=[...q?.items||[]].sort((Y,la)=>Y.id.localeCompare(la.id)),ne=te?0:q?.pagination?.totalItems||0,{data:re,isLoading:Je,isFetching:ea}=ya({campaignId:t,page:ae,limit:7,filter:N.length>0?N:void 0,...Xe&&{startDate:H,endDate:O,dateRangetype:l.type}},{skip:!t||b!=="leads"}),ie=Je||ea,{data:ye,isLoading:le,isFetching:_e}=Sa({campaignId:t,...s&&{tagId:s},filter:{dateSelection:{startDate:S.utc(l.startDate).startOf("day").format("YYYY-MM-DD"),endDate:S.utc(l.endDate).startOf("day").format("YYYY-MM-DD")}},dateRangetype:l.type},{skip:!t||b!=="analytics",pollingInterval:I&&b==="analytics"?de:0}),Ne=I?le:le||_e,aa=I&&b==="analytics"&&_e&&!le,{data:Ce,isLoading:ce,isFetching:De}=Aa({campaignId:t,startDate:H,endDate:O,dateRangetype:l.type},{skip:!t||b!=="analytics",pollingInterval:I&&b==="analytics"?de:0}),Se=I?ce:ce||De,Ae=aa||I&&b==="analytics"&&De&&!ce,{data:Le,isLoading:sa,isFetching:ta}=_a({campaignId:t,page:ee,limit:We,startDate:H,endDate:O,dateRangetype:l.type},{skip:!0}),ze=sa||ta,{data:Me,isLoading:na,isFetching:ra}=Na({campaignId:t,startDate:H,endDate:O,dateRangetype:l.type},{skip:!0}),ke=na||ra,ia=g.useMemo(()=>({campaignId:t,activeTab:b,setActiveTab:z,audienceSearch:x,setAudienceSearch:u,audienceData:{audience:be.map(Y=>({id:Y.id,email:Y.email,phone:Y.phone,description:Y.name})),total:ne,page:q?.pagination?.page||d,limit:q?.pagination?.pageSize||oe,totalPages:q?.pagination?.totalPages||0,isLoadingAudience:te},totalAudience:ne,filter:he,setFilter:Qe,sequencePage:d,setSequencePage:h,PAGE_SIZE:oe,customDateRange:m,setCustomDateRange:p,userId:A,setUserId:R,leadsData:re?.data?{...re.data,isLoadingLeadsData:ie}:{leads:[],total:0,page:1,limit:7,totalPages:0,hasNextPage:!1,hasPrevPage:!1,triggerType:void 0,isLoadingLeadsData:ie},leadSearch:_,setLeadSearch:D,leadsPage:ae,setLeadsPage:ge,dateRange:l,setDateRange:j,analyticsData:n&&t?wa(t):ye,isLoadingAnalyticsData:n?!1:Ne,stepAnalyticsData:Ce,isLoadingStepAnalyticsData:Se,activityData:Le?.data,isLoadingActivityData:ze,activitySearch:C,setActivitySearch:c,activityPage:ee,setActivityPage:Ze,setActivityActiveTab:y,activityActiveTab:f,channelData:n&&t?va(t):Me?.data,isLoadingChannelData:n?!1:ke,campaignChannels:je,campaignData:G,is
1FetchingCampaign:fe,leadsFilters:N,setLeadsFilters:J,isAudiencePolling:we,isAnalyticsPolling:Ae}),[t,b,x,be,q?.pagination,te,ne,he,d,m,A,re?.data,ie,_,ae,l,n,ye,Ne,Ce,Se,Le?.data,ze,C,ee,f,Me?.data,ke,je,G,fe,N,we,Ae]);return e.jsx($e.Provider,{value:ia,children:i})},Qa=()=>{const{t:i}=M(),{filter:s,setFilter:a,setDateRange:t,setCustomDateRange:n,customDateRange:d}=P(),h=l=>{if(a(j=>({...j,dateRange:l})),l!=="custom"){const j=xe(l);t?.(j)}},m=l=>{if(n?.(l),l[0]&&l[1]){const j=xe("custom",S(l[0]).format("YYYY-MM-DD"),S(l[1]).format("YYYY-MM-DD"));t?.(j),a(f=>({...f,dateRange:"custom"}))}},p=s?.dateRange??"last_week";return e.jsxs(v,{className:"gap-md items-center flex-wrap",children:[e.jsx("div",{className:"w-36",children:e.jsx(xa,{className:"w-full",triggerClassName:"h-10",value:p,onValueChange:l=>h(l),leftSection:e.jsx(Oa,{size:18,color:"rgb(var(--primary))"}),data:[{label:i("campaign_details.today"),value:"today"},{label:i("campaign_details.yesterday"),value:"yesterday"},{label:i("campaign_details.last_week"),value:"last_week"},{label:i("campaign_details.last_month"),value:"last_month"},{label:i("campaign_details.last_year"),value:"last_year"},{label:i("campaign_details.custom"),value:"custom"}]})}),p==="custom"&&e.jsx(qa,{type:"range",size:"sm",placeholder:i("monitoring.select_date_range","Select date range"),value:d,onChange:m,maxDate:new Date})]})};function Pe(i){return i?i.email?i.name?`${i.name} <${i.email}>`:i.email:i.phone?i.name?`${i.name} (${i.phone})`:i.phone:i.name||"":""}function Re(i){return i?.cleanErrorMessage||i?.errorMessage||void 0}function Ka(i){return(i||[]).map(s=>{const a=s.messages?.[s.messages.length-1],t=s.channel==="whatsapp"?(s.messages??[]).find(d=>d.role==="assistant"||!d.role):void 0,n=t?.templateBody??t?.textContent??a?.emailContent?.body??a?.pushContent?.body??a?.textContent??(a?.transcript?.length?a.transcript.map(d=>`${d.role}: ${d.message}`).join(`
2`):void 0);return{channel:s.channel,provider:s.provider,status:a?.status,messages:[{error:Re(a)}],subject:a?.emailContent?.subject??a?.pushContent?.title,content:n,whatsappTemplateName:t?.templateBody?t?.textContent:void 0,pushImageUrl:a?.pushContent?.imageUrl??null,pushLink:a?.pushContent?.link??null,sentAt:a?.createdAt??s.createdAt,nextActionText:s.nextActionText,from:Pe(s.from),to:Pe(s.to),error:Re(a),conversationMessages:s.channel==="whatsapp"&&s.messages?.length?s.messages:void 0}})}const Xa=({active:i,setActive:s,rightSection:a})=>{const{t}=M(),{setUserId:n}=P(),d=[{value:"sequences",label:t("campaign_view_details.sequences_tab")},{value:"analytics",label:t("campaign_view_details.analtyics_tab")}];return e.jsxs(v,{className:"justify-between items-center gap-4 relative flex-wrap",children:[e.jsx(Ge,{active:i,setActive:h=>{s(h),n(null)},options:d}),a]})},Ja=()=>{const[i,s]=g.useState([]),[a,t]=g.useState(!1),{activeTab:n,setActiveTab:d,analyticsData:h,campaignData:m,userId:p,campaignId:l}=P(),{t:j}=M(),f=oa(),y=da(),b=n!=="leads"&&n!=="sequences",[z]=La();return g.useLayoutEffect(()=>{if(!p||!l){t(!1),s([]);return}let x=!0;return t(!0),s([]),z({campaignId:l,muid:p}).unwrap().then(u=>{x&&s(Ka(u||[]))}).catch(()=>{x&&s([])}).finally(()=>{x&&t(!1)}),()=>{x=!1}},[p,l,z]),e.jsxs(o,{gap:24,children:[e.jsxs(o,{gap:48,children:[e.jsxs(o,{gap:16,children:[e.jsx(Ha,{}),e.jsxs(v,{className:"justify-between",children:[e.jsxs(o,{gap:4,children:[m?.name?e.jsx(r,{size:"32px",weight:"semibold",className:"text-foreground font-title",children:m.name}):e.jsx(B,{className:"h-9 w-64 rounded"}),h?.campaignStartDate||m?.createdAt?e.jsx(r,{size:"16px",className:"text-muted-foreground",children:j("campaign_view_details.created_on",{date:S(h?.campaignStartDate||m?.createdAt).format("MMM DD, YYYY [at] hh:mm a")})}):e.jsx(B,{className:"h-5 w-48 rounded"})]}),e.jsx(qe,{variant:"ghost",leftSection:e.jsx(ha,{strokeWidth:2}),onClick:()=>f("/campaigns",{state:{page:y?.state?.page}}),children:j("campaign_view_details.back_to_campaigns")})]})]}),e.jsx(Xa,{active:n,setActive:x=>d(x),rightSection:e.jsxs(v,{className:"gap-md items-center justify-end flex-wrap",children:[b&&e.jsx(Qa,{}),e.jsx(_s,{onSetBreakDown:()=>{s([]),t(!1)}})]})})]}),(()=>{switch(n){case"analytics":return e.jsx(rs,{});case"leads":return e.jsx(cs,{});case"sequences":return e.jsx(ps,{breakdown:i,isSequenceBreakdownLoading:a});default:return null}})()]})},es=()=>e.jsx("div",{children:e.jsx(o,{gap:24,children:[0,1].map(i=>e.jsx(v,{gap:24,children:[0,1,2,3].map(s=>e.jsx(B,{className:"h-[66px] w-[260px] rounded"},s))},i))})}),Ie=({title:i,stats:s})=>e.jsxs(o,{gap:12,children:[e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:i}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:Object.entries(s||{}).map(([a,t])=>{const n=t?.value!==null&&t?.value!==void 0,d=t?.type==="duration"?t?.value:ua(t?.value??0,t?.type);return e.jsx(E,{className:"px-4 py-3 min-h-fit border border-border/40 bg-card/80",children:e.jsxs(o,{gap:0,children:[e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:a}),e.jsx(v,{className:"justify-between",children:e.jsx(r,{size:"16px",weight:"semibold",className:"text-foreground",children:n?d:"-"})})]})},a)})})]}),as=i=>{const s={email:"Email",sms:"SMS",push:"Push",call:"Voice",voice:"Voice",voice_call:"Voice",whatsapp:"WhatsApp"},a=new Set;
2return i.forEach(t=>{const n=s[t.toLowerCase()];n&&a.add(n)}),Array.from(a)},ss=i=>{const s=(t="number")=>({value:0,change:0,type:t});return{Email:{Processed:s(),Sent:s(),Delivered:s(),"Delivery Rate":s("percentage"),Opened:s(),"Open Rate":s("percentage"),Clicked:s(),"Click Rate":s("percentage"),"Click-to-Open Rate":s("percentage")},SMS:{Processed:s(),Sent:s(),Delivered:s(),"Delivery Rate":s("percentage"),Clicked:s(),"Click Rate":s("percentage")},WhatsApp:{Contacted:s(),Delivered:s(),"Delivery Rate":s("percentage"),Read:s(),Failed:s(),"Response Rate":s("percentage"),"Responses Received":s(),"Active Conversations":s(),"Drop-off Rate":s("percentage")},Voice:{Contacted:s(),"Call Initiated":s(),"Call Connected":s(),"Connection Rate":s("percentage"),"Average Call Duration":s("duration"),"Calls Booked":s(),"Booking Rate":s("percentage")}}[i]||{}},ts=(i,s)=>{const a={},t={},n=["Conversions","Conversion Rate","Revenue","Page Views","Add to Carts","Checkouts Started"],d=["Open Rate","Opened","Click-to-Open Rate"],h=["Positive Intent Rate","Positive Intent","positive_intent"];return Object.entries(i||{}).forEach(([m,p])=>{if(n.includes(m))t[m]=p;else{if(s==="SMS"&&d.includes(m)||s==="Voice"&&h.includes(m))return;a[m]=p}}),Object.keys(a).length===0?{channelMetrics:ss(s),attributionMetrics:t}:{channelMetrics:a,attributionMetrics:t}},ns=({isPolling:i})=>e.jsxs("div",{className:"flex items-center gap-2",children:[i?e.jsx(Ue,{size:12,className:"animate-spin text-green-500"}):e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})]}),e.jsx(r,{size:"12px",weight:"medium",className:"text-green-500",children:"Campaign is running — analytics are updating in real time"})]}),rs=()=>{const{analyticsData:i,isLoadingAnalyticsData:s,campaignChannels:a,campaignData:t,isAnalyticsPolling:n}=P(),{t:d}=M(),h=t?.status==="active",m=i?.names||Object.keys(i?.details||{}),p={Email:d("campaign_view_details.analytics.email"),SMS:d("campaign_view_details.analytics.sms"),Voice:d("campaign_view_details.analytics.voice_ai"),WhatsApp:d("campaign_view_details.analytics.whatsapp")};if(s)return e.jsx(es,{});const l=a&&a.length>0?as(a.map(x=>typeof x=="string"?x:x.channel)):m,j=m.filter(x=>l.includes(x)),f=["Email","SMS","WhatsApp","Voice"],y=x=>[...x].sort((u,_)=>{const D=f.indexOf(u),C=f.indexOf(_);return D!==-1&&C!==-1?D-C:D!==-1?-1:C!==-1?1:u.localeCompare(_)}),b=y(j),z=b.length>0?b:y(l);return e.jsxs(g.Fragment,{children:[h&&e.jsx(ns,{isPolling:n}),e.jsxs(o,{gap:24,className:"mb-8",children:[z.length>0?z.map((x,u)=>{const _=i?.details?.[x],{channelMetrics:D,attributionMetrics:C}=ts(_,x),c=Object.entries(C).filter(([A,R])=>R?.value!==0&&R?.value!=="0").reduce((A,[R,N])=>({...A,[R]:N}),{});return e.jsxs(g.Fragment,{children:[e.jsx(Ie,{title:p[x]||x,stats:D}),Object.keys(c).length>0&&e.jsx(Ie,{title:`${p[x]||x} - Attribution`,stats:c})]},u)}):e.jsx(o,{gap:24,align:"center",className:"w-full mx-auto py-12 rounded border border-border/40 bg-card/80",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:d("alt_text.channel_performance_empty"),className:"w-8 h-8"}),e.jsxs(o,{gap:2,children:[e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:d("campaign_view_details.no_analytics_data")}),!i?.isMarktagConnected&&e.jsx(r,{size:"12px",className:"text-muted-foreground",children:d("campaign_view_details.enableAttributionTracking")})]})]})}),e.jsx(hs,{})]})]})},is=["campaign_view_details.leads_table.email","campaign_view_details.leads_table.data_source","campaign_view_details.leads_table.status","campaign_view_details.leads_table.phone_number","campaign_view_details.leads_table.website"],ls=["campaign_view_details.leads_table.muid","campaign_view_details.leads_table.email","campaign_view_details.leads_table.phone_number","campaign_view_details.leads_table.status","campaign_view_details.leads_table.initiated_at"],Fe={ACTIVE:"verified",INACTIVE:"outline",completed:"light",active:"default",failed:"destructive"},cs=()=>{const{t:i}=M(),{leadsData:s,leadsPage:a=1,setLeadsPage:t}=P(),n=s?.leads||[],d=s?.triggerType==="event_based",h=d?ls:is,m=s?.totalPages??0,p=e.jsx(ue,{total:m,value:a,onChange:l=>t?.(l),className:"flex justify-end text-sm font-semibold text-foreground
2/80"});return e.jsx(e.Fragment,{children:e.jsx(He,{pagination:m>0?p:null,children:s?.isLoadingLeadsData?e.jsx(X,{}):e.jsxs(e.Fragment,{children:[n.length>0&&e.jsx(Z,{children:e.jsx(k,{children:h.map((l,j)=>e.jsx(W,{className:"pl-6",children:e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:i(l)})})},j))})}),e.jsxs(Q,{children:[n.length>0&&n.map((l,j)=>e.jsx(k,{className:"odd:bg-muted/40 even:bg-transparent hover:bg-accent/40 text-sm font-normal text-foreground/90 whitespace-nowrap transition-colors duration-200",children:d?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"px-6 py-4",children:l?.muid?e.jsx(r,{size:"14px",weight:"medium",className:"text-foreground",children:l?.muid}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:l?.email?e.jsx(r,{size:"14px",weight:"medium",className:"text-foreground",children:l?.email}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:l?.phone_number?e.jsx(r,{size:"14px",className:"text-muted-foreground",children:l?.phone_number}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:l?.user_status?e.jsx(T,{variant:Fe[l.user_status]||"secondary",children:L(l.user_status)}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:l?.created_at?e.jsx(r,{size:"14px",className:"text-muted-foreground",children:S(l.created_at).format("MMM D, YYYY h:mm A")}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"px-6 py-4",children:l?.email?e.jsx(r,{size:"14px",weight:"medium",className:"text-foreground",children:l?.email}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:(()=>{const f=l?.datasource,y=Array.isArray(f)?f[0]??"":f??"";if(!y)return e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"});const b=String(y).toLowerCase();return e.jsxs(v,{className:"gap-3",children:[b!=="csv"&&e.jsx(K,{app:y,width:20}),e.jsx(r,{size:"14px",weight:"medium",className:"text-foreground",children:L(y)})]})})()}),e.jsx(w,{className:"px-6 py-4",children:l?.user_status?e.jsx(T,{variant:Fe[l.user_status]==="verified"?"default":"secondary",children:L(l.user_status)}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:l?.phone_number?e.jsx(r,{size:"14px",className:"text-muted-foreground",children:l?.phone_number}):e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"px-6 py-4",children:l?.website?e.jsx(r,{size:"14px",className:"text-muted-foreground",children:l?.website}):e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground",children:"-"})})]})},j)),n.length===0&&e.jsx(k,{className:"hover:bg-transparent",children:e.jsx(w,{colSpan:5,className:"text-center",style:{height:"200px"},children:e.jsx(o,{gap:24,align:"center",className:"max-w-96 mx-auto",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:"Leads empty",className:"w-8 h-8"}),e.jsx(o,{gap:2,children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:i("campaign_view_details.leads_table.no_leads")})})]})})})})]})]})})})},os=({data:i,subText:s})=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"relative h-6",children:e.jsxs("div",{className:"absolute start-1/2 z-9 -translate-x-1/2 transform rtl:translate-x-1/2",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/60 ring-2 ring-primary/15"}),e.jsx("div",{className:"mx-auto h-4 w-[2px] bg-gradient-to-b from-primary/50 to-border/60"})]})}),i&&e.jsxs("div",{className:"flex-col mx-auto",children:[e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(T,{variant:"secondary",children:e.jsx(r,{size:"12px",className:"text-foreground",children:i})})}),s&&e.jsx("div",{className:"mt-2 flex w-full justify-center px-4",children:e.jsxs("div",{className:"flex w-full max-w-2xl items-start gap-3 rounded border border-primary/20 bg-primary/5 px-4 py-3 shadow-sm ring-1 ring-primary/10 dark:border-primary/25 dark:bg-primary/[0.08] dark:ring-primary/15",role:"note",children:[e.jsx("span",{className:"mt-1.5 h-2 w-2 shrink-0 rounded-full bg-[var(--base-primary,#D8FE91)] shadow-[0_0_10px_rgba(216,254,145,0.35)]","aria-hidden":!0}),e.jsx(r,{size:"12px",weight:"normal",className:"text-left text-foreground
2/90 dark:text-foreground/95",children:s})]})}),e.jsx("div",{className:"mx-auto h-4 w-[2px] bg-gradient-to-b from-border/70 to-primary/40"})]})]}),me=()=>{const{t:i}=M();return e.jsx(o,{gap:10,justify:"center",align:"start",children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground",children:i("ui_common.no_data_found")})})},Ye={sent:"default",success:"default",failed:"destructive",pending:"secondary",error:"destructive"},ds=i=>[...i||[]].sort((s,a)=>new Date(s?.sentAt??s?.createdAt??0).getTime()-new Date(a?.sentAt??a?.createdAt??0).getTime()),ms=i=>{const s=i?.toLowerCase();return s==="assistant"||s==="system"},Be=i=>(i?.templateBody??i?.textContent??i?.content??i?.message??"").trim(),xs=({opened:i,onClose:s,selectedContent:a})=>{const{t}=M(),[n,d]=g.useState("40%"),h=(()=>{if(a?.channel!=="whatsapp"||!Array.isArray(a?.conversationMessages)||a.conversationMessages.length===0)return null;const m=ds(a.conversationMessages).filter(p=>Be(p));return m.length>0?m:null})();return g.useEffect(()=>{const m=()=>{const p=window.innerWidth;p<=640?d("100%"):p<=1024?d("60%"):d("40%")};return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]),e.jsxs(Ea,{isCloseHidden:!0,opened:i,onClose:()=>{s()},position:"right",size:n,offset:16,radius:12,styles:{content:{padding:16}},children:[e.jsx(Pa,{className:"!p-0 !pb-4",children:e.jsx(o,{gap:4,children:e.jsxs(r,{size:"18px",weight:"semibold",className:"text-foreground",children:[t("ui_common.id_label")," ",a?.to||a?.name||a?.email||a?.phone||a?.clusterUserId]})})}),e.jsx(Ra,{className:"flex flex-col min-h-0 !p-0 !pt-4",children:a?.channel==="call"?e.jsxs(o,{gap:32,children:[e.jsxs(v,{justify:"space-between",children:[e.jsxs(v,{gap:8,children:[e.jsx(pe,{size:24,className:"text-muted-foreground"}),e.jsx(r,{size:"18px",weight:"semibold",className:"text-foreground",children:t("ui_common.ai_voice_call")})]}),e.jsx(v,{gap:12,children:e.jsx(T,{variant:Ye[a?.status],children:L(a?.status)})})]}),e.jsxs(o,{gap:20,children:[a?.from?.trim()!==""&&e.jsxs(v,{gap:8,className:"w-full justify-between",children:[e.jsxs(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:["From: ",a?.from]}),e.jsx(r,{size:"12px",className:"text-muted-foreground",children:S(a?.sentAt).format("MMM DD, YYYY [at] hh:mm a")})]}),a?.error&&e.jsx(E,{className:"bg-destructive/10 border border-destructive/30 !p-3 min-h-fit backdrop-blur-sm",children:e.jsxs(o,{gap:4,children:[e.jsxs(v,{gap:8,align:"center",children:[e.jsx("span",{className:"text-destructive text-base leading-none",children:"⚠️"}),e.jsx(r,{size:"14px",weight:"semibold",className:"text-destructive leading-none",children:t("ui_common.call_failed")})]}),e.jsx(r,{size:"12px",className:"text-destructive/80 leading-normal",children:a.error})]})}),e.jsxs(o,{gap:12,children:[e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:t("ui_common.recording")}),a?.recordingUrl!==void 0?e.jsx(Za,{audioUrl:a?.recordingUrl}):e.jsx(me,{})]}),e.jsxs(o,{gap:12,children:[e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:t("ui_common.ai_summary")}
2),a?.summary!==void 0?e.jsx(E,{className:"min-h-fit !p-3 bg-card/50 border border-border backdrop-blur-sm text-sm font-normal text-foreground",children:a?.summary}):e.jsx(me,{})]}),e.jsxs(o,{gap:12,children:[e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:t("ui_common.transcript")}),a?.transcript?.length>0?e.jsx(E,{className:"bg-card/50 border border-border backdrop-blur-sm !p-3 max-h-[calc(100vh-700px)] min-h-fit overflow-y-auto",children:e.jsx(o,{gap:8,children:a?.transcript?.map((m,p)=>m?.message&&e.jsxs(o,{gap:6,align:m?.role.toLowerCase()==="assistant"?"start":"end",children:[e.jsx(v,{gap:8,children:e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:m?.role.toLowerCase()==="assistant"?t("ui_common.assistant_name"):t("ui_common.you_label")})}),e.jsx("span",{className:F("border border-border rounded p-[10px_14px_10px_14px] w-fit text-sm font-normal bg-white/5 text-foreground backdrop-blur-sm",m?.role.toLowerCase()==="assistant"?"rounded-tl-none":"rounded-tr-none"),children:m?.message})]},p))})}):e.jsx(me,{})]})]})]}):e.jsxs(o,{className:F("flex flex-col flex-1 border border-border rounded p-3 gap-8 bg-card/50 backdrop-blur-sm",a?.channel==="email"&&!a?.error||a?.channel==="whatsapp"&&h?"min-h-0":"max-h-fit"),children:[e.jsxs(v,{justify:"space-between",children:[e.jsxs(v,{gap:8,children:[e.jsx(K,{app:a?.provider,width:32}),e.jsx(r,{size:"18px",weight:"semibold",className:"text-foreground",children:L(a?.channel||t("home_page.channel_email"))})]}),e.jsx(v,{gap:12,children:e.jsx(T,{variant:Ye[a?.status],children:L(a?.status)})})]}),e.jsx(o,{gap:24,className:"flex flex-col flex-1 min-h-0",children:e.jsxs(o,{gap:6,align:"start",className:"flex flex-col flex-1 min-h-0",children:[a?.from?.trim()!==""&&e.jsxs(v,{gap:8,className:"w-full justify-between",children:[e.jsxs(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:["From: ",a?.from]}),e.jsx(r,{size:"12px",className:"text-muted-foreground",children:S(a?.sentAt).format("MMM DD, YYYY [at] hh:mm a")})]}),(a?.channel==="email"||a?.channel==="push")&&a?.subject&&e.jsxs(o,{gap:8,className:"mt-2",children:[e.jsx(r,{size:"14px",weight:"semibold",className:"text-muted-foreground",children:a?.channel==="push"?t("ui_common.title","Title"):t("ui_common.subject")}),e.jsx(r,{size:"16px",weight:"medium",className:"text-foreground",children:a?.subject})]}),a?.error&&e.jsx(E,{className:"bg-destructive/10 border border-destructive/30 !p-3 w-full min-h-fit backdrop-blur-sm",children:e.jsxs(o,{gap:4,children:[e.jsxs(v,{gap:8,align:"center",children:[e.jsx("span",{className:"text-destructive text-base leading-none",children:"⚠️"}),e.jsx(r,{size:"14px",weight:"semibold",className:"text-destructive leading-none",children:t("ui_common.message_failed")})]}),e.jsx(r,{size:"12px",className:"text-destructive/80 leading-normal",children:a?.error})]})}),h?e.jsx(E,{className:"flex w-full flex-1 min-h-0 max-h-[min(64vh,600px)] flex-col overflow-hidden border border-border/60 bg-card/40 !p-0",children:e.jsx(o,{gap:14,className:"min-h-0 flex-1 overflow-y-auto !p-3",children:h.map((m,p)=>{const l=Be(m),j=ms(m?.role),f=m?.role?.toLowerCase(),y=j?t("campaign_details.messaging_role_assistant"):f==="user"?t("campaign_details.messaging_role_customer"):L(m?.role||"");return e.jsxs(o,{gap:6,align:j?"start":"end",className:"w-full min-w-0",children:[e.jsx(v,{gap:8,wrap:"wrap",className:F("w-full",j?"justify-start":"justify-end"),children:e.jsx(r,{size:"12px",weight:"semibold",className:"text-foreground",children:y})}),e.jsx("div",{className:F("flex w-full min-w-0",j?"justify-start":"justify-end"),children:e.jsx("div",{className:F("max-w-[min(92%,28rem)] rounded border px-3.5 py-2.5 text-xs font-normal text-foreground backdrop-blur-sm","[&_p]:mb-1.5 [&_p:last-child]:mb-0 [&_ul]:list-disc [&_ul]:pl-4 [&_ul]:my-1 [&_li]:mb-0.5 [&_strong]:font-semibold [&_a]:text-primary [&_a]:underline [&_a]:break-all",j?"rounded-tl-none border-border bg-white/5":"rounded-tr-none border-primary/25 bg-primary/10"),dangerouslySetInnerHTML:{__html:$(U(l)?l:Oe(l))}})}),m?.templateBody&&m?.textContent&&j&&e.jsxs(r,{size:"10px",weight:"medium",className:"text-muted-foreground self-start font-mono",children:["Template: ",m.textContent]}
2),(m?.sentAt??m?.createdAt)&&e.jsx(r,{size:"12px",className:F("text-muted-foreground",j?"self-start":"self-end"),children:S(m?.sentAt??m?.createdAt).format("MMM DD, YYYY [at] hh:mm a")})]},m?.messageId??p)})})}):a?.content&&e.jsx(e.Fragment,{children:a?.channel==="email"&&U(a?.content)?e.jsx(Ta,{html:a?.content||""}):e.jsx("span",{className:F("border border-border rounded p-[10px_14px_10px_14px] w-fit text-xs font-normal text-foreground bg-white/5 backdrop-blur-sm",a?.length>1?a?.role?.toLowerCase()==="assistant"?"rounded-tl-none":"rounded-tr-none":""),children:U(a?.content)?e.jsx("div",{dangerouslySetInnerHTML:{__html:$(a?.content||"")}}):e.jsx("pre",{className:"whitespace-pre-wrap",children:a?.content})})}),a?.channel==="push"&&a?.pushImageUrl&&e.jsxs(o,{gap:8,className:"mt-2 w-full",children:[e.jsx(r,{size:"14px",weight:"semibold",className:"text-muted-foreground",children:t("ui_common.image","Image")}),e.jsx("img",{src:a.pushImageUrl,alt:"Push notification",className:"rounded-lg object-contain self-start",style:{maxHeight:160,maxWidth:160}})]}),a?.channel==="push"&&a?.pushLink&&e.jsxs(o,{gap:8,className:"mt-2 w-full",children:[e.jsx(r,{size:"14px",weight:"semibold",className:"text-muted-foreground",children:t("ui_common.link","Link")}),e.jsx("span",{"aria-disabled":"true",className:"text-xs text-primary underline break-all pointer-events-none cursor-default",children:a.pushLink})]})]})})]})})]})},us=10,Ve={sent:"success",success:"success",failed:"error",skipped:"secondary",pending:"warning",scheduled:"secondary",error:"error"},ps=({breakdown:i,isSequenceBreakdownLoading:s=!1})=>{const{audienceData:a,totalAudience:t,sequencePage:n,setSequencePage:d,audienceSearch:h,userId:m,setUserId:p,campaignData:l,isAudiencePolling:j}=P(),{t:f}=M(),[y,b]=g.useState(!1),[z,x]=g.useState(null),u=a?.audience||[],_=a?.isLoadingAudience,D=Math.ceil(a?.total/us),C=l?.status==="active";return e.jsxs(g.Fragment,{children:[C&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[j?e.jsx(Ue,{size:12,className:"animate-spin text-green-500"}):e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})]}),e.jsx(r,{size:"12px",weight:"medium",className:"text-green-500",children:"Campaign is running — sequences are updating in real time"})]}),e.jsx(xs,{opened:y,onClose:()=>{b(!1)},selectedContent:z}),l?.lastError&&l?.triggerType!=="event_based"&&e.jsx(E,{className:"mb-4 border border-border/40 bg-card/80 !p-4 !min-h-full",children:e.jsx(o,{gap:12,children:l.lastError&&e.jsx("div",{className:F("p-3 rounded border",l.lastError.allChannelsFailed?"bg-destructive/10 border-destructive/40":"bg-warning/10 border-warning/40"),children:e.jsxs(o,{gap:6,children:[e.jsxs(v,{gap:6,children:[e.jsx("span",{className:"text-base",children:l.lastError.allChannelsFailed?"🛑":"⚠️"}),e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:l.lastError.message})]}),l.lastError.channels?.length>0&&e.jsxs(r,{size:"12px",className:"text-muted-foreground",children:[e.jsx("strong",{children:f("campaign_details.failed_channels")})," ",l.lastError.channels.map(L).join(", ")]}),e.jsx(r,{size:"12px",className:"text-muted-foreground",children:S(l.lastError.timestamp).format("MMM DD, YYYY [at] hh:mm a")}),l.lastError.allChannelsFailed&&e.jsx(r,{size:"12px",weight:"medium",className:"text-destructive",children:f("campaign_details.campaign_paused_check_integration")})]})})})}),e.jsxs(v,{className:"grid grid-cols-[1fr_0.8fr] mb-4 gap-28 items-start",children:[e.jsx(E,{className:"w-full border border-border/40 min-h-fit",children:e.jsxs(o,{gap:24,children:[_&&e.jsx(e.Fragment,{children:[0,1,2,3].map(c=>e.jsx(B,{className:"h-20 w-full rounded"},c))}),e.jsxs(o,{gap:12,children:[!_&&u.length>0&&u.map(c=>e.jsx("div",{role:"button",tabIndex:0,onClick:()=>{p(c?.id),x(null),window.scrollTo({top:0,behavior:"smooth"})},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),p(c?.id),x(null),window.scrollTo({top:0,behavior:"smooth"}))},children:e.jsx(E,{className:F("min-h-min border bg-card/80 !p-4 cursor-pointer transition-colors",m===c?.id?"border-primary":"border-border/70 hover:border-border"),children:e.jsxs(o,{gap:12,children:[c?.description&&e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:c?.description}),e.jsxs(v,{className:"gap-2 flex-wrap",children:[c?.email&&e.jsx(T,{variant:"secondary",children:e.jsx(r,{size:"12px",className:"text-foreground",children:c?.email})}),c?.phone&&e.jsx(T,{variant:"secondary",children:e.jsx(r,{size:"12px",className:"text-foreground",children:c?.phone})}),c?.id&&e.jsx(T,{variant:"secondary",children:e.jsxs(r,{size:"10px",className:"text-muted-foreground font-mono",children:["ID: ",c.id]})})]})]})})},c?.id)),!_&&u.length===0&&e.jsx(o,{gap:24,align:"center",className:"max-w-96 mx-auto",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:"Leads empty",className:"w-8 h-8"}),e.jsx(o,{gap:2,children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:f("campaign_details.no_audience_found")})})]})}),h!==""&&u.length!==0&&e.jsx(r,{size:"14px",className:"text-muted-foreground text-center",children:f("campaign_details.results_found",{total:t})})]}),a?.totalPages>1&&e.jsx(ue,{total:a?.totalPages||D||0,page:n||a?.page||1,onChange:c=>{d(c),p(null),window.scrollTo({top:0,behavior:"smooth"})},className:"flex justify-start text-sm font-semibold text-foreground
2/80"})]})}),e.jsx(o,{gap:16,className:"w-full",children:m&&s?e.jsxs(o,{gap:16,className:"w-full","aria-busy":!0,"aria-live":"polite","aria-label":f("campaign_details.sequence_breakdown_loading"),children:[e.jsx(B,{className:"h-36 w-full rounded"}),e.jsx(B,{className:"h-28 w-full rounded"}),e.jsx(B,{className:"h-40 w-full rounded"}),e.jsx(B,{className:"h-40 w-full rounded"})]}):e.jsx(e.Fragment,{children:e.jsx(o,{gap:0,className:"w-full",children:i?.length>0?i?.map((c,A,R)=>e.jsxs(g.Fragment,{children:[e.jsx(E,{className:"border border-border/40 bg-card/80 !p-4 min-h-fit",children:e.jsxs(o,{gap:32,children:[e.jsxs(o,{gap:16,children:[e.jsxs(v,{className:"justify-between",children:[e.jsxs(v,{gap:8,align:"center",children:[c?.channel==="call"?e.jsx("span",{className:"text-muted-foreground",children:e.jsx(pe,{size:24})}):e.jsx(K,{app:c?.provider,width:24}),e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:L(c?.channel)})]}),e.jsxs(v,{gap:12,children:[c?.isPersonalizedInjection&&e.jsx(T,{variant:"outline",className:"border-violet-400 text-violet-600 dark:text-violet-400",children:"Personalized"}),e.jsx(T,{variant:Ve[c?.status]==="success"?"default":Ve[c?.status]==="error"?"destructive":"secondary",children:c?.statusDisplay??L(c?.status)}),c?.messages?.[0]?.error&&e.jsx(pa,{label:c.messages[0].error,position:"right",children:e.jsx(T,{variant:"destructive",children:e.jsx(r,{size:"12px",className:"text-destructive-foreground",children:f("campaign_details.error_label")})})})]})]}),c?.channel==="push"&&c?.subject&&e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:c.subject}),c?.channel==="whatsapp"&&c?.conversationMessages?.length>0&&(()=>{const N=c.conversationMessages.filter(J=>J.role==="user").length;return N>0?e.jsxs(r,{size:"12px",className:"text-muted-foreground",children:[N," user",N===1?" reply":" replies"," ","· ",c.conversationMessages.length," messages total"]}):null})(),c?.content&&(()=>{const N=c?.content;return N?c?.channel==="email"&&U(N)?e.jsxs("pre",{className:"whitespace-pre-wrap text-xs font-normal text-foreground",children:["Subject: ",c?.subject]}):c?.channel==="whatsapp"?e.jsxs(e.Fragment,{children:[c?.whatsappTemplateName&&e.jsxs(r,{size:"10px",weight:"medium",className:"text-muted-foreground font-mono",children:["Template: ",c.whatsappTemplateName]}),e.jsx("div",{className:"text-xs font-normal text-foreground line-clamp-4 [&_p]:mb-1 [&_p:last-child]:mb-0 [&_ul]:list-disc [&_ul]:pl-4 [&_li]:mb-0.5 [&_strong]:font-semibold [&_a]:underline [&_a]:break-all",dangerouslySetInnerHTML:{__html:$(Oe(N))}})]}):U(N)?e.jsx("div",{className:"text-xs font-normal text-foreground",dangerouslySetInnerHTML:{__html:$(N||"")}}):e.jsx("pre",{className:"whitespace-pre-wrap text-xs font-normal text-foreground",children:N}):null})()]}),c?.stepPurpose&&c?.isPersonalizedInjection&&e.jsxs(v,{gap:10,align:"flex-start",className:"w-full rounded bg-[#1e2214] px-3 py-2.5 ring-1 ring-[#2d3322] dark:bg-[#1a1d12] dark:ring-white/10",children:[e.jsx(Ga,{size:16,className:"mt-0.5 shrink-0 text-[#d9f171]","aria-hidden":!0}),e.jsxs(r,{size:"12px",weight:"normal",className:"min-w-0 flex-1 leading-snug text-[#d9f171]",children:[e.jsx("span",{className:"font-medium",children:f("campaign_details.ai_objective_label")}),": ",c.stepPurpose]})]}),c?.decisionExplanation&&e.jsx(r,{size:"12px",className:"text-muted-foreground italic",children:c.decisionExplanation}),c?.preferredSendHint&&e.jsxs(r,{size:"12px",className:"text-amber-600 dark:text-amber-400",children:["⏰ ",c.preferredSendHint]}),e.jsxs(v,{justify:"space-between",align:"center",className:"w-full",children:[e.jsx("div",{className:"min-w-0 flex-1",children:c?.status!=="pending"&&c?.status!=="skipped"&&e.jsx(r,{size:"12px",className:"text-muted-foreground",children:c?.status==="scheduled"?f("campaign_details.scheduled_for",{scheduled:S(c?.scheduledFor).format("MMM DD, YYYY [at] hh:mm a")}):f("campaign_details.sent_on_2",{date:S(c?.sentAt).format("MMM DD, YYYY [at] hh:mm a")})})}),i.length>0&&c?.status!=="pending"&&c?.status!=="skipped"&&e.jsx(qe,{trailingIcon:e.jsx(ka,{size:20}),variant:"ghost",disabled:c?.status==="scheduled",onClick:()=>{b(!0),x({...c,idx:A+1})},children:f("campaign_details.view")})]})]})}),A<R.length-1&&e.jsx(os,{data:c?.nextActionText,subText:R[A+1]?.delayReasoning})]},A)):m&&e.jsx(E,{className:"border border-border/40 bg-card/80 !p-8 min-h-fit",children:e.jsx(o,{gap:24,align:"center",className:"max-w-96 mx-auto",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:f("alt_text.no_data_available"),className:"w-8 h-8"}),e.jsx(o,{gap:2,children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:f("campaign_details.no_data_available")})})]})})})})})})]})]})},gs=["channel","activity"],hs=()=>{const{t:i}=M(),{activityPage:s,setActivityPage:a,activityData:t,activityActiveTab:n,setActivityActiveTab:d}=P(),h=[{label:i("campaign_view_details.analytics.channel_performance"),value:"channel"},{label:i("campaign_view_details.analytics.step_analytics"),value:"step"},{label:i("campaign_view_details.analytics.activity"),value:"activity"}].filter(l=>!gs.includes(l.value)),m=e.jsx(o,{gap:4,className:"px-4 py-3 ",children:e.jsx(v,{className:"justify-between",children:h.length>1?e.jsx(Ge,{active:n,setActive:d,options:h}):e.jsx(r,{size:"14px",weight:"semibold",className:"text-foreground",children:"Workflow Analytics"})})}),p=e.jsx(ue,{value:s,total:t?.pagination?.totalPages||0,onChange:l=>a(l),className:"flex justify-end text-sm font-semibold text-foreground
2/80"});return e.jsx(He,{banner:m,withBanner:!0,pagination:n==="activity"&&t?.pagination?.totalPages>0?p:null,children:(()=>{switch(n){case"channel":return e.jsx(js,{});case"step":return e.jsx(ws,{});case"activity":return e.jsx(ys,{});default:return null}})()})},fs=["campaign_view_details.analytics.channel","campaign_view_details.analytics.total_sent","campaign_view_details.analytics.open_rate","campaign_view_details.analytics.ctr","campaign_view_details.analytics.engagement_rate"],js=()=>{const{t:i}=M(),{channelData:s,isLoadingChannelData:a}=P(),t=s||[];return e.jsx(e.Fragment,{children:a?e.jsx(X,{}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:t.length>0&&e.jsx(k,{className:"px-6 py-3",children:fs.map((n,d)=>e.jsx(W,{children:e.jsx("div",{className:"flex gap-1",children:e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:i(n)})})},d))})}),e.jsxs(Q,{children:[t.length===0&&e.jsx(k,{children:e.jsx(w,{colSpan:5,className:"text-center",style:{height:"200px"},children:e.jsx(o,{gap:24,align:"center",className:"max-w-96 mx-auto",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:"Channel performance Empty",className:"w-8 h-8"}),e.jsx(o,{gap:2,children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:i("campaign_view_details.no_data")})})]})})})}),t.length>0&&t.map((n,d)=>e.jsxs(k,{className:"odd:bg-muted/40 even:bg-transparent hover:bg-accent/40 text-sm font-normal text-foreground/90 whitespace-nowrap transition-colors duration-200",children:[e.jsx(w,{className:"px-6 py-4 w-98",children:e.jsx("div",{children:e.jsxs(v,{gap:12,children:[n?.platform?e.jsx("span",{className:"w-10 h-10 rounded-full bg-muted/30 border border-white/10 grid place-items-center",children:n?.platform==="vapi"?e.jsx("span",{className:"text-muted-foreground",children:e.jsx(pe,{size:20,strokeWidth:2})}):e.jsx(K,{app:n?.platform,width:20})}):e.jsx("span",{className:"w-10 h-10"}),e.jsxs(o,{gap:0,children:[e.jsx(r,{size:"14px",weight:"medium",className:"text-foreground",children:n?.channel?L(n?.channel):"-"}),e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.platform?L(n?.platform):"-"})]})]})})}),e.jsx(w,{className:"px-6 py-4",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.sent!==void 0?`${n.sent}`:"-"})}),e.jsx(w,{className:"px-6 py-4",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.opened!==void 0?`${n.opened}%`:"-"})}),e.jsx(w,{className:"px-6 py-4",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.ctr!==void 0?`${n.ctr}%`:"-"})}),e.jsx(w,{className:"px-6 py-4",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.engagementRate!==void 0?`${n.engagementRate}%`:"-"})})]},d))]})]})})},vs=["campaign_view_details.analytics.step",{key:"sent",combined:"sent_contacted"},{key:"delivered",combined:"delivered_connected"},"campaign_view_details.analytics.opened","campaign_view_details.analytics.clicked","campaign_view_details.analytics.replied"],ws=()=>{const{stepAnalyticsData:i,isLoadingStepAnalyticsData:s}=P(),{t:a}=M(),t=i?.stepAnalytics||[];return e.jsx(e.Fragment,{children:s?e.jsx(X,{}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:t.length>0&&e.jsx(k,{className:"px-6 py-3",children:vs.map((n,d)=>{let h="";return typeof n=="string"?h=a(n):n.key==="sent"?h=`${a("campaign_view_details.analytics.sent")}/${a("campaign_view_details.analytics.contacted")}`:n.key==="delivered"&&(h=`${a("campaign_view_details.analytics.delivered")}/${a("campaign_view_details.analytics.connected")}`),e.jsx(W,{className:d===0?"":"text-center",children:e.jsx("div",{className:`flex gap-1 ${d===0?"pl-4":"justify-center"}`,children:e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:h})})},d)})})}),e.jsxs(Q,{children:[t.length===0&&e.jsx(k,{children:e.jsx(w,{colSpan:7,className:"text-center",style:{height:"200px"},children:e.jsx(o,{gap:24,align:"center",className:"max-w-96 mx-auto",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:"Step analysis Empty",className:"w-8 h-8"}),e.jsx(o,{gap:2,children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:a("campaign_view_details.no_data")})})]})})})}),t.length>0&&t.map((n,d)=>e.jsxs(k,{className:"odd:bg-muted/40 even:bg-transparent hover:bg-accent/40 text-sm font-normal text-foreground
2/90 whitespace-nowrap transition-colors duration-200",children:[e.jsx(w,{className:"px-6 py-4",children:e.jsxs(r,{size:"14px",weight:"medium",className:"text-foreground",children:[n?.step??"-",": ",n?.stepName??"Unnamed Step"]})}),e.jsx(w,{className:"px-6 py-4 text-center",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.sent??n?.contacted??"-"})}),e.jsx(w,{className:"px-6 py-4 text-center",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.delivered??n?.connected??"-"})}),e.jsx(w,{className:"px-6 py-4 text-center",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.opened??"-"})}),e.jsx(w,{className:"px-6 py-4 text-center",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.clicked??"-"})}),e.jsx(w,{className:"px-6 py-4 text-center",children:e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.reply??"-"})})]},d))]})]})})},bs=["campaign_view_details.analytics.activity","campaign_view_details.analytics.lead","campaign_view_details.analytics.when"],ys=()=>{const{activityData:i,isLoadingActivityData:s}=P(),{t:a}=M(),t=i?.activity||[];return e.jsx(e.Fragment,{children:s?e.jsx(X,{}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:t.length>0&&e.jsx(k,{className:"px-6 py-3",children:bs.map((n,d)=>e.jsx(W,{className:"pl-6",children:e.jsx("div",{className:"flex gap-1",children:e.jsx(r,{size:"12px",weight:"medium",className:"text-muted-foreground",children:a(n)})})},d))})}),e.jsxs(Q,{children:[t.length===0&&e.jsx(k,{children:e.jsx(w,{colSpan:3,className:"text-center",style:{height:"200px"},children:e.jsx(o,{gap:24,align:"center",className:"max-w-96 mx-auto",children:e.jsxs(o,{gap:12,align:"center",children:[e.jsx("img",{src:V,alt:"Activity analysis empty",className:"w-8 h-8"}),e.jsx(o,{gap:2,children:e.jsx(r,{size:"14px",weight:"medium",className:"text-muted-foreground text-center",children:a("campaign_view_details.no_data")})})]})})})}),t.length>0&&t.map((n,d)=>e.jsxs(k,{className:"odd:bg-muted/40 even:bg-transparent hover:bg-accent/40 text-sm font-normal text-foreground/90 transition-colors duration-200",children:[e.jsx(w,{className:"px-6 py-4",children:e.jsxs(o,{gap:2,children:[e.jsxs(r,{size:"14px",weight:"medium",className:"text-foreground",children:[n?.step??"-"," ",n?.channel?L(n.channel):"-"," via"," ",n?.platform?L(n.platform):"-"]}),e.jsxs(r,{size:"14px",className:"text-muted-foreground",children:["from ",n?.from??"-"]})]})}),e.jsx(w,{className:"px-6 py-4",children:e.jsxs(o,{gap:2,children:[e.jsx(r,{size:"14px",weight:"medium",className:"text-foreground",children:n?.lead??"-"}),e.jsx(r,{size:"12px",className:"text-muted-foreground",children:n?.muid??"-"})]})}),e.jsx(w,{className:"px-6 py-4",children:e.jsxs(o,{gap:2,children:[e.jsx(r,{size:"14px",className:"text-muted-foreground",children:n?.when??"-"}),e.jsx(r,{size:"14px",className:"text-muted-foreground opacity-0",children:" "})]})})]},d))]})]})})},_s=({onSetBreakDown:i})=>{const{t:s}=M(),{activeTab:a,filter:t,setFilter:n,setUserId:d,setAudienceSearch:h,campaignData:m,leadsFilters:p,setLeadsFilters:l}=P(),j=m?.triggerType==="event_based",[f,y]=g.useState(""),b=Ba(x=>{h(x),n({...t,search:x}),d(null),i()},500),z=()=>{y(""),h(""),n({...t,search:""}),d(null),i()};return e.jsxs(e.Fragment,{children:[a==="leads"&&j&&e.jsx(Va,{value:p,onChange:x=>l(x),data:[{label:s("campaign_view_details.leads_table.self_identified"),value:"self_identified"},{label:s("campaign_view_details.leads_table.visitor_identified"),value:"visitor_identified"},{label:s("campaign_view_details.leads_table.anonymous"),value:"anonymous"}],className:"w-full sm:w-60",size:"sm",enableSelectAll:!1}),a==="sequences"&&e.jsx(v,{className:"gap-md items-center",children:e.jsx(ga,{className:"h-10 min-h-10",wrapperClassName:"w-[320px]",value:f,onChange:x=>{const u=x.target.value;y(u),b(u)},leftSection:e.jsx("span",{className:"text-muted-foreground",children:e.jsx(ja,{size:18})}),rightSection:f?e.jsx("button",{type:"button",onClick:z,className:"flex items-center justify-center rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Clear search",children:e.jsx(Ma,{size:15})}):null,placeholder:`${s("campaign_view_details.sequence_tab.search")}...`})})]})},rt=()=>e.jsx(Wa,{children:e.jsx(Ja,{})});
2export{rt as CampaignViewDetailsPage};

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.