UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

81 lines (80 loc) 2.58 kB
import ge from "./base-device-parser.js"; import { Browsers as oi, OperatingSystems as so } from "./device-constants.js"; export default class gi extends ge { constructor() { super(), (this.fd = gi.Bc(navigator.userAgent || "")); } ef() { return this.fd[0] || "Unknown Browser"; } ff() { return this.fd[1] || "Unknown Version"; } Ha(r) { for (let n = 0; n < r.length; n++) { const e = r[n].string; let i = gi.nf(e, r[n]); if (i) return ( i === so.Pg && navigator.maxTouchPoints > 1 && (i = so.co), Promise.resolve(i) ); } return Promise.resolve(navigator.platform); } static Bc(r) { let n, e = r.match( /(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i, ) || []; if (-1 !== r.indexOf("(Web0S; Linux/SmartTV)")) return ["LG Smart TV", null]; if (-1 !== r.indexOf("CrKey")) return ["Chromecast", null]; if ( -1 !== r.indexOf("BRAVIA") || -1 !== r.indexOf("SonyCEBrowser") || -1 !== r.indexOf("SonyDTV") ) return ["Sony Smart TV", null]; if (-1 !== r.indexOf("PhilipsTV")) return ["Philips Smart TV", null]; if (r.match(/\b(Roku)\b/)) return ["Roku", null]; if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null]; if ( e[1] === oi.rO && ((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)), null != n) ) return ( (n = n.slice(1)), (n[0] = n[0].replace("OPR", oi.oO)), (n[0] = n[0].replace("EdgA", oi.eO)), "Edg" === n[0] && (n[0] = oi.eO), [n[0], n[1]] ); if ( e[1] === oi.Bg && ((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n) ) return ( (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", oi.eO)), [n[0], n[1]] ); if ( ((e = e[2] ? [e[1], e[2]] : [null, null]), e[0] === oi.Bg && null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) && e.splice(1, 1, n[1]), null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) && e.splice(1, 1, n[2]), e[0] === oi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i))) ) return ["Opera Mini", n[1] || ""]; if (e[0]) { const r = e[0].toLowerCase(); "crios" === r && (e[0] = oi.rO), "tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)), "samsungbrowser" === r && (e[0] = "Samsung Browser"); } return e; } }