1import{a1 as S,m as D,dv as T,dg as y,dw as p,c_ as s,cB as k,cw as _,e as A,dx as w,f as O,d0 as $,c$ as M,_ as L,M as g,N as f,aJ as N,aK as P,aA as b,a5 as U}from"./CqWH0BZP.js";import{C as B}from"./DestWLa6.js";import"./BoA7liN9.js";s.extend($);s.extend(M);const j=S({data(){return{images:[this.getImageUrl(),""],index:0,timeCompleted:!1,imageUpdateInterval:null,imageUpdateTimeouts:[],resolvedRedirectUrl:""}},setup(){const e=_(),t=A(),a=O();return{previewStore:t,config:a,route:e}},props:{element:{type:Object,required:!0}},mounted(){this.element?.extra?.countdownTimerId?.value!=="none"&&this.initializeImageRefreshCycle()},beforeUnmount(){this.element?.extra?.countdownTimerId?.value!=="none"&&this.cleanupImageRefreshCycle()},methods:{cleanupImageRefreshCycle(){this.imageUpdateInterval&&clearInterval(this.imageUpdateInterval),this.imageUpdateTimeouts.forEach(e=>{clearTimeout(e)})},initializeImageRefreshCycle(){if(this.imageUpdateInterval=k(this.updateImages,6e4),this.setExpireAction().catch(()=>{}),this.element.extra.timerType.value===p.RECURRING){const e=this.element.extra.timezone.value,t=s(this.element.extra.startDate.value).tz(e),a=this.element.extra.timerLoop.value,{days:i,hours:d,minutes:l,seconds:m}=this.element.extra.timerDuration.value,r=[t];for(let o=1;o<=a;o++){const u=t.clone().add(i*o,"days").add(d*o,"hours").add(l*o,"minutes").add(m*o,"seconds");r.push(u)}const h=s().tz(e);r.forEach(o=>{if(o.isAfter(h)){const u=setTimeout(this.updateImages,o.diff(h));this.imageUpdateTimeouts.push(u)}})}},getTimerId(){return this.element.extra.countdownTimerId.value},getContact(){return this.route.query?.contact_id},getImageUrl(){const e=T(),t=w(e)?"true":"false",a=this.getContact();return`${this.config.public.REST_API_URLS}/countdown-timer/render/${this.getTimerId()}?source=FUNNELS&isPreview=${t}${a?`&uniqueId=${a}`:""}`},async getEndTime(){let e=this.element.extra.endDate.value,t=this.element.extra.timezone.value;t==="Asia/Calcutta"&&(t="Asia/Kolkata");const a=this.getContact(),i=this.element.extra.timerType.value,d=this.getTimerId();if(d){const o=T(),u=w(o);try{const n=await B.getCountdownTimerById(d,this.previewStore.locationId,u,a);n.timezone==="Asia/Calcutta"&&(n.timezone="Asia/Kolkata");const C=this.element.extra.redirectUrl?.value;if(n.trackingLink&&y(C)&&(this.resolvedRedirectUrl=n.trackingLink),i===p.DYNAMIC){t=n.timezone;let c=s(n.endDate);if(u){const{days:x,hours:z,minutes:R,seconds:E}=n.timerDuration,I=s.utc().add(x,"days").add(z,"hours").add(R,"minutes").add(E,"seconds");if(n.dynamicTimerParams?.endTime){const v=s.utc(n.dynamicTimerParams.endTime,"hh:mm A");c=I.clone().hour(v.get("hours")).minute(v.get("minutes")).second(0)}c.isBefore(I)&&(c=c.add(1,"day")),c=c.tz(n.timezone),e=c.toISOString()}else e=s(n.endDate).toISOString()}else n.adaptToContactTimezone===!0&&(t=n.timezone,i===p.FIXED&&n.endDate?e=s(n.endDate).toISOString():i===p.RECURRING&&n.endDate&&(e=s(n.endDate).toISOString()))}catch{y(this.element.extra.redirectUrl?.value)}}const l=s(e).tz(t).valueOf(),m=s().tz(t).valueOf(),r=l-m;return r>0?Math.min(r,2147483647):0},updateImages(){let e=(this.index+1)%this.images.length;this.images[e]=this.getImageUrl()},updateImageFrame(e,t){this.images[e]===t&&(this.index=e,this.images=this.images.map((a,i)=>i===e?a:""))},async setExpireAction(){const e=await this.getEndTime();setTimeout(()=>{this.timeCompleted=!0;const{expireAction:t,redirectUrl:a}=this.element.extra;switch(t.value){case"url":{let i=this.resolvedRedirectUrl||a.value;if(!i||i==="#")return;i=D(i),/^https?:/.test(i)||(i=`https://${i}`);const d=window.location.href.split("?")[0],l=i.split("?")[0];if(d===l)return;window.location.replace(i);break}}},e)}}}),F={key:0,class:"flex w-full justify-center relative"},V=["src","onLoad"];function q(e,t,a,i,d,l){return!e.timeCompleted&&e.element.extra.countdownTimerId.value!=="none"?(g(),f("div",F,[(g(!0),f(N,null,P(e.images,(m,r)=>(g(),f("div",{key:r},[m?(g(),f("img",{key:0,loading:"lazy",src:m,alt:"",onLoad:h=>e.updateImageFrame(r,m),style:b({position:r!==e.index?"absolute":"static",opacity:r!==e.index?0:1,zIndex:r!==e.index?-1:"auto"})},null,44,V)):U("",!0)]))),128))])):U("",!0)}const W=Object.assign(L(j,[["render",q]]),{__name:"PreviewElementsMarketingCountdown"});export{W 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.