1import{b as ae,h as B,j as e,T as _,S as ne,f as ie,r as $,g as O,u as re,al as le,A as V,e as oe,L as ce,B as N,M as de,an as ue}from"./index-BrT3F50e.js";import{b as A}from"./broadcast-DTyl9Ml3.js";import{l as pe}from"./list-8nSQBgxW.js";import{B as T,t as me}from"./task-D_2TjadH.js";import{l as xe}from"./segment-Bwak2QKo.js";import{f as ge,a as fe,c as he,b as ye,e as be,F as C,h as je,j as M,k as _e,l as ve,m as we}from"./index-aiUU9uK4.js";import{h as ke,k as Ce,f as Ne,a as H,c as Te,l as Se,i as Pe}from"./index-CERVQ99E.js";import{d as F,f as Ae,i as Be}from"./dayjs-CSchl2My.js";import{E as Fe,a as De,P as Re}from"./EmptyState-BsaFrTWq.js";import{g as $e}from"./messages_history-CRZ042o3.js";import{d as ze}from"./direct_messages-Bl2wA-_h.js";import{T as X}from"./index-JIFlWX-e.js";import{R as Ee}from"./PlusOutlined-B06sW5qS.js";import{A as qe}from"./index-DRrMmQ2c.js";import{I as Ie}from"./index-BI2D8MSW.js";import{P as Ke}from"./index-DG69r-Xk.js";import{S as We}from"./index-DDdNZ6K1.js";import{P as K}from"./index-DAk8RiMc.js";import{T as W}from"./index-KB2153Cz.js";import"./timezoneNormalizer-l1yj-VtS.js";import"./styleChecker-CI4V7a_h.js";import"./TextArea-BpydDq59.js";import"./getAllowClear-C4A34otO.js";import"./Input-DOcZa3u3.js";import"./gapSize-U1swVQyS.js";const k={sent:{description:"Total emails handed off to your email provider for sending."},delivered:{description:"Emails accepted by the recipient's mail server.",tip:"Keep your list clean of invalid addresses to maximize deliverability."},opens:{description:"Recipients who opened the email. Opens are tracked with an invisible pixel, so blocked images may hide some of them.",tip:"Test different subject lines and send when your audience actually reads mail."},clicks:{description:"Recipients who clicked at least one link in the email.",tip:"Use one clear call to action near the top of the email."},replies:{description:"Inbound direct messages received from recipients of this campaign."},failed:{description:"Emails that could not be sent â rejected before delivery because of an invalid address, a provider error or a rate limit.",tip:"Open the logs to see the exact error and re-check your provider settings."},bounced:{description:"Emails returned by the recipient server. Hard bounces mean the mailbox does not exist; soft bounces are temporary (full mailbox, server issues).",tip:"Remove hard-bounced addresses â a bounce rate above ~2% damages your sender reputation."},complaints:{description:"Recipients who marked the email as spam.",tip:"Send only to people who opted in and keep the unsubscribe link easy to find. Stay under 0.1%."},unsubscribed:{description:"Recipients who unsubscribed using the link in this email.",tip:"Match content to what subscribers signed up for and segment your audience."},subscribed:{description:"Recipients who subscribed (or re-subscribed) using the preferences link in this email.",tip:"Give people a reason to join â exclusive content, good content, etc."}},Le=1440*60*1e3,G="Open and click data may take up to 24 hours after sending";function Ye(t,o=Date.now()){if(!t)return!0;const x=new Date(t).getTime();return Number.isNaN(x)?!0:o-x<Le}const{Text:Qe}=X;function Me({heading:t,info:o}){return e.jsxs("div",{style:{maxWidth:280},children:[t&&e.jsx("div",{style:{fontWeight:600},children:t}),e.jsx("div",{style:{marginTop:t?4:0},children:o.description}),o.tip&&e.jsxs("div",{style:{marginTop:6,opacity:.85},children:["Tip: ",o.tip]})]})}function Ge({workspaceId:t,broadcastId:o,workspace:x,isMobile:n=!1,completedAt:j}){const u=ae(),w=Ye(j),{data:y,isLoading:p}=B({queryKey:["broadcast-stats",t,o],queryFn:async()=>$e(t,o),refetchInterval:6e4}),{data:c,isLoading:v}=B({queryKey:["direct-message-replies",t,o],queryFn:()=>ze.replies(t,o),refetchInterval:6e4}),s=y?.stats||{total_sent:0,total_delivered:0,total_opened:0,total_clicked:0,total_failed:0,total_bounced:0,total_complained:0,total_unsubscribed:0,total_subscribed:0},D=w&&s.total_opened===0,h=w&&s.total_clicked===0,r=(()=>{if(!x?.settings?.marketing_email_provider_id)return!1;const l=x.settings.marketing_email_provider_id;return x.integrations?.find(f=>f.id===l)?.email_provider?.kind==="smtp"})(),b=(l,d)=>{if(d===0)return"-";const f=l/d*100;return f===0||f>=10?`${Math.round(f)}
1%`:`${f.toFixed(1)}%`},a=l=>{const d=new URLSearchParams;d.set("broadcast_id",o),l!=="sent"&&d.set(l,"true");const f=`/workspace/${t}/logs?${d.toString()}`;u({to:f})},S=[{key:"sent",info:k.sent,icon:ge,iconColor:"text-blue-500",label:"Sent",value:p?null:String(s.total_sent),tooltip:`${s.total_sent} total emails sent`,onClick:()=>a("sent"),disabled:!1},{key:"delivered",info:k.delivered,icon:fe,iconColor:"text-green-500",label:"Delivered",value:p?null:r?"-":b(s.total_delivered,s.total_sent),tooltip:r?"SMTP provider doesn't support delivery webhooks":`${s.total_delivered} emails delivered`,onClick:()=>a("is_delivered"),disabled:r},{key:"opens",info:k.opens,icon:he,iconColor:"text-pink-500",label:"Opens",value:p?null:D?"â":b(s.total_opened,s.total_sent),tooltip:D?G:`${s.total_opened} total opens`,onClick:()=>a("is_opened"),disabled:D},{key:"clicks",info:k.clicks,icon:ke,iconColor:"text-violet-500",label:"Clicks",value:p?null:h?"â":b(s.total_clicked,s.total_sent),tooltip:h?G:`${s.total_clicked} total clicks`,onClick:()=>a("is_clicked"),disabled:h},{key:"replies",info:k.replies,icon:Ce,iconColor:"text-cyan-600",label:"Replies",value:v?null:String(c?.count??0),tooltip:`${c?.count??0} total replies`,onClick:()=>u({to:`/workspace/${t}/direct_messages?group_code=${encodeURIComponent(o)}&group_type=broadcast`}),disabled:v||(c?.count??0)===0},{key:"failed",info:k.failed,icon:ye,iconColor:"text-red-500",label:"Failed",value:p?null:b(s.total_failed,s.total_sent),tooltip:`${s.total_failed} emails failed`,onClick:()=>a("is_failed"),disabled:!1},{key:"bounced",info:k.bounced,icon:Ne,iconColor:"text-amber-500",label:"Bounced",value:p?null:r?"-":b(s.total_bounced,s.total_sent),tooltip:r?"SMTP provider doesn't support bounce webhooks":`${s.total_bounced} emails bounced`,onClick:()=>a("is_bounced"),disabled:r},{key:"complaints",info:k.complaints,icon:be,iconColor:"text-pink-500",label:"Complaints",value:p?null:r?"-":b(s.total_complained,s.total_sent),tooltip:r?"SMTP provider doesn't support complaint webhooks":`${s.total_complained} total complaints`,onClick:()=>a("is_complained"),disabled:r},{key:"unsub",info:k.unsubscribed,icon:H,iconColor:"text-green-600",label:"Unsub.",value:p?null:b(s.total_unsubscribed,s.total_sent),tooltip:`${s.total_unsubscribed} total unsubscribes`,onClick:()=>a("is_unsubscribed"),disabled:!1},{key:"sub",info:k.subscribed,icon:Te,iconColor:"text-emerald-600",label:"Sub.",value:p?null:b(s.total_subscribed,s.total_sent),tooltip:`${s.total_subscribed} total subscribes`,onClick:()=>a("is_subscribed"),disabled:!1}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:n?"repeat(2, 1fr)":"repeat(10, 1fr)",gap:n?6:8},children:S.map(l=>e.jsx(_,{title:e.jsx(Me,{heading:l.tooltip,info:l.info}),children:e.jsxs("div",{className:`bg-[#1C1D1F08] transition-colors ${l.disabled?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-gray-50"}`,style:{borderRadius:8,padding:"12px"},onClick:l.disabled?void 0:l.onClick,children:[e.jsxs("div",{className:"flex items-center gap-1.5",style:{marginBottom:6},children:[e.jsx(C,{icon:l.icon,className:l.iconColor,style:{fontSize:15}}),e.jsx(Qe,{style:{fontSize:16,fontWeight:500},children:l.label})]}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"#111827"},children:l.value===null?e.jsx(ne,{size:"small"}):l.value})]})},l.key))})}const{Text:Ue}=X,Oe=(t,o)=>{if(t.status!=="testing"||!t.test_settings.enabled||!t.test_settings.test_duration_hours)return null;const x=o?.test_started_at||t.test_sent_at;if(!x)return null;const j=F(x).add(t.test_settings.test_duration_hours,"hours"),u=F();return u.isAfter(j)?null:u.to(j,!0)+" remaining"},U=(t,o)=>t?(o?F(t).tz(o):F(t)).format("MMM D, h:mm A"):"",L=({broadcast:t,remainingTime:o})=>{const n={draft:{label:"Draft",className:"text-gray-500 bg-gray-100"},scheduled:{label:"Scheduled",className:"text-blue-600 bg-blue-50"},sending:{label:"In Progress",className:"text-green-600 bg-green-50"},paused:{label:"Paused",className:"text-amber-600 bg-amber-50"},sent:{label:"Completed",className:"text-white bg-green-500"},cancelled:{label:"Cancelled",className:"text-red-600 bg-red-50"},stopped:{label:"Stopped",className:"text-gray-700 bg-gray-200"},failed:{label:"Failed",className:"text-red-600 bg-red-50"},testing:{label:"A/B Testing",className:"text-violet-600 bg-violet-50"},test_completed:{label:"Test Completed",className:"text-green-600 bg-green-50"},winner_selected:{label:"Winner Selected",className:"text-green-600 bg-green-50"},paused_system:{label:"Paused by System",className:"text-blue-700 bg-blue-50 border border-blue-200"}}[t.status]||{label:t.status,className:"text-gray-500 bg-gray-100"},j=t.send_window?.timezone,u=t.send_window?.next_start,w=t.send_window?.next_pause,y=U(u,j),p=U(w,j),c=F(),v=!!u&&F(u).isAfter(c);return t.status==="sent"?(n.label="Completed",n.className="text-white bg-green-500"):t.status==="scheduled"&&y?(n.label=`Scheduled for ${y}`,n.className="text-gray-900 bg-[#FFBA00]"):t.status==="paused_system"&&y?(n.label=`Paused by system until ${y}`,n.className="text-blue-800 bg-blue-100"):t.status==="sending"&&(y||p)&&(v&&y?(n.label=`Resumes ${y}`,n.className="text-gray-900 bg-[#FFBA00]"):p&&(n.label=`In progress until ${p}`,n.className="text-white bg-blue-500")),e.jsxs(We,{size:"small",children:[e.jsx("span",{className:`text-xs font-semibold px-2.5 py-1 rounded-md inline-block ${n.className}`,children:n.label}),o&&e.jsxs("span",{className:"text-xs text-gray-400",children:["(",o,")"]}),t.status==="paused"&&t.pause_reason&&e.jsx(_,{title:t.pause_reason,children:e.jsx(C,{icon:M,className:"text-orange-500 cursor-help opacity-70 text-xs"})}),t.status==="paused_system"&&e.jsx(_,{title:"Broadcast was paused by the system due to reaching sending limits per day.",children:e.jsx(C,{icon:M,className:"text-orange-500 cursor-help opacity-70 text-xs"})}),t.metadata?.estimated_period&&e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(Estimate: ",t.metadata.estimated_period," ",t.metadata.estimated_period===1?"day":"days",")"]})]})},Ve=({broadcast:t,lists:o,segments:x,workspaceId:n,onDelete:j,onPause:u,onResume:w,onCancel:y,onRefresh:p,onStop:c,currentWorkspace:v,permissions:s,currentPage:D,pageSize:h,isMobile:r})=>{O();const{message:b}=V.useApp(),{data:a,isLoading:S}=B({queryKey:["task",n,t.id],queryFn:()=>me.findByBroadcastId(n,t.id),refetchInterval:t.status==="sending"?5e3:t.status==="scheduled"?3e4:!1}),{data:l}=B({queryKey:["testResults",n,t.id],queryFn:()=>A.getTestResults({workspace_id:n,id:t.id}),enabled:t.test_settings.enabled&&["testing","test_completed","winner_selected"].includes(t.status),refetchInterval:t.status==="testing"?1e4:!1}),d=Oe(t,l),f=m=>
1{switch(m){case"pending":return e.jsx(T,{status:"processing",text:"Pending"});case"running":return e.jsx(T,{status:"processing",text:"Running"});case"completed":return e.jsx(T,{status:"success",text:"Completed"});case"failed":return e.jsx(T,{status:"error",text:"Failed"});case"cancelled":return e.jsx(T,{status:"warning",text:"Cancelled"});case"paused":return e.jsx(T,{status:"warning",text:"Paused"});case"stopped":return e.jsx(T,{status:"default",text:"Stopped"});default:return e.jsx(T,{status:"default",text:m})}},E=()=>a?e.jsxs("div",{className:"max-w-xs",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"font-medium text-gray-500",children:"Status"}),e.jsx("div",{children:f(a.status)})]}),(a.progress>0||a.state?.send_broadcast)&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"font-medium text-gray-500",children:"Progress"}),e.jsx(ue,{percent:Math.round(a.state?.send_broadcast?a.state.send_broadcast.sent_count/a.state.send_broadcast.total_recipients*100:a.progress*100),size:"small"})]}),a.state?.message&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"font-medium text-gray-500",children:"Message"}),e.jsx("div",{children:a.state.message})]}),a.state?.send_broadcast&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"font-medium text-gray-500",children:"Broadcast Progress"}),e.jsxs("div",{className:"text-sm",children:["Sent: ",a.state.send_broadcast.sent_count," of"," ",a.state.send_broadcast.total_recipients,a.state.send_broadcast.failed_count>0&&e.jsxs("div",{className:"text-red-500",children:["Failed: ",a.state.send_broadcast.failed_count]})]})]}),a.type&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Task type: ",a.type]})]}):null,q=()=>t.audience.segments&&t.audience.segments.length>0?t.audience.segments.map(m=>{const g=x.find(R=>R.id===m);return g?e.jsx(W,{color:g.color,bordered:!1,className:"!m-0",children:g.name},g.id):e.jsx(W,{bordered:!1,className:"!m-0",children:"Unknown"},m)}):[e.jsx(W,{color:"blue",bordered:!1,className:"!m-0",children:"All Contacts"},"all")],z=m=>{if(!m)return"-";const g=v?.settings?.timezone,R=Ae(m,g,"lll");return Be(m,g)?e.jsx(_,{title:`${R} in ${g||"UTC"}`,children:e.jsx("span",{children:"Today"})}):e.jsx(_,{title:`${R} in ${g||"UTC"}`,children:e.jsx("span",{children:F(m).fromNow()})})},I=()=>{const m=[];if(t.status==="sending"||t.status==="paused_system"){const g=t.status==="paused_system";m.push(e.jsx(_,{title:s?.broadcasts?.write?g?"Keep paused":"Pause":"You don't have write permission for broadcasts",children:e.jsx(K,{title:g?"Keep broadcast paused?":"Pause broadcast?",description:g?"The broadcast will remain paused and will not auto-resume. You can resume it later.":"The broadcast will stop sending and can be resumed later.",onConfirm:()=>u(t),okText:g?"Yes, keep paused":"Yes, pause",cancelText:"Cancel",disabled:!s?.broadcasts?.write,children:e.jsx(N,{type:"text",size:"small",disabled:!s?.broadcasts?.write,children:e.jsx(C,{icon:_e,style:{opacity:.7}})})})},"pause"))}return t.status==="paused"&&m.push(e.jsx(_,{title:s?.broadcasts?.write?"Resume":"You don't have write permission for broadcasts",children:e.jsx(K,{title:"Resume broadcast?",description:"The broadcast will continue sending from where it was paused.",onConfirm:()=>w(t),okText:"Yes, resume",cancelText:"Cancel",disabled:!s?.broadcasts?.write,children:e.jsx(N,{type:"text",size:"small",disabled:!s?.broadcasts?.write,children:e.jsx(C,{icon:ve,style:{opacity:.7}})})})},"resume")),(t.status==="sending"||t.status==="paused"||t.status==="paused_system")&&m.push(e.jsx(_,{title:s?.broadcasts?.write?"Stop":"You don't have write permission for broadcasts",children:e.jsx(K,{title:"Stop broadcast?",description:"The broadcast will be stopped and cannot be resumed.",onConfirm:()=>c(t),okText:"Yes, stop",cancelText:"Cancel",disabled:!s?.broadcasts?.write,children:e.jsx(N,{type:"text",size:"small",disabled:!s?.broadcasts?.write,children:e.jsx(C,{icon:we,style:{opacity:.7}})})})},"stop")),t.status==="scheduled"&&m.push(e.jsx(_,{title:s?.broadcasts?.write?"Cancel":"You don't have write permission for broadcasts",children:e.jsx(N,{type:"text",size:"small",onClick:()=>y(t),disabled:!s?.broadcasts?.write,children:e.jsx(C,{icon:H,style:{opacity:.7}})})},"cancel")),m};return e.jsxs("div",{style:{borderRadius:r?12:20,backgroundColor:"#FAFAFA",marginBottom:r?12:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:r?"flex-start":"center",justifyContent:"space-between",padding:r?"12px 14px 8px":"20px 24px 12px",flexDirection:r?"column":"row",gap:r?6:0},children:[e.jsxs("div",{className:"flex items-center gap-2",style:{flexWrap:"wrap",minWidth:0},children:[e.jsx("span",{style:{fontSize:r?14:16,fontWeight:600,color:"#111827"},children:t.name}),a?e.jsx(Ke,{content:E,title:"Task Status",placement:"bottom",trigger:r?"click":"hover",children:e.jsx("span",{className:"cursor-help",children:e.jsx(L,{broadcast:t,remainingTime:d})})}):S?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(L,{broadcast:t,remainingTime:d}),e.jsx(C,{icon:Se,spin:!0,className:"text-gray-400",style:{fontSize:"12px"}})]}):e.jsx(L,{broadcast:t,remainingTime:d})]}),e.jsxs("div",{className:"flex items-center gap-1",style:{flexShrink:0,alignSelf:r?"flex-end":void 0,marginTop:r?-24:0},children:[I(),e.jsx(_,{title:"Refresh",children:e.jsx(N,{type:"text",size:"small",icon:e.jsx(C,{icon:Pe,style:{fontSize:"16px"}}),onClick:()=>p(t),className:"!text-[#1C1D1F] hover:!text-gray-600"})})]})]}),e.jsx("div",{style:{padding:r?"0 10px 10px":"0 16px 16px"},children:e.jsx(Ge,{workspaceId:n,broadcastId:t.id,workspace:v,isMobile:r,completedAt:t.completed_at})}),e.jsxs("div",{style:{display:"flex",alignItems:r?"flex-start":"center",justifyContent:"space-between",padding:r?"4px 14px 12px":"4px 24px 20px",flexDirection:r?"column":"row",gap:r?8:0},children:[e.jsxs("div",{className:"flex items-center gap-2",style:{flexWrap:"wrap"},children:[e.jsx("span",{className:"text-xs text-gray-400 font-medium",children:"Audience:"}),e.jsx("div",{className:"flex items-center gap-1.5",style:{flexWrap:"wrap"},children:q()})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",style:{flexWrap:"wrap"},children:[t.send_window&&e.jsxs("span",{title:t.send_window.timezone,children:[e.jsx("span",{className:"font-medium",children:"Window:"})," ",e.jsxs("span",{className:"font-semibold text-gray-700",children:[t.send_window.label," · ",t.send_window.timezone]})]}),t.started_at&&e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Started:"})," ",e.jsx("span",{className:"font-semibold text-gray-700",children:z(t.started_at)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Completed:"})," ",e.jsx("span",{className:"font-semibold text-gray-700",children:z(t.completed_at)})]})]})]})]})};function _t(){const{workspaceId:t}=ie({strict:!1}),[o,x]=$.useState(!1),[n,j]=$.useState(null),[u,w]=$.useState(""),[y,p]=$.useState(!1),[c,v]=$.useState(1),[s,D]=$.useState(10),h=O(),{workspaces:r}=re(),{permissions:b}=le(t),{message:a}=V.useApp(),S=oe(),l=r.find(i=>i.id===t),{data:d,isLoading:f}=B({queryKey:["broadcasts",t,c,s],queryFn:()=>A.list({workspace_id:t,with_templates:!0,limit:s,offset:(c-1)*s})}),{data:E}=B({queryKey:["lists",t],queryFn:()=>pe.list({workspace_id:t,with_templates:!0})}),q=E?.lists||[],{data:z}=B({queryKey:["segments",t],queryFn:()=>xe({workspace_id:t,with_count:!0})}),I=z?.segments||[],m=async()=>
1{if(n){p(!0);try{await A.delete({workspace_id:t,id:n.id}),a.success(`Broadcast "${n.name}" deleted successfully`),h.invalidateQueries({queryKey:["broadcasts",t,c,s]}),c>1&&d?.broadcasts.length===1&&v(c-1),x(!1),j(null),w("")}catch(i){a.error("Failed to delete broadcast"),console.error(i)}finally{p(!1)}}},g=async i=>{try{await A.pause({workspace_id:t,id:i.id}),a.success(`Broadcast "${i.name}" paused successfully`),h.invalidateQueries({queryKey:["broadcasts",t,c,s]})}catch(P){a.error("Failed to pause broadcast"),console.error(P)}},R=async i=>{try{await A.resume({workspace_id:t,id:i.id}),a.success(`Broadcast "${i.name}" resumed successfully`),h.invalidateQueries({queryKey:["broadcasts",t,c,s]})}catch(P){a.error("Failed to resume broadcast"),console.error(P)}},J=async i=>{try{await A.cancel({workspace_id:t,id:i.id}),a.success(`Broadcast "${i.name}" cancelled successfully`),h.invalidateQueries({queryKey:["broadcasts",t,c,s]})}catch(P){a.error("Failed to cancel broadcast"),console.error(P)}},Z=i=>{j(i),x(!0)},Y=()=>{x(!1),j(null),w("")},ee=i=>{h.invalidateQueries({queryKey:["broadcast-stats",t,i.id]}),h.invalidateQueries({queryKey:["task",t,i.id]}),h.invalidateQueries({queryKey:["testResults",t,i.id]}),h.invalidateQueries({queryKey:["broadcasts",t,c,s]}),a.success(`Broadcast "${i.name}" refreshed`)},te=async i=>{try{await A.stop({workspace_id:t,id:i.id}),a.success(`Broadcast "${i.name}" stopped successfully`),h.invalidateQueries({queryKey:["broadcasts",t,c,s]})}catch(P){a.error("Failed to stop broadcast"),console.error(P)}},se=!f&&d?.broadcasts&&d.broadcasts.length>0,Q=!f&&(!d?.broadcasts||d.broadcasts.length===0);return e.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[Q?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.jsx(Fe,{icon:e.jsx(De,{}),title:"No Campaigns Launched Yet",action:l?e.jsx(_,{title:b?.broadcasts?.write?void 0:"You don't have write permission for broadcasts",children:e.jsx(ce,{to:"/workspace/$workspaceId/create",params:{workspaceId:t},style:{textDecoration:"none"},children:e.jsx(N,{type:"primary",icon:e.jsx(Ee,{}),disabled:!b?.broadcasts?.write,style:{borderRadius:"10px"},children:"Create Campaign"})})}):void 0})}):e.jsxs("div",{className:"flex-1 overflow-auto",style:{padding:S?"16px 16px 0":"20px 20px 0"},children:[!l?.settings?.marketing_email_provider_id&&e.jsx(qe,{message:"Email Provider Required",description:"You don't have a marketing email provider configured. Please set up an email provider in your workspace settings to send broadcasts.",type:"warning",showIcon:!0,className:"!mb-6",action:e.jsx(N,{type:"primary",size:"small",href:`/workspace/${t}/settings/integrations`,children:"Configure Provider"})}),f?e.jsx("div",{className:"space-y-5",children:[1,2,3].map(i=>e.jsx("div",{className:"rounded-xl bg-[#F5F7FA] h-48 animate-pulse"},i))}):se?e.jsx("div",{children:d.broadcasts.map(i=>e.jsx(Ve,{broadcast:i,lists:q,segments:I,workspaceId:t,onDelete:Z,onPause:g,onResume:R,onCancel:J,onRefresh:ee,onStop:te,currentWorkspace:l,permissions:b,currentPage:c,pageSize:s,isMobile:S},i.id))}):e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"rgba(28, 29, 31, 0.4)"},children:"No broadcasts found"})]}),!Q&&e.jsx(Re,{totalItems:d?.total_count||0,currentPage:c,pageSize:s,onPageChange:v,onPageSizeChange:i=>{D(i),v(1)},loading:f,emptyLabel:"No broadcasts",isMobile:S}),e.jsx(de,{title:"Delete Broadcast",open:o,onCancel:Y,footer:[e.jsx(N,{onClick:Y,children:"Cancel"},"cancel"),e.jsx(N,{type:"primary",danger:!0,loading:y,disabled:u!==(n?.id||""),onClick:m,children:"Delete"},"delete")],children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:['Are you sure you want to delete the broadcast "',n.name,'"?']}),e.jsxs("p",{children:["This action cannot be undone. To confirm, please enter the broadcast ID:"," ",e.jsx(Ue,{code:!0,children:n.id}),e.jsx(_,{title:"Copy to clipboard",children:e.jsx(N,{type:"text",icon:e.jsx(C,{icon:je,style:{opacity:.7}}),size:"small",onClick:()=>{navigator.clipboard.writeText(n.id),a.success("Broadcast ID copied to clipboard")}})})]}),e.jsx(Ie,{placeholder:"Enter broadcast ID to confirm",value:u,onChange:i=>w(i.target.value),status:u&&u!==n.id?"error":""}),u&&u!==n.id&&e.jsx("p",{className:"text-red-500 mt-2",children:"ID doesn't match"})]})})]})}export{_t as BroadcastsPage};
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.