import{c as e,o as i,L as t,K as a,P as s,b as l,Q as r,as as n,R as o,a2 as h}from"./vendor.js?ver=3.1.0";import{_ as d}from"./fc-bits-ui.js?ver=3.1.0";const m={name:"PreviewIframeBuilder",props:{preview_html:{type:String,default:()=>""},campaign:{type:Object,default:()=>({})},campaign_id:{default:()=>0},frame_height:{type:String,default:()=>"500px"},show_audit:{type:Boolean,default:()=>!1}},data(){return{loading_preview:!0,invalidDoms:[],preview_full_html:this.preview_html}},methods:{loadFrame(){const e=this.$refs.fc_ifr;if(!e)return;const i=e.contentDocument||e.contentWindow&&e.contentWindow.document;i&&(i.open(),i.write(this.preview_full_html),i.close(),this.loading_preview=!1,this.checkDoms(this.preview_full_html))},fetchHtml(){this.loading_preview=!0,this.showing_view=!0,this.$post("campaigns/email-preview-html",{campaign_id:this.campaign_id,disable_subscriber:"yes"}).then(e=>{this.preview_full_html=e.preview_html,this.$nextTick(()=>this.loadFrame())}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading_preview=!1})},checkDoms(e){if(!this.show_audit)return;this.invalidDoms=[];const i=jQuery('a[href=""], a:not([href]), a[href="#"]',e);this.each(i,e=>{console.log(e),this.invalidDoms.push({text:e.text||"Empty Text / Image"})})}},mounted(){this.campaign_id?this.fetchHtml():this.loadFrame()}},c={class:"fc_iframe_wrap"},p={key:0},_={key:1,class:"el-alert el-alert--error is-light",style:{display:"block",overflow:"hidden",padding:"0 20px","margin-bottom":"0px"}},f={style:{"font-size":"16px"}},v={class:"inline_disc_lists"};const u=d(m,[["render",function(d,m,u,w,g,y){return i(),e("div",c,[g.loading_preview?(i(),e("h3",p,s(d.$t("Loading Preview. Please wait...")),1)):u.show_audit&&g.invalidDoms&&g.invalidDoms.length?(i(),e("div",_,[l("h3",f,s(d.$t("Invalid_Link_Detected"))+" ("+s(g.invalidDoms.length)+")",1),l("ul",v,[(i(!0),e(r,null,n(g.invalidDoms,(t,a)=>(i(),e("li",{key:a},s(t.text),1))),128))])])):t("",!0),a(l("iframe",{ref:"fc_ifr",frameborder:"0",scrolling:"auto",style:h([{width:"100%",border:"none",display:"block"},{height:u.frame_height}])},null,4),[[o,!g.loading_preview]])])}]]);export{u as P};
