@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
24 lines (23 loc) • 713 B
JavaScript
import { logger as E } from "../../shared-lib/index.js";
import { BannerStrings as j } from "./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.Yt,
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.Jt()) &&
E.error(j.aa);
const t = i.o();
if (!t.P()) return null;
return getBannerIfNotExpired(t.k(), n);
}