UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

48 lines (47 loc) 1.27 kB
import ne, { STORAGE_KEYS as s } from "./storage-manager.js"; import { logger as E } from "../../shared-lib/index.js"; const Zt = { rl: function (o, t = !1, e) { const r = Zt.Sc(), a = Zt.sl(), n = new ne.Ec(o, r && !t, a, e); let c; return (c = a ? new ne.wc(o) : new ne.Rc()), new ne(n, c); }, Sc: function () { return ( navigator.cookieEnabled || ("cookie" in document && (document.cookie.length > 0 || (document.cookie = "test").indexOf.call(document.cookie, "test") > -1)) ); }, sl: function () { let o = !1; try { if (localStorage && localStorage.getItem) try { localStorage.setItem(s.Tt._c, "true"), localStorage.getItem(s.Tt._c) ? (localStorage.removeItem(s.Tt._c), (o = !0)) : (o = !1); } catch (t) { if ( !( t instanceof Error && ("QuotaExceededError" === t.name || "NS_ERROR_DOM_QUOTA_REACHED" === t.name) && localStorage.length > 0 ) ) throw t; o = !0; } } catch (o) { E.info("Local Storage not supported!"); } return o; }, }; export default Zt;