!function() { var e, t, n, r, a, i, o, c, s, u, d, l, p, g, f, m, v, h, I, E, x, S, y; return S = {localStorage: this.localStorage ? !0 : !1,postMessage: this.postMessage ? !0 : !1}, S.localStorage || (this.localStorage = {setItem: function() { },getItem: function() { },removeItem: function() { }}, this.sessionStorage = {setItem: function() { },getItem: function() { },removeItem: function() { }}), o = this.localStorage, d = this.sessionStorage, y = function() { var e, t, n; return e = (new Date).getTime(), t = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = t.replace(/[xy]/g, function(t) { var n; return n = (e + 16 * Math.random()) % 16 | 0, e = Math.floor(e / 16), "x" === t ? n.toString(16) : (7 & n | 8).toString(16) }), n.replace(/-/g, "").toUpperCase() }, t = {get: function(e) { var t, n; return n = "(^|;)\\s*" + e + "=([^;\\s]*)", t = document.cookie.match(new RegExp(n)), t && t.length >= 3 ? decodeURIComponent(t[2]) : null },set: function(e, t, n, r, a, i) { var o, c, s, u, d; return n && (o = new Date, o.setTime(o.getTime() + 864e5 * n)), s = n ? "; expires=" + o.toGMTString() : "", u = "; path=" + (a || "/"), c = r ? "; domain=" + r : "", d = i ? "; secure" : "", document.cookie = e + "=" + encodeURIComponent(t) + s + u + c + d },remove: function(e, n, r) { return t.set(e, "", -1, n, r) }}, v = function(e) { return "[object Object]" === Object.prototype.toString.call(e) }, g = Array.prototype.every, g || (g = function(e) { var t, n, r, a; for (n = !0, r = 0, a = this.length; a > r; r++) if (t = this[r], !e(t)) return !1; return n }), f = function(e) { var t, n, r; for (t in e) r = e[t], e[t] = r; return n = arguments.length >= 2 ? [].slice.call(arguments, 1) : [], n.forEach(function(n) { var a; a = []; for (t in n) r = n[t], a.push(e[t] = r); return a }), e }, x = {API_PATH: "http://rd.gdatacube.net/dc/html5/sync",PROXY: "http://rd.gdatacube.net/dc/html5/whoami",CLIENT_KEY: "dcagent_client_id",VERSION_NUMBER: "9",appId: "",deviceId: "",accountId: "",channel: "",appVer: "",interval: 10,intervalCount: 0,initialized: !1,loginTime: 0,timer: 0}, l = {max: 100,count: 0,excludes: [],isReportAllowed: function(e) { var t; return l.count < l.max ? t = g.call(l.excludes, function(t) { return -1 === e.indexOf(t) }) : void 0 }}, I = {succ: 0,fail: 0,total: 0}, s = "_DESelf_OSS", h = [], E = function(e, t) { var n, r, a, i, o, c, u, d; if (e.data) { (null != (u = e.data.errors) ? u.length : void 0) > l.max && (e.data.errors = e.data.errors.slice(0, 100)), d = e.data; for (n in d) o = d[n], "number" == typeof o && (a[n] = String(o)); if (a = f({headers: m.getBaseSettings()}, e.data), x.debug) return x.debug(x.API_PATH, a); if (r = Math.abs(x.onlinetime), !(r > 864e3 || 0 >= r)) return c = new XMLHttpRequest, c.timeout = 3e4, c.open("POST", t || x.API_PATH, !0), c.setRequestHeader("Content-Type", "text/plain; charset=UTF-8"), i = Date.now(), c.onreadystatechange = function(t) { var n, r, a; return r = this.status >= 200 && this.status < 300, 4 === this.readyState ? (n = Date.now() - i, a = r && "success" === this.responseText, a ? (I.succ = 1, I.fail = 0, I.total = n) : (I.fail += 1, I.succ = 0, I.total += n), p.updateEvents({eventid: s,labelmap: JSON.stringify(I),duration: "1"}), a ? "function" == typeof e.success ? e.success(t) : void 0 : "function" == typeof e.fail ? e.fail(t) : void 0) : void 0 }, c.ontimeout = function() { return I.fail += 1, I.succ = 0, I.total += elapsed, p.updateEvents({eventid: s,labelmap: JSON.stringify(I),duration: "1"}) }, c.send(JSON.stringify(a)) } }, a = "dcagent_client_events", r = "dcagent_client_errors", c = "dcagent_parent_id", e = "dcagent_create_time", u = "dcagent_login_time", i = "dcagent_interval_key", p = {getEvents: function() { return function() { var e; return e = o.getItem(a), e ? JSON.parse(e) : [] } }(this),getErrors: function() { return function() { var e; return e = o.getItem(r), e ? JSON.parse(e) : [] } }(this),updateEvents: function() { return function(e, t) { var n, r, i, c; if (null == t && (t = !0), n = p.getEvents(), Array.isArray(e)) for (i = 0, c = e.length; c > i; i++) r = e[i], n.push(r); else n.push(e); return S.localStorage && t ? o.setItem(a, JSON.stringify(n.slice(0, l.max))) : E({data: {events: n}}) } }(this),updateErrors: function() { return function(e) { var t, n, a, i; if (t = p.getErrors(), Array.isArray(e)) for (a = 0, i = e.length; i > a; a++) n = e[a], t.push(n); else t.push(e); return S.localStorage ? o.setItem(r, JSON.stringify(t.slice(0, l.max))) : E({data: {errors: t}}) } }(this),clear: function() { return function() { return o.removeItem(a), o.removeItem(r) } }(this)}, m = {set: function(e, n) { return null == n && (n = y()), localStorage.setItem(e, n), t.set(e, n, 365), n },get: function(e) { return localStorage.getItem(e) || t.get(e) },getBaseSettings: function() { var t; if (!x.appId) throw new Error("InitError: missing appId"); if (!x.accountId) throw new Error("AccountError: unknown accountId"); if (!x.deviceId) throw new Error("DeviceError: unknown device"); return t = x.intervalCount * x.interval / 1e3 || 1, {appid: x.appId,accountid: x.accountId,uid: x.deviceId,appver: x.appVer,ver: x.VERSION_NUMBER,referer: document.referrer || "",screen: "" + (parseInt(screen.width) || 0) + "*" + (parseInt(screen.height) || 0),logintime: String(parseInt(x.loginTime / 1e3)),onlinetime: String(t),crtime: m.get(e) || "",domain: document.domain} },reportOnline: function(e, t, n) { var r, a, i; return i = {data: {online: {}}}, i.data.events = e || [], i.data.errors = t || [], n && (i.data.reg = n), a = p.getEvents(), r = p.getErrors(), (a.length || r.length) && (p.clear(), i.data.events = i.data.events.concat(a), i.data.errors = i.data.errors.concat(r), i.data.fail = function() { return p.updateErrors(r), p.updateEvents(a) }), E(i) },injectErrorEvent: function(e) { return function() { return e.addEventListener("error", function(e) { var t, n, r, a, i; try { if (l.isReportAllowed(e.filename)) return l.count += 1, r = {}, n = ["colno", "filename", "lineno", "message"], n.forEach(function(t) { return r[t] = e[t] || "0" }), r.stack = (null != (a = e.error) ? a.stack : void 0) || "", r.type = (null != (i = e.error) ? i.name : void 0) || "Error", r.timestamp = parseInt(e.timeStamp / 1e3), p.updateErrors(r) } catch (o) { return t = o, console.log(t) } }, !1) } }(this),appendUID: function(e) { var t, n, r, a, i; return r = location.hash, t = "!" + e, r ? (i = /![0-9A-Z]{32,128}/gi, n = r.match(i), n ? (a = n[0].slice(1), e === a || m.get(c) || (x.parentId = a, m.set(c, a)), location.href = location.href.replace(i, t)) : location.href += t) : location.href += "#" + t },getServerUID: function(t) { var n, r, a; return S.postMessage ? (n = function(r) { var a; return 0 === x.PROXY.indexOf(r.origin) ? (a = JSON.parse(r.data), m.set(e, a.crtime), t(a.id), window.removeEventListener("message", n, !1)) : void 0 }, window.addEventListener("message", n, !1), r = document.createElement("iframe"), r.style.display = "none", r.src = "" + x.PROXY, r.onload = function() { return this.onload = null, this.parentNode.removeChild(this) }, a = function() { return document.body.appendChild(r) }, document.body ? a() : document.addEventListener("DOMContentLoaded", a, !1)) : t(y()) },sendPV: function(e, t) { var n, r; return null == e && (e = location.pathname + location.search), n = {page: encodeURIComponent(e),optime: parseInt(x.initializedOn / 1e3),ottime: parseInt(Date.now() / 1e3),lttime: parseInt(x.loginTime / 1e3)}, r = [{eventid: "_DESelf_PV",labelmap: JSON.stringify(n),duration: "1"}], m.reportOnline(r, null, t) }}, n = {version: x.VERSION_NUMBER,init: function(e) { var t, n, r, a; if (e.errorReport !== !1 && (e.excludes && (l.excludes = l.excludes.concat(e.excludes)), m.injectErrorEvent()), x.initialized) throw new Error("InitError: initialized already"); if (!e.appId) throw new Error("InitError: missing argument appId"); return n = ["appId", "accountId", "appVer"], n.forEach(function(t) { return x[t] = e[t] || "" }), t = m.get(x.CLIENT_KEY), a = function(t) { var n, a, o; return m.set(x.CLIENT_KEY, t), x.deviceId = t, x.accountId || (x.accountId = t), x.debug = e.debug, a = d.getItem(u), a || (a = Date.now(), d.setItem(u, a)), x.loginTime = a, n = d.getItem(i), n || (n = "0", d.setItem(i, n)), x.intervalCount = parseInt(n), x.interval = 1e3 * Math.max(10, parseFloat(e.interval || x.interval)), x.timer = setInterval(function() { return x.intervalCount += 1, d.setItem(i, x.intervalCount), m.reportOnline() }, x.interval), x.virus = e.virus === !1 ? 0 : 1, x.virus && m.appendUID(t), x.initializedOn = Date.now(), x.initialized = !0, r && (o = {isact: r,isreg: 1}, x.parentId && (o.parentid = x.parentId), S.localStorage || (o.localstorage = 1)), m.sendPV(null, o) }, r = t ? 0 : 1, t ? a(t) : m.getServerUID(a) },onEvent: function(e, t, n) { var r, a, i; if (null == t && (t = 0), !e) throw new Error("ArgumentError: missing eventId"); if (v(n)) { for (a in n) i = n[a], n[a] = encodeURIComponent(i); r = JSON.stringify(n) } else r = ""; return p.updateEvents({eventid: e,duration: String(t),labelmap: r}) },onPageView: function(e) { return m.sendPV(e) },onPayment: function(e) { var t; if (e && e.hasOwnProperty("amount")) return e.amount = parseFloat(e.amount) || 0, t = {data: {payment: {currencyAmount: e.amount.toFixed(2),currencyType: e.currencyType || "CNY",payType: String(e.payType || ""),iapid: String(e.iapid || ""),orderId: String(e.orderId || ""),payTime: String(e.payTime || "")}}}, E(t, x.API_PATH) }}, this.DCAgent = n }();