UNPKG

monito-action

Version:

H5全埋点组件

3 lines (2 loc) 31.3 kB
(function(R,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(R=typeof globalThis<"u"?globalThis:R||self,R["muk-ui"]=v())})(this,function(){"use strict";var cn=Object.defineProperty;var ln=(R,v,x)=>v in R?cn(R,v,{enumerable:!0,configurable:!0,writable:!0,value:x}):R[v]=x;var p=(R,v,x)=>(ln(R,typeof v!="symbol"?v+"":v,x),x);function R({element:t,type:e,handler:r}){t.addEventListener(e,r)}const v={addEventListener:R},x=window||globalThis,Ie=x.indexedDB||x.mozIndexedDB||x.webkitIndexedDB||x.msIndexedDB,C={};let F,J;const Le=(t,e,r)=>new Promise((n,i)=>{var a;if(Ie||i("浏览器不支持indexedDB"),F=t,C!=null&&C[t]){n(C[t]);return}J=Ie.open(t,e),(a=Ot(r))==null||a.then(s=>n(s)),J.onsuccess=s=>{const o=s.target.result;C[t]=o,n(o)},J.onerror=s=>i(s)}),Ot=t=>{if(t)return new Promise(e=>{J.onupgradeneeded=r=>{const n=r.target.result;C[F]=n;for(const i in t)if(!n.objectStoreNames.contains(t[i].storeName)){const a=n.createObjectStore(t[i].storeName,t[i].option);for(const s of t[i].index)a.createIndex(s.name,s.keyPath,{unique:s.unique})}e(n)}})},Pt=async(t,e)=>{let r;return C[F]?r=C[F]:r=await Le(F,e),r.transaction(t,"readwrite")},te=async(t,e)=>(await Pt(t,e)).objectStore(t),O=(t,e,r)=>new Promise(n=>{te(t).then(i=>{const a=i[e](r);a.onsuccess=s=>n(s.target.result)})}),At=(t,e,r,n,i)=>new Promise((a,s)=>{te(t).then(o=>{const u=o.openCursor(IDBKeyRange.bound(e,r,n,i));u.onsuccess=f=>a(f.target.result),u.onerror=f=>s(f)})});function Ct(t){return O(t,"getAll")}function qt(t){return O(t,"count")}function re(t){return O(t,"clear")}const It=async(t,e,r)=>{const h={add:c=>O(t,"add",c),get:c=>O(t,"get",c),clear:c=>O(t,"clear",c),del:c=>O(t,"delete",c),put:c=>O(t,"put",c),find:(c,w,j,b)=>At(t,c,w,j,b),getAll:()=>O(t,"getAll"),getCount:()=>O(t,"count")};return te(t,e),r(h),h};function Lt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ne={},Nt={get exports(){return ne},set exports(t){ne=t}},V={},Dt={get exports(){return V},set exports(t){V=t}},Ne=function(e,r){return function(){for(var i=new Array(arguments.length),a=0;a<i.length;a++)i[a]=arguments[a];return e.apply(r,i)}},Ut=Ne,ie=Object.prototype.toString,ae=function(t){return function(e){var r=ie.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())}}(Object.create(null));function L(t){return t=t.toLowerCase(),function(r){return ae(r)===t}}function se(t){return Array.isArray(t)}function G(t){return typeof t>"u"}function kt(t){return t!==null&&!G(t)&&t.constructor!==null&&!G(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}var De=L("ArrayBuffer");function Bt(t){var e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&De(t.buffer),e}function _t(t){return typeof t=="string"}function jt(t){return typeof t=="number"}function Ue(t){return t!==null&&typeof t=="object"}function K(t){if(ae(t)!=="object")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}var Mt=L("Date"),$t=L("File"),Ft=L("Blob"),Wt=L("FileList");function oe(t){return ie.call(t)==="[object Function]"}function Ht(t){return Ue(t)&&oe(t.pipe)}function Jt(t){var e="[object FormData]";return t&&(typeof FormData=="function"&&t instanceof FormData||ie.call(t)===e||oe(t.toString)&&t.toString()===e)}var Vt=L("URLSearchParams");function Gt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Kt(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function ue(t,e){if(!(t===null||typeof t>"u"))if(typeof t!="object"&&(t=[t]),se(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function ce(){var t={};function e(i,a){K(t[a])&&K(i)?t[a]=ce(t[a],i):K(i)?t[a]=ce({},i):se(i)?t[a]=i.slice():t[a]=i}for(var r=0,n=arguments.length;r<n;r++)ue(arguments[r],e);return t}function Xt(t,e,r){return ue(e,function(i,a){r&&typeof i=="function"?t[a]=Ut(i,r):t[a]=i}),t}function zt(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}function Qt(t,e,r,n){t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,r&&Object.assign(t.prototype,r)}function Yt(t,e,r){var n,i,a,s={};e=e||{};do{for(n=Object.getOwnPropertyNames(t),i=n.length;i-- >0;)a=n[i],s[a]||(e[a]=t[a],s[a]=!0);t=Object.getPrototypeOf(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e}function Zt(t,e,r){t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;var n=t.indexOf(e,r);return n!==-1&&n===r}function er(t){if(!t)return null;var e=t.length;if(G(e))return null;for(var r=new Array(e);e-- >0;)r[e]=t[e];return r}var tr=function(t){return function(e){return t&&e instanceof t}}(typeof Uint8Array<"u"&&Object.getPrototypeOf(Uint8Array)),g={isArray:se,isArrayBuffer:De,isBuffer:kt,isFormData:Jt,isArrayBufferView:Bt,isString:_t,isNumber:jt,isObject:Ue,isPlainObject:K,isUndefined:G,isDate:Mt,isFile:$t,isBlob:Ft,isFunction:oe,isStream:Ht,isURLSearchParams:Vt,isStandardBrowserEnv:Kt,forEach:ue,merge:ce,extend:Xt,trim:Gt,stripBOM:zt,inherits:Qt,toFlatObject:Yt,kindOf:ae,kindOfTest:L,endsWith:Zt,toArray:er,isTypedArray:tr,isFileList:Wt},D=g;function ke(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Be=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(D.isURLSearchParams(r))i=r.toString();else{var a=[];D.forEach(r,function(u,f){u===null||typeof u>"u"||(D.isArray(u)?f=f+"[]":u=[u],D.forEach(u,function(h){D.isDate(h)?h=h.toISOString():D.isObject(h)&&(h=JSON.stringify(h)),a.push(ke(f)+"="+ke(h))}))}),i=a.join("&")}if(i){var s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e},rr=g;function X(){this.handlers=[]}X.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1},X.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},X.prototype.forEach=function(e){rr.forEach(this.handlers,function(n){n!==null&&e(n)})};var nr=X,ir=g,ar=function(e,r){ir.forEach(e,function(i,a){a!==r&&a.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[a])})},_e=g;function U(t,e,r,n,i){Error.call(this),this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}_e.inherits(U,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var je=U.prototype,Me={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach(function(t){Me[t]={value:t}}),Object.defineProperties(U,Me),Object.defineProperty(je,"isAxiosError",{value:!0}),U.from=function(t,e,r,n,i,a){var s=Object.create(je);return _e.toFlatObject(t,s,function(u){return u!==Error.prototype}),U.call(s,t.message,e,r,n,i),s.name=t.name,a&&Object.assign(s,a),s};var k=U,$e={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},T=g;function sr(t,e){e=e||new FormData;var r=[];function n(a){return a===null?"":T.isDate(a)?a.toISOString():T.isArrayBuffer(a)||T.isTypedArray(a)?typeof Blob=="function"?new Blob([a]):Buffer.from(a):a}function i(a,s){if(T.isPlainObject(a)||T.isArray(a)){if(r.indexOf(a)!==-1)throw Error("Circular reference detected in "+s);r.push(a),T.forEach(a,function(u,f){if(!T.isUndefined(u)){var l=s?s+"."+f:f,h;if(u&&!s&&typeof u=="object"){if(T.endsWith(f,"{}"))u=JSON.stringify(u);else if(T.endsWith(f,"[]")&&(h=T.toArray(u))){h.forEach(function(c){!T.isUndefined(c)&&e.append(l,n(c))});return}}i(u,l)}}),r.pop()}else e.append(s,n(a))}return i(t),e}var Fe=sr,le,We;function or(){if(We)return le;We=1;var t=k;return le=function(r,n,i){var a=i.config.validateStatus;!i.status||!a||a(i.status)?r(i):n(new t("Request failed with status code "+i.status,[t.ERR_BAD_REQUEST,t.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))},le}var fe,He;function ur(){if(He)return fe;He=1;var t=g;return fe=t.isStandardBrowserEnv()?function(){return{write:function(n,i,a,s,o,u){var f=[];f.push(n+"="+encodeURIComponent(i)),t.isNumber(a)&&f.push("expires="+new Date(a).toGMTString()),t.isString(s)&&f.push("path="+s),t.isString(o)&&f.push("domain="+o),u===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(n){var i=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),fe}var cr=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},lr=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},fr=cr,dr=lr,Je=function(e,r){return e&&!fr(r)?dr(e,r):r},de,Ve;function hr(){if(Ve)return de;Ve=1;var t=g,e=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return de=function(n){var i={},a,s,o;return n&&t.forEach(n.split(` `),function(f){if(o=f.indexOf(":"),a=t.trim(f.substr(0,o)).toLowerCase(),s=t.trim(f.substr(o+1)),a){if(i[a]&&e.indexOf(a)>=0)return;a==="set-cookie"?i[a]=(i[a]?i[a]:[]).concat([s]):i[a]=i[a]?i[a]+", "+s:s}}),i},de}var he,Ge;function pr(){if(Ge)return he;Ge=1;var t=g;return he=t.isStandardBrowserEnv()?function(){var r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),i;function a(s){var o=s;return r&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return i=a(window.location.href),function(o){var u=t.isString(o)?a(o):o;return u.protocol===i.protocol&&u.host===i.host}}():function(){return function(){return!0}}(),he}var pe,Ke;function z(){if(Ke)return pe;Ke=1;var t=k,e=g;function r(n){t.call(this,n??"canceled",t.ERR_CANCELED),this.name="CanceledError"}return e.inherits(r,t,{__CANCEL__:!0}),pe=r,pe}var me,Xe;function mr(){return Xe||(Xe=1,me=function(e){var r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return r&&r[1]||""}),me}var ve,ze;function Qe(){if(ze)return ve;ze=1;var t=g,e=or(),r=ur(),n=Be,i=Je,a=hr(),s=pr(),o=$e,u=k,f=z(),l=mr();return ve=function(c){return new Promise(function(j,b){var A=c.data,W=c.headers,H=c.responseType,M;function bt(){c.cancelToken&&c.cancelToken.unsubscribe(M),c.signal&&c.signal.removeEventListener("abort",M)}t.isFormData(A)&&t.isStandardBrowserEnv()&&delete W["Content-Type"];var d=new XMLHttpRequest;if(c.auth){var sn=c.auth.username||"",on=c.auth.password?unescape(encodeURIComponent(c.auth.password)):"";W.Authorization="Basic "+btoa(sn+":"+on)}var Ae=i(c.baseURL,c.url);d.open(c.method.toUpperCase(),n(Ae,c.params,c.paramsSerializer),!0),d.timeout=c.timeout;function St(){if(d){var S="getAllResponseHeaders"in d?a(d.getAllResponseHeaders()):null,$=!H||H==="text"||H==="json"?d.responseText:d.response,N={data:$,status:d.status,statusText:d.statusText,headers:S,config:c,request:d};e(function(qe){j(qe),bt()},function(qe){b(qe),bt()},N),d=null}}if("onloadend"in d?d.onloadend=St:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(St)},d.onabort=function(){d&&(b(new u("Request aborted",u.ECONNABORTED,c,d)),d=null)},d.onerror=function(){b(new u("Network Error",u.ERR_NETWORK,c,d,d)),d=null},d.ontimeout=function(){var $=c.timeout?"timeout of "+c.timeout+"ms exceeded":"timeout exceeded",N=c.transitional||o;c.timeoutErrorMessage&&($=c.timeoutErrorMessage),b(new u($,N.clarifyTimeoutError?u.ETIMEDOUT:u.ECONNABORTED,c,d)),d=null},t.isStandardBrowserEnv()){var xt=(c.withCredentials||s(Ae))&&c.xsrfCookieName?r.read(c.xsrfCookieName):void 0;xt&&(W[c.xsrfHeaderName]=xt)}"setRequestHeader"in d&&t.forEach(W,function($,N){typeof A>"u"&&N.toLowerCase()==="content-type"?delete W[N]:d.setRequestHeader(N,$)}),t.isUndefined(c.withCredentials)||(d.withCredentials=!!c.withCredentials),H&&H!=="json"&&(d.responseType=c.responseType),typeof c.onDownloadProgress=="function"&&d.addEventListener("progress",c.onDownloadProgress),typeof c.onUploadProgress=="function"&&d.upload&&d.upload.addEventListener("progress",c.onUploadProgress),(c.cancelToken||c.signal)&&(M=function(S){d&&(b(!S||S&&S.type?new f:S),d.abort(),d=null)},c.cancelToken&&c.cancelToken.subscribe(M),c.signal&&(c.signal.aborted?M():c.signal.addEventListener("abort",M))),A||(A=null);var Ce=l(Ae);if(Ce&&["http","https","file"].indexOf(Ce)===-1){b(new u("Unsupported protocol "+Ce+":",u.ERR_BAD_REQUEST,c));return}d.send(A)})},ve}var ge,Ye;function vr(){return Ye||(Ye=1,ge=null),ge}var m=g,Ze=ar,et=k,gr=$e,wr=Fe,yr={"Content-Type":"application/x-www-form-urlencoded"};function tt(t,e){!m.isUndefined(t)&&m.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Er(){var t;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(t=Qe()),t}function Rr(t,e,r){if(m.isString(t))try{return(e||JSON.parse)(t),m.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Q={transitional:gr,adapter:Er(),transformRequest:[function(e,r){if(Ze(r,"Accept"),Ze(r,"Content-Type"),m.isFormData(e)||m.isArrayBuffer(e)||m.isBuffer(e)||m.isStream(e)||m.isFile(e)||m.isBlob(e))return e;if(m.isArrayBufferView(e))return e.buffer;if(m.isURLSearchParams(e))return tt(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n=m.isObject(e),i=r&&r["Content-Type"],a;if((a=m.isFileList(e))||n&&i==="multipart/form-data"){var s=this.env&&this.env.FormData;return wr(a?{"files[]":e}:e,s&&new s)}else if(n||i==="application/json")return tt(r,"application/json"),Rr(e);return e}],transformResponse:[function(e){var r=this.transitional||Q.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,a=!n&&this.responseType==="json";if(a||i&&m.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(a)throw s.name==="SyntaxError"?et.from(s,et.ERR_BAD_RESPONSE,this,null,this.response):s}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:vr()},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};m.forEach(["delete","get","head"],function(e){Q.headers[e]={}}),m.forEach(["post","put","patch"],function(e){Q.headers[e]=m.merge(yr)});var we=Q,Tr=g,br=we,Sr=function(e,r,n){var i=this||br;return Tr.forEach(n,function(s){e=s.call(i,e,r)}),e},ye,rt;function nt(){return rt||(rt=1,ye=function(e){return!!(e&&e.__CANCEL__)}),ye}var it=g,Ee=Sr,xr=nt(),Or=we,Pr=z();function Re(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Pr}var Ar=function(e){Re(e),e.headers=e.headers||{},e.data=Ee.call(e,e.data,e.headers,e.transformRequest),e.headers=it.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),it.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Or.adapter;return r(e).then(function(i){return Re(e),i.data=Ee.call(e,i.data,i.headers,e.transformResponse),i},function(i){return xr(i)||(Re(e),i&&i.response&&(i.response.data=Ee.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})},E=g,at=function(e,r){r=r||{};var n={};function i(l,h){return E.isPlainObject(l)&&E.isPlainObject(h)?E.merge(l,h):E.isPlainObject(h)?E.merge({},h):E.isArray(h)?h.slice():h}function a(l){if(E.isUndefined(r[l])){if(!E.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],r[l])}function s(l){if(!E.isUndefined(r[l]))return i(void 0,r[l])}function o(l){if(E.isUndefined(r[l])){if(!E.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,r[l])}function u(l){if(l in r)return i(e[l],r[l]);if(l in e)return i(void 0,e[l])}var f={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:u};return E.forEach(Object.keys(e).concat(Object.keys(r)),function(h){var c=f[h]||a,w=c(h);E.isUndefined(w)&&c!==u||(n[h]=w)}),n},Te,st;function ot(){return st||(st=1,Te={version:"0.27.2"}),Te}var Cr=ot().version,q=k,be={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){be[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var ut={};be.transitional=function(e,r,n){function i(a,s){return"[Axios v"+Cr+"] Transitional option '"+a+"'"+s+(n?". "+n:"")}return function(a,s,o){if(e===!1)throw new q(i(s," has been removed"+(r?" in "+r:"")),q.ERR_DEPRECATED);return r&&!ut[s]&&(ut[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,s,o):!0}};function qr(t,e,r){if(typeof t!="object")throw new q("options must be an object",q.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(t),i=n.length;i-- >0;){var a=n[i],s=e[a];if(s){var o=t[a],u=o===void 0||s(o,a,t);if(u!==!0)throw new q("option "+a+" must be "+u,q.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new q("Unknown option "+a,q.ERR_BAD_OPTION)}}var Ir={assertOptions:qr,validators:be},ct=g,Lr=Be,lt=nr,ft=Ar,Y=at,Nr=Je,dt=Ir,B=dt.validators;function _(t){this.defaults=t,this.interceptors={request:new lt,response:new lt}}_.prototype.request=function(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Y(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var n=r.transitional;n!==void 0&&dt.assertOptions(n,{silentJSONParsing:B.transitional(B.boolean),forcedJSONParsing:B.transitional(B.boolean),clarifyTimeoutError:B.transitional(B.boolean)},!1);var i=[],a=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(r)===!1||(a=a&&w.synchronous,i.unshift(w.fulfilled,w.rejected))});var s=[];this.interceptors.response.forEach(function(w){s.push(w.fulfilled,w.rejected)});var o;if(!a){var u=[ft,void 0];for(Array.prototype.unshift.apply(u,i),u=u.concat(s),o=Promise.resolve(r);u.length;)o=o.then(u.shift(),u.shift());return o}for(var f=r;i.length;){var l=i.shift(),h=i.shift();try{f=l(f)}catch(c){h(c);break}}try{o=ft(f)}catch(c){return Promise.reject(c)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},_.prototype.getUri=function(e){e=Y(this.defaults,e);var r=Nr(e.baseURL,e.url);return Lr(r,e.params,e.paramsSerializer)},ct.forEach(["delete","get","head","options"],function(e){_.prototype[e]=function(r,n){return this.request(Y(n||{},{method:e,url:r,data:(n||{}).data}))}}),ct.forEach(["post","put","patch"],function(e){function r(n){return function(a,s,o){return this.request(Y(o||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:s}))}}_.prototype[e]=r(),_.prototype[e+"Form"]=r(!0)});var Dr=_,Se,ht;function Ur(){if(ht)return Se;ht=1;var t=z();function e(r){if(typeof r!="function")throw new TypeError("executor must be a function.");var n;this.promise=new Promise(function(s){n=s});var i=this;this.promise.then(function(a){if(i._listeners){var s,o=i._listeners.length;for(s=0;s<o;s++)i._listeners[s](a);i._listeners=null}}),this.promise.then=function(a){var s,o=new Promise(function(u){i.subscribe(u),s=u}).then(a);return o.cancel=function(){i.unsubscribe(s)},o},r(function(s){i.reason||(i.reason=new t(s),n(i.reason))})}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]},e.prototype.unsubscribe=function(n){if(this._listeners){var i=this._listeners.indexOf(n);i!==-1&&this._listeners.splice(i,1)}},e.source=function(){var n,i=new e(function(s){n=s});return{token:i,cancel:n}},Se=e,Se}var xe,pt;function kr(){return pt||(pt=1,xe=function(e){return function(n){return e.apply(null,n)}}),xe}var Oe,mt;function Br(){if(mt)return Oe;mt=1;var t=g;return Oe=function(r){return t.isObject(r)&&r.isAxiosError===!0},Oe}var vt=g,_r=Ne,Z=Dr,jr=at,Mr=we;function gt(t){var e=new Z(t),r=_r(Z.prototype.request,e);return vt.extend(r,Z.prototype,e),vt.extend(r,e),r.create=function(i){return gt(jr(t,i))},r}var y=gt(Mr);y.Axios=Z,y.CanceledError=z(),y.CancelToken=Ur(),y.isCancel=nt(),y.VERSION=ot().version,y.toFormData=Fe,y.AxiosError=k,y.Cancel=y.CanceledError,y.all=function(e){return Promise.all(e)},y.spread=kr(),y.isAxiosError=Br(),Dt.exports=y,V.default=y,function(t){t.exports=V}(Nt);const $r=Lt(ne),Fr={timeout:6e3},ee=class{constructor(){}static setRequestType(e="POST"){this.method=e}static setRequestUrl(e=""){this.url=e}static setRequestConfigs(e){this.url=e==null?void 0:e.requestUrl,this.config={...this.config,...e==null?void 0:e.requesHeader}}static httpRequestGet(e){return ee.axiosInstance.get(this.url,this.config).then(r=>r.data).catch()}static httpRequestPost(e){return ee.axiosInstance.post(this.url,e,this.config).then(r=>r.data).catch()}};let P=ee;p(P,"method","POST"),p(P,"url",""),p(P,"config",{responseType:"json",withCredentials:!0}),p(P,"axiosInstance",$r.create(Fr));let wt=!1;function Wr(t){wt=t}function I({logMake:t="",logInfo:e=""}){wt&&console.log([t,e])}async function yt(){let t=[];try{t=await Ct("monito")}catch(r){I({logMake:"获取数据错误",logInfo:r})}function e(r){return JSON.parse(r.value)}return t.map(e)}function Et(){return qt("monito")}function Pe(){return re("monito")}class Hr{constructor(){p(this,"projectName","");p(this,"userInfo",{userCode:""});p(this,"requesKey","value");p(this,"url","");p(this,"http");p(this,"maxRequesGatewayLength",10);p(this,"monito",new CustomEvent("monito",{detail:{getAllData:yt,getCountData:Et,clearData:Pe}}));this.http=new P}DBinit(){Le(this.projectName+this.userInfo.userCode,"1",[{storeName:"monito",option:{keyPath:"id"},index:[{name:"id",keyPath:"id",unique:!0},{name:"elementText",keyPath:"elementText",unique:!1},{name:"pageUrl",keyPath:"pageUrl",unique:!1},{name:"actionType",keyPath:"actionType",unique:!1}]}])}storageData(e){It("monito","1",async({add:r})=>{console.log();try{r({id:e.id||(e==null?void 0:e.entetTim)||new Date().getTime().toString(),elementText:e==null?void 0:e.elementText,actionType:e==null?void 0:e.actionType,pageUrl:e==null?void 0:e.pageUrl,value:JSON.stringify(e)})}catch(n){I({logInfo:n,logMake:"存储数据失败"})}try{const n=await Et();if(window.dispatchEvent(this.monito),this.url&&Number(n)>this.maxRequesGatewayLength){const i=await yt(),a=await P.httpRequestPost({[this.requesKey]:i});I({logInfo:a,logMake:"上传数据成功"}),await Pe()}}catch(n){await Pe(),I({logInfo:n,logMake:"上传数据失败"})}})}setMaxRequesLength(e=10){this.maxRequesGatewayLength=e}setUserInfo(e){this.userInfo=e}setUrl(e){this.url=e}setRequesKey(e){this.requesKey=e}setPackageName(e){this.projectName=e}}const Jr=Yr(),Vr=Zr(),{availHeight:Gr,availWidth:Kr,width:Xr,height:zr}=window.screen;async function Qr({isPosition:t}){let e="";if(t)try{e=await en()}catch(r){e=r}return{availWidth:Kr.toString(),availHeight:Gr.toString(),resolution:`${Xr}*${zr}`,systemType:Jr,...Vr,position:e}}function Yr(){let t="Unknown";return window.navigator.userAgent.indexOf("Windows NT 10.0")!==-1?t="Windows 10":window.navigator.userAgent.indexOf("Windows NT 6.2")!==-1?t="Windows 8":window.navigator.userAgent.indexOf("Windows NT 6.1")!==-1?t="Windows 7":window.navigator.userAgent.indexOf("Windows NT 6.0")!==-1?t="Windows Vista":window.navigator.userAgent.indexOf("Windows NT 5.1")!==-1?t="Windows XP":window.navigator.userAgent.indexOf("Windows NT 5.0")!==-1?t="Windows 2000":window.navigator.userAgent.indexOf("iPhone")!==-1?t="iPhone":window.navigator.userAgent.indexOf("Android")!==-1?t="Android":window.navigator.userAgent.indexOf("Mac")!==-1?t="Mac":window.navigator.userAgent.indexOf("X11")!==-1?t="UNIX":(window.navigator.userAgent.indexOf("Linux")!==-1&&(t="Linux"),t)}function Zr(){const t={phoneVision:"",phoneBrand:""},e=navigator.userAgent,r=e.indexOf("Android")>-1||e.indexOf("Linux")>-1,n=!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),i=navigator.userAgent.split(";")[1],a=e.match(/\(.*?\)/),s=a?a[0]:"";if(r&&(t.phoneVision=i.match(/\d/g),t.phoneBrand=s.split(";")[2]),n){const o=i.match(/(\d+)_(\d+)?(\d+)?/);t.phoneVision=o?o[0]:"",t.phoneBrand=s.split(";")[1]}return t}function en(){return new Promise((t,e)=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(function(r){let n=r.coords.latitude,i=r.coords.longitude;t({latitude:n,longitude:i})},function(r){e(r)}):e("你的浏览器不支持当前地理位置信息获取")})}const tn={getGlobalData:Qr};function Rt(){return new Promise((t,e)=>{const r=[];new PerformanceObserver(n=>{for(const i of n.getEntries())r.push({name:i.name,duration:i.duration});t(r)}).observe({entryTypes:["longtask","frame","navigation","resource","mark","measure","paint"]})})}function Tt(){const t=window.performance.timing,{domainLookupEnd:e,domainLookupStart:r,connectEnd:n,connectStart:i,responseStart:a,navigationStart:s,domContentLoadedEventEnd:o,loadEventEnd:u,loadEventStart:f}=t;return{DNS:e-r,TCP:n-i,WhitecrSeend:a-s,DOM:o-s,Load:u-f}}class rn{constructor(){p(this,"projectName","");p(this,"data");p(this,"newPageUrl","");p(this,"oldPageUrl","");p(this,"pageTimeIfon",{});p(this,"pageAllrecord",{});p(this,"isPosition",!1);p(this,"userInfo",null);p(this,"maxRequesGatewayLength",10);p(this,"url","");p(this,"requesKey","value");this.data=new Hr}getGlobalData(){return new Promise(async(e,r)=>{const n=await tn.getGlobalData({isPosition:this.isPosition});e(n)})}async getPerformanceData(){const e=Tt();return{allResourceLoad:await Rt(),aboutPerformances:e}}pageUrlRecord(e,r="",n){this.oldPageUrl=r,this.newPageUrl=e,this.pageEnter(e,r,n)}async pageEnter(e,r,n){const i=new Date().getTime();if(r){this.pageTimeIfon[r].leaveTime=i,this.pageTimeIfon[r].pageUrl=e,this.pageTimeIfon[r].oldURL=r;const a=this.pageTimeIfon[r].leaveTime,s=this.pageTimeIfon[r].entetTim;this.pageTimeIfon[r].remainTime=a-s,this.track(this.pageTimeIfon[r]),delete this.pageTimeIfon[r]}try{let a={allResource:[]};this.pageAllrecord[e]||(a.allResource=await Rt());const s=Tt();this.pageTimeIfon[e]={actionType:n,pageUrl:e,entetTim:i,...s,...a},this.pageAllrecord[e]=e}catch(a){I({logInfo:a,logMake:"页面进入记录报错"})}}pageTrack(e){let r="index",n=this.newPageUrl;if(e.pageUrl){const s=/\/([^\/]*)$/;r=e.pageUrl.match(s),n=r[1]===""?"index":r[1]}const a={pageBack:()=>{this.pageUrlRecord(n,this.newPageUrl,e.actionType)},pagejump:()=>{this.pageUrlRecord(n,this.newPageUrl,e.actionType)},pageLoad:()=>{this.pageUrlRecord(n,this.newPageUrl,e.actionType)}}[e.actionType];a()}async track(e){const r=await this.getGlobalData(),n={...e,...r,userInfo:this.userInfo,projectName:this.projectName};let i=n.actionType;if(n.actionType==="click"&&(i=n==null?void 0:n.elementText),n.actionType==="click-img"&&(i=n.imgSrc),I({logMake:i,logInfo:n}),this.url&&this.maxRequesGatewayLength===1)try{await P.httpRequestPost({[this.requesKey]:n}),await re()}catch(a){I({logInfo:a,logMake:"上传数据失败"}),await re()}else this.data.storageData(n)}setPackageName(e){this.projectName=e,this.data.setPackageName(e)}setisPosition(e){this.isPosition=e}setUserInfo(e){this.userInfo=e,this.data.setUserInfo(e)}dbInit(){this.data.DBinit()}setMaxRequesLength(e=10){this.maxRequesGatewayLength=e,this.data.setMaxRequesLength(e)}setRequesKey(e){this.requesKey=e,this.data.setRequesKey(e)}setUrl(e){this.url=e,this.data.setUrl(e)}}class nn{constructor(){p(this,"dataProcess");p(this,"pageMonito",{vue:{info:"页面跳转",actionType:"pagejump"},uniapp:{info:"应用首次进入",actionType:"pageLoad"}});p(this,"monitoConfigList",[{elementText:"",actionType:""}]);p(this,"monitoImgList",[{imgSrc:""}]);this.dataProcess=new rn}eventInit(e){var s,o;this.monitoConfigList=e.globaMonitoConfigList,this.monitoImgList=e.globaMonitoImgList??[],this.dataProcess.setisPosition(e.isPosition),this.dataProcess.setPackageName(e.projectName),this.dataProcess.setUserInfo(e.userInfo),this.dataProcess.setMaxRequesLength(e.maxRequesGatewayLength),this.dataProcess.setRequesKey((s=e.reques)==null?void 0:s.requesKey),this.dataProcess.setUrl((o=e.reques)==null?void 0:o.requestUrl),this.dataProcess.dbInit();const r={};this.monitoConfigList.forEach(u=>r[u.elementText]=u);const n={};this.monitoImgList.forEach(u=>n[u.imgSrc]=u);const i=/\/([^\/]*)$/;v.addEventListener({element:window,type:"click",handler:async u=>{var h,c,w,j,b;const f=new Date().getTime(),l=document.elementFromPoint(u.pageX,u.pageY);if((l==null?void 0:l.nodeName)==="IMG"){const A=l==null?void 0:l.src.match(i)[1];l!=null&&l.src.includes((h=n[A])==null?void 0:h.imgSrc)&&await this.dataProcess.track({id:f.toString(),pageUrl:l.baseURI,actionType:"click-img",imgSrc:(c=n[A])==null?void 0:c.imgSrc,...n[(w=n[A])==null?void 0:w.imgSrc]})}l&&r[(j=l==null?void 0:l.textContent)==null?void 0:j.trim()]&&await this.dataProcess.track({id:f.toString(),pageUrl:l.baseURI,actionType:"click",elementText:l==null?void 0:l.textContent,...r[(b=l==null?void 0:l.textContent)==null?void 0:b.trim()]})}}),v.addEventListener({element:document,type:"visibilitychange",handler:u=>{}}),v.addEventListener({element:window,type:"popstate",handler:u=>{this.dataProcess.pageTrack({id:u.timeStamp.toString(),info:"页面返回",pageUrl:document.baseURI,actionType:"pageBack"})}});const a=function(u){const f=history[u];return function(){f.apply(history,arguments);const l=new Event(u);return l.arguments=arguments,window.dispatchEvent(l),f}};history.pushState=a("pushState"),history.replaceState=a("replaceState"),v.addEventListener({element:window,type:"replaceState",handler:u=>{const f=document.baseURI;this.dataProcess.pageTrack({id:u.timeStamp.toString(),info:this.pageMonito.uniapp.info,pageUrl:f,actionType:this.pageMonito.uniapp.actionType}),["vue","react"].includes(e.frameType)&&(this.pageMonito.uniapp=this.pageMonito.vue)}}),e.frameType==="uniapp"&&v.addEventListener({element:window,type:"pushState",handler:u=>{const f=u.arguments[2];console.log("页面跳转",f),this.dataProcess.pageTrack({id:u.timeStamp.toString(),info:"页面跳转",pageUrl:f,actionType:"pagejump"})}})}async track(e){try{await this.dataProcess.track(e)}catch(r){I({logInfo:r,logMake:"initTrack错误"})}}}class an{constructor(){p(this,"monitoInit");this.monitoInit=new nn}init(e){const{reques:r,monitoSwitch:n=!0,showLog:i=!1}=e;n&&(Wr(i),this.monitoInit.eventInit(e),P.setRequestConfigs(r))}track(e){this.monitoInit.track(e)}}return an});