Files
OpenMaopaoya/frontend-uni/node_modules/@dcloudio/uni-stat/dist/uni-stat-public.mp-weixin.es.js
T

75 lines
81 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{onAppShow,onAppHide,onError}from"@dcloudio/uni-app";const e={Launch:"1",Hide:"3",Page:"11",Event:"21",Error:"31",Push:"101"};const n={ColdLaunch:1,BackgroundTimeout:2,PageInactiveTimeout:3};const t={No:0,Yes:1};function o(e){if(e===true||e===1||e==="1")return t.Yes;return t.No}function r(e,n,t,o){function r(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function u(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o["throw"](e))}catch(e){i(e)}}function c(e){e.done?t(e.value):r(e.value).then(u,s)}c((o=o.apply(e,n||[])).next())}))}typeof SuppressedError==="function"?SuppressedError:function(e,n,t){var o=new Error(t);return o.name="SuppressedError",o.error=e,o.suppressed=n,o};const i=4096;const u="…[truncated]";function s(e,n=i){var t;if(e===undefined)return"";let o;if(typeof e==="string"){o=e}else{const n=new WeakSet;try{o=(t=JSON.stringify(e,((e,t)=>{if(typeof t==="object"&&t!==null){if(n.has(t))return"[Circular]";n.add(t)}if(typeof t==="bigint")return t.toString();if(typeof t==="function")return`[Function ${t.name||"anonymous"}]`;return t})))!==null&&t!==void 0?t:""}catch(e){o=`[Unserializable: ${e.message}]`}}if(o.length>n){return o.slice(0,Math.max(0,n-u.length))+u}return o}function c(e,n){try{return e()}catch(e){return n}}function l(e,n){return r(this,void 0,void 0,(function*(){var t;const o=Math.max(1,Math.floor(n.times));const r=(t=n.sleep)!==null&&t!==void 0?t:f;let i;for(let t=1;t<=o;t++){try{return yield e()}catch(e){i=e;if(t>=o)break;yield r(n.baseDelayMs*Math.pow(2,t-1))}}throw i}))}function f(e){return new Promise((n=>setTimeout(n,e)))}function a(){return process.env.UNI_STAT_VAPOR==="true"}function d(e){if(e==null||typeof e!=="object")return false;const n=e;return typeof n.getStorageSync==="function"||typeof n.onCreateVueApp==="function"||typeof n.request==="function"||typeof n.onAppShow==="function"||typeof n.onAppRoute==="function"}function p(){if(typeof uni==="undefined"||uni==null||typeof uni!=="object"){return undefined}return uni}function v(){try{const e=Function('return typeof window !== "undefined" ? window : undefined')();return e!=null?e:undefined}catch(e){return undefined}}function h(){if(typeof globalThis!=="undefined"&&globalThis!=null){return globalThis}if(typeof global!=="undefined"&&global!=null){return global}if(typeof self!=="undefined"&&self!=null){return self}const e=v();if(e)return e;return{}}function g(){try{const e={};const n=(n,t)=>{if(typeof t==="function")e[n]=t};n("getStorageSync",uni.getStorageSync);n("setStorageSync",uni.setStorageSync);n("removeStorageSync",uni.removeStorageSync);n("getSystemInfoSync",uni.getSystemInfoSync);n("getDeviceInfo",uni.getDeviceInfo);n("getAppBaseInfo",uni.getAppBaseInfo);n("getWindowInfo",uni.getWindowInfo);n("getNetworkType",uni.getNetworkType);n("request",uni.request);n("onAppShow",uni.onAppShow);n("offAppShow",uni.offAppShow);n("onAppHide",uni.onAppHide);n("offAppHide",uni.offAppHide);n("onAppLaunch",uni.onAppLaunch);n("offAppLaunch",uni.offAppLaunch);n("onAppRoute",uni.onAppRoute);n("offAppRoute",uni.offAppRoute);n("onBeforeAppRoute",uni.onBeforeAppRoute);n("offBeforeAppRoute",uni.offBeforeAppRoute);n("getLaunchOptionsSync",uni.getLaunchOptionsSync);n("addInterceptor",uni.addInterceptor);n("removeInterceptor",uni.removeInterceptor);n("getPushClientId",uni.getPushClientId);n("getAccountInfoSync",uni.getAccountInfoSync);n("onCreateVueApp",uni.onCreateVueApp);return Object.keys(e).length>0?e:undefined}catch(e){return undefined}}function m(){const e=typeof globalThis!=="undefined";const n=h();const t=n.uni;const o=t!=null&&typeof t==="object";const r=o&&!d(t);const i=p();const u=i!=null;if(d(t)){return{resolved:true,source:"globalThis",globalThisHasUni:true,globalThisUniStub:false,moduleUniDefined:u,globalThisAvailable:e,uni:t}}if(d(i)){return{resolved:true,source:"module",globalThisHasUni:o,globalThisUniStub:r,moduleUniDefined:true,globalThisAvailable:e,uni:i}}const s=g();if(d(s)){return{resolved:true,source:"injected",globalThisHasUni:o,globalThisUniStub:r,moduleUniDefined:u,globalThisAvailable:e,uni:s}}return{resolved:false,source:"none",globalThisHasUni:o,globalThisUniStub:r,moduleUniDefined:u,globalThisAvailable:e,uni:undefined}}function y(){const e=m();return e.resolved?e.uni:undefined}const b="[uni统计 2.0]";let w;let S;function k(){return I()}function I(){var e,n,t,o,r,i,u,s;const c=(e="mp-weixin")!==null&&e!==void 0?e:"";const l=h();if(c==="app"||c==="app-plus"||c==="app-harmony"){const e=(o=(t=(n=l.plus)===null||n===void 0?void 0:n.os)===null||t===void 0?void 0:t.name)===null||o===void 0?void 0:o.toLowerCase();if(!e)return false;if(e.includes("android"))return true;if(e==="ios"||e.includes("iphone"))return true;return false}if(c.startsWith("mp-")){try{const e=(s=(u=(i=(r=l.uni)===null||r===void 0?void 0:r.getSystemInfoSync)===null||i===void 0?void 0:i.call(r))===null||u===void 0?void 0:u.platform)===null||s===void 0?void 0:s.toLowerCase();return e==="android"||e==="ios"}catch(e){return false}}return false}function T(e){if(e===null||e===undefined)return e;if(typeof e!=="object")return e;if(e instanceof Error)return`${e.name}: ${e.message}`;return s(e)}function A(e){if(e===null)return"null";if(e===undefined)return"undefined";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"){return String(e)}if(typeof e==="bigint")return String(e);if(typeof e==="symbol"){try{return e.toString()}catch(e){return"?"}}if(typeof e==="function"){const n=e;return`[Function ${n.name||"anonymous"}]`}if(typeof e==="object"){if(e instanceof Error)return`${e.name}: ${e.message}`;return s(e)}return String(e)}function R(){if(S!==undefined)return S;return process.env.NODE_ENV==="test"}function N(e){S=e}function P(e,n){if(e!=="log"&&R())return;const t=console[e];if(!k()){t.call(console,b,...n);return}const o=I()?n.map(T):n;if(o.length===0){t.call(console,b);return}const r=o.map(A).join(" ");t.call(console,`${b} ${r}`)}function _(){if(w!==undefined)return w;const e=process.env.UNI_STAT_DEBUG;return e==="true"||e===true}function j(e){w=e}const C={debug(...e){if(!_())return;P("log",e)},info(...e){P("info",e)},warn(...e){P("warn",e)},error(...e){P("error",e)},setDebug:j,isDebug:_,setMuteNonDebug:N};const E="UNI_STAT_DATA";const $="$$STAT__DBDATA";const B=new Map;const x=new Set;function M(e){const n=process.env.UNI_APP_ID||"default";return`${E}:${n}:${e}`}function O(){const e=y();const n=e!=null&&typeof e==="object"?e:undefined;if(!n||typeof n.getStorageSync!=="function"){throw new Error("[uni统计 2.0] uni storage API is not available")}return n}function U(e){const n=M(e);if(B.has(n))return B.get(n);try{const e=O().getStorageSync(n);if(e===""||e===null||e===undefined){B.set(n,undefined);return undefined}B.set(n,e);x.add(n);return e}catch(e){return undefined}}function D(e){const n=M(e);if(B.has(n))return{ok:true,value:B.get(n)};try{const e=O().getStorageSync(n);if(e===""||e===null||e===undefined){B.set(n,undefined);return{ok:true,value:undefined}}B.set(n,e);x.add(n);return{ok:true,value:e}}catch(e){return{ok:false,value:undefined}}}function L(e,n){const t=M(e);if(n===undefined){q(e);return}B.set(t,n);x.add(t);try{O().setStorageSync(t,n)}catch(e){}}function q(e){const n=M(e);B.set(n,undefined);try{O().removeStorageSync(n)}catch(e){}}function V(e){const n={};for(const t of e)n[t]=U(t);return n}function H(e){for(const n of Object.keys(e))L(n,e[n])}function W(){let e;try{e=O()}catch(e){}for(const n of Array.from(x)){try{e===null||e===void 0?void 0:e.removeStorageSync(n)}catch(e){}B.set(n,undefined)}x.clear()}function F(){B.clear();x.clear()}const J={get:U,set:L,remove:q,safeRead:D,batchGet:V,batchSet:H,clearNamespace:W,__resetCache:F};const G="visit:fvts";const z="visit:lvts";const K="visit:tvc";const Y={fvts:0,lvts:0,tvc:0,isNewUser:true,degraded:false};let Q=null;let X=null;let Z=null;let ee=null;let ne=null;let te=false;function oe(e){if(typeof e==="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof e==="string"&&e.length>0){const n=Number(e);if(Number.isFinite(n)&&n>=0)return n}return 0}function re(e){return e.fvts===0&&e.lvts===0&&e.tvc===0}function ie(e){if(!e.isNewUser)return false;if(a()&&!re(e))return false;return!e.degraded||re(e)}function ue(){const e=J.safeRead(G);const n=J.safeRead(z);const t=J.safeRead(K);const o=!e.ok||!n.ok||!t.ok;const r=oe(e.value);const i=oe(n.value);const u=oe(t.value);const s={fvts:r,lvts:i,tvc:u,isNewUser:i===0,degraded:o};if(o){const e=r===0&&i===0&&u===0&&s.isNewUser;if(!e){C.warn("[uni统计 2.0] visit snapshot degraded; some storage keys read failed")}}Q=s;return s}function se(){if(!Q)Q=Y;return Q}function ce(e){J.set(G,e);J.set(z,e);J.set(K,1);const n={fvts:e,lvts:e,tvc:1,isNewUser:false,degraded:false};Q=n;ee=n}function le(e){const n=se();if(te&&ne){C.warn("[uni统计 2.0] buildVisitFields() called twice in same process; returning cached fields");return Object.assign({},ne)}te=true;if(ie(n)){X={fvts:e,lvts:0,tvc:1,now:e};ce(e)}else if(n.isNewUser){C.warn("[uni统计 2.0] visit degraded: lvts 读取失败但检测到历史数据,按老用户处理以避免新增虚高");const t=n.fvts>0?n.fvts:e;X={fvts:t,lvts:t,tvc:n.tvc+1,now:e}}else{X={fvts:n.fvts,lvts:n.lvts,tvc:n.tvc+1,now:e}}ne={fvts:X.fvts,lvts:X.lvts,tvc:X.tvc};return Object.assign({},ne)}function fe(e){let n;let t;let o;if(ee){n=ee.fvts;t=ee.lvts;o=ee.tvc+1}else if(ne){n=ne.fvts;t=ne.lvts!==0?ne.lvts:ne.fvts;o=ne.tvc}else{const r=se();if(ie(r)){n=e;t=0;o=1;ce(e)}else if(r.isNewUser){n=r.fvts>0?r.fvts:e;t=n;o=r.tvc+1}else{n=r.fvts;t=r.lvts;o=r.tvc+1}}Z={fvts:n,lvts:t,tvc:o,now:e};return{fvts:n,lvts:t,tvc:o}}function ae(e){if(X){const n=se();const t=n.fvts===0?e:n.fvts;const o=e;const r=X.tvc;J.set(G,t);J.set(z,o);J.set(K,r);ee={fvts:t,lvts:o,tvc:r,isNewUser:false,degraded:false};Q=ee;X=null;return}if(!Z)return;const n=Z.fvts;const t=e;const o=Z.tvc;J.set(G,n);J.set(z,t);J.set(K,o);ee={fvts:n,lvts:t,tvc:o,isNewUser:false,degraded:false};Q=ee;Z=null}function de(){X=null;Z=null}const pe="session:entryRoute";let ve;let he=false;function ge(e){if(!e)return;const n=me();if(n)return;J.set(pe,e);ve=e}function me(){if(ve!==undefined)return ve||undefined;const e=J.safeRead(pe);if(!e.ok)return undefined;if(typeof e.value==="string"&&e.value.length>0){ve=e.value;return e.value}ve="";return undefined}function ye(e){if(!e)return false;const n=me();return n===e}function be(e){if(he)return false;return ye(e)}function we(){he=true}function Se(){ve="";he=false;J.remove(pe)}let ke;
// #ifndef VUE3
function Ie(){const e={};try{const n=require('uni-pages?{"type":"style"}').default;const t=n===null||n===void 0?void 0:n.pages;if(!t||typeof t!=="object")return e;for(const n in t){const o=t[n];const r=o.navigationBar;const i=o.navigationBarTitleText||o.defaultTitle||(r===null||r===void 0?void 0:r.titleText)||"";if(i){e[n]=i}}}catch(e){}return e}const Te=Ie();
// #endif
// #ifdef VUE3
function Ae(){if(ke)return ke;ke={};try{const e=process.env.UNI_STAT_TITLE_JSON;if(typeof e!=="string"||!e)return ke;const n=JSON.parse(e);if(n&&typeof n==="object"&&!Array.isArray(n)){ke=n}}catch(e){ke={}}return ke}
// #endif
function Re(){let e={};
// #ifndef VUE3
e=Te;
// #endif
// #ifdef VUE3
e=Ae();
// #endif
return e}function Ne(e){if(!e||typeof e!=="string")return"";const n=e.split("?")[0].trim();if(!n)return"";const t=Re();let o="";
// #ifndef VUE3
const r=t[n];o=typeof r==="string"&&r.length>0?r:"";
// #endif
// #ifdef VUE3
const i=[n];if(n.startsWith("/")){i.push(n.slice(1))}else{i.push(`/${n}`)}for(const e of i){const n=t[e];if(typeof n==="string"&&n.length>0){o=n;break}}
// #endif
return o}const Pe={page:"",config:"",report:""};function _e(e){Pe.page=typeof e==="string"?e:""}function je(e){Pe.config=typeof e==="string"?e:""}function Ce(e){Pe.report=typeof e==="string"?e:""}function Ee(){return{ttn:Pe.page,ttpj:Pe.config,ttc:Pe.report}}function $e(){Pe.page=""}function Be(){return Date.now()}function xe(){return Math.floor(Date.now()/1e3)}function Me(e){const n=e>0?e:0;return n<1?1:n}function Oe(e){var n,t,o,r,i;const u=e=>{const n=e.toLowerCase().trim();if(!n)return"";if(n==="devtools")return"";if(n==="android")return"android";if(n==="ios"||n==="iphone")return"ios";if(n.includes("android"))return"android";if(n.includes("iphone")||n==="iphone os"||/\bios\b/.test(n))return"ios";if(n.includes("harmony")||n==="ohos"||n==="openharmony")return"harmonyos";if(n.includes("windows")||n==="windows_nt")return"windows";if(n==="mac"||n==="darwin"||n.includes("mac os")||n==="macos")return"macos";if(n.includes("linux")&&!n.includes("android"))return"linux";return""};const s=u((n=e.platform)!==null&&n!==void 0?n:"");if(s)return s;const c=u((t=e.osName)!==null&&t!==void 0?t:"");if(c)return c;const l=((o=e.system)!==null&&o!==void 0?o:"").toLowerCase();if(l.includes("android"))return"android";if(l.includes("iphone")||/\bios\b/.test(l))return"ios";if(l.includes("harmony")||l.includes("ohos"))return"harmonyos";if(l.includes("windows"))return"windows";if(l.includes("mac os")||l.includes("darwin"))return"macos";if(l.includes("linux"))return"linux";const f=h().plus;const a=u((i=(r=f===null||f===void 0?void 0:f.os)===null||r===void 0?void 0:r.name)!==null&&i!==void 0?i:"");if(a)return a;return""}function Ue(){const e=["y","a","p","mp-ali"];return[...e].reverse().join("")}const De={app:"n","app-plus":"n","app-harmony":"n","mp-harmony":"mhm",h5:"h5","mp-weixin":"wx",[Ue()]:"ali","mp-baidu":"bd","mp-toutiao":"tt","mp-qq":"qq","mp-kuaishou":"ks","mp-lark":"lark","mp-xhs":"xhs","mp-jd":"jd","quickapp-native":"qn","quickapp-webview":"qw"};function Le(){var e;return(e="mp-weixin")!==null&&e!==void 0?e:""}function qe(){var e;const n=Le();const t=De[n];if(!t)return"unknown";if(t==="ali"){const n=h().my;if(((e=n===null||n===void 0?void 0:n.env)===null||e===void 0?void 0:e.clientName)==="dingtalk")return"dt";return"ali"}return t}function Ve(){const e=Le();return e==="app"||e==="app-plus"||e==="app-harmony"}function He(){return Le().startsWith("mp-")}function We(){return Le()==="h5"}function Fe(){return Boolean(h().__NVUE__)}const Je="device:uuid";const Ge="__DC_STAT_UUID";let ze=null;function Ke(){if(Ve()||We())return true;return Le()==="mp-weixin"}function Ye(){const e=y();const n=e!=null&&typeof e==="object"?e:undefined;if(!n||typeof n.getSystemInfoSync!=="function")return"";return c((()=>{var e;return(e=n.getSystemInfoSync().deviceId)!==null&&e!==void 0?e:""}),"")}function Qe(){const e=y();const n=e!=null&&typeof e==="object"?e:undefined;if(!n||typeof n.getDeviceInfo!=="function")return"";return c((()=>{var e;return(e=n.getDeviceInfo().deviceId)!==null&&e!==void 0?e:""}),"")}function Xe(){const e=Be();const n=Math.floor(Math.random()*1e6).toString().padStart(6,"0");return`${e}${n}`}function Ze(e){c((()=>J.set(Je,e)),undefined)}function en(){return c((()=>{const e=h();if(e.navigator&&e.navigator.cookieEnabled===false)return undefined;const n=e.localStorage;if(n&&typeof n.getItem==="function"&&typeof n.setItem==="function"){return n}return undefined}),undefined)}function nn(){const e=en();if(!e)return"";return c((()=>{const n=e.getItem(Ge);return typeof n==="string"?n:""}),"")}function tn(e){const n=en();if(!n)return;c((()=>n.setItem(Ge,e)),undefined)}function on(){if(Ke()){const e=Qe();if(e)return e}return Ye()}function rn(){if(ze)return ze;if(We()){const e=nn();if(e){ze=e;return ze}}const e=on();if(e){Ze(e);if(We())tn(e);ze=e;return ze}const n=J.safeRead(Je);if(n.ok){const e=n.value;if(typeof e==="string"&&e.length>0){if(e.startsWith("device-anon-")){const e=Xe();Ze(e);if(We())tn(e);ze=e;return ze}ze=e;return ze}const t=Xe();Ze(t);if(We())tn(t);ze=t;return ze}const t=Xe();if(We()){tn(t);ze=t;return ze}return t}const un=8;const sn=4;function cn(e){const n=Math.random().toString(36).slice(2,2+e);return n.length>=e?n:n.padEnd(e,"0")}function ln(){return`${cn(un)}-${cn(sn)}`}function fn(){const e=Be();const n=Math.floor(Math.random()*1e6).toString().padStart(6,"0");return`${e}${n}`}function an(e){if(e&&e.length>0){return`${e}-${ln()}`}return`${fn()}-${ln()}`}const dn="session:id";const pn="session:start";const vn="session:sct";const hn="session:seq";const gn="session:lastActive";const mn="session:bgTs";const yn="session:lastScene";const bn={backgroundTimeoutSec:300,pageInactiveTimeoutSec:1800};let wn=Object.assign({},bn);let Sn=null;function kn(e){wn=Object.assign({},bn,e)}function In(e){const n=J.safeRead(e);if(!n.ok)return 0;const t=n.value;if(typeof t==="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t==="string"&&t.length>0){const e=Number(t);if(Number.isFinite(e)&&e>=0)return e}return 0}function Tn(e){const n=J.safeRead(e);if(!n.ok)return"";return typeof n.value==="string"?n.value:""}function An(e,n){const t=e-n;return t>0?t:0}function Rn(){const e=Tn(dn);if(!e)return null;return{sid:e,sst:In(pn),sct:In(vn)||n.ColdLaunch,seq:In(hn),lastActive:In(gn),bgTs:In(mn),lastScene:Tn(yn)}}function Nn(){if(Sn!==null)return Sn;Sn=Rn();return Sn}function Pn(e,n,t){const o=an(rn());const r={sid:o,sst:e,sct:n,seq:0,lastActive:e,bgTs:0,lastScene:t};J.set(dn,o);J.set(pn,e);J.set(vn,n);J.set(hn,0);J.set(gn,e);J.set(mn,0);J.set(yn,t);Sn=r;return r}function _n(e,t){const{now:o,scene:r=""}=t;const i=Nn();if(e==="cold_launch"){const e=Pn(o,n.ColdLaunch,r);return{snapshot:e,isNew:true,cst:n.ColdLaunch}}if(!i){const e=Pn(o,n.ColdLaunch,r);return{snapshot:e,isNew:true,cst:n.ColdLaunch}}if(e==="app_show"){const e=[];if(t.backgroundEnteredAt&&t.backgroundEnteredAt>0){e.push(t.backgroundEnteredAt)}if(i.bgTs>0){e.push(i.bgTs)}const u=e.length>0?Math.min(...e):0;const s=u>0?An(o,u):An(o,i.lastActive);const c=!!r&&!!i.lastScene&&r!==i.lastScene;const l=u>0;if(c||l&&s>=wn.backgroundTimeoutSec){const e=Pn(o,n.BackgroundTimeout,r);return{snapshot:e,isNew:true,cst:n.BackgroundTimeout}}Cn(o);J.set(mn,0);if(Sn)Sn.bgTs=0;return{snapshot:Sn,isNew:false,cst:0}}if(e==="wx_scene_changed"){if(r&&r!==i.lastScene){const e=Pn(o,n.BackgroundTimeout,r);return{snapshot:e,isNew:true,cst:n.BackgroundTimeout}}return{snapshot:i,isNew:false,cst:0}}const u=An(o,i.lastActive);if(u>=wn.pageInactiveTimeoutSec){const e=Pn(o,n.PageInactiveTimeout,r||i.lastScene);return{snapshot:e,isNew:true,cst:n.PageInactiveTimeout}}Cn(o);return{snapshot:Sn,isNew:false,cst:0}}function jn(e){if(!Sn)Sn=Rn();if(!Sn)return;J.set(mn,e);Sn.bgTs=e}function Cn(e){if(!Sn)Sn=Rn();if(!Sn)return;J.set(gn,e);Sn.lastActive=e}function En(){if(!Sn)Sn=Rn();if(!Sn)return 0;const e=Sn.seq+1;Sn.seq=e;J.set(hn,e);return e}function $n(){return Nn()}function Bn(e){if(!e)return;if(!Sn)Sn=Rn();if(!Sn)return;J.set(yn,e);Sn.lastScene=e}function xn(e){var n,t,o,r,i,u,s,c;if(!e)return null;const l=(o=(t=(n=e.$)===null||n===void 0?void 0:n.type)===null||t===void 0?void 0:t.mpType)!==null&&o!==void 0?o:(r=e.type)===null||r===void 0?void 0:r.mpType;if(e.mpType==="page"||e.$mpType==="page"||((i=e.$mp)===null||i===void 0?void 0:i.mpType)==="page"||((u=e.$options)===null||u===void 0?void 0:u.mpType)==="page"||l==="page"){return"page"}if(e.mpType==="app"||e.$mpType==="app"||((s=e.$mp)===null||s===void 0?void 0:s.mpType)==="app"||((c=e.$options)===null||c===void 0?void 0:c.mpType)==="app"||l==="app"){return"app"}return null}function Mn(){var e;const n=h().getCurrentPages;if(typeof n!=="function")return undefined;const t=c((()=>n()),[])||[];if(!Array.isArray(t)||t.length===0)return undefined;const o=t[t.length-1];return(e=o===null||o===void 0?void 0:o.$vm)!==null&&e!==void 0?e:o}function On(e){var n,t,o,r,i,u,s,c,l,f,a;const d=e!==null&&e!==void 0?e:Mn();if(!d)return"";if(qe()==="bd"){const e=(i=(o=(t=(n=d.$mp)===null||n===void 0?void 0:n.page)===null||t===void 0?void 0:t.is)!==null&&o!==void 0?o:(r=d.$scope)===null||r===void 0?void 0:r.is)!==null&&i!==void 0?i:"";if(e)return e}return(a=(c=(u=d.route)!==null&&u!==void 0?u:(s=d.$scope)===null||s===void 0?void 0:s.route)!==null&&c!==void 0?c:(f=(l=d.$mp)===null||l===void 0?void 0:l.page)===null||f===void 0?void 0:f.route)!==null&&a!==void 0?a:""}function Un(e){var n,t;const o=e!==null&&e!==void 0?e:Mn();if(!o)return"";const r=(n=o.$page)!==null&&n!==void 0?n:(t=o.$scope)===null||t===void 0?void 0:t.$page;if(r){if(r.fullPath&&r.fullPath!=="/")return r.fullPath;if(r.route)return r.route}return On(o)}function Dn(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function Ln(e){if(e!==undefined&&e!==null&&e!==""){return String(e)}const n=Dn();if(typeof(n===null||n===void 0?void 0:n.getLaunchOptionsSync)!=="function")return"";if(!He())return"";return c((()=>{const e=n.getLaunchOptionsSync();const t=e===null||e===void 0?void 0:e.scene;return t===undefined||t===null?"":String(t)}),"")}function qn(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function Vn(e={}){const{enabled:n=false,timeoutMs:t=3e3}=e;return new Promise((e=>{if(!n){e({ok:false,cid:"",reason:"disabled"});return}const o=qn();if(!o||typeof o.getPushClientId!=="function"){e({ok:false,cid:"",reason:"unsupported"});return}let r=false;const i=n=>{if(r)return;r=true;e(n)};const u=setTimeout((()=>i({ok:false,cid:"",reason:"timeout"})),t);c((()=>o.getPushClientId({success:e=>{clearTimeout(u);const n=typeof(e===null||e===void 0?void 0:e.cid)==="string"?e.cid:"";if(!n){i({ok:false,cid:"",reason:"fail"});return}i({ok:true,cid:n})},fail:()=>{clearTimeout(u);i({ok:false,cid:"",reason:"fail"})}})),undefined)}))}const Hn={ttn:"",ttpj:"",ttc:""};function Wn(e){return typeof e==="number"&&Number.isFinite(e)?Math.floor(e):xe()}const Fn={lastRoute:"",lastRouteFull:"",beforeLastRoute:"",beforeLastRouteFull:"",lastRouteEnterTime:0,lastPageTitleSnap:Object.assign({},Hn),lastIey:false,prevIey:false,isHide:false,wasBackgrounded:false,pendingBackgroundResume:false,backgroundEnteredAt:0,suppressNextPageLogAfterResume:false,backgroundResumeLt1At:0};function Jn(){const e=Fn.lastRouteFull||Fn.lastRoute;if(!e)return{};return Object.assign({url:e,iey:Fn.lastIey},Ee())}const Gn=1;const zn=3;const Kn=120;let Yn;function Qn(){return!St()}function Xn(e){Fn.backgroundResumeLt1At=e}function Zn(e){return Fn.backgroundResumeLt1At>0&&e-Fn.backgroundResumeLt1At<=zn}function et(){if(Yn!==undefined){clearTimeout(Yn);Yn=undefined}}function nt(e,n){var t;if(!We())return;if(Fn.pendingBackgroundResume)return;const o=(t=globalThis.document)===null||t===void 0?void 0:t.visibilityState;if(o==="hidden"){vt(e,n)}}function tt(e,n){if(We())return;if(Fn.pendingBackgroundResume)return;et();Yn=setTimeout((()=>{Yn=undefined;if(Fn.pendingBackgroundResume)return;vt(e,n)}),Kn)}
// #ifndef VUE3
function ot(e,n){if(Fn.pendingBackgroundResume)return;if(We()){nt(e,n);return}tt(e,n)}
// #endif
// #ifdef VUE3
function rt(e,n){if(Fn.pendingBackgroundResume)return;if(We()){nt(e,n);return}tt(e,n)}
// #endif
function it(e){return e.getCollector()}function ut(e){var n;if(!e||typeof e!=="string")return"";const t=(n=e.split("?")[0])!==null&&n!==void 0?n:"";return t.startsWith("/")?t.slice(1):t}function st(n,t,o,r,i,u=""){let s;if(i&&!ct){ct=true;s=c((()=>le(r)),undefined)}else{s=c((()=>fe(r)),undefined)}const l={lt:e.Launch,t:r,sc:o,visit:s};if(u)l.url=u;n.report(l)}let ct=false;let lt=0;function ft(){const e=lt;const n=typeof queueMicrotask==="function"?queueMicrotask:e=>{void Promise.resolve().then(e)};n((()=>{c((()=>{if(e!==lt)return;Fn.lastPageTitleSnap=Object.assign({},Ee())}),undefined)}))}function at(t,o={},r={},i){const u=it(t);if(!u)return;const s=Wn(i);const l=c((()=>Ln(o.scene)),"");const f=c((()=>_n("cold_launch",{now:s,scene:l})),null);if(!f)return;c((()=>Se()),undefined);const a=o.path||"";const d=ut(a);if(d){c((()=>ge(d)),undefined)}st(u,f.cst||n.ColdLaunch,l,s,true,a);if(r.enablePush){void Vn({enabled:true,timeoutMs:r.pushTimeoutMs}).then((n=>{if(!n.ok||!n.cid)return;const o=it(t);if(!o)return;o.report({lt:e.Push,cid:n.cid,t:xe()})})).catch((e=>C.warn("[uni统计 2.0] push cid fetch failed",e)))}}function dt(e,t={},o={},r="unknown",i,u=false){if(!Fn.pendingBackgroundResume){return false}const s=Fn.backgroundEnteredAt;if(s<=0){return false}const l=it(e);if(!l){return false}const f=Wn(i);const a=f-s;if(a<Gn&&!u){Fn.suppressNextPageLogAfterResume=true;return true}Fn.wasBackgrounded=false;Fn.suppressNextPageLogAfterResume=true;Fn.lastRouteEnterTime=f;const d=c((()=>Ln(t.scene)),"");const p=c((()=>_n("app_show",{now:f,scene:d,backgroundEnteredAt:s})),null);Fn.pendingBackgroundResume=false;Fn.backgroundEnteredAt=0;if(!p||!p.isNew){return true}c((()=>Se()),undefined);const v=t.path||Fn.lastRoute||"";const h=ut(v);if(h){c((()=>ge(h)),undefined)}st(l,p.cst||n.BackgroundTimeout,d,f,false,v);Xn(f);void l.flush(true).catch((e=>C.warn("[uni统计 2.0] flush after new session (app_show) failed",e)));return true}function pt(e,t={},o={},r,i=false){if(dt(e,t,o,"handleAppShow",r,i))return;const u=it(e);if(!u)return;const s=Wn(r);const l=c((()=>Ln(t.scene)),"");if(Zn(s)){c((()=>Bn(l)),undefined);return}const f=c((()=>_n("app_show",{now:s,scene:l})),null);if(!f||!f.isNew){return}c((()=>Se()),undefined);const a=t.path||Fn.lastRoute||"";const d=ut(a);if(d){c((()=>ge(d)),undefined)}st(u,f.cst||n.BackgroundTimeout,l,s,false,a);Xn(s);void u.flush(true).catch((e=>C.warn("[uni统计 2.0] flush after new session (app_show) failed",e)))}function vt(n,t={},o){if(Fn.pendingBackgroundResume)return;const r=it(n);if(!r)return;const i=Wn(o);Fn.wasBackgrounded=true;Fn.pendingBackgroundResume=true;Fn.backgroundEnteredAt=i;c((()=>jn(i)),undefined);const u=Fn.lastRouteEnterTime>0?i-Fn.lastRouteEnterTime:0;const s=Me(u);if(Fn.lastRoute&&t.enablePageLog!==false){const n=Fn.lastRouteFull||Fn.lastRoute;const t=Fn.beforeLastRouteFull||Fn.beforeLastRoute||"";const o=Fn.lastPageTitleSnap;const u={lt:e.Page,t:i,url:n,urlref_ts:s,iey:Fn.lastIey,ppiey:Fn.prevIey,ttn:o.ttn,ttpj:o.ttpj,ttc:o.ttc};if(t)u.urlref=t;r.report(u);if(Fn.lastIey){c((()=>we()),undefined);Fn.lastIey=false}}r.report({lt:e.Hide,t:i,urlref:Fn.lastRoute,urlref_ts:s});void r.flush(true).catch((e=>C.warn("[uni统计 2.0] flush on hide failed",e)))}function ht(t,o,r={},i){const u=it(t);if(!u)return;if(Fn.pendingBackgroundResume&&Qn()){dt(t,{},r,"handlePageShow",i)}const s=Wn(i);const l=c((()=>On(o)),"");const f=c((()=>Un(o)),"")||l;if(!l&&!f)return;const a=c((()=>_n("page_show",{now:s})),null);if(!a)return;c((()=>je(Ne(l))),undefined);if(a.isNew){c((()=>Se()),undefined)}if(l){c((()=>ge(l)),undefined)}if(a.isNew){st(u,a.cst||n.PageInactiveTimeout,"",s,false,f)}const d=Fn.suppressNextPageLogAfterResume;if(Fn.lastRoute&&r.enablePageLog!==false&&!d){const n=Fn.lastRouteEnterTime>0?s-Fn.lastRouteEnterTime:0;const t=Me(n);const o=Fn.lastRouteFull||Fn.lastRoute;const r=Fn.beforeLastRouteFull||Fn.beforeLastRoute||"";const i=Fn.lastPageTitleSnap;const l={lt:e.Page,t:s,url:o,urlref_ts:t,iey:Fn.lastIey,ppiey:Fn.prevIey};if(r)l.urlref=r;l.ttn=i.ttn;l.ttpj=i.ttpj;l.ttc=i.ttc;u.report(l);if(Fn.lastIey){c((()=>we()),undefined)}}Fn.beforeLastRoute=Fn.lastRoute;Fn.beforeLastRouteFull=Fn.lastRouteFull;Fn.prevIey=Fn.lastIey;Fn.lastIey=!!l&&c((()=>be(l)),false);Fn.lastRoute=l;Fn.lastRouteFull=f;Fn.lastRouteEnterTime=s;Fn.suppressNextPageLogAfterResume=false;ft();Fn.isHide=false;if(a.isNew){void u.flush(true).catch((e=>C.warn("[uni统计 2.0] flush after new session (page_show) failed",e)))}}function gt(e,n){const t=it(e);if(!t)return;Fn.isHide=true;lt++;Fn.lastPageTitleSnap=Object.assign({},Ee());c((()=>$e()),undefined);c((()=>Ce("")),undefined)}const mt=typeof WeakSet==="function"?new WeakSet:{has:()=>false,add:()=>mt};function yt(e,n,t,o=true){const r=typeof n==="object"&&n!==null;if(r&&mt.has(n))return;if(r)mt.add(n);try{e.reportError(n,t)}catch(e){C.warn("[uni统计 2.0] handleError failed",e)}if(!o||He()){return}c((()=>{setTimeout((()=>{throw n}),0)}),undefined)}function bt(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function wt(){let e=We()||qe()==="n"||Fe();
// #ifndef VUE3
e=true;
// #endif
// #ifdef VUE3
e=We()||qe()==="n"||Fe();
// #endif
return e}function St(){let e=!We()&&qe()!=="n"&&!Fe();
// #ifndef VUE3
e=false;
// #endif
// #ifdef VUE3
e=!We()&&qe()!=="n"&&!Fe();
// #endif
return e}const kt={showBound:false,hideBound:false,appShowCb:undefined,appHideCb:undefined};function It(e,n={}){if(!St())return false;const t=bt();if(!t)return false;if(!kt.showBound&&typeof t.onAppShow==="function"){kt.appShowCb=t=>pt(e,t!==null&&t!==void 0?t:{},n);c((()=>t.onAppShow(kt.appShowCb)),undefined);kt.showBound=true}if(!kt.hideBound&&typeof t.onAppHide==="function"){kt.appHideCb=()=>vt(e,n);c((()=>t.onAppHide(kt.appHideCb)),undefined);kt.hideBound=true}return kt.showBound&&kt.hideBound}function Tt(){if(!kt.showBound&&!kt.hideBound)return;const e=bt();if(kt.showBound&&kt.appShowCb&&(e===null||e===void 0?void 0:e.offAppShow)){c((()=>e.offAppShow(kt.appShowCb)),undefined)}if(kt.hideBound&&kt.appHideCb&&(e===null||e===void 0?void 0:e.offAppHide)){c((()=>e.offAppHide(kt.appHideCb)),undefined)}kt.showBound=false;kt.hideBound=false;kt.appShowCb=undefined;kt.appHideCb=undefined}function At(e,n={}){let t=true;const o={onLaunch(t={}){at(e,t,n)},onLoad(){},onShow(){const t=xn(this);et();if(Fn.pendingBackgroundResume&&Qn()){dt(e,{},n,"mixin.onShow")}Fn.isHide=false;if(t==="page"){ht(e,this,n)}if(wt()&&t==="app"){pt(e,{},n)}},onHide(){Fn.isHide=true;if(xn(this)==="page"){gt(e);
// #ifndef VUE3
ot(e,n);
// #endif
// #ifdef VUE3
rt(e,n);
// #endif
}if(wt()&&xn(this)==="app"&&!Fn.pendingBackgroundResume){vt(e,n)}},onUnload(){if(Fn.isHide){Fn.isHide=false;return}gt(e)},onError(n){yt(e,n)}};if(St()){It(e,n)}return{mixin:o,tryBindUniAppHooks:()=>St()&&It(e,n),unbind(){if(!t)return;t=false;Tt()}}}const Rt=process.env.UNI_COMPILER_VERSION||"";const Nt="https://tongji.dcloud.io/uni/stat";const Pt="https://tongji.dcloud.io/uni/stat.gif";const _t=10;const jt=3;const Ct=2;const Et=2;const $t=1e3;const Bt=true;const xt=3e4;const Mt=2e3;const Ot=300;const Ut=4*1024;const Dt=4*1024;const Lt=30;const qt=1e3;const Vt=5;const Ht={host:"https://tongji-collector.dcloud.net.cn",projectId:"964f0397-af5d-45bf-99d6-8fb3500d7849",topicId:"8563e231-f4cd-4ab0-8870-917e4b04e810"};function Wt(){var e;return(e=process.env.UNI_APP_ID)!==null&&e!==void 0?e:""}function Ft(e){if(!e||typeof e!=="object")return;const n=e;if(n.success===false){throw new Error("cloud receiver reported success=false")}if(typeof n.errCode==="number"&&n.errCode!==0){throw new Error("cloud receiver reported errCode="+String(n.errCode))}}function Jt(e){if(e)return e;const n=y();const t=n!=null&&typeof n==="object"?n:undefined;return t===null||t===void 0?void 0:t.__stat_uniCloud_space}function Gt(e={}){var n,t;const o=(n=e.receiverName)!==null&&n!==void 0?n:"uni-stat-receiver";const i=(t=e.maxRetries)!==null&&t!==void 0?t:Ct;function u(){const n=Jt(e.uniCloudSpace);if(!n||typeof n.importObject!=="function")return undefined;try{return n.importObject(o,{customUI:true})}catch(e){C.warn("[uni统计 2.0] cloud importObject threw",e);return undefined}}function s(e){const n=u();if(!n||typeof n.report!=="function"){return Promise.reject(new Error("uniCloud space unavailable"))}return Promise.resolve(n.report(e)).then((e=>{Ft(e)}))}return{name:"2.0",available(){const n=Jt(e.uniCloudSpace);return!!(n&&typeof n.importObject==="function")},send(n){return r(this,void 0,void 0,(function*(){try{yield l((()=>s(n)),{times:i,baseDelayMs:$t,sleep:e.sleep})}catch(e){C.warn("[uni统计 2.0] 统计上报失败(云函数已重试)",e);throw e}}))}}}function zt(n){switch(n){case e.Launch:return"应用启动";case e.Hide:return"应用进入后台";case e.Page:return"页面切换";case e.Event:return"事件触发";case e.Error:return"应用错误";case e.Push:return"PUSH 设备标识";default:return`未知事件 (lt=${String(n!==null&&n!==void 0?n:"?")})`}}function Kt(e){let n=0;for(const t of Object.keys(e)){const o=e[t];if(Array.isArray(o))n+=o.length}return n}function Yt(e){const n=[];for(const t of Object.keys(e)){const o=e[t];if(Array.isArray(o)&&o.length>0){n.push(`lt=${t}×${o.length}`)}}return n.join(", ")||"<空>"}function Qt(e){if(!C.isDebug())return;const n=e.lt;const t=zt(n);C.debug(`=== 统计数据采集:${t} (lt=${String(n!==null&&n!==void 0?n:"?")}) ===`);C.debug(e);C.debug("=== 采集结束 ===")}function Xt(e){if(!C.isDebug())return;const n=[];if(e.backgroundTimeoutSec!=null){n.push(`后台超时(新会话): ${e.backgroundTimeoutSec}s`)}if(e.pageInactiveTimeoutSec!=null){n.push(`前台无操作超时: ${e.pageInactiveTimeoutSec}s`)}const t=n.length>0?` | ${n.join(" | ")}`:"";const o=["=== uni统计 2.0 已启用 ===",`上报间隔: ${e.reportIntervalSec}s${t} | 应用APPID: ${e.ak||"<未注入>"}${e.appName?` | 应用名: ${e.appName}`:""}${e.vueMode?` | ${e.vueMode}`:""}`];if(e.debugFromManifest){o.push("调试模式:已从 manifest.uniStatistics.debug 自动开启")}o.push("=== 后续将在每次采集 / 上报时输出过程日志 ===");C.debug(o.join("\n"))}function Zt(e){if(!C.isDebug())return;const n=Kt(e.bucket);const t=Yt(e.bucket);C.debug(`=== 准备上报:共 ${n} 条事件 (${t}) ===`)}function eo(e){if(!C.isDebug())return;C.debug(`原因: ${io(e.error)}`);if(e.persistedId){C.debug(`已暂存重试队列 [retryId=${e.persistedId}],下次启动自动续传`)}else{C.debug("未能写入重试队列:本批数据已丢弃")}}function no(e){if(!C.isDebug())return;if(e.failedCount===0){C.debug(`=== 上报成功: ${e.okCount} 条事件已送达, 用时 ${e.elapsedMs}ms ===`)}else if(e.okCount===0){C.debug(`=== 上报失败: ${e.failedCount} 条事件未送达, 用时 ${e.elapsedMs}ms ===`)}else{C.debug(`=== 上报完成:成功 ${e.okCount} 条,失败 ${e.failedCount} 条,用时 ${e.elapsedMs}ms ===`)}}function to(e){if(!C.isDebug())return;C.debug(`=== 上报跳过:当前无可用通道,已回滚 ${Kt(e.bucket)} 条事件入队 ===`)}function oo(e){if(!C.isDebug())return;C.debug(`=== 冷启续传:发现 ${e} 条历史 payload,开始逐条重发 ===`)}function ro(e){if(!C.isDebug())return;if(e.ok){C.debug(`续传成功 (${e.index}/${e.total})`)}else{C.debug(`续传失败 (${e.index}/${e.total}):${io(e.error)}`)}}function io(e){if(!e)return"<无错误对象>";if(e instanceof Error){return`${e.name}: ${e.message}`}if(typeof e==="string")return e;return s(e)||String(e)}function uo(e){const n={};for(const t of Object.keys(e)){const o=e[t];if(o==="")continue;n[t]=o}return n}const so={1:1,11:2,21:3,31:4,101:5,3:100};const co=50;function lo(e){return JSON.stringify(fo(e))}function fo(e){const n=Object.keys(e);n.sort(((e,n)=>ao(e)-ao(n)));const t=[];for(let o=0;o<n.length;o++){const r=n[o];const i=e[r];if(!i||i.length===0)continue;for(let e=0;e<i.length;e++)t.push(i[e])}return t}function ao(e){const n=so[e];return typeof n==="number"?n:co}function po(e,n={}){var t,o;const r=(t=n.maxEvents)!==null&&t!==void 0?t:Infinity;const i=(o=n.maxBytes)!==null&&o!==void 0?o:Infinity;const u=[];if(!Array.isArray(e)||e.length===0)return u;const s=r>0?r:Infinity;const c=i>0?i:Infinity;let l=[];let f=2;for(let n=0;n<e.length;n++){const t=e[n];let o="";try{o=JSON.stringify(t)}catch(e){continue}const r=l.length===0?o.length:o.length+1;const i=l.length>=s||l.length>0&&f+r>c;if(i){u.push(l);l=[];f=2}l.push(t);f+=l.length===1?o.length:o.length+1}if(l.length>0)u.push(l);return u}function vo(e,n={}){const t=fo(e);if(t.length===0)return[];const o=po(t,n);const r=[];for(let e=0;e<o.length;e++){r.push(JSON.stringify(o[e]))}return r}class ho extends Error{constructor(e){super(e);this.permanent=true;this.name="PermanentChannelError";Object.setPrototypeOf(this,ho.prototype)}}function go(e){if(!e||typeof e!=="object")return false;if(e instanceof ho)return true;const n=e;if(n.name==="PermanentChannelError")return true;if(n.permanent===true)return true;return false}function mo(e){return"p-"+e.toString(36)+"-"+Math.random().toString(36).slice(2,6)}function yo(n){let t=false;let o=null;let i;function u(){if(o==null)return;clearTimeout(o);o=null}function s(){var e;const r=Math.max(0,Math.floor((e=n.firstFlushDeferMs)!==null&&e!==void 0?e:0));if(!t&&r>0){if(o!=null)return;o=setTimeout((()=>{o=null;t=true;void p(false).catch((e=>C.warn("[uni统计 2.0] auto-flush failed",e)))}),r);return}t=true;void p(false).catch((e=>C.warn("[uni统计 2.0] auto-flush failed",e)))}function l(t){c((()=>{const o=typeof t.t==="number"?t.t:n.nowSec();const r=n.session.getSnapshot();let i;if(r){const e=n.session.nextSeq();i=Object.assign({},r,{seq:e})}if(r&&t.lt===e.Event&&n.session.touch){n.session.touch(o)}const u=Object.assign({},t,{t:o,session:i});const c=n.builder.build(u);Qt(c);n.queue.enqueue(uo(c));if(n.queue.shouldFlush()){s()}}),undefined)}function f(e){const t=n.resolveUploadFields?n.resolveUploadFields():{};const o=Object.keys(t).filter((e=>{const n=t[e];return n!==""&&n!==undefined&&n!==null}));if(o.length===0)return;for(const n of Object.keys(e)){const r=e[n];if(!Array.isArray(r))continue;for(let e=0;e<r.length;e++){const n=r[e];for(let e=0;e<o.length;e++){const r=o[e];n[r]=t[r]}}}}function a(e){const t=n.resolveUploadFields?n.resolveUploadFields():{};const o=Object.keys(t).filter((e=>{const n=t[e];return n!==""&&n!==undefined&&n!==null}));if(o.length===0)return e;try{const n=JSON.parse(e);if(!Array.isArray(n))return e;for(let e=0;e<n.length;e++){const r=n[e];if(!r||typeof r!=="object")continue;for(let e=0;e<o.length;e++){const n=o[e];r[n]=t[n]}}return JSON.stringify(n)}catch(n){return e}}function d(e){const n=a(e.requests);if(n===e.requests)return e;return Object.assign({},e,{requests:n})}function p(){return r(this,arguments,void 0,(function*(e=false){var t,o,r,i,u;if(!n.queue.shouldFlush(e))return;if(n.isNetworkOffline){let e=false;try{e=yield n.isNetworkOffline()}catch(n){e=false}if(e){C.warn("[uni统计 2.0] 当前无网络,延后 flush");return}}const s=n.queue.flush();if(!s)return;f(s);const l=n.selectChannel();if(!l){C.warn("[uni统计 2.0] 无可用上报线路,本批已回滚队列");to({bucket:s});n.queue.rollback(s);return}const a=(o=(t=n.batchLimits)===null||t===void 0?void 0:t.maxBytes)!==null&&o!==void 0?o:Dt;const d=typeof l.maxRequestBytes==="function"?l.maxRequestBytes():Number.POSITIVE_INFINITY;const p={maxEvents:(i=(r=n.batchLimits)===null||r===void 0?void 0:r.maxEvents)!==null&&i!==void 0?i:Lt,maxBytes:Math.min(a,d)};const h=vo(s,p);if(h.length===0){C.warn("[uni统计 2.0] flush 切片结果为空,已回滚队列",s);n.queue.rollback(s);return}const g=n.nowMs();let m=0;for(const e of Object.keys(s)){const n=s[e];if(Array.isArray(n))m+=n.length}Zt({channel:l.name,bucket:s});const y=Array.isArray(s["1"])&&s["1"].length>0;let b=0;let w=0;let S=true;let k=true;for(let e=0;e<h.length;e++){const t=h[e];const o={usv:n.config.usv,t:n.nowSec(),requests:t,_id:((u=n.genPayloadId)!==null&&u!==void 0?u:()=>mo(n.nowMs()))()};const r=v(t);try{yield l.send(o);b+=r}catch(i){S=false;if(e===0)k=false;w+=r;if(go(i)){C.warn("[uni统计 2.0] 统计上报失败(本批已丢弃,不可重试)",i,"sliceBytes="+t.length);eo({error:i,persistedId:undefined});continue}C.warn("[uni统计 2.0] 统计上报失败(已暂存,下次启动自动重试)",i);const u=n.retry.persist(o);if(!u){C.warn("[uni统计 2.0] 统计暂存重试失败(无 retryId),本批已丢弃")}eo({error:i,persistedId:u})}}const I=y?k:S;if(I){c((()=>n.visit.commitVisitOnAck(n.nowSec())),undefined)}else{c((()=>n.visit.rollbackPendingVisit()),undefined)}no({channel:l.name,okCount:b,failedCount:w,elapsedMs:n.nowMs()-g})}))}function v(e){try{const n=JSON.parse(e);return Array.isArray(n)?n.length:0}catch(e){return 0}}function h(){return r(this,void 0,void 0,(function*(){if(n.isNetworkOffline){let e=false;try{e=yield n.isNetworkOffline()}catch(n){e=false}if(e){C.warn("[uni统计 2.0] 当前无网络,延后续传重试");return}}const e=n.retry.loadAll();if(e.length===0)return;const t=n.selectChannel();if(!t){C.warn("[uni统计 2.0] 续传重试跳过:当前无可用上报线路");return}oo(e.length);let o=0;for(const r of e){o++;const i=d(r);try{yield t.send(i);if(r._id)n.retry.ack(r._id);ro({index:o,total:e.length,payloadId:r._id,ok:true})}catch(t){if(go(t)){if(r._id)n.retry.ack(r._id);C.warn("[uni统计 2.0] 续传重试失败(不可重试,已从队列移除)",t,"id="+r._id);ro({index:o,total:e.length,payloadId:r._id,ok:false,error:t});continue}if(r._id&&n.retry.markAttempt){n.retry.markAttempt(r._id)}C.warn("[uni统计 2.0] 续传重试失败(保留队列,下次启动再试)",t);ro({index:o,total:e.length,payloadId:r._id,ok:false,error:t})}}}))}function g(){if(i)return i;const e=h();i=e;const n=()=>{if(i===e)i=undefined};void e.then(n,n);return e}function m(){return r(this,arguments,void 0,(function*(e=false){u();t=true;return p(e)}))}function y(){u();t=true}return{report:l,flush:m,recoverRetry:g,destroy:y}}function bo(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function wo(e){const n=[];n.push("usv="+encodeURIComponent(String(e.usv)));n.push("t="+encodeURIComponent(String(e.t)));n.push("requests="+encodeURIComponent(e.requests));return n.join("&")}function So(e,n=Pt){const t=h().Image;if(typeof t!=="function")return false;return c((()=>{const o=new t;o.src=n+"?"+wo(e);return true}),false)}function ko(e={}){var n,t,o,i,u;const s=(n=e.url)!==null&&n!==void 0?n:Nt;const c=(t=e.h5Url)!==null&&t!==void 0?t:Pt;const f=(o=e.ut)!==null&&o!==void 0?o:"";const a=(i=e.timeoutMs)!==null&&i!==void 0?i:1e4;const d=(u=e.maxRetries)!==null&&u!==void 0?u:jt;function p(n){if(f==="h5"&&e.preferImageOnH5!==false){if(So(n,c))return Promise.resolve()}const t=bo();if(!t||typeof t.request!=="function"){return Promise.reject(new Error("uni.request unavailable"))}return new Promise(((e,o)=>{let r=false;const i=setTimeout((()=>{if(r)return;r=true;o(new Error("http timeout"))}),a);t.request({url:s,method:"POST",data:n,timeout:a,success:n=>{var t;if(r)return;r=true;clearTimeout(i);const u=(t=n===null||n===void 0?void 0:n.statusCode)!==null&&t!==void 0?t:0;if(u>=200&&u<300)e();else o(new Error("http status "+u))},fail:e=>{if(r)return;r=true;clearTimeout(i);o(e instanceof Error?e:new Error(String(e)))}})}))}return{name:"1.0",available(){const e=bo();return!!(e&&typeof e.request==="function")},send(n){return r(this,void 0,void 0,(function*(){try{yield l((()=>p(n)),{times:d,baseDelayMs:$t,sleep:e.sleep})}catch(e){C.warn("[uni统计 2.0] 统计上报失败(HTTP 已重试)",e);throw e}}))}}}const Io="/WebTrack";const To="/WebTrack.gif";function Ao(){const e=y();return e!=null&&typeof e==="object"?e:undefined}const Ro=256;const No=3;function Po(e,n){var t;const o=((t=n.nowMs)!==null&&t!==void 0?t:()=>Date.now())();const r=encodeURIComponent(e.requests);const i=n.host.replace(/\/+$/,"");return i+n.path+"?ProjectId="+encodeURIComponent(n.projectId)+"&TopicId="+encodeURIComponent(n.topicId)+"&Logs="+r+"&Source=webImg"+"&Time="+o}function _o(e,n=320){if(e==null)return"";if(typeof e==="string"){return e.length<=n?e:e.slice(0,n)+"…"}try{const t=JSON.stringify(e);return t.length<=n?t:t.slice(0,n)+"…"}catch(t){return String(e).slice(0,n)}}function jo(e,n){const t=h().Image;if(typeof t!=="function"){return Promise.reject(new ho("当前环境无法完成统计上报"))}return new Promise(((o,r)=>{let i=false;const u=setTimeout((()=>{if(i)return;i=true;r(new Error("统计上报超时"))}),n);const s=new t;s.onload=()=>{if(i)return;i=true;clearTimeout(u);o()};s.onerror=()=>{if(i)return;i=true;clearTimeout(u);o()};s.src=e}))}function Co(e,n){const t=h();const o=t.fetch;if(typeof o!=="function"){return Promise.reject(new Error("fetch unavailable"))}const r=typeof t.AbortController==="function"?new t.AbortController:undefined;return new Promise(((t,i)=>{let u=false;const s=setTimeout((()=>{if(u)return;u=true;if(r)c((()=>r.abort()),undefined);i(new Error("统计上报超时"))}),n);o(e,{method:"GET",keepalive:true,credentials:"omit",signal:r?r.signal:undefined}).then((e=>{if(u)return;u=true;clearTimeout(s);if(e&&e.ok){t();return}i(new Error("统计上报 HTTP "+(e?e.status:0)))}),(e=>{if(u)return;u=true;clearTimeout(s);i(e instanceof Error?e:new Error(String(e)))}))}))}function Eo(){const e=h().wx;return typeof(e===null||e===void 0?void 0:e.preloadAssets)==="function"?e.preloadAssets:undefined}function $o(e){if(e instanceof Error)return e;if(e!=null&&typeof e==="object"&&"errMsg"in e){const n=e.errMsg;if(typeof n==="string"&&n.length>0)return new Error(n)}if(e==null)return new Error("preloadAssets fail (empty err)");return new Error(String(e))}function Bo(e,n,t){return new Promise(((o,r)=>{let i=false;const u=setTimeout((()=>{if(i)return;i=true;r(new Error("统计上报超时(preloadAssets)"))}),n);try{t({data:[{type:"image",src:e}],success:()=>{if(i)return;i=true;clearTimeout(u);o()},fail:e=>{if(i)return;i=true;clearTimeout(u);r($o(e))}})}catch(e){if(i)return;i=true;clearTimeout(u);r(e instanceof Error?e:new Error(String(e)))}}))}function xo(e){var n,t;const o=(n=e.mpWeixinPreloadReport)!==null&&n!==void 0?n:Bt;if(!o)return false;const r=(t=e.rawPlatform)!==null&&t!==void 0?t:Le();return r==="mp-weixin"}function Mo(e={}){var n,t,o,i,u,s,c;const f=(n=e.host)!==null&&n!==void 0?n:Ht.host;const a=(t=e.projectId)!==null&&t!==void 0?t:Ht.projectId;const d=(o=e.topicId)!==null&&o!==void 0?o:Ht.topicId;const p=(i=e.timeoutMs)!==null&&i!==void 0?i:1e4;const v=(u=e.maxRetries)!==null&&u!==void 0?u:Et;const g=(s=e.maxUrlLength)!==null&&s!==void 0?s:6*1024;const m=e.preferImageBeacon!==false;const y=e.nowMs;const b=(c=e.ut)!==null&&c!==void 0?c:"";const w=b==="h5";const S=xo(e);function k(){return!!(f&&a&&d)}const I={host:f,projectId:a,topicId:d,nowMs:y};function T(e,n){if(!k()){throw new ho("统计上报未配置:请设置 TLS host、projectId、topicId")}const t=Po(e,{host:I.host,projectId:I.projectId,topicId:I.topicId,nowMs:I.nowMs,path:n});if(t.length>g){throw new ho("统计上报 URL 过长: "+t.length+" > "+g)}return t}function A(e){const n=Ao();if(!n||typeof n.request!=="function"){return Promise.reject(new ho("当前环境无法完成统计上报"))}return new Promise(((t,o)=>{let r=false;const i=setTimeout((()=>{if(r)return;r=true;o(new Error("统计上报超时"))}),p);n.request({url:e,method:"GET",dataType:"text",timeout:p,success:e=>{var n;if(r)return;r=true;clearTimeout(i);const u=(n=e===null||e===void 0?void 0:e.statusCode)!==null&&n!==void 0?n:0;if(u>=200&&u<300){t();return}const s=_o(e===null||e===void 0?void 0:e.data);o(new Error(s?`统计上报 HTTP ${u}: ${s}`:`统计上报 HTTP ${u}`))},fail:e=>{if(r)return;r=true;clearTimeout(i);o(e instanceof Error?e:new Error(_o(e)||String(e)))}})}))}function R(e){const n=h();const t=Ao();const o=!!(t&&typeof t.request==="function");if(m&&typeof n.fetch==="function"){return Co(T(e,To),p)}if(o){return A(T(e,Io))}if(m&&typeof n.Image==="function"){return jo(T(e,To),p)}return Promise.reject(new ho("当前环境无法完成统计上报"))}function N(e){const n=Eo();if(n){return Bo(T(e,To),xt,n)}C.warn("[uni统计 2.0] wx.preloadAssets 不可用,回退 uni.request GET /WebTrack");return A(T(e,Io))}function P(e){if(w)return R(e);if(S)return N(e);return A(T(e,Io))}return{name:"image",available(){return k()},maxRequestBytes(){const e=(g-Ro)/No;return Math.max(512,Math.floor(e))},send(n){return r(this,void 0,void 0,(function*(){try{yield l((()=>P(n)),{times:v,baseDelayMs:$t,sleep:e.sleep})}catch(e){if(go(e)){C.warn("[uni统计 2.0] 统计上报失败(不可重试)",e)}else{C.warn("[uni统计 2.0] 统计上报失败(已重试)",e)}throw e}}))}}}function Oo(e,n=""){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);return n}function Uo(e,n=0){if(typeof e==="number"&&Number.isFinite(e))return e;if(typeof e==="string"&&e.length>0){const n=Number(e);if(Number.isFinite(n))return n}return n}function Do(e){function n(){var n,t,o;const{config:r,platform:i,system:u,device:s,net:c,location:l,pkg:f,legacy:a,web:d}=e;const p=e.resolveLocale?e.resolveLocale():e.locale;return{ak:Oo(r.ak),usv:Oo(r.usv),v:Oo((n=r.v)!==null&&n!==void 0?n:u.appVersion),ch:Oo(r.ch),ut:Oo(i.ut),p:Oo((t=i.p)!==null&&t!==void 0?t:u.osP),on:Oo(u.on),did:Oo(s.uuid),brand:Oo(u.brand),md:Oo(u.md),sv:Oo(u.sv),mpsdk:Oo(u.sdkVersion),mpv:Oo(u.mpvHostVersion),pr:Uo(p.pr,1),ww:Uo(p.ww),wh:Uo(p.wh),sw:Uo(p.sw),sh:Uo(p.sh),lang:Oo(p.lang),net:Oo(c.net,"unknown"),lat:Oo(l.lat),lng:Oo(l.lng),mpn:Oo((o=a===null||a===void 0?void 0:a.mpn)!==null&&o!==void 0?o:f.mpn),tdaid:Oo(f.tdaid),pkn:Oo(f.pkn),an:Oo(f.an),domain:Oo(d.domain)}}function t(e){if(!e.session)return{};return{sid:e.session.sid,cst:e.session.sct}}function r(e){const n={};if(e.url!==undefined)n.url=Oo(e.url);if(e.urlref!==undefined)n.urlref=Oo(e.urlref);if(e.urlref_ts!==undefined)n.urlref_ts=Uo(e.urlref_ts);if(e.ttn!==undefined)n.ttn=Oo(e.ttn);if(e.ttpj!==undefined)n.ttpj=Oo(e.ttpj);if(e.ttc!==undefined)n.ttc=Oo(e.ttc);return n}function i(e){if(e.lt==="11"){return{iey:o(e.iey!==undefined?e.iey:false),ppiey:o(e.ppiey!==undefined?e.ppiey:false)}}if(e.lt==="21"&&e.iey!==undefined){return{iey:o(e.iey)}}return{}}function u(e){if(e.lt!=="1")return{};if(!e.visit)return{};return{fvts:e.visit.fvts,lvts:e.visit.lvts,tvc:e.visit.tvc}}function s(e){if(e.lt!=="1")return{};if(e.sc===undefined)return{};return{sc:Oo(e.sc)}}function c(e){if(e.lt!=="31"||!e.errMsg)return{};const n=3*1024;const t="…[truncated]";let o=Oo(e.errMsg);if(o.length>n){o=o.slice(0,n-t.length)+t}return{em:o}}function l(e){if(e.lt!=="101"||!e.cid)return{};return{cid:Oo(e.cid)}}function f(e){const o={};if(e.custom){const n=new Set(["lt","t","sid","cst","did","p","on","mpv","domain","fvts","lvts","tvc","sc"]);for(const t of Object.keys(e.custom)){if(!n.has(t))o[t]=e.custom[t]}}const f={lt:e.lt,t:Uo(e.t)};Object.assign(f,n(),t(e),r(e),i(e),u(e),s(e),c(e),l(e),o);return f}return{build:f}}function Lo(e){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);return""}function qo(){if(a()){if(!Ve())return"";const e=y();return Lo(c((()=>{var n;return(n=e===null||e===void 0?void 0:e.getAppBaseInfo)===null||n===void 0?void 0:n.call(e).channel}),undefined))}const e=h().plus;if(!Ve()&&!(e===null||e===void 0?void 0:e.runtime))return"";const n=c((()=>{var n;return(n=e===null||e===void 0?void 0:e.runtime)===null||n===void 0?void 0:n.channel}),undefined);return Lo(n)}let Vo=null;function Ho(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function Wo(){const e=Le();if(e!=="mp-weixin"&&e!=="mp-qq")return null;const n=h().wx;if(!n)return null;const t=typeof n.getSystemInfoSync==="function"?c((()=>n.getSystemInfoSync()),null):null;const o=typeof n.getDeviceInfo==="function"?c((()=>n.getDeviceInfo()),null):null;const r=typeof n.getAppBaseInfo==="function"?c((()=>n.getAppBaseInfo()),null):null;const i=typeof n.getWindowInfo==="function"?c((()=>n.getWindowInfo()),null):null;return Fo(t,o,r,i)}function Fo(...e){const n={};for(const t of e){if(!t)continue;for(const e of Object.keys(t)){const o=t[e];if(o!==undefined&&o!==null)n[e]=o}}return n}function Jo(){const e=Ho();const n=e&&typeof e.getSystemInfoSync==="function"?c((()=>e.getSystemInfoSync()),null):null;const t=e&&typeof e.getDeviceInfo==="function"?c((()=>e.getDeviceInfo()),null):null;const o=e&&typeof e.getAppBaseInfo==="function"?c((()=>e.getAppBaseInfo()),null):null;const r=e&&typeof e.getWindowInfo==="function"?c((()=>e.getWindowInfo()),null):null;const i=Fo(n,t,o,r);const u=Wo();const s=u?Fo(i,u):i;return s}function Go(){return c((()=>{const e=h().__uniConfig;return typeof(e===null||e===void 0?void 0:e.appVersion)==="string"?e.appVersion:""}),"")}function zo(){const e=process.env.UNI_APP_VERSION_NAME;return typeof e==="string"?e:""}function Ko(e,n){var t;const o=(t=e===null||e===void 0?void 0:e.runtime)===null||t===void 0?void 0:t.version;if(typeof o==="string"&&o)return o;const r=n.appVersion;if(typeof r==="string"&&r)return r;const i=Go();if(i)return i;return zo()}function Yo(e){const n=typeof e.romName==="string"?e.romName.trim():"";if(n){const t=typeof e.romVersion==="string"?e.romVersion.trim():"";return t?`${n} ${t}`.trim():n}return typeof e.osName==="string"?e.osName.trim():""}function Qo(){var e,n,t,o,r,i,u,s,c,l,f,a,d,p,v,g,m,y;if(Vo)return Vo;const b=Jo();const w=h().plus;const S=Ko(w,b);Vo={brand:(n=(e=b.deviceBrand)!==null&&e!==void 0?e:b.brand)!==null&&n!==void 0?n:"",md:(o=(t=b.deviceModel)!==null&&t!==void 0?t:b.model)!==null&&o!==void 0?o:"",sv:(i=(r=b.osVersion)!==null&&r!==void 0?r:b.system)!==null&&i!==void 0?i:"",v:(s=(u=b.hostVersion)!==null&&u!==void 0?u:b.version)!==null&&s!==void 0?s:"",ut:(c=b.deviceType)!==null&&c!==void 0?c:"unknown",appVersion:S,appWgtVersion:(p=(d=(f=(l=w===null||w===void 0?void 0:w.runtime)===null||l===void 0?void 0:l.appWgtVersion)!==null&&f!==void 0?f:(a=w===null||w===void 0?void 0:w.runtime)===null||a===void 0?void 0:a.appWgtRevision)!==null&&d!==void 0?d:b.appWgtVersion)!==null&&p!==void 0?p:"",mpvHostVersion:((g=(v=b.hostVersion)!==null&&v!==void 0?v:b.version)!==null&&g!==void 0?g:"").trim(),on:Yo(b),sdkVersion:(y=(m=b.hostSDKVersion)!==null&&m!==void 0?m:b.SDKVersion)!==null&&y!==void 0?y:"",statusBarHeight:typeof b.statusBarHeight==="number"?b.statusBarHeight:0,osP:Oe({platform:b.platform,osName:b.osName,system:b.system})};return Vo}function Xo(){var e,n;const t=Jo();const o=typeof t.pixelRatio==="number"?t.pixelRatio:typeof t.devicePixelRatio==="number"?t.devicePixelRatio:1;return{lang:((n=(e=t.hostLanguage)!==null&&e!==void 0?e:t.language)!==null&&n!==void 0?n:"").replace(/_/g,"-"),ww:typeof t.windowWidth==="number"?t.windowWidth:0,wh:typeof t.windowHeight==="number"?t.windowHeight:0,sw:typeof t.screenWidth==="number"?t.screenWidth:0,sh:typeof t.screenHeight==="number"?t.screenHeight:0,pr:o>0?o:1}}let Zo=null;function er(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function nr(){return h().plus}function tr(){return c((()=>{var e,n,t;return(t=(n=(e=er())===null||e===void 0?void 0:e.getAppBaseInfo)===null||n===void 0?void 0:n.call(e))!==null&&t!==void 0?t:{}}),{})}function or(e){const n=er();switch(e){case"wx":case"qq":{if(typeof(n===null||n===void 0?void 0:n.getAccountInfoSync)==="function"){const e=c((()=>{var e,t;return(t=(e=n.getAccountInfoSync().miniProgram)===null||e===void 0?void 0:e.appId)!==null&&t!==void 0?t:""}),"");if(e)return e}const e=h().wx;if(typeof(e===null||e===void 0?void 0:e.getAccountInfoSync)==="function"){const n=c((()=>{var n,t;return(t=(n=e.getAccountInfoSync().miniProgram)===null||n===void 0?void 0:n.appId)!==null&&t!==void 0?t:""}),"");if(n)return n}const t=process.env.UNI_APP_ID;return typeof t==="string"?t:""}case"ali":case"dt":{const e=h().my;if(!e)return"";const n=c((()=>{var n,t;return(t=(n=e.getAppIdSync)===null||n===void 0?void 0:n.call(e))!==null&&t!==void 0?t:""}),"");if(n)return n;return c((()=>{var n,t,o;return(o=(t=(n=e.getAccountInfoSync)===null||n===void 0?void 0:n.call(e).miniProgram)===null||t===void 0?void 0:t.appId)!==null&&o!==void 0?o:""}),"")}case"tt":case"lark":{const e=h().tt;return c((()=>{var n,t,o;return(o=(t=(n=e===null||e===void 0?void 0:e.getEnvInfoSync)===null||n===void 0?void 0:n.call(e).microapp)===null||t===void 0?void 0:t.appId)!==null&&o!==void 0?o:""}),"")}case"bd":{const e=h().swan;return c((()=>{var n,t,o;return(o=(t=(n=e===null||e===void 0?void 0:e.getEnvInfoSync)===null||n===void 0?void 0:n.call(e).common)===null||t===void 0?void 0:t.appKey)!==null&&o!==void 0?o:""}),"")}default:return""}}function rr(){var e,n,t;const o=nr();if(!o)return"";const r=(t=(n=(e=o.os)===null||e===void 0?void 0:e.name)===null||n===void 0?void 0:n.toLowerCase())!==null&&t!==void 0?t:"";if(r.includes("android")){return c((()=>{var e,n,t,r,i;return(i=(r=(t=(n=(e=o.android)===null||e===void 0?void 0:e.runtimeMainActivity)===null||n===void 0?void 0:n.call(e))===null||t===void 0?void 0:t.getPackageName)===null||r===void 0?void 0:r.call(t))!==null&&i!==void 0?i:""}),"")}if(r==="ios"||r==="iphone os"){const e=c((()=>{var e,n;return(n=(e=o.ios)===null||e===void 0?void 0:e.bundleId)!==null&&n!==void 0?n:""}),"");return e||c((()=>{var e,n;return(n=(e=o.runtime)===null||e===void 0?void 0:e.appid)!==null&&n!==void 0?n:""}),"")}return c((()=>{var e,n;return(n=(e=o.runtime)===null||e===void 0?void 0:e.appid)!==null&&n!==void 0?n:""}),"")}function ir(){const e=nr();if(!e)return"";return c((()=>{var n,t;return(t=(n=e.runtime)===null||n===void 0?void 0:n.appname)!==null&&t!==void 0?t:""}),"")||c((()=>{var n,t;return(t=(n=e.runtime)===null||n===void 0?void 0:n.name)!==null&&t!==void 0?t:""}),"")}function ur(){var e;return(e=process.env.UNI_APP_NAME)!==null&&e!==void 0?e:""}function sr(){const e=ur();if(e)return e;return c((()=>{var e,n;return(n=(e=h().document)===null||e===void 0?void 0:e.title)!==null&&n!==void 0?n:""}),"")}function cr(){if(Zo)return Zo;const e=qe();let n="";let t="";let o="";let r="";if(Ve()){const e=tr();if(a()){t=e.appId||"";o=e.packageName||e.bundleId||e.bundleName||e.hostPackageName||"";r=e.appName||ur()}else{t=c((()=>{var e,n,t;return(t=(n=(e=nr())===null||e===void 0?void 0:e.runtime)===null||n===void 0?void 0:n.appid)!==null&&t!==void 0?t:""}),"")||e.appId||"";o=rr()||e.hostPackageName||t;r=ir()||e.appName||ur()}n=o||t}else if(He()){t=or(e);o="";r=ur();n=t||(typeof process.env.UNI_APP_ID==="string"?process.env.UNI_APP_ID:"")}else if(We()){t="";o="";r=sr();n=""}else{t="";o="";r=ur();n=""}Zo={mpn:n,tdaid:t,pkn:o,an:r};return Zo}const lr={domain:""};let fr=null;function ar(e){const n=typeof e.protocol==="string"?e.protocol.toLowerCase():"";if(n!=="http:"&&n!=="https:")return"";if(typeof e.origin==="string"&&e.origin.trim()){return e.origin.trim()}const t=typeof e.host==="string"&&e.host.trim()?e.host.trim():typeof e.hostname==="string"?e.hostname.trim():"";if(!t)return"";return`${n}//${t}`}function dr(){if(!We())return lr;if(fr!==null)return fr;fr=c((()=>{const e=h();const n=e.location;if(!n)return lr;return{domain:ar(n)}}),lr);return fr}const pr=new Map;const vr=new Map;function hr(e,n){var t;const o=(t=pr.get(e))!==null&&t!==void 0?t:new Set;o.add(n);pr.set(e,o);mr(e);return()=>{const t=pr.get(e);if(!t)return;t.delete(n);if(t.size===0){pr.delete(e);const n=vr.get(e);vr.delete(e);if(n){try{yr().removeInterceptor(e,n)}catch(e){}}}else{mr(e)}}}function gr(e){return{invoke(n){let t=false;for(const o of e){if(!o.invoke)continue;const e=o.invoke(n);if(e===false)t=true}return t?false:undefined},success(n){var t;for(const o of e)(t=o.success)===null||t===void 0?void 0:t.call(o,n)},fail(n){var t;for(const o of e)(t=o.fail)===null||t===void 0?void 0:t.call(o,n)},complete(n){var t;for(const o of e)(t=o.complete)===null||t===void 0?void 0:t.call(o,n)},returnValue(n){let t=n;for(const n of e){if(!n.returnValue)continue;t=n.returnValue(t)}return t}}}function mr(e){const n=pr.get(e);if(!n||n.size===0)return;const t=gr(n);try{const n=yr();const o=vr.get(e);if(o){try{n.removeInterceptor(e,o)}catch(e){}}n.addInterceptor(e,t);vr.set(e,t)}catch(e){}}function yr(){const e=y();const n=e!=null&&typeof e==="object"?e:undefined;if(!n)throw new Error("[uni统计 2.0] uni interceptor API is not available");return n}function br(){pr.clear();vr.clear()}const wr={add:hr,__reset:br};function Sr(n){return wr.add("login",{complete(){n.report({lt:e.Event,custom:{e_n:"login"}})}})}function kr(){return wr.add("setNavigationBarTitle",{invoke(e){const n=e;if(n&&"title"in n)_e(n.title)}})}function Ir(n){return wr.add("requestPayment",{success(){n.report({lt:e.Event,custom:{e_n:"pay_success"}})},fail(){n.report({lt:e.Event,custom:{e_n:"pay_fail"}})}})}function Tr(n){const t=()=>n.report({lt:e.Event,custom:{e_n:"share"}});return wr.add("share",{success(){t()},fail(){t()}})}function Ar(e){const n=[Sr(e),Tr(e),Ir(e),kr()];return()=>{for(const e of n){try{e()}catch(e){}}}}const Rr="migration:done";const Nr=[["__first__visit__time","visit:fvts"],["__last__visit__time","visit:lvts"],["__total__visit__count","visit:tvc"]];function Pr(){const e=process.env.UNI_APP_ID;if(typeof e==="string"&&e.length>0)return e;return"default"}function _r(){const e=y();if(!e||typeof e.getStorageSync!=="function")return null;const n=`${$}:${Pr()}`;const t=c((()=>e.getStorageSync(n)),null);if(t&&typeof t==="object")return t;return null}let jr=false;function Cr(){if(jr)return false;jr=true;const e=J.safeRead(Rr);if(e.ok&&e.value)return false;const n=_r();if(!n){J.set(Rr,1);return false}let t=0;for(let e=0;e<Nr.length;e++){const[o,r]=Nr[e];if(!(o in n))continue;const i=n[o];const u=J.safeRead(r);if(u.ok&&u.value!==undefined)continue;J.set(r,i);t++}J.set(Rr,1);if(t>0){C.info("[uni统计 2.0] migrated legacy keys",t)}return t>0}function Er(e){var n;const t=(n=e.version)!==null&&n!==void 0?n:"image";const o=e.fallbackToHttp!==false;if(t==="1"){if(e.http&&e.http.available())return e.http;return undefined}if(t==="2"){if(e.cloud&&e.cloud.available())return e.cloud;if(!o){C.warn("[uni统计 2.0] 云函数上报不可用且已关闭 HTTP 兜底,本批已丢弃");return undefined}if(e.http&&e.http.available()){C.warn("[uni统计 2.0] 云函数上报不可用,已降级为 HTTP 上报");return e.http}C.warn("[uni统计 2.0] 无可用上报线路");return undefined}if(e.image&&e.image.available())return e.image;if(!o){if(e.image){C.warn("[uni统计 2.0] 统计上报线路不可用且已关闭 HTTP 兜底,本批已丢弃")}return undefined}if(e.http&&e.http.available()){if(e.image){C.warn("[uni统计 2.0] 统计上报线路不可用,已降级为 HTTP 上报")}return e.http}C.warn("[uni统计 2.0] 无可用上报线路");return undefined}const $r={net:"unknown",raw:""};const Br={wifi:"wifi","2g":"2g","3g":"3g","4g":"4g","5g":"5g",ethernet:"ethernet",none:"none",unknown:"unknown"};function xr(){const e=y();return e!=null&&typeof e==="object"?e:undefined}function Mr(e){var n;if(typeof e!=="string"||e.length===0)return"unknown";return(n=Br[e.toLowerCase()])!==null&&n!==void 0?n:"unknown"}function Or(e=1500){return new Promise((n=>{const t=xr();if(!t||typeof t.getNetworkType!=="function"){n($r);return}let o=false;const r=e=>{if(o)return;o=true;n(e)};const i=setTimeout((()=>r($r)),e);c((()=>t.getNetworkType({success:e=>{var n;clearTimeout(i);const t=(n=e===null||e===void 0?void 0:e.networkType)!==null&&n!==void 0?n:"";r({net:Mr(t),raw:t})},fail:()=>{clearTimeout(i);r($r)}})),undefined)}))}function Ur(e){const n=xr();if(!n||typeof n.onNetworkStatusChange!=="function"){return()=>{}}const t=n=>{var t;const o=(t=n===null||n===void 0?void 0:n.networkType)!==null&&t!==void 0?t:"";const r=(n===null||n===void 0?void 0:n.isConnected)===false?"none":Mr(o);c((()=>e({net:r,raw:o})),undefined)};c((()=>n.onNetworkStatusChange(t)),undefined);return()=>{if(typeof n.offNetworkStatusChange==="function"){c((()=>n.offNetworkStatusChange(t)),undefined)}}}function Dr(e){return e.net==="none"}function Lr(){return r(this,void 0,void 0,(function*(){const e=yield Or();return Dr(e)}))}function qr(e){return Ur((n=>{if(Dr(n))return;e()}))}const Vr="queue";const Hr=Ut;const Wr={bucket:{},lastFlushAt:0};let Fr=_t;let Jr=Hr;let Gr=qt;let zr=false;let Kr=false;function Yr(e){if(typeof e.intervalSec==="number"&&e.intervalSec>=0){Fr=Math.floor(e.intervalSec)}if(typeof e.singleEventMaxBytes==="number"&&e.singleEventMaxBytes>0){Jr=Math.floor(e.singleEventMaxBytes)}if(typeof e.maxEvents==="number"&&e.maxEvents>0){Gr=Math.floor(e.maxEvents)}}function Qr(){let e=ri();if(e<=Gr){Kr=false;return}const n=e-Gr;while(e>Gr){let n="";let t=0;for(const e of Object.keys(Wr.bucket)){const o=Wr.bucket[e].length;if(o>t){t=o;n=e}}if(!n||t===0)break;Wr.bucket[n].shift();if(Wr.bucket[n].length===0)delete Wr.bucket[n];e--}if(!Kr){Kr=true;C.warn("[uni统计 2.0] 上报队列超过容量上限,已丢弃最旧事件","dropped="+n,"limit="+Gr)}}function Xr(){if(Object.keys(Wr.bucket).length===0){J.remove(Vr);return}try{J.set(Vr,Wr.bucket)}catch(e){C.warn("[uni统计 2.0] queue persist failed",e)}}function Zr(){if(zr)return;zr=true;const e=J.safeRead(Vr);if(!e.ok||!e.value||typeof e.value!=="object")return;const n=e.value;for(const e of Object.keys(n)){const t=n[e];if(!Array.isArray(t)||t.length===0)continue;if(!Wr.bucket[e])Wr.bucket[e]=[];Wr.bucket[e].push(...t)}}function ei(e){var n;if(!e||typeof e!=="object")return;const t=String((n=e.lt)!==null&&n!==void 0?n:"");if(!t){C.warn("[uni统计 2.0] enqueue dropped: missing lt",e);return}let o="";try{o=JSON.stringify(e)}catch(e){C.warn("[uni统计 2.0] enqueue dropped: stringify failed",e);return}if(o.length>Jr){C.warn("[uni统计 2.0] enqueue dropped: single event too large","lt="+t,"bytes="+o.length,"limit="+Jr);return}Zr();if(!Wr.bucket[t])Wr.bucket[t]=[];Wr.bucket[t].push(e);Qr();Xr()}function ni(e=false){if(e)return true;if(Fr<=0)return true;const n=(Be()-Wr.lastFlushAt)/1e3;return n>=Fr}function ti(){Zr();const e=Object.keys(Wr.bucket);if(e.length===0)return undefined;const n=Wr.bucket;Wr.bucket={};Wr.lastFlushAt=Be();J.remove(Vr);return n}function oi(e){if(!e)return;for(const n of Object.keys(e)){const t=e[n];if(!Array.isArray(t)||t.length===0)continue;if(!Wr.bucket[n])Wr.bucket[n]=[];Wr.bucket[n]=t.concat(Wr.bucket[n])}Qr();Xr()}function ri(){let e=0;for(const n of Object.keys(Wr.bucket)){e+=Wr.bucket[n].length}return e}const ii="retry:queue";const ui=50;const si=7*24*60*60*1e3;const ci=Vt;const li={maxItems:ui,maxAgeMs:si,maxAttempts:ci};function fi(){const e=J.safeRead(ii);if(!e.ok||!Array.isArray(e.value))return[];return e.value.filter((e=>e&&typeof e.id==="string"&&e.payload&&typeof e.payload==="object"))}function ai(e){if(e.length===0){J.remove(ii);return}J.set(ii,e)}function di(e){if(e._id)return e._id;return"r-"+Be().toString(36)+"-"+Math.random().toString(36).slice(2,6)}function pi(e){if(!e)return undefined;const n=di(e);const t=fi();if(t.some((e=>e.id===n))){return n}const o={id:n,payload:Object.assign({},e,{_id:n}),createdAt:Be(),attempts:0};t.push(o);while(t.length>li.maxItems){const e=t.shift();C.warn("[uni统计 2.0] retry queue overflow, drop oldest",e===null||e===void 0?void 0:e.id)}ai(t);return n}function vi(){const e=fi();if(e.length===0)return[];const n=Be()-li.maxAgeMs;const t=[];for(const o of e){if(o.createdAt<n){C.warn("[uni统计 2.0] retry item expired, drop",o.id);continue}t.push(o)}if(t.length!==e.length)ai(t);return t.map((e=>e.payload))}function hi(e){if(!e)return;const n=fi();const t=n.filter((n=>n.id!==e));if(t.length===n.length)return;ai(t)}function gi(e){if(!e)return;const n=fi();let t=null;for(let o=0;o<n.length;o++){const r=n[o];if(r.id!==e)continue;r.attempts++;if(r.attempts>=li.maxAttempts){C.warn("[uni统计 2.0] retry item exceeded maxAttempts, drop as dead letter",e,"attempts="+r.attempts);t=n.slice(0,o).concat(n.slice(o+1))}else{t=n}break}if(t)ai(t)}let mi=null;const yi=100;class bi{constructor(){this.installed=false;this.statVersion="image";this.deferredReports=[];this.deferReportsUntilSession=false;this.deferredReportsWarningShown=false}static getInstance(){if(!mi)mi=new bi;return mi}install(e={},n={}){var t,o,r,i,u;if(this.installed)return;const s=this.normalizeConfig(e);this.config=s;this.statVersion=s.version;this.deferReportsUntilSession=n.deferReportsUntilSession===true;c((()=>kn({backgroundTimeoutSec:s.backgroundTimeoutSec,pageInactiveTimeoutSec:s.pageInactiveTimeoutSec})),undefined);c((()=>Yr({intervalSec:s.reportIntervalSec})),undefined);if(!n.skipMigration){c((()=>Cr()),false)}c((()=>ue()),undefined);this.httpChannel=(o=(t=n.channels)===null||t===void 0?void 0:t.http)!==null&&o!==void 0?o:ko({ut:qe(),maxRetries:jt});if(n.channels&&"cloud"in n.channels){this.cloudChannel=(r=n.channels.cloud)!==null&&r!==void 0?r:undefined}else if(this.statVersion==="2"){this.cloudChannel=Gt({maxRetries:Ct})}else{this.cloudChannel=undefined}if(n.channels&&"image"in n.channels){this.imageChannel=(i=n.channels.image)!==null&&i!==void 0?i:undefined}else if(this.statVersion==="image"){this.imageChannel=Mo({host:Ht.host,projectId:Ht.projectId,topicId:Ht.topicId,maxRetries:Et,ut:qe(),rawPlatform:Le()})}else{this.imageChannel=undefined}this.collectorDeps=this.buildCollectorDeps(s,(u=n.collectorDepsPatch)!==null&&u!==void 0?u:{});this.collector=yo(this.collectorDeps);if(!n.skipInterceptors){this.uninstallInterceptors=c((()=>Ar({report:e=>this.reportInput(e)})),undefined)}if(!n.skipRecoverRetry){void this.collector.recoverRetry().catch((e=>C.warn("[uni统计 2.0] recoverRetry failed",e)))}this.uninstallNetworkWatch=c((()=>qr((()=>{const e=this.collector;if(!e)return;void e.recoverRetry().catch((e=>C.warn("[uni统计 2.0] recoverRetry on online failed",e)));void e.flush(true).catch((e=>C.warn("[uni统计 2.0] flush on online failed",e)))}))),undefined);this.installed=true}report(n,t){if(!this.installed||!this.collector)return;if(n==="title"){Ce(t);return}const o=typeof t==="object"&&t!==null?c((()=>JSON.stringify(t)),""):t===undefined?"":String(t);this.reportInput({lt:e.Event,custom:{e_n:n,e_v:o}})}reportError(n,t){var o;if(!this.installed||!this.collector)return;const r=n instanceof Error?`${n.name}: ${n.message}\n${(o=n.stack)!==null&&o!==void 0?o:""}`:typeof n==="string"?n:c((()=>JSON.stringify(n)),"");this.reportInput({lt:e.Error,errMsg:r,t:t})}reportInput(n){if(!this.collector)return;const t=n.lt===e.Event||n.lt===e.Error?Jn():undefined;const o=Object.assign({},t,n,n.t===undefined?{t:xe()}:undefined);if(this.deferReportsUntilSession){if(this.deferredReports.length>=yi){if(!this.deferredReportsWarningShown){this.deferredReportsWarningShown=true;C.warn("[vapor] 启动前事件暂存超过上限,后续事件已丢弃,请检查 uni.onBeforeAppRoute 是否可用","limit="+yi)}return}this.deferredReports.push(o);return}this.collector.report(o)}releaseDeferredReports(){if(!this.collector||!$n())return;this.deferReportsUntilSession=false;const e=this.deferredReports.splice(0);for(const n of e)this.collector.report(n)}getCollector(){return this.collector}getDeps(){return this.collectorDeps}isInstalled(){return this.installed}getStatVersion(){return this.statVersion}getConfig(){return this.config}uninstall(){if(this.uninstallInterceptors){c((()=>this.uninstallInterceptors()),undefined)}this.uninstallInterceptors=undefined;if(this.uninstallNetworkWatch){c((()=>this.uninstallNetworkWatch()),undefined)}this.uninstallNetworkWatch=undefined;if(this.collector){c((()=>this.collector.destroy()),undefined)}this.collector=undefined;this.collectorDeps=undefined;this.httpChannel=undefined;this.cloudChannel=undefined;this.imageChannel=undefined;this.config=undefined;this.deferredReports=[];this.deferReportsUntilSession=false;this.deferredReportsWarningShown=false;this.installed=false}resolveChannel(e){if(Ve()){return qo()}if(typeof e==="string"&&e.length>0){return e}return""}resolveFirstFlushDeferMs(){if(Le()==="mp-weixin"&&Bt){return Mt}if(Ve()&&!qo()){return Ot}return 0}normalizeConfig(e){var n,t,o,r;return{ak:(n=e.ak)!==null&&n!==void 0?n:Wt(),v:e.v,ch:this.resolveChannel(e.ch),version:(t=e.version)!==null&&t!==void 0?t:"image",backgroundTimeoutSec:(o=e.backgroundTimeoutSec)!==null&&o!==void 0?o:300,pageInactiveTimeoutSec:(r=e.pageInactiveTimeoutSec)!==null&&r!==void 0?r:1800,reportIntervalSec:typeof e.reportIntervalSec==="number"?e.reportIntervalSec:_t,enablePush:e.enablePush===true,enablePageLog:e.enablePageLog!==false}}buildCollectorDeps(e,n){const t=qe();const o=c((()=>Xo()),{lang:"",ww:0,wh:0,sw:0,sh:0,pr:1});const r=Do({config:{ak:e.ak,usv:Rt,v:e.v,get ch(){return Ve()?qo():e.ch}},platform:{ut:t},system:c((()=>Qo()),{brand:"",md:"",sv:"",v:"",ut:"unknown",appVersion:"",appWgtVersion:"",mpvHostVersion:"",on:"",sdkVersion:"",statusBarHeight:0,osP:""}),locale:o,resolveLocale:a()?()=>{const e=c((()=>Xo()),o);if(e.ww<=0)e.ww=e.sw;if(e.wh<=0)e.wh=e.sh;return e}:undefined,device:{get uuid(){return c((()=>rn()),"")}},net:{net:"unknown",raw:""},location:{lat:"",lng:"",ok:false},pkg:c((()=>cr()),{mpn:"",tdaid:"",pkn:"",an:""}),web:c((()=>dr()),{domain:""})});const i={builder:r,queue:{enqueue:ei,flush:ti,rollback:oi,shouldFlush:ni},serializer:{handleData:lo},selectChannel:()=>Er({version:this.statVersion,http:this.httpChannel,cloud:this.cloudChannel,image:this.imageChannel}),retry:{persist:pi,loadAll:vi,ack:hi,markAttempt:gi},visit:{commitVisitOnAck:ae,rollbackPendingVisit:de},session:{getSnapshot:$n,nextSeq:En,touch:Cn},config:{usv:Rt},resolveUploadFields:()=>{const e=qo();return e?{ch:e}:{}},nowMs:Be,nowSec:xe,firstFlushDeferMs:this.resolveFirstFlushDeferMs(),isNetworkOffline:Lr};return Object.assign(i,n)}}function wi(){return bi.getInstance()}function Si(){if(mi){mi.uninstall();mi=null}}function ki(){const e=process.env.UNI_STATISTICS_CONFIG;if(e==null)return undefined;if(typeof e==="object"&&!Array.isArray(e)){return e}if(typeof e!=="string")return undefined;const n=e.trim();if(!n||n==="undefined")return undefined;try{const e=JSON.parse(n);if(!e||typeof e!=="object"||Array.isArray(e))return undefined;return e}catch(e){return undefined}}function Ii(){try{const e=ki();if(!e)return undefined;const n={};if(e.channelVersion!=null){const t=String(e.channelVersion);if(t==="1"||t==="2"||t==="image")n.version=t}const t=Ri(e.backgroundTimeout,e.backgroundTimeoutSec);if(t!==undefined)n.backgroundTimeoutSec=t;const o=Ri(e.pageInactiveTimeout,e.pageInactiveTimeoutSec);if(o!==undefined)n.pageInactiveTimeoutSec=o;const r=Ni(e.reportInterval,e.reportIntervalSec);if(r!==undefined)n.reportIntervalSec=r;if(e.collectItems&&typeof e.collectItems==="object"){const t=e.collectItems;if(typeof t.uniPushClientID==="boolean"){n.enablePush=t.uniPushClientID}if(typeof t.uniStatPageLog==="boolean"){n.enablePageLog=t.uniStatPageLog}}return Object.keys(n).length>0?n:undefined}catch(e){C.warn("[uni统计 2.0] readManifestStatConfig failed",e);return undefined}}function Ti(e){if(typeof e==="number"){return e>0?e:undefined}if(typeof e==="string"){const n=e.trim();if(n==="")return undefined;const t=Number(n);if(Number.isFinite(t)&&t>0)return t}return undefined}function Ai(e){if(typeof e==="number"){return e>=0?e:undefined}if(typeof e==="string"){const n=e.trim();if(n==="")return undefined;const t=Number(n);if(Number.isFinite(t)&&t>=0)return t}return undefined}function Ri(...e){for(const n of e){const e=Ti(n);if(e!==undefined)return e}return undefined}function Ni(...e){for(const n of e){const e=Ai(n);if(e!==undefined)return e}return undefined}function Pi(){const e=y();return e!=null&&typeof e==="object"?e:undefined}const _i=20;const ji=50;let Ci=false;let Ei;let $i=false;let Bi;let xi;function Mi(e={}){if($i)return;$i=true;const n=Ii();const t=Object.assign({},n,e.config);const o=wi();c((()=>o.install(t,Object.assign({},e.overrides,{deferReportsUntilSession:e.vapor===true}))),undefined);c((()=>{var n,t,r;const i=o.getConfig();const u=process.env.UNI_APP_NAME||"";const s=ki();const c={channel:(n=i===null||i===void 0?void 0:i.version)!==null&&n!==void 0?n:"image",reportIntervalSec:(t=i===null||i===void 0?void 0:i.reportIntervalSec)!==null&&t!==void 0?t:0,ak:(r=i===null||i===void 0?void 0:i.ak)!==null&&r!==void 0?r:"",appName:u,debugFromManifest:process.env.UNI_STAT_DEBUG==="true"||process.env.UNI_STAT_DEBUG===true};if(s!=null){if(s.backgroundTimeout!=null||s.backgroundTimeoutSec!=null){c.backgroundTimeoutSec=i===null||i===void 0?void 0:i.backgroundTimeoutSec}if(s.pageInactiveTimeout!=null||s.pageInactiveTimeoutSec!=null){c.pageInactiveTimeoutSec=i===null||i===void 0?void 0:i.pageInactiveTimeoutSec}}
// #ifndef VUE3
Xt(Object.assign({},c,{vueMode:"Vue2"}));
// #endif
// #ifdef VUE3
Xt(Object.assign({},c,{vueMode:e.vapor?"Vapor":"Vue3"}));
// #endif
}),undefined);const r=()=>{var n,t;const r=o.getConfig();const i=Object.assign({},{enablePush:(n=r===null||r===void 0?void 0:r.enablePush)!==null&&n!==void 0?n:false,enablePageLog:(t=r===null||r===void 0?void 0:r.enablePageLog)!==null&&t!==void 0?t:true},e.lifecycle);const{mixin:u,unbind:s}=At(o,i);Bi=s;if(!e.skipVueMixin){c((()=>Di(u)),undefined)}if(!e.skipUniReport){c((()=>Vi(o)),undefined)}if(St()&&!It(o,i)){Oi((()=>It(o,i)))}};if(e.vapor){if(!e.skipUniReport){c((()=>Vi(o)),undefined)}}else{r()}}function Oi(e){if(xi){clearTimeout(xi);xi=undefined}let n=0;const t=()=>{if(e())return;if(++n>=_i){C.warn("[uni统计 2.0] Vue3 小程序:uni.onAppShow 暂不可用,应用前后台统计可能缺失");return}xi=setTimeout(t,ji)};xi=setTimeout(t,ji)}
// #ifdef VUE3
function Ui(e){try{uni.onCreateVueApp((n=>{c((()=>n.mixin(e)),undefined)}));return true}catch(e){}const n=Pi();if(n&&typeof n.onCreateVueApp==="function"){n.onCreateVueApp((n=>{c((()=>n.mixin(e)),undefined)}));return true}return false}
// #endif
function Di(e){if(Ci)return;
// #ifndef VUE3
if(qi(e)){Ci=true}
// #endif
// #ifdef VUE3
if(Ui(e)){Ci=true;return}Li(e);
// #endif
}
// #ifdef VUE3
function Li(e){if(Ci)return;if(Ei)return;let n=0;const t=()=>{Ei=undefined;if(Ci)return;if(Ui(e)){Ci=true;return}if(++n>=_i){if(!Ci){C.warn("[uni统计 2.0] Vue3: onCreateVueApp 在重试后仍不可用,页面级 mixin 未注入")}return}Ei=setTimeout(t,ji)};Ei=setTimeout(t,ji)}
// #endif
// #ifndef VUE3
function qi(e){var n;const t=require("vue");const o=(n=t.default)!==null&&n!==void 0?n:t;if(o&&typeof o.mixin==="function"){c((()=>o.mixin(e)),undefined);return true}C.warn("[uni统计 2.0] Vue2: vue.mixin 不可用,请检查是否已安装 vue 依赖");return false}
// #endif
function Vi(e){var n;const t=(n,t)=>{e.report(n,t)};c((()=>{if(typeof uni==="object"&&uni)uni.report=t}),undefined);const o=h();const r=(n=Pi())!==null&&n!==void 0?n:o.uni;if(!r||typeof r!=="object")return;r.report=t}function Hi(){if(xi){clearTimeout(xi);xi=undefined}if(Ei){clearTimeout(Ei);Ei=undefined}Ci=false;if(Bi)c((()=>Bi()),undefined);Bi=undefined;$i=false}const Wi="__UNI_STAT_VAPOR_BRIDGE__";const Fi=100;const Ji=100;const Gi=new Set(["appLaunch","navigateTo","navigateBack","redirectTo","reLaunch","switchTab"]);let zi;function Ki(){return{beforeRouteBound:false,routeBound:false,beforeRouteWarningShown:false,routeWarningShown:false,lifecycleWarningShown:false,lifecycleStarted:false}}function Yi(){const e=h();const n=e[Wi];if(n)return n;if(zi)return zi;const t=Ki();zi=t;try{Object.defineProperty(e,Wi,{configurable:true,value:t});return t}catch(e){return t}}function Qi(e){return Math.floor(e/1e3)}function Xi(e){return e.startsWith("/")?e.slice(1):e}function Zi(e){return Object.keys(e).map((n=>{var t;return[n,String((t=e[n])!==null&&t!==void 0?t:"")]}))}function eu(e,n){const t=encodeURIComponent(e);return n?encodeURIComponent(t):t}function nu(e){var n;if(e.notFound===true||!Gi.has(e.openType)||typeof e.path!=="string"||e.path.length===0){return}const t=Xi(e.path);const o=qe();const r=o==="h5";const i=r||o==="wx"?"/":"";const u=Zi((n=e.query)!==null&&n!==void 0?n:{});const s=u.map((([e,n])=>`${eu(e,r)}=${eu(n,r)}`)).join("&");const c=u.slice().sort((([e],[n])=>e<n?-1:e>n?1:0));const l=`${t}?${JSON.stringify(c)}`;return{path:t,fullPath:`${i}${t}${s?`?${s}`:""}`,key:l,timeMs:typeof e.timeStamp==="number"&&Number.isFinite(e.timeStamp)?e.timeStamp:Date.now()}}function tu(e){return{mpType:"page",route:e.path,$page:{route:e.path,fullPath:e.fullPath}}}function ou(e){var n,t;const o=e.getConfig();return{enablePush:(n=o===null||o===void 0?void 0:o.enablePush)!==null&&n!==void 0?n:false,enablePageLog:(t=o===null||o===void 0?void 0:o.enablePageLog)!==null&&t!==void 0?t:true}}function ru(e){const n=ou(e);const t=[];const o=new Set;const r=[];let i=false;let u=false;let s=false;let c;let l=false;let f;let a;const d=e=>{if(!e)return true;if(o.has(e))return false;o.add(e);r.push(e);if(r.length>Fi){o.delete(r.shift())}return true};const p=(t,o)=>{if(c&&!l)gt(e,tu(c));ht(e,tu(t),n,Qi(o));c=t;l=false};const v=n=>{if(l||!u||!c||!nu(n)){return}gt(e,tu(c));l=true};const h=(e,n)=>{if(!d(e.routeEventId))return;const t=nu(e);if(!t)return;if(!u){f=t;return}if(a){const e=!l&&a===t.key;a=undefined;if(e){c=t;l=false;return}}p(t,t.timeMs||n)};const g=(t,o)=>{var r;if(u)return;const i=s;const l=f!==null&&f!==void 0?f:c;pt(e,{scene:t.scene,path:(r=l===null||l===void 0?void 0:l.path)!==null&&r!==void 0?r:t.path},n,Qi(o),true);u=true;s=false;if(l&&(i||f)){p(l,o)}if(i&&l){a=l.key}f=undefined};const m=t=>{if(!u)return;if(c&&!l)gt(e,tu(c));vt(e,n,Qi(t));u=false;s=true;a=undefined;l=!!c};const y=n=>{if(n.type==="show")g(n.value,n.timeMs);else if(n.type==="hide")m(n.timeMs);else if(n.type==="error"){yt(e,n.value,Qi(n.timeMs),false)}else h(n.value,n.timeMs)};const b=e=>{if(!i){if(t.length<Ji)t.push(e);return}y(e)};return{launch(o,r){if(i)return;at(e,o,n,Qi(r));e.releaseDeferredReports();i=true;t.splice(0).forEach(y)},show(e,n){b({type:"show",value:e,timeMs:n})},hide(e){b({type:"hide",timeMs:e})},error(e,n){b({type:"error",value:e,timeMs:n})},beforeRoute(e){if(i)v(e)},route(e){b({type:"route",value:e,timeMs:typeof e.timeStamp==="number"?e.timeStamp:Date.now()})}}}function iu(e){const n=y();if(!e.beforeRouteBound){if(typeof(n===null||n===void 0?void 0:n.onBeforeAppRoute)!=="function"){if(!e.beforeRouteWarningShown){e.beforeRouteWarningShown=true;C.warn("[vapor] uni.onBeforeAppRoute 不可用,应用启动统计未启用")}}else{e.beforeRouteCallback=e=>{var t,o,r,i,u;const s=Yi();(t=s.sink)===null||t===void 0?void 0:t.beforeRoute(e);if(s.lifecycleStarted)return;s.lifecycleStarted=true;try{const e=(r=(o=n.getLaunchOptionsSync)===null||o===void 0?void 0:o.call(n))!==null&&r!==void 0?r:{};(i=s.sink)===null||i===void 0?void 0:i.launch(e,Date.now());(u=s.sink)===null||u===void 0?void 0:u.show(e,Date.now());onAppShow((e=>{var n;return(n=Yi().sink)===null||n===void 0?void 0:n.show(e!==null&&e!==void 0?e:{},Date.now())}));onAppHide((()=>{var e;return(e=Yi().sink)===null||e===void 0?void 0:e.hide(Date.now())}));onError((e=>{var n;return(n=Yi().sink)===null||n===void 0?void 0:n.error(e,Date.now())}))}catch(e){if(!s.lifecycleWarningShown){s.lifecycleWarningShown=true;C.warn("[vapor] 应用生命周期初始化失败,部分统计可能缺失",e)}}};try{n.onBeforeAppRoute(e.beforeRouteCallback);e.beforeRouteBound=true}catch(n){e.beforeRouteCallback=undefined;if(!e.beforeRouteWarningShown){e.beforeRouteWarningShown=true;C.warn("[vapor] uni.onBeforeAppRoute 注册失败,应用启动统计未启用",n)}}}}if(e.routeBound)return;if(!n||typeof n.onAppRoute!=="function"){if(!e.routeWarningShown){e.routeWarningShown=true;C.warn("[vapor] uni.onAppRoute 不可用,页面统计已停用")}return}e.routeCallback=e=>{var n;return(n=Yi().sink)===null||n===void 0?void 0:n.route(e)};try{n.onAppRoute(e.routeCallback);e.routeBound=true}catch(n){e.routeCallback=undefined;if(!e.routeWarningShown){e.routeWarningShown=true;C.warn("[vapor] uni.onAppRoute 注册失败,页面统计已停用",n)}}}const uu={install(){var e;const n=Yi();n.sink=(e=n.sink)!==null&&e!==void 0?e:ru(wi());iu(n)}};function su(){const e=Yi();const n=y();if(e.beforeRouteCallback&&typeof(n===null||n===void 0?void 0:n.offBeforeAppRoute)==="function"){c((()=>n.offBeforeAppRoute(e.beforeRouteCallback)),undefined)}if(e.routeCallback&&typeof(n===null||n===void 0?void 0:n.offAppRoute)==="function"){c((()=>n.offAppRoute(e.routeCallback)),undefined)}const t=h();c((()=>Reflect.deleteProperty(t,Wi)),false);zi=undefined}const cu=process.env.NODE_ENV!=="development"||process.env.UNI_STAT_DEBUG==="true"||process.env.UNI_STAT_DEBUG===true;if(cu){const e=process.env.UNI_STAT_VAPOR==="true";Mi({vapor:e});if(e)uu.install()}export{Hi as __resetInstall,Si as __resetStatApp,su as __resetVaporStat,wi as getStatApp,Mi as installPublicStat,uu as vaporStat};