1import{e as B,U as G,g as z,c,a as e,b as n,t as i,i as a,F as _,r as D,l as T,w,m as P,V,$ as J,p as f,j as Y,q as u,o as m,n as U,Z as q,d as H}from"./CkpukmhO.js";import{_ as Z}from"./dk8CUGDj.js";import"./DUgR6Z00.js";import"./Bm4_zX6v.js";const K={class:"flex h-full overflow-hidden"},Q={class:"flex-1 overflow-y-auto"},W={class:"max-w-2xl mx-auto px-4 md:px-8 py-6 space-y-0"},X={class:"flex items-center gap-3 mb-6"},ee={class:"border-b border-gray-100 py-5 flex items-start justify-between gap-4"},te={class:"text-sm text-gray-500"},se={class:"border-b border-gray-100 py-5 flex items-start justify-between gap-4"},ae={class:"text-sm text-gray-500"},le={class:"border-b border-gray-100 py-5 flex items-start justify-between gap-4"},oe={class:"text-sm text-gray-500"},ne={class:"border-b border-gray-100 py-5 flex items-start justify-between gap-4"},re={class:"flex-1 min-w-0"},ie={class:"text-sm text-gray-700 leading-relaxed flex flex-wrap items-center gap-1"},de={key:0,class:"inline-flex items-center px-2 py-0.5 bg-blue-100 text-blue-700 rounded text-xs font-medium"},ce={key:1,class:"text-gray-700 text-sm"},me={class:"mt-4 space-y-2"},ue={class:"text-sm text-gray-500"},ge={class:"text-sm text-gray-500"},pe={class:"border-b border-gray-100 py-5 flex items-start justify-between gap-4"},xe={key:0,class:"text-sm text-green-600 font-medium"},be={key:1,class:"text-sm text-gray-400"},fe={class:"pt-6"},ye={class:"divide-y divide-gray-100 border border-gray-100 rounded-xl overflow-hidden"},ve={class:"pt-4"},he={class:"flex items-start gap-3 p-4 bg-amber-50 border border-amber-200 rounded-xl"},_e={class:"sticky bottom-0 -mx-4 md:-mx-8 px-4 md:px-8 py-4 bg-white/90 backdrop-blur border-t border-gray-100 mt-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3"},we={class:"flex items-center gap-2"},Se={class:"hidden lg:flex w-72 xl:w-80 border-l border-gray-100 bg-gray-50 flex-col items-center justify-start pt-16 shrink-0"},ke={class:"relative w-52"},Ce={class:"bg-gray-900 rounded-[2.5rem] p-2.5 shadow-2xl"},Ie={class:"bg-white rounded-[2rem] overflow-hidden min-h-[28rem]"},Oe={class:"bg-gray-100 px-4 pt-3 pb-2 flex items-center justify-between"},De={class:"flex items-center gap-1"},Te={class:"bg-white px-3 py-2 border-b border-gray-100 flex items-center gap-2"},Ue={class:"text-[10px] font-semibold text-gray-800 leading-none"},Ne={class:"p-3 bg-gray-50 min-h-48"},Ae={class:"bg-white rounded-xl rounded-tl-none shadow-sm border border-gray-100 p-2.5 max-w-[90%]"},Me={class:"text-[10px] text-gray-700 leading-relaxed whitespace-pre-wrap break-words"},Re={key:0,class:"mt-3 bg-gray-100 rounded-xl rounded-tl-none p-2 max-w-[90%]"},Ee={class:"space-y-4"},$e={class:"flex justify-end gap-2 w-full"},je={key:0,class:"fixed bottom-6 right-6 bg-gray-900 text-white text-sm px-5 py-3 rounded-xl shadow-xl flex items-center gap-3 z-50"},Pe=B({__name:"review",setup(Fe){const N=G(),s=J({name:"",body:"",audience:"",abTesting:!1,scheduled:!1,scheduleDate:"",scheduleTime:"",timezone:"Africa/Lagos",smartSending:"enable",followUp:!1,followUpBody:"",includeOptOut:!0,imageUrl:null,reachCount:0});z(()=>{try{const l=localStorage.getItem("txtcart_campaign_draft");l&&Object.assign(s,JSON.parse(l))}catch{}});const A=u(()=>{const l=s.body||"",t=[],o=/(\{\{[^}]+\}\})/g;let d=0,g;for(;(g=o.exec(l))!==null;){g.index>d&&t.push({type:"text",text:l.slice(d,g.index)});const r=g[1].replace(/\{\{|\}\}/g,"").replace(/_/g," ").replace(/\b\w/g,h=>h.toUpperCase());t.push({type:"var",text:r}),d=g.index+g[1].length}return d<l.length&&t.push({type:"text",text:l.slice(d)}),t}),M=u(()=>(s.reachCount??0).toLocaleString()),S=u(()=>{const l=s.includeOptOut!==!1?` 2 3Reply STOP to opt out: kartbeam.com/u?t=abc123`:"";return((s.body??"")+l).length}),y=u(()=>Math.max(1,Math.ceil(S.value/160))),k=u(()=>s.imageUrl?s.reachCount??0:0),R=u(()=>s.imageUrl?0:s.reachCount??0),v=u(()=>s.reachCount??0),E=u(()=>v.value*4*y.value),$=u(()=>[{label:"Message Per Recipient",value:"1"},{label:"SMS Count",value:y.value},{label:"SMS Recipients",value:R.value.toLocaleString()},{label:"MMS Recipients",value:k.value>
30?k.value.toLocaleString():"â"},{label:"Total Recipients",value:v.value.toLocaleString()},{label:"Estimated Cost",value:`â¦${E.value.toLocaleString()}`,bold:!0}]),j=u(()=>(s.body??"").replace(/\{\{first_name\}\}/g,"Amaka").replace(/\{\{last_name\}\}/g,"Okafor").replace(/\{\{site_name\}\}/g,"Your Store NG").replace(/\{\{site_url\}\}/g,"yourstore.ng").replace(/\{\{discount_code\}\}/g,"SALE20").replace(/\{\{discount_value\}\}/g,"20%").replace(/\{\{discount_url\}\}/g,"yourstore.ng/discount/SALE20")),p=f(!1),C=f();function F(){C.value?.click()}function L(l){const t=l.target.files?.[0];if(!t)return;const o=new FileReader;o.onload=()=>{s.imageUrl=o.result,p.value=!1,O("Image attached!")},o.readAsDataURL(t)}const x=f(""),b=f("");async function I(l){x.value=l==="DRAFT"?"draft":"send";const t={name:s.name,body:s.body,segment:s.audience||"all",status:l,scheduledAt:s.scheduled?`${s.scheduleDate}T${s.scheduleTime}`:null,smartSending:s.smartSending,includeOptOut:s.includeOptOut,imageUrl:s.imageUrl};await $fetch("/api/campaigns",{method:"POST",body:t}).catch(()=>{});try{const o=JSON.parse(localStorage.getItem("txtcart_campaigns")??"[]");o.unshift({id:crypto.randomUUID(),...t,sentAt:l==="SENDING"?new Date().toISOString():null,recipients:v.value,createdAt:new Date().toISOString(),_local:!0}),localStorage.setItem("txtcart_campaigns",JSON.stringify(o)),localStorage.removeItem("txtcart_campaign_draft")}catch{}x.value="",O(l==="DRAFT"?`"${s.name}" saved as draft`:`"${s.name}" is being sent!`),setTimeout(()=>N.push("/dashboard/campaigns"),1800)}function O(l){b.value=l,setTimeout(()=>{b.value=""},4e3)}return(l,t)=>{const o=Y,d=q,g=Z;return m(),c("div",K,[e("div",Q,[e("div",W,[e("div",X,[n(o,{to:"/dashboard/campaigns/create",variant:"ghost",color:"neutral",icon:"i-lucide-arrow-left",size:"sm"}),t[5]||(t[5]=e("h1",{class:"text-xl font-bold text-gray-900"},"Campaign Overview",-1))]),e("div",ee,[e("div",null,[t[6]||(t[6]=e("p",{class:"text-sm font-semibold text-gray-900 mb-1"},"Campaign Name",-1)),e("p",te,i(a(s).name||"Untitled Campaign"),1)]),n(o,{to:"/dashboard/campaigns/create",color:"neutral",variant:"ghost",label:"Edit",size:"sm"})]),e("div",se,[e("div",null,[t[7]||(t[7]=e("p",{class:"text-sm font-semibold text-gray-900 mb-1"},"Target Audience / Segment",-1)),e("p",ae,i(a(s).audience||"All customers")+" ("+i(a(M))+") ",1)]),n(o,{to:"/dashboard/campaigns/create",color:"neutral",variant:"ghost",label:"Edit",size:"sm"})]),e("div",le,[e("div",null,[t[8]||(t[8]=e("p",{class:"text-sm font-semibold text-gray-900 mb-1"},"A/B testing",-1)),e("p",oe,i(a(s).abTesting?"Enabled":"Disabled"),1)]),n(o,{to:"/dashboard/campaigns/create",color:"neutral",variant:"ghost",label:"Edit",size:"sm"})]),e("div",ne,[e("div",re,[t[11]||(t[11]=e("p",{class:"text-sm font-semibold text-gray-900 mb-2"},"Text Message",-1)),e("div",ie,[(m(!0),c(_,null,D(a(A),(r,h)=>(m(),c(_,{key:h},[r.type==="var"?(m(),c("span",de,i(r.text),1)):(m(),c("span",ce,i(r.text),1))],64))),128))]),e("div",me,[e("div",null,[t[9]||(t[9]=e("p",{class:"text-sm font-semibold text-gray-900"},"SMS Count",-1)),e("p",ue,i(a(y)),1)]),e("div",null,[t[10]||(t[10]=e("p",{class:"text-sm font-semibold text-gray-900"},"Characters",-1)),e("p",ge,i(a(S))+" / 1600",1)])])]),n(o,{to:"/dashboard/campaigns/create",color:"neutral",variant:"ghost",label:"Edit",size:"sm",class:"shrink-0"})]),e("div",pe,[e("div",null,[t[12]||(t[12]=e("p",{class:"text-sm font-semibold text-gray-900 mb-1"},"Attach Image or GIF",-1)),a(s).imageUrl?(m(),c("p",xe,"Image attached")):(m(),c("p",be,"No image selected"))]),n(o,{color:"neutral",variant:"ghost",label:"Edit",size:"sm",onClick:t[0]||(t[0]=r=>p.value=!0)})]),e("div",fe,[t[13]||(t[13]=e("h2",{class:"text-base font-bold text-gray-900 mb-4"},"Campaign Data",-1)),e("div",ye,[(m(!0),c(_,null,D(a($),r=>(m(),c("div",{key:r.label,class:"flex items-center justify-between px-4 py-3.5 bg-white"},[e("span",{class:U(["text-sm text-gray-600",r.bold?"font-bold text-gray-900":""])},i(r.label),3),e("span",{class:U(["text-sm font-semibold",r.bold?"font-bold text-gray-900":"text-gray-700"])},i(r.value),3)]))),128))])]),e("div",ve,[e("div",he,[n(d,{name:"i-lucide-triangle-alert",class:"w-4 h-4 text-amber-600 shrink-0 mt-0.5"}),t[14]||(t[14]=e("div",{class:"text-sm text-amber-800"},[e("p",{class:"font-semibold mb-0.5"},"Before you send"),e("p",{class:"text-xs text-amber-700"},"Make sure your message is compliant with NDPC/NITDA regulations. All subscribers will receive an opt-out link.")],-1))])]),e("div",_e,[n(o,{to:"/dashboard/campaigns/create",color:"neutral",variant:"ghost",label:"Back to Edit",icon:"i-lucide-arrow-left"}),e("div",we,[n(o,{color:"neutral",variant:"outline",icon:"i-lucide-file-text",label:"Save Draft",loading:a(x)==="draft",onClick:t[1]||(t[1]=r=>I("DRAFT"))},null,8,["loading"]),n(o,{color:"primary",icon:a(s).scheduled?"i-lucide-calendar":"i-lucide-send",label:a(s).scheduled?"Confirm & Schedule":"C
3onfirm & Send Now",loading:a(x)==="send",disabled:!a(s).body,onClick:t[2]||(t[2]=r=>I(a(s).scheduled?"SCHEDULED":"SENDING"))},null,8,["icon","label","loading","disabled"])])])])]),e("div",Se,[t[24]||(t[24]=e("p",{class:"text-xs font-semibold text-gray-400 uppercase tracking-widest mb-8"},"Preview",-1)),e("div",ke,[e("div",Ce,[e("div",Ie,[e("div",Oe,[t[15]||(t[15]=e("span",{class:"text-[9px] font-bold text-gray-700"},"9:41",-1)),t[16]||(t[16]=e("div",{class:"w-16 h-4 bg-gray-900 rounded-full"},null,-1)),e("div",De,[n(d,{name:"i-lucide-signal",class:"w-2.5 h-2.5 text-gray-700"}),n(d,{name:"i-lucide-wifi",class:"w-2.5 h-2.5 text-gray-700"}),n(d,{name:"i-lucide-battery-full",class:"w-2.5 h-2.5 text-gray-700"})])]),e("div",Te,[t[18]||(t[18]=e("div",{class:"w-7 h-7 rounded-full bg-green-100 flex items-center justify-center text-[10px] font-bold text-green-700"},"S",-1)),e("div",null,[e("p",Ue,i(a(s).name||"Your Store NG"),1),t[17]||(t[17]=e("p",{class:"text-[8px] text-gray-400 mt-0.5"},"SMS · Business",-1))])]),e("div",Ne,[e("div",Ae,[e("p",Me,i(a(j)||"Your message will appear hereâ¦"),1)]),t[20]||(t[20]=e("p",{class:"text-[8px] text-gray-300 mt-1.5 ml-1"},"Delivered â",-1)),a(s).includeOptOut!==!1?(m(),c("div",Re,[...t[19]||(t[19]=[e("p",{class:"text-[9px] text-gray-400"},"Reply STOP to opt out: kartbeam.com/u?t=abc123",-1)])])):T("",!0)])])]),t[21]||(t[21]=e("div",{class:"absolute -left-1.5 top-20 w-1 h-10 bg-gray-700 rounded-l-full"},null,-1)),t[22]||(t[22]=e("div",{class:"absolute -left-1.5 top-32 w-1 h-8 bg-gray-700 rounded-l-full"},null,-1)),t[23]||(t[23]=e("div",{class:"absolute -right-1.5 top-24 w-1 h-12 bg-gray-700 rounded-r-full"},null,-1))])]),n(g,{open:a(p),"onUpdate:open":t[4]||(t[4]=r=>P(p)?p.value=r:null),title:"Attach Image or GIF",ui:{content:"max-w-md"}},{body:w(()=>[e("div",Ee,[e("div",{class:"border-2 border-dashed border-gray-200 rounded-xl p-8 text-center hover:border-green-300 transition-colors cursor-pointer",onClick:F},[n(d,{name:"i-lucide-image-plus",class:"w-10 h-10 text-gray-300 mx-auto mb-3"}),t[25]||(t[25]=e("p",{class:"text-sm font-semibold text-gray-600"},"Click to upload image or GIF",-1)),t[26]||(t[26]=e("p",{class:"text-xs text-gray-400 mt-1"},"PNG, JPG, GIF up to 5MB",-1)),e("input",{ref_key:"fileInput",ref:C,type:"file",accept:"image/*,.gif",class:"hidden",onChange:L},null,544)]),t[27]||(t[27]=e("p",{class:"text-xs text-gray-400 text-center"},"Adding an image converts this to MMS (higher cost per message)",-1))])]),footer:w(()=>[e("div",$e,[n(o,{color:"neutral",variant:"ghost",label:"Cancel",onClick:t[3]||(t[3]=r=>p.value=!1)})])]),_:1},8,["open"]),n(V,{"enter-active-class":"transition-all duration-300","enter-from-class":"translate-y-4 opacity-0","leave-active-class":"transition-all duration-200","leave-to-class":"translate-y-4 opacity-0"},{default:w(()=>[a(b)?(m(),c("div",je,[n(d,{name:"i-lucide-check-circle",class:"w-5 h-5 text-green-400 shrink-0"}),H(" "+i(a(b)),1)])):T("",!0)]),_:1})])}}});export{Pe 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.