gio-miniprogram-sdk 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/baidu.js CHANGED
@@ -1 +1 @@
1
- const e=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,t=e=>["undefined","null"].includes(T(e)),i=e=>"string"===T(e),n=e=>"number"===T(e),s=e=>"boolean"===T(e),r=e=>"[object Object]"==={}.toString.call(e)&&!t(e),o=e=>["function","asyncfunction"].includes(T(e)),a=e=>Array.isArray(e)&&"array"===T(e),l=e=>"date"===T(e),g=e=>{try{return Array.from(e)[0]}catch(e){return}},u=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},c=(e,t=1)=>a(e)&&n(t)?e.slice(t>0?t:1,e.length):e,d=(e,t=!1)=>{if(a(e)){let i=0;const n=[];for(const s of e)s&&!_(s)&&(n[i++]=s),t&&0===s&&(n[i++]=s);return n}return e},h=(e,t)=>{if(a(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},p=e=>t(e)?"":""+e,v=(e,t)=>"string"===T(e)?e.split(t):e,m=e=>{if(i(e)){const t=v(e,"");return`${g(t).toLowerCase()}${c(t).join("")}`}return e},f=(e,t)=>(i(e)||(e=p(e)),e.slice(0,t.length)===t),I={}.hasOwnProperty,S=(e,i)=>!t(e)&&I.call(e,i),y=e=>r(e)?Object.keys(e):[],O=(e,t)=>{y(e).forEach((i=>t(e[i],i)))},b=(e,t)=>{const i=y(e);return!(!r(e)||!r(t)||i.length!==y(t).length||i.map(((i,n)=>r(e[i])?b(e[i],t[i]):e[i]===t[i])).includes(!1))},w=(e,t,i)=>{let n=e;return r(e)?(t.split(".").forEach((e=>{n=n?n[e]:i})),n):i},P=(e,t)=>{if(!r(e))return!1;try{if("string"===T(t))return delete e[t];if("array"===T(t))return t.map((t=>delete e[t]));"object"===T(t)&&t.constructor===RegExp&&y(e).forEach((i=>{t.test(i)&&P(e,i)}))}catch(e){return!1}},k=(e,t=250,i,n)=>{let s,r=0;return"boolean"!==T(i)&&(n=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),e.apply(a,o)}n&&!s&&g(),s&&clearTimeout(s),void 0===n&&l>t?g():!0!==i&&(s=setTimeout(n?function(){s=void 0}:g,void 0===n?t-l:t))}},_=e=>a(e)?0===e.length:r(e)?0===y(e).length:!e,T=e=>({}.toString.call(e).slice(8,-1).toLowerCase()),E=e=>{function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())};var C=Object.freeze({__proto__:null,isNil:t,isString:i,isNaN:e=>"NaN"===p(Number(e)),isNumber:n,isBoolean:s,isObject:r,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:o,isArray:a,isDate:l,fixed:(e,t)=>n(e)?Number(e.toFixed(n(t)?t:2)):i(e)&&"NaN"!==p(Number(e))?Number(Number(e).toFixed(n(t)?t:2)):e,head:g,last:u,drop:c,dropWhile:(e,t)=>a(e)?e.filter((e=>!t(e))):e,compact:d,find:h,isEqualArray:(e,t)=>!(!a(e)||!a(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:p,split:v,lowerFirst:m,upperFirst:e=>{if(i(e)){const t=v(e,"");return`${g(t).toUpperCase()}${c(t).join("")}`}return e},startsWith:f,endsWith:(e,t)=>{const{length:i}=e;let n=i;n>i&&(n=i);const s=n;return n-=t.length,n>=0&&e.slice(n,s)===t},hasOwnProperty:I,has:S,keys:y,forEach:O,isEqual:b,get:w,unset:P,throttle:k,isEmpty:_,typeOf:T,formatDate:E});const A=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},x=(e,t=!0,i="参数不合法")=>A(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),j=e=>{try{return e()}catch(e){return}},q=(e,t)=>{if(o(e))try{e(t)}catch(e){A("回调执行失败!"+e,"error")}},N=e=>i(e)?e.trim().substring(0,100):e,U=(t,n)=>i(t)&&!_(t)&&t.match(e)?n():(A("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),D=e=>(t(e)||y(e).forEach((t=>{o(e[t])?e[t]=j((()=>e[t]())):r(e[t])?P(e,t):a(e[t])||(e[t]=p(e[t]))})),e),K=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),L=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,H=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,$=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},R=e=>{if(i(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},B=e=>i(e)?e.startsWith("/")?e:"/"+e:"",V=e=>j((()=>{switch(e){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let e;return e||(e=j((()=>swan))),e||(e=j((()=>my))),e||(e=j((()=>tt))),e||(e=j((()=>qq))),e||(e=j((()=>ks))),e||(e=j((()=>jd))),e||(e=j((()=>wx))),e}}})),F=e=>j((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return j((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),G=()=>{let e;return!e&&j((()=>swan))&&(e="swan"),!e&&j((()=>tt))&&(e="tt"),!e&&j((()=>qq))&&(e="qq"),!e&&j((()=>my.tb))&&(e="tb"),!e&&j((()=>my))&&(e="my"),!e&&j((()=>ks))&&(e="ks"),!e&&j((()=>jd))&&(e="jd"),!e&&j((()=>wx))&&(e="wx"),e||h(y(global),(e=>p(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},M=()=>{var e;return null!==(e=j((()=>{var e;return null!==(e=j((()=>{var e;return null!==(e=j((()=>$global)))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},Q=e=>{const i={};return r(e)&&(P(e,"&&sendTo"),O(e,((e,n)=>{const s=p(n).slice(0,100);r(e)?i[s]=Q(e):a(e)?(i[s]=d(e.slice(0,100),!0),i[s]=i[s].join("||").slice(0,1e3)):l(e)?i[s]=E(e):i[s]=t(e)?"":p(e).slice(0,1e3)}))),i},z=(e,t)=>{const i=()=>t.map((t=>e.getStorageSync(t)));try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):i()}catch(e){return i()}},W=(e,t)=>{const i=()=>t.map((({key:t,value:i})=>e.setStorageSync(t,i)));try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):i()}catch(e){return i()}},J=e=>y(e||{}).map((i=>i?`${i}=${t(e[i])?"":e[i]}`:"")).join("&"),Y=e=>{(f(e,"?")||f(e,"&"))&&(e=e.slice(1,e.length));const t={};return e.split("&").forEach((e=>{const i=e.split("=");i[0]&&(t[i[0]]=i[1])})),t},Z=(e={},t={})=>{const i={};return y(t).forEach((e=>{["string","number","boolean"].includes(T(t[e]))&&(i[e]=t[e])})),Object.assign({},i,e)};var X=Object.freeze({__proto__:null,consoleText:A,callError:x,niceTry:j,niceCallback:q,limitString:N,eventNameValidate:U,getDynamicAttributes:D,guid:K,getScreenHeight:L,getScreenWidth:H,getOS:$,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),n=e=>e.replace(/[vV]/g,""),s=i(n(e)),r=i(n(t)),o=s.split("."),a=r.split(".");for(let e=0;3>e;e++){let t=Number(o[e]),i=Number(a[e]);if(t>i)return 1;if(i>t)return-1;if(!isNaN(t)&&isNaN(i))return 1;if(isNaN(t)&&!isNaN(i))return-1}return 0},getVueVersion:e=>{if(e){const t=Number(g(v(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:R,normalPath:B,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:V,getPlainConfig:F,getPlainPlatform:G,getSubKeys:e=>y(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let e=j((()=>getApp({allowDefault:!0})));return e||(e=M()),e},getGlobal:M,limitObject:Q,batchGetStorageSync:z,batchSetStorageSync:W,qsStringify:J,qsParse:Y,hashCode:(e,t=!1)=>{let i=0;if(_(e)||"boolean"==typeof e)return i;let n=0;for(;n<e.length;)i=(i<<5)-i+e.charCodeAt(n),i|=0,n++;return t?Math.abs(i):i},getLaunchQuery:Z});const ee=e=>i(e)&&e.length>0||n(e)&&e>0,te={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},impressionScale:{type:"number",default:0},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:-1},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},ie=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],ne=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ie],se={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},re=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],oe=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ae=[...oe,"appChannel","language","platformVersion"],le={gsid:"_growing_gsid_",originalSource:"_gdp_original_source_",userId:"_growing_userId_",userKey:"_growing_userKey_",gioId:"_growing_gioId_",plugin_gsid:"_growing_plugin_gsid_",plugin_originalSource:"_gdp_plugin_original_source_",plugin_userId:"_growing_plugin_userId_",plugin_userKey:"_growing_plugin_userKey_",plugin_gioId:"_growing_plugin_gioId_"};var ge="MINIP_LIFECYCLE",ue="ON_COMMIT_REQUEST",ce="ON_COMPOSE_AFTER",de="ON_COMPOSE_BEFORE",he="ON_ERROR",pe="ON_INSTALL",ve="ON_SEND_AFTER",me="ON_SEND_BEFORE",fe="OPTION_CHANGE",Ie="OPTION_INITIALIZED",Se="SDK_INITIALIZED",ye="SESSIONID_UPDATE";class Oe{constructor(e){this.growingIO=e,this.main=(e,t,i=!0)=>{e||(e=this.growingIO.trackingId);const{sdkVersion:n,platformConfig:s,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:u}}=this.growingIO,{version:c,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(e),m=a.locationData[e],{systemInfo:f={},network:I={}}=r,{brand:S,model:y,platform:O,language:b}=f,w=g.getPagePath(),k={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:S,deviceId:o.getUid(),deviceModel:y,deviceType:$(O,s.name),domain:h,language:b,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:$(O,s.name),path:w,platform:s.platform,platformVersion:s.name+(f.version?" "+f.version:""),query:w?g.getPageQuery():"",screenHeight:L(f),screenWidth:H(f),sdkVersion:n,sessionId:o.getSessionId(e),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(e)};return p&&(k.userKey=o.getUserKey(e)),i&&!_(u[e])&&(k.attributes=Object.assign({},u[e])),_(k.attributes)||(k.attributes=Q(D(Object.assign({},k.attributes)))),_(v)||v.forEach((e=>{P(k,e)})),_(t)?Object.assign(Object.assign({},k),{trackingId:e}):Object.assign(Object.assign(Object.assign({},k),t),{trackingId:e})}}}function be(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class we{constructor(e){this.growingIO=e,this.enterParams={},this.main=(e,t)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:u,dataStore:{trackersExecute:c,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(ge,{event:"App "+e,timestamp:s,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,s);const m=l.listeners.app;switch(r.emit(de,{event:"App "+e,params:null!==(n=t[0])&&void 0!==n?n:{}}),e){case m.appLaunch:this.enterParams=Object.assign({},t[0]);break;case m.appCreate:case m.appShow:{const{path:e,query:i,referralPage:n}=this.enterParamsParse(t[0]);!d&&a.originalSource&&e&&c((t=>{v(t,{path:e,query:i,referralPage:n})})),h?(Date.now()-h>60*a.keepAlive*1e3||u.lastScene&&u.scene!==u.lastScene)&&c((e=>{o.setSessionId(e)})):c((t=>{u.lastVisitEvent[t]={path:e,query:i,referralPage:n},this.buildVisitEvent(t,{path:e,query:i,referralPage:n})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((e=>{this.buildCloseEvent(e),a.forceLogin||g.initiateRequest(e,!0)}))}},this.enterParamsParse=(e={})=>{var t;const{gioPlatform:i,minipInstance:n,dataStore:s}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&n.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:u}=n.minip.getEnterOptionsSync()||{};r=i||e.path,o=l||e.query,a=(null==u?void 0:u.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",s.scene=g||e.scene,o=_(null==u?void 0:u.extraData)?J(o):J(Z(o,u.extraData))}else{const{path:t,query:i,referrerInfo:n}=e;r=t,o=J(i),a=(null==n?void 0:n.appId)||"",this.parseScene(e)}return{path:r,query:o,referralPage:a}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else _(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:s.scene="NA");s.scene=r},this.buildVisitEvent=(e,t)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:n,eventInterceptor:s},vdsConfig:r}=this.growingIO,o=i(e),a=(null==t?void 0:t.query)||"";let l=Object.assign({eventType:"VISIT"},n(e,{}));!_(t)&&t.path&&(l.path=t.path||"",l.query="string"===T(a)?a:J(a),t.referralPage&&(l.referralPage=t.referralPage)),r.originalSource&&!_(o)&&(l=Object.assign(Object.assign({},l),o)),s(l)},this.buildCloseEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},t(e)))}}}class Pe{constructor(e){this.growingIO=e,this.lifeBeforeShow=!0,this.getPagePath=()=>{var e,t,i;const{minipInstance:n,inPlugin:s,dataStore:r,trackingId:o}=this.growingIO,a=n.getCurrentPath();if(s){const e=r.getTrackerVds(o);return a||"/插件"+e.appId}return a||(null===(e=r.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=r.lastPageEvent[o])||void 0===t?void 0:t.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQuery=()=>{var e,t,i,n,s,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),u=o.getCurrentPath(),{enterParams:c={}}=a.eventHooks.appEffects;if(!u)return c.path?this.qsQuery(Z(null==c?void 0:c.query,null===(i=null==c?void 0:c.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.path)?null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(e=g.options)&&void 0!==e?e:g.$taroParams;if(!_(i))return P(i,"$taroTimestamp"),this.qsQuery(i);if(!_(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(Z(null==c?void 0:c.query,null===(t=null==c?void 0:c.referrerInfo)||void 0===t?void 0:t.extraData))}},this.getPageTitle=e=>{const{minipInstance:t,inPlugin:i,dataStore:n}=this.growingIO,s=t.getCurrentPath(),r=this.configuredTitle[s]||t.getPageTitle(t.getCurrentPage());if(i){const t=n.getTrackerVds(e||this.growingIO.trackingId);return r||`/插件${t.appId}${s?"_"+u(s.split("/")):""}`}return r},this.qsQuery=(e={})=>{const t=Object.assign({},e);return P(t,"wxShoppingListScene"),J(t)},this.getReferralPage=e=>{var t,i,n;const{minipInstance:s,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(t=r[e])||void 0===t?void 0:t.path)||(null===(n=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===n?void 0:n.appId)||(o?`scn:${s.scnPrefix}${o}`:null)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=B(t+(i?"?"+i:"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=B(t+(i?"?"+i:"")),e.query=i,e},this.eventSetPageProps=(e,t)=>{const i=j((()=>this.pageProps[e][this.getPagePath()]));return _(i)?t.attributes:Q(D(Object.assign(Object.assign({},t.attributes),i)))},this.queryOption={},this.configuredTitle={},this.pageProps={}}buildShareQuery(e){var t,i;const n=R(null!==(t=e.path)&&void 0!==t?t:"");let s=this.getPagePath(),r={},o=S(e,"path");if(o&&(s=g(n),r=Y(u(n))||{}),_(r)&&(r=Y(null!==(i=e.query)&&void 0!==i?i:"")||{},d(y(r)).forEach((e=>{e.toLowerCase().startsWith("utm_")&&P(r,e)}))),!o&&_(r)){const e=this.growingIO.minipInstance.getCurrentPage();r=e.options||this.queryOption[e.route]||{}}return[s,J(r)]}}class ke{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var n,s;const r=Date.now(),{emitter:a,minipInstance:l,plugins:g,vdsConfig:u,platformConfig:c,dataStore:{getTrackerVds:d,getOriginalSource:h,setOriginalSource:p,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:S,buildAddFavorites:y}}=this.growingIO,{currentPage:O}=m;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=l.getCurrentPage()),e.route||(e.route=l.getCurrentPath(e));const b=e.route||e.uri||e.__route__||(null===(n=null==e?void 0:e.$page)||void 0===n?void 0:n.fullPath)||"";a.emit(ge,{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),u.debug&&console.log("Page:",b,"#",t,r),this.prevEvent[t]=Date.now();const k=c.listeners.page;switch(a.emit(de,{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t,t){case k.pageLoad:O.queryOption[b]=w(e,"options")||w(e,"__displayReporter.query")||w(e,"$page.query")||w(e,"$wx.__displayReporter.query")||w(e,"$taroParams")||i[0]||{},P(O.queryOption[b],"$taroTimestamp");break;case k.pageShow:v((e=>{const t=h(e);_(t)||t.path!==b||p(e,Object.assign(Object.assign({},t),{title:O.getPageTitle()}));const{trackPage:i}=d(e);i&&this.buildPageEvent(e)})),f(!1);break;case k.pageHide:case k.pageUnload:break;case k.shareApp:f(!0),v((e=>{const{followShare:t}=d(e);t&&I(e,i)}));break;case k.shareTime:v((e=>{const{followShare:t}=d(e);t&&S(e,i)}));break;case k.addFavorites:v((e=>{const{followShare:t}=d(e);t&&y(e,i)}));break;case k.tabTap:{const e=null===(s=null==g?void 0:g.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;u.autotrack&&e&&o(e)&&e(this.growingIO.trackingId,i[0]);break}}O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t+"End",["onHideEnd","onUnloadEnd"].includes(O.currentLifecycle)&&(O.lifeBeforeShow=!0),"onShowEnd"===O.currentLifecycle&&(O.lifeBeforeShow=!1)},this.buildPageEvent=(e,t)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:{currentPage:s}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:s.getReferralPage(e)},i(e));r.attributes=s.eventSetPageProps(e,r),!_(t)&&t.title&&(r.title=t.title),n(r)},this.prevEvent={}}}class _e{constructor(e){var t;this.growingIO=e,this.isNormalFc=(e,t)=>o(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),S(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),S(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),S(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{a(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{o(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...s){let r=t.apply(this,s);"onShareTimeline"===e&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][e].apply(this,o),r}:function(...s){var r;return be(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=t.apply(this,s))&&void 0!==r?r:{},"promise"===T(o)&&(o=yield o.then((e=>e))),"promise"===T(o.promise)){const e=function(){return be(this,void 0,void 0,(function*(){let e=o;return new Promise((t=>{let i=setTimeout((()=>{t(Object.assign({},e)),clearTimeout(i),i=void 0}),3e3);o.promise.then((n=>{e=n,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),P(o,"promise")}n.growingIO.vdsConfig.followShare&&(o=n.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(s);o&&a.push(o),n[`def${i}Cbs`][e].apply(this,a)}catch(e){A(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,s)),n.growingIO.emitter.emit(ge,{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...n){var s,r;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=n[0]||{};S(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=n[n.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(o(i.actionEffects)||(i.actionEffects=(null===(r=null===(s=i.growingIO.plugins)||void 0===s?void 0:s.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(t,e))}catch(e){A(e,"error")}return a=t.apply(this,n),a}},this.appApplyProxy=(e,t)=>this.appHandlers.includes(e)?this.lifeFcEffects(e,t,"App"):this.customFcEffects(e,t),this.pageApplyProxy=(e,t)=>this.pageHandlers.includes(e)?this.lifeFcEffects(e,t,"Page"):this.customFcEffects(e,t),this.appOverriding=e=>(this.setAppEffectCbs(),this.supLifeFcs(e,"app"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.appApplyProxy(e,t[e]))})),e),this.pageOverriding=e=>(this.setPageEffectCbs(),this.supLifeFcs(e,"page"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.componentOverriding=e=>(this.setPageEffectCbs(),e.methods||(e.methods={}),this.supLifeFcs(this.growingIO.inPlugin?e:e.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?e:e.methods,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.setAppEffectCbs=()=>{const e=this;this.appHandlers.forEach((t=>{this.defAppCbs[t]=function(...i){e.appEffects.main(t,i)}}))},this.setPageEffectCbs=()=>{const e=this;this.pageHandlers.forEach((t=>{this.defPageCbs[t]=function(...i){e.pageEffects.main(this,t,i)}}))},this.growingApp=e=>o(this.originalApp)?this.originalApp(this.appOverriding(e)):this.appOverriding(e),this.growingPage=e=>o(this.originalPage)?this.originalPage(this.pageOverriding(e)):this.pageOverriding(e),this.growingComponent=e=>o(this.originalComponent)?this.originalComponent(this.componentOverriding(e)):this.componentOverriding(e),this.growingBehavior=e=>o(this.originalBehavior)?this.originalBehavior(this.componentOverriding(e)):this.componentOverriding(e),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(e.includes("App"))try{n.App&&!this.appHooked&&(App=function(...e){return t.originalApp(t.appOverriding(e[0]))},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!this.pageHooked&&(Page=function(...e){return t.originalPage(t.pageOverriding(e[0]))},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!this.componentHooked&&(Component=function(...e){return t.originalComponent(t.componentOverriding(e[0]))},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.originalBehavior(t.componentOverriding(e[0]))},this.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=j((()=>App||global.App)),this.originalPage=j((()=>Page||global.Page)),this.originalComponent=j((()=>Component||global.Component)),this.originalBehavior=j((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;this.initOriginalValue(),t.canHook?(this.nativeGrowing(),M().GioApp=j((()=>null!==App&&void 0!==App?App:this.originalApp)),M().GioPage=j((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),M().GioComponent=j((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),M().GioBehavior=j((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(M().GioApp=function(...t){return e.appOverriding(t[0])},M().GioPage=function(...t){return e.pageOverriding(t[0])},M().GioComponent=function(...t){return e.pageOverriding(t[0])})};const i=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new we(this.growingIO),this.pageEffects=new ke(this.growingIO),this.currentPage=new Pe(this.growingIO)}}class Te{constructor(e){var t,n;this.growingIO=e,this.ALLOW_SETTING_KEYS=y(te),this.getStorageKey=(e,t)=>{const{inPlugin:i}=this.growingIO;return`${e===this.growingIO.trackingId?"":e}${le[i?"plugin_"+t:t]}`},this.getGsid=e=>{let t=Number(this._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(this.setGsid(e,1),1):t},this.setGsid=(e,t)=>{let i=Number(t);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[e]=i,10>this._gsid[e]-this._stid[e]||this.saveStorageInfo()},this.initStorageInfo=e=>{const{minipInstance:t}=this.growingIO,i=t.getStorageSync(this.getStorageKey(e,"gsid"));let n=Number(i);(Number.isNaN(n)||n>=1e9||1>n)&&(n=1),this._gsid[e]=n,this._stid[e]=n,n!==i&&t.setStorageSync(this.getStorageKey(e,"gsid"),n)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=Object.assign({},this._gsid),W(e,this.initializedTrackingIds.map((e=>({key:this.getStorageKey(e,"gsid"),value:this._gsid[e]}))))},this.setOriginalSource=(e,t)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=e=>{var t;const{minipInstance:i}=this.growingIO;return null!==(t=j((()=>JSON.parse(i.getStorageSync(this.getStorageKey(e,"originalSource"))))))&&void 0!==t?t:{}},this.getTrackerVds=e=>this.growingIO.trackingId===e?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=e=>{const t=this.initOptions(e);return t.trackingId=e.trackingId,this.growingIO.trackingId=e.trackingId,this.growingIO.vdsConfig=t,t},this.initTrackerHooker=e=>{var t,i;const{platformConfig:n,inPlugin:s,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=e;a||l||"quickapp"===r.platform||(n.canHook=!0),!s||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(t=null==o?void 0:o.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=e=>{var t,i,n,s,r,o;const{projectId:l,dataSourceId:g,appId:u,trackingId:c}=e,d={};return this.ALLOW_SETTING_KEYS.forEach((t=>{const i=te[t].type;(a(i)?i.includes(T(e[t])):T(e[t])===te[t].type)?"ignoreFields"===t?d.ignoreFields=e.ignoreFields.filter((e=>oe.includes(e))):"extraParams"===t?d.extraParams=e.extraParams.filter((e=>ae.includes(e))):(d[t]=e[t],["dataCollect","autotrack"].includes(t)&&!d[t]&&A("已关闭"+se[t],"info")):d[t]=te[t].default})),d.uploadInterval=Math.round(d.uploadInterval),(Number.isNaN(d.uploadInterval)||0>d.uploadInterval||d.uploadInterval>3e3)&&(d.uploadInterval=1e3),d.enableIdMapping&&!d.idMapping&&(d.idMapping=!0,d.idMapping||this.growingIO.userStore.setUserKey(c,"")),P(d,"enableIdMapping"),d.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(d.requestTimeout))&&d.requestTimeout>0||(d.requestTimeout=5e3),(0>d.impressionScale||d.impressionScale>1)&&(d.impressionScale=0),(0>d.keepAlive||d.keepAlive>1440)&&(d.keepAlive=5),(1>d.sessionExpires||d.sessionExpires>1440)&&(d.sessionExpires=-1),Object.assign(Object.assign({},d),{projectId:l,dataSourceId:g,appId:u,trackingId:c,performance:{monitor:null===(i=null===(t=d.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(s=null===(n=d.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(o=null===(r=d.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(e,t,n)=>{var s;const{userStore:r,emitter:o}=this.growingIO,a=this.getTrackerVds(e),l=i(t)&&this.ALLOW_SETTING_KEYS.includes(t),g=l&&typeof n===(null===(s=te[t])||void 0===s?void 0:s.type);if(l&&g){const i=Object.assign({},a);return this.updateVdsConfig(e,Object.assign(Object.assign({},a),{[t]:n})),"dataCollect"===t&&i.dataCollect!==n&&n&&r.setSessionId(e),o.emit(fe,{optionName:t,optionValue:n}),!0}return x("setOption > "+t),!1},this.getOption=(e,t)=>{const i=this.getTrackerVds(e);return t&&S(this.growingIO.vdsConfig,t)?S(i,t)?i[t]:this.growingIO.vdsConfig[t]:_(t)?i:void x("getOption > "+t)},this.updateVdsConfig=(e,t)=>{e===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),t),M().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[e]=Object.assign(Object.assign({},this.growingIO.subInstance[e]),t),M().vdsConfig.subInstance[e]=this.growingIO.subInstance[e])},this.toggleShareOut=e=>{s(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=(e,t)=>{this.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=(e,t)=>{this.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=e=>{const{dataStore:t,uploader:i}=this.growingIO,{dataCollect:n}=this.getTrackerVds(e.trackingId);if(n){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=t.getGsid(e.trackingId),t.setGsid(e.trackingId,e.eventSequenceId+1));const n={};O(e,((e,t)=>{var i;if("element"===t){const t=null!==(i=g(e))&&void 0!==i?i:{};O(t,((e,t)=>{_(e)&&0!==e||(n[t]=e)}))}else _(e)&&0!==e||(n[t]=e)})),this.growingIO.emitter.emit(ce,{composedEvent:n}),i.commitRequest(Object.assign(Object.assign({},n),{requestId:K()}))}},this.eventRefactor=e=>{var t,i;const n=Object.assign(Object.assign({},e),this.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return n.attributes=Object.assign(Object.assign({},null!==(t=n.attributes)&&void 0!==t?t:{}),null!==(i=e.attributes)&&void 0!==i?i:{}),n},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;_(t)||_(i)?this.interceptEvents.push(e):_(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!_(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.buildAppMessageEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(e));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$from:s.from,$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:g(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(u)},this.buildTimelineEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(e));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:g(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(u)},this.buildAddFavorites=(e,t)=>{var i;const n=t[0];let s;2>t.length?1===t.length&&(s=n):s=t[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==s?void 0:s.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(e));l.attributes=Q(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==s?void 0:s.title,$share_path:g(a),$share_query:a[1]})),o(l)},this.trackersExecute=e=>{this.initializedTrackingIds.forEach((t=>{"function"===T(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Oe(this.growingIO).main,this.eventHooks=new _e(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:r,minipInstance:l}=this.growingIO;r.on(Se,(({trackingId:e})=>{this.initializedTrackingIds.push(e),this.initStorageInfo(e)})),r.on(ue,(({eventData:e,trackingId:t})=>{"VISIT"===e.eventType&&(this.lastVisitEvent[t]=e),"PAGE"===e.eventType&&(this.lastPageEvent[t]=e)})),o(null===(t=l.minip)||void 0===t?void 0:t.onAppHide)&&l.minip.onAppHide((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];O(t,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),o(null===(n=l.minip)||void 0===n?void 0:n.onAppShow)&&l.minip.onAppShow((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];O(t,(e=>{e.start&&(e.start=+Date.now())}))}))})),r.on(fe,(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.trackersExecute((e=>{this.growingIO.clearTrackTimer(e)}))})),this.growingIO.emitter.on(ye,(({oldSessionId:e,trackingId:t})=>{if(e){const{getPagePath:e,getPageQuery:i}=this.eventHooks.currentPage,n=e(),s=i();if(n)this.sendVisit(t,{path:n,query:s});else{const e=this.lastPageEvent[t];this.sendVisit(t,{path:e.path,query:e.query})}this.eventHooks.currentPage.lifeBeforeShow||this.sendPage(t)}}))}get scene(){return this._scene}set scene(e){const t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})}}const Ee={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},Ce=Object.assign(Object.assign({},Ee),{listeners:Object.assign({},Ee.listeners),name:"Baidu",platform:"baidup",scnPrefix:"baidup_"});class Ae{constructor(e){this.growingIO=e,this.minip=V("swan"),this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBarTitle,i=this;t&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return t.apply(this,arguments)}})},this.navigateTo=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateTo(e)},this.switchTab=e=>{var t;null===(t=this.minip)||void 0===t||t.switchTab(e)},this.navigateToMiniProgram=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateToMiniProgram(e)},this.getImageInfo=({src:e,success:t,fail:i,complete:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:e,success:t,fail:i,complete:n})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"observeAll")},this.getCurrentPage=()=>j((()=>u(getCurrentPages())))||{},this.getCurrentPath=()=>{const e=this.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=e=>{var t;const n=G();let s="",r=F(n);"string"===T(r)&&(r=null!==(t=j((()=>JSON.parse(r))))&&void 0!==t?t:{});const o=(null==e?void 0:e.data)||e.$data||{};if(s=i(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",r){const{enterParams:t}=this.growingIO.dataStore.eventHooks.appEffects;e.route||_(t)||(e.route=t.path||"",s=this._getTitleFromTabBar(r,e.route)),j((()=>{var t,i,o,a,l,g;if(!s){const u=r.page||{},c=u[e.route]||u[e.route+".html"];s=c?null===(t=null==c?void 0:c.window)||void 0===t?void 0:t.navigationBarTitleText:["wx","tt"].includes(n)?null===(a=null===(o=null===(i=r||global||$global)||void 0===i?void 0:i.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=r||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),s||(s=this._getTitleFromTabBar(r,e.route))}return N(s)},this._getTitleFromTabBar=(e,t)=>{var i,n;const s=null===(n=null===(i=null==e?void 0:e.tabBar)||void 0===i?void 0:i.list)||void 0===n?void 0:n.find((e=>e.pagePath===t||e.pagePath===t+".html"));return(null==s?void 0:s.text)||""},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return r(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=e=>new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:e,success:({data:e})=>t(e),fail:()=>t("")})})),this.setStorageSync=(e,t,i)=>{var n;i&&(t={value:t,expiredAt:i}),null===(n=this.minip)||void 0===n||n.setStorageSync(e,t)},this.setStorage=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync(e)},this.removeStorage=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorage(e)},this.getNetworkType=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))},this.request=({url:e,data:t,header:i,timeout:n,method:s,success:r,fail:a,complete:l})=>{var g;const u=null===(g=this.minip)||void 0===g?void 0:g.request({url:e,data:t,header:i,headers:i,timeout:n,method:s,success:r,fail:a,complete:l});let c=setTimeout((()=>{(null==u?void 0:u.abort)&&o(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(c),c=null}),(n||1e4)+10);return u},this.getSystemInfo=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{e.systemInfo=i,t(i)},fail:()=>t(null)})}))},this.getSetting=()=>new Promise((e=>{var t;null===(t=this.minip)||void 0===t||t.getSetting({success:e,fail:e})}));const{platformConfig:{platform:t,scnPrefix:n}}=this.growingIO;this.platform=t,this.scnPrefix=n,this.growingIO.emitter.on(Ie,(()=>{this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))}}class xe extends Ae{constructor(e){super(e),this.growingIO=e,this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"selectAll")},this.hookSetTitle()}}const je=["gioPerformance"];class qe{constructor(e){var t,i,n,s,r,a;this.growingIO=e,this.innerPluginInit=()=>{var e;je.forEach((e=>{var t;return P(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins,e)})),y(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins).forEach((e=>{var t,i;const{name:n,method:s}=null!==(i=null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==i?i:{};h(this.pluginItems,(e=>e.name===n))||this.pluginItems.push({name:m(n||e),method:s||(e=>{})})})),_(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var n,s;const{emitter:r}=this.growingIO,o=t||h(this.pluginItems,(t=>t.name===e));if((null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[e])return A(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return A(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return(null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[e]=new o.method(this.growingIO,i),t&&(r.emit(pe,e),A("加载插件 "+e,"info")),!0}catch(i){return this.lifeError(t,i),A(`插件【${e}】加载异常 ${i}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>{this.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!h(this.pluginItems,(e=>e.name===t.name))&&this.pluginItems.push({name:m(t.name),method:t.method?t.method:()=>{}})}))},this.uninstall=e=>{var t;P(this.pluginItems,e);const i=P(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||A(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>{this.growingIO.emitter.emit(he,{plugin:e,error:t}),A(`插件执行错误 ${e.name} ${t}`,"error")},this.callLifeCycle=(e,t)=>{this.pluginItems.forEach((i=>{const n=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][e]:void 0;if(n&&o(n))try{n(t)}catch(e){this.lifeError(i,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(pe,(e=>this.callLifeCycle("onInstall",e))),null===(i=this.growingIO.emitter)||void 0===i||i.on(he,(e=>this.callLifeCycle("onError",e))),null===(n=this.growingIO.emitter)||void 0===n||n.on(de,(e=>this.callLifeCycle("onComposeBefore",e))),null===(s=this.growingIO.emitter)||void 0===s||s.on(ce,(e=>this.callLifeCycle("onComposeAfter",e))),null===(r=this.growingIO.emitter)||void 0===r||r.on(me,(e=>this.callLifeCycle("onSendBefore",e))),null===(a=this.growingIO.emitter)||void 0===a||a.on(ve,(e=>this.callLifeCycle("onSendAfter",e)))}}var Ne={},Ue={}.hasOwnProperty;function De(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Ke(e){try{return encodeURIComponent(e)}catch(e){return null}}Ne.stringify=function(e,t){t=t||"";var i,n,s=[];for(n in"string"!=typeof t&&(t="?"),e)if(Ue.call(e,n)){if((i=e[n])||null!=i&&!isNaN(i)||(i=""),n=Ke(n),i=Ke(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?t+s.join("&"):""},Ne.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,n={};t=i.exec(e);){var s=De(t[1]),r=De(t[2]);null===s||null===r||s in n||(n[s]=r)}return n};class Le{constructor(e){this.growingIO=e,this.generateURL=e=>{const{serverUrl:t,projectId:i}=this.growingIO.dataStore.getTrackerVds(e);return f(t,"http")?`${t}/v3/projects/${i}/collect`:`https://${t}/v3/projects/${i}/collect`},this.getHoardingQueue=e=>{var t;return null!==(t=this.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=e=>{var t;return null!==(t=this.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=e=>{var i,n;const s=Object.assign({},e),{vdsConfig:r,emitter:o}=this.growingIO;o.emit(ue,{eventData:e,trackingId:e.trackingId}),r.forceLogin?(t(this.hoardingQueue[e.trackingId])&&(this.hoardingQueue[e.trackingId]=[]),null===(i=this.hoardingQueue[e.trackingId])||void 0===i||i.push(s)):(t(this.requestQueue[e.trackingId])&&(this.requestQueue[e.trackingId]=[]),null===(n=this.requestQueue[e.trackingId])||void 0===n||n.push(s),this.initiateRequest(e.trackingId))},this.initiateRequest=(e,t)=>{const{plugins:i,vdsConfig:n,minipInstance:s,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(e),...this.getRequestQueue(e)],a=e=>{var a,l;if(null===(a=null==n?void 0:n.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(e);else if(t)this.batchInvoke(e);else{const{uploadInterval:t}=this.growingIO.dataStore.getTrackerVds(e);k(this.batchInvoke,t,!1,!1)(e)}o.some((e=>"VISIT"===e.eventType))&&s.removeStorageSync(r.getStorageKey(e,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(e);else{let t=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(e),clearInterval(t),t=void 0)}),500)}},this.batchInvoke=e=>{const{vdsConfig:t,emitter:i}=this.growingIO,n=this.getHoardingQueue(e),s=this.getRequestQueue(e);let r=[...n,...s];r.length>50?(r=r.slice(0,50),n.length>50?this.hoardingQueue[e]=n.slice(50):(this.requestQueue[e]=s.slice(50-n.length),this.hoardingQueue[e]=[])):(this.hoardingQueue[e]=[],this.requestQueue[e]=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(_(o))return;const a=o.map((e=>{const t=Object.assign({},e);return P(t,["requestId","trackingId"]),t}));t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(me,{eventsQueue:o,requestData:a,trackingId:e})},this.sendEvent=(e,t)=>{var i;const n=g(e).trackingId,{minipInstance:s,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:u}=r.getTrackerVds(n);this.requestingNum+=1;const c={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let d=[...t];const h=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);h&&(d=a.gioCompress.compressToUTF16(JSON.stringify(t)),c["X-Compress-Codec"]="1");const p=this.generateURL(n);s.request({url:`${p}?stm=${Date.now()}&compress=${h?"1":"0"}`,header:c,method:"POST",data:d,timeout:u,fail:t=>{[200,204].includes(t.code)||(e.forEach((e=>{this.requestFailFn(e)})),A("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,o.emit(ve,{result:e,requestData:t}),this.initiateRequest(n)}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue[e.trackingId].some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{_(this.requestQueue[e.trackingId])?(this.requestQueue[e.trackingId].push(e),this.initiateRequest(e.trackingId)):this.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:i,vdsConfig:n,plugins:s}=this.growingIO;i.on(me,(({eventsQueue:e,requestData:t,trackingId:i})=>{var r,o;i===this.growingIO.trackingId&&((null===(r=null==n?void 0:n.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(e,t):this.sendEvent(e,t))}))}}class He{constructor(e){this.growingIO=e,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:e}=this.growingIO;return this._uid||(this._uid=e.getStorageSync(this._getUidKey())),this._uid||(this._uid=K(),e.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=e=>{const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))},this.getSessionId=e=>{const{vdsConfig:{sessionExpires:t},dataStore:{trackersExecute:i}}=this.growingIO;return this._sessionId[e]||this.setSessionId(e),t>-1&&(Date.now()>this._sessionExpires&&i((e=>{this.setSessionId(e)})),this._sessionExpires=Date.now()+6e4*t),this._sessionId[e]},this.setSessionId=(e,t)=>{const i=this._sessionId[e];t||(t=K()),this._sessionId[e]=t;const{sessionExpires:n}=this.growingIO.vdsConfig;n>-1&&(this._sessionExpires=Date.now()+6e4*n),i!==t&&this.growingIO.emitter.emit(ye,{trackingId:e,newSessionId:t,oldSessionId:i})},this._getUserIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"userId"),this.getUserId=e=>{const{minipInstance:t}=this.growingIO;return this._userId[e]||(this._userId[e]=t.getStorageSync(this._getUserIdKey(e))),this._userId[e]},this.setUserId=(e,i)=>{const n=this._userId[e];this._userId[e]=t(i)?"":i,n!==this._userId[e]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(e),this._userId[e]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:i,oldUserId:n})),i&&this.setGioId(e,i)},this._getUserKeyKey=e=>this.growingIO.dataStore.getStorageKey(e,"userKey"),this.getUserKey=e=>{const{minipInstance:t}=this.growingIO;return this._userKey[e]||(this._userKey[e]=t.getStorageSync(this._getUserKeyKey(e))),this._userKey[e]},this.setUserKey=(e,i)=>{const n=this._userKey[e];this._userKey[e]=t(i)?"":i,n!==this._userKey[e]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(e),this._userKey[e]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:i,oldUserKey:n}))},this._getGioIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"gioId"),this.getGioId=e=>{const{minipInstance:t}=this.growingIO;return this._gioId[e]||(this._gioId[e]=t.getStorageSync(this._getGioIdKey(e))),this._gioId[e]},this.setGioId=(e,i)=>{const n=this._gioId[e];this._gioId[e]=t(i)?"":i,n!==this._gioId[e]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(e),this._gioId[e]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:i,oldGioId:n}))},this.initUserInfo=e=>{var t;const{minipInstance:i}=this.growingIO,n=[this._getUidKey(),this._getUserIdKey(e),this._getUserKeyKey(e),this._getGioIdKey(e)],s=null!==(t=z(i,n))&&void 0!==t?t:[];["_uid","_userId","_userKey","_gioId"].forEach(((t,i)=>{"_uid"===t?this.getUid():this[t][e]=s[i]}))},this.saveUserInfo=()=>{const{minipInstance:e,dataStore:{trackersExecute:t}}=this.growingIO;t((t=>{W(e,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(t),value:this._userId[t]},{key:this._getUserKeyKey(t),value:this._userKey[t]},{key:this._getGioIdKey(t),value:this._gioId[t]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={},this._sessionExpires=-1}}const $e=new class{constructor(){var e;this.init=e=>{var t;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(A("Gio小程序SDK 初始化中...","info"),e.trackingId&&this.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error(`已存在实例 ${e.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(e);return null===(t=this.emitter)||void 0===t||t.emit(Ie,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(e.trackingId),this.emitter.emit(Se,i),this.trackingId&&this.trackingId!==e.trackingId||(M().__gio__=()=>this),A("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&A("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return A(e,"error"),!1}},this.handlerDistribute=(e,t,i)=>{const{initializedTrackingIds:n,getTrackerVds:s}=this.dataStore;if(s(e)&&n.includes(e))return this[t](e,...i);A(`不存在实例:${e},请检查!`,"warn")},this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(e,t)=>this.dataStore.getOption(e,t),this.setOption=(e,t,i)=>{var n;return y(se).includes(t)?typeof i===(null===(n=te[t])||void 0===n?void 0:n.type)?(this.dataStore.setOption(e,t,i),A(`已修改${se[t]}: ${i}`,"info"),!0):(A(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(A(`不存在可修改的配置项:${t},请检查后重试!`,"error"),!1)},this.setPageAttributes=(e,t)=>{if(r(t)&&!_(t)){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();return _(i.pageProps[e])&&(i.pageProps[e]={}),_(i.pageProps[e][n])&&(i.pageProps[e][n]={}),_(t)||O(t,((t,s)=>{o(i.pageProps[e][n][s])&&!o(t)||(i.pageProps[e][n][s]=t)})),!0}return x("setPageAttributes"),!1},this.clearPageAttributes=(e,t)=>{try{if(!_(this.dataStore.eventHooks.currentPage.pageProps[e])){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();a(t)&&!_(t)?t.forEach((t=>{P(i.pageProps[e][n],t)})):i.pageProps[e][n]={}}}catch(e){return x("clearPageAttributes"),!1}},this.sendPage=(e,t)=>{const{trackPage:i}=this.dataStore.getTrackerVds(e);i?A("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(e,t)},this.identify=(e,t)=>{if(e===this.trackingId)if(this.vdsConfig.forceLogin){if(!ee(t))return void x("identify");const e=p(t).slice(0,1e3);this.userStore.setUid(e),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((t=>{const i=this.uploader.getHoardingQueue(t);i.forEach(((t,n)=>i[n].deviceId=e)),this.uploader.initiateRequest(t,!0)}))}else x("identify",!1,"forceLogin未开启");else x("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(e,t)=>{var i,n,s,o;if(r(t)&&!_(t)){const{eventContextBuilder:r,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},r(e));g.attributes=Q(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),D(t))),g.path||(g.path=null===(n=l[e])||void 0===n?void 0:n.path,g.query=null===(s=l[e])||void 0===s?void 0:s.query,g.title=null===(o=l[e])||void 0===o?void 0:o.title),a(g)}else x("setUserAttributes")},this.setUserId=(e,i,n)=>{if(ee(i)){const s=this.userStore.getGioId(e);i=p(i).slice(0,1e3),n=p(n).slice(0,1e3),this.userStore.setUserId(e,i);const{idMapping:r}=this.dataStore.getTrackerVds(e);r&&this.userStore.setUserKey(e,t(n)?"":n),s&&s!==i&&this.userStore.setSessionId(e)}else x("setUserId")},this.clearUserId=e=>{this.userStore.setUserId(e,void 0),this.userStore.setUserKey(e,void 0)},this.setGeneralProps=(e,t)=>r(t)&&!_(t)?(_(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]={}),O(t,((t,i)=>{o(this.dataStore.generalProps[e][i])&&!o(t)||(this.dataStore.generalProps[e][i]=t)})),!0):(x("setGeneralProps"),!1),this.clearGeneralProps=(e,t)=>{try{_(this.dataStore.generalProps[e])||(a(t)&&!_(t)?t.forEach((t=>{P(this.dataStore.generalProps[e],t)})):this.dataStore.generalProps[e]={})}catch(e){return x("clearGeneralProps"),!1}},this.track=(e,t,i)=>{U(t,(()=>{var n;const{eventContextBuilder:s,eventInterceptor:o}=this.dataStore,a=Object.assign({eventType:"CUSTOM",eventName:t},s(e));a.attributes=Q(Object.assign(Object.assign({},null!==(n=a.attributes)&&void 0!==n?n:{}),D(Object.assign({},r(i)&&!_(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(a["&&sendTo"]=i["&&sendTo"]),o(a)}))},this.trackTimerStart=(e,t)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(e);return i?U(t,(()=>{const i=K();return this.dataStore.trackTimers[e]||(this.dataStore.trackTimers[e]={}),this.dataStore.trackTimers[e][i]={eventName:t,leng:0,start:+Date.now()},i})):(A("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return e.start&&(e.leng=e.leng+(+Date.now()-e.start)),e.start=0,!0}return!1},this.trackTimerResume=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return 0===e.start&&(e.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t,i)=>{var n;const{dataCollect:s}=this.dataStore.getTrackerVds(e),o=this.dataStore.trackTimers[e];if(t&&o&&o[t]){if(s){const s=864e5,a=o[t];if(0!==a.start){const e=+Date.now()-a.start;a.leng=e>0?a.leng+e:0}const{eventContextBuilder:l,eventInterceptor:g}=this.dataStore,u=Object.assign({eventType:"CUSTOM",eventName:a.eventName},l(e));return u.attributes=Q(Object.assign(Object.assign({},null!==(n=u.attributes)&&void 0!==n?n:{}),D(Object.assign(Object.assign({},r(i)&&!_(i)?i:{}),{event_duration:a.leng>s?0:a.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(u["&&sendTo"]=i["&&sendTo"]),g(u),!0}return A("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return A("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(e,t)=>{const i=this.dataStore.trackTimers[e];return t&&i&&i[t]?(delete i[t],!0):(A("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=e=>{this.dataStore.trackTimers[e]={}},this.setLocation=(e,t,i)=>{_(this.dataStore.locationData[e])&&(this.dataStore.locationData[e]={});const n=this.dataStore.locationData[e],s=e=>e>=-180&&180>=e;s(t)&&s(i)&&(n.latitude!==t||n.longitude!==i)&&(this.dataStore.locationData[e]={latitude:t,longitude:i})},this.updateImpression=()=>{A("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(e,t,i)=>{A("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),q(i,{})},this.getGioInfo=e=>{const{getUid:t,getUserId:i,getUserKey:n,getSessionId:s}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(e),d={gioappid:o,giocs1:i(e)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:s(e),giou:t()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=n(e)),_(u)||u.forEach((t=>{var i;c.includes(t)||(d["gio"+t]=(null!==(i=this.dataStore.lastVisitEvent[e])&&void 0!==i?i:{})[t])})),Ne.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},C),X),{qs:Ne}),this.emitter={all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map((function(e){e(i)})),(n=e.get("*"))&&n.slice().map((function(e){e(t,i)}))}},this.gioPlatform="swan",this.gioFramework="native",this.sdkVersion="4.3.1";try{"quickapp"===this.gioPlatform||o(getApp)&&o(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&A("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Ce,this.minipInstance=new xe(this),this.dataStore=new Te(this),this.userStore=new He(this),this.uploader=new Le(this),this.plugins=new qe(this),this.plugins.innerPluginInit()}},Re=function(){var e;const t=arguments[0];let n="g0",s=t;if(t.indexOf(".")>-1&&(n=null!==(e=t.split(".")[0])&&void 0!==e?e:"g0",s=t.split(".")[1]),i(s)&&ne.includes(s)&&$e[s]){const e=c(Array.from(arguments));if("init"===s){const t=((e,t)=>{const i=p(t[0]),n=p(t[1]),s=(4===t.length?t[3]:t[2])||{};return i&&n?e.dataStore.initializedTrackingIds.some(((t,s)=>{const r=0===s?e.vdsConfig:e.subInstance[t];return r.projectId===i&&r.dataSourceId===n}))?(A("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:n,appId:p(4===t.length?t[2]:""),userOptions:s}:(A('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})($e,e);if(t){const{projectId:e,dataSourceId:i,appId:s,userOptions:r}=t;return $e.init(Object.assign(Object.assign({},r),{projectId:e,dataSourceId:i,appId:s,trackingId:n}))}return!1}if("registerPlugins"===s)$e.registerPlugins(e[0]);else{if($e.gioSDKInitialized&&$e.vdsConfig)return ie.includes(s)?j((()=>$e.handlerDistribute(n,s,e))):j((()=>$e[s](...e)));A("SDK未初始化!","error")}}else if(re.includes(s))A(`方法 ${p(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return ne.includes(arguments[1])&&!!$e[arguments[1]];A(`不存在名为 ${p(s)} 的方法调用!`,"error")}};M().gdp=Re,M().gioSDKVersion=$e.sdkVersion;const{growingApp:Be,growingPage:Ve,growingComponent:Fe,growingBehavior:Ge,initOriginalValue:Me}=$e.dataStore.eventHooks;Me();const Qe=j((()=>null!=Be?Be:App)),ze=j((()=>null!=Ve?Ve:Page)),We=j((()=>null!=Fe?Fe:Component)),Je=j((()=>null!=Ge?Ge:Behavior));export{Qe as GioApp,Je as GioBehavior,We as GioComponent,ze as GioPage,Re as default};
1
+ const e=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,t=e=>["undefined","null"].includes(T(e)),i=e=>"string"===T(e),n=e=>"number"===T(e),s=e=>"boolean"===T(e),r=e=>"[object Object]"==={}.toString.call(e)&&!t(e),o=e=>["function","asyncfunction"].includes(T(e)),a=e=>Array.isArray(e)&&"array"===T(e),l=e=>"date"===T(e),g=e=>{try{return Array.from(e)[0]}catch(e){return}},u=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},c=(e,t=1)=>a(e)&&n(t)?e.slice(t>0?t:1,e.length):e,d=(e,t=!1)=>{if(a(e)){let i=0;const n=[];for(const s of e)s&&!_(s)&&(n[i++]=s),t&&0===s&&(n[i++]=s);return n}return e},h=(e,t)=>{if(a(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},p=e=>t(e)?"":""+e,v=(e,t)=>"string"===T(e)?e.split(t):e,m=e=>{if(i(e)){const t=v(e,"");return`${g(t).toLowerCase()}${c(t).join("")}`}return e},f=(e,t)=>(i(e)||(e=p(e)),e.slice(0,t.length)===t),I={}.hasOwnProperty,S=(e,i)=>!t(e)&&I.call(e,i),y=e=>r(e)?Object.keys(e):[],O=(e,t)=>{y(e).forEach((i=>t(e[i],i)))},b=(e,t)=>{const i=y(e);return!(!r(e)||!r(t)||i.length!==y(t).length||i.map(((i,n)=>r(e[i])?b(e[i],t[i]):e[i]===t[i])).includes(!1))},w=(e,t,i)=>{let n=e;return r(e)?(t.split(".").forEach((e=>{n=n?n[e]:i})),n):i},P=(e,t)=>{if(!r(e))return!1;try{if("string"===T(t))return delete e[t];if("array"===T(t))return t.map((t=>delete e[t]));"object"===T(t)&&t.constructor===RegExp&&y(e).forEach((i=>{t.test(i)&&P(e,i)}))}catch(e){return!1}},k=(e,t=250,i,n)=>{let s,r=0;return"boolean"!==T(i)&&(n=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),e.apply(a,o)}n&&!s&&g(),s&&clearTimeout(s),void 0===n&&l>t?g():!0!==i&&(s=setTimeout(n?function(){s=void 0}:g,void 0===n?t-l:t))}},_=e=>a(e)?0===e.length:r(e)?0===y(e).length:!e,T=e=>({}.toString.call(e).slice(8,-1).toLowerCase()),E=e=>{function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())};var C=Object.freeze({__proto__:null,isNil:t,isString:i,isNaN:e=>"NaN"===p(Number(e)),isNumber:n,isBoolean:s,isObject:r,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:o,isArray:a,isDate:l,fixed:(e,t)=>n(e)?Number(e.toFixed(n(t)?t:2)):i(e)&&"NaN"!==p(Number(e))?Number(Number(e).toFixed(n(t)?t:2)):e,head:g,last:u,drop:c,dropWhile:(e,t)=>a(e)?e.filter((e=>!t(e))):e,compact:d,find:h,isEqualArray:(e,t)=>!(!a(e)||!a(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:p,split:v,lowerFirst:m,upperFirst:e=>{if(i(e)){const t=v(e,"");return`${g(t).toUpperCase()}${c(t).join("")}`}return e},startsWith:f,endsWith:(e,t)=>{const{length:i}=e;let n=i;n>i&&(n=i);const s=n;return n-=t.length,n>=0&&e.slice(n,s)===t},hasOwnProperty:I,has:S,keys:y,forEach:O,isEqual:b,get:w,unset:P,throttle:k,isEmpty:_,typeOf:T,formatDate:E});const A=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},x=(e,t=!0,i="参数不合法")=>A(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),j=e=>{try{return e()}catch(e){return}},q=(e,t)=>{if(o(e))try{e(t)}catch(e){A("回调执行失败!"+e,"error")}},N=e=>i(e)?e.trim().substring(0,100):e,U=(t,n)=>i(t)&&!_(t)&&t.match(e)?n():(A("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),D=e=>(t(e)||y(e).forEach((t=>{o(e[t])?e[t]=j((()=>e[t]())):r(e[t])?P(e,t):a(e[t])||(e[t]=p(e[t]))})),e),K=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),L=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,H=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,$=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},R=e=>{if(i(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},B=e=>i(e)?e.startsWith("/")?e:"/"+e:"",V=e=>j((()=>{switch(e){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let e;return e||(e=j((()=>swan))),e||(e=j((()=>my))),e||(e=j((()=>tt))),e||(e=j((()=>qq))),e||(e=j((()=>ks))),e||(e=j((()=>jd))),e||(e=j((()=>wx))),e}}})),F=e=>j((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return j((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),G=()=>{let e;return!e&&j((()=>swan))&&(e="swan"),!e&&j((()=>tt))&&(e="tt"),!e&&j((()=>qq))&&(e="qq"),!e&&j((()=>my.tb))&&(e="tb"),!e&&j((()=>my))&&(e="my"),!e&&j((()=>ks))&&(e="ks"),!e&&j((()=>jd))&&(e="jd"),!e&&j((()=>wx))&&(e="wx"),e||h(y(global),(e=>p(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},M=()=>{var e;return null!==(e=j((()=>{var e;return null!==(e=j((()=>{var e;return null!==(e=j((()=>$global)))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},Q=e=>{const i={};return r(e)&&(P(e,"&&sendTo"),O(e,((e,n)=>{const s=p(n).slice(0,100);r(e)?i[s]=Q(e):a(e)?(i[s]=d(e.slice(0,100),!0),i[s]=i[s].join("||").slice(0,1e3)):l(e)?i[s]=E(e):i[s]=t(e)?"":p(e).slice(0,1e3)}))),i},z=(e,t)=>{const i=()=>t.map((t=>e.getStorageSync(t)));try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):i()}catch(e){return i()}},W=(e,t)=>{const i=()=>t.map((({key:t,value:i})=>e.setStorageSync(t,i)));try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):i()}catch(e){return i()}},J=e=>y(e||{}).map((i=>i?`${i}=${t(e[i])?"":e[i]}`:"")).join("&"),Y=e=>{(f(e,"?")||f(e,"&"))&&(e=e.slice(1,e.length));const t={};return e.split("&").forEach((e=>{const i=e.split("=");i[0]&&(t[i[0]]=i[1])})),t},Z=(e={},t={})=>{const i={};return y(t).forEach((e=>{["string","number","boolean"].includes(T(t[e]))&&(i[e]=t[e])})),Object.assign({},i,e)};var X=Object.freeze({__proto__:null,consoleText:A,callError:x,niceTry:j,niceCallback:q,limitString:N,eventNameValidate:U,getDynamicAttributes:D,guid:K,getScreenHeight:L,getScreenWidth:H,getOS:$,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),n=e=>e.replace(/[vV]/g,""),s=i(n(e)),r=i(n(t)),o=s.split("."),a=r.split(".");for(let e=0;3>e;e++){let t=Number(o[e]),i=Number(a[e]);if(t>i)return 1;if(i>t)return-1;if(!isNaN(t)&&isNaN(i))return 1;if(isNaN(t)&&!isNaN(i))return-1}return 0},getVueVersion:e=>{if(e){const t=Number(g(v(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:R,normalPath:B,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:V,getPlainConfig:F,getPlainPlatform:G,getSubKeys:e=>y(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let e=j((()=>getApp({allowDefault:!0})));return e||(e=M()),e},getGlobal:M,limitObject:Q,batchGetStorageSync:z,batchSetStorageSync:W,qsStringify:J,qsParse:Y,hashCode:(e,t=!1)=>{let i=0;if(_(e)||"boolean"==typeof e)return i;let n=0;for(;n<e.length;)i=(i<<5)-i+e.charCodeAt(n),i|=0,n++;return t?Math.abs(i):i},getLaunchQuery:Z});const ee=e=>i(e)&&e.length>0||n(e)&&e>0,te={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},impressionScale:{type:"number",default:0},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:-1},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},ie=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],ne=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ie],se={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},re=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],oe=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ae=[...oe,"appChannel","language","platformVersion"],le={gsid:"_growing_gsid_",originalSource:"_gdp_original_source_",userId:"_growing_userId_",userKey:"_growing_userKey_",gioId:"_growing_gioId_",plugin_gsid:"_growing_plugin_gsid_",plugin_originalSource:"_gdp_plugin_original_source_",plugin_userId:"_growing_plugin_userId_",plugin_userKey:"_growing_plugin_userKey_",plugin_gioId:"_growing_plugin_gioId_"};var ge="MINIP_LIFECYCLE",ue="ON_COMMIT_REQUEST",ce="ON_COMPOSE_AFTER",de="ON_COMPOSE_BEFORE",he="ON_ERROR",pe="ON_INSTALL",ve="ON_SEND_AFTER",me="ON_SEND_BEFORE",fe="OPTION_CHANGE",Ie="OPTION_INITIALIZED",Se="SDK_INITIALIZED",ye="SESSIONID_UPDATE";class Oe{constructor(e){this.growingIO=e,this.main=(e,t,i=!0)=>{e||(e=this.growingIO.trackingId);const{sdkVersion:n,platformConfig:s,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:u}}=this.growingIO,{version:c,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(e),m=a.locationData[e],{systemInfo:f={},network:I={}}=r,{brand:S,model:y,platform:O,language:b}=f,w=g.getPagePath(),k={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:S,deviceId:o.getUid(),deviceModel:y,deviceType:$(O,s.name),domain:h,language:b,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:$(O,s.name),path:w,platform:s.platform,platformVersion:s.name+(f.version?" "+f.version:""),query:w?g.getPageQuery():"",screenHeight:L(f),screenWidth:H(f),sdkVersion:n,sessionId:o.getSessionId(e),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(e)};return p&&(k.userKey=o.getUserKey(e)),i&&!_(u[e])&&(k.attributes=Object.assign({},u[e])),_(k.attributes)||(k.attributes=Q(D(Object.assign({},k.attributes)))),_(v)||v.forEach((e=>{P(k,e)})),_(t)?Object.assign(Object.assign({},k),{trackingId:e}):Object.assign(Object.assign(Object.assign({},k),t),{trackingId:e})}}}function be(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class we{constructor(e){this.growingIO=e,this.enterParams={},this.main=(e,t)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:u,dataStore:{trackersExecute:c,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(ge,{event:"App "+e,timestamp:s,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,s);const m=l.listeners.app;switch(r.emit(de,{event:"App "+e,params:null!==(n=t[0])&&void 0!==n?n:{}}),e){case m.appLaunch:this.enterParams=Object.assign({},t[0]);break;case m.appCreate:case m.appShow:{const{path:e,query:i,referralPage:n}=this.enterParamsParse(t[0]);!d&&a.originalSource&&e&&c((t=>{v(t,{path:e,query:i,referralPage:n})})),h?(Date.now()-h>60*a.keepAlive*1e3||u.lastScene&&u.scene!==u.lastScene)&&c((e=>{o.setSessionId(e)})):c((t=>{u.lastVisitEvent[t]={path:e,query:i,referralPage:n},this.buildVisitEvent(t,{path:e,query:i,referralPage:n})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((e=>{this.buildCloseEvent(e),a.forceLogin||g.initiateRequest(e,!0)}))}},this.enterParamsParse=(e={})=>{var t;const{gioPlatform:i,minipInstance:n,dataStore:s}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&n.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:u}=n.minip.getEnterOptionsSync()||{};r=i||e.path,o=l||e.query,a=(null==u?void 0:u.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",s.scene=g||e.scene,o=_(null==u?void 0:u.extraData)?J(o):J(Z(o,u.extraData))}else{const{path:t,query:i,referrerInfo:n}=e;r=t,o=J(i),a=(null==n?void 0:n.appId)||"",this.parseScene(e)}return{path:r,query:o,referralPage:a}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else _(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:s.scene="NA");s.scene=r},this.buildVisitEvent=(e,t)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:n,eventInterceptor:s},vdsConfig:r}=this.growingIO,o=i(e),a=(null==t?void 0:t.query)||"";let l=Object.assign({eventType:"VISIT"},n(e,{}));!_(t)&&t.path&&(l.path=t.path||"",l.query="string"===T(a)?a:J(a),t.referralPage&&(l.referralPage=t.referralPage)),r.originalSource&&!_(o)&&(l=Object.assign(Object.assign({},l),o)),s(l)},this.buildCloseEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},t(e)))}}}class Pe{constructor(e){this.growingIO=e,this.lifeBeforeShow=!0,this.getPagePath=()=>{var e,t,i;const{minipInstance:n,inPlugin:s,dataStore:r,trackingId:o}=this.growingIO,a=n.getCurrentPath();if(s){const e=r.getTrackerVds(o);return a||"/插件"+e.appId}return a||(null===(e=r.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=r.lastPageEvent[o])||void 0===t?void 0:t.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQuery=()=>{var e,t,i,n,s,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),u=o.getCurrentPath(),{enterParams:c={}}=a.eventHooks.appEffects;if(!u)return c.path?this.qsQuery(Z(null==c?void 0:c.query,null===(i=null==c?void 0:c.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.path)?null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(e=g.options)&&void 0!==e?e:g.$taroParams;if(!_(i))return P(i,"$taroTimestamp"),this.qsQuery(i);if(!_(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(Z(null==c?void 0:c.query,null===(t=null==c?void 0:c.referrerInfo)||void 0===t?void 0:t.extraData))}},this.getPageTitle=e=>{const{minipInstance:t,inPlugin:i,dataStore:n}=this.growingIO,s=t.getCurrentPath(),r=this.configuredTitle[s]||t.getPageTitle(t.getCurrentPage());if(i){const t=n.getTrackerVds(e||this.growingIO.trackingId);return r||`/插件${t.appId}${s?"_"+u(s.split("/")):""}`}return r},this.qsQuery=(e={})=>{const t=Object.assign({},e);return P(t,"wxShoppingListScene"),J(t)},this.getReferralPage=e=>{var t,i,n;const{minipInstance:s,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(t=r[e])||void 0===t?void 0:t.path)||(null===(n=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===n?void 0:n.appId)||(o?`scn:${s.scnPrefix}${o}`:null)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=B(t+(i?"?"+i:"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=B(t+(i?"?"+i:"")),e.query=i,e},this.eventSetPageProps=(e,t)=>{const i=j((()=>this.pageProps[e][this.getPagePath()]));return _(i)?t.attributes:Q(D(Object.assign(Object.assign({},t.attributes),i)))},this.queryOption={},this.configuredTitle={},this.pageProps={}}buildShareQuery(e){var t,i;const n=R(null!==(t=e.path)&&void 0!==t?t:"");let s=this.getPagePath(),r={},o=S(e,"path");if(o&&(s=g(n),r=Y(u(n))||{}),_(r)&&(r=Y(null!==(i=e.query)&&void 0!==i?i:"")||{},d(y(r)).forEach((e=>{e.toLowerCase().startsWith("utm_")&&P(r,e)}))),!o&&_(r)){const e=this.growingIO.minipInstance.getCurrentPage();r=e.options||this.queryOption[e.route]||{}}return[s,J(r)]}}class ke{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var n,s;const r=Date.now(),{emitter:a,minipInstance:l,plugins:g,vdsConfig:u,platformConfig:c,dataStore:{getTrackerVds:d,getOriginalSource:h,setOriginalSource:p,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:S,buildAddFavorites:y}}=this.growingIO,{currentPage:O}=m;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=l.getCurrentPage()),e.route||(e.route=l.getCurrentPath(e));const b=e.route||e.uri||e.__route__||(null===(n=null==e?void 0:e.$page)||void 0===n?void 0:n.fullPath)||"";a.emit(ge,{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),u.debug&&console.log("Page:",b,"#",t,r),this.prevEvent[t]=Date.now();const k=c.listeners.page;switch(a.emit(de,{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t,t){case k.pageLoad:O.queryOption[b]=w(e,"options")||w(e,"__displayReporter.query")||w(e,"$page.query")||w(e,"$wx.__displayReporter.query")||w(e,"$taroParams")||i[0]||{},P(O.queryOption[b],"$taroTimestamp");break;case k.pageShow:v((e=>{const t=h(e);_(t)||t.path!==b||p(e,Object.assign(Object.assign({},t),{title:O.getPageTitle()}));const{trackPage:i}=d(e);i&&this.buildPageEvent(e)})),f(!1);break;case k.pageHide:case k.pageUnload:break;case k.shareApp:f(!0),v((e=>{const{followShare:t}=d(e);t&&I(e,i)}));break;case k.shareTime:v((e=>{const{followShare:t}=d(e);t&&S(e,i)}));break;case k.addFavorites:v((e=>{const{followShare:t}=d(e);t&&y(e,i)}));break;case k.tabTap:{const e=null===(s=null==g?void 0:g.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;u.autotrack&&e&&o(e)&&e(this.growingIO.trackingId,i[0]);break}}O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t+"End",["onHideEnd","onUnloadEnd"].includes(O.currentLifecycle)&&(O.lifeBeforeShow=!0),"onShowEnd"===O.currentLifecycle&&(O.lifeBeforeShow=!1)},this.buildPageEvent=(e,t)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:{currentPage:s}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:s.getReferralPage(e)},i(e));r.attributes=s.eventSetPageProps(e,r),!_(t)&&t.title&&(r.title=t.title),n(r)},this.prevEvent={}}}class _e{constructor(e){var t;this.growingIO=e,this.isNormalFc=(e,t)=>o(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),S(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),S(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),S(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{a(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{o(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...s){let r=t.apply(this,s);"onShareTimeline"===e&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][e].apply(this,o),r}:function(...s){var r;return be(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=t.apply(this,s))&&void 0!==r?r:{},"promise"===T(o)&&(o=yield o.then((e=>e))),"promise"===T(o.promise)){const e=function(){return be(this,void 0,void 0,(function*(){let e=o;return new Promise((t=>{let i=setTimeout((()=>{t(Object.assign({},e)),clearTimeout(i),i=void 0}),3e3);o.promise.then((n=>{e=n,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),P(o,"promise")}n.growingIO.vdsConfig.followShare&&(o=n.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(s);o&&a.push(o),n[`def${i}Cbs`][e].apply(this,a)}catch(e){A(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,s)),n.growingIO.emitter.emit(ge,{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...n){var s,r;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=n[0]||{};S(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=n[n.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(o(i.actionEffects)||(i.actionEffects=(null===(r=null===(s=i.growingIO.plugins)||void 0===s?void 0:s.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(t,e))}catch(e){A(e,"error")}return a=t.apply(this,n),a}},this.appApplyProxy=(e,t)=>this.appHandlers.includes(e)?this.lifeFcEffects(e,t,"App"):this.customFcEffects(e,t),this.pageApplyProxy=(e,t)=>this.pageHandlers.includes(e)?this.lifeFcEffects(e,t,"Page"):this.customFcEffects(e,t),this.appOverriding=e=>(this.setAppEffectCbs(),this.supLifeFcs(e,"app"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.appApplyProxy(e,t[e]))})),e),this.pageOverriding=e=>(this.setPageEffectCbs(),this.supLifeFcs(e,"page"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.componentOverriding=e=>(this.setPageEffectCbs(),e.methods||(e.methods={}),this.supLifeFcs(this.growingIO.inPlugin?e:e.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?e:e.methods,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.setAppEffectCbs=()=>{const e=this;this.appHandlers.forEach((t=>{this.defAppCbs[t]=function(...i){e.appEffects.main(t,i)}}))},this.setPageEffectCbs=()=>{const e=this;this.pageHandlers.forEach((t=>{this.defPageCbs[t]=function(...i){e.pageEffects.main(this,t,i)}}))},this.growingApp=e=>o(this.originalApp)?this.originalApp(this.appOverriding(e)):this.appOverriding(e),this.growingPage=e=>o(this.originalPage)?this.originalPage(this.pageOverriding(e)):this.pageOverriding(e),this.growingComponent=e=>o(this.originalComponent)?this.originalComponent(this.componentOverriding(e)):this.componentOverriding(e),this.growingBehavior=e=>o(this.originalBehavior)?this.originalBehavior(this.componentOverriding(e)):this.componentOverriding(e),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(e.includes("App"))try{n.App&&!this.appHooked&&(App=function(...e){return t.originalApp(t.appOverriding(e[0]))},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!this.pageHooked&&(Page=function(...e){return t.originalPage(t.pageOverriding(e[0]))},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!this.componentHooked&&(Component=function(...e){return t.originalComponent(t.componentOverriding(e[0]))},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.originalBehavior(t.componentOverriding(e[0]))},this.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=j((()=>App||global.App)),this.originalPage=j((()=>Page||global.Page)),this.originalComponent=j((()=>Component||global.Component)),this.originalBehavior=j((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;this.initOriginalValue(),t.canHook?(this.nativeGrowing(),M().GioApp=j((()=>null!==App&&void 0!==App?App:this.originalApp)),M().GioPage=j((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),M().GioComponent=j((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),M().GioBehavior=j((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(M().GioApp=function(...t){return e.appOverriding(t[0])},M().GioPage=function(...t){return e.pageOverriding(t[0])},M().GioComponent=function(...t){return e.pageOverriding(t[0])})};const i=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new we(this.growingIO),this.pageEffects=new ke(this.growingIO),this.currentPage=new Pe(this.growingIO)}}class Te{constructor(e){var t,n;this.growingIO=e,this.ALLOW_SETTING_KEYS=y(te),this.getStorageKey=(e,t)=>{const{inPlugin:i}=this.growingIO;return`${e===this.growingIO.trackingId?"":e}${le[i?"plugin_"+t:t]}`},this.getGsid=e=>{let t=Number(this._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(this.setGsid(e,1),1):t},this.setGsid=(e,t)=>{let i=Number(t);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[e]=i,10>this._gsid[e]-this._stid[e]||this.saveStorageInfo()},this.initStorageInfo=e=>{const{minipInstance:t}=this.growingIO,i=t.getStorageSync(this.getStorageKey(e,"gsid"));let n=Number(i);(Number.isNaN(n)||n>=1e9||1>n)&&(n=1),this._gsid[e]=n,this._stid[e]=n,n!==i&&t.setStorageSync(this.getStorageKey(e,"gsid"),n)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=Object.assign({},this._gsid),W(e,this.initializedTrackingIds.map((e=>({key:this.getStorageKey(e,"gsid"),value:this._gsid[e]}))))},this.setOriginalSource=(e,t)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=e=>{var t;const{minipInstance:i}=this.growingIO;return null!==(t=j((()=>JSON.parse(i.getStorageSync(this.getStorageKey(e,"originalSource"))))))&&void 0!==t?t:{}},this.getTrackerVds=e=>this.growingIO.trackingId===e?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=e=>{const t=this.initOptions(e);return t.trackingId=e.trackingId,this.growingIO.trackingId=e.trackingId,this.growingIO.vdsConfig=t,t},this.initTrackerHooker=e=>{var t,i;const{platformConfig:n,inPlugin:s,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=e;a||l||"quickapp"===r.platform||(n.canHook=!0),!s||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(t=null==o?void 0:o.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=e=>{var t,i,n,s,r,o;const{projectId:l,dataSourceId:g,appId:u,trackingId:c}=e,d={};return this.ALLOW_SETTING_KEYS.forEach((t=>{const i=te[t].type;(a(i)?i.includes(T(e[t])):T(e[t])===te[t].type)?"ignoreFields"===t?d.ignoreFields=e.ignoreFields.filter((e=>oe.includes(e))):"extraParams"===t?d.extraParams=e.extraParams.filter((e=>ae.includes(e))):(d[t]=e[t],["dataCollect","autotrack"].includes(t)&&!d[t]&&A("已关闭"+se[t],"info")):d[t]=te[t].default})),d.uploadInterval=Math.round(d.uploadInterval),(Number.isNaN(d.uploadInterval)||0>d.uploadInterval||d.uploadInterval>3e3)&&(d.uploadInterval=1e3),d.enableIdMapping&&!d.idMapping&&(d.idMapping=!0,d.idMapping||this.growingIO.userStore.setUserKey(c,"")),P(d,"enableIdMapping"),d.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(d.requestTimeout))&&d.requestTimeout>0||(d.requestTimeout=5e3),(0>d.impressionScale||d.impressionScale>1)&&(d.impressionScale=0),(0>d.keepAlive||d.keepAlive>1440)&&(d.keepAlive=5),(1>d.sessionExpires||d.sessionExpires>1440)&&(d.sessionExpires=-1),Object.assign(Object.assign({},d),{projectId:l,dataSourceId:g,appId:u,trackingId:c,performance:{monitor:null===(i=null===(t=d.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(s=null===(n=d.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(o=null===(r=d.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(e,t,n)=>{var s;const{userStore:r,emitter:o}=this.growingIO,a=this.getTrackerVds(e),l=i(t)&&this.ALLOW_SETTING_KEYS.includes(t),g=l&&typeof n===(null===(s=te[t])||void 0===s?void 0:s.type);if(l&&g){const i=Object.assign({},a);return this.updateVdsConfig(e,Object.assign(Object.assign({},a),{[t]:n})),"dataCollect"===t&&i.dataCollect!==n&&n&&r.setSessionId(e),o.emit(fe,{optionName:t,optionValue:n}),!0}return x("setOption > "+t),!1},this.getOption=(e,t)=>{const i=this.getTrackerVds(e);return t&&S(this.growingIO.vdsConfig,t)?S(i,t)?i[t]:this.growingIO.vdsConfig[t]:_(t)?i:void x("getOption > "+t)},this.updateVdsConfig=(e,t)=>{e===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),t),M().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[e]=Object.assign(Object.assign({},this.growingIO.subInstance[e]),t),M().vdsConfig.subInstance[e]=this.growingIO.subInstance[e])},this.toggleShareOut=e=>{s(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=(e,t)=>{this.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=(e,t)=>{this.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=e=>{const{dataStore:t,uploader:i}=this.growingIO,{dataCollect:n}=this.getTrackerVds(e.trackingId);if(n){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=t.getGsid(e.trackingId),t.setGsid(e.trackingId,e.eventSequenceId+1));const n={};O(e,((e,t)=>{var i;if("element"===t){const t=null!==(i=g(e))&&void 0!==i?i:{};O(t,((e,t)=>{_(e)&&0!==e||(n[t]=e)}))}else _(e)&&0!==e||(n[t]=e)})),this.growingIO.emitter.emit(ce,{composedEvent:n}),i.commitRequest(Object.assign(Object.assign({},n),{requestId:K()}))}},this.eventRefactor=e=>{var t,i;const n=Object.assign(Object.assign({},e),this.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return n.attributes=Object.assign(Object.assign({},null!==(t=n.attributes)&&void 0!==t?t:{}),null!==(i=e.attributes)&&void 0!==i?i:{}),n},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;_(t)||_(i)?this.interceptEvents.push(e):_(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!_(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.buildAppMessageEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(e));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$from:s.from,$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:g(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(u)},this.buildTimelineEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(e));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:g(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(u)},this.buildAddFavorites=(e,t)=>{var i;const n=t[0];let s;2>t.length?1===t.length&&(s=n):s=t[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==s?void 0:s.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(e));l.attributes=Q(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==s?void 0:s.title,$share_path:g(a),$share_query:a[1]})),o(l)},this.trackersExecute=e=>{this.initializedTrackingIds.forEach((t=>{"function"===T(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Oe(this.growingIO).main,this.eventHooks=new _e(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:r,minipInstance:l}=this.growingIO;r.on(Se,(({trackingId:e})=>{this.initializedTrackingIds.push(e),this.initStorageInfo(e)})),r.on(ue,(({eventData:e,trackingId:t})=>{"VISIT"===e.eventType&&(this.lastVisitEvent[t]=e),"PAGE"===e.eventType&&(this.lastPageEvent[t]=e)})),o(null===(t=l.minip)||void 0===t?void 0:t.onAppHide)&&l.minip.onAppHide((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];O(t,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),o(null===(n=l.minip)||void 0===n?void 0:n.onAppShow)&&l.minip.onAppShow((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];O(t,(e=>{e.start&&(e.start=+Date.now())}))}))})),r.on(fe,(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.trackersExecute((e=>{this.growingIO.clearTrackTimer(e)}))})),this.growingIO.emitter.on(ye,(({oldSessionId:e,trackingId:t})=>{if(e){const{getPagePath:e,getPageQuery:i}=this.eventHooks.currentPage,n=e(),s=i();if(n)this.sendVisit(t,{path:n,query:s});else{const e=this.lastPageEvent[t];this.sendVisit(t,{path:e.path,query:e.query})}this.eventHooks.currentPage.lifeBeforeShow||this.sendPage(t)}}))}get scene(){return this._scene}set scene(e){const t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})}}const Ee={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},Ce=Object.assign(Object.assign({},Ee),{listeners:Object.assign({},Ee.listeners),name:"Baidu",platform:"baidup",scnPrefix:"baidup_"});class Ae{constructor(e){this.growingIO=e,this.minip=V("swan"),this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBarTitle,i=this;t&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return t.apply(this,arguments)}})},this.navigateTo=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateTo(e)},this.switchTab=e=>{var t;null===(t=this.minip)||void 0===t||t.switchTab(e)},this.navigateToMiniProgram=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateToMiniProgram(e)},this.getImageInfo=({src:e,success:t,fail:i,complete:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:e,success:t,fail:i,complete:n})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"observeAll")},this.getCurrentPage=()=>j((()=>u(getCurrentPages())))||{},this.getCurrentPath=()=>{const e=this.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=e=>{var t;const n=G();let s="",r=F(n);"string"===T(r)&&(r=null!==(t=j((()=>JSON.parse(r))))&&void 0!==t?t:{});const o=(null==e?void 0:e.data)||e.$data||{};if(s=i(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",r){const{enterParams:t}=this.growingIO.dataStore.eventHooks.appEffects;e.route||_(t)||(e.route=t.path||"",s=this._getTitleFromTabBar(r,e.route)),j((()=>{var t,i,o,a,l,g;if(!s){const u=r.page||{},c=u[e.route]||u[e.route+".html"];s=c?null===(t=null==c?void 0:c.window)||void 0===t?void 0:t.navigationBarTitleText:["wx","tt"].includes(n)?null===(a=null===(o=null===(i=r||global||$global)||void 0===i?void 0:i.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=r||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),s||(s=this._getTitleFromTabBar(r,e.route))}return N(s)},this._getTitleFromTabBar=(e,t)=>{var i,n;const s=null===(n=null===(i=null==e?void 0:e.tabBar)||void 0===i?void 0:i.list)||void 0===n?void 0:n.find((e=>e.pagePath===t||e.pagePath===t+".html"));return(null==s?void 0:s.text)||""},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return r(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=e=>new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:e,success:({data:e})=>t(e),fail:()=>t("")})})),this.setStorageSync=(e,t,i)=>{var n;i&&(t={value:t,expiredAt:i}),null===(n=this.minip)||void 0===n||n.setStorageSync(e,t)},this.setStorage=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync(e)},this.removeStorage=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorage(e)},this.getNetworkType=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))},this.request=({url:e,data:t,header:i,timeout:n,method:s,success:r,fail:a,complete:l})=>{var g;const u=null===(g=this.minip)||void 0===g?void 0:g.request({url:e,data:t,header:i,timeout:n,method:s,success:r,fail:a,complete:l});let c=setTimeout((()=>{(null==u?void 0:u.abort)&&o(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(c),c=null}),(n||1e4)+10);return u},this.getSystemInfo=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{e.systemInfo=i,t(i)},fail:()=>t(null)})}))},this.getSetting=()=>new Promise((e=>{var t;null===(t=this.minip)||void 0===t||t.getSetting({success:e,fail:e})}));const{platformConfig:{platform:t,scnPrefix:n}}=this.growingIO;this.platform=t,this.scnPrefix=n,this.growingIO.emitter.on(Ie,(()=>{this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))}}class xe extends Ae{constructor(e){super(e),this.growingIO=e,this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"selectAll")},this.hookSetTitle()}}const je=["gioPerformance"];class qe{constructor(e){var t,i,n,s,r,a;this.growingIO=e,this.innerPluginInit=()=>{var e;je.forEach((e=>{var t;return P(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins,e)})),y(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins).forEach((e=>{var t,i;const{name:n,method:s}=null!==(i=null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==i?i:{};h(this.pluginItems,(e=>e.name===n))||this.pluginItems.push({name:m(n||e),method:s||(e=>{})})})),_(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var n,s;const{emitter:r}=this.growingIO,o=t||h(this.pluginItems,(t=>t.name===e));if((null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[e])return A(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return A(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return(null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[e]=new o.method(this.growingIO,i),t&&(r.emit(pe,e),A("加载插件 "+e,"info")),!0}catch(i){return this.lifeError(t,i),A(`插件【${e}】加载异常 ${i}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>{this.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!h(this.pluginItems,(e=>e.name===t.name))&&this.pluginItems.push({name:m(t.name),method:t.method?t.method:()=>{}})}))},this.uninstall=e=>{var t;P(this.pluginItems,e);const i=P(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||A(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>{this.growingIO.emitter.emit(he,{plugin:e,error:t}),A(`插件执行错误 ${e.name} ${t}`,"error")},this.callLifeCycle=(e,t)=>{this.pluginItems.forEach((i=>{const n=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][e]:void 0;if(n&&o(n))try{n(t)}catch(e){this.lifeError(i,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(pe,(e=>this.callLifeCycle("onInstall",e))),null===(i=this.growingIO.emitter)||void 0===i||i.on(he,(e=>this.callLifeCycle("onError",e))),null===(n=this.growingIO.emitter)||void 0===n||n.on(de,(e=>this.callLifeCycle("onComposeBefore",e))),null===(s=this.growingIO.emitter)||void 0===s||s.on(ce,(e=>this.callLifeCycle("onComposeAfter",e))),null===(r=this.growingIO.emitter)||void 0===r||r.on(me,(e=>this.callLifeCycle("onSendBefore",e))),null===(a=this.growingIO.emitter)||void 0===a||a.on(ve,(e=>this.callLifeCycle("onSendAfter",e)))}}var Ne={},Ue={}.hasOwnProperty;function De(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Ke(e){try{return encodeURIComponent(e)}catch(e){return null}}Ne.stringify=function(e,t){t=t||"";var i,n,s=[];for(n in"string"!=typeof t&&(t="?"),e)if(Ue.call(e,n)){if((i=e[n])||null!=i&&!isNaN(i)||(i=""),n=Ke(n),i=Ke(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?t+s.join("&"):""},Ne.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,n={};t=i.exec(e);){var s=De(t[1]),r=De(t[2]);null===s||null===r||s in n||(n[s]=r)}return n};class Le{constructor(e){this.growingIO=e,this.generateURL=e=>{const{serverUrl:t,projectId:i}=this.growingIO.dataStore.getTrackerVds(e);return f(t,"http")?`${t}/v3/projects/${i}/collect`:`https://${t}/v3/projects/${i}/collect`},this.getHoardingQueue=e=>{var t;return null!==(t=this.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=e=>{var t;return null!==(t=this.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=e=>{var i,n;const s=Object.assign({},e),{vdsConfig:r,emitter:o}=this.growingIO;o.emit(ue,{eventData:e,trackingId:e.trackingId}),r.forceLogin?(t(this.hoardingQueue[e.trackingId])&&(this.hoardingQueue[e.trackingId]=[]),null===(i=this.hoardingQueue[e.trackingId])||void 0===i||i.push(s)):(t(this.requestQueue[e.trackingId])&&(this.requestQueue[e.trackingId]=[]),null===(n=this.requestQueue[e.trackingId])||void 0===n||n.push(s),this.initiateRequest(e.trackingId))},this.initiateRequest=(e,t)=>{const{plugins:i,vdsConfig:n,minipInstance:s,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(e),...this.getRequestQueue(e)],a=e=>{var a,l;if(null===(a=null==n?void 0:n.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(e);else if(t)this.batchInvoke(e);else{const{uploadInterval:t}=this.growingIO.dataStore.getTrackerVds(e);k(this.batchInvoke,t,!1,!1)(e)}o.some((e=>"VISIT"===e.eventType))&&s.removeStorageSync(r.getStorageKey(e,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(e);else{let t=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(e),clearInterval(t),t=void 0)}),500)}},this.batchInvoke=e=>{const{vdsConfig:t,emitter:i}=this.growingIO,n=this.getHoardingQueue(e),s=this.getRequestQueue(e);let r=[...n,...s];r.length>50?(r=r.slice(0,50),n.length>50?this.hoardingQueue[e]=n.slice(50):(this.requestQueue[e]=s.slice(50-n.length),this.hoardingQueue[e]=[])):(this.hoardingQueue[e]=[],this.requestQueue[e]=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(_(o))return;const a=o.map((e=>{const t=Object.assign({},e);return P(t,["requestId","trackingId"]),t}));t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(me,{eventsQueue:o,requestData:a,trackingId:e})},this.sendEvent=(e,t)=>{var i;const n=g(e).trackingId,{minipInstance:s,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:u}=r.getTrackerVds(n);this.requestingNum+=1;const c={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let d=[...t];const h=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);h&&(d=a.gioCompress.compressToUTF16(JSON.stringify(t)),c["X-Compress-Codec"]="1");const p=this.generateURL(n);s.request({url:`${p}?stm=${Date.now()}&compress=${h?"1":"0"}`,header:c,method:"POST",data:d,timeout:u,fail:t=>{[200,204].includes(t.code)||(e.forEach((e=>{this.requestFailFn(e)})),A("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,o.emit(ve,{result:e,requestData:t}),this.initiateRequest(n)}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue[e.trackingId].some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{_(this.requestQueue[e.trackingId])?(this.requestQueue[e.trackingId].push(e),this.initiateRequest(e.trackingId)):this.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:i,vdsConfig:n,plugins:s}=this.growingIO;i.on(me,(({eventsQueue:e,requestData:t,trackingId:i})=>{var r,o;i===this.growingIO.trackingId&&((null===(r=null==n?void 0:n.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(e,t):this.sendEvent(e,t))}))}}class He{constructor(e){this.growingIO=e,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:e}=this.growingIO;return this._uid||(this._uid=e.getStorageSync(this._getUidKey())),this._uid||(this._uid=K(),e.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=e=>{const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))},this.getSessionId=e=>{const{vdsConfig:{sessionExpires:t},dataStore:{trackersExecute:i}}=this.growingIO;return this._sessionId[e]||this.setSessionId(e),t>-1&&(Date.now()>this._sessionExpires&&i((e=>{this.setSessionId(e)})),this._sessionExpires=Date.now()+6e4*t),this._sessionId[e]},this.setSessionId=(e,t)=>{const i=this._sessionId[e];t||(t=K()),this._sessionId[e]=t;const{sessionExpires:n}=this.growingIO.vdsConfig;n>-1&&(this._sessionExpires=Date.now()+6e4*n),i!==t&&this.growingIO.emitter.emit(ye,{trackingId:e,newSessionId:t,oldSessionId:i})},this._getUserIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"userId"),this.getUserId=e=>{const{minipInstance:t}=this.growingIO;return this._userId[e]||(this._userId[e]=t.getStorageSync(this._getUserIdKey(e))),this._userId[e]},this.setUserId=(e,i)=>{const n=this._userId[e];this._userId[e]=t(i)?"":i,n!==this._userId[e]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(e),this._userId[e]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:i,oldUserId:n})),i&&this.setGioId(e,i)},this._getUserKeyKey=e=>this.growingIO.dataStore.getStorageKey(e,"userKey"),this.getUserKey=e=>{const{minipInstance:t}=this.growingIO;return this._userKey[e]||(this._userKey[e]=t.getStorageSync(this._getUserKeyKey(e))),this._userKey[e]},this.setUserKey=(e,i)=>{const n=this._userKey[e];this._userKey[e]=t(i)?"":i,n!==this._userKey[e]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(e),this._userKey[e]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:i,oldUserKey:n}))},this._getGioIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"gioId"),this.getGioId=e=>{const{minipInstance:t}=this.growingIO;return this._gioId[e]||(this._gioId[e]=t.getStorageSync(this._getGioIdKey(e))),this._gioId[e]},this.setGioId=(e,i)=>{const n=this._gioId[e];this._gioId[e]=t(i)?"":i,n!==this._gioId[e]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(e),this._gioId[e]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:i,oldGioId:n}))},this.initUserInfo=e=>{var t;const{minipInstance:i}=this.growingIO,n=[this._getUidKey(),this._getUserIdKey(e),this._getUserKeyKey(e),this._getGioIdKey(e)],s=null!==(t=z(i,n))&&void 0!==t?t:[];["_uid","_userId","_userKey","_gioId"].forEach(((t,i)=>{"_uid"===t?this.getUid():this[t][e]=s[i]}))},this.saveUserInfo=()=>{const{minipInstance:e,dataStore:{trackersExecute:t}}=this.growingIO;t((t=>{W(e,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(t),value:this._userId[t]},{key:this._getUserKeyKey(t),value:this._userKey[t]},{key:this._getGioIdKey(t),value:this._gioId[t]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={},this._sessionExpires=-1}}const $e=new class{constructor(){var e;this.init=e=>{var t;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(A("Gio小程序SDK 初始化中...","info"),e.trackingId&&this.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error(`已存在实例 ${e.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(e);return null===(t=this.emitter)||void 0===t||t.emit(Ie,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(e.trackingId),this.emitter.emit(Se,i),this.trackingId&&this.trackingId!==e.trackingId||(M().__gio__=()=>this),A("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&A("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return A(e,"error"),!1}},this.handlerDistribute=(e,t,i)=>{const{initializedTrackingIds:n,getTrackerVds:s}=this.dataStore;if(s(e)&&n.includes(e))return this[t](e,...i);A(`不存在实例:${e},请检查!`,"warn")},this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(e,t)=>this.dataStore.getOption(e,t),this.setOption=(e,t,i)=>{var n;return y(se).includes(t)?typeof i===(null===(n=te[t])||void 0===n?void 0:n.type)?(this.dataStore.setOption(e,t,i),A(`已修改${se[t]}: ${i}`,"info"),!0):(A(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(A(`不存在可修改的配置项:${t},请检查后重试!`,"error"),!1)},this.setPageAttributes=(e,t)=>{if(r(t)&&!_(t)){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();return _(i.pageProps[e])&&(i.pageProps[e]={}),_(i.pageProps[e][n])&&(i.pageProps[e][n]={}),_(t)||O(t,((t,s)=>{o(i.pageProps[e][n][s])&&!o(t)||(i.pageProps[e][n][s]=t)})),!0}return x("setPageAttributes"),!1},this.clearPageAttributes=(e,t)=>{try{if(!_(this.dataStore.eventHooks.currentPage.pageProps[e])){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();a(t)&&!_(t)?t.forEach((t=>{P(i.pageProps[e][n],t)})):i.pageProps[e][n]={}}}catch(e){return x("clearPageAttributes"),!1}},this.sendPage=(e,t)=>{const{trackPage:i}=this.dataStore.getTrackerVds(e);i?A("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(e,t)},this.identify=(e,t)=>{if(e===this.trackingId)if(this.vdsConfig.forceLogin){if(!ee(t))return void x("identify");const e=p(t).slice(0,1e3);this.userStore.setUid(e),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((t=>{const i=this.uploader.getHoardingQueue(t);i.forEach(((t,n)=>i[n].deviceId=e)),this.uploader.initiateRequest(t,!0)}))}else x("identify",!1,"forceLogin未开启");else x("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(e,t)=>{var i,n,s,o;if(r(t)&&!_(t)){const{eventContextBuilder:r,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},r(e));g.attributes=Q(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),D(t))),g.path||(g.path=null===(n=l[e])||void 0===n?void 0:n.path,g.query=null===(s=l[e])||void 0===s?void 0:s.query,g.title=null===(o=l[e])||void 0===o?void 0:o.title),a(g)}else x("setUserAttributes")},this.setUserId=(e,i,n)=>{if(ee(i)){const s=this.userStore.getGioId(e);i=p(i).slice(0,1e3),n=p(n).slice(0,1e3),this.userStore.setUserId(e,i);const{idMapping:r}=this.dataStore.getTrackerVds(e);r&&this.userStore.setUserKey(e,t(n)?"":n),s&&s!==i&&this.userStore.setSessionId(e)}else x("setUserId")},this.clearUserId=e=>{this.userStore.setUserId(e,void 0),this.userStore.setUserKey(e,void 0)},this.setGeneralProps=(e,t)=>r(t)&&!_(t)?(_(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]={}),O(t,((t,i)=>{o(this.dataStore.generalProps[e][i])&&!o(t)||(this.dataStore.generalProps[e][i]=t)})),!0):(x("setGeneralProps"),!1),this.clearGeneralProps=(e,t)=>{try{_(this.dataStore.generalProps[e])||(a(t)&&!_(t)?t.forEach((t=>{P(this.dataStore.generalProps[e],t)})):this.dataStore.generalProps[e]={})}catch(e){return x("clearGeneralProps"),!1}},this.track=(e,t,i)=>{U(t,(()=>{var n;const{eventContextBuilder:s,eventInterceptor:o}=this.dataStore,a=Object.assign({eventType:"CUSTOM",eventName:t},s(e));a.attributes=Q(Object.assign(Object.assign({},null!==(n=a.attributes)&&void 0!==n?n:{}),D(Object.assign({},r(i)&&!_(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(a["&&sendTo"]=i["&&sendTo"]),o(a)}))},this.trackTimerStart=(e,t)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(e);return i?U(t,(()=>{const i=K();return this.dataStore.trackTimers[e]||(this.dataStore.trackTimers[e]={}),this.dataStore.trackTimers[e][i]={eventName:t,leng:0,start:+Date.now()},i})):(A("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return e.start&&(e.leng=e.leng+(+Date.now()-e.start)),e.start=0,!0}return!1},this.trackTimerResume=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return 0===e.start&&(e.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t,i)=>{var n;const{dataCollect:s}=this.dataStore.getTrackerVds(e),o=this.dataStore.trackTimers[e];if(t&&o&&o[t]){if(s){const s=864e5,a=o[t];if(0!==a.start){const e=+Date.now()-a.start;a.leng=e>0?a.leng+e:0}const{eventContextBuilder:l,eventInterceptor:g}=this.dataStore,u=Object.assign({eventType:"CUSTOM",eventName:a.eventName},l(e));return u.attributes=Q(Object.assign(Object.assign({},null!==(n=u.attributes)&&void 0!==n?n:{}),D(Object.assign(Object.assign({},r(i)&&!_(i)?i:{}),{event_duration:a.leng>s?0:a.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(u["&&sendTo"]=i["&&sendTo"]),g(u),!0}return A("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return A("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(e,t)=>{const i=this.dataStore.trackTimers[e];return t&&i&&i[t]?(delete i[t],!0):(A("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=e=>{this.dataStore.trackTimers[e]={}},this.setLocation=(e,t,i)=>{_(this.dataStore.locationData[e])&&(this.dataStore.locationData[e]={});const n=this.dataStore.locationData[e],s=e=>e>=-180&&180>=e;s(t)&&s(i)&&(n.latitude!==t||n.longitude!==i)&&(this.dataStore.locationData[e]={latitude:t,longitude:i})},this.updateImpression=()=>{A("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(e,t,i)=>{A("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),q(i,{})},this.getGioInfo=e=>{const{getUid:t,getUserId:i,getUserKey:n,getSessionId:s}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(e),d={gioappid:o,giocs1:i(e)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:s(e),giou:t()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=n(e)),_(u)||u.forEach((t=>{var i;c.includes(t)||(d["gio"+t]=(null!==(i=this.dataStore.lastVisitEvent[e])&&void 0!==i?i:{})[t])})),Ne.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},C),X),{qs:Ne}),this.emitter={all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map((function(e){e(i)})),(n=e.get("*"))&&n.slice().map((function(e){e(t,i)}))}},this.gioPlatform="swan",this.gioFramework="native",this.sdkVersion="4.3.2";try{"quickapp"===this.gioPlatform||o(getApp)&&o(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&A("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Ce,this.minipInstance=new xe(this),this.dataStore=new Te(this),this.userStore=new He(this),this.uploader=new Le(this),this.plugins=new qe(this),this.plugins.innerPluginInit()}},Re=function(){var e;const t=arguments[0];let n="g0",s=t;if(t.indexOf(".")>-1&&(n=null!==(e=t.split(".")[0])&&void 0!==e?e:"g0",s=t.split(".")[1]),i(s)&&ne.includes(s)&&$e[s]){const e=c(Array.from(arguments));if("init"===s){const t=((e,t)=>{const i=p(t[0]),n=p(t[1]),s=(4===t.length?t[3]:t[2])||{};return i&&n?e.dataStore.initializedTrackingIds.some(((t,s)=>{const r=0===s?e.vdsConfig:e.subInstance[t];return r.projectId===i&&r.dataSourceId===n}))?(A("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:n,appId:p(4===t.length?t[2]:""),userOptions:s}:(A('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})($e,e);if(t){const{projectId:e,dataSourceId:i,appId:s,userOptions:r}=t;return $e.init(Object.assign(Object.assign({},r),{projectId:e,dataSourceId:i,appId:s,trackingId:n}))}return!1}if("registerPlugins"===s)$e.registerPlugins(e[0]);else{if($e.gioSDKInitialized&&$e.vdsConfig)return ie.includes(s)?j((()=>$e.handlerDistribute(n,s,e))):j((()=>$e[s](...e)));A("SDK未初始化!","error")}}else if(re.includes(s))A(`方法 ${p(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return ne.includes(arguments[1])&&!!$e[arguments[1]];A(`不存在名为 ${p(s)} 的方法调用!`,"error")}};M().gdp=Re,M().gioSDKVersion=$e.sdkVersion;const{growingApp:Be,growingPage:Ve,growingComponent:Fe,growingBehavior:Ge,initOriginalValue:Me}=$e.dataStore.eventHooks;Me();const Qe=j((()=>null!=Be?Be:App)),ze=j((()=>null!=Ve?Ve:Page)),We=j((()=>null!=Fe?Fe:Component)),Je=j((()=>null!=Ge?Ge:Behavior));export{Qe as GioApp,Je as GioBehavior,We as GioComponent,ze as GioPage,Re as default};