import{_ as x}from"./WebProcessingSpinner-DZLVOY48.mjs";import{_ as k}from"./WebPager-IBVEaT-v.mjs";import{_ as v,d as r,e as a,f as t,F as m,z as y,q as h,g as _,h as i,j as C,t as u,r as S,x as b,T,C as N,N as W}from"#entry";import"./Pager-CB4_LMaG.mjs";const F={props:{templates:{type:Array,required:!0},showPager:{type:Boolean,default:!1}},data(){return{currTemplates:this.templates,currPage:1,processing:!1}},computed:{useConvertUtcTimeToLocalDate(){return W},itemsPerPage(){return 20}},methods:{hasNextPage(s){return s?.campaigns?.pageInfo?.hasNextPage},async getPage(s,n){this.processing=!0;const o={templateId:this.currTemplates[s].id,omedaStatus:["Sent","Sending"],sortOrder:"desc",limit:this.itemsPerPage,skip:(n-1)*this.itemsPerPage,hideOnWeb:!1},d=await this.$gql.queryStream("getNewsletterCampaignStream",o);d.error?this.currTemplates[0].campaigns={items:[]}:(this.currTemplates[s].campaigns={...d.data},this.currPage=n),this.processing=!1}}},B={class:"web-newsletter-campaigns-wrapper"},V={key:0,style:{maxWidth:"630px"}},q=["src"],j={key:1,style:{maxWidth:"630px"}},D=["src"],L={key:2},O={style:{height:"75px",width:"calc(100% - 250px)",padding:"5px 10px"}},M=["src"],z={class:"campaigns"},U=["href"],E={class:"date"},A={class:"actions"},I=["href"],R={key:0,class:"divider"},G=["href"];function H(s,n,o,d,g,l){const p=x,w=k,P=T;return a(),r("div",B,[t("div",{class:N(["web-newsletter-campaigns",g.currTemplates.length>1?"multi":""])},[(a(!0),r(m,null,y(g.currTemplates,(e,f)=>(a(),r("div",{key:e.id,class:"template"},[t("div",{class:"content",style:h({fontFamily:s.$ss.general.primaryFontFamily})},[o.showPager?(a(),_(p,{key:0,processing:g.processing},null,8,["processing"])):i("",!0),t("div",{class:"heading",style:h({backgroundColor:e.header.backgroundColor})},[e.header.headerStyle.style===1?(a(),r("div",V,[t("img",{src:e.header.headerStyle.style1Settings.image,alt:"newsletter header style 1",style:{maxWidth:"100%"}},null,8,q)])):i("",!0),e.header.headerStyle.style===2?(a(),r("div",j,[t("img",{src:e.header.headerStyle.style2Settings.image,alt:"newsletter header style 2",style:{maxWidth:"100%"}},null,8,D)])):i("",!0),e.header.headerStyle.style===3?(a(),r("div",L,[t("table",{style:h({width:"100%",backgroundColor:e.header.backgroundColor})},[t("tbody",null,[t("tr",null,[t("td",O,[t("h1",{style:h({color:e.header.headerStyle.style3Settings.nameColor,fontFamily:e.styles.primaryFontFamily})},u(e.name),5)]),t("td",{style:h({height:"75px",padding:"10px",width:"120px",background:e.header.headerStyle.style3Settings.logoBackgroundColor})},[t("img",{src:e.header.headerStyle.style3Settings.image,alt:"newsletter header style 3",width:120},null,8,M)],4)])])],4)])):i("",!0)],4),t("div",z,[(a(!0),r(m,null,y(e.campaigns.items,c=>(a(),r("div",{key:c.id,class:"campaign"},[t("a",{target:"_blank",href:`/newsletter/${c.id}`,class:"link"},[t("span",E,u(l.useConvertUtcTimeToLocalDate(c.deploymentDate,"MMM d, yyyy")),1),S(u(c.subject),1)],8,U)]))),128))]),C(P,null,{default:b(()=>[o.showPager&&e.campaigns.totalCount>l.itemsPerPage?(a(),_(w,{key:0,"active-page":g.currPage,"total-count":e.campaigns.totalCount,"items-per-page":l.itemsPerPage,onChangeValue:c=>l.getPage(f,c)},null,8,["active-page","total-count","items-per-page","onChangeValue"])):i("",!0)]),_:2},1024),t("div",A,[t("a",{href:`/latest-newsletter/${e.id}`,target:"_blank"},"Latest Edition",8,I),!o.showPager&&l.hasNextPage(e)?(a(),r("span",R,"|")):i("",!0),!o.showPager&&l.hasNextPage(e)?(a(),r("a",{key:1,href:`/newsletters/${e.id}`},"View More",8,G)):i("",!0)])],4)]))),128))],2)])}const J=Object.assign(v(F,[["render",H]]),{__name:"WebNewsletterCampaigns"}),Z={__name:"NewsletterCampaignsBlock",props:{data:{type:Object,required:!0,validator(s){return["templates"].every(n=>n in s)}},settings:{type:Object,required:!0,validator(s){return["showPager"].every(n=>n in s)}}},setup(s){return(n,o)=>{const d=J;return a(),_(d,{templates:s.data.templates,"show-pager":s.settings.showPager},null,8,["templates","show-pager"])}}};export{Z as default};