!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e(require("crypto"),require("buffer")):"function"===typeof define&&define.amd?define(["crypto","buffer"],e):(t="undefined"!==typeof globalThis?globalThis:t||self).BigLogger=e(t.require$$0,t.require$$1)}(this,(function(t,e){"use strict";function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function h(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}var d=function(){return a((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.dbName,n=e.storeName;o(this,t),this.dbName=r,this.storeName=n,this.db=null,this.init()}),[{key:"init",value:function(){var t=this,e=indexedDB.open(this.dbName);e.onupgradeneeded=function(e){var r=e.target.result;r.objectStoreNames.contains(t.storeName)||r.createObjectStore(t.storeName,{keyPath:"id",autoIncrement:!0})},e.onsuccess=function(e){t.db=e.target.result},e.onerror=function(t){reject("数据库打开失败: ".concat(t.target.errorCode))}}},{key:"_getTransactionStore",value:function(t){var e=this.db.transaction([this.storeName],t),r=e.objectStore(this.storeName);return{transaction:e,store:r}}},{key:"count",value:function(){var t=this;return new Promise((function(e,r){var n=t._getTransactionStore("readonly").store.count();n.onsuccess=function(){e(n.result)},n.onerror=r}))}},{key:"add",value:function(t){var e=this;return new Promise((function(r,n){var i=e._getTransactionStore("readwrite"),o=i.store,a=i.transaction;(t.length?t:[t]).forEach((function(t){return o.add(t)})),a.oncomplete=r,a.onerror=n}))}},{key:"get",value:function(t){var e=this;return new Promise((function(r,n){var i=e._getTransactionStore("readonly").store.get(t);i.onsuccess=function(t){r(t.target.result)},i.onerror=n}))}},{key:"getNumItems",value:function(t){var e=this;return new Promise((function(r,n){var i=e._getTransactionStore("readonly").store.openCursor(),o=[],a=0;i.onsuccess=function(e){var n=e.target.result;n&&a0&&void 0!==arguments[0]?arguments[0]:[],r=this._getTransactionStore("readwrite"),n=r.store,i=r.transaction,o=(e.length?e:[e]).map((function(e){return t._remove(n,e)}));return Promise.all(o).catch((function(){return i.abort()}))}},{key:"clear",value:function(){var t=this;return new Promise((function(e,r){var n=t._getTransactionStore("readwrite").store.clear();n.onsuccess=e,n.onerror=r}))}}])}(),f=Object.freeze({__proto__:null,indexdb:d}),v={d:(t,e)=>{for(var r in e)v.o(e,r)&&!v.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},p={};v.d(p,{A:()=>w,k:()=>m});var y=function(t,e,r,n){return new(r||(r=Promise))((function(e,i){function o(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(o,a)}s((n=n.apply(t,[])).next())}))},g=function(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]>>6,o[s++]=128|63&i):i<55296||i>=57344?(o[s++]=224|i>>>12,o[s++]=128|i>>>6&63,o[s++]=128|63&i):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++r)),o[s++]=240|i>>>18,o[s++]=128|i>>>12&63,o[s++]=128|i>>>6&63,o[s++]=128|63&i);t=o}t.length>64&&(t=new S(!0).update(t).array());var u=[],c=[];for(r=0;r<64;++r){var l=t[r]||0;u[r]=92^l,c[r]=54^l}S.call(this,e),this.update(c),this.oKeyPad=u,this.inner=!0,this.sharedMemory=e}S.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var e=b(t);t=e[0];for(var r,n,i=e[1],o=0,a=t.length,s=this.blocks,u=this.buffer8;o>>6,u[n++]=128|63&r):r<55296||r>=57344?(u[n++]=224|r>>>12,u[n++]=128|r>>>6&63,u[n++]=128|63&r):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++o)),u[n++]=240|r>>>18,u[n++]=128|r>>>12&63,u[n++]=128|r>>>6&63,u[n++]=128|63&r);else for(n=this.start;o>>2]|=r<>>2]|=(192|r>>>6)<>>2]|=(128|63&r)<=57344?(s[n>>>2]|=(224|r>>>12)<>>2]|=(128|r>>>6&63)<>>2]|=(128|63&r)<>>2]|=(240|r>>>18)<>>2]|=(128|r>>>12&63)<>>2]|=(128|r>>>6&63)<>>2]|=(128|63&r)<>>2]|=t[o]<=64?(this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},S.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[e>>>2]|=d[3&e],e>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},S.prototype.hash=function(){var t,e,r,n,i,o,a=this.blocks;this.first?e=((e=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879|0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&t)+a[1]-117830708)<<12|n>>>20)+t|0)&(-271733879^t))+a[2]-1126478375)<<17|r>>>15)+n|0)&(n^t))+a[3]-1316259209)<<22|e>>>10)+r|0:(t=this.h0,e=this.h1,r=this.h2,e=((e+=((t=((t+=((n=this.h3)^e&(r^n))+a[0]-680876936)<<7|t>>>25)+e|0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[1]-389564586)<<12|n>>>20)+t|0)&(t^e))+a[2]+606105819)<<17|r>>>15)+n|0)&(n^t))+a[3]-1044525330)<<22|e>>>10)+r|0),e=((e+=((t=((t+=(n^e&(r^n))+a[4]-176418897)<<7|t>>>25)+e|0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[5]+1200080426)<<12|n>>>20)+t|0)&(t^e))+a[6]-1473231341)<<17|r>>>15)+n|0)&(n^t))+a[7]-45705983)<<22|e>>>10)+r|0,e=((e+=((t=((t+=(n^e&(r^n))+a[8]+1770035416)<<7|t>>>25)+e|0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[9]-1958414417)<<12|n>>>20)+t|0)&(t^e))+a[10]-42063)<<17|r>>>15)+n|0)&(n^t))+a[11]-1990404162)<<22|e>>>10)+r|0,e=((e+=((t=((t+=(n^e&(r^n))+a[12]+1804603682)<<7|t>>>25)+e|0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[13]-40341101)<<12|n>>>20)+t|0)&(t^e))+a[14]-1502002290)<<17|r>>>15)+n|0)&(n^t))+a[15]+1236535329)<<22|e>>>10)+r|0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[1]-165796510)<<5|t>>>27)+e|0)^e))+a[6]-1069501632)<<9|n>>>23)+t|0)^t&((r=((r+=(t^e&(n^t))+a[11]+643717713)<<14|r>>>18)+n|0)^n))+a[0]-373897302)<<20|e>>>12)+r|0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[5]-701558691)<<5|t>>>27)+e|0)^e))+a[10]+38016083)<<9|n>>>23)+t|0)^t&((r=((r+=(t^e&(n^t))+a[15]-660478335)<<14|r>>>18)+n|0)^n))+a[4]-405537848)<<20|e>>>12)+r|0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[9]+568446438)<<5|t>>>27)+e|0)^e))+a[14]-1019803690)<<9|n>>>23)+t|0)^t&((r=((r+=(t^e&(n^t))+a[3]-187363961)<<14|r>>>18)+n|0)^n))+a[8]+1163531501)<<20|e>>>12)+r|0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[13]-1444681467)<<5|t>>>27)+e|0)^e))+a[2]-51403784)<<9|n>>>23)+t|0)^t&((r=((r+=(t^e&(n^t))+a[7]+1735328473)<<14|r>>>18)+n|0)^n))+a[12]-1926607734)<<20|e>>>12)+r|0,e=((e+=((o=(n=((n+=((i=e^r)^(t=((t+=(i^n)+a[5]-378558)<<4|t>>>28)+e|0))+a[8]-2022574463)<<11|n>>>21)+t|0)^t)^(r=((r+=(o^e)+a[11]+1839030562)<<16|r>>>16)+n|0))+a[14]-35309556)<<23|e>>>9)+r|0,e=((e+=((o=(n=((n+=((i=e^r)^(t=((t+=(i^n)+a[1]-1530992060)<<4|t>>>28)+e|0))+a[4]+1272893353)<<11|n>>>21)+t|0)^t)^(r=((r+=(o^e)+a[7]-155497632)<<16|r>>>16)+n|0))+a[10]-1094730640)<<23|e>>>9)+r|0,e=((e+=((o=(n=((n+=((i=e^r)^(t=((t+=(i^n)+a[13]+681279174)<<4|t>>>28)+e|0))+a[0]-358537222)<<11|n>>>21)+t|0)^t)^(r=((r+=(o^e)+a[3]-722521979)<<16|r>>>16)+n|0))+a[6]+76029189)<<23|e>>>9)+r|0,e=((e+=((o=(n=((n+=((i=e^r)^(t=((t+=(i^n)+a[9]-640364487)<<4|t>>>28)+e|0))+a[12]-421815835)<<11|n>>>21)+t|0)^t)^(r=((r+=(o^e)+a[15]+530742520)<<16|r>>>16)+n|0))+a[2]-995338651)<<23|e>>>9)+r|0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[0]-198630844)<<6|t>>>26)+e|0)|~r))+a[7]+1126891415)<<10|n>>>22)+t|0)^((r=((r+=(t^(n|~e))+a[14]-1416354905)<<15|r>>>17)+n|0)|~t))+a[5]-57434055)<<21|e>>>11)+r|0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[12]+1700485571)<<6|t>>>26)+e|0)|~r))+a[3]-1894986606)<<10|n>>>22)+t|0)^((r=((r+=(t^(n|~e))+a[10]-1051523)<<15|r>>>17)+n|0)|~t))+a[1]-2054922799)<<21|e>>>11)+r|0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[8]+1873313359)<<6|t>>>26)+e|0)|~r))+a[15]-30611744)<<10|n>>>22)+t|0)^((r=((r+=(t^(n|~e))+a[6]-1560198380)<<15|r>>>17)+n|0)|~t))+a[13]+1309151649)<<21|e>>>11)+r|0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[4]-145523070)<<6|t>>>26)+e|0)|~r))+a[11]-1120210379)<<10|n>>>22)+t|0)^((r=((r+=(t^(n|~e))+a[2]+718787259)<<15|r>>>17)+n|0)|~t))+a[9]-343485551)<<21|e>>>11)+r|0,this.first?(this.h0=t+1732584193|0,this.h1=e-271733879|0,this.h2=r-1732584194|0,this.h3=n+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+e|0,this.h2=this.h2+r|0,this.h3=this.h3+n|0)},S.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,n=this.h3;return h[t>>>4&15]+h[15&t]+h[t>>>12&15]+h[t>>>8&15]+h[t>>>20&15]+h[t>>>16&15]+h[t>>>28&15]+h[t>>>24&15]+h[e>>>4&15]+h[15&e]+h[e>>>12&15]+h[e>>>8&15]+h[e>>>20&15]+h[e>>>16&15]+h[e>>>28&15]+h[e>>>24&15]+h[r>>>4&15]+h[15&r]+h[r>>>12&15]+h[r>>>8&15]+h[r>>>20&15]+h[r>>>16&15]+h[r>>>28&15]+h[r>>>24&15]+h[n>>>4&15]+h[15&n]+h[n>>>12&15]+h[n>>>8&15]+h[n>>>20&15]+h[n>>>16&15]+h[n>>>28&15]+h[n>>>24&15]},S.prototype.toString=S.prototype.hex,S.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,n=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&n,n>>>8&255,n>>>16&255,n>>>24&255]},S.prototype.array=S.prototype.digest,S.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),e=new Uint32Array(t);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,t},S.prototype.buffer=S.prototype.arrayBuffer,S.prototype.base64=function(){for(var t,e,r,n="",i=this.array(),o=0;o<15;)t=i[o++],e=i[o++],r=i[o++],n+=p[t>>>2]+p[63&(t<<4|e>>>4)]+p[63&(e<<2|r>>>6)]+p[63&r];return t=i[o],n+(p[t>>>2]+p[t<<4&63]+"==")},E.prototype=new S,E.prototype.finalize=function(){if(S.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();S.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),S.prototype.finalize.call(this)}};var O=function(){var r=x("hex");s&&(r=function(r){var i,a=t,s=e.Buffer;return i=s.from&&!o.JS_MD5_NO_BUFFER_FROM?s.from:function(t){return new s(t)},function(t){if("string"===typeof t)return a.createHash("md5").update(t,"utf8").digest("hex");if(null===t||void 0===t)throw new Error(n);return t.constructor===ArrayBuffer&&(t=new Uint8Array(t)),m(t)||w(t)||t.constructor===s?a.createHash("md5").update(i(t)).digest("hex"):r(t)}}(r)),r.create=function(){return new S},r.update=function(t){return r.create().update(t)};for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(e){e.id;var r=function(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n=e,g=r.includes(".ico"),m=p&&!$.includes(String(p)[0]);if(y||g||m){var w=this.calculateTimes(t);this.logger.track({type:W,subType:"resource",data:new J(c(c({},w),{},{resourceSize:v,resourceUrl:T(r),resourceCost:Math.round(n),resourceBlockingStatus:f,httpStatus:p})).json})}}}},{key:"calculateTimes",value:function(t){var e=t.navigationStart,r=t.redirectStart,n=t.redirectEnd,i=t.domainLookupStart,o=t.domainLookupEnd,a=t.connectStart,s=t.connectEnd,u=t.requestStart,c=t.responseStart,l=t.responseEnd,h=t.domComplete,d=t.loadEventEnd,f=t.domInteractive;return{startTime:e,blankCost:Math.ceil(c-e),redirectCost:Math.ceil(n-r),dnsCost:Math.ceil(o-i),tcpCost:Math.ceil(s-a),reqTime:u,resTime:l,resCost:Math.ceil(l-c),domTime:h,loadTime:d,interactiveTime:f}}}])}(),Y=function(){return a((function t(e){var r=e.cost,n=e.url,i=e.httpStatus,a=e.bizStatus,s=e.bizMessage,u=e.requestId,c=void 0===u?"":u,l=e.responseHeaders,h=void 0===l?{}:l;o(this,t),this.url=n,this.cost=r,this.http_status=i||0,this.biz_status=a,this.biz_message=s,this.request_id=c,this.response_headers=JSON.stringify(h)}),[{key:"json",get:function(){return c({},this)}}])}(),Q=function(){return a((function t(){o(this,t)}),[{key:"apply",value:function(t){this.logger=t,this.watch()}},{key:"watch",value:function(){P()&&(this.overrideXhr(),this.overrideFetch())}},{key:"logEvent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.track({type:"api",data:new Y(t).json})}},{key:"checkIsExcludeUrl",value:function(t){var e=this.logger,r=e.options,n=e.uploader.url,i=r.excludePaths;return!!/https?:\/\/(localhost|127.0.0.1).*/.test(t)||t.includes(n)||i.some((function(e){return t.includes(e)}))}},{key:"checkIsAddTraceHeader",value:function(t){var e=this.logger,r=e.options,n=e.uploader.url,i=r.allowedDomains;return t.includes(n)||i.some((function(e){return t.includes(e)}))}},{key:"overrideXhr",value:function(){var t=this.logger.globalParams.terminalId,e=this,r=window.XMLHttpRequest;function n(){var n,i,o,a,s,u=new r,c=z(t),l=u.open,h=function(){if(!s){i=performance.now();var t=Math.ceil(i-n),r=T(o),a=u.status,l=-1,h="",d={};try{var f=u.getResponseHeader("x-oss-request-id"),v=u.getResponseHeader("x-amz-request-id"),p=u.getResponseHeader("x-as-ret-code"),y=u.getResponseHeader("x-as-ret-message");f&&(d["x-oss-request-id"]=f),v&&(d["x-amz-request-id"]=v),p&&(l=p),y&&(h=y)}catch(t){}e.logEvent({cost:t,url:r,httpStatus:a,bizStatus:l,bizMessage:h,requestId:c,responseHeaders:d})}};return u.open=function(t,r){o=r,a=t,s=e.checkIsExcludeUrl(o);for(var n=arguments.length,i=new Array(n>2?n-2:0),h=2;h1&&void 0!==arguments[1]?arguments[1]:{},s=performance.now(),u=0,l=0,h=-1,d="",f={},v=r.checkIsExcludeUrl(i);return v?n(i,a):new Promise((function(p,y){var g=z(e),m=function(){r.logEvent({cost:u,url:T(i),httpStatus:l,bizStatus:h,bizMessage:d,requestId:g,responseHeaders:f})},w=r.checkIsAddTraceHeader(i)?Object.assign({},a.headers||{},{"X-AS-REQUEST-ID":g}):Object.assign({},a.headers||{});n(i,c(c({},a),{},{headers:w})).then((function(t){p(t),o=performance.now(),u=Math.ceil(o-s),l=t.status;var e=t.headers.get("x-oss-request-id"),r=t.headers.get("x-amz-request-id"),n=t.headers.get("x-as-ret-code"),i=t.headers.get("x-as-ret-message");e&&(f["x-oss-request-id"]=e),r&&(f["x-amz-request-id"]=r),n&&(h=n),i&&(d=i),m()})).catch((function(e){try{var r=e.message,n=e.stack;t.logger.track({type:"error",data:new D({message:"".concat(r,": ").concat(T(i)),stack:JSON.stringify(n)})})}catch(t){}v||m()}))}))}}}])}(),K=function(){return a((function t(e){var r=e.downlink,n=void 0===r?0:r,i=e.effectiveType,a=void 0===i?-1:i,s=e.rtt,u=void 0===s?"":s,c=e.saveData,l=void 0===c?"":c;o(this,t),this.downlink=n,this.effective_type=a,this.rtt=u,this.save_data=l}),[{key:"json",get:function(){return c({},this)}}])}(),Z=function(){return a((function t(){o(this,t)}),[{key:"apply",value:function(t){var e;this.logger=t,null!==(e=window)&&void 0!==e&&null!==(e=e.navigator)&&void 0!==e&&e.connection&&this.logEvent(window.navigator.connection)}},{key:"logEvent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.track({type:"network",data:new K(t).json})}}])}(),tt=[R,V,Q,Z,function(){return a((function t(){o(this,t)}),[{key:"apply",value:function(t){this.logger=t,this.watch()}},{key:"watch",value:function(){var t=this;P()&&(this.logger.track({data:{name:"enterPage"}}),window.addEventListener("beforeunload",(function(){t.logger.track({data:{name:"closeOrLeavePage"}},{forceUpload:!0})})))}}])}()],et={maxCountPerBatch:20,resourceCostThrottle:3e3,eventsAddInterval:800,scheduleSendInterval:3e4,allowedDomains:[],excludePaths:[],storage:{policy:"indexdb",dbName:"big-logger",storeName:"events"},uploader:{url:"/log"}},rt=function(){return a((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.options=Object.assign({},et,e),this.globalParams={},this.baseParams={},this.storage={},this.uploader={},this.isUploading=!1,this.terminalId=P()?function(){var t=document.createElement("canvas"),e=t.getContext("2d"),r=" id";t.width=158,t.height=30,e.textBaseline="top",e.font="14px Arial",e.textBaseline="alphabetic",e.fillStyle="#069",e.fillRect(90,2,62,60),e.fillStyle="#069",e.fillText(r,3,25),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText(r,4,17);for(var n=t.toDataURL(),i=atob(n.split(",")[1]),o=[],a=0;a0&&void 0!==arguments[0]?arguments[0]:{};this.options=Object.assign(this.options,t),this.setGlobalParams(this.options),this.setBaseParams(this.options)}},{key:"setGlobalParams",value:function(){var t=i(l().mark((function t(e){var r,n,i,o,a,s,u,c;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.agentType,n=void 0===r?"":r,i=e.osType,o=void 0===i?"":i,a=e.deviceType,s=void 0===a?"":a,u=e.agentVersion,c=void 0===u?"":u,t.next=3,I();case 3:t.t0=t.sent,t.t1=this.terminalId,t.t2=(P()?function(){var t=window.navigator.userAgent,e=window.navigator.platform;return/Mac/i.test(e)?"mac-os":/Win/i.test(e)?"windows":/Linux/i.test(e)?"linux":/Android/i.test(t)?"android":/iOS/i.test(t)||/iPhone|iPad|iPod/i.test(e)?"ios":/CrOS/i.test(t)?"chrome-os":"other"}():"")||o,t.t3=(P()?navigator.userAgent:"")||n,t.t4=(P()?function(){var t=navigator.userAgent;return/Mobi|Android/i.test(t)?"mobile":/Tablet|iPad/i.test(t)?"pad":"pc"}():"")||s,t.t5=(P()?function(){var t,e=navigator.userAgent,r="",n=e.match(/(firefox|msie|trident|chrome|safari|opr|edg|edge(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?r=(t=/\brv[ :]+(\d+)/g.exec(e)||[])[1]||"":"Chrome"===n[1]?r=null!==(t=e.match(/\b(OPR|Edg|Edge)\/(\d+)/))?t[2]:n[2]:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!==(t=e.match(/version\/(\d+)/i))&&n.splice(1,1,t[1]),r=n[1]),r}():"")||c,this.globalParams={agentMode:t.t0,terminalId:t.t1,osType:t.t2,agentType:t.t3,deviceType:t.t4,agentVersion:t.t5};case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},{key:"setBaseParams",value:function(t){var e=t.appId,r=void 0===e?"":e,n=t.bizlineId,i=void 0===n?"":n;this.baseParams={appId:r,bizlineId:i}}},{key:"getEvent",value:function(t){return new B(c(c(c({id:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},this.baseParams),{},{host:P()?location.host:"",pageUrl:P()?T(location.href):"",type:"user_behav"},function(){var t={};if(P()){var e=A("virtualProjectGuid");e&&(t.projectId=e);var r=(RegExp("".concat("collection","/([^/$]*)")).test(location.href)?decodeURIComponent(RegExp.$1):"")||A("collection_uid");r&&(t.collectionId=r);var n=O("AS_UID");n&&(t.userId=n);var i=O("customerSessionGuid");i&&(t.sessionId=i);var o=O("_as_install_id");o&&(t.installId=o)}return t}()),t)).json}},{key:"getSendMsg",value:function(t){return new U(c(c({},this.globalParams),{},{events:t})).json}},{key:"send",value:function(t){var e=this.getSendMsg([t]);this.uploader.send(e)}},{key:"batchSend",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new Promise((function(r,n){var i=t.getSendMsg(e);requestIdleCallback((function(){t.uploader.send(i).then(r).catch(n)}))}))}},{key:"scheduleSend",value:function(){var t=this;this._schedule_send_timer=setTimeout((function(){clearTimeout(t._schedule_send_timer),t.sendIfNeed(t.scheduleSend.bind(t),!1)}),this.options.scheduleSendInterval)}},{key:"sendIfNeed",value:function(t){var e=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];("undefined"===typeof window||window._IS_WINDOW_LOADED)&&(this.isUploading?t&&t():(this.isUploading=!0,requestIdleCallback(i(l().mark((function n(){var i,o;return l().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,n.t0=!r,n.t0){n.next=6;break}return n.next=5,e.checkNeedUpload();case 5:n.t0=n.sent;case 6:if(!n.t0){n.next=16;break}return n.next=10,e.storage.getNumItems(e.options.maxCountPerBatch);case 10:if(!(i=n.sent).length){n.next=16;break}return n.next=14,e.batchSend(i);case 14:o=i.map((function(t){return t.id})),e.storage.remove(o);case 16:n.next=20;break;case 18:n.prev=18,n.t1=n.catch(0);case 20:return n.prev=20,e.isUploading=!1,t&&t(),n.finish(20);case 24:case"end":return n.stop()}}),n,null,[[0,18,20,24]])}))))))}},{key:"cacheEvent",value:function(t){var e=this;return this._events_cache.push(t),this._events_add_timer&&clearTimeout(this._events_add_timer),new Promise((function(t,r){e._events_add_timer=setTimeout((function(){var n=e._events_cache.splice(0,e._events_cache.length);e.storage.add(n).then((function(){t(),clearTimeout(e._events_add_timer)})).catch(r)}),e.options.eventsAddInterval)}))}},{key:"checkNeedUpload",value:function(){var t=i(l().mark((function t(){var e;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.options.maxCountPerBatch,t.next=3,this.storage.count();case 3:if(!(t.sent>=e)){t.next=6;break}return t.abrupt("return",!0);case 6:return t.abrupt("return",!1);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}()},{key:"track",value:function(){var t=i(l().mark((function t(e){var r,n,i,o=this,a=arguments;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=(a.length>1&&void 0!==a[1]?a[1]:{}).forceUpload,n=void 0!==r&&r,this.options.isEnabled){t.next=4;break}return t.abrupt("return");case 4:if(i=this.getEvent(e),!n){t.next=8;break}return this.send(i),t.abrupt("return",!0);case 8:return this.cacheEvent(i).finally((function(){o.sendIfNeed()})),t.abrupt("return",!0);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()}])}();return rt})); //# sourceMappingURL=big-log.umd.js.map