@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
23 lines (22 loc) • 726 B
JavaScript
import { logger as E } from "../../shared-lib/index.js";
import { BANNERS_DISABLED_MESSAGE as v } from "../common/constants.js";
import r from "../managers/braze-instance.js";
import i from "./banner-provider-factory.js";
export function getBannerIfNotExpired(n, r) {
const e = n[r];
if (!e) return null;
const t = e.zt,
o = new Date().valueOf();
return -1 !== t && 1e3 * t < o
? (E.info(`Banner with ID: ${e.id} and placement ID: ${r} has expired.`),
null)
: e;
}
export function getBanner(n) {
var e;
if (!r.rr()) return;
!1 === (null === (e = r.l()) || void 0 === e ? void 0 : e.Dt()) && E.error(v);
const t = i.o();
if (!t.k()) return null;
return getBannerIfNotExpired(t.ht(), n);
}