UNPKG

monito-action

Version:

H5全埋点组件

276 lines 84.7 kB
(function(L,E){typeof exports=="object"&&typeof module<"u"?module.exports=E():typeof define=="function"&&define.amd?define(E):(L=typeof globalThis<"u"?globalThis:L||self,L["muk-ui"]=E())})(this,function(){"use strict";var Ro=Object.defineProperty;var Oo=(L,E,M)=>E in L?Ro(L,E,{enumerable:!0,configurable:!0,writable:!0,value:M}):L[E]=M;var p=(L,E,M)=>(Oo(L,typeof E!="symbol"?E+"":E,M),M);console.log("🚀 立即劫持模块加载");const L=globalThis.Page;L?(console.log("🔧 开始立即劫持 Page 构造函数"),globalThis.Page=function(n){console.log("📄 Page 构造函数被调用,立即注入 globalClick 方法"),n||(n={}),n.globalClick=function(t){console.log("📱 globalClick 被调用",t),E(t,this)},n.autoTrack=function(t){console.log("📱 autoTrack 被调用",t),E(t,this)},n.handleAnyClick=function(t){console.log("📱 handleAnyClick 被调用",t),E(t,this)};const e=n.onLoad;return n.onLoad=function(t){console.log("📄 页面 onLoad - 检查方法注入:"),console.log("- globalClick:",typeof this.globalClick),console.log("- autoTrack:",typeof this.autoTrack),console.log("- handleAnyClick:",typeof this.handleAnyClick),typeof this.globalClick!="function"?(console.error("❌ globalClick 方法仍然不存在!执行紧急修复"),this.globalClick=function(o){console.log("🚨 紧急修复的 globalClick"),E(o,this)}):console.log("✅ globalClick 方法注入成功"),e&&typeof e=="function"&&e.call(this,t)},console.log("📄 方法注入完成,调用原始 Page"),L.call(this,n)},console.log("✅ Page 构造函数劫持完成")):console.error("❌ Page 构造函数不存在,可能不在小程序环境中");function E(n,e){console.log("🎯 处理全局点击事件",n);const t=n.target||n.currentTarget,o=(t==null?void 0:t.dataset)||{};console.log("点击目标:",{target:t,dataset:o}),M(o)?(console.log("✅ 检测到需要埋点的元素"),At(o,e)):console.log("⏭️ 元素不需要埋点,忽略")}function M(n){return n?!!(n.text||n.src||n.track):!1}function At(n,e){const t={elementText:n.text,imgSrc:n.src,trackType:n.track,pageUrl:(e==null?void 0:e.route)||"unknown",timestamp:new Date().getTime()};console.log("📊 埋点数据:",t);try{const o=getApp();if(o.globalData&&o.globalData.monitoInit&&o.globalData.monitoInit.handleGlobalClick){console.log("🌐 调用全局埋点处理器");const i={target:{dataset:n},currentTarget:{dataset:n},dataset:n,timeStamp:t.timestamp};o.globalData.monitoInit.handleGlobalClick(i)}else console.warn("⚠️ 全局埋点处理器未初始化,使用本地处理"),_e(t)}catch(o){console.error("❌ 调用全局埋点处理器失败:",o),_e(t)}}function _e(n){console.log("💾 使用本地埋点处理器"),typeof wx<"u"&&wx.showToast&&wx.showToast({title:`埋点: ${n.elementText||n.imgSrc||n.trackType}`,icon:"none",duration:1500});try{if(typeof wx<"u"&&wx.setStorageSync){const e="local_tracking_data";let t=wx.getStorageSync(e)||[];t.push(n),t.length>100&&(t=t.slice(-100)),wx.setStorageSync(e,t),console.log("✅ 埋点数据已存储到本地")}}catch(e){console.error("❌ 本地存储失败:",e)}}globalThis.__emergencyGlobalClick=function(n){console.log("🚨 全局紧急修复方法被调用",n),E(n,null)},console.log("🚨 紧急修复方法已设置到全局对象"),console.log("✅ 立即劫持模块加载完成");function Rt({element:n,type:e,handler:t}){n.addEventListener(e,t)}const W={addEventListener:Rt};function ve(n,e){return function(){return n.apply(e,arguments)}}const{toString:Ot}=Object.prototype,{getPrototypeOf:be}=Object,{iterator:Z,toStringTag:je}=Symbol,ee=(n=>e=>{const t=Ot.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),D=n=>(n=n.toLowerCase(),e=>ee(e)===n),te=n=>e=>typeof e===n,{isArray:$}=Array,J=te("undefined");function z(n){return n!==null&&!J(n)&&n.constructor!==null&&!J(n.constructor)&&O(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const Be=D("ArrayBuffer");function Lt(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Be(n.buffer),e}const Nt=te("string"),O=te("function"),Me=te("number"),V=n=>n!==null&&typeof n=="object",Dt=n=>n===!0||n===!1,ne=n=>{if(ee(n)!=="object")return!1;const e=be(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(je in n)&&!(Z in n)},It=n=>{if(!V(n)||z(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},Ut=D("Date"),_t=D("File"),vt=D("Blob"),jt=D("FileList"),Bt=n=>V(n)&&O(n.pipe),Mt=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||O(n.append)&&((e=ee(n))==="formdata"||e==="object"&&O(n.toString)&&n.toString()==="[object FormData]"))},Ft=D("URLSearchParams"),[qt,Gt,$t,Ht]=["ReadableStream","Request","Response","Headers"].map(D),Wt=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let o,i;if(typeof n!="object"&&(n=[n]),$(n))for(o=0,i=n.length;o<i;o++)e.call(null,n[o],o,n);else{if(z(n))return;const r=t?Object.getOwnPropertyNames(n):Object.keys(n),s=r.length;let a;for(o=0;o<s;o++)a=r[o],e.call(null,n[a],a,n)}}function Fe(n,e){if(z(n))return null;e=e.toLowerCase();const t=Object.keys(n);let o=t.length,i;for(;o-- >0;)if(i=t[o],e===i.toLowerCase())return i;return null}const F=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),qe=n=>!J(n)&&n!==F;function we(){const{caseless:n}=qe(this)&&this||{},e={},t=(o,i)=>{const r=n&&Fe(e,i)||i;ne(e[r])&&ne(o)?e[r]=we(e[r],o):ne(o)?e[r]=we({},o):$(o)?e[r]=o.slice():e[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&K(arguments[o],t);return e}const Jt=(n,e,t,{allOwnKeys:o}={})=>(K(e,(i,r)=>{t&&O(i)?n[r]=ve(i,t):n[r]=i},{allOwnKeys:o}),n),zt=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Vt=(n,e,t,o)=>{n.prototype=Object.create(e.prototype,o),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},Kt=(n,e,t,o)=>{let i,r,s;const a={};if(e=e||{},n==null)return e;do{for(i=Object.getOwnPropertyNames(n),r=i.length;r-- >0;)s=i[r],(!o||o(s,n,e))&&!a[s]&&(e[s]=n[s],a[s]=!0);n=t!==!1&&be(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Xt=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const o=n.indexOf(e,t);return o!==-1&&o===t},Qt=n=>{if(!n)return null;if($(n))return n;let e=n.length;if(!Me(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},Yt=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&be(Uint8Array)),Zt=(n,e)=>{const o=(n&&n[Z]).call(n);let i;for(;(i=o.next())&&!i.done;){const r=i.value;e.call(n,r[0],r[1])}},en=(n,e)=>{let t;const o=[];for(;(t=n.exec(e))!==null;)o.push(t);return o},tn=D("HTMLFormElement"),nn=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Ge=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),on=D("RegExp"),$e=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),o={};K(t,(i,r)=>{let s;(s=e(i,r,n))!==!1&&(o[r]=s||i)}),Object.defineProperties(n,o)},rn=n=>{$e(n,(e,t)=>{if(O(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=n[t];if(O(o)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},sn=(n,e)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return $(n)?o(n):o(String(n).split(e)),t},an=()=>{},ln=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function cn(n){return!!(n&&O(n.append)&&n[je]==="FormData"&&n[Z])}const un=n=>{const e=new Array(10),t=(o,i)=>{if(V(o)){if(e.indexOf(o)>=0)return;if(z(o))return o;if(!("toJSON"in o)){e[i]=o;const r=$(o)?[]:{};return K(o,(s,a)=>{const u=t(s,i+1);!J(u)&&(r[a]=u)}),e[i]=void 0,r}}return o};return t(n,0)},dn=D("AsyncFunction"),fn=n=>n&&(V(n)||O(n))&&O(n.then)&&O(n.catch),He=((n,e)=>n?setImmediate:e?((t,o)=>(F.addEventListener("message",({source:i,data:r})=>{i===F&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),F.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",O(F.postMessage)),hn=typeof queueMicrotask<"u"?queueMicrotask.bind(F):typeof process<"u"&&process.nextTick||He,l={isArray:$,isArrayBuffer:Be,isBuffer:z,isFormData:Mt,isArrayBufferView:Lt,isString:Nt,isNumber:Me,isBoolean:Dt,isObject:V,isPlainObject:ne,isEmptyObject:It,isReadableStream:qt,isRequest:Gt,isResponse:$t,isHeaders:Ht,isUndefined:J,isDate:Ut,isFile:_t,isBlob:vt,isRegExp:on,isFunction:O,isStream:Bt,isURLSearchParams:Ft,isTypedArray:Yt,isFileList:jt,forEach:K,merge:we,extend:Jt,trim:Wt,stripBOM:zt,inherits:Vt,toFlatObject:Kt,kindOf:ee,kindOfTest:D,endsWith:Xt,toArray:Qt,forEachEntry:Zt,matchAll:en,isHTMLForm:tn,hasOwnProperty:Ge,hasOwnProp:Ge,reduceDescriptors:$e,freezeMethods:rn,toObjectSet:sn,toCamelCase:nn,noop:an,toFiniteNumber:ln,findKey:Fe,global:F,isContextDefined:qe,isSpecCompliantForm:cn,toJSONObject:un,isAsyncFn:dn,isThenable:fn,setImmediate:He,asap:hn,isIterable:n=>n!=null&&O(n[Z])};function b(n,e,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}l.inherits(b,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:l.toJSONObject(this.config),code:this.code,status:this.status}}});const We=b.prototype,Je={};["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","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{Je[n]={value:n}}),Object.defineProperties(b,Je),Object.defineProperty(We,"isAxiosError",{value:!0}),b.from=(n,e,t,o,i,r)=>{const s=Object.create(We);return l.toFlatObject(n,s,function(u){return u!==Error.prototype},a=>a!=="isAxiosError"),b.call(s,n.message,e,t,o,i),s.cause=n,s.name=n.name,r&&Object.assign(s,r),s};const gn=null;function ke(n){return l.isPlainObject(n)||l.isArray(n)}function ze(n){return l.endsWith(n,"[]")?n.slice(0,-2):n}function Ve(n,e,t){return n?n.concat(e).map(function(i,r){return i=ze(i),!t&&r?"["+i+"]":i}).join(t?".":""):e}function pn(n){return l.isArray(n)&&!n.some(ke)}const mn=l.toFlatObject(l,{},null,function(e){return/^is[A-Z]/.test(e)});function oe(n,e,t){if(!l.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=l.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!l.isUndefined(g[m])});const o=t.metaTokens,i=t.visitor||d,r=t.dots,s=t.indexes,u=(t.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(e);if(!l.isFunction(i))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(l.isBoolean(h))return h.toString();if(!u&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?u&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function d(h,m,g){let k=h;if(h&&!g&&typeof h=="object"){if(l.endsWith(m,"{}"))m=o?m:m.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&pn(h)||(l.isFileList(h)||l.endsWith(m,"[]"))&&(k=l.toArray(h)))return m=ze(m),k.forEach(function(C,N){!(l.isUndefined(C)||C===null)&&e.append(s===!0?Ve([m],N,r):s===null?m:m+"[]",c(C))}),!1}return ke(h)?!0:(e.append(Ve(g,m,r),c(h)),!1)}const f=[],y=Object.assign(mn,{defaultVisitor:d,convertValue:c,isVisitable:ke});function w(h,m){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(h),l.forEach(h,function(k,T){(!(l.isUndefined(k)||k===null)&&i.call(e,k,l.isString(T)?T.trim():T,m,y))===!0&&w(k,m?m.concat(T):[T])}),f.pop()}}if(!l.isObject(n))throw new TypeError("data must be an object");return w(n),e}function Ke(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(o){return e[o]})}function Te(n,e){this._pairs=[],n&&oe(n,this,e)}const Xe=Te.prototype;Xe.append=function(e,t){this._pairs.push([e,t])},Xe.toString=function(e){const t=e?function(o){return e.call(this,o,Ke)}:Ke;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function yn(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Qe(n,e,t){if(!e)return n;const o=t&&t.encode||yn;l.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(e,t):r=l.isURLSearchParams(e)?e.toString():new Te(e,t).toString(o),r){const s=n.indexOf("#");s!==-1&&(n=n.slice(0,s)),n+=(n.indexOf("?")===-1?"?":"&")+r}return n}class bn{constructor(){this.handlers=[]}use(e,t,o){return this.handlers.push({fulfilled:e,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){l.forEach(this.handlers,function(o){o!==null&&e(o)})}}const Ye=bn,Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},wn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Te,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ce=typeof window<"u"&&typeof document<"u",Se=typeof navigator=="object"&&navigator||void 0,kn=Ce&&(!Se||["ReactNative","NativeScript","NS"].indexOf(Se.product)<0),Tn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),Cn=Ce&&window.location.href||"http://localhost",A={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ce,hasStandardBrowserEnv:kn,hasStandardBrowserWebWorkerEnv:Tn,navigator:Se,origin:Cn},Symbol.toStringTag,{value:"Module"})),...wn};function Sn(n,e){return oe(n,new A.classes.URLSearchParams,{visitor:function(t,o,i,r){return A.isNode&&l.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...e})}function xn(n){return l.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function En(n){const e={},t=Object.keys(n);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],e[r]=n[r];return e}function et(n){function e(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=r>=t.length;return s=!s&&l.isArray(i)?i.length:s,u?(l.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!a):((!i[s]||!l.isObject(i[s]))&&(i[s]=[]),e(t,o,i[s],r)&&l.isArray(i[s])&&(i[s]=En(i[s])),!a)}if(l.isFormData(n)&&l.isFunction(n.entries)){const t={};return l.forEachEntry(n,(o,i)=>{e(xn(o),i,t,0)}),t}return null}function Pn(n,e,t){if(l.isString(n))try{return(e||JSON.parse)(n),l.trim(n)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(n)}const xe={transitional:Ze,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=l.isObject(e);if(r&&l.isHTMLForm(e)&&(e=new FormData(e)),l.isFormData(e))return i?JSON.stringify(et(e)):e;if(l.isArrayBuffer(e)||l.isBuffer(e)||l.isStream(e)||l.isFile(e)||l.isBlob(e)||l.isReadableStream(e))return e;if(l.isArrayBufferView(e))return e.buffer;if(l.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return Sn(e,this.formSerializer).toString();if((a=l.isFileList(e))||o.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return oe(a?{"files[]":e}:e,u&&new u,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Pn(e)):e}],transformResponse:[function(e){const t=this.transitional||xe.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(l.isResponse(e)||l.isReadableStream(e))return e;if(e&&l.isString(e)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(a){if(s)throw a.name==="SyntaxError"?b.from(a,b.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:A.classes.FormData,Blob:A.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],n=>{xe.headers[n]={}});const Ee=xe,An=l.toObjectSet(["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"]),Rn=n=>{const e={};let t,o,i;return n&&n.split(`
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||e[t]&&An[t])&&(t==="set-cookie"?e[t]?e[t].push(o):e[t]=[o]:e[t]=e[t]?e[t]+", "+o:o)}),e},tt=Symbol("internals");function X(n){return n&&String(n).trim().toLowerCase()}function ie(n){return n===!1||n==null?n:l.isArray(n)?n.map(ie):String(n)}function On(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(n);)e[o[1]]=o[2];return e}const Ln=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Pe(n,e,t,o,i){if(l.isFunction(o))return o.call(this,e,t);if(i&&(e=t),!!l.isString(e)){if(l.isString(o))return e.indexOf(o)!==-1;if(l.isRegExp(o))return o.test(e)}}function Nn(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,o)=>t.toUpperCase()+o)}function Dn(n,e){const t=l.toCamelCase(" "+e);["get","set","has"].forEach(o=>{Object.defineProperty(n,o+t,{value:function(i,r,s){return this[o].call(this,e,i,r,s)},configurable:!0})})}class re{constructor(e){e&&this.set(e)}set(e,t,o){const i=this;function r(a,u,c){const d=X(u);if(!d)throw new Error("header name must be a non-empty string");const f=l.findKey(i,d);(!f||i[f]===void 0||c===!0||c===void 0&&i[f]!==!1)&&(i[f||u]=ie(a))}const s=(a,u)=>l.forEach(a,(c,d)=>r(c,d,u));if(l.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(l.isString(e)&&(e=e.trim())&&!Ln(e))s(Rn(e),t);else if(l.isObject(e)&&l.isIterable(e)){let a={},u,c;for(const d of e){if(!l.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(u=a[c])?l.isArray(u)?[...u,d[1]]:[u,d[1]]:d[1]}s(a,t)}else e!=null&&r(t,e,o);return this}get(e,t){if(e=X(e),e){const o=l.findKey(this,e);if(o){const i=this[o];if(!t)return i;if(t===!0)return On(i);if(l.isFunction(t))return t.call(this,i,o);if(l.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=X(e),e){const o=l.findKey(this,e);return!!(o&&this[o]!==void 0&&(!t||Pe(this,this[o],o,t)))}return!1}delete(e,t){const o=this;let i=!1;function r(s){if(s=X(s),s){const a=l.findKey(o,s);a&&(!t||Pe(o,o[a],a,t))&&(delete o[a],i=!0)}}return l.isArray(e)?e.forEach(r):r(e),i}clear(e){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!e||Pe(this,this[r],r,e,!0))&&(delete this[r],i=!0)}return i}normalize(e){const t=this,o={};return l.forEach(this,(i,r)=>{const s=l.findKey(o,r);if(s){t[s]=ie(i),delete t[r];return}const a=e?Nn(r):String(r).trim();a!==r&&delete t[r],t[a]=ie(i),o[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return l.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=e&&l.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const o=new this(e);return t.forEach(i=>o.set(i)),o}static accessor(e){const o=(this[tt]=this[tt]={accessors:{}}).accessors,i=this.prototype;function r(s){const a=X(s);o[a]||(Dn(i,s),o[a]=!0)}return l.isArray(e)?e.forEach(r):r(e),this}}re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),l.reduceDescriptors(re.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(o){this[t]=o}}}),l.freezeMethods(re);const I=re;function Ae(n,e){const t=this||Ee,o=e||t,i=I.from(o.headers);let r=o.data;return l.forEach(n,function(a){r=a.call(t,r,i.normalize(),e?e.status:void 0)}),i.normalize(),r}function nt(n){return!!(n&&n.__CANCEL__)}function H(n,e,t){b.call(this,n??"canceled",b.ERR_CANCELED,e,t),this.name="CanceledError"}l.inherits(H,b,{__CANCEL__:!0});function ot(n,e,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?n(t):e(new b("Request failed with status code "+t.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function In(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function Un(n,e){n=n||10;const t=new Array(n),o=new Array(n);let i=0,r=0,s;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),d=o[r];s||(s=c),t[i]=u,o[i]=c;let f=r,y=0;for(;f!==i;)y+=t[f++],f=f%n;if(i=(i+1)%n,i===r&&(r=(r+1)%n),c-s<e)return;const w=d&&c-d;return w?Math.round(y*1e3/w):void 0}}function _n(n,e){let t=0,o=1e3/e,i,r;const s=(c,d=Date.now())=>{t=d,i=null,r&&(clearTimeout(r),r=null),n(...c)};return[(...c)=>{const d=Date.now(),f=d-t;f>=o?s(c,d):(i=c,r||(r=setTimeout(()=>{r=null,s(i)},o-f)))},()=>i&&s(i)]}const se=(n,e,t=3)=>{let o=0;const i=Un(50,250);return _n(r=>{const s=r.loaded,a=r.lengthComputable?r.total:void 0,u=s-o,c=i(u),d=s<=a;o=s;const f={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:c||void 0,estimated:c&&a&&d?(a-s)/c:void 0,event:r,lengthComputable:a!=null,[e?"download":"upload"]:!0};n(f)},t)},it=(n,e)=>{const t=n!=null;return[o=>e[0]({lengthComputable:t,total:n,loaded:o}),e[1]]},rt=n=>(...e)=>l.asap(()=>n(...e)),vn=A.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,A.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(A.origin),A.navigator&&/(msie|trident)/i.test(A.navigator.userAgent)):()=>!0,jn=A.hasStandardBrowserEnv?{write(n,e,t,o,i,r){const s=[n+"="+encodeURIComponent(e)];l.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),l.isString(o)&&s.push("path="+o),l.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Bn(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Mn(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function st(n,e,t){let o=!Bn(e);return n&&(o||t==!1)?Mn(n,e):e}const at=n=>n instanceof I?{...n}:n;function q(n,e){e=e||{};const t={};function o(c,d,f,y){return l.isPlainObject(c)&&l.isPlainObject(d)?l.merge.call({caseless:y},c,d):l.isPlainObject(d)?l.merge({},d):l.isArray(d)?d.slice():d}function i(c,d,f,y){if(l.isUndefined(d)){if(!l.isUndefined(c))return o(void 0,c,f,y)}else return o(c,d,f,y)}function r(c,d){if(!l.isUndefined(d))return o(void 0,d)}function s(c,d){if(l.isUndefined(d)){if(!l.isUndefined(c))return o(void 0,c)}else return o(void 0,d)}function a(c,d,f){if(f in e)return o(c,d);if(f in n)return o(void 0,c)}const u={url:r,method:r,data:r,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(c,d,f)=>i(at(c),at(d),f,!0)};return l.forEach(Object.keys({...n,...e}),function(d){const f=u[d]||i,y=f(n[d],e[d],d);l.isUndefined(y)&&f!==a||(t[d]=y)}),t}const lt=n=>{const e=q({},n);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:a}=e;e.headers=s=I.from(s),e.url=Qe(st(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(l.isFormData(t)){if(A.hasStandardBrowserEnv||A.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[c,...d]=u?u.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([c||"multipart/form-data",...d].join("; "))}}if(A.hasStandardBrowserEnv&&(o&&l.isFunction(o)&&(o=o(e)),o||o!==!1&&vn(e.url))){const c=i&&r&&jn.read(r);c&&s.set(i,c)}return e},Fn=typeof XMLHttpRequest<"u"&&function(n){return new Promise(function(t,o){const i=lt(n);let r=i.data;const s=I.from(i.headers).normalize();let{responseType:a,onUploadProgress:u,onDownloadProgress:c}=i,d,f,y,w,h;function m(){w&&w(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(d),i.signal&&i.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function k(){if(!g)return;const C=I.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:C,config:n,request:g};ot(function(S){t(S),m()},function(S){o(S),m()},P),g=null}"onloadend"in g?g.onloadend=k:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(k)},g.onabort=function(){g&&(o(new b("Request aborted",b.ECONNABORTED,n,g)),g=null)},g.onerror=function(){o(new b("Network Error",b.ERR_NETWORK,n,g)),g=null},g.ontimeout=function(){let N=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const P=i.transitional||Ze;i.timeoutErrorMessage&&(N=i.timeoutErrorMessage),o(new b(N,P.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,n,g)),g=null},r===void 0&&s.setContentType(null),"setRequestHeader"in g&&l.forEach(s.toJSON(),function(N,P){g.setRequestHeader(P,N)}),l.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),c&&([y,h]=se(c,!0),g.addEventListener("progress",y)),u&&g.upload&&([f,w]=se(u),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",w)),(i.cancelToken||i.signal)&&(d=C=>{g&&(o(!C||C.type?new H(null,n,g):C),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(d),i.signal&&(i.signal.aborted?d():i.signal.addEventListener("abort",d)));const T=In(i.url);if(T&&A.protocols.indexOf(T)===-1){o(new b("Unsupported protocol "+T+":",b.ERR_BAD_REQUEST,n));return}g.send(r||null)})},qn=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let o=new AbortController,i;const r=function(c){if(!i){i=!0,a();const d=c instanceof Error?c:this.reason;o.abort(d instanceof b?d:new H(d instanceof Error?d.message:d))}};let s=e&&setTimeout(()=>{s=null,r(new b(`timeout ${e} of ms exceeded`,b.ETIMEDOUT))},e);const a=()=>{n&&(s&&clearTimeout(s),s=null,n.forEach(c=>{c.unsubscribe?c.unsubscribe(r):c.removeEventListener("abort",r)}),n=null)};n.forEach(c=>c.addEventListener("abort",r));const{signal:u}=o;return u.unsubscribe=()=>l.asap(a),u}},Gn=function*(n,e){let t=n.byteLength;if(!e||t<e){yield n;return}let o=0,i;for(;o<t;)i=o+e,yield n.slice(o,i),o=i},$n=async function*(n,e){for await(const t of Hn(n))yield*Gn(t,e)},Hn=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:o}=await e.read();if(t)break;yield o}}finally{await e.cancel()}},ct=(n,e,t,o)=>{const i=$n(n,e);let r=0,s,a=u=>{s||(s=!0,o&&o(u))};return new ReadableStream({async pull(u){try{const{done:c,value:d}=await i.next();if(c){a(),u.close();return}let f=d.byteLength;if(t){let y=r+=f;t(y)}u.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},ae=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ut=ae&&typeof ReadableStream=="function",Wn=ae&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),dt=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Jn=ut&&dt(()=>{let n=!1;const e=new Request(A.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),ft=64*1024,Re=ut&&dt(()=>l.isReadableStream(new Response("").body)),le={stream:Re&&(n=>n.body)};ae&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!le[e]&&(le[e]=l.isFunction(n[e])?t=>t[e]():(t,o)=>{throw new b(`Response type '${e}' is not supported`,b.ERR_NOT_SUPPORT,o)})})})(new Response);const zn=async n=>{if(n==null)return 0;if(l.isBlob(n))return n.size;if(l.isSpecCompliantForm(n))return(await new Request(A.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(l.isArrayBufferView(n)||l.isArrayBuffer(n))return n.byteLength;if(l.isURLSearchParams(n)&&(n=n+""),l.isString(n))return(await Wn(n)).byteLength},Vn=async(n,e)=>{const t=l.toFiniteNumber(n.getContentLength());return t??zn(e)},Oe={http:gn,xhr:Fn,fetch:ae&&(async n=>{let{url:e,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:c,headers:d,withCredentials:f="same-origin",fetchOptions:y}=lt(n);c=c?(c+"").toLowerCase():"text";let w=qn([i,r&&r.toAbortSignal()],s),h;const m=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let g;try{if(u&&Jn&&t!=="get"&&t!=="head"&&(g=await Vn(d,o))!==0){let P=new Request(e,{method:"POST",body:o,duplex:"half"}),U;if(l.isFormData(o)&&(U=P.headers.get("content-type"))&&d.setContentType(U),P.body){const[S,ye]=it(g,se(rt(u)));o=ct(P.body,ft,S,ye)}}l.isString(f)||(f=f?"include":"omit");const k="credentials"in Request.prototype;h=new Request(e,{...y,signal:w,method:t.toUpperCase(),headers:d.normalize().toJSON(),body:o,duplex:"half",credentials:k?f:void 0});let T=await fetch(h,y);const C=Re&&(c==="stream"||c==="response");if(Re&&(a||C&&m)){const P={};["status","statusText","headers"].forEach(Pt=>{P[Pt]=T[Pt]});const U=l.toFiniteNumber(T.headers.get("content-length")),[S,ye]=a&&it(U,se(rt(a),!0))||[];T=new Response(ct(T.body,ft,S,()=>{ye&&ye(),m&&m()}),P)}c=c||"text";let N=await le[l.findKey(le,c)||"text"](T,n);return!C&&m&&m(),await new Promise((P,U)=>{ot(P,U,{data:N,headers:I.from(T.headers),status:T.status,statusText:T.statusText,config:n,request:h})})}catch(k){throw m&&m(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new b("Network Error",b.ERR_NETWORK,n,h),{cause:k.cause||k}):b.from(k,k&&k.code,n,h)}})};l.forEach(Oe,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const ht=n=>`- ${n}`,Kn=n=>l.isFunction(n)||n===null||n===!1,gt={getAdapter:n=>{n=l.isArray(n)?n:[n];const{length:e}=n;let t,o;const i={};for(let r=0;r<e;r++){t=n[r];let s;if(o=t,!Kn(t)&&(o=Oe[(s=String(t)).toLowerCase()],o===void 0))throw new b(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=e?r.length>1?`since :
`+r.map(ht).join(`
`):" "+ht(r[0]):"as no adapter specified";throw new b("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:Oe};function Le(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new H(null,n)}function pt(n){return Le(n),n.headers=I.from(n.headers),n.data=Ae.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),gt.getAdapter(n.adapter||Ee.adapter)(n).then(function(o){return Le(n),o.data=Ae.call(n,n.transformResponse,o),o.headers=I.from(o.headers),o},function(o){return nt(o)||(Le(n),o&&o.response&&(o.response.data=Ae.call(n,n.transformResponse,o.response),o.response.headers=I.from(o.response.headers))),Promise.reject(o)})}const mt="1.11.0",ce={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{ce[n]=function(o){return typeof o===n||"a"+(e<1?"n ":" ")+n}});const yt={};ce.transitional=function(e,t,o){function i(r,s){return"[Axios v"+mt+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,a)=>{if(e===!1)throw new b(i(s," has been removed"+(t?" in "+t:"")),b.ERR_DEPRECATED);return t&&!yt[s]&&(yt[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(r,s,a):!0}},ce.spelling=function(e){return(t,o)=>(console.warn(`${o} is likely a misspelling of ${e}`),!0)};function Xn(n,e,t){if(typeof n!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const o=Object.keys(n);let i=o.length;for(;i-- >0;){const r=o[i],s=e[r];if(s){const a=n[r],u=a===void 0||s(a,r,n);if(u!==!0)throw new b("option "+r+" must be "+u,b.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new b("Unknown option "+r,b.ERR_BAD_OPTION)}}const ue={assertOptions:Xn,validators:ce},_=ue.validators;class de{constructor(e){this.defaults=e||{},this.interceptors={request:new Ye,response:new Ye}}async request(e,t){try{return await this._request(e,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
`+r):o.stack=r}catch{}}throw o}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=q(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&ue.assertOptions(o,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),i!=null&&(l.isFunction(i)?t.paramsSerializer={serialize:i}:ue.assertOptions(i,{encode:_.function,serialize:_.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ue.assertOptions(t,{baseUrl:_.spelling("baseURL"),withXsrfToken:_.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&l.merge(r.common,r[t.method]);r&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete r[h]}),t.headers=I.concat(s,r);const a=[];let u=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(u=u&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let d,f=0,y;if(!u){const h=[pt.bind(this),void 0];for(h.unshift(...a),h.push(...c),y=h.length,d=Promise.resolve(t);f<y;)d=d.then(h[f++],h[f++]);return d}y=a.length;let w=t;for(f=0;f<y;){const h=a[f++],m=a[f++];try{w=h(w)}catch(g){m.call(this,g);break}}try{d=pt.call(this,w)}catch(h){return Promise.reject(h)}for(f=0,y=c.length;f<y;)d=d.then(c[f++],c[f++]);return d}getUri(e){e=q(this.defaults,e);const t=st(e.baseURL,e.url,e.allowAbsoluteUrls);return Qe(t,e.params,e.paramsSerializer)}}l.forEach(["delete","get","head","options"],function(e){de.prototype[e]=function(t,o){return this.request(q(o||{},{method:e,url:t,data:(o||{}).data}))}}),l.forEach(["post","put","patch"],function(e){function t(o){return function(r,s,a){return this.request(q(a||{},{method:e,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}de.prototype[e]=t(),de.prototype[e+"Form"]=t(!0)});const fe=de;class Ne{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const o=this;this.promise.then(i=>{if(!o._listeners)return;let r=o._listeners.length;for(;r-- >0;)o._listeners[r](i);o._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(a=>{o.subscribe(a),r=a}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},e(function(r,s,a){o.reason||(o.reason=new H(r,s,a),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=o=>{e.abort(o)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Ne(function(i){e=i}),cancel:e}}}const Qn=Ne;function Yn(n){return function(t){return n.apply(null,t)}}function Zn(n){return l.isObject(n)&&n.isAxiosError===!0}const De={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(De).forEach(([n,e])=>{De[e]=n});const eo=De;function bt(n){const e=new fe(n),t=ve(fe.prototype.request,e);return l.extend(t,fe.prototype,e,{allOwnKeys:!0}),l.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return bt(q(n,i))},t}const x=bt(Ee);x.Axios=fe,x.CanceledError=H,x.CancelToken=Qn,x.isCancel=nt,x.VERSION=mt,x.toFormData=oe,x.AxiosError=b,x.Cancel=x.CanceledError,x.all=function(e){return Promise.all(e)},x.spread=Yn,x.isAxiosError=Zn,x.mergeConfig=q,x.AxiosHeaders=I,x.formToJSON=n=>et(l.isHTMLForm(n)?new FormData(n):n),x.getAdapter=gt.getAdapter,x.HttpStatusCode=eo,x.default=x;const to=x,no={timeout:6e3},me=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 me.axiosInstance.get(this.url,this.config).then(t=>t.data).catch()}static httpRequestPost(e){return me.axiosInstance.post(this.url,e,this.config).then(t=>t.data).catch()}};let v=me;p(v,"method","POST"),p(v,"url",""),p(v,"config",{responseType:"json",withCredentials:!0}),p(v,"axiosInstance",to.create(no));let wt=!1;function oo(n){wt=n}function R({logMake:n="",logInfo:e=""}){wt&&console.log([n,e])}let G=class{static isWeb(){return typeof window<"u"&&typeof document<"u"}static isMiniProgram(){return typeof globalThis.wx<"u"||typeof globalThis.my<"u"||typeof globalThis.swan<"u"||typeof globalThis.tt<"u"}static isUniApp(){return typeof globalThis.uni<"u"}};class io{constructor(){p(this,"dbName","");p(this,"storeName","monito")}async init(e){this.dbName=e;const{createDB:t}=await Promise.resolve().then(()=>Y);await t(e,"1",[{storeName:this.storeName,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}]}])}async add(e){const{onDBSelect:t}=await Promise.resolve().then(()=>Y);return new Promise((o,i)=>{t(this.storeName,"1",async({add:r})=>{try{await 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)}),o()}catch(s){i(s)}})})}async getAll(){const{getAll:e}=await Promise.resolve().then(()=>Y);return(await e(this.storeName)).map(o=>JSON.parse(o.value))}async getCount(){const{getCount:e}=await Promise.resolve().then(()=>Y);return await e(this.storeName)}async clear(){const{clear:e}=await Promise.resolve().then(()=>Y);await e(this.storeName)}}class ro{constructor(){p(this,"storageKey","")}async init(e){this.storageKey=`monito_${e}`}async add(e){try{const t=await this.getAll(),o={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),timestamp:new Date().getTime()};t.push(o),G.isUniApp()?globalThis.uni.setStorageSync(this.storageKey,JSON.stringify(t)):this.getStorageAPI().setStorageSync(this.storageKey,JSON.stringify(t))}catch(t){throw R({logMake:"小程序存储失败",logInfo:t}),t}}async getAll(){try{let e="";return G.isUniApp()?e=globalThis.uni.getStorageSync(this.storageKey)||"[]":e=this.getStorageAPI().getStorageSync(this.storageKey)||"[]",JSON.parse(e).map(o=>JSON.parse(o.value))}catch(e){return R({logMake:"小程序读取数据失败",logInfo:e}),[]}}async getCount(){return(await this.getAll()).length}async clear(){try{G.isUniApp()?globalThis.uni.removeStorageSync(this.storageKey):this.getStorageAPI().removeStorageSync(this.storageKey)}catch(e){R({logMake:"小程序清除数据失败",logInfo:e})}}getStorageAPI(){if(typeof globalThis.wx<"u")return globalThis.wx;if(typeof globalThis.my<"u")return globalThis.my;if(typeof globalThis.swan<"u")return globalThis.swan;if(typeof globalThis.tt<"u")return globalThis.tt;throw new Error("未知的小程序环境")}}class so{constructor(){p(this,"listeners",{})}dispatchEvent(e,t){if(G.isWeb()){const o=new CustomEvent(e,{detail:t});window.dispatchEvent(o)}else(this.listeners[e]||[]).forEach(i=>{try{i({detail:t})}catch(r){R({logMake:"事件处理失败",logInfo:r})}})}addEventListener(e,t){G.isWeb()?window.addEventListener(e,t):(this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t))}removeEventListener(e,t){if(G.isWeb())window.removeEventListener(e,t);else{const o=this.listeners[e];if(o){const i=o.indexOf(t);i>-1&&o.splice(i,1)}}}}class ao{static create(){return G.isWeb()?new io:new ro}}const kt=new so;class lo{constructor(){p(this,"projectName","");p(this,"userInfo",{userCode:""});p(this,"url","");p(this,"http");p(this,"maxRequesGatewayLength",10);p(this,"storageAdapter");this.http=new v,this.storageAdapter=ao.create()}async DBinit(){try{const e=this.projectName+this.userInfo.userCode;await this.storageAdapter.init(e),kt.dispatchEvent("monito",{getAllData:()=>this.getAllData(),getCountData:()=>this.getCountData(),clearData:()=>this.clearData()})}catch(e){R({logMake:"数据库初始化失败",logInfo:e})}}async getAllData(){try{return await this.storageAdapter.getAll()}catch(e){return R({logMake:"获取数据错误",logInfo:e}),[]}}async getCountData(){try{return await this.storageAdapter.getCount()}catch(e){return R({logMake:"获取数据条数错误",logInfo:e}),0}}async clearData(){try{await this.storageAdapter.clear()}catch(e){R({logMake:"清除数据错误",logInfo:e})}}async storageData(e){try{await this.storageAdapter.add(e),kt.dispatchEvent("monito",{getAllData:()=>this.getAllData(),getCountData:()=>this.getCountData(),clearData:()=>this.clearData()});const t=await this.getCountData();if(this.url&&t>Number(this.maxRequesGatewayLength)){const o=await this.getAllData(),i=await v.httpRequestPost(o);R({logInfo:i,logMake:"上传数据成功"}),await this.clearData()}}catch(t){await this.clearData(),R({logInfo:t,logMake:"存储或上传数据失败"})}}setMaxRequesLength(e=10){this.maxRequesGatewayLength=e}setUserInfo(e){this.userInfo=e}setUrl(e){this.url=e}setPackageName(e){this.projectName=e}}function co({isPosition:n}){return new Promise(async(e,t)=>{let o="";if(n)try{o=await Promise.race([ho(),new Promise((i,r)=>setTimeout(()=>r("获取位置信息总体超时"),3e3))])}catch(i){console.warn("获取位置信息失败:",i),o=typeof i=="string"?i:"位置获取失败"}setTimeout(()=>{const i=uo(),r=fo(),{availHeight:s,availWidth:a,width:u,height:c}=window.screen;e({availWidth:a.toString(),availHeight:s.toString(),resolution:`${u}*${c}`,systemType:i,...r,position:o})})})}function uo(){let n="Unknown";return window.navigator.userAgent.indexOf("Windows NT 10.0")!==-1?n="Windows 10":window.navigator.userAgent.indexOf("Windows NT 6.2")!==-1?n="Windows 8":window.navigator.userAgent.indexOf("Windows NT 6.1")!==-1?n="Windows 7":window.navigator.userAgent.indexOf("Windows NT 6.0")!==-1?n="Windows Vista":window.navigator.userAgent.indexOf("Windows NT 5.1")!==-1?n="Windows XP":window.navigator.userAgent.indexOf("Windows NT 5.0")!==-1?n="Windows 2000":window.navigator.userAgent.indexOf("iPhone")!==-1?n="iPhone":window.navigator.userAgent.indexOf("Android")!==-1?n="Android":window.navigator.userAgent.indexOf("Mac")!==-1?n="Mac":window.navigator.userAgent.indexOf("X11")!==-1?n="UNIX":(window.navigator.userAgent.indexOf("Linux")!==-1&&(n="Linux"),n)}function fo(){const n={phoneVision:"",phoneBrand:""},e=navigator.userAgent,t=e.indexOf("Android")>-1||e.indexOf("Linux")>-1,o=!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),i=navigator.userAgent.split(";")[1],r=e.match(/\(.*?\)/),s=r?r[0]:"";if(t&&(n.phoneVision=i.match(/\d/g),n.phoneBrand=s.split(";")[2]),o){const a=i.match(/(\d+)_(\d+)?(\d+)?/);n.phoneVision=a?a[0]:"",n.phoneBrand=s.split(";")[1]}return n}function ho(){return new Promise((n,e)=>{if(!navigator.geolocation){e("你的浏览器不支持当前地理位置信息获取");return}const t=setTimeout(()=>{e("获取地理位置超时")},5e3);navigator.geolocation.getCurrentPosition(function(o){clearTimeout(t);let i=o.coords.latitude,r=o.coords.longitude;n({latitude:i,longitude:r})},function(o){clearTimeout(t),e(o)},{timeout:5e3,enableHighAccuracy:!1,maximumAge:3e5})})}const go={getGlobalData:co};function Tt(){return new Promise((n,e)=>{const t=[];new PerformanceObserver(o=>{for(const i of o.getEntries())t.push({name:i.name,duration:i.duration});n(t)}).observe({entryTypes:["longtask","frame","navigation","resource","mark","measure","paint"]})})}function Ct(){const n=window.performance.timing,{domainLookupEnd:e,domainLookupStart:t,connectEnd:o,connectStart:i,responseStart:r,navigationStart:s,domContentLoadedEventEnd:a,loadEventEnd:u,loadEventStart:c}=n;return{DNS:e-t,TCP:o-i,WhitecrSeend:r-s,DOM:a-s,Load:u-c}}const he=window||globalThis,St=he.indexedDB||he.mozIndexedDB||he.webkitIndexedDB||he.msIndexedDB,B={};let Q,ge;const xt=(n,e,t)=>new Promise((o,i)=>{var r;if(St||i("浏览器不支持indexedDB"),Q=n,B!=null&&B[n]){o(B[n]);return}ge=St.open(n,e),(r=Et(t))==null||r.then(s=>o(s)),ge.onsuccess=s=>{const a=s.target.result;B[n]=a,o(a)},ge.onerror=s=>i(s)}),Et=n=>{if(n)return new Promise(e=>{ge.onupgradeneeded=t=>{const o=t.target.result;B[Q]=o;for(const i in n)if(!o.objectStoreNames.contains(n[i].storeName)){const r=o.createObjectStore(n[i].storeName,n[i].option);for(const s of n[i].index)r.createIndex(s.name,s.keyPath,{unique:s.unique})}e(o)}})},po=async(n,e)=>{let t;return B[Q]?t=B[Q]:t=await xt(Q,e),t.transaction(n,"readwrite")},Ie=async(n,e)=>(await po(n,e)).objectStore(n),j=(n,e,t)=>new Promise(o=>{Ie(n).then(i=>{const r=i[e](t);r.onsuccess=s=>o(s.target.result)})}),mo=(n,e,t,o,i)=>new Promise((r,s)=>{Ie(n).then(a=>{const u=a.openCursor(IDBKeyRange.bound(e,t,o,i));u.onsuccess=c=>r(c.target.result),u.onerror=c=>s(c)})});function yo(n){return j(n,"getAll")}function bo(n){return j(n,"count")}function Ue(n){return j(n,"clear")}const Y=Object.freeze(Object.defineProperty({__proto__:null,clear:Ue,createDB:xt,createTable:Et,getAll:yo,getCount:bo,onDBSelect:async(n,e,t)=>{const f={add:y=>j(n,"add",y),get:y=>j(n,"get",y),clear:y=>j(n,"clear",y),del:y=>j(n,"delete",y),put:y=>j(n,"put",y),find:(y,w,h,m)=>mo(n,y,w,h,m),getAll:()=>j(n,"getAll"),getCount:()=>j(n,"count")};return Ie(n,e),t(f),f}},Symbol.toStringTag,{value:"Module"}));class wo{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","");this.data=new lo}async getGlobalData(){try{return await go.getGlobalData({isPosition:this.isPosition})}catch(e){return console.error("获取全局数据失败:",e),{availWidth:window.screen.availWidth.toString(),availHeight:window.screen.availHeight.toString(),resolution:`${window.screen.width}*${window.screen.height}`,systemType:"Unknown",phoneBrand:"",phoneVision:"",position:"获取失败"}}}async getPerformanceData(){const e=Ct();return{allResourceLoad:await Tt(),aboutPerformances:e}}pageUrlRecord(e,t="",o){this.oldPageUrl=t,this.newPageUrl=e,this.pageEnter(e,t,o)}async pageEnter(e,t,o){const i=new Date().getTime();if(t){this.pageTimeIfon[t].leaveTime=i,this.pageTimeIfon[t].pageUrl=e,this.pageTimeIfon[t].oldURL=t;const r=this.pageTimeIfon[t].leaveTime,s=this.pageTimeIfon[t].entetTim;this.pageTimeIfon[t].remainTime=r-s,this.track(this.pageTimeIfon[t]),delete this.pageTimeIfon[t]}try{let r={allResource:[]};this.pageAllrecord[e]||(r.allResource=await Tt());const s=Ct();this.pageTimeIfon[e]={actionType:o,pageUrl:e,entetTim:i,...s,...r},this.pageAllrecord[e]=e}catch(r){R({logInfo:r,logMake:"页面进入记录报错"})}}pageTrack(e){let t="index",o=this.newPageUrl;if(e.pageUrl){const s=/\/([^\/]*)$/;t=e.pageUrl.match(s),o=t[1]===""?"index":t[1]}const r={pageBack:()=>{this.pageUrlRecord(o,this.newPageUrl,e.actionType)},pagejump:()=>{this.pageUrlRecord(o,this.newPageUrl,e.actionType)},pageLoad:()=>{this.pageUrlRecord(o,this.newPageUrl,e.actionType)}}[e.actionType];r()}async track(e){const t=await this.getGlobalData(),o={...e,...t,userInfo:this.userInfo,projectName:this.projectName};let i=o.actionType||"unknown";if(o.actionType==="click"&&(i=(o==null?void 0:o.elementText)||"click"),o.actionType==="click-img"&&(i=o.imgSrc||"click-img"),R({logMake:i,logInfo:o}),this.url&&this.maxRequesGatewayLength===1)try{await v.httpRequestPost([o]),await Ue("monito"),R({logInfo:o,logMake:"上传数据"})}catch(r){R({logInfo:r,logMake:"上传数据失败"}),await Ue("monito")}else this.data.storageData(o)}setPackageName(e){this.projectName=e,this.data.setPackageName(e)}setisPosition(e){this.isPosition=e}setUserInfo(e){this.userInfo=e,this.data.setUserInfo(e)}async dbInit(){await this.data.DBinit()}setMaxRequesLength(e=10){this.maxRequesGatewayLength=e,this.data.setMaxRequesLength(e)}setUrl(e){this.url=e,this.data.setUrl(e)}}class ko{constructor(e,t,o){p(this,"viewMap",{});p(this,"imgMap",{});p(this,"handleGlobalClick");this.viewMap=e,this.imgMap=t,this.handleGlobalClick=o}enhancedPageScan(e){console.log("开始增强扫描..."),this.multiSelectorScan(e),setTimeout(()=>{this.delayedScan(e)},200),setTimeout(()=>{this.recursiveScan(e)},500)}multiSelectorScan(e){e.createSelectorQuery(),[{selector:"view",name:"view元素"},{selector:"[data-text]",name:"带data-text的元素"},{selector:"[data-src]",name:"带data-src的元素"},{selector:"button",name:"按钮元素"},{selector:"image",name:"图片元素"},{selector:"text",name:"文本元素"}].forEach((o,i)=>{const r=e.createSelectorQuery();r.selectAll(o.selector).boundingClientRect(),r.exec(s=>{s&&s[0]&&s[0].length>0?(console.log(`${o.name}扫描结果:`,s[0].length,"个元素"),s[0].forEach((a,u)=>{this.tryBindElement(e,a,`${i}_${u}`)})):console.log(`${o.name}扫描结果: 0个元素`)})})}delayedScan(e){console.log("执行延迟扫描...");const t=e.createSelectorQuery();t.selectAll("*").boundingClientRect(),t.exec(o=>{if(o&&o[0]){console.log(`延迟扫描找到 ${o[0].length} 个元素`);const i=o[0].filter(r=>r.width>0&&r.height>0);console.log(`其中 ${i.length} 个元素可能需要埋点`),i.forEach((r,s)=>{this.tryBindElement(e,r,`delayed_${s}`)})}})}recursiveScan(e){console.log("执行递归扫描..."),["view","button","image","text","navigator","scroll-view","swiper","swiper-item","movable-view","cover-view","cover-image",".btn",".button",".clickable",".item",".card",".list-item"].forEach((o,i)=>{setTimeout(()=>{const r=e.createSelectorQuery();r.selectAll(o).boundingClientRect(),r.exec(s=>{s&&s[0]&&s[0].length>0&&(console.log(`递归扫描 ${o}: ${s[0].length} 个元素`),s[0].forEach((a,u)=>{this.tryBindElement(e,a,`recursive_${i}_${u}`)}))})},i*50)})}tryBindElement(e,t,o){const i=`__autoHandler_${o}`;e[i]||(e[i]=r=>{console.log(`自动绑定的点击事件触发 - ${o}`,r),this.shouldTrackElement(r)&&this.handleGlobalClick(r)},console.log(`为元素创建处理器: ${i}`))}shouldTrackElement(e){const t=e.target||e.currentTarget;if(!t||!t.dataset)return!1;const o=t.dataset;return o.text||o.src||o.track?o.text&&this.viewMap[o.text]?(console.log("匹配到文本埋点配置:",o.text),!0):o.src&&this.imgMap[o.src]?(console.log("匹配到图片埋点配置:",o.src),!0):o.track?(console.log("匹配到自定义埋点配置:",o.track),!0):!1:!1}injectGlobalClickHandler(e){e.handleGlobalClick=t=>{console.log("全局点击处理器触发",t),this.shouldTrackElement(t)?this.handleGlobalClick(t):console.log("元素不需要埋点,忽略点击")},e.trackClick=t=>{console.log("手动埋点方法调用",t),this.handleGlobalClick(t)},console.log("已为页面注入全局点击处理器")}generateTemplateBindings(){return`
<!-- 在需要埋点的 view 元素上添加以下绑定 -->
<view data-text="打开按钮" bindtap="handleGlobalClick">
    打开
</view>

<!-- 或者使用便捷的埋点方法 -->
<view data-text="打开按钮" bindtap="trackClick">
    打开
</view>

<!-- 支持的所有元素类型 -->
<button data-text="按钮文本" bindtap="handleGlobalClick">按钮</button>
<image data-src="图片标识" bindtap="handleGlobalClick" />
<text data-text="文本内容" bindtap="handleGlobalClick">文本</text>
<navigator data-text="导航链接" bindtap="handleGlobalClick">链接</navigator>

<!-- 自定义埋点属性 -->
<view data-track="custom-event" bindtap="handleGlobalClick">自定义事件</view>
        `.trim()}}class To{constructor(e,t,o,i){p(this,"viewMap",{});p(this,"imgMap",{});p(this,"regex");p(this,"handleGlobalClick");this.viewMap=e,this.imgMap=t,this.regex=o,this.handleGlobalClick=i}injectRootClickHandler(e){console.log("注入根节点点击处理器"),e.__rootClickHandler=t=>{console.log("根节点点击事件触发",t),this.processRootClick(t)},e.handleAnyClick=t=>{console.log("通用点击处理",t),this.processRootClick(t)},e.autoTrack=t=>{console.log("自动埋点触发",t),this.processRootClick(t)},console.log("根节点点击处理器注入完成"),this.logUsageInstructions()}async processRootClick(e){try{const t=e.target||e.currentTarget,o=e.detail||{};if(console.log("处理点击事件:",{target:t,detail:o,dataset:t==null?void 0:t.dataset}),this.shouldTrackElement(t)){console.log("检测到需要埋点的元素,开始处理");const i=this.buildStandardEvent(e,t);await this.handleGlobalClick(i)}else console.log("元素不需要埋点,忽略")}catch(t){console.error("处理根节点点击事件失败:",t)}}shouldTrackElement(e){if(!e||!e.dataset)return!1;const t=e.dataset;return t.text||t.src||t.track?t.text&&this.viewMap[t.text]?(console.log("匹配到文本埋点配置:",t.text),!0):t.src&&this.imgMap[t.src]?(console.log("匹配到图片埋点配置:",t.src),!0):t.track?(console.log("匹配到自定义埋点配置:",t.track),!0):!1:!1}buildStandardEvent(e,t){return{type:"tap",timeStamp:e.timeStamp||Date.now(),target:t,currentTarget:t,detail:e.detail||{},dataset:t.dataset||{},...e}}logUsageInstructions(){console.log(`
=== 小程序根节点点击处理使用说明 ===

方案1: 在根容器上绑定全局点击事件
<view class="page-container" bindtap="__rootClickHandler">
    <!-- 所有页面内容 -->
    <view data-text="按钮1">按钮1</view>
    <view data-text="按钮2">按钮2</view>
    <image data-src="banner.jpg" />
</view>

方案2: 使用便捷的通用点击方法
<view data-text="任意元素" bindtap="handleAnyClick">
    任意需要埋点的元素
</view>

方案3: 使用自动埋点方法
<view data-text="自动埋点" bindtap="autoTrack">
    自动埋点元素
</view>

注意事项:
1. 确保元素有 data-text、data-src 或 data-track 属性
2. 属性值要与配置列表匹配
3. 根节点绑定会捕获所有子元素的点击事件
4. 系统会自动过滤不需要埋点的元素

推荐使用方案1,在页面根容器上绑定一次即可!
        `)}generateTemplateCode(){return`
<!-- 推荐方案:在页面根容器上绑定全局点击事件 -->
<view class="page-container" bindtap="__rootClickHandler">
    <!-- 页面内容 -->
    <view class="header">
        <text>页面标题</text>
    </view>
    
    <!-- 需要埋点的元素只需要添加 data 属性 -->
    <view class="content">
        <view data-text="打开按钮" class="btn">打开</view>
        <view data-text="关闭按钮" class="btn">关闭</view>
        <image data-src="banner.jpg" src="/images/banner.jpg" />
        
        <!-- 列表项 -->
        <view wx:for="{{list}}" wx:key="id" data-text="列表项{{item.id}}" class="list-item">
            {{item.name}}
        </view>
        
        <!-- 自定义埋点 -->
        <view data-track="special-action" class="special">特殊操作</view>
    </view>
</view>

<!-- 样式 -->
<style>
.page-container {
    min-height: 100vh;
    padding: 20rpx;
}

.btn {
    padding: 20rpx;
    margin: 10rpx 0;
    background-color: #007aff;
    color: white;
    text-align: center;
    border-radius: 8rpx;
}

.list-item {
    padding: 15rpx;
    margin: 5rpx 0;
    background-color: #f8f8f8;
    border-left: 4rpx solid #007aff;
}

.special {
    padding: 20rpx;
    background-color: #ff3b30;
    color: white;
    text-align: center;
    border-radius: 8rpx;
}
</style>
        `.trim()}generatePageJSCode(){return`
// 页面 JS 代码 - 无需手写埋点逻辑
Page({
    data: {
        list: [
            { id: 1, name: '项目1' },
            { id: 2, name: '项目2' },
            { id: 3, name: '项目3' }
        ]
    },

    onLoad() {
        console.log('页面加载');
        // 只需要写业务逻辑
    },

    onReady() {
        console.log('页面渲染完成');
        // __rootClickHandler 方法已被自动注入
        console.log('根节点点击处理器:', typeof this.__rootClickHandler);
    }

    // 注意:
    // 1. __rootClickHandler 方法会被自动注入
    // 2. handleAnyClick 和 autoTrack 方法也会被自动注入
    // 3. 无需手写任何埋点相关代码
    // 4. 在根容器上绑定 bindtap="__rootClickHandler" 即可捕获所有点击
});
        `.trim()}}class Co{constructor(e,t,o){p(this,"viewMap",{});p(this,"imgMap",{});p(this,"handleGlobalClick");p(this,"originalPageConstructor");this.viewMap=e,this.imgMap=t,this.handleGlobalClick=o,this.originalPageConstructor=globalThis.Page}init(){this.hijackPageConstructor(),this.setupGlobalEventCapture(),console.log("小程序全局事件系统已启动")}hijackPageConstructor(){if(!this.originalPageConstructor){console.error("原始 Page 构造函数不存在");return}const e=this;console.log("开始劫持 Page 构造函数"),globalThis.Page=function(t){return console.log("Page 构造函数被调用,注入全局事件处理",t),(!t||typeof t!="object")&&(t={}),t.globalClick=async function(o){console.log("globalClick 方法被调用",o);try{await e.processGlobalClick(o,this)}catch(i){console.error("globalClick 处理失败:",i)}},t.autoTrack=async function(o){console.log("autoTrack 方法被调用",o);try{await e.processGlobalClick(o,this)}catch(i){console.error("autoTrack 处理失败:",i)}},t.handleAnyClick=async function(o){console.log("handleAnyClick 方法被调用",o);try{await e.processGlobalClick(o,this)}catch(i){console.error("handleAnyClick 处理失败:",i)}},e.hijackLifecycle(t),console.log("方法注入完成,调用原始 Page 构造函数"),e.originalPageConstructor.call(this,t)},console.log("Page 构造函数劫持完成")}hijackClickMethods(e,t){const o=this;Object.keys(t).filter(r=>typeof t[r]=="function").forEach(r=>{const s=t[r];e[r]=async function(a){if(console.log(`方法 ${r} 被调用`,a),await o.processGlobalClick(a,this),s)return s.call(this,a)}})}injectConvenienceMethods(e){const t=this;e.globalClick=async o=>{console.log("globalClick 方法调用",o),await t.processGlobalClick(o,e)},e.autoTrack=async o=>{console.log("autoTrack 方法调用",o),await t.processGlobalClick(o,e)},e.handleAnyClick=async o=>{console.log("handleAnyClick 方法调用",o),await t.processGlobalClick(o,e)}}hijackLifecycle(e){const t=e.onLoad,o=e.onReady;e.onLoad=function(i){console.log("页面加载,全局事件捕获准备就绪"),typeof this.globalClick!="function"?console.warn("globalClick 方法不存在,可能注入失败"):console.log("globalClick 方法注入成功"),t&&typeof t=="function"&&t.call(this,i)},e.onReady=function(){console.log("页面渲染完成,检查全局事件方法"),console.log("方法检查结果:"),console.log("- globalClick:",typeof this.globalClick),console.log("- autoTrack:",typeof this.autoTrack),console.log("- handleAnyClick:",typeof this.handleAnyClick),o&&typeof o=="function"&&o.call(this),console.log(`
=== 全局事件捕获使用说明 ===

✅ 在模板中使用:
<view class="page" bindtap="globalClick">
    <view data-text="按钮1">按钮1</view>
    <view data-text="按钮2">按钮2</view>
</view>

🔧 确保:
1. 元素有 data-text、data-src 或 data-track 属性
2. 属性值在配置列表中
3. 在根容器上绑定 bindtap="globalClick"
            `)}}setupGlobalEventCapture(){console.log("设置全局事件捕获机制")}async processGlobalClick(e,t){try{const o=e.target||e.currentTarget;if(!o||!o.dataset)return;const i=o.dataset;if(console.log("处理全局点击",{dataset:i,target:o}),this.shouldTrackElement(i)){console.log("检测到需要埋点的元素");const r={...e,target:o,currentTarget:o,dataset:i};await this.handleGlobalClick(r)}}catch(o){console.error("处理全局点击失败:",o)}}shouldTrackElement(e){return e?e.text&&this.viewMap[e.text]?(console.log("匹配文本埋点:",e.text),!0):e.src&&this.imgMap[e.src]?(console.log("匹配图片埋点:",e.src),!0):e.track?(console.log("匹配自定义埋点:",e.track),!0):!1:!1}generateTemplateExample(){return`
<!-- 方案1: 根容器全局捕获(推荐) -->
<view class="page-container" bindtap="globalClick">
    <!-- 页面内容,所有点击都会被捕获 -->
    <view class="header">
        <text>页面标题</text>
    </view>
    
    <view class="content">
        <!-- 需要埋点的元素只需要 data 属性 -->
        <view data-text="打开按钮" class="btn">打开</view>
        <view data-text="关闭按钮" class="btn">关闭</view>
        <image data-src="banner.jpg" src="/images/banner.jpg" />
        
        <!-- 列表项 -->
        <view wx:for="{{list}}" wx:key="id" data-text="列表项{{item.id}}">
            {{item.name}}
        </view>
    </view>
</view>

<!-- 方案2: 单独绑定 -->
<view data-text="独立按钮" bindtap="autoTrack" class="btn">
    独立按钮
</view>

<!-- 方案3: 通用方法 -->
<view data-text="通用点击" bindtap="handleAnyClick" class="btn">
    通用点击
</view>
        `.trim()}generatePageJSExample(){return`
Page({
    data: {
        list: [
            { id: 1, name: '项目1' },
            { id: 2, name: '项目2' }
        ]
    },

    onLoad() {
        // 只需要写业务逻辑
        console.log('页面加载');
    },

    onReady() {
        // 全局事件捕获已自动就绪
        console.log('全局事件捕获已就绪');
    }

    // 注意:
    // 1. globalClick、autoTrack、handleAnyClick 方法已自动注入
    // 2. 所有原有的方法都会被包装,自动处理埋点
    // 3. 无需手写任何埋点代码
    // 4. 在根容器上绑定 bindtap="globalClick" 即可捕获所有点击
});
        `.trim()}}class So{constructor(e,t,o){p(this,"viewMap",{});p(this,"imgMap",{});p(this,"handleGlobalClick");p(this,"isInjected",!1);this.viewMap=e,this.imgMap=t,this.handleGlobalClick=o}inject(){if(this.isInjected){console.log("方法已经注入过,跳过");return}console.log("开始直接注入 globalClick 方法"),this.hijackPageConstructor(),this.hijackExistingPages(),this.setupGlobalMethods(),this.isInjected=!0,console.log("✅ 直接注入完成")}hijackPageConstructor(){const e=globalThis.Page;if(!e){console.error("Page 构造函数不存在");return}const t=this;console.log("劫持 Page 构造函数..."),globalThis.Page=function(o){console.log("🔧 Page 构造函数被调用,注入方法",o),o||(o={}),o.globalClick=function(r){return console.log("📱 globalClick 被调用",r),t.processClick(r,this)},o.autoTrack=function(r){return console.log("📱 autoTrack 被调用",r),t.processClick(r,this)},o.handleAnyClick=function(r){return console.log("📱 handleAnyClick 被调用",r),t.processClick(r,this)};const i=o.onLoad;return o.onLoad=function(r){console.log("📄 页面 onLoad,检查方法注入"),console.log("- globalClick:",typeof this.globalClick),console.log("- autoTrack:",typeof this.autoTrack),console.log("- handleAnyClick:",typeof this.handleAnyClick),typeof this.globalClick!="function"?(console.error("❌ globalClick 方法注入失败!"),this.globalClick=function(s){return console.log("🚨 紧急修复的 globalClick"),t.processClick(s,this)}):console.log("✅ globalClick 方法注入成功"),i&&typeof i=="function"&&i.call(this,r)},console.log("🔧 方法注入完成,调用原始 Page"),e.call(this,o)},console.log("✅ Page 构造函数劫持完成")}hijackExistingPages(){console.log("检查已存在的页面...");try{const e=globalThis.getCurrentPages;if(typeof e=="function"){const t=e();console.log(`发现 ${t.length} 个已存在的页面`),t.forEach((o,i)=>{console.log(`为页面 ${i} 注入方法`),this.injectToExistingPage(o)})}}catch(e){console.error("处理已存在页面失败:",e)}}injectToExistingPage(e){if(!e)return;const t=this;if(typeof e.globalClick=="function"){console.log("页面已有 globalClick 方法,跳过注入");return}e.globalClick=function(o){return console.log("📱 已存在页面的 globalClick 被调用",o),t.processClick(o,this)},e.autoTrack=function(o){return console.log("📱 已存在页面的 autoTrack 被调用",o),t.processClick(o,this)},e.handleAnyClick=function(o){return console.log("📱 已存在页面的 handleAnyClick 被调用",o),t.processClick(o,this)},console.log("✅ 已存在页面方法注入完成")}setupGlobalMethods(){console.log("设置全局方法..."),globalThis.__monitoGlobalClick=e=>(console.log("🌐 全局 globalClick 被调用",e),this.processClick(e,null)),console.log("✅ 全局方法设置完成")}async processClick(e,t){try{console.log("🎯 处理点击事件",e);const o=e.target||e.currentTarget,i=(o==null?void 0:o.dataset)||{};console.log("点击目标:",{target:o,dataset:i}),this.shouldTrack(i)?(console.log("✅ 需要埋点,调用处理器"),await this.handleGlobalClick(e)):console.log("⏭️ 不需要埋点,忽略")}catch(o){console.error("❌ 处理点击事件失败:",o)}}shouldTrack(e){return e?e.text&&this.viewMap[e.text]?(console.log("匹配文本埋点:",e.text),!0):e.src&&this.imgMap[e.src]?(console.log("匹配图片埋点:",e.src),!0):e.track?(console.log("匹配自定义埋点:",e.track),!0):!1:!1}static createEmergencyFix(e,t,o){console.log("🚨 创建紧急修复方法");const i=async r=>{console.log("🚨 紧急修复方法被调用",r);const s=r.target||r.currentTarget,a=(s==null?void 0:s.dataset)||{};a.text&&e[a.text]?await o(r):a.src&&t[a.src]?await o(r):a.track&&await o(r)};return globalThis.__emergencyGlobalClick=i,i}getUsageInstructions(){return`
=== 直接注入使用说明 ===

✅ 推荐用法(根容器绑定):
<view class="page" bindtap="globalClick">
    <view data-text="按钮1">按钮1</view>
    <view data-text="按钮2">按钮2</view>
</view>

🔧 备用方法:
- globalClick: 全局点击处理
- autoTrack: 自动埋点
- handleAnyClick: 通用点击处理

🚨 如果还是报错,请在页面 JS 中添加:
Page({
    onLoad() {
        if (typeof this.globalClick !== 'function') {
            this.globalClick = globalThis.__emergencyGlobalClick || function(evt) {
                console.log('紧急备用方法', evt);
            };
        }
    }
});

📱 检查方法是否存在:
console.log('globalClick:', typeof this.globalClick);
        `.trim()}}class xo{constructor(e,t,o,i){p(this,"viewMap",{});p(this,"imgMap",{});p(this,"regex");p(this,"handleGlobalClick");p(this,"enhancedScanner");p(this,"rootClickHandler");p(this,"eventSystem");p(this,"directInjection");this.viewMap=e,this.imgMap=t,this.regex=o,this.handleGlobalClick=i,this.directInjection=new So(e,t,i),this.enhancedScanner=new ko(e,t,i),this.rootClickHandler=new To(e,t,o,i),this.eventSystem=new Co(e,t,i)}init(){console.log("🚀 初始化小程序智能自动绑定系统"),this.syncInit(),setTimeout(()=>{this.asyncInit()},0),console.log("✅ 小程序智能自动绑定系统初始化完成")}syncInit(){console.log("⚡ 执行同步初始化"),this.isMiniProgram()?(console.log("📱 检测到小程序环境"),console.log("🎯 立即劫持 Page 构造函数"),this.immediatePageHijack(),this.createImmediateEmergencyFix()):this.isUniApp()&&(console.log("📱 检测到 UniApp 环境"),this.immediatePageHijack()),console.log("⚡ 同步初始化完成")}asyncInit(){console.log("🔄 执行异步初始化"),this.isMiniProgram()?(this.directInjection.inject(),this.eventSystem.init(),this.initNativeMiniProgramBinding()):this.isUniApp()&&(this.directInjection.inject(),this.initUniAppBinding()),this.logUsageInstructions(),console.log("🔄 异步初始化完成")}immediatePageHijack(){const e=globalThis.Page;if(!e){console.error("❌ Page 构造函数不存在");return}const t=this;console.log("🔧 立即劫持 Page 构造函数"),globalThis.Page=function(o){console.log("📄 Page 构造函数被调用,立即注入方法"),o||(o={}),o.globalClick=function(r){return console.log("📱 globalClick 被调用",r),t.handleClickEvent(r,this)},o.autoTrack=function(r){return console.log("📱 autoTrack 被调用",r),t.handleClickEvent(r,this)},o.handleAnyClick=function(r){return console.log("📱 handleAnyClick 被调用",r),t.handleClickEvent(r,this)};const i=o.onLoad;return o.onLoad=function(r){console.log("📄 页面 onLoad - 方法检查:"),console.log("- globalClick:",typeof this.globalClick),console.log("- autoTrack:",typeof this.autoTrack),console.log("- handleAnyClick:",typeof this.handleAnyClick),typeof this.globalClick!="function"&&(console.error("❌ globalClick 方法仍然不存在!执行紧急修复"),this.globalClick=function(s){return console.log("🚨 紧急修复的 globalClick"),t.handleClickEvent(s,this)}),i&&typeof i=="function"&&i.call(this,r)},console.log("📄 方法注入完成,调用原始 Page"),e.call(this,o)},console.log("✅ Page 构造函数劫持完成")}createImmediateEmergencyFix(){const e=this;globalThis.__emergencyGlobalClick=function(t){return console.log("� 全局紧急修复方法被调用",t),e.handleClickEvent(t,null)},globalThis.__emergencyAutoTrack=function(t){return console.log("🚨 全局紧急 autoTrack 被调用",t),e.handleClickEvent(t,null)},console.log("🚨 紧急修复方法已创建")}async handleClickEvent(e,t){try{console.log("🎯 处理点击事件",e);const o=e.target||e.currentTarget,i=(o==null?void 0:o.dataset)||{};console.log("点击目标:",{target:o,dataset:i}),this.shouldTrackElement(i)?(console.log("✅ 需要埋点,调用处理器"),await this.handleGlobalClick(e)):console.log("⏭️ 不需要埋点,忽略")}catch(o){console.error("❌ 处理点击事件失败:",o)}}shouldTrackElement(e){return e?e.text&&this.viewMap[e.text]?(console.log("匹配文本埋点:",e.text),!0):e.src&&this.imgMap[e.src]?(console.log("匹配图片埋点:",e.src),!0):e.track?(console.log("匹配自定义埋点:",e.track),!0):!1:!1}logUsageInstructions(){console.log(`
=== 小程序全局点击事件使用指南 ===

🎯 直接注入方案(推荐):
${this.directInjection.getUsageInstructions()}

🚀 全局事件系统方案:
${this.eventSystem.generateTemplateExample()}

📝 页面 JS 代码:
${this.eventSystem.generatePageJSExample()}

🚨 如果还是报错 "globalClick" 方法不存在:

1. 检查初始化时机:
   确保在 app.js 的 onLaunch 中初始化埋点组件

2. 手动修复(立即可用):
   在页面 JS 中添加:
   Page({
       onLoad() {
           if (typeof this.globalClick !== 'function') {
               this.globalClick = globalThis.__emergencyGlobalClick || function(evt) {
                   console.log('紧急备用 globalClick', evt);
               };
           }
       }
   });

3. 检查方法注入:
   在页面 onReady 中添加:
   console.log('globalClick:', typeof this.globalClick);

✨ 特点:
1. 多重注入方案,确保方法存在
2. 自动捕获所有子元素点击
3. 智能过滤需要埋点的元素
4. 紧急修复机制

🔧 配置要求:
- 确保元素有 data-text、data-src 或 data-track 属性
- 属性值要与配置列表匹配
- 在根容器上绑定 bindtap="globalClick"
        `)}isUniApp(){return typeof globalThis.uni<"u"}isMiniProgram(){return typeof globalThis.wx<"u"||typeof globalThis.my<"u"||typeof globalThis.swan<"u"||typeof globalThis.tt<"u"}initUniAppBinding(){if(globalThis.uni){const e={onLoad(){this.$monitoGlobalClick=this.handleGlobalClick.bind(this)},onReady(){this.$nextTick(()=>{this.autoScanAndBind()})},methods:{$monitoGlobalClick:t=>{this.handleGlobalClick(t)},autoScanAndBind(){const t=globalThis.uni.createSelectorQuery().in(this);t.selectAll("button, image, view, text").boundingClientRect(),t.exec(o=>{o&&o[0]&&(console.log(`UniApp 自动扫描到 ${o[0].length} 个元素`),this.bindEventsToElements(o[0]))})},bindEventsToElements(t){t.forEach((o,i)=>{console.log(`为元素 ${i} 绑定点击事件`)})}}};globalThis.Vue&&globalThis.Vue.mixin&&globalThis.Vue.mixin(e)}globalThis.uni&&globalThis.uni.addInterceptor&&(globalThis.uni.addInterceptor("navigateTo",{success:()=>{setTimeout(()=>{this.injectToCurrentPage()},100)}}),globalThis.uni.addInterceptor("redirectTo",{success:()=>{setTimeout(()=>{this.injectToCurrentPage()},100)}}))}initNativeMiniProgramBinding(){this.hijackPageConstructor(),this.hijackComponentConstructor(),this.setupGlobalEventProxy()}hijackPageConstructor(){const e=globalThis.Page;if(!e)return;const t=this;globalThis.Page=o=>{o.$monitoGlobalClick=s=>{t.handleGlobalClick(s)},o.handleGlobalClick=s=>{console.log("页面点击处理器触发",s),t.handleGlobalClick(s)},o.trackClick=s=>{console.log("手动埋点方法调用",s),t.handleGlobalClick(s)};const i=o.onLoad;o.onLoad=function(s){i&&i.call(this,s),this.__monitoInstance=this,console.log("页面加载完成,准备自动绑定事件")};const r=o.onReady;return o.onReady=function(){r&&r.call(this),console.log("页面渲染完成,开始增强扫描"),t.enhancedScanner.enhancedPageScan(this),t.enhancedScanner.injectGlobalClickHandler(this),console.log(`模板绑定建议:
`,t.enhancedScanner.generateTemplateBindings())},o.autoBindEvents=function(){const s=this.createSelectorQuery(),a=["button","image","view[data-text]","view[data-src]","text[data-text]","navigator[data-text]",".clickable","[data-track]"].join(", ");s.selectAll(a).boundingClientRect(),s.exec(u=>{console.log("自动扫描元素完成",u),u&&u[0]?(console.log(`小程序自动扫描到 ${u[0].length} 个可绑定元素`),u[0].forEach((c,d)=>{const f=`__autoHandler_${d}`;this[f]=y=>{console.log(`自动绑定的点击事件触发 - 元素${d}`,y),this.$monitoGlobalClick(y)}}),this.scanElementsByDataset()):(console.warn("未扫描到任何可绑定元素,尝试备用方案"),this.fallbackScan())})},o.scanElementsByDataset=function(){const s=this.createSelectorQuery();s.selectAll("view, button, image, text, navigator").boundingClientRect(),s.exec(a=>{a&&a[0]&&(console.log(`备用扫描找到 ${a[0].length} 个元素`),a[0].forEach((u,c)=>{console.log(`检查元素 ${c}:`,u)}))})},o.fallbackScan=function(){console.log("执行降级扫描方案"),this.globalClickHandler=s=>{console.log("全局点击事件触发",s);const a=s.target||s.currentTarget;a&&a.dataset&&(a.dataset.text||a.dataset.src||a.dataset.track)&&(console.log("检测到埋点元素被点击:",a.dataset),this.$monitoGlobalClick(s))},console.log('降级方案:需要在模板中手动绑定 bindtap="globalClickHandler"')},e(o)}}hijackComponentConstructor(){const e=globalThis.Component;e&&(globalThis.Component=t=>{t.methods||(t.methods={}),t.methods.$monitoGlobalClick=i=>{this.handleGlobalClick(i)};const o=t.attached;return t.attached=function(){o&&o.call(this),setTimeout(()=>{console.log("组件附加完成,自动绑定事件")},50)},e(t)})}setupGlobalEventProxy(){const e=globalThis.getCurrentPages;if(e){let t=0;setInterval(()=>{const o=e();if(o.length!==t&&(t=o.length,o.length>0)){const i=o[o.length-1];this.injectToPage(i)}},100)}}injectToCurrentPage(){var t;const e=(t=globalThis.getCurrentPages)==null?void 0:t.call(globalThis);if(e&&e.length>0){const o=e[e.length-1];this.injectToPage(o)}}injectToPage(e){!e||e.__monitoInjected||(e.__monitoInjected=!0,e.$monitoGlobalClick=t=>{console.log("全局点击事件触发",t),this.handleGlobalClick(t)},e.autoScanElements=()=>{if(e.createSelectorQuery){const t=e.createSelectorQuery();t.selectAll("button, image, view").boundingClientRect(),t.exec(o=>{console.log("自动扫描元素完成",o),o&&o[0]&&console.log(`为页面注入埋点,扫描到 ${o[0].length} 个元素`)})}},setTimeout(()=>{var t;(t=e.autoScanElements)==null||t.call(e)},100),console.log("已向页面注入埋点方法"))}}class pe{static isWeb(){return typeof window<"u"&&typeof document<"u"}static isMiniProgram(){return!!(typeof globalThis.wx<"u"&&globalThis.wx.getSystemInfoSync||typeof globalThis.my<"u"&&globalThis.my.getSystemInfoSync||typeof globalThis.swan<"u"&&globalThis.swan.getSystemInfoSync||typeof globalThis.tt<"u"&&globalThis.tt.getSystemInfoSync)}static isUniApp(){return typeof globalThis.uni<"u"}}class Eo{static getClickedElement(e){var t,o,i,r,s,a,u,c,d,f,y,w,h,m,g,k,T,C,N,P;if(pe.isWeb()){const U=e,S=document.elementFromPoint(U.pageX,U.pageY);return{element:S,nodeName:S==null?void 0:S.nodeName,textContent:S==null?void 0:S.textContent,src:S==null?void 0:S.src,baseURI:S==null?void 0:S.baseURI,target:e.target}}else{if(pe.isUniApp())return{element:null,nodeName:(o=(t=e.target)==null?void 0:t.tagName)==null?void 0:o.toUpperCase(),textContent:((r=(i=e.target)==null?void 0:i.dataset)==null?void 0:r.text)||((s=e.target)==null?void 0:s.innerText),src:(a=e.target)==null?void 0:a.src,baseURI:(d=(c=globalThis.getCurrentPages)==null?void 0:c.call(globalThis)[(((u=globalThis.getCurrentPages)==null?void 0:u.call(globalThis).length)||1)-1])==null?void 0:d.route,target:e.target};if(pe.isMiniProgram())return{element:null,nodeName:(y=(f=e.target)==null?void 0:f.tagName)==null?void 0:y.toUpperCase(),textContent:((h=(w=e.target)==null?void 0:w.dataset)==null?void 0:h.text)||((m=e.detail)==null?void 0:m.text),src:((k=(g=e.target)==null?void 0:g.dataset)==null?void 0:k.src)||((T=e.detail)==null?void 0:T.src),baseURI:(P=(N=globalThis.getCurrentPages)==null?void 0:N.call(globalThis)[(((C=globalThis.getCurrentPages)==null?void 0:C.call(globalThis).length)||1)-1])==null?void 0:P.route,target:e.target}}return null}}class Po{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 wo}initClickEvent(e,t,o){pe.isWeb()?W.addEventListener({element:document,type:"click",handler:async i=>{var c,d;const r=new Date().getTime();let s=null;if(i.target&&i.target.nodeType===Node.ELEMENT_NODE&&(s=i.target),!s&&i.currentTarget&&i.currentTarget.nodeType===Node.ELEMENT_NODE&&(s=i.currentTarget),!s&&i.pageX!==void 0&&i.pageY!==void 0&&(s=document.elementFromPoint(i.pageX,i.pageY)),!s&&i.clientX!==void 0&&i.clientY!==void 0&&(s=document.elementFromPoint(i.clientX,i.clientY)),!s)return;const u=(f=>{if(f.innerText!==void 0&&f.innerText!==null){const w=f.innerText.trim();if(w)return w}if(f.textContent!==void 0&&f.textContent!==null){const w=f.textContent.trim();if(w)return w}const y=w=>{for(let h=0;h<w.children.length;h++){const m=w.children[h],g=m.innerText||m.textContent;if(g&&g.trim())return g.trim();const k=y(m);if(k)return k}return""};return y(f)})(s);if(s.nodeName==="IMG"&&s.src){const f=(c=s.src.match(o))==null?void 0:c[1];f&&s.src.includes((d=t[f])==null?void 0:d.imgSrc)&&await this.dataProcess.track({id:r.toString(),pageUrl:s.baseURI,actionType:"click-img",...t[f]})}u&&e[u]&&await this.dataProcess.track({id:r.toString(),pageUrl:s.baseURI,actionType:"click",elementText:u,...e[u]})}}):this.initMiniProgramAutoBinding(e,t,o)}initMiniProgramAutoBinding(e,t,o){new xo(e,t,o,this.handleGlobalClick.bind(this)).init(),console.log("小程序智能自动绑定已启动")}async handleGlobalClick(e){var a,u;const t=new Date().getTime(),o=Eo.getClickedElement(e);if(!o)return;const i={};this.monitoConfigList.forEach(c=>i[c.elementText]=c);const r={};this.monitoImgList.forEach(c=>r[c.imgSrc]=c);const s=/\/([^\/]*)$/;if(o.nodeName==="IMAGE"&&o.src){const c=(a=o.src.match(s))==null?void 0:a[1];c&&o.src.includes((u=r[c])==null?void 0:u.imgSrc)&&await this.dataProcess.track({id:t.toString(),pageUrl:o.baseURI,actionType:"click-img",...r[c]})}if(o.textContent){const c=o.textContent.trim();i[c]&&await this.dataProcess.track({id:t.toString(),pageUrl:o.baseURI,actionType:"click",elementText:o.textContent,...i[c]})}}getUrl(){}async eventInit(e){var s,a;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((s=e.reques)==null?void 0:s.maxRequesGatewayLength),this.dataProcess.setUrl((a=e.reques)==null?void 0:a.requestUrl),await this.dataProcess.dbInit(),this.dataProcess.pageTrack({id:new Date().getTime().toString(),info:"应用首次进入",pageUrl:document.baseURI,actionType:"pageLoad"});const t={};this.monitoConfigList.forEach(u=>t[u.elementText]=u);const o={};this.monitoImgList.forEach(u=>o[u.imgSrc]=u);const i=/\/([^\/]*)$/;this.initClickEvent(t,o,i),W.addEventListener({element:document,type:"visibilitychange",handler:u=>{}}),W.addEventListener({element:window,type:"popstate",handler:u=>{this.dataProcess.pageTrack({id:u.timeStamp.toString(),info:"页面返回",pageUrl:document.baseURI,actionType:"pageBack"})}});const r=function(u){const c=history[u];return function(){c.apply(history,arguments);const d=new Event(u);return d.arguments=arguments,window.dispatchEvent(d),c}};history.pushState=r("pushState"),history.replaceState=r("replaceState"),W.addEventListener({element:window,type:"replaceState",handler:u=>{const c=document.baseURI;this.dataProcess.pageTrack({id:u.timeStamp.toString(),info:this.pageMonito.uniapp.info,pageUrl:c,actionType:this.pageMonito.uniapp.actionType}),["vue","react"].includes(String(e.frameType))&&(this.pageMonito.uniapp=this.pageMonito.vue)}}),String(e.frameType)==="uniapp"&&W.addEventListener({element:window,type:"pushState",handler:u=>{const c=u.arguments[2];console.log("页面跳转",c),this.dataProcess.pageTrack({id:u.timeStamp.toString(),info:"页面跳转",pageUrl:c,actionType:"pagejump"})}})}async track(e){try{await this.dataProcess.track(e)}catch(t){R({logInfo:t,logMake:"initTrack错误"})}}}class Ao{constructor(){p(this,"monitoInit");this.monitoInit=new Po}init(e){const{reques:t,monitoSwitch:o=!0,showLog:i=!1}=e;o&&(oo(i),this.monitoInit.eventInit(e),v.setRequestConfigs(t))}track(e){this.monitoInit.track(e)}}return Ao});