gio-miniprogram-sdk 4.2.0 → 4.3.1

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