!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BeaconAction=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]60*this.strategy.requestInterval*1e3},t.prototype.getUploadUrl=function(){return this.strategy.httpsUploadUrl+"?appkey="+this.appkey},t.prototype.isBlackEvent=function(t){return-1!=this.strategy.blacklist.indexOf(t)},t.prototype.isEventUpOnOff=function(){return this.strategy.isEventUpOnOff},t.prototype.isSampleEvent=function(t){return!!Object.prototype.hasOwnProperty.call(this.realSample,t)&&this.realSample[t]this.duration)return this.createSession();e=r.sessionId,n=r.sessionStart,this.getSessionStackDepth=0}catch(t){}return{sessionId:e,sessionStart:n}},t.prototype.createSession=function(){var t=Date.now(),e={sessionId:this.appkey+"_"+t.toString(),sessionStart:t};this.storage.setItem(m,JSON.stringify(e)),this.storage.setItem(s,t.toString());var n="is_new_user",r=this.storage.getItem(n);return this.getSessionStackDepth<=1&&this.beacon.onDirectUserAction("rqd_applaunched",{A21:r?"N":"Y"}),this.storage.setItem(n,JSON.stringify(!1)),e},t}();function b(){var t=navigator.userAgent,e=t.indexOf("compatible")>-1&&t.indexOf("MSIE")>-1,n=t.indexOf("Edge")>-1&&!e,r=t.indexOf("Trident")>-1&&t.indexOf("rv:11.0")>-1;if(e){new RegExp("MSIE (\\d+\\.\\d+);").test(t);var o=parseFloat(RegExp.$1);return 7==o?7:8==o?8:9==o?9:10==o?10:6}return n?-2:r?11:-1}function S(t,e){var n,r;return(n="https://tun-cos-1258344701.file.myqcloud.com/fp.js",void 0===r&&(r=Date.now()+"-"+Math.random()),new Promise((function(t,e){if(document.getElementById(r))t(void 0);else{var o=document.getElementsByTagName("head")[0],i=document.createElement("script");i.onload=function(){return function(){i.onload=null,t(void 0)}},i.onerror=function(t){i.onerror=null,o.removeChild(i),e(t)},i.src=n,i.id=r,o.appendChild(i)}}))).then((function(){(new Fingerprint).getQimei36(t,e)})).catch((function(t){})),""}var I=function(){return(I=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0||!window.indexedDB||/X5Lite/.test(navigator.userAgent)?(this.store=new x(e),this.dbEventCount=this.store.getCount()):(this.store=new D(t),this.getCount().then((function(t){n.dbEventCount=t})).catch((function(t){})))}return t.prototype.getCount=function(){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.store.getCount()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,Promise.reject()];case 3:return[2]}}))}))},t.prototype.insertEvent=function(t,e){return n(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:if(this.dbEventCount>=1e4)return[2,Promise.reject()];n=f(t.mapValue),r.label=1;case 1:return r.trys.push([1,3,,4]),this.dbEventCount++,[4,this.store.setItem(n,t)];case 2:return[2,r.sent()];case 3:return o=r.sent(),e&&e(o,t),this.dbEventCount--,[2,Promise.reject()];case 4:return[2]}}))}))},t.prototype.getEvents=function(){return n(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:t=[],e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.store.iterate((function(e){t.push(e)}))];case 2:return e.sent(),[2,Promise.all(t)];case 3:return e.sent(),[2,Promise.all(t)];case 4:return[2]}}))}))},t.prototype.removeEvent=function(t){return n(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:e=f(t.mapValue),n.label=1;case 1:return n.trys.push([1,3,,4]),this.dbEventCount--,[4,this.store.removeItem(e)];case 2:return[2,n.sent()];case 3:return n.sent(),this.dbEventCount++,[2,Promise.reject()];case 4:return[2]}}))}))},t}(),P=function(){return(P=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&i<8,e.isUnderIE8||(e.isUnderIE=i>0,t.needInitQimei&&S(t.appkey,(function(t){e.qimei36=t.q36})),e.network=new F(t),e.storage=new G(t.appkey),e.initCommonInfo(t),e.store=new _(t.appkey,e.storage),e.errorReport=new g(e.config,e.commonInfo,"web",e.network),e.strategy=new y(null==t.needQueryConfig||t.needQueryConfig,e.config,e.commonInfo,e.storage,e.network),e.logidStartTime=e.storage.getItem(z),e.logidStartTime||(e.logidStartTime=Date.now().toString(),e.storage.setItem(z,e.logidStartTime)),r=e.logidStartTime,o=Date.now()-Number.parseFloat(r),Math.floor(o/864e5)>=365&&e.storage.clear(),e.initSession(t),e.onDirectUserAction("rqd_js_init",{}),setTimeout((function(){return e.lifeCycle.emit("init")}),0),e.initDelayTime=t.delay?t.delay:1e3,e.cycleTask(e.initDelayTime)),e}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),r.prototype.initSession=function(t){var e=18e5;t.sessionDuration&&t.sessionDuration>3e4&&(e=t.sessionDuration),this.beaconSession=new w(this.storage,e,this)},r.prototype.initCommonInfo=function(t){var e=Number(this.storage.getItem(s));try{var n=JSON.parse(this.storage.getItem(a));(Date.now()-e>3e4||!n)&&this.storage.setItem(a,JSON.stringify([]))}catch(t){}t.uploadUrl&&(this.uploadUrl=t.uploadUrl+"?appkey="+t.appkey);var r=[window.screen.width,window.screen.height];window.devicePixelRatio&&r.push(window.devicePixelRatio),this.commonInfo={deviceId:this.storage.createDeviceId(),language:navigator&&navigator.language||"zh_CN",query:window.location.search,userAgent:navigator.userAgent,pixel:r.join("*"),channelID:t.channelID?String(t.channelID):"",openid:t.openid?String(t.openid):"",unid:t.unionid?String(t.unionid):"",sdkVersion:W},this.config.appVersion=t.versionCode?String(t.versionCode):"",this.config.strictMode=t.strictMode},r.prototype.cycleTask=function(t){var e=this;this.intervalID=window.setInterval((function(){e.pauseSearching||e.store.getEvents().then((function(t){0==t.length&&(e.pauseSearching=!0);var n=[],r=JSON.parse(e.storage.getItem(a));r||(r=[]),t&&t.forEach((function(t){var e=f(t.mapValue);-1==r.indexOf(e)&&(n.push(t),r.push(e))})),0!=n.length&&(e.storage.setItem(a,JSON.stringify(r)),e._normalLogPipeline(e.assembleData(n)))})).catch((function(t){}))}),t)},r.prototype.onReport=function(t,e,n){var r=this;if(this.isUnderIE8)this.errorReport.reportError("601","UnderIE8");else{this.pauseSearching=!1;var o=this.generateData(t,e,n);if(n&&0==this.delayTime&&!this.underWeakNet)this._normalLogPipeline(this.assembleData(o));else{var i=o.shift();i&&this.store.insertEvent(i,(function(t){t&&r.errorReport.reportError("604","insertEvent fail!")})).catch((function(t){r._normalLogPipeline(r.assembleData(o))}))}}},r.prototype.onSendBeacon=function(t,e){if(this.isUnderIE)this.errorReport.reportError("605","UnderIE");else{this.pauseSearching=!1;var n=this.assembleData(this.generateData(t,e,!0));"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(this.uploadUrl||this.strategy.getUploadUrl(),JSON.stringify(n))}},r.prototype.generateData=function(t,n,r){var o=[],i="4.5.14-web_"+(r?"direct_log_id":"normal_log_id"),s=Number(this.storage.getItem(i));return s=s||1,n=e(e({},n),{A99:r?"Y":"N",A100:s.toString(),A72:W,A88:this.logidStartTime}),s++,this.storage.setItem(i,s.toString()),o.push({eventCode:t,eventTime:Date.now().toString(),mapValue:p(n,this.config.strictMode)}),o},r.prototype.assembleData=function(t){var n=this.beaconSession.getSession();return{appVersion:this.config.appVersion?h(this.config.appVersion):"",sdkId:"js",sdkVersion:W,mainAppKey:this.config.appkey,platformId:3,common:p(e(e({},this.additionalParams),{A2:this.commonInfo.deviceId,A8:this.commonInfo.openid,A12:this.commonInfo.language,A17:this.commonInfo.pixel,A23:this.commonInfo.channelID,A50:this.commonInfo.unid,A76:n.sessionId,A101:this.commonInfo.userAgent,A102:window.location.href,A104:document.referrer,A119:this.commonInfo.query,A153:this.qimei36}),!1),events:t}},r.prototype.monitorUploadFailed=function(){this.uselessCycleTaskNum++,this.uselessCycleTaskNum>=5&&(window.clearInterval(this.intervalID),this.cycleTask(6e4),this.underWeakNet=!0)},r.prototype.doCustomCycleTask=function(){this.uselessCycleTaskNum>=5&&(window.clearInterval(this.intervalID),this.cycleTask(this.initDelayTime)),this.uselessCycleTaskNum=0,this.underWeakNet=!1},r}(v)}));